@putout/bundle 5.3.0 → 5.3.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/bundle/putout.js +2651 -457
- package/bundle/putout.min.js +3 -3
- package/bundle/putout.slim.js +2651 -457
- package/package.json +2 -2
package/bundle/putout.slim.js
CHANGED
|
@@ -3236,7 +3236,7 @@ __export(lib_exports, {
|
|
|
3236
3236
|
isExportNamespaceSpecifier: () => isExportNamespaceSpecifier$1,
|
|
3237
3237
|
isExportSpecifier: () => isExportSpecifier$1,
|
|
3238
3238
|
isExpression: () => isExpression$2,
|
|
3239
|
-
isExpressionStatement: () => isExpressionStatement$
|
|
3239
|
+
isExpressionStatement: () => isExpressionStatement$b,
|
|
3240
3240
|
isExpressionWrapper: () => isExpressionWrapper,
|
|
3241
3241
|
isFile: () => isFile$2,
|
|
3242
3242
|
isFlow: () => isFlow,
|
|
@@ -3443,7 +3443,7 @@ __export(lib_exports, {
|
|
|
3443
3443
|
isThisTypeAnnotation: () => isThisTypeAnnotation,
|
|
3444
3444
|
isThrowStatement: () => isThrowStatement,
|
|
3445
3445
|
isTopicReference: () => isTopicReference,
|
|
3446
|
-
isTryStatement: () => isTryStatement,
|
|
3446
|
+
isTryStatement: () => isTryStatement$1,
|
|
3447
3447
|
isTupleTypeAnnotation: () => isTupleTypeAnnotation,
|
|
3448
3448
|
isType: () => isType,
|
|
3449
3449
|
isTypeAlias: () => isTypeAlias,
|
|
@@ -3537,7 +3537,7 @@ __export(lib_exports, {
|
|
|
3537
3537
|
spreadElement: () => spreadElement,
|
|
3538
3538
|
spreadProperty: () => SpreadProperty,
|
|
3539
3539
|
staticBlock: () => staticBlock,
|
|
3540
|
-
stringLiteral: () => stringLiteral$
|
|
3540
|
+
stringLiteral: () => stringLiteral$6,
|
|
3541
3541
|
stringLiteralTypeAnnotation: () => stringLiteralTypeAnnotation,
|
|
3542
3542
|
stringTypeAnnotation: () => stringTypeAnnotation,
|
|
3543
3543
|
super: () => _super,
|
|
@@ -5284,7 +5284,7 @@ function isEmptyStatement(node, opts) {
|
|
|
5284
5284
|
return opts == null || shallowEqual(node, opts);
|
|
5285
5285
|
}
|
|
5286
5286
|
|
|
5287
|
-
function isExpressionStatement$
|
|
5287
|
+
function isExpressionStatement$b(node, opts) {
|
|
5288
5288
|
if (!node)
|
|
5289
5289
|
return false;
|
|
5290
5290
|
|
|
@@ -5574,7 +5574,7 @@ function isThrowStatement(node, opts) {
|
|
|
5574
5574
|
return opts == null || shallowEqual(node, opts);
|
|
5575
5575
|
}
|
|
5576
5576
|
|
|
5577
|
-
function isTryStatement(node, opts) {
|
|
5577
|
+
function isTryStatement$1(node, opts) {
|
|
5578
5578
|
if (!node)
|
|
5579
5579
|
return false;
|
|
5580
5580
|
|
|
@@ -9554,7 +9554,7 @@ function defineType$5(type, opts = {}) {
|
|
|
9554
9554
|
store[type] = opts;
|
|
9555
9555
|
}
|
|
9556
9556
|
|
|
9557
|
-
var utils$
|
|
9557
|
+
var utils$6 = /* @__PURE__ */Object.freeze({
|
|
9558
9558
|
__proto__: null,
|
|
9559
9559
|
ALIAS_KEYS,
|
|
9560
9560
|
BUILDER_KEYS,
|
|
@@ -13479,7 +13479,7 @@ var _validate = /* @__PURE__ */Object.freeze({
|
|
|
13479
13479
|
|
|
13480
13480
|
var {validateInternal: validate$3} = _validate;
|
|
13481
13481
|
|
|
13482
|
-
var {NODE_FIELDS} = utils$
|
|
13482
|
+
var {NODE_FIELDS} = utils$6;
|
|
13483
13483
|
|
|
13484
13484
|
function arrayExpression$3(elements) {
|
|
13485
13485
|
const node = {
|
|
@@ -13791,7 +13791,7 @@ function labeledStatement(label, body) {
|
|
|
13791
13791
|
return node;
|
|
13792
13792
|
}
|
|
13793
13793
|
|
|
13794
|
-
function stringLiteral$
|
|
13794
|
+
function stringLiteral$6(value) {
|
|
13795
13795
|
const node = {
|
|
13796
13796
|
type: 'StringLiteral',
|
|
13797
13797
|
value,
|
|
@@ -16682,7 +16682,7 @@ var b = /* @__PURE__ */Object.freeze({
|
|
|
16682
16682
|
spreadElement,
|
|
16683
16683
|
spreadProperty: SpreadProperty,
|
|
16684
16684
|
staticBlock,
|
|
16685
|
-
stringLiteral: stringLiteral$
|
|
16685
|
+
stringLiteral: stringLiteral$6,
|
|
16686
16686
|
stringLiteralTypeAnnotation,
|
|
16687
16687
|
stringTypeAnnotation,
|
|
16688
16688
|
super: _super,
|
|
@@ -17079,7 +17079,7 @@ function cleanJSXElementLiteralChild(child, args) {
|
|
|
17079
17079
|
}
|
|
17080
17080
|
|
|
17081
17081
|
if (str)
|
|
17082
|
-
args.push(inherits(stringLiteral$
|
|
17082
|
+
args.push(inherits(stringLiteral$6(str), child));
|
|
17083
17083
|
}
|
|
17084
17084
|
|
|
17085
17085
|
function buildChildren(node) {
|
|
@@ -18854,13 +18854,13 @@ function toBindingIdentifierName(name) {
|
|
|
18854
18854
|
|
|
18855
18855
|
function toComputedKey(node, key = node.key || node.property) {
|
|
18856
18856
|
if (!node.computed && isIdentifier$h(key))
|
|
18857
|
-
key = stringLiteral$
|
|
18857
|
+
key = stringLiteral$6(key.name);
|
|
18858
18858
|
|
|
18859
18859
|
return key;
|
|
18860
18860
|
}
|
|
18861
18861
|
|
|
18862
18862
|
function toExpression$1(node) {
|
|
18863
|
-
if (isExpressionStatement$
|
|
18863
|
+
if (isExpressionStatement$b(node)) {
|
|
18864
18864
|
node = node.expression;
|
|
18865
18865
|
}
|
|
18866
18866
|
|
|
@@ -19064,7 +19064,7 @@ function valueToNode(value) {
|
|
|
19064
19064
|
}
|
|
19065
19065
|
|
|
19066
19066
|
if (typeof value === 'string') {
|
|
19067
|
-
return stringLiteral$
|
|
19067
|
+
return stringLiteral$6(value);
|
|
19068
19068
|
}
|
|
19069
19069
|
|
|
19070
19070
|
if (typeof value === 'number') {
|
|
@@ -19119,12 +19119,12 @@ function valueToNode(value) {
|
|
|
19119
19119
|
if (isValidIdentifier(key)) {
|
|
19120
19120
|
if (key === '__proto__') {
|
|
19121
19121
|
computed = true;
|
|
19122
|
-
nodeKey = stringLiteral$
|
|
19122
|
+
nodeKey = stringLiteral$6(key);
|
|
19123
19123
|
} else {
|
|
19124
19124
|
nodeKey = identifier$2(key);
|
|
19125
19125
|
}
|
|
19126
19126
|
} else {
|
|
19127
|
-
nodeKey = stringLiteral$
|
|
19127
|
+
nodeKey = stringLiteral$6(key);
|
|
19128
19128
|
}
|
|
19129
19129
|
|
|
19130
19130
|
props.push(objectProperty$3(nodeKey, valueToNode(value[key]), computed));
|
|
@@ -20523,14 +20523,6 @@ var estree = (superClass) => class ESTreeParserMixin extends superClass {
|
|
|
20523
20523
|
return node;
|
|
20524
20524
|
}
|
|
20525
20525
|
|
|
20526
|
-
toReferencedArguments(node) {
|
|
20527
|
-
if (node.type === 'ImportExpression') {
|
|
20528
|
-
return;
|
|
20529
|
-
}
|
|
20530
|
-
|
|
20531
|
-
super.toReferencedArguments(node);
|
|
20532
|
-
}
|
|
20533
|
-
|
|
20534
20526
|
parseExport(unfinished, decorators) {
|
|
20535
20527
|
const exportStartLoc = this.state.lastTokStartLoc;
|
|
20536
20528
|
const node = super.parseExport(unfinished, decorators);
|
|
@@ -23054,7 +23046,7 @@ var jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
23054
23046
|
|
|
23055
23047
|
do {
|
|
23056
23048
|
ch = this.input.charCodeAt(++this.state.pos);
|
|
23057
|
-
} while (isIdentifierChar2(ch) || ch === 45)
|
|
23049
|
+
} while (isIdentifierChar2(ch) || ch === 45);
|
|
23058
23050
|
this.finishToken(136, this.input.slice(start, this.state.pos));
|
|
23059
23051
|
}
|
|
23060
23052
|
|
|
@@ -23813,7 +23805,7 @@ var CommentsParser = class extends BaseParser {
|
|
|
23813
23805
|
};
|
|
23814
23806
|
|
|
23815
23807
|
var State$2 = class _State {
|
|
23816
|
-
flags =
|
|
23808
|
+
flags = 512;
|
|
23817
23809
|
get strict() {
|
|
23818
23810
|
return (this.flags & 1) > 0;
|
|
23819
23811
|
}
|
|
@@ -23843,107 +23835,96 @@ var State$2 = class _State {
|
|
|
23843
23835
|
potentialArrowAt = -1;
|
|
23844
23836
|
noArrowAt = [];
|
|
23845
23837
|
noArrowParamsConversionAt = [];
|
|
23846
|
-
get
|
|
23838
|
+
get inType() {
|
|
23847
23839
|
return (this.flags & 2) > 0;
|
|
23848
23840
|
}
|
|
23849
23841
|
|
|
23850
|
-
set
|
|
23842
|
+
set inType(v) {
|
|
23851
23843
|
if (v)
|
|
23852
23844
|
this.flags |= 2;
|
|
23853
23845
|
else
|
|
23854
23846
|
this.flags &= -3;
|
|
23855
23847
|
}
|
|
23856
23848
|
|
|
23857
|
-
get
|
|
23849
|
+
get noAnonFunctionType() {
|
|
23858
23850
|
return (this.flags & 4) > 0;
|
|
23859
23851
|
}
|
|
23860
23852
|
|
|
23861
|
-
set
|
|
23853
|
+
set noAnonFunctionType(v) {
|
|
23862
23854
|
if (v)
|
|
23863
23855
|
this.flags |= 4;
|
|
23864
23856
|
else
|
|
23865
23857
|
this.flags &= -5;
|
|
23866
23858
|
}
|
|
23867
23859
|
|
|
23868
|
-
get
|
|
23860
|
+
get hasFlowComment() {
|
|
23869
23861
|
return (this.flags & 8) > 0;
|
|
23870
23862
|
}
|
|
23871
23863
|
|
|
23872
|
-
set
|
|
23864
|
+
set hasFlowComment(v) {
|
|
23873
23865
|
if (v)
|
|
23874
23866
|
this.flags |= 8;
|
|
23875
23867
|
else
|
|
23876
23868
|
this.flags &= -9;
|
|
23877
23869
|
}
|
|
23878
23870
|
|
|
23879
|
-
get
|
|
23871
|
+
get isAmbientContext() {
|
|
23880
23872
|
return (this.flags & 16) > 0;
|
|
23881
23873
|
}
|
|
23882
23874
|
|
|
23883
|
-
set
|
|
23875
|
+
set isAmbientContext(v) {
|
|
23884
23876
|
if (v)
|
|
23885
23877
|
this.flags |= 16;
|
|
23886
23878
|
else
|
|
23887
23879
|
this.flags &= -17;
|
|
23888
23880
|
}
|
|
23889
23881
|
|
|
23890
|
-
get
|
|
23882
|
+
get inAbstractClass() {
|
|
23891
23883
|
return (this.flags & 32) > 0;
|
|
23892
23884
|
}
|
|
23893
23885
|
|
|
23894
|
-
set
|
|
23886
|
+
set inAbstractClass(v) {
|
|
23895
23887
|
if (v)
|
|
23896
23888
|
this.flags |= 32;
|
|
23897
23889
|
else
|
|
23898
23890
|
this.flags &= -33;
|
|
23899
23891
|
}
|
|
23900
23892
|
|
|
23901
|
-
get
|
|
23893
|
+
get inDisallowConditionalTypesContext() {
|
|
23902
23894
|
return (this.flags & 64) > 0;
|
|
23903
23895
|
}
|
|
23904
23896
|
|
|
23905
|
-
set
|
|
23897
|
+
set inDisallowConditionalTypesContext(v) {
|
|
23906
23898
|
if (v)
|
|
23907
23899
|
this.flags |= 64;
|
|
23908
23900
|
else
|
|
23909
23901
|
this.flags &= -65;
|
|
23910
23902
|
}
|
|
23911
23903
|
|
|
23912
|
-
get inDisallowConditionalTypesContext() {
|
|
23913
|
-
return (this.flags & 128) > 0;
|
|
23914
|
-
}
|
|
23915
|
-
|
|
23916
|
-
set inDisallowConditionalTypesContext(v) {
|
|
23917
|
-
if (v)
|
|
23918
|
-
this.flags |= 128;
|
|
23919
|
-
else
|
|
23920
|
-
this.flags &= -129;
|
|
23921
|
-
}
|
|
23922
|
-
|
|
23923
23904
|
topicContext = {
|
|
23924
23905
|
maxNumOfResolvableTopics: 0,
|
|
23925
23906
|
maxTopicIndex: null,
|
|
23926
23907
|
};
|
|
23927
23908
|
get soloAwait() {
|
|
23928
|
-
return (this.flags &
|
|
23909
|
+
return (this.flags & 128) > 0;
|
|
23929
23910
|
}
|
|
23930
23911
|
|
|
23931
23912
|
set soloAwait(v) {
|
|
23932
23913
|
if (v)
|
|
23933
|
-
this.flags |=
|
|
23914
|
+
this.flags |= 128;
|
|
23934
23915
|
else
|
|
23935
|
-
this.flags &= -
|
|
23916
|
+
this.flags &= -129;
|
|
23936
23917
|
}
|
|
23937
23918
|
|
|
23938
23919
|
get inFSharpPipelineDirectBody() {
|
|
23939
|
-
return (this.flags &
|
|
23920
|
+
return (this.flags & 256) > 0;
|
|
23940
23921
|
}
|
|
23941
23922
|
|
|
23942
23923
|
set inFSharpPipelineDirectBody(v) {
|
|
23943
23924
|
if (v)
|
|
23944
|
-
this.flags |=
|
|
23925
|
+
this.flags |= 256;
|
|
23945
23926
|
else
|
|
23946
|
-
this.flags &= -
|
|
23927
|
+
this.flags &= -257;
|
|
23947
23928
|
}
|
|
23948
23929
|
|
|
23949
23930
|
labels = [];
|
|
@@ -23958,37 +23939,37 @@ var State$2 = class _State {
|
|
|
23958
23939
|
lastTokStartLoc = null;
|
|
23959
23940
|
context = [types.brace];
|
|
23960
23941
|
get canStartJSXElement() {
|
|
23961
|
-
return (this.flags &
|
|
23942
|
+
return (this.flags & 512) > 0;
|
|
23962
23943
|
}
|
|
23963
23944
|
|
|
23964
23945
|
set canStartJSXElement(v) {
|
|
23965
23946
|
if (v)
|
|
23966
|
-
this.flags |=
|
|
23947
|
+
this.flags |= 512;
|
|
23967
23948
|
else
|
|
23968
|
-
this.flags &= -
|
|
23949
|
+
this.flags &= -513;
|
|
23969
23950
|
}
|
|
23970
23951
|
|
|
23971
23952
|
get containsEsc() {
|
|
23972
|
-
return (this.flags &
|
|
23953
|
+
return (this.flags & 1024) > 0;
|
|
23973
23954
|
}
|
|
23974
23955
|
|
|
23975
23956
|
set containsEsc(v) {
|
|
23976
23957
|
if (v)
|
|
23977
|
-
this.flags |=
|
|
23958
|
+
this.flags |= 1024;
|
|
23978
23959
|
else
|
|
23979
|
-
this.flags &= -
|
|
23960
|
+
this.flags &= -1025;
|
|
23980
23961
|
}
|
|
23981
23962
|
|
|
23982
23963
|
firstInvalidTemplateEscapePos = null;
|
|
23983
23964
|
get hasTopLevelAwait() {
|
|
23984
|
-
return (this.flags &
|
|
23965
|
+
return (this.flags & 2048) > 0;
|
|
23985
23966
|
}
|
|
23986
23967
|
|
|
23987
23968
|
set hasTopLevelAwait(v) {
|
|
23988
23969
|
if (v)
|
|
23989
|
-
this.flags |=
|
|
23970
|
+
this.flags |= 2048;
|
|
23990
23971
|
else
|
|
23991
|
-
this.flags &= -
|
|
23972
|
+
this.flags &= -2049;
|
|
23992
23973
|
}
|
|
23993
23974
|
|
|
23994
23975
|
strictErrors = /* @__PURE__ */new Map();
|
|
@@ -26448,15 +26429,6 @@ var LValParser = class extends NodeUtils {
|
|
|
26448
26429
|
return exprList;
|
|
26449
26430
|
}
|
|
26450
26431
|
|
|
26451
|
-
toReferencedListDeep(exprList, isParenthesizedExpr) {
|
|
26452
|
-
this.toReferencedList(exprList, isParenthesizedExpr);
|
|
26453
|
-
for (const expr of exprList) {
|
|
26454
|
-
if (expr?.type === 'ArrayExpression') {
|
|
26455
|
-
this.toReferencedListDeep(expr.elements);
|
|
26456
|
-
}
|
|
26457
|
-
}
|
|
26458
|
-
}
|
|
26459
|
-
|
|
26460
26432
|
parseSpread(refExpressionErrors) {
|
|
26461
26433
|
const node = this.startNode();
|
|
26462
26434
|
this.next();
|
|
@@ -28019,7 +27991,7 @@ var typescript$1 = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
28019
27991
|
|
|
28020
27992
|
do {
|
|
28021
27993
|
types2.push(parseConstituentType());
|
|
28022
|
-
} while (this.eat(operator))
|
|
27994
|
+
} while (this.eat(operator));
|
|
28023
27995
|
if (types2.length === 1 && !hasLeadingOperator) {
|
|
28024
27996
|
return types2[0];
|
|
28025
27997
|
}
|
|
@@ -28697,9 +28669,6 @@ var typescript$1 = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
28697
28669
|
if (!this.match(43))
|
|
28698
28670
|
return;
|
|
28699
28671
|
|
|
28700
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
28701
|
-
|
|
28702
|
-
this.state.maybeInArrowParameters = true;
|
|
28703
28672
|
const res = this.tsTryParseAndCatch(() => {
|
|
28704
28673
|
const node = this.startNodeAt(startLoc);
|
|
28705
28674
|
|
|
@@ -28710,8 +28679,6 @@ var typescript$1 = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
28710
28679
|
return node;
|
|
28711
28680
|
});
|
|
28712
28681
|
|
|
28713
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
28714
|
-
|
|
28715
28682
|
if (!res)
|
|
28716
28683
|
return;
|
|
28717
28684
|
|
|
@@ -29396,7 +29363,7 @@ var typescript$1 = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
29396
29363
|
if (!this.match(13))
|
|
29397
29364
|
return expr;
|
|
29398
29365
|
|
|
29399
|
-
if (
|
|
29366
|
+
if (refExpressionErrors != null) {
|
|
29400
29367
|
const nextCh = this.lookaheadCharCode();
|
|
29401
29368
|
|
|
29402
29369
|
if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
|
|
@@ -31296,7 +31263,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
31296
31263
|
do {
|
|
31297
31264
|
base = this.parseSubscript(base, startLoc, noCalls, state);
|
|
31298
31265
|
state.maybeAsyncArrow = false;
|
|
31299
|
-
} while (!state.stop)
|
|
31266
|
+
} while (!state.stop);
|
|
31300
31267
|
|
|
31301
31268
|
return base;
|
|
31302
31269
|
}
|
|
@@ -31383,10 +31350,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
31383
31350
|
}
|
|
31384
31351
|
|
|
31385
31352
|
parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
|
|
31386
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
31387
31353
|
let refExpressionErrors = null;
|
|
31388
|
-
|
|
31389
|
-
this.state.maybeInArrowParameters = true;
|
|
31390
31354
|
this.next();
|
|
31391
31355
|
const node = this.startNodeAt(startLoc);
|
|
31392
31356
|
|
|
@@ -31425,17 +31389,12 @@ var ExpressionParser = class extends LValParser {
|
|
|
31425
31389
|
this.expressionScope.exit();
|
|
31426
31390
|
}
|
|
31427
31391
|
|
|
31428
|
-
this.
|
|
31392
|
+
this.toReferencedList(node.arguments);
|
|
31429
31393
|
}
|
|
31430
31394
|
|
|
31431
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
31432
31395
|
return finishedNode;
|
|
31433
31396
|
}
|
|
31434
31397
|
|
|
31435
|
-
toReferencedArguments(node, isParenthesizedExpr) {
|
|
31436
|
-
this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
|
|
31437
|
-
}
|
|
31438
|
-
|
|
31439
31398
|
parseTaggedTemplateExpression(base, startLoc, state) {
|
|
31440
31399
|
const node = this.startNodeAt(startLoc);
|
|
31441
31400
|
|
|
@@ -31954,10 +31913,8 @@ var ExpressionParser = class extends LValParser {
|
|
|
31954
31913
|
let val;
|
|
31955
31914
|
this.next();
|
|
31956
31915
|
this.expressionScope.enter(newArrowHeadScope());
|
|
31957
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
31958
31916
|
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
|
31959
31917
|
|
|
31960
|
-
this.state.maybeInArrowParameters = true;
|
|
31961
31918
|
this.state.inFSharpPipelineDirectBody = false;
|
|
31962
31919
|
const innerStartLoc = this.state.startLoc;
|
|
31963
31920
|
const exprList = [];
|
|
@@ -32001,7 +31958,6 @@ var ExpressionParser = class extends LValParser {
|
|
|
32001
31958
|
|
|
32002
31959
|
const innerEndLoc = this.state.lastTokEndLoc;
|
|
32003
31960
|
this.expect(7);
|
|
32004
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
32005
31961
|
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
|
|
32006
31962
|
let arrowNode = this.startNodeAt(startLoc);
|
|
32007
31963
|
|
|
@@ -32026,7 +31982,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
32026
31982
|
this.unexpected(spreadStartLoc);
|
|
32027
31983
|
|
|
32028
31984
|
this.checkExpressionErrors(refExpressionErrors, true);
|
|
32029
|
-
this.
|
|
31985
|
+
this.toReferencedList(exprList, true);
|
|
32030
31986
|
|
|
32031
31987
|
if (exprList.length > 1) {
|
|
32032
31988
|
val = this.startNodeAt(innerStartLoc);
|
|
@@ -32472,18 +32428,14 @@ var ExpressionParser = class extends LValParser {
|
|
|
32472
32428
|
|
|
32473
32429
|
this.prodParam.enter(flags);
|
|
32474
32430
|
this.initFunction(node, isAsync);
|
|
32475
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
32476
32431
|
|
|
32477
32432
|
if (params) {
|
|
32478
|
-
this.state.maybeInArrowParameters = true;
|
|
32479
32433
|
this.setArrowFunctionParameters(node, params, trailingCommaLoc);
|
|
32480
32434
|
}
|
|
32481
32435
|
|
|
32482
|
-
this.state.maybeInArrowParameters = false;
|
|
32483
32436
|
this.parseFunctionBody(node, true);
|
|
32484
32437
|
this.prodParam.exit();
|
|
32485
32438
|
this.scope.exit();
|
|
32486
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
32487
32439
|
return this.finishNode(node, 'ArrowFunctionExpression');
|
|
32488
32440
|
}
|
|
32489
32441
|
|
|
@@ -32804,7 +32756,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
32804
32756
|
if (!this.match(7)) {
|
|
32805
32757
|
do {
|
|
32806
32758
|
this.parseMaybeAssignAllowIn();
|
|
32807
|
-
} while (this.eat(8) && !this.match(7))
|
|
32759
|
+
} while (this.eat(8) && !this.match(7));
|
|
32808
32760
|
this.raise(Errors.ImportCallArity, node);
|
|
32809
32761
|
}
|
|
32810
32762
|
}
|
|
@@ -33386,7 +33338,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
33386
33338
|
|
|
33387
33339
|
do {
|
|
33388
33340
|
decorators.push(this.parseDecorator());
|
|
33389
|
-
} while (this.match(22))
|
|
33341
|
+
} while (this.match(22));
|
|
33390
33342
|
if (this.match(78)) {
|
|
33391
33343
|
if (!allowExport) {
|
|
33392
33344
|
this.unexpected();
|
|
@@ -34016,9 +33968,6 @@ var StatementParser = class extends ExpressionParser {
|
|
|
34016
33968
|
node.id = this.parseFunctionId(requireId);
|
|
34017
33969
|
}
|
|
34018
33970
|
|
|
34019
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
34020
|
-
|
|
34021
|
-
this.state.maybeInArrowParameters = false;
|
|
34022
33971
|
this.scope.enter(514);
|
|
34023
33972
|
this.prodParam.enter(functionFlags(isAsync, node.generator));
|
|
34024
33973
|
|
|
@@ -34035,7 +33984,6 @@ var StatementParser = class extends ExpressionParser {
|
|
|
34035
33984
|
this.registerFunctionStatementId(node);
|
|
34036
33985
|
}
|
|
34037
33986
|
|
|
34038
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
34039
33987
|
return node;
|
|
34040
33988
|
}
|
|
34041
33989
|
|
|
@@ -35024,7 +34972,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
35024
34972
|
|
|
35025
34973
|
node.value = this.parseStringLiteral(this.state.value);
|
|
35026
34974
|
attrs.push(this.finishNode(node, 'ImportAttribute'));
|
|
35027
|
-
} while (this.eat(8))
|
|
34975
|
+
} while (this.eat(8));
|
|
35028
34976
|
this.expect(4);
|
|
35029
34977
|
return attrs;
|
|
35030
34978
|
}
|
|
@@ -35216,7 +35164,7 @@ var Parser = class extends StatementParser {
|
|
|
35216
35164
|
}
|
|
35217
35165
|
};
|
|
35218
35166
|
|
|
35219
|
-
function parse$
|
|
35167
|
+
function parse$b(input, options) {
|
|
35220
35168
|
if (options?.sourceType === 'unambiguous') {
|
|
35221
35169
|
options = {
|
|
35222
35170
|
...options,
|
|
@@ -36456,7 +36404,7 @@ function parseWithCodeFrame(code2, parserOpts, syntacticPlaceholders) {
|
|
|
36456
36404
|
plugins,
|
|
36457
36405
|
};
|
|
36458
36406
|
try {
|
|
36459
|
-
return parse$
|
|
36407
|
+
return parse$b(code2, parserOpts);
|
|
36460
36408
|
} catch(err) {
|
|
36461
36409
|
const loc = err.loc;
|
|
36462
36410
|
|
|
@@ -36677,7 +36625,7 @@ function buildLiteralData(formatter, tpl, opts) {
|
|
|
36677
36625
|
|
|
36678
36626
|
do {
|
|
36679
36627
|
prefix2 = '$$' + prefix2;
|
|
36680
|
-
} while (raw.includes(prefix2))
|
|
36628
|
+
} while (raw.includes(prefix2));
|
|
36681
36629
|
const {names: names2, code: code2} = buildTemplateCode(tpl, prefix2);
|
|
36682
36630
|
|
|
36683
36631
|
const metadata = parseAndBuildMetadata(formatter, formatter.code(code2), {
|
|
@@ -36829,7 +36777,7 @@ function decodeInteger(reader, relative) {
|
|
|
36829
36777
|
integer = charToInt[c];
|
|
36830
36778
|
value |= (integer & 31) << shift;
|
|
36831
36779
|
shift += 5;
|
|
36832
|
-
} while (integer & 32)
|
|
36780
|
+
} while (integer & 32);
|
|
36833
36781
|
const shouldNegate = value & 1;
|
|
36834
36782
|
|
|
36835
36783
|
value >>>= 1;
|
|
@@ -36854,7 +36802,7 @@ function encodeInteger(builder, num, relative) {
|
|
|
36854
36802
|
clamped |= 32;
|
|
36855
36803
|
|
|
36856
36804
|
builder.write(intToChar[clamped]);
|
|
36857
|
-
} while (delta > 0)
|
|
36805
|
+
} while (delta > 0);
|
|
36858
36806
|
|
|
36859
36807
|
return num;
|
|
36860
36808
|
}
|
|
@@ -36997,7 +36945,7 @@ function decode(mappings) {
|
|
|
36997
36945
|
|
|
36998
36946
|
decoded.push(line);
|
|
36999
36947
|
reader.pos = semi + 1;
|
|
37000
|
-
} while (reader.pos <= length)
|
|
36948
|
+
} while (reader.pos <= length);
|
|
37001
36949
|
|
|
37002
36950
|
return decoded;
|
|
37003
36951
|
}
|
|
@@ -38715,6 +38663,14 @@ function ConditionalExpression2(node) {
|
|
|
38715
38663
|
this.print(node.alternate);
|
|
38716
38664
|
}
|
|
38717
38665
|
|
|
38666
|
+
function _printExpressionArguments(node) {
|
|
38667
|
+
this.tokenChar(40);
|
|
38668
|
+
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
|
38669
|
+
this.printList(node.arguments, this.shouldPrintTrailingComma(')'), void 0, void 0, void 0, true);
|
|
38670
|
+
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
|
38671
|
+
this.rightParens(node);
|
|
38672
|
+
}
|
|
38673
|
+
|
|
38718
38674
|
function NewExpression2(node, parent) {
|
|
38719
38675
|
this.word('new');
|
|
38720
38676
|
this.space();
|
|
@@ -38730,11 +38686,7 @@ function NewExpression2(node, parent) {
|
|
|
38730
38686
|
return;
|
|
38731
38687
|
}
|
|
38732
38688
|
|
|
38733
|
-
|
|
38734
|
-
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
|
38735
|
-
this.printList(node.arguments, this.shouldPrintTrailingComma(')'), void 0, void 0, void 0, true);
|
|
38736
|
-
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
|
38737
|
-
this.rightParens(node);
|
|
38689
|
+
_printExpressionArguments.call(this, node);
|
|
38738
38690
|
}
|
|
38739
38691
|
|
|
38740
38692
|
function SequenceExpression2(node) {
|
|
@@ -38801,21 +38753,13 @@ function OptionalCallExpression2(node) {
|
|
|
38801
38753
|
}
|
|
38802
38754
|
|
|
38803
38755
|
this.print(node.typeArguments);
|
|
38804
|
-
|
|
38805
|
-
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
|
38806
|
-
this.printList(node.arguments, void 0, void 0, void 0, void 0, true);
|
|
38807
|
-
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
|
38808
|
-
this.rightParens(node);
|
|
38756
|
+
_printExpressionArguments.call(this, node);
|
|
38809
38757
|
}
|
|
38810
38758
|
|
|
38811
38759
|
function CallExpression2(node) {
|
|
38812
38760
|
this.print(node.callee);
|
|
38813
38761
|
this.print(node.typeArguments);
|
|
38814
|
-
|
|
38815
|
-
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
|
38816
|
-
this.printList(node.arguments, this.shouldPrintTrailingComma(')'), void 0, void 0, void 0, true);
|
|
38817
|
-
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
|
38818
|
-
this.rightParens(node);
|
|
38762
|
+
_printExpressionArguments.call(this, node);
|
|
38819
38763
|
}
|
|
38820
38764
|
|
|
38821
38765
|
function Import2() {
|
|
@@ -45277,7 +45221,7 @@ var Scope2 = class _Scope {
|
|
|
45277
45221
|
|
|
45278
45222
|
if (path?.isScope())
|
|
45279
45223
|
parent = path;
|
|
45280
|
-
} while (path && !parent)
|
|
45224
|
+
} while (path && !parent);
|
|
45281
45225
|
|
|
45282
45226
|
return parent?.scope;
|
|
45283
45227
|
}
|
|
@@ -45321,7 +45265,7 @@ var Scope2 = class _Scope {
|
|
|
45321
45265
|
uid2 += i + 1;
|
|
45322
45266
|
|
|
45323
45267
|
i++;
|
|
45324
|
-
} while (this.hasLabel(uid2) || this.hasBinding(uid2) || this.hasGlobal(uid2) || this.hasReference(uid2))
|
|
45268
|
+
} while (this.hasLabel(uid2) || this.hasBinding(uid2) || this.hasGlobal(uid2) || this.hasReference(uid2));
|
|
45325
45269
|
const program3 = this.getProgramParent();
|
|
45326
45270
|
program3.referencesSet.add(uid2);
|
|
45327
45271
|
program3.uidsSet.add(uid2);
|
|
@@ -45424,7 +45368,7 @@ var Scope2 = class _Scope {
|
|
|
45424
45368
|
kind: binding.kind,
|
|
45425
45369
|
});
|
|
45426
45370
|
}
|
|
45427
|
-
} while (scope2 = scope2.parent)
|
|
45371
|
+
} while (scope2 = scope2.parent);
|
|
45428
45372
|
console.log(sep);
|
|
45429
45373
|
}
|
|
45430
45374
|
|
|
@@ -45556,7 +45500,7 @@ var Scope2 = class _Scope {
|
|
|
45556
45500
|
do {
|
|
45557
45501
|
if (scope2.globals[name])
|
|
45558
45502
|
return true;
|
|
45559
|
-
} while (scope2 = scope2.parent)
|
|
45503
|
+
} while (scope2 = scope2.parent);
|
|
45560
45504
|
|
|
45561
45505
|
return false;
|
|
45562
45506
|
}
|
|
@@ -45696,7 +45640,7 @@ var Scope2 = class _Scope {
|
|
|
45696
45640
|
|
|
45697
45641
|
if (data != null)
|
|
45698
45642
|
return data;
|
|
45699
|
-
} while (scope2 = scope2.parent)
|
|
45643
|
+
} while (scope2 = scope2.parent);
|
|
45700
45644
|
}
|
|
45701
45645
|
|
|
45702
45646
|
removeData(key) {
|
|
@@ -45707,7 +45651,7 @@ var Scope2 = class _Scope {
|
|
|
45707
45651
|
|
|
45708
45652
|
if (data != null)
|
|
45709
45653
|
scope2.data[key] = null;
|
|
45710
|
-
} while (scope2 = scope2.parent)
|
|
45654
|
+
} while (scope2 = scope2.parent);
|
|
45711
45655
|
}
|
|
45712
45656
|
|
|
45713
45657
|
init() {
|
|
@@ -45730,7 +45674,7 @@ var Scope2 = class _Scope {
|
|
|
45730
45674
|
if (scope2.path.isProgram()) {
|
|
45731
45675
|
break;
|
|
45732
45676
|
}
|
|
45733
|
-
} while (scope2 = scope2.parent)
|
|
45677
|
+
} while (scope2 = scope2.parent);
|
|
45734
45678
|
const programParent = scope2;
|
|
45735
45679
|
|
|
45736
45680
|
const state = {
|
|
@@ -45846,7 +45790,7 @@ collectorVisitor]);
|
|
|
45846
45790
|
if (scope2.path.isProgram()) {
|
|
45847
45791
|
return scope2;
|
|
45848
45792
|
}
|
|
45849
|
-
} while (scope2 = scope2.parent)
|
|
45793
|
+
} while (scope2 = scope2.parent);
|
|
45850
45794
|
throw new Error('Couldn\'t find a Program');
|
|
45851
45795
|
}
|
|
45852
45796
|
|
|
@@ -45857,7 +45801,7 @@ collectorVisitor]);
|
|
|
45857
45801
|
if (scope2.path.isFunctionParent()) {
|
|
45858
45802
|
return scope2;
|
|
45859
45803
|
}
|
|
45860
|
-
} while (scope2 = scope2.parent)
|
|
45804
|
+
} while (scope2 = scope2.parent);
|
|
45861
45805
|
|
|
45862
45806
|
return null;
|
|
45863
45807
|
}
|
|
@@ -45869,7 +45813,7 @@ collectorVisitor]);
|
|
|
45869
45813
|
if (scope2.path.isBlockParent()) {
|
|
45870
45814
|
return scope2;
|
|
45871
45815
|
}
|
|
45872
|
-
} while (scope2 = scope2.parent)
|
|
45816
|
+
} while (scope2 = scope2.parent);
|
|
45873
45817
|
throw new Error('We couldn\'t find a BlockStatement, For, Switch, Function, Loop or Program...');
|
|
45874
45818
|
}
|
|
45875
45819
|
|
|
@@ -45880,7 +45824,7 @@ collectorVisitor]);
|
|
|
45880
45824
|
if (!scope2.path.isPattern()) {
|
|
45881
45825
|
return scope2.getBlockParent();
|
|
45882
45826
|
}
|
|
45883
|
-
} while (scope2 = scope2.parent.parent)
|
|
45827
|
+
} while (scope2 = scope2.parent.parent);
|
|
45884
45828
|
throw new Error('We couldn\'t find a BlockStatement, For, Switch, Function, Loop or Program...');
|
|
45885
45829
|
}
|
|
45886
45830
|
|
|
@@ -45896,7 +45840,7 @@ collectorVisitor]);
|
|
|
45896
45840
|
}
|
|
45897
45841
|
|
|
45898
45842
|
scope2 = scope2.parent;
|
|
45899
|
-
} while (scope2)
|
|
45843
|
+
} while (scope2);
|
|
45900
45844
|
|
|
45901
45845
|
return ids;
|
|
45902
45846
|
}
|
|
@@ -45922,7 +45866,7 @@ collectorVisitor]);
|
|
|
45922
45866
|
}
|
|
45923
45867
|
|
|
45924
45868
|
previousPath = scope2.path;
|
|
45925
|
-
} while (scope2 = scope2.parent)
|
|
45869
|
+
} while (scope2 = scope2.parent);
|
|
45926
45870
|
}
|
|
45927
45871
|
|
|
45928
45872
|
getOwnBinding(name) {
|
|
@@ -45968,7 +45912,7 @@ collectorVisitor]);
|
|
|
45968
45912
|
if (scope2.hasOwnBinding(name)) {
|
|
45969
45913
|
return true;
|
|
45970
45914
|
}
|
|
45971
|
-
} while (scope2 = scope2.parent)
|
|
45915
|
+
} while (scope2 = scope2.parent);
|
|
45972
45916
|
if (!noUids && this.hasUid(name))
|
|
45973
45917
|
return true;
|
|
45974
45918
|
|
|
@@ -46083,7 +46027,7 @@ function find(callback) {
|
|
|
46083
46027
|
do {
|
|
46084
46028
|
if (callback(path))
|
|
46085
46029
|
return path;
|
|
46086
|
-
} while (path = path.parentPath)
|
|
46030
|
+
} while (path = path.parentPath);
|
|
46087
46031
|
|
|
46088
46032
|
return null;
|
|
46089
46033
|
}
|
|
@@ -46101,7 +46045,7 @@ function getStatementParent() {
|
|
|
46101
46045
|
} else {
|
|
46102
46046
|
path = path.parentPath;
|
|
46103
46047
|
}
|
|
46104
|
-
} while (path)
|
|
46048
|
+
} while (path);
|
|
46105
46049
|
if (path && (path.isProgram() || path.isFile())) {
|
|
46106
46050
|
throw new Error('File/Program node, we can\'t possibly find a statement parent to this');
|
|
46107
46051
|
}
|
|
@@ -46158,7 +46102,7 @@ function getDeepestCommonAncestorFrom(paths, filter) {
|
|
|
46158
46102
|
|
|
46159
46103
|
do {
|
|
46160
46104
|
ancestry.unshift(path);
|
|
46161
|
-
} while ((path = path.parentPath) && path !== this)
|
|
46105
|
+
} while ((path = path.parentPath) && path !== this);
|
|
46162
46106
|
if (ancestry.length < minDepth) {
|
|
46163
46107
|
minDepth = ancestry.length;
|
|
46164
46108
|
}
|
|
@@ -46197,7 +46141,7 @@ function getAncestry() {
|
|
|
46197
46141
|
|
|
46198
46142
|
do {
|
|
46199
46143
|
paths.push(path);
|
|
46200
|
-
} while (path = path.parentPath)
|
|
46144
|
+
} while (path = path.parentPath);
|
|
46201
46145
|
|
|
46202
46146
|
return paths;
|
|
46203
46147
|
}
|
|
@@ -47266,7 +47210,7 @@ function replaceWithSourceString(replacement) {
|
|
|
47266
47210
|
|
|
47267
47211
|
try {
|
|
47268
47212
|
replacement = `(${replacement})`;
|
|
47269
|
-
ast = parse$
|
|
47213
|
+
ast = parse$b(replacement);
|
|
47270
47214
|
} catch(err) {
|
|
47271
47215
|
const loc = err.loc;
|
|
47272
47216
|
|
|
@@ -48557,7 +48501,7 @@ var getScopeInformationVisitor = environmentVisitor({
|
|
|
48557
48501
|
if (curr.path.isFunction() && !curr.path.isArrowFunctionExpression()) {
|
|
48558
48502
|
break;
|
|
48559
48503
|
}
|
|
48560
|
-
} while (curr = curr.parent)
|
|
48504
|
+
} while (curr = curr.parent);
|
|
48561
48505
|
argumentsPaths.push(child);
|
|
48562
48506
|
},
|
|
48563
48507
|
MetaProperty(child, {newTargetPaths}) {
|
|
@@ -48819,7 +48763,7 @@ function isCompletionRecord(allowInsideFunction) {
|
|
|
48819
48763
|
if (Array.isArray(container) && path.key !== container.length - 1) {
|
|
48820
48764
|
return false;
|
|
48821
48765
|
}
|
|
48822
|
-
} while ((path = path.parentPath) && !path.isProgram() && !path.isDoExpression())
|
|
48766
|
+
} while ((path = path.parentPath) && !path.isProgram() && !path.isDoExpression());
|
|
48823
48767
|
|
|
48824
48768
|
return true;
|
|
48825
48769
|
}
|
|
@@ -49872,7 +49816,7 @@ var NodePath_Final = class NodePath {
|
|
|
49872
49816
|
key = `${path.listKey}[${key}]`;
|
|
49873
49817
|
|
|
49874
49818
|
parts.unshift(key);
|
|
49875
|
-
} while (path = path.parentPath)
|
|
49819
|
+
} while (path = path.parentPath);
|
|
49876
49820
|
|
|
49877
49821
|
return parts.join('.');
|
|
49878
49822
|
}
|
|
@@ -50333,6 +50277,7 @@ const {
|
|
|
50333
50277
|
isArrayExpression: isArrayExpression$9,
|
|
50334
50278
|
isObjectExpression: isObjectExpression$c,
|
|
50335
50279
|
isLabeledStatement: isLabeledStatement$1,
|
|
50280
|
+
isTryStatement,
|
|
50336
50281
|
} = lib_exports;
|
|
50337
50282
|
|
|
50338
50283
|
const isParentProgram = (path) => path.parentPath?.isProgram();
|
|
@@ -50347,6 +50292,12 @@ const isNext = (path) => {
|
|
|
50347
50292
|
return !next.isEmptyStatement();
|
|
50348
50293
|
};
|
|
50349
50294
|
|
|
50295
|
+
const isNextTry = (path) => {
|
|
50296
|
+
return isTryStatement(path.getNextSibling());
|
|
50297
|
+
};
|
|
50298
|
+
|
|
50299
|
+
const isPrevTry = (path) => isTryStatement(path.getPrevSibling());
|
|
50300
|
+
|
|
50350
50301
|
const isPrev = (path) => {
|
|
50351
50302
|
const next = path.getPrevSibling();
|
|
50352
50303
|
return next.node;
|
|
@@ -50386,7 +50337,7 @@ function isCoupleLines(path) {
|
|
|
50386
50337
|
return end !== start;
|
|
50387
50338
|
}
|
|
50388
50339
|
|
|
50389
|
-
const exists = (a) => a.node;
|
|
50340
|
+
const exists$1 = (a) => a.node;
|
|
50390
50341
|
|
|
50391
50342
|
function isStringAndIdentifier([a, b]) {
|
|
50392
50343
|
return isStringLiteral$a(a) && isIdentifier$g(b);
|
|
@@ -50993,7 +50944,7 @@ const isIfUp = (path) => {
|
|
|
50993
50944
|
const {
|
|
50994
50945
|
isDecorator,
|
|
50995
50946
|
isMemberExpression: isMemberExpression$7,
|
|
50996
|
-
isExpressionStatement: isExpressionStatement$
|
|
50947
|
+
isExpressionStatement: isExpressionStatement$a,
|
|
50997
50948
|
isCallExpression: isCallExpression$8,
|
|
50998
50949
|
} = lib_exports;
|
|
50999
50950
|
|
|
@@ -51136,7 +51087,7 @@ const parseTrailingComments = (path, printer, semantics, {currentTraverse} = {})
|
|
|
51136
51087
|
function isPrevCall(path) {
|
|
51137
51088
|
const prev = path.getPrevSibling();
|
|
51138
51089
|
|
|
51139
|
-
if (isExpressionStatement$
|
|
51090
|
+
if (isExpressionStatement$a(prev))
|
|
51140
51091
|
return false;
|
|
51141
51092
|
|
|
51142
51093
|
const {expression} = path.node;
|
|
@@ -51280,7 +51231,7 @@ const ArrowFunctionExpression = maybeParens((path, printer, semantics) => {
|
|
|
51280
51231
|
|
|
51281
51232
|
const returnType = path.get('returnType');
|
|
51282
51233
|
|
|
51283
|
-
if (exists(returnType)) {
|
|
51234
|
+
if (exists$1(returnType)) {
|
|
51284
51235
|
write(':');
|
|
51285
51236
|
write.space();
|
|
51286
51237
|
traverse(returnType);
|
|
@@ -51306,7 +51257,7 @@ const {
|
|
|
51306
51257
|
isTSModuleBlock: isTSModuleBlock$3,
|
|
51307
51258
|
isBlockStatement: isBlockStatement$6,
|
|
51308
51259
|
isExportNamedDeclaration: isExportNamedDeclaration$2,
|
|
51309
|
-
isExpressionStatement: isExpressionStatement$
|
|
51260
|
+
isExpressionStatement: isExpressionStatement$9,
|
|
51310
51261
|
isFunctionDeclaration: isFunctionDeclaration$2,
|
|
51311
51262
|
isExportDefaultDeclaration,
|
|
51312
51263
|
} = lib_exports;
|
|
@@ -51364,7 +51315,7 @@ const isNextFunction = (path) => {
|
|
|
51364
51315
|
const isNextAssign$1 = (path) => {
|
|
51365
51316
|
const next = path.getNextSibling();
|
|
51366
51317
|
|
|
51367
|
-
if (!isExpressionStatement$
|
|
51318
|
+
if (!isExpressionStatement$9(next))
|
|
51368
51319
|
return false;
|
|
51369
51320
|
|
|
51370
51321
|
return isAssignmentExpression$3(next.node.expression);
|
|
@@ -51625,7 +51576,7 @@ const FunctionExpression = maybeParens((path, printer, semantics) => {
|
|
|
51625
51576
|
|
|
51626
51577
|
const id = path.get('id');
|
|
51627
51578
|
|
|
51628
|
-
if (exists(id)) {
|
|
51579
|
+
if (exists$1(id)) {
|
|
51629
51580
|
write(' ');
|
|
51630
51581
|
traverse(id);
|
|
51631
51582
|
}
|
|
@@ -51881,7 +51832,7 @@ const CallExpression = maybeParens((path, {indent, print, maybe, traverse}) => {
|
|
|
51881
51832
|
|
|
51882
51833
|
traverse(callee);
|
|
51883
51834
|
|
|
51884
|
-
if (exists(typeParameters))
|
|
51835
|
+
if (exists$1(typeParameters))
|
|
51885
51836
|
traverse(typeParameters);
|
|
51886
51837
|
|
|
51887
51838
|
if (path.node.optional)
|
|
@@ -51932,12 +51883,12 @@ function tooLong$1(args) {
|
|
|
51932
51883
|
}
|
|
51933
51884
|
|
|
51934
51885
|
const {
|
|
51935
|
-
isExpressionStatement: isExpressionStatement$
|
|
51886
|
+
isExpressionStatement: isExpressionStatement$8,
|
|
51936
51887
|
isMemberExpression: isMemberExpression$6,
|
|
51937
51888
|
} = lib_exports;
|
|
51938
51889
|
|
|
51939
|
-
const isInsideExpressionStatement = ({parentPath}) => isExpressionStatement$
|
|
51940
|
-
const notFirst = ({parentPath}) => exists(parentPath.getPrevSibling());
|
|
51890
|
+
const isInsideExpressionStatement = ({parentPath}) => isExpressionStatement$8(parentPath);
|
|
51891
|
+
const notFirst = ({parentPath}) => exists$1(parentPath.getPrevSibling());
|
|
51941
51892
|
const isInsideMember = ({parentPath}) => isMemberExpression$6(parentPath);
|
|
51942
51893
|
|
|
51943
51894
|
const getPrev = ({parentPath}) => {
|
|
@@ -52162,7 +52113,7 @@ const ObjectExpression = (path, printer, semantics) => {
|
|
|
52162
52113
|
const hasNextLeadingComment = (path) => {
|
|
52163
52114
|
const next = path.getNextSibling();
|
|
52164
52115
|
|
|
52165
|
-
if (!exists(next))
|
|
52116
|
+
if (!exists$1(next))
|
|
52166
52117
|
return false;
|
|
52167
52118
|
|
|
52168
52119
|
return hasLeadingComment(next);
|
|
@@ -52637,7 +52588,7 @@ const isCoupleProperties = ({path, valuePath, property}) => {
|
|
|
52637
52588
|
if (!isCoupleLines(valuePath))
|
|
52638
52589
|
return false;
|
|
52639
52590
|
|
|
52640
|
-
if (exists(property.getPrevSibling()))
|
|
52591
|
+
if (exists$1(property.getPrevSibling()))
|
|
52641
52592
|
return false;
|
|
52642
52593
|
|
|
52643
52594
|
const properties = path.get('properties');
|
|
@@ -52828,7 +52779,7 @@ const condition$4 = (path, printer, semantics) => {
|
|
|
52828
52779
|
|
|
52829
52780
|
const {
|
|
52830
52781
|
isAssignmentExpression: isAssignmentExpression$2,
|
|
52831
|
-
isExpressionStatement: isExpressionStatement$
|
|
52782
|
+
isExpressionStatement: isExpressionStatement$7,
|
|
52832
52783
|
} = lib_exports;
|
|
52833
52784
|
|
|
52834
52785
|
const printSeparator = (path, {print}) => {
|
|
@@ -52841,7 +52792,7 @@ const printSeparator = (path, {print}) => {
|
|
|
52841
52792
|
function isMultiline(path) {
|
|
52842
52793
|
const {right} = path.node;
|
|
52843
52794
|
|
|
52844
|
-
if (!path.parentPath.find(isExpressionStatement$
|
|
52795
|
+
if (!path.parentPath.find(isExpressionStatement$7))
|
|
52845
52796
|
return false;
|
|
52846
52797
|
|
|
52847
52798
|
return isAssignmentExpression$2(right);
|
|
@@ -54689,7 +54640,7 @@ const processClassProperty = maybeDecorators$1((path, printer, semantics, {acces
|
|
|
54689
54640
|
|
|
54690
54641
|
maybePrintTypeAnnotation(path, printer);
|
|
54691
54642
|
|
|
54692
|
-
if (exists(value)) {
|
|
54643
|
+
if (exists$1(value)) {
|
|
54693
54644
|
print.space();
|
|
54694
54645
|
print('=');
|
|
54695
54646
|
print.space();
|
|
@@ -54818,6 +54769,7 @@ const DoWhileStatement = {
|
|
|
54818
54769
|
print('(');
|
|
54819
54770
|
print('__test');
|
|
54820
54771
|
print(')');
|
|
54772
|
+
print(';');
|
|
54821
54773
|
},
|
|
54822
54774
|
afterSatisfy: () => [notLast],
|
|
54823
54775
|
after(path, {print}) {
|
|
@@ -54955,7 +54907,7 @@ const SwitchStatement = {
|
|
|
54955
54907
|
|
|
54956
54908
|
parseLeadingComments(switchCase, printer, semantics);
|
|
54957
54909
|
|
|
54958
|
-
if (exists(test)) {
|
|
54910
|
+
if (exists$1(test)) {
|
|
54959
54911
|
write('case');
|
|
54960
54912
|
maybeSpaceAfterKeyword$1(test, printer, semantics);
|
|
54961
54913
|
traverse(test);
|
|
@@ -55155,7 +55107,7 @@ const ExportNamedDeclaration = {
|
|
|
55155
55107
|
}
|
|
55156
55108
|
|
|
55157
55109
|
const n = specifiers.length;
|
|
55158
|
-
const isNewline = !exists(source) || n > maxOneLineSpecifiers;
|
|
55110
|
+
const isNewline = !exists$1(source) || n > maxOneLineSpecifiers;
|
|
55159
55111
|
|
|
55160
55112
|
if (specifiers && !path.node.declaration) {
|
|
55161
55113
|
print.space();
|
|
@@ -55205,7 +55157,7 @@ const ExportNamedDeclaration = {
|
|
|
55205
55157
|
|
|
55206
55158
|
const source = path.get('source');
|
|
55207
55159
|
|
|
55208
|
-
if (exists(source)) {
|
|
55160
|
+
if (exists$1(source)) {
|
|
55209
55161
|
print(' from ');
|
|
55210
55162
|
traverse(source);
|
|
55211
55163
|
printAttributes(path, printer);
|
|
@@ -55477,7 +55429,7 @@ const ForStatement = {
|
|
|
55477
55429
|
}
|
|
55478
55430
|
},
|
|
55479
55431
|
afterIf(path) {
|
|
55480
|
-
return exists(path.getNextSibling());
|
|
55432
|
+
return exists$1(path.getNextSibling());
|
|
55481
55433
|
},
|
|
55482
55434
|
after(path, {print}) {
|
|
55483
55435
|
print.linebreak();
|
|
@@ -55502,8 +55454,10 @@ const DebuggerStatement = {
|
|
|
55502
55454
|
},
|
|
55503
55455
|
};
|
|
55504
55456
|
|
|
55457
|
+
const {isExpressionStatement: isExpressionStatement$6} = lib_exports;
|
|
55458
|
+
|
|
55505
55459
|
const TryStatement = {
|
|
55506
|
-
print(path, {print}) {
|
|
55460
|
+
print(path, {print, maybe}) {
|
|
55507
55461
|
const finalizer = path.get('finalizer');
|
|
55508
55462
|
print.indent();
|
|
55509
55463
|
print('try');
|
|
@@ -55516,16 +55470,22 @@ const TryStatement = {
|
|
|
55516
55470
|
print('finally');
|
|
55517
55471
|
print.space();
|
|
55518
55472
|
print(finalizer);
|
|
55519
|
-
print.newline();
|
|
55473
|
+
maybe.print.newline(!isNext(path));
|
|
55520
55474
|
}
|
|
55521
55475
|
},
|
|
55522
55476
|
afterSatisfy: () => [isNext],
|
|
55523
|
-
after(path, {
|
|
55524
|
-
|
|
55525
|
-
|
|
55477
|
+
after(path, {print}) {
|
|
55478
|
+
print.newline();
|
|
55479
|
+
|
|
55480
|
+
if (isNextExpression(path) || isNextTry(path))
|
|
55481
|
+
print.breakline();
|
|
55526
55482
|
},
|
|
55527
55483
|
};
|
|
55528
55484
|
|
|
55485
|
+
const isNextExpression = (path) => {
|
|
55486
|
+
return isExpressionStatement$6(path.getNextSibling());
|
|
55487
|
+
};
|
|
55488
|
+
|
|
55529
55489
|
const CatchClause = (path, {print, maybe}) => {
|
|
55530
55490
|
const param = path.get('param');
|
|
55531
55491
|
const body = path.get('body');
|
|
@@ -55557,6 +55517,9 @@ const isInsideIfWithElse = ({parentPath}) => parentPath.isIfStatement() && paren
|
|
|
55557
55517
|
|
|
55558
55518
|
const ReturnStatement = {
|
|
55559
55519
|
beforeIf(path) {
|
|
55520
|
+
if (isPrevTry(path))
|
|
55521
|
+
return true;
|
|
55522
|
+
|
|
55560
55523
|
return !hasPrevNewline(path) && isBodyLength(path) || isPrevBody(path);
|
|
55561
55524
|
},
|
|
55562
55525
|
before(path, {print}) {
|
|
@@ -55621,7 +55584,7 @@ const insideIfWithNoBody = (path) => {
|
|
|
55621
55584
|
|
|
55622
55585
|
const next = path.parentPath?.parentPath.getNextSibling();
|
|
55623
55586
|
|
|
55624
|
-
return !exists(next);
|
|
55587
|
+
return !exists$1(next);
|
|
55625
55588
|
};
|
|
55626
55589
|
|
|
55627
55590
|
const {
|
|
@@ -55841,7 +55804,7 @@ function isNextIfAlternate(path) {
|
|
|
55841
55804
|
if (path === alternate)
|
|
55842
55805
|
return false;
|
|
55843
55806
|
|
|
55844
|
-
return exists(alternate);
|
|
55807
|
+
return exists$1(alternate);
|
|
55845
55808
|
}
|
|
55846
55809
|
|
|
55847
55810
|
function isTry({parentPath}) {
|
|
@@ -56002,7 +55965,7 @@ const IfStatement = {
|
|
|
56002
55965
|
|
|
56003
55966
|
write('else ');
|
|
56004
55967
|
traverse(alternate);
|
|
56005
|
-
} else if (exists(alternate)) {
|
|
55968
|
+
} else if (exists$1(alternate)) {
|
|
56006
55969
|
maybe.write.newline(isVar || isStatementNotExpression(consequent));
|
|
56007
55970
|
maybe.indent(!isConsequentBlock);
|
|
56008
55971
|
maybe.write.space(isConsequentBlock);
|
|
@@ -56081,7 +56044,7 @@ const VariableDeclaration = {
|
|
|
56081
56044
|
|
|
56082
56045
|
traverse(id);
|
|
56083
56046
|
|
|
56084
|
-
if (exists(init)) {
|
|
56047
|
+
if (exists$1(init)) {
|
|
56085
56048
|
write.space();
|
|
56086
56049
|
write('=');
|
|
56087
56050
|
maybe.write.space(!isConcatenation(init));
|
|
@@ -56173,7 +56136,7 @@ function notLastPrevVarNotNextVar(path) {
|
|
|
56173
56136
|
const prev = path.getPrevSibling();
|
|
56174
56137
|
const next = path.getNextSibling();
|
|
56175
56138
|
|
|
56176
|
-
if (!exists(prev.getPrevSibling()))
|
|
56139
|
+
if (!exists$1(prev.getPrevSibling()))
|
|
56177
56140
|
return false;
|
|
56178
56141
|
|
|
56179
56142
|
if (path.node.loc?.start.line === prev.node?.loc?.start.line + 2)
|
|
@@ -56186,7 +56149,7 @@ function isNextCoupleLines(path) {
|
|
|
56186
56149
|
const next = path.getNextSibling();
|
|
56187
56150
|
const prev = path.getPrevSibling();
|
|
56188
56151
|
|
|
56189
|
-
if (!exists(prev.getPrevSibling()) && next.isVariableDeclaration())
|
|
56152
|
+
if (!exists$1(prev.getPrevSibling()) && next.isVariableDeclaration())
|
|
56190
56153
|
return false;
|
|
56191
56154
|
|
|
56192
56155
|
if (path.node.loc?.start.line === prev.node?.loc?.start?.line + 2)
|
|
@@ -56840,14 +56803,14 @@ const TSTypeParameter = (path, {write, traverse}) => {
|
|
|
56840
56803
|
|
|
56841
56804
|
write(path.node.name.name);
|
|
56842
56805
|
|
|
56843
|
-
if (exists(constraint)) {
|
|
56806
|
+
if (exists$1(constraint)) {
|
|
56844
56807
|
write(' extends ');
|
|
56845
56808
|
traverse(constraint);
|
|
56846
56809
|
}
|
|
56847
56810
|
|
|
56848
56811
|
const defaultPath = path.get('default');
|
|
56849
56812
|
|
|
56850
|
-
if (exists(defaultPath)) {
|
|
56813
|
+
if (exists$1(defaultPath)) {
|
|
56851
56814
|
write.space();
|
|
56852
56815
|
write('=');
|
|
56853
56816
|
write.space();
|
|
@@ -58311,7 +58274,7 @@ function createStore$1() {
|
|
|
58311
58274
|
};
|
|
58312
58275
|
}
|
|
58313
58276
|
|
|
58314
|
-
const isObject$
|
|
58277
|
+
const isObject$7 = (a) => a && typeof a === 'object';
|
|
58315
58278
|
const isBool$3 = (a) => typeof a === 'boolean';
|
|
58316
58279
|
|
|
58317
58280
|
const ROUND_BRACES_DEFAULTS = {
|
|
@@ -58336,7 +58299,7 @@ const ROUND_BRACES_DISABLED = {
|
|
|
58336
58299
|
};
|
|
58337
58300
|
|
|
58338
58301
|
const parseRoundBraces = ({roundBraces}) => {
|
|
58339
|
-
if (isObject$
|
|
58302
|
+
if (isObject$7(roundBraces))
|
|
58340
58303
|
return {
|
|
58341
58304
|
...ROUND_BRACES_DEFAULTS,
|
|
58342
58305
|
...roundBraces,
|
|
@@ -58406,7 +58369,7 @@ const initSemantics = (format, semantics = {}) => ({
|
|
|
58406
58369
|
roundBraces: parseRoundBraces(semantics),
|
|
58407
58370
|
});
|
|
58408
58371
|
|
|
58409
|
-
const isObject$
|
|
58372
|
+
const isObject$6 = (a) => a && typeof a === 'object';
|
|
58410
58373
|
const {round} = Math;
|
|
58411
58374
|
const isString$b = (a) => typeof a === 'string';
|
|
58412
58375
|
const {assign: assign$9, freeze} = Object;
|
|
@@ -58644,7 +58607,7 @@ const createPrint = (path, {traverse, write}) => (maybeLine) => {
|
|
|
58644
58607
|
|
|
58645
58608
|
const computed = computePath(path, maybeLine);
|
|
58646
58609
|
|
|
58647
|
-
if (isObject$
|
|
58610
|
+
if (isObject$6(computed))
|
|
58648
58611
|
return traverse(computed);
|
|
58649
58612
|
|
|
58650
58613
|
return write(computed);
|
|
@@ -58654,7 +58617,7 @@ const computePath = (path, maybeLine) => {
|
|
|
58654
58617
|
if (isString$b(maybeLine) && maybeLine.startsWith(GET))
|
|
58655
58618
|
return get(path, maybeLine);
|
|
58656
58619
|
|
|
58657
|
-
if (isObject$
|
|
58620
|
+
if (isObject$6(maybeLine))
|
|
58658
58621
|
return maybeLine;
|
|
58659
58622
|
|
|
58660
58623
|
return maybeLine;
|
|
@@ -59580,7 +59543,7 @@ const initAcorn = once$4(() => {
|
|
|
59580
59543
|
return Parser.extend(typescript(), stage3);
|
|
59581
59544
|
});
|
|
59582
59545
|
|
|
59583
|
-
var parse$
|
|
59546
|
+
var parse$a = (source) => {
|
|
59584
59547
|
const parser = initAcorn();
|
|
59585
59548
|
const options = {
|
|
59586
59549
|
locations: true,
|
|
@@ -59638,7 +59601,7 @@ const {assign: assign$5} = Object;
|
|
|
59638
59601
|
const getFlow = (a) => !a.indexOf('// @flow');
|
|
59639
59602
|
const clean = (a) => a.filter(Boolean);
|
|
59640
59603
|
|
|
59641
|
-
const parse$
|
|
59604
|
+
const parse$9 = (source, overrides) => {
|
|
59642
59605
|
const {
|
|
59643
59606
|
sourceFileName,
|
|
59644
59607
|
isTS,
|
|
@@ -59669,7 +59632,7 @@ const parse$7 = (source, overrides) => {
|
|
|
59669
59632
|
tokens: true,
|
|
59670
59633
|
});
|
|
59671
59634
|
|
|
59672
|
-
const ast = parse$
|
|
59635
|
+
const ast = parse$b(source, parserOptions);
|
|
59673
59636
|
|
|
59674
59637
|
ast.program.extra.__putout_printer = printer;
|
|
59675
59638
|
return ast;
|
|
@@ -59690,7 +59653,7 @@ const once$3 = onceExports;
|
|
|
59690
59653
|
|
|
59691
59654
|
const initEspree = once$3(() => require$$1);
|
|
59692
59655
|
|
|
59693
|
-
var parse$
|
|
59656
|
+
var parse$8 = (source) => {
|
|
59694
59657
|
const {parse} = initEspree();
|
|
59695
59658
|
const preventUsingEsprima = true;
|
|
59696
59659
|
|
|
@@ -59710,7 +59673,7 @@ const once$2 = onceExports;
|
|
|
59710
59673
|
|
|
59711
59674
|
const initEsprima = once$2(() => require$$1);
|
|
59712
59675
|
|
|
59713
|
-
var parse$
|
|
59676
|
+
var parse$7 = (source) => {
|
|
59714
59677
|
const {parse} = initEsprima();
|
|
59715
59678
|
|
|
59716
59679
|
return parse(source, {
|
|
@@ -59726,7 +59689,7 @@ const once$1 = onceExports;
|
|
|
59726
59689
|
|
|
59727
59690
|
const initTenko = once$1(() => require$$1);
|
|
59728
59691
|
|
|
59729
|
-
var parse$
|
|
59692
|
+
var parse$6 = (source) => {
|
|
59730
59693
|
const {Tenko} = initTenko();
|
|
59731
59694
|
const {ast} = Tenko(source, {
|
|
59732
59695
|
goalMode: 'module',
|
|
@@ -59740,7 +59703,7 @@ var parse$4 = (source) => {
|
|
|
59740
59703
|
const once = onceExports;
|
|
59741
59704
|
const initHermes = once(() => require$$1);
|
|
59742
59705
|
|
|
59743
|
-
var parse$
|
|
59706
|
+
var parse$5 = (source) => {
|
|
59744
59707
|
const parser = initHermes();
|
|
59745
59708
|
const options = {
|
|
59746
59709
|
babel: true,
|
|
@@ -59790,7 +59753,7 @@ function checkError(error, messages) {
|
|
|
59790
59753
|
return false;
|
|
59791
59754
|
}
|
|
59792
59755
|
|
|
59793
|
-
const isObject$
|
|
59756
|
+
const isObject$5 = (a) => typeof a === 'object';
|
|
59794
59757
|
|
|
59795
59758
|
const MESSAGES = [
|
|
59796
59759
|
'has already been declared',
|
|
@@ -59823,33 +59786,33 @@ var customParser = (source, parser, {isTS, isJSX, printer}) => {
|
|
|
59823
59786
|
|
|
59824
59787
|
function customParse(source, {parser, printer, isTS, isJSX, isRecovery}) {
|
|
59825
59788
|
if (parser === 'babel')
|
|
59826
|
-
return parse$
|
|
59789
|
+
return parse$9(source, {
|
|
59827
59790
|
isTS,
|
|
59828
59791
|
isJSX,
|
|
59829
59792
|
isRecovery,
|
|
59830
59793
|
printer,
|
|
59831
59794
|
});
|
|
59832
59795
|
|
|
59833
|
-
if (isObject$
|
|
59796
|
+
if (isObject$5(parser))
|
|
59834
59797
|
return parser.parse(source, {
|
|
59835
59798
|
isJSX,
|
|
59836
59799
|
isTS,
|
|
59837
59800
|
});
|
|
59838
59801
|
|
|
59839
59802
|
if (parser === 'espree')
|
|
59840
|
-
return parse$
|
|
59803
|
+
return parse$8(source);
|
|
59841
59804
|
|
|
59842
59805
|
if (parser === 'acorn')
|
|
59843
|
-
return parse$
|
|
59806
|
+
return parse$a(source);
|
|
59844
59807
|
|
|
59845
59808
|
if (parser === 'esprima')
|
|
59846
|
-
return parse$
|
|
59809
|
+
return parse$7(source);
|
|
59847
59810
|
|
|
59848
59811
|
if (parser === 'tenko')
|
|
59849
|
-
return parse$
|
|
59812
|
+
return parse$6(source);
|
|
59850
59813
|
|
|
59851
59814
|
if (parser === 'hermes')
|
|
59852
|
-
return parse$
|
|
59815
|
+
return parse$5(source);
|
|
59853
59816
|
|
|
59854
59817
|
const require = _module.createRequire(import.meta.url);
|
|
59855
59818
|
|
|
@@ -59870,7 +59833,7 @@ const tryThrowWithReason$1 = (fn, ...args) => {
|
|
|
59870
59833
|
const {assign: assign$4} = Object;
|
|
59871
59834
|
const isString$8 = (a) => typeof a === 'string';
|
|
59872
59835
|
|
|
59873
|
-
const parse$
|
|
59836
|
+
const parse$4 = (source, options) => {
|
|
59874
59837
|
check$b(source);
|
|
59875
59838
|
|
|
59876
59839
|
const {
|
|
@@ -61265,7 +61228,7 @@ function createListStore(returns = id) {
|
|
|
61265
61228
|
const {merge: merge$2} = traverse3.visitors;
|
|
61266
61229
|
const {assign: assign$1} = Object;
|
|
61267
61230
|
|
|
61268
|
-
const parse$
|
|
61231
|
+
const parse$3 = (name, plugin, options) => {
|
|
61269
61232
|
const list = [];
|
|
61270
61233
|
|
|
61271
61234
|
if (plugin[name]) {
|
|
@@ -61317,8 +61280,8 @@ var mergeVisitors = (pluginsToMerge, {fix, shebang, template}) => {
|
|
|
61317
61280
|
throw Error(`☝️ Visitors cannot be empty in "${rule}"`);
|
|
61318
61281
|
|
|
61319
61282
|
assign$1(options, {
|
|
61320
|
-
include: parse$
|
|
61321
|
-
exclude: parse$
|
|
61283
|
+
include: parse$3('include', plugin, options),
|
|
61284
|
+
exclude: parse$3('exclude', plugin, options),
|
|
61322
61285
|
});
|
|
61323
61286
|
|
|
61324
61287
|
mergeItems.push(...template({
|
|
@@ -61395,7 +61358,7 @@ function superFind({rule, find, ast, options, template, traverse = traverse3}) {
|
|
|
61395
61358
|
};
|
|
61396
61359
|
|
|
61397
61360
|
const returnItems = find(ast, {
|
|
61398
|
-
traverse: createTraverse$
|
|
61361
|
+
traverse: createTraverse$4({
|
|
61399
61362
|
rule,
|
|
61400
61363
|
options,
|
|
61401
61364
|
template,
|
|
@@ -61413,7 +61376,7 @@ function superFind({rule, find, ast, options, template, traverse = traverse3}) {
|
|
|
61413
61376
|
];
|
|
61414
61377
|
}
|
|
61415
61378
|
|
|
61416
|
-
const createTraverse$
|
|
61379
|
+
const createTraverse$4 = ({rule, options, template, traverse}) => (ast, visitor) => {
|
|
61417
61380
|
const templateVisitors = merge$1(template({
|
|
61418
61381
|
rule,
|
|
61419
61382
|
visitor,
|
|
@@ -61748,7 +61711,7 @@ const isLinkedRegExp = (a, b) => {
|
|
|
61748
61711
|
|
|
61749
61712
|
const isPath$1 = (path) => Boolean(path.node);
|
|
61750
61713
|
|
|
61751
|
-
const isObject$
|
|
61714
|
+
const isObject$4 = (a) => {
|
|
61752
61715
|
if (!a)
|
|
61753
61716
|
return false;
|
|
61754
61717
|
|
|
@@ -62079,7 +62042,7 @@ const createDebug = (namespace) => {
|
|
|
62079
62042
|
const debug$3 = createDebug('putout:compare');
|
|
62080
62043
|
|
|
62081
62044
|
const {isArray: isArray$4} = Array;
|
|
62082
|
-
const isObject$
|
|
62045
|
+
const isObject$3 = (a) => a && typeof a === 'object';
|
|
62083
62046
|
|
|
62084
62047
|
var log$4 = (a, b) => {
|
|
62085
62048
|
if (!debug$3.enabled)
|
|
@@ -62102,7 +62065,7 @@ function parseValue(a) {
|
|
|
62102
62065
|
return `${type}: ["${name || value}"]`;
|
|
62103
62066
|
}
|
|
62104
62067
|
|
|
62105
|
-
if (isObject$
|
|
62068
|
+
if (isObject$3(a)) {
|
|
62106
62069
|
const {
|
|
62107
62070
|
type,
|
|
62108
62071
|
name,
|
|
@@ -62189,7 +62152,7 @@ const comparePlain = (node, template, {add}) => {
|
|
|
62189
62152
|
if (isIdentifier$1(node) && node.name === template.name)
|
|
62190
62153
|
return true;
|
|
62191
62154
|
|
|
62192
|
-
if (isObject$
|
|
62155
|
+
if (isObject$4(template) && !Array.isArray(template))
|
|
62193
62156
|
return add(node, template, {
|
|
62194
62157
|
plain: true,
|
|
62195
62158
|
});
|
|
@@ -62305,7 +62268,7 @@ function linkNodes(node, template, {add, templateStore}) {
|
|
|
62305
62268
|
}
|
|
62306
62269
|
|
|
62307
62270
|
function addObject(node, template, {add}) {
|
|
62308
|
-
const is = isObject$
|
|
62271
|
+
const is = isObject$4(template);
|
|
62309
62272
|
|
|
62310
62273
|
if (is)
|
|
62311
62274
|
add(node, template);
|
|
@@ -63335,7 +63298,7 @@ const {stringify: stringify$1} = JSON;
|
|
|
63335
63298
|
const stub = () => [];
|
|
63336
63299
|
const stubMatch = () => ({});
|
|
63337
63300
|
const packKeys = (a) => () => keys$1(a);
|
|
63338
|
-
const isObject$
|
|
63301
|
+
const isObject$2 = (a) => typeof a === 'object';
|
|
63339
63302
|
|
|
63340
63303
|
const replace = ({rule, plugin, msg, options}) => {
|
|
63341
63304
|
const maybeMatch = plugin.match || stubMatch;
|
|
@@ -63389,7 +63352,7 @@ const parseExpression = (nodeFrom, {node}) => {
|
|
|
63389
63352
|
return node;
|
|
63390
63353
|
};
|
|
63391
63354
|
|
|
63392
|
-
const fix$
|
|
63355
|
+
const fix$9 = (from, to, path) => {
|
|
63393
63356
|
const nodeFrom = template$1.ast(from);
|
|
63394
63357
|
const mark = watermark(from, to, path);
|
|
63395
63358
|
|
|
@@ -63444,7 +63407,7 @@ const getFix = (items, match) => (path) => {
|
|
|
63444
63407
|
const matchFn = match[from];
|
|
63445
63408
|
|
|
63446
63409
|
if (!matchFn || runMatch(path, nodeFrom, matchFn))
|
|
63447
|
-
fix$
|
|
63410
|
+
fix$9(from, to, path);
|
|
63448
63411
|
}
|
|
63449
63412
|
}
|
|
63450
63413
|
};
|
|
@@ -63484,7 +63447,7 @@ function parseTo(to, values, path) {
|
|
|
63484
63447
|
if (!toStr)
|
|
63485
63448
|
return null;
|
|
63486
63449
|
|
|
63487
|
-
if (isObject$
|
|
63450
|
+
if (isObject$2(toStr) && toStr.type) {
|
|
63488
63451
|
toStr.__putout_replace_cooked = true;
|
|
63489
63452
|
return toStr;
|
|
63490
63453
|
}
|
|
@@ -63589,7 +63552,7 @@ const TS_EXCLUDE = [
|
|
|
63589
63552
|
const declare$1 = (declarations) => ({
|
|
63590
63553
|
report: report$4,
|
|
63591
63554
|
include,
|
|
63592
|
-
fix: fix$
|
|
63555
|
+
fix: fix$8(declarations),
|
|
63593
63556
|
filter: filter(declarations),
|
|
63594
63557
|
});
|
|
63595
63558
|
|
|
@@ -63633,7 +63596,7 @@ const filter = (declarations) => (path, {options}) => {
|
|
|
63633
63596
|
return parseCode(type, allDeclarations[name]);
|
|
63634
63597
|
};
|
|
63635
63598
|
|
|
63636
|
-
const fix$
|
|
63599
|
+
const fix$8 = (declarations) => (path, {options}) => {
|
|
63637
63600
|
const type = getModuleType(path);
|
|
63638
63601
|
|
|
63639
63602
|
const allDeclarations = {
|
|
@@ -63816,7 +63779,7 @@ const {entries: entries$2} = Object;
|
|
|
63816
63779
|
|
|
63817
63780
|
const isPath = (path) => Boolean(path.node);
|
|
63818
63781
|
|
|
63819
|
-
const createTraverse$
|
|
63782
|
+
const createTraverse$3 = (path) => {
|
|
63820
63783
|
if (isPath(path))
|
|
63821
63784
|
return path.traverse.bind(path);
|
|
63822
63785
|
|
|
@@ -63833,7 +63796,7 @@ const createTraverse$1 = (path) => {
|
|
|
63833
63796
|
const getTemplate = ([a]) => a;
|
|
63834
63797
|
|
|
63835
63798
|
function traverse$3(basePath, visitor) {
|
|
63836
|
-
const traverse = createTraverse$
|
|
63799
|
+
const traverse = createTraverse$3(basePath);
|
|
63837
63800
|
const items = [];
|
|
63838
63801
|
const parsedVisitors = entries$2(visitor);
|
|
63839
63802
|
|
|
@@ -63907,12 +63870,12 @@ const getRootFromAst = (ast) => {
|
|
|
63907
63870
|
|
|
63908
63871
|
const {
|
|
63909
63872
|
arrayExpression: arrayExpression$2,
|
|
63910
|
-
stringLiteral: stringLiteral$
|
|
63873
|
+
stringLiteral: stringLiteral$5,
|
|
63911
63874
|
objectProperty: objectProperty$2,
|
|
63912
63875
|
} = lib_exports;
|
|
63913
63876
|
|
|
63914
63877
|
const createTypeProperty = (type) => {
|
|
63915
|
-
const value = stringLiteral$
|
|
63878
|
+
const value = stringLiteral$5(type);
|
|
63916
63879
|
return createProperty$1('type', value);
|
|
63917
63880
|
};
|
|
63918
63881
|
|
|
@@ -63922,17 +63885,17 @@ const createFilesProperty = (files) => {
|
|
|
63922
63885
|
};
|
|
63923
63886
|
|
|
63924
63887
|
const createFilenameProperty = (filename) => {
|
|
63925
|
-
const value = stringLiteral$
|
|
63888
|
+
const value = stringLiteral$5(filename);
|
|
63926
63889
|
return createProperty$1('filename', value);
|
|
63927
63890
|
};
|
|
63928
63891
|
|
|
63929
63892
|
const createContentProperty = (content) => {
|
|
63930
|
-
const value = stringLiteral$
|
|
63893
|
+
const value = stringLiteral$5(content);
|
|
63931
63894
|
return createProperty$1('content', value);
|
|
63932
63895
|
};
|
|
63933
63896
|
|
|
63934
63897
|
function createProperty$1(name, value) {
|
|
63935
|
-
const key = stringLiteral$
|
|
63898
|
+
const key = stringLiteral$5(name);
|
|
63936
63899
|
return objectProperty$2(key, value);
|
|
63937
63900
|
}
|
|
63938
63901
|
|
|
@@ -64414,7 +64377,7 @@ function getFile(directoryPath, name, {type} = {}) {
|
|
|
64414
64377
|
const {
|
|
64415
64378
|
objectExpression,
|
|
64416
64379
|
arrayExpression: arrayExpression$1,
|
|
64417
|
-
stringLiteral: stringLiteral$
|
|
64380
|
+
stringLiteral: stringLiteral$4,
|
|
64418
64381
|
isArrayExpression,
|
|
64419
64382
|
isStringLiteral,
|
|
64420
64383
|
isTemplateLiteral,
|
|
@@ -64425,22 +64388,22 @@ const isDirectory = (a) => a.endsWith('/');
|
|
|
64425
64388
|
const getType = (a) => {
|
|
64426
64389
|
const type = isDirectory(a) ? 'directory' : 'file';
|
|
64427
64390
|
|
|
64428
|
-
return objectProperty$1(stringLiteral$
|
|
64391
|
+
return objectProperty$1(stringLiteral$4('type'), stringLiteral$4(type));
|
|
64429
64392
|
};
|
|
64430
64393
|
|
|
64431
64394
|
const createFilename = (filename) => {
|
|
64432
|
-
return objectProperty$1(stringLiteral$
|
|
64395
|
+
return objectProperty$1(stringLiteral$4('filename'), stringLiteral$4(filename));
|
|
64433
64396
|
};
|
|
64434
64397
|
|
|
64435
64398
|
const getFiles = (a) => {
|
|
64436
64399
|
if (isDirectory(a))
|
|
64437
|
-
return objectProperty$1(stringLiteral$
|
|
64400
|
+
return objectProperty$1(stringLiteral$4('files'), arrayExpression$1([]));
|
|
64438
64401
|
|
|
64439
64402
|
return null;
|
|
64440
64403
|
};
|
|
64441
64404
|
|
|
64442
64405
|
const getContent = (a) => {
|
|
64443
|
-
return objectProperty$1(stringLiteral$
|
|
64406
|
+
return objectProperty$1(stringLiteral$4('content'), stringLiteral$4(a));
|
|
64444
64407
|
};
|
|
64445
64408
|
|
|
64446
64409
|
function parseContent(node, path) {
|
|
@@ -64453,7 +64416,7 @@ function parseContent(node, path) {
|
|
|
64453
64416
|
throw Error(`☝️ Looks like wrong content type: '${node.type}' from file: '${path}'`);
|
|
64454
64417
|
}
|
|
64455
64418
|
|
|
64456
|
-
const fix$
|
|
64419
|
+
const fix$7 = (path) => {
|
|
64457
64420
|
const array = arrayExpression$1([]);
|
|
64458
64421
|
|
|
64459
64422
|
for (const element of path.get('elements')) {
|
|
@@ -64567,19 +64530,19 @@ function check$3(filename) {
|
|
|
64567
64530
|
|
|
64568
64531
|
var fromSimple = /*#__PURE__*/Object.freeze({
|
|
64569
64532
|
__proto__: null,
|
|
64570
|
-
fix: fix$
|
|
64533
|
+
fix: fix$7,
|
|
64571
64534
|
traverse: traverse$2
|
|
64572
64535
|
});
|
|
64573
64536
|
|
|
64574
64537
|
const {
|
|
64575
|
-
stringLiteral: stringLiteral$
|
|
64538
|
+
stringLiteral: stringLiteral$3,
|
|
64576
64539
|
arrayExpression,
|
|
64577
64540
|
} = lib_exports;
|
|
64578
64541
|
|
|
64579
64542
|
const {isArray} = Array;
|
|
64580
64543
|
const maybeAddSlash = (a) => a === '/' ? a : `${a}/`;
|
|
64581
64544
|
|
|
64582
|
-
const fix$
|
|
64545
|
+
const fix$6 = (root, {files}) => {
|
|
64583
64546
|
const names = [];
|
|
64584
64547
|
|
|
64585
64548
|
for (const file of files) {
|
|
@@ -64606,13 +64569,13 @@ const fix$4 = (root, {files}) => {
|
|
|
64606
64569
|
for (const name of names) {
|
|
64607
64570
|
if (isArray(name)) {
|
|
64608
64571
|
list.push(arrayExpression([
|
|
64609
|
-
stringLiteral$
|
|
64610
|
-
stringLiteral$
|
|
64572
|
+
stringLiteral$3(name[0]),
|
|
64573
|
+
stringLiteral$3(name[1]),
|
|
64611
64574
|
]));
|
|
64612
64575
|
continue;
|
|
64613
64576
|
}
|
|
64614
64577
|
|
|
64615
|
-
list.push(stringLiteral$
|
|
64578
|
+
list.push(stringLiteral$3(name));
|
|
64616
64579
|
}
|
|
64617
64580
|
|
|
64618
64581
|
replaceWith(root, arrayExpression(list));
|
|
@@ -64631,13 +64594,13 @@ const traverse$1 = ({push}) => ({
|
|
|
64631
64594
|
|
|
64632
64595
|
var toSimple = /*#__PURE__*/Object.freeze({
|
|
64633
64596
|
__proto__: null,
|
|
64634
|
-
fix: fix$
|
|
64597
|
+
fix: fix$6,
|
|
64635
64598
|
traverse: traverse$1
|
|
64636
64599
|
});
|
|
64637
64600
|
|
|
64638
64601
|
const log = createDebug$1('putout:runner:scanner');
|
|
64639
64602
|
|
|
64640
|
-
const scan = ({rule, plugin, msg, options}, {progress}) => {
|
|
64603
|
+
const scan$2 = ({rule, plugin, msg, options}, {progress}) => {
|
|
64641
64604
|
const {
|
|
64642
64605
|
scan,
|
|
64643
64606
|
report,
|
|
@@ -64646,7 +64609,7 @@ const scan = ({rule, plugin, msg, options}, {progress}) => {
|
|
|
64646
64609
|
|
|
64647
64610
|
progress.inc();
|
|
64648
64611
|
|
|
64649
|
-
const traverse = createTraverse({
|
|
64612
|
+
const traverse = createTraverse$2({
|
|
64650
64613
|
scan,
|
|
64651
64614
|
rule,
|
|
64652
64615
|
progress,
|
|
@@ -64703,7 +64666,7 @@ const createTrackFile = ({fileProgress, crawled}) => function*(...a) {
|
|
|
64703
64666
|
}
|
|
64704
64667
|
};
|
|
64705
64668
|
|
|
64706
|
-
const createTraverse = ({scan, rule, progress}) => ({push, options}) => ({
|
|
64669
|
+
const createTraverse$2 = ({scan, rule, progress}) => ({push, options}) => ({
|
|
64707
64670
|
[`${__filesystem_name}(__)`](path) {
|
|
64708
64671
|
log(rule);
|
|
64709
64672
|
progress.start(rule);
|
|
@@ -64962,7 +64925,7 @@ function splitPlugins(plugins, {progress}) {
|
|
|
64962
64925
|
}
|
|
64963
64926
|
|
|
64964
64927
|
if (plugin.scan) {
|
|
64965
|
-
pluginsTraverse.push(scan(item, {
|
|
64928
|
+
pluginsTraverse.push(scan$2(item, {
|
|
64966
64929
|
progress,
|
|
64967
64930
|
}));
|
|
64968
64931
|
continue;
|
|
@@ -65125,7 +65088,7 @@ const putout = (source, opts) => {
|
|
|
65125
65088
|
|
|
65126
65089
|
const [clearSource, shebang] = cutShebang(source);
|
|
65127
65090
|
|
|
65128
|
-
const ast = parse$
|
|
65091
|
+
const ast = parse$4(clearSource, {
|
|
65129
65092
|
parser,
|
|
65130
65093
|
isTS,
|
|
65131
65094
|
isJSX,
|
|
@@ -65166,7 +65129,7 @@ const putoutAsync = async (source, opts) => {
|
|
|
65166
65129
|
|
|
65167
65130
|
const [clearSource, shebang] = cutShebang(source);
|
|
65168
65131
|
|
|
65169
|
-
const ast = parse$
|
|
65132
|
+
const ast = parse$4(clearSource, {
|
|
65170
65133
|
parser,
|
|
65171
65134
|
isTS,
|
|
65172
65135
|
isJSX,
|
|
@@ -65204,7 +65167,7 @@ const {
|
|
|
65204
65167
|
isJSXElement,
|
|
65205
65168
|
jsxAttribute,
|
|
65206
65169
|
jsxIdentifier,
|
|
65207
|
-
stringLiteral: stringLiteral$
|
|
65170
|
+
stringLiteral: stringLiteral$2,
|
|
65208
65171
|
} = lib_exports;
|
|
65209
65172
|
|
|
65210
65173
|
const getNode = (a) => a.node || a;
|
|
@@ -65270,7 +65233,7 @@ function addAttribute(path, name, value) {
|
|
|
65270
65233
|
let attributeNode = getAttributeNode(node, name);
|
|
65271
65234
|
|
|
65272
65235
|
if (!attributeNode) {
|
|
65273
|
-
attributeNode = jsxAttribute(jsxIdentifier(name), stringLiteral$
|
|
65236
|
+
attributeNode = jsxAttribute(jsxIdentifier(name), stringLiteral$2(value));
|
|
65274
65237
|
node.openingElement.attributes.push(attributeNode);
|
|
65275
65238
|
}
|
|
65276
65239
|
}
|
|
@@ -68154,7 +68117,7 @@ function increaseQuantifierByOne$2(quantifier) {
|
|
|
68154
68117
|
}
|
|
68155
68118
|
}
|
|
68156
68119
|
|
|
68157
|
-
var utils = {
|
|
68120
|
+
var utils$5 = {
|
|
68158
68121
|
disjunctionToList: disjunctionToList$1,
|
|
68159
68122
|
listToDisjunction: listToDisjunction$1,
|
|
68160
68123
|
increaseQuantifierByOne: increaseQuantifierByOne$2
|
|
@@ -68165,7 +68128,7 @@ var utils = {
|
|
|
68165
68128
|
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
|
68166
68129
|
*/
|
|
68167
68130
|
|
|
68168
|
-
var _require$5 = utils,
|
|
68131
|
+
var _require$5 = utils$5,
|
|
68169
68132
|
increaseQuantifierByOne$1 = _require$5.increaseQuantifierByOne;
|
|
68170
68133
|
|
|
68171
68134
|
/**
|
|
@@ -69163,7 +69126,7 @@ function isMetaWCharOrCode(expression) {
|
|
|
69163
69126
|
|
|
69164
69127
|
var NodePath$1 = nodePath;
|
|
69165
69128
|
|
|
69166
|
-
var _require$4 = utils,
|
|
69129
|
+
var _require$4 = utils$5,
|
|
69167
69130
|
disjunctionToList = _require$4.disjunctionToList,
|
|
69168
69131
|
listToDisjunction = _require$4.listToDisjunction;
|
|
69169
69132
|
|
|
@@ -69421,7 +69384,7 @@ function _toConsumableArray$3(arr) { if (Array.isArray(arr)) { for (var i = 0, a
|
|
|
69421
69384
|
|
|
69422
69385
|
var NodePath = nodePath;
|
|
69423
69386
|
|
|
69424
|
-
var _require$3 = utils,
|
|
69387
|
+
var _require$3 = utils$5,
|
|
69425
69388
|
increaseQuantifierByOne = _require$3.increaseQuantifierByOne;
|
|
69426
69389
|
|
|
69427
69390
|
/**
|
|
@@ -71238,11 +71201,11 @@ const report$3 = ({name}) => `Argument '${name}' is missing`;
|
|
|
71238
71201
|
|
|
71239
71202
|
const addArgs = (args) => ({
|
|
71240
71203
|
report: report$3,
|
|
71241
|
-
fix: fix$
|
|
71204
|
+
fix: fix$5,
|
|
71242
71205
|
traverse: traverse(args),
|
|
71243
71206
|
});
|
|
71244
71207
|
|
|
71245
|
-
const fix$
|
|
71208
|
+
const fix$5 = ({declaration, path, pattern, params, index}) => {
|
|
71246
71209
|
const declarationNode = template$1.ast.fresh(declaration);
|
|
71247
71210
|
|
|
71248
71211
|
if (isSequenceExpression(declarationNode)) {
|
|
@@ -71357,10 +71320,11 @@ function getObjectPattern(params) {
|
|
|
71357
71320
|
const moduleDeclarations = [
|
|
71358
71321
|
'import',
|
|
71359
71322
|
'export',
|
|
71360
|
-
'assert',
|
|
71361
71323
|
'with',
|
|
71362
71324
|
];
|
|
71363
71325
|
|
|
71326
|
+
const legacyKeywords = ['assert'];
|
|
71327
|
+
|
|
71364
71328
|
const declarations = [
|
|
71365
71329
|
'const',
|
|
71366
71330
|
'var',
|
|
@@ -71446,6 +71410,10 @@ const isTSKeyword = (name) => {
|
|
|
71446
71410
|
return ts || tsReserved;
|
|
71447
71411
|
};
|
|
71448
71412
|
|
|
71413
|
+
const isLegacyKeyword = (name) => {
|
|
71414
|
+
return legacyKeywords.includes(name);
|
|
71415
|
+
};
|
|
71416
|
+
|
|
71449
71417
|
const findPlaces = (ast, source, opts) => {
|
|
71450
71418
|
return transform(ast, source, {
|
|
71451
71419
|
...opts,
|
|
@@ -71488,7 +71456,7 @@ function mergeIgnores(ignores) {
|
|
|
71488
71456
|
|
|
71489
71457
|
const {join} = path;
|
|
71490
71458
|
|
|
71491
|
-
const isObject = (a) => a && typeof a === 'object';
|
|
71459
|
+
const isObject$1 = (a) => a && typeof a === 'object';
|
|
71492
71460
|
const {entries} = Object;
|
|
71493
71461
|
const report$2 = (path, {message}) => message;
|
|
71494
71462
|
|
|
@@ -71506,13 +71474,13 @@ const matchFiles = (options) => {
|
|
|
71506
71474
|
});
|
|
71507
71475
|
|
|
71508
71476
|
return {
|
|
71509
|
-
fix: fix$
|
|
71477
|
+
fix: fix$4,
|
|
71510
71478
|
scan,
|
|
71511
71479
|
report: report$2,
|
|
71512
71480
|
};
|
|
71513
71481
|
};
|
|
71514
71482
|
|
|
71515
|
-
function fix$
|
|
71483
|
+
function fix$4(inputFile, {dirPath, matchInputFilename, outputFilename, matchedJS, matchedAST, options, rawOptions}) {
|
|
71516
71484
|
transform(matchedAST, matchedJS, options);
|
|
71517
71485
|
|
|
71518
71486
|
const matchedJSON = magicPrint(outputFilename, matchedAST, rawOptions);
|
|
@@ -71607,20 +71575,20 @@ const createScan$2 = ({files, exclude, defaultFilename}) => (mainPath, {push, pr
|
|
|
71607
71575
|
function magicParse(name, content) {
|
|
71608
71576
|
if (name.endsWith('.json')) {
|
|
71609
71577
|
const js = toJS(content);
|
|
71610
|
-
const ast = parse$
|
|
71578
|
+
const ast = parse$4(js);
|
|
71611
71579
|
|
|
71612
71580
|
return [js, ast];
|
|
71613
71581
|
}
|
|
71614
71582
|
|
|
71615
71583
|
if (/\.[cm]?ts(x)?$/.test(name)) {
|
|
71616
|
-
const ast = parse$
|
|
71584
|
+
const ast = parse$4(content, {
|
|
71617
71585
|
isTS: true,
|
|
71618
71586
|
});
|
|
71619
71587
|
|
|
71620
71588
|
return [content, ast];
|
|
71621
71589
|
}
|
|
71622
71590
|
|
|
71623
|
-
return [content, parse$
|
|
71591
|
+
return [content, parse$4(content)];
|
|
71624
71592
|
}
|
|
71625
71593
|
|
|
71626
71594
|
function magicPrint(name, ast, options) {
|
|
@@ -71635,7 +71603,7 @@ function magicPrint(name, ast, options) {
|
|
|
71635
71603
|
|
|
71636
71604
|
function check(files) {
|
|
71637
71605
|
for (const [, plugin] of entries(files)) {
|
|
71638
|
-
if (!isObject(plugin))
|
|
71606
|
+
if (!isObject$1(plugin))
|
|
71639
71607
|
throw Error(`☝️ Looks like provided to 'matchFiles()' typeof of plugin is not an 'object' but '${typeof plugin}'`);
|
|
71640
71608
|
}
|
|
71641
71609
|
}
|
|
@@ -71682,11 +71650,11 @@ function parseOptions(inputFilename, rawOptions) {
|
|
|
71682
71650
|
};
|
|
71683
71651
|
}
|
|
71684
71652
|
|
|
71685
|
-
const {parse} = JSON;
|
|
71653
|
+
const {parse: parse$2} = JSON;
|
|
71686
71654
|
|
|
71687
71655
|
const report$1 = (file, {from, to}) => `Rename '${from}' to '${to}'`;
|
|
71688
71656
|
|
|
71689
|
-
const fix$
|
|
71657
|
+
const fix$3 = (file, {to}) => {
|
|
71690
71658
|
renameFile(file, to);
|
|
71691
71659
|
};
|
|
71692
71660
|
|
|
@@ -71719,7 +71687,7 @@ function checkType(type, file) {
|
|
|
71719
71687
|
if (!packageContent)
|
|
71720
71688
|
return false;
|
|
71721
71689
|
|
|
71722
|
-
const info = parse(packageContent);
|
|
71690
|
+
const info = parse$2(packageContent);
|
|
71723
71691
|
const infoType = info.type || 'commonjs';
|
|
71724
71692
|
|
|
71725
71693
|
return infoType === type;
|
|
@@ -71740,7 +71708,7 @@ function findUpPackage(file) {
|
|
|
71740
71708
|
var renameFileWithFn = /*#__PURE__*/Object.freeze({
|
|
71741
71709
|
__proto__: null,
|
|
71742
71710
|
createScan: createScan$1,
|
|
71743
|
-
fix: fix$
|
|
71711
|
+
fix: fix$3,
|
|
71744
71712
|
report: report$1
|
|
71745
71713
|
});
|
|
71746
71714
|
|
|
@@ -71753,7 +71721,7 @@ const report = (path, {mask, from, to}) => {
|
|
|
71753
71721
|
return `Rename '${mask}' to '${mask.replace(from, to)}'`;
|
|
71754
71722
|
};
|
|
71755
71723
|
|
|
71756
|
-
const fix = (path, {from, to}) => {
|
|
71724
|
+
const fix$2 = (path, {from, to}) => {
|
|
71757
71725
|
const filename = getFilename(path);
|
|
71758
71726
|
const newFilename = filename.replace(from, to);
|
|
71759
71727
|
|
|
@@ -71801,7 +71769,7 @@ const createCheckNear = (near) => (file) => {
|
|
|
71801
71769
|
var renameFileByMask = /*#__PURE__*/Object.freeze({
|
|
71802
71770
|
__proto__: null,
|
|
71803
71771
|
createScan: createScan,
|
|
71804
|
-
fix: fix,
|
|
71772
|
+
fix: fix$2,
|
|
71805
71773
|
report: report
|
|
71806
71774
|
});
|
|
71807
71775
|
|
|
@@ -71842,220 +71810,2444 @@ const renameFiles = ({type, mask, rename, from, to, near} = {}) => {
|
|
|
71842
71810
|
};
|
|
71843
71811
|
};
|
|
71844
71812
|
|
|
71845
|
-
|
|
71846
|
-
const getValue = ({value}) => value;
|
|
71813
|
+
var utils$4 = {};
|
|
71847
71814
|
|
|
71848
|
-
const
|
|
71849
|
-
|
|
71850
|
-
|
|
71851
|
-
|
|
71852
|
-
|
|
71853
|
-
|
|
71854
|
-
|
|
71855
|
-
|
|
71856
|
-
|
|
71857
|
-
|
|
71858
|
-
|
|
71859
|
-
|
|
71860
|
-
|
|
71861
|
-
|
|
71862
|
-
|
|
71863
|
-
|
|
71864
|
-
|
|
71865
|
-
|
|
71815
|
+
const WIN_SLASH = '\\\\/';
|
|
71816
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
71817
|
+
|
|
71818
|
+
/**
|
|
71819
|
+
* Posix glob regex
|
|
71820
|
+
*/
|
|
71821
|
+
|
|
71822
|
+
const DOT_LITERAL = '\\.';
|
|
71823
|
+
const PLUS_LITERAL = '\\+';
|
|
71824
|
+
const QMARK_LITERAL = '\\?';
|
|
71825
|
+
const SLASH_LITERAL = '\\/';
|
|
71826
|
+
const ONE_CHAR = '(?=.)';
|
|
71827
|
+
const QMARK = '[^/]';
|
|
71828
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
71829
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
71830
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
71831
|
+
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
71832
|
+
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
71833
|
+
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
71834
|
+
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
71835
|
+
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
71836
|
+
const STAR = `${QMARK}*?`;
|
|
71837
|
+
const SEP = '/';
|
|
71838
|
+
|
|
71839
|
+
const POSIX_CHARS = {
|
|
71840
|
+
DOT_LITERAL,
|
|
71841
|
+
PLUS_LITERAL,
|
|
71842
|
+
QMARK_LITERAL,
|
|
71843
|
+
SLASH_LITERAL,
|
|
71844
|
+
ONE_CHAR,
|
|
71845
|
+
QMARK,
|
|
71846
|
+
END_ANCHOR,
|
|
71847
|
+
DOTS_SLASH,
|
|
71848
|
+
NO_DOT,
|
|
71849
|
+
NO_DOTS,
|
|
71850
|
+
NO_DOT_SLASH,
|
|
71851
|
+
NO_DOTS_SLASH,
|
|
71852
|
+
QMARK_NO_DOT,
|
|
71853
|
+
STAR,
|
|
71854
|
+
START_ANCHOR,
|
|
71855
|
+
SEP
|
|
71866
71856
|
};
|
|
71867
71857
|
|
|
71868
|
-
|
|
71858
|
+
/**
|
|
71859
|
+
* Windows glob regex
|
|
71860
|
+
*/
|
|
71869
71861
|
|
|
71870
|
-
const
|
|
71871
|
-
|
|
71872
|
-
|
|
71873
|
-
|
|
71874
|
-
|
|
71875
|
-
|
|
71876
|
-
|
|
71877
|
-
|
|
71878
|
-
|
|
71879
|
-
|
|
71880
|
-
|
|
71881
|
-
|
|
71882
|
-
|
|
71883
|
-
|
|
71884
|
-
|
|
71885
|
-
|
|
71886
|
-
for (const name of newNames) {
|
|
71887
|
-
if (!list.includes(name))
|
|
71888
|
-
return true;
|
|
71889
|
-
}
|
|
71890
|
-
|
|
71891
|
-
return false;
|
|
71892
|
-
},
|
|
71893
|
-
};
|
|
71862
|
+
const WINDOWS_CHARS = {
|
|
71863
|
+
...POSIX_CHARS,
|
|
71864
|
+
|
|
71865
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
71866
|
+
QMARK: WIN_NO_SLASH,
|
|
71867
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
71868
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
71869
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
71870
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
71871
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
71872
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
71873
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
71874
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
71875
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
71876
|
+
SEP: '\\'
|
|
71894
71877
|
};
|
|
71895
71878
|
|
|
71896
|
-
|
|
71897
|
-
|
|
71898
|
-
|
|
71899
|
-
|
|
71879
|
+
/**
|
|
71880
|
+
* POSIX Bracket Regex
|
|
71881
|
+
*/
|
|
71882
|
+
|
|
71883
|
+
const POSIX_REGEX_SOURCE$1 = {
|
|
71884
|
+
alnum: 'a-zA-Z0-9',
|
|
71885
|
+
alpha: 'a-zA-Z',
|
|
71886
|
+
ascii: '\\x00-\\x7F',
|
|
71887
|
+
blank: ' \\t',
|
|
71888
|
+
cntrl: '\\x00-\\x1F\\x7F',
|
|
71889
|
+
digit: '0-9',
|
|
71890
|
+
graph: '\\x21-\\x7E',
|
|
71891
|
+
lower: 'a-z',
|
|
71892
|
+
print: '\\x20-\\x7E ',
|
|
71893
|
+
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
71894
|
+
space: ' \\t\\r\\n\\v\\f',
|
|
71895
|
+
upper: 'A-Z',
|
|
71896
|
+
word: 'A-Za-z0-9_',
|
|
71897
|
+
xdigit: 'A-Fa-f0-9'
|
|
71898
|
+
};
|
|
71899
|
+
|
|
71900
|
+
var constants$2 = {
|
|
71901
|
+
MAX_LENGTH: 1024 * 64,
|
|
71902
|
+
POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
|
|
71903
|
+
|
|
71904
|
+
// regular expressions
|
|
71905
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
71906
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
71907
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
71908
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
71909
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
71910
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
71911
|
+
|
|
71912
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
71913
|
+
REPLACEMENTS: {
|
|
71914
|
+
__proto__: null,
|
|
71915
|
+
'***': '*',
|
|
71916
|
+
'**/**': '**',
|
|
71917
|
+
'**/**/**': '**'
|
|
71918
|
+
},
|
|
71919
|
+
|
|
71920
|
+
// Digits
|
|
71921
|
+
CHAR_0: 48, /* 0 */
|
|
71922
|
+
CHAR_9: 57, /* 9 */
|
|
71923
|
+
|
|
71924
|
+
// Alphabet chars.
|
|
71925
|
+
CHAR_UPPERCASE_A: 65, /* A */
|
|
71926
|
+
CHAR_LOWERCASE_A: 97, /* a */
|
|
71927
|
+
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
71928
|
+
CHAR_LOWERCASE_Z: 122, /* z */
|
|
71929
|
+
|
|
71930
|
+
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
71931
|
+
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
71932
|
+
|
|
71933
|
+
CHAR_ASTERISK: 42, /* * */
|
|
71934
|
+
|
|
71935
|
+
// Non-alphabetic chars.
|
|
71936
|
+
CHAR_AMPERSAND: 38, /* & */
|
|
71937
|
+
CHAR_AT: 64, /* @ */
|
|
71938
|
+
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
71939
|
+
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
71940
|
+
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
71941
|
+
CHAR_COLON: 58, /* : */
|
|
71942
|
+
CHAR_COMMA: 44, /* , */
|
|
71943
|
+
CHAR_DOT: 46, /* . */
|
|
71944
|
+
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
71945
|
+
CHAR_EQUAL: 61, /* = */
|
|
71946
|
+
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
71947
|
+
CHAR_FORM_FEED: 12, /* \f */
|
|
71948
|
+
CHAR_FORWARD_SLASH: 47, /* / */
|
|
71949
|
+
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
71950
|
+
CHAR_HASH: 35, /* # */
|
|
71951
|
+
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
71952
|
+
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
71953
|
+
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
71954
|
+
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
71955
|
+
CHAR_LINE_FEED: 10, /* \n */
|
|
71956
|
+
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
71957
|
+
CHAR_PERCENT: 37, /* % */
|
|
71958
|
+
CHAR_PLUS: 43, /* + */
|
|
71959
|
+
CHAR_QUESTION_MARK: 63, /* ? */
|
|
71960
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
71961
|
+
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
71962
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
71963
|
+
CHAR_SEMICOLON: 59, /* ; */
|
|
71964
|
+
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
71965
|
+
CHAR_SPACE: 32, /* */
|
|
71966
|
+
CHAR_TAB: 9, /* \t */
|
|
71967
|
+
CHAR_UNDERSCORE: 95, /* _ */
|
|
71968
|
+
CHAR_VERTICAL_LINE: 124, /* | */
|
|
71969
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
71970
|
+
|
|
71971
|
+
/**
|
|
71972
|
+
* Create EXTGLOB_CHARS
|
|
71973
|
+
*/
|
|
71974
|
+
|
|
71975
|
+
extglobChars(chars) {
|
|
71900
71976
|
return {
|
|
71901
|
-
|
|
71902
|
-
|
|
71903
|
-
|
|
71904
|
-
|
|
71905
|
-
|
|
71906
|
-
|
|
71907
|
-
const list = elements.map(getValue);
|
|
71908
|
-
|
|
71909
|
-
for (const name of newNames) {
|
|
71910
|
-
if (!list.includes(name))
|
|
71911
|
-
elements.push(stringLiteral(name));
|
|
71912
|
-
}
|
|
71913
|
-
|
|
71914
|
-
return path;
|
|
71915
|
-
},
|
|
71977
|
+
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
71978
|
+
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
71979
|
+
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
71980
|
+
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
71981
|
+
'@': { type: 'at', open: '(?:', close: ')' }
|
|
71916
71982
|
};
|
|
71983
|
+
},
|
|
71984
|
+
|
|
71985
|
+
/**
|
|
71986
|
+
* Create GLOB_CHARS
|
|
71987
|
+
*/
|
|
71988
|
+
|
|
71989
|
+
globChars(win32) {
|
|
71990
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
71991
|
+
}
|
|
71917
71992
|
};
|
|
71918
71993
|
|
|
71919
|
-
|
|
71920
|
-
|
|
71921
|
-
|
|
71922
|
-
|
|
71923
|
-
|
|
71994
|
+
constants$2.default;
|
|
71995
|
+
|
|
71996
|
+
(function (exports$1) {
|
|
71997
|
+
|
|
71998
|
+
const {
|
|
71999
|
+
REGEX_BACKSLASH,
|
|
72000
|
+
REGEX_REMOVE_BACKSLASH,
|
|
72001
|
+
REGEX_SPECIAL_CHARS,
|
|
72002
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
72003
|
+
} = constants$2;
|
|
72004
|
+
|
|
72005
|
+
exports$1.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
72006
|
+
exports$1.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
72007
|
+
exports$1.isRegexChar = str => str.length === 1 && exports$1.hasRegexChars(str);
|
|
72008
|
+
exports$1.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
72009
|
+
exports$1.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
72010
|
+
|
|
72011
|
+
exports$1.isWindows = () => {
|
|
72012
|
+
if (typeof navigator !== 'undefined' && navigator.platform) {
|
|
72013
|
+
const platform = navigator.platform.toLowerCase();
|
|
72014
|
+
return platform === 'win32' || platform === 'windows';
|
|
72015
|
+
}
|
|
72016
|
+
|
|
72017
|
+
if (typeof browser$1 !== 'undefined' && "unix") {
|
|
72018
|
+
return "unix" === 'win32';
|
|
72019
|
+
}
|
|
72020
|
+
|
|
72021
|
+
return false;
|
|
72022
|
+
};
|
|
72023
|
+
|
|
72024
|
+
exports$1.removeBackslashes = str => {
|
|
72025
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
|
72026
|
+
return match === '\\' ? '' : match;
|
|
72027
|
+
});
|
|
72028
|
+
};
|
|
72029
|
+
|
|
72030
|
+
exports$1.escapeLast = (input, char, lastIdx) => {
|
|
72031
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
72032
|
+
if (idx === -1) return input;
|
|
72033
|
+
if (input[idx - 1] === '\\') return exports$1.escapeLast(input, char, idx - 1);
|
|
72034
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
72035
|
+
};
|
|
72036
|
+
|
|
72037
|
+
exports$1.removePrefix = (input, state = {}) => {
|
|
72038
|
+
let output = input;
|
|
72039
|
+
if (output.startsWith('./')) {
|
|
72040
|
+
output = output.slice(2);
|
|
72041
|
+
state.prefix = './';
|
|
72042
|
+
}
|
|
72043
|
+
return output;
|
|
72044
|
+
};
|
|
72045
|
+
|
|
72046
|
+
exports$1.wrapOutput = (input, state = {}, options = {}) => {
|
|
72047
|
+
const prepend = options.contains ? '' : '^';
|
|
72048
|
+
const append = options.contains ? '' : '$';
|
|
72049
|
+
|
|
72050
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
72051
|
+
if (state.negated === true) {
|
|
72052
|
+
output = `(?:^(?!${output}).*$)`;
|
|
72053
|
+
}
|
|
72054
|
+
return output;
|
|
72055
|
+
};
|
|
72056
|
+
|
|
72057
|
+
exports$1.basename = (path, { windows } = {}) => {
|
|
72058
|
+
const segs = path.split(windows ? /[\\/]/ : '/');
|
|
72059
|
+
const last = segs[segs.length - 1];
|
|
72060
|
+
|
|
72061
|
+
if (last === '') {
|
|
72062
|
+
return segs[segs.length - 2];
|
|
72063
|
+
}
|
|
72064
|
+
|
|
72065
|
+
return last;
|
|
72066
|
+
};
|
|
72067
|
+
} (utils$4));
|
|
72068
|
+
|
|
72069
|
+
utils$4.default;
|
|
72070
|
+
|
|
72071
|
+
const utils$3 = utils$4;
|
|
72072
|
+
const {
|
|
72073
|
+
CHAR_ASTERISK, /* * */
|
|
72074
|
+
CHAR_AT, /* @ */
|
|
72075
|
+
CHAR_BACKWARD_SLASH, /* \ */
|
|
72076
|
+
CHAR_COMMA, /* , */
|
|
72077
|
+
CHAR_DOT, /* . */
|
|
72078
|
+
CHAR_EXCLAMATION_MARK, /* ! */
|
|
72079
|
+
CHAR_FORWARD_SLASH, /* / */
|
|
72080
|
+
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
72081
|
+
CHAR_LEFT_PARENTHESES, /* ( */
|
|
72082
|
+
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
72083
|
+
CHAR_PLUS, /* + */
|
|
72084
|
+
CHAR_QUESTION_MARK, /* ? */
|
|
72085
|
+
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
72086
|
+
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
72087
|
+
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
72088
|
+
} = constants$2;
|
|
72089
|
+
|
|
72090
|
+
const isPathSeparator = code => {
|
|
72091
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
72092
|
+
};
|
|
72093
|
+
|
|
72094
|
+
const depth = token => {
|
|
72095
|
+
if (token.isPrefix !== true) {
|
|
72096
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
72097
|
+
}
|
|
72098
|
+
};
|
|
72099
|
+
|
|
72100
|
+
/**
|
|
72101
|
+
* Quickly scans a glob pattern and returns an object with a handful of
|
|
72102
|
+
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
72103
|
+
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
72104
|
+
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
72105
|
+
*
|
|
72106
|
+
* ```js
|
|
72107
|
+
* const pm = require('picomatch');
|
|
72108
|
+
* console.log(pm.scan('foo/bar/*.js'));
|
|
72109
|
+
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
72110
|
+
* ```
|
|
72111
|
+
* @param {String} `str`
|
|
72112
|
+
* @param {Object} `options`
|
|
72113
|
+
* @return {Object} Returns an object with tokens and regex source string.
|
|
72114
|
+
* @api public
|
|
72115
|
+
*/
|
|
72116
|
+
|
|
72117
|
+
const scan$1 = (input, options) => {
|
|
72118
|
+
const opts = options || {};
|
|
72119
|
+
|
|
72120
|
+
const length = input.length - 1;
|
|
72121
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
72122
|
+
const slashes = [];
|
|
72123
|
+
const tokens = [];
|
|
72124
|
+
const parts = [];
|
|
72125
|
+
|
|
72126
|
+
let str = input;
|
|
72127
|
+
let index = -1;
|
|
72128
|
+
let start = 0;
|
|
72129
|
+
let lastIndex = 0;
|
|
72130
|
+
let isBrace = false;
|
|
72131
|
+
let isBracket = false;
|
|
72132
|
+
let isGlob = false;
|
|
72133
|
+
let isExtglob = false;
|
|
72134
|
+
let isGlobstar = false;
|
|
72135
|
+
let braceEscaped = false;
|
|
72136
|
+
let backslashes = false;
|
|
72137
|
+
let negated = false;
|
|
72138
|
+
let negatedExtglob = false;
|
|
72139
|
+
let finished = false;
|
|
72140
|
+
let braces = 0;
|
|
72141
|
+
let prev;
|
|
72142
|
+
let code;
|
|
72143
|
+
let token = { value: '', depth: 0, isGlob: false };
|
|
72144
|
+
|
|
72145
|
+
const eos = () => index >= length;
|
|
72146
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
72147
|
+
const advance = () => {
|
|
72148
|
+
prev = code;
|
|
72149
|
+
return str.charCodeAt(++index);
|
|
72150
|
+
};
|
|
72151
|
+
|
|
72152
|
+
while (index < length) {
|
|
72153
|
+
code = advance();
|
|
72154
|
+
let next;
|
|
72155
|
+
|
|
72156
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
72157
|
+
backslashes = token.backslashes = true;
|
|
72158
|
+
code = advance();
|
|
72159
|
+
|
|
72160
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
72161
|
+
braceEscaped = true;
|
|
72162
|
+
}
|
|
72163
|
+
continue;
|
|
72164
|
+
}
|
|
72165
|
+
|
|
72166
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
72167
|
+
braces++;
|
|
72168
|
+
|
|
72169
|
+
while (eos() !== true && (code = advance())) {
|
|
72170
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
72171
|
+
backslashes = token.backslashes = true;
|
|
72172
|
+
advance();
|
|
72173
|
+
continue;
|
|
72174
|
+
}
|
|
72175
|
+
|
|
72176
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
72177
|
+
braces++;
|
|
72178
|
+
continue;
|
|
72179
|
+
}
|
|
72180
|
+
|
|
72181
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
72182
|
+
isBrace = token.isBrace = true;
|
|
72183
|
+
isGlob = token.isGlob = true;
|
|
72184
|
+
finished = true;
|
|
72185
|
+
|
|
72186
|
+
if (scanToEnd === true) {
|
|
71924
72187
|
continue;
|
|
71925
|
-
|
|
71926
|
-
|
|
72188
|
+
}
|
|
72189
|
+
|
|
72190
|
+
break;
|
|
72191
|
+
}
|
|
72192
|
+
|
|
72193
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
72194
|
+
isBrace = token.isBrace = true;
|
|
72195
|
+
isGlob = token.isGlob = true;
|
|
72196
|
+
finished = true;
|
|
72197
|
+
|
|
72198
|
+
if (scanToEnd === true) {
|
|
72199
|
+
continue;
|
|
72200
|
+
}
|
|
72201
|
+
|
|
72202
|
+
break;
|
|
72203
|
+
}
|
|
72204
|
+
|
|
72205
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
72206
|
+
braces--;
|
|
72207
|
+
|
|
72208
|
+
if (braces === 0) {
|
|
72209
|
+
braceEscaped = false;
|
|
72210
|
+
isBrace = token.isBrace = true;
|
|
72211
|
+
finished = true;
|
|
72212
|
+
break;
|
|
72213
|
+
}
|
|
72214
|
+
}
|
|
72215
|
+
}
|
|
72216
|
+
|
|
72217
|
+
if (scanToEnd === true) {
|
|
72218
|
+
continue;
|
|
72219
|
+
}
|
|
72220
|
+
|
|
72221
|
+
break;
|
|
71927
72222
|
}
|
|
71928
|
-
|
|
71929
|
-
return newNames;
|
|
71930
|
-
}
|
|
71931
72223
|
|
|
71932
|
-
|
|
71933
|
-
|
|
71934
|
-
|
|
71935
|
-
|
|
71936
|
-
return node.elements;
|
|
71937
|
-
|
|
71938
|
-
const [prop] = traverseProperties(node, property);
|
|
71939
|
-
|
|
71940
|
-
if (!prop)
|
|
71941
|
-
return null;
|
|
71942
|
-
|
|
71943
|
-
return prop.node.value.elements;
|
|
71944
|
-
}
|
|
72224
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
72225
|
+
slashes.push(index);
|
|
72226
|
+
tokens.push(token);
|
|
72227
|
+
token = { value: '', depth: 0, isGlob: false };
|
|
71945
72228
|
|
|
71946
|
-
|
|
71947
|
-
|
|
71948
|
-
|
|
71949
|
-
|
|
72229
|
+
if (finished === true) continue;
|
|
72230
|
+
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
72231
|
+
start += 2;
|
|
72232
|
+
continue;
|
|
72233
|
+
}
|
|
71950
72234
|
|
|
71951
|
-
|
|
71952
|
-
|
|
71953
|
-
|
|
71954
|
-
if (hasParens(path, printer))
|
|
71955
|
-
return path;
|
|
71956
|
-
|
|
71957
|
-
if (printer !== 'babel') {
|
|
71958
|
-
const {extra = {}} = path.node;
|
|
71959
|
-
|
|
71960
|
-
extra.parenthesized = true;
|
|
71961
|
-
path.node.extra = extra;
|
|
71962
|
-
|
|
71963
|
-
return path;
|
|
72235
|
+
lastIndex = index + 1;
|
|
72236
|
+
continue;
|
|
71964
72237
|
}
|
|
71965
|
-
|
|
71966
|
-
const {node} = path;
|
|
71967
|
-
|
|
71968
|
-
if (path.type.startsWith('TS'))
|
|
71969
|
-
return path.replaceWith(tsParenthesizedType(node));
|
|
71970
|
-
|
|
71971
|
-
path.replaceWith(parenthesizedExpression(node));
|
|
71972
|
-
|
|
71973
|
-
return path;
|
|
71974
|
-
};
|
|
71975
72238
|
|
|
71976
|
-
|
|
71977
|
-
|
|
71978
|
-
|
|
71979
|
-
|
|
71980
|
-
|
|
71981
|
-
|
|
71982
|
-
|
|
71983
|
-
|
|
71984
|
-
|
|
72239
|
+
if (opts.noext !== true) {
|
|
72240
|
+
const isExtglobChar = code === CHAR_PLUS
|
|
72241
|
+
|| code === CHAR_AT
|
|
72242
|
+
|| code === CHAR_ASTERISK
|
|
72243
|
+
|| code === CHAR_QUESTION_MARK
|
|
72244
|
+
|| code === CHAR_EXCLAMATION_MARK;
|
|
72245
|
+
|
|
72246
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
72247
|
+
isGlob = token.isGlob = true;
|
|
72248
|
+
isExtglob = token.isExtglob = true;
|
|
72249
|
+
finished = true;
|
|
72250
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
72251
|
+
negatedExtglob = true;
|
|
72252
|
+
}
|
|
72253
|
+
|
|
72254
|
+
if (scanToEnd === true) {
|
|
72255
|
+
while (eos() !== true && (code = advance())) {
|
|
72256
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
72257
|
+
backslashes = token.backslashes = true;
|
|
72258
|
+
code = advance();
|
|
72259
|
+
continue;
|
|
72260
|
+
}
|
|
72261
|
+
|
|
72262
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
72263
|
+
isGlob = token.isGlob = true;
|
|
72264
|
+
finished = true;
|
|
72265
|
+
break;
|
|
72266
|
+
}
|
|
72267
|
+
}
|
|
72268
|
+
continue;
|
|
72269
|
+
}
|
|
72270
|
+
break;
|
|
72271
|
+
}
|
|
71985
72272
|
}
|
|
71986
|
-
|
|
71987
|
-
|
|
71988
|
-
|
|
71989
|
-
|
|
71990
|
-
|
|
72273
|
+
|
|
72274
|
+
if (code === CHAR_ASTERISK) {
|
|
72275
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
72276
|
+
isGlob = token.isGlob = true;
|
|
72277
|
+
finished = true;
|
|
72278
|
+
|
|
72279
|
+
if (scanToEnd === true) {
|
|
72280
|
+
continue;
|
|
72281
|
+
}
|
|
72282
|
+
break;
|
|
72283
|
+
}
|
|
72284
|
+
|
|
72285
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
72286
|
+
isGlob = token.isGlob = true;
|
|
72287
|
+
finished = true;
|
|
72288
|
+
|
|
72289
|
+
if (scanToEnd === true) {
|
|
72290
|
+
continue;
|
|
72291
|
+
}
|
|
72292
|
+
break;
|
|
72293
|
+
}
|
|
72294
|
+
|
|
72295
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
72296
|
+
while (eos() !== true && (next = advance())) {
|
|
72297
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
72298
|
+
backslashes = token.backslashes = true;
|
|
72299
|
+
advance();
|
|
72300
|
+
continue;
|
|
72301
|
+
}
|
|
72302
|
+
|
|
72303
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
72304
|
+
isBracket = token.isBracket = true;
|
|
72305
|
+
isGlob = token.isGlob = true;
|
|
72306
|
+
finished = true;
|
|
72307
|
+
break;
|
|
72308
|
+
}
|
|
72309
|
+
}
|
|
72310
|
+
|
|
72311
|
+
if (scanToEnd === true) {
|
|
72312
|
+
continue;
|
|
72313
|
+
}
|
|
72314
|
+
|
|
72315
|
+
break;
|
|
72316
|
+
}
|
|
72317
|
+
|
|
72318
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
72319
|
+
negated = token.negated = true;
|
|
72320
|
+
start++;
|
|
72321
|
+
continue;
|
|
72322
|
+
}
|
|
72323
|
+
|
|
72324
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
72325
|
+
isGlob = token.isGlob = true;
|
|
72326
|
+
|
|
72327
|
+
if (scanToEnd === true) {
|
|
72328
|
+
while (eos() !== true && (code = advance())) {
|
|
72329
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
72330
|
+
backslashes = token.backslashes = true;
|
|
72331
|
+
code = advance();
|
|
72332
|
+
continue;
|
|
72333
|
+
}
|
|
72334
|
+
|
|
72335
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
72336
|
+
finished = true;
|
|
72337
|
+
break;
|
|
72338
|
+
}
|
|
72339
|
+
}
|
|
72340
|
+
continue;
|
|
72341
|
+
}
|
|
72342
|
+
break;
|
|
72343
|
+
}
|
|
72344
|
+
|
|
72345
|
+
if (isGlob === true) {
|
|
72346
|
+
finished = true;
|
|
72347
|
+
|
|
72348
|
+
if (scanToEnd === true) {
|
|
72349
|
+
continue;
|
|
72350
|
+
}
|
|
72351
|
+
|
|
72352
|
+
break;
|
|
72353
|
+
}
|
|
72354
|
+
}
|
|
72355
|
+
|
|
72356
|
+
if (opts.noext === true) {
|
|
72357
|
+
isExtglob = false;
|
|
72358
|
+
isGlob = false;
|
|
72359
|
+
}
|
|
72360
|
+
|
|
72361
|
+
let base = str;
|
|
72362
|
+
let prefix = '';
|
|
72363
|
+
let glob = '';
|
|
72364
|
+
|
|
72365
|
+
if (start > 0) {
|
|
72366
|
+
prefix = str.slice(0, start);
|
|
72367
|
+
str = str.slice(start);
|
|
72368
|
+
lastIndex -= start;
|
|
72369
|
+
}
|
|
72370
|
+
|
|
72371
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
72372
|
+
base = str.slice(0, lastIndex);
|
|
72373
|
+
glob = str.slice(lastIndex);
|
|
72374
|
+
} else if (isGlob === true) {
|
|
72375
|
+
base = '';
|
|
72376
|
+
glob = str;
|
|
72377
|
+
} else {
|
|
72378
|
+
base = str;
|
|
72379
|
+
}
|
|
72380
|
+
|
|
72381
|
+
if (base && base !== '' && base !== '/' && base !== str) {
|
|
72382
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
72383
|
+
base = base.slice(0, -1);
|
|
72384
|
+
}
|
|
72385
|
+
}
|
|
72386
|
+
|
|
72387
|
+
if (opts.unescape === true) {
|
|
72388
|
+
if (glob) glob = utils$3.removeBackslashes(glob);
|
|
72389
|
+
|
|
72390
|
+
if (base && backslashes === true) {
|
|
72391
|
+
base = utils$3.removeBackslashes(base);
|
|
72392
|
+
}
|
|
72393
|
+
}
|
|
72394
|
+
|
|
72395
|
+
const state = {
|
|
72396
|
+
prefix,
|
|
72397
|
+
input,
|
|
72398
|
+
start,
|
|
72399
|
+
base,
|
|
72400
|
+
glob,
|
|
72401
|
+
isBrace,
|
|
72402
|
+
isBracket,
|
|
72403
|
+
isGlob,
|
|
72404
|
+
isExtglob,
|
|
72405
|
+
isGlobstar,
|
|
72406
|
+
negated,
|
|
72407
|
+
negatedExtglob
|
|
72408
|
+
};
|
|
72409
|
+
|
|
72410
|
+
if (opts.tokens === true) {
|
|
72411
|
+
state.maxDepth = 0;
|
|
72412
|
+
if (!isPathSeparator(code)) {
|
|
72413
|
+
tokens.push(token);
|
|
72414
|
+
}
|
|
72415
|
+
state.tokens = tokens;
|
|
72416
|
+
}
|
|
72417
|
+
|
|
72418
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
72419
|
+
let prevIndex;
|
|
72420
|
+
|
|
72421
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
72422
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
72423
|
+
const i = slashes[idx];
|
|
72424
|
+
const value = input.slice(n, i);
|
|
72425
|
+
if (opts.tokens) {
|
|
72426
|
+
if (idx === 0 && start !== 0) {
|
|
72427
|
+
tokens[idx].isPrefix = true;
|
|
72428
|
+
tokens[idx].value = prefix;
|
|
72429
|
+
} else {
|
|
72430
|
+
tokens[idx].value = value;
|
|
72431
|
+
}
|
|
72432
|
+
depth(tokens[idx]);
|
|
72433
|
+
state.maxDepth += tokens[idx].depth;
|
|
72434
|
+
}
|
|
72435
|
+
if (idx !== 0 || value !== '') {
|
|
72436
|
+
parts.push(value);
|
|
72437
|
+
}
|
|
72438
|
+
prevIndex = i;
|
|
72439
|
+
}
|
|
72440
|
+
|
|
72441
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
72442
|
+
const value = input.slice(prevIndex + 1);
|
|
72443
|
+
parts.push(value);
|
|
72444
|
+
|
|
72445
|
+
if (opts.tokens) {
|
|
72446
|
+
tokens[tokens.length - 1].value = value;
|
|
72447
|
+
depth(tokens[tokens.length - 1]);
|
|
72448
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
72449
|
+
}
|
|
72450
|
+
}
|
|
72451
|
+
|
|
72452
|
+
state.slashes = slashes;
|
|
72453
|
+
state.parts = parts;
|
|
72454
|
+
}
|
|
72455
|
+
|
|
72456
|
+
return state;
|
|
71991
72457
|
};
|
|
71992
72458
|
|
|
71993
|
-
|
|
71994
|
-
const scope = path.scope.getProgramParent();
|
|
71995
|
-
const programPath = scope.path;
|
|
71996
|
-
|
|
71997
|
-
return programPath.node.extra.__putout_printer;
|
|
71998
|
-
}
|
|
72459
|
+
var scan_1 = scan$1;
|
|
71999
72460
|
|
|
72000
|
-
|
|
72001
|
-
|
|
72002
|
-
return path.node.extra?.parenthesized;
|
|
72003
|
-
|
|
72004
|
-
const {type} = path.parentPath;
|
|
72005
|
-
|
|
72006
|
-
return /^(TS)?Parenthesized(Expression|Type)?$/.test(type);
|
|
72007
|
-
}
|
|
72461
|
+
const constants$1 = constants$2;
|
|
72462
|
+
const utils$2 = utils$4;
|
|
72008
72463
|
|
|
72009
|
-
|
|
72010
|
-
|
|
72011
|
-
|
|
72012
|
-
|
|
72013
|
-
|
|
72014
|
-
|
|
72015
|
-
|
|
72016
|
-
|
|
72017
|
-
|
|
72018
|
-
|
|
72019
|
-
|
|
72020
|
-
|
|
72021
|
-
|
|
72022
|
-
|
|
72464
|
+
/**
|
|
72465
|
+
* Constants
|
|
72466
|
+
*/
|
|
72467
|
+
|
|
72468
|
+
const {
|
|
72469
|
+
MAX_LENGTH,
|
|
72470
|
+
POSIX_REGEX_SOURCE,
|
|
72471
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
72472
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
72473
|
+
REPLACEMENTS
|
|
72474
|
+
} = constants$1;
|
|
72475
|
+
|
|
72476
|
+
/**
|
|
72477
|
+
* Helpers
|
|
72478
|
+
*/
|
|
72479
|
+
|
|
72480
|
+
const expandRange = (args, options) => {
|
|
72481
|
+
if (typeof options.expandRange === 'function') {
|
|
72482
|
+
return options.expandRange(...args, options);
|
|
72483
|
+
}
|
|
72484
|
+
|
|
72485
|
+
args.sort();
|
|
72486
|
+
const value = `[${args.join('-')}]`;
|
|
72487
|
+
|
|
72488
|
+
try {
|
|
72489
|
+
/* eslint-disable-next-line no-new */
|
|
72490
|
+
new RegExp(value);
|
|
72491
|
+
} catch (ex) {
|
|
72492
|
+
return args.map(v => utils$2.escapeRegex(v)).join('..');
|
|
72493
|
+
}
|
|
72494
|
+
|
|
72495
|
+
return value;
|
|
72023
72496
|
};
|
|
72024
72497
|
|
|
72025
|
-
|
|
72026
|
-
|
|
72027
|
-
|
|
72028
|
-
|
|
72029
|
-
|
|
72030
|
-
|
|
72031
|
-
|
|
72032
|
-
|
|
72033
|
-
|
|
72034
|
-
|
|
72035
|
-
|
|
72036
|
-
|
|
72037
|
-
|
|
72038
|
-
|
|
72039
|
-
|
|
72040
|
-
|
|
72041
|
-
|
|
72042
|
-
|
|
72043
|
-
|
|
72044
|
-
|
|
72045
|
-
|
|
72046
|
-
|
|
72047
|
-
|
|
72048
|
-
|
|
72049
|
-
|
|
72050
|
-
|
|
72051
|
-
|
|
72052
|
-
|
|
72053
|
-
|
|
72054
|
-
|
|
72055
|
-
|
|
72056
|
-
|
|
72057
|
-
|
|
72058
|
-
|
|
72498
|
+
/**
|
|
72499
|
+
* Create the message for a syntax error
|
|
72500
|
+
*/
|
|
72501
|
+
|
|
72502
|
+
const syntaxError = (type, char) => {
|
|
72503
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
72504
|
+
};
|
|
72505
|
+
|
|
72506
|
+
/**
|
|
72507
|
+
* Parse the given input string.
|
|
72508
|
+
* @param {String} input
|
|
72509
|
+
* @param {Object} options
|
|
72510
|
+
* @return {Object}
|
|
72511
|
+
*/
|
|
72512
|
+
|
|
72513
|
+
const parse$1 = (input, options) => {
|
|
72514
|
+
if (typeof input !== 'string') {
|
|
72515
|
+
throw new TypeError('Expected a string');
|
|
72516
|
+
}
|
|
72517
|
+
|
|
72518
|
+
input = REPLACEMENTS[input] || input;
|
|
72519
|
+
|
|
72520
|
+
const opts = { ...options };
|
|
72521
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
72522
|
+
|
|
72523
|
+
let len = input.length;
|
|
72524
|
+
if (len > max) {
|
|
72525
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
72526
|
+
}
|
|
72527
|
+
|
|
72528
|
+
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
72529
|
+
const tokens = [bos];
|
|
72530
|
+
|
|
72531
|
+
const capture = opts.capture ? '' : '?:';
|
|
72532
|
+
|
|
72533
|
+
// create constants based on platform, for windows or posix
|
|
72534
|
+
const PLATFORM_CHARS = constants$1.globChars(opts.windows);
|
|
72535
|
+
const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
|
|
72536
|
+
|
|
72537
|
+
const {
|
|
72538
|
+
DOT_LITERAL,
|
|
72539
|
+
PLUS_LITERAL,
|
|
72540
|
+
SLASH_LITERAL,
|
|
72541
|
+
ONE_CHAR,
|
|
72542
|
+
DOTS_SLASH,
|
|
72543
|
+
NO_DOT,
|
|
72544
|
+
NO_DOT_SLASH,
|
|
72545
|
+
NO_DOTS_SLASH,
|
|
72546
|
+
QMARK,
|
|
72547
|
+
QMARK_NO_DOT,
|
|
72548
|
+
STAR,
|
|
72549
|
+
START_ANCHOR
|
|
72550
|
+
} = PLATFORM_CHARS;
|
|
72551
|
+
|
|
72552
|
+
const globstar = opts => {
|
|
72553
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
72554
|
+
};
|
|
72555
|
+
|
|
72556
|
+
const nodot = opts.dot ? '' : NO_DOT;
|
|
72557
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
72558
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
72559
|
+
|
|
72560
|
+
if (opts.capture) {
|
|
72561
|
+
star = `(${star})`;
|
|
72562
|
+
}
|
|
72563
|
+
|
|
72564
|
+
// minimatch options support
|
|
72565
|
+
if (typeof opts.noext === 'boolean') {
|
|
72566
|
+
opts.noextglob = opts.noext;
|
|
72567
|
+
}
|
|
72568
|
+
|
|
72569
|
+
const state = {
|
|
72570
|
+
input,
|
|
72571
|
+
index: -1,
|
|
72572
|
+
start: 0,
|
|
72573
|
+
dot: opts.dot === true,
|
|
72574
|
+
consumed: '',
|
|
72575
|
+
output: '',
|
|
72576
|
+
prefix: '',
|
|
72577
|
+
backtrack: false,
|
|
72578
|
+
negated: false,
|
|
72579
|
+
brackets: 0,
|
|
72580
|
+
braces: 0,
|
|
72581
|
+
parens: 0,
|
|
72582
|
+
quotes: 0,
|
|
72583
|
+
globstar: false,
|
|
72584
|
+
tokens
|
|
72585
|
+
};
|
|
72586
|
+
|
|
72587
|
+
input = utils$2.removePrefix(input, state);
|
|
72588
|
+
len = input.length;
|
|
72589
|
+
|
|
72590
|
+
const extglobs = [];
|
|
72591
|
+
const braces = [];
|
|
72592
|
+
const stack = [];
|
|
72593
|
+
let prev = bos;
|
|
72594
|
+
let value;
|
|
72595
|
+
|
|
72596
|
+
/**
|
|
72597
|
+
* Tokenizing helpers
|
|
72598
|
+
*/
|
|
72599
|
+
|
|
72600
|
+
const eos = () => state.index === len - 1;
|
|
72601
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
72602
|
+
const advance = state.advance = () => input[++state.index] || '';
|
|
72603
|
+
const remaining = () => input.slice(state.index + 1);
|
|
72604
|
+
const consume = (value = '', num = 0) => {
|
|
72605
|
+
state.consumed += value;
|
|
72606
|
+
state.index += num;
|
|
72607
|
+
};
|
|
72608
|
+
|
|
72609
|
+
const append = token => {
|
|
72610
|
+
state.output += token.output != null ? token.output : token.value;
|
|
72611
|
+
consume(token.value);
|
|
72612
|
+
};
|
|
72613
|
+
|
|
72614
|
+
const negate = () => {
|
|
72615
|
+
let count = 1;
|
|
72616
|
+
|
|
72617
|
+
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
72618
|
+
advance();
|
|
72619
|
+
state.start++;
|
|
72620
|
+
count++;
|
|
72621
|
+
}
|
|
72622
|
+
|
|
72623
|
+
if (count % 2 === 0) {
|
|
72624
|
+
return false;
|
|
72625
|
+
}
|
|
72626
|
+
|
|
72627
|
+
state.negated = true;
|
|
72628
|
+
state.start++;
|
|
72629
|
+
return true;
|
|
72630
|
+
};
|
|
72631
|
+
|
|
72632
|
+
const increment = type => {
|
|
72633
|
+
state[type]++;
|
|
72634
|
+
stack.push(type);
|
|
72635
|
+
};
|
|
72636
|
+
|
|
72637
|
+
const decrement = type => {
|
|
72638
|
+
state[type]--;
|
|
72639
|
+
stack.pop();
|
|
72640
|
+
};
|
|
72641
|
+
|
|
72642
|
+
/**
|
|
72643
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
72644
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
72645
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
72646
|
+
* characters are plain text. This improves performance and simplifies
|
|
72647
|
+
* lookbehinds.
|
|
72648
|
+
*/
|
|
72649
|
+
|
|
72650
|
+
const push = tok => {
|
|
72651
|
+
if (prev.type === 'globstar') {
|
|
72652
|
+
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
72653
|
+
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
72654
|
+
|
|
72655
|
+
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
72656
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
72657
|
+
prev.type = 'star';
|
|
72658
|
+
prev.value = '*';
|
|
72659
|
+
prev.output = star;
|
|
72660
|
+
state.output += prev.output;
|
|
72661
|
+
}
|
|
72662
|
+
}
|
|
72663
|
+
|
|
72664
|
+
if (extglobs.length && tok.type !== 'paren') {
|
|
72665
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
72666
|
+
}
|
|
72667
|
+
|
|
72668
|
+
if (tok.value || tok.output) append(tok);
|
|
72669
|
+
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
72670
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
72671
|
+
prev.value += tok.value;
|
|
72672
|
+
return;
|
|
72673
|
+
}
|
|
72674
|
+
|
|
72675
|
+
tok.prev = prev;
|
|
72676
|
+
tokens.push(tok);
|
|
72677
|
+
prev = tok;
|
|
72678
|
+
};
|
|
72679
|
+
|
|
72680
|
+
const extglobOpen = (type, value) => {
|
|
72681
|
+
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
72682
|
+
|
|
72683
|
+
token.prev = prev;
|
|
72684
|
+
token.parens = state.parens;
|
|
72685
|
+
token.output = state.output;
|
|
72686
|
+
const output = (opts.capture ? '(' : '') + token.open;
|
|
72687
|
+
|
|
72688
|
+
increment('parens');
|
|
72689
|
+
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
72690
|
+
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
72691
|
+
extglobs.push(token);
|
|
72692
|
+
};
|
|
72693
|
+
|
|
72694
|
+
const extglobClose = token => {
|
|
72695
|
+
let output = token.close + (opts.capture ? ')' : '');
|
|
72696
|
+
let rest;
|
|
72697
|
+
|
|
72698
|
+
if (token.type === 'negate') {
|
|
72699
|
+
let extglobStar = star;
|
|
72700
|
+
|
|
72701
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
72702
|
+
extglobStar = globstar(opts);
|
|
72703
|
+
}
|
|
72704
|
+
|
|
72705
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
72706
|
+
output = token.close = `)$))${extglobStar}`;
|
|
72707
|
+
}
|
|
72708
|
+
|
|
72709
|
+
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
72710
|
+
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
72711
|
+
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
72712
|
+
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
72713
|
+
//
|
|
72714
|
+
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
72715
|
+
const expression = parse$1(rest, { ...options, fastpaths: false }).output;
|
|
72716
|
+
|
|
72717
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
72718
|
+
}
|
|
72719
|
+
|
|
72720
|
+
if (token.prev.type === 'bos') {
|
|
72721
|
+
state.negatedExtglob = true;
|
|
72722
|
+
}
|
|
72723
|
+
}
|
|
72724
|
+
|
|
72725
|
+
push({ type: 'paren', extglob: true, value, output });
|
|
72726
|
+
decrement('parens');
|
|
72727
|
+
};
|
|
72728
|
+
|
|
72729
|
+
/**
|
|
72730
|
+
* Fast paths
|
|
72731
|
+
*/
|
|
72732
|
+
|
|
72733
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
72734
|
+
let backslashes = false;
|
|
72735
|
+
|
|
72736
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
72737
|
+
if (first === '\\') {
|
|
72738
|
+
backslashes = true;
|
|
72739
|
+
return m;
|
|
72740
|
+
}
|
|
72741
|
+
|
|
72742
|
+
if (first === '?') {
|
|
72743
|
+
if (esc) {
|
|
72744
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
72745
|
+
}
|
|
72746
|
+
if (index === 0) {
|
|
72747
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
72748
|
+
}
|
|
72749
|
+
return QMARK.repeat(chars.length);
|
|
72750
|
+
}
|
|
72751
|
+
|
|
72752
|
+
if (first === '.') {
|
|
72753
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
72754
|
+
}
|
|
72755
|
+
|
|
72756
|
+
if (first === '*') {
|
|
72757
|
+
if (esc) {
|
|
72758
|
+
return esc + first + (rest ? star : '');
|
|
72759
|
+
}
|
|
72760
|
+
return star;
|
|
72761
|
+
}
|
|
72762
|
+
return esc ? m : `\\${m}`;
|
|
72763
|
+
});
|
|
72764
|
+
|
|
72765
|
+
if (backslashes === true) {
|
|
72766
|
+
if (opts.unescape === true) {
|
|
72767
|
+
output = output.replace(/\\/g, '');
|
|
72768
|
+
} else {
|
|
72769
|
+
output = output.replace(/\\+/g, m => {
|
|
72770
|
+
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
72771
|
+
});
|
|
72772
|
+
}
|
|
72773
|
+
}
|
|
72774
|
+
|
|
72775
|
+
if (output === input && opts.contains === true) {
|
|
72776
|
+
state.output = input;
|
|
72777
|
+
return state;
|
|
72778
|
+
}
|
|
72779
|
+
|
|
72780
|
+
state.output = utils$2.wrapOutput(output, state, options);
|
|
72781
|
+
return state;
|
|
72782
|
+
}
|
|
72783
|
+
|
|
72784
|
+
/**
|
|
72785
|
+
* Tokenize input until we reach end-of-string
|
|
72786
|
+
*/
|
|
72787
|
+
|
|
72788
|
+
while (!eos()) {
|
|
72789
|
+
value = advance();
|
|
72790
|
+
|
|
72791
|
+
if (value === '\u0000') {
|
|
72792
|
+
continue;
|
|
72793
|
+
}
|
|
72794
|
+
|
|
72795
|
+
/**
|
|
72796
|
+
* Escaped characters
|
|
72797
|
+
*/
|
|
72798
|
+
|
|
72799
|
+
if (value === '\\') {
|
|
72800
|
+
const next = peek();
|
|
72801
|
+
|
|
72802
|
+
if (next === '/' && opts.bash !== true) {
|
|
72803
|
+
continue;
|
|
72804
|
+
}
|
|
72805
|
+
|
|
72806
|
+
if (next === '.' || next === ';') {
|
|
72807
|
+
continue;
|
|
72808
|
+
}
|
|
72809
|
+
|
|
72810
|
+
if (!next) {
|
|
72811
|
+
value += '\\';
|
|
72812
|
+
push({ type: 'text', value });
|
|
72813
|
+
continue;
|
|
72814
|
+
}
|
|
72815
|
+
|
|
72816
|
+
// collapse slashes to reduce potential for exploits
|
|
72817
|
+
const match = /^\\+/.exec(remaining());
|
|
72818
|
+
let slashes = 0;
|
|
72819
|
+
|
|
72820
|
+
if (match && match[0].length > 2) {
|
|
72821
|
+
slashes = match[0].length;
|
|
72822
|
+
state.index += slashes;
|
|
72823
|
+
if (slashes % 2 !== 0) {
|
|
72824
|
+
value += '\\';
|
|
72825
|
+
}
|
|
72826
|
+
}
|
|
72827
|
+
|
|
72828
|
+
if (opts.unescape === true) {
|
|
72829
|
+
value = advance();
|
|
72830
|
+
} else {
|
|
72831
|
+
value += advance();
|
|
72832
|
+
}
|
|
72833
|
+
|
|
72834
|
+
if (state.brackets === 0) {
|
|
72835
|
+
push({ type: 'text', value });
|
|
72836
|
+
continue;
|
|
72837
|
+
}
|
|
72838
|
+
}
|
|
72839
|
+
|
|
72840
|
+
/**
|
|
72841
|
+
* If we're inside a regex character class, continue
|
|
72842
|
+
* until we reach the closing bracket.
|
|
72843
|
+
*/
|
|
72844
|
+
|
|
72845
|
+
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
72846
|
+
if (opts.posix !== false && value === ':') {
|
|
72847
|
+
const inner = prev.value.slice(1);
|
|
72848
|
+
if (inner.includes('[')) {
|
|
72849
|
+
prev.posix = true;
|
|
72850
|
+
|
|
72851
|
+
if (inner.includes(':')) {
|
|
72852
|
+
const idx = prev.value.lastIndexOf('[');
|
|
72853
|
+
const pre = prev.value.slice(0, idx);
|
|
72854
|
+
const rest = prev.value.slice(idx + 2);
|
|
72855
|
+
const posix = POSIX_REGEX_SOURCE[rest];
|
|
72856
|
+
if (posix) {
|
|
72857
|
+
prev.value = pre + posix;
|
|
72858
|
+
state.backtrack = true;
|
|
72859
|
+
advance();
|
|
72860
|
+
|
|
72861
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
72862
|
+
bos.output = ONE_CHAR;
|
|
72863
|
+
}
|
|
72864
|
+
continue;
|
|
72865
|
+
}
|
|
72866
|
+
}
|
|
72867
|
+
}
|
|
72868
|
+
}
|
|
72869
|
+
|
|
72870
|
+
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
72871
|
+
value = `\\${value}`;
|
|
72872
|
+
}
|
|
72873
|
+
|
|
72874
|
+
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
72875
|
+
value = `\\${value}`;
|
|
72876
|
+
}
|
|
72877
|
+
|
|
72878
|
+
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
72879
|
+
value = '^';
|
|
72880
|
+
}
|
|
72881
|
+
|
|
72882
|
+
prev.value += value;
|
|
72883
|
+
append({ value });
|
|
72884
|
+
continue;
|
|
72885
|
+
}
|
|
72886
|
+
|
|
72887
|
+
/**
|
|
72888
|
+
* If we're inside a quoted string, continue
|
|
72889
|
+
* until we reach the closing double quote.
|
|
72890
|
+
*/
|
|
72891
|
+
|
|
72892
|
+
if (state.quotes === 1 && value !== '"') {
|
|
72893
|
+
value = utils$2.escapeRegex(value);
|
|
72894
|
+
prev.value += value;
|
|
72895
|
+
append({ value });
|
|
72896
|
+
continue;
|
|
72897
|
+
}
|
|
72898
|
+
|
|
72899
|
+
/**
|
|
72900
|
+
* Double quotes
|
|
72901
|
+
*/
|
|
72902
|
+
|
|
72903
|
+
if (value === '"') {
|
|
72904
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
72905
|
+
if (opts.keepQuotes === true) {
|
|
72906
|
+
push({ type: 'text', value });
|
|
72907
|
+
}
|
|
72908
|
+
continue;
|
|
72909
|
+
}
|
|
72910
|
+
|
|
72911
|
+
/**
|
|
72912
|
+
* Parentheses
|
|
72913
|
+
*/
|
|
72914
|
+
|
|
72915
|
+
if (value === '(') {
|
|
72916
|
+
increment('parens');
|
|
72917
|
+
push({ type: 'paren', value });
|
|
72918
|
+
continue;
|
|
72919
|
+
}
|
|
72920
|
+
|
|
72921
|
+
if (value === ')') {
|
|
72922
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
72923
|
+
throw new SyntaxError(syntaxError('opening', '('));
|
|
72924
|
+
}
|
|
72925
|
+
|
|
72926
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
72927
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
72928
|
+
extglobClose(extglobs.pop());
|
|
72929
|
+
continue;
|
|
72930
|
+
}
|
|
72931
|
+
|
|
72932
|
+
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
72933
|
+
decrement('parens');
|
|
72934
|
+
continue;
|
|
72935
|
+
}
|
|
72936
|
+
|
|
72937
|
+
/**
|
|
72938
|
+
* Square brackets
|
|
72939
|
+
*/
|
|
72940
|
+
|
|
72941
|
+
if (value === '[') {
|
|
72942
|
+
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
72943
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
72944
|
+
throw new SyntaxError(syntaxError('closing', ']'));
|
|
72945
|
+
}
|
|
72946
|
+
|
|
72947
|
+
value = `\\${value}`;
|
|
72948
|
+
} else {
|
|
72949
|
+
increment('brackets');
|
|
72950
|
+
}
|
|
72951
|
+
|
|
72952
|
+
push({ type: 'bracket', value });
|
|
72953
|
+
continue;
|
|
72954
|
+
}
|
|
72955
|
+
|
|
72956
|
+
if (value === ']') {
|
|
72957
|
+
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
72958
|
+
push({ type: 'text', value, output: `\\${value}` });
|
|
72959
|
+
continue;
|
|
72960
|
+
}
|
|
72961
|
+
|
|
72962
|
+
if (state.brackets === 0) {
|
|
72963
|
+
if (opts.strictBrackets === true) {
|
|
72964
|
+
throw new SyntaxError(syntaxError('opening', '['));
|
|
72965
|
+
}
|
|
72966
|
+
|
|
72967
|
+
push({ type: 'text', value, output: `\\${value}` });
|
|
72968
|
+
continue;
|
|
72969
|
+
}
|
|
72970
|
+
|
|
72971
|
+
decrement('brackets');
|
|
72972
|
+
|
|
72973
|
+
const prevValue = prev.value.slice(1);
|
|
72974
|
+
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
72975
|
+
value = `/${value}`;
|
|
72976
|
+
}
|
|
72977
|
+
|
|
72978
|
+
prev.value += value;
|
|
72979
|
+
append({ value });
|
|
72980
|
+
|
|
72981
|
+
// when literal brackets are explicitly disabled
|
|
72982
|
+
// assume we should match with a regex character class
|
|
72983
|
+
if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) {
|
|
72984
|
+
continue;
|
|
72985
|
+
}
|
|
72986
|
+
|
|
72987
|
+
const escaped = utils$2.escapeRegex(prev.value);
|
|
72988
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
72989
|
+
|
|
72990
|
+
// when literal brackets are explicitly enabled
|
|
72991
|
+
// assume we should escape the brackets to match literal characters
|
|
72992
|
+
if (opts.literalBrackets === true) {
|
|
72993
|
+
state.output += escaped;
|
|
72994
|
+
prev.value = escaped;
|
|
72995
|
+
continue;
|
|
72996
|
+
}
|
|
72997
|
+
|
|
72998
|
+
// when the user specifies nothing, try to match both
|
|
72999
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
73000
|
+
state.output += prev.value;
|
|
73001
|
+
continue;
|
|
73002
|
+
}
|
|
73003
|
+
|
|
73004
|
+
/**
|
|
73005
|
+
* Braces
|
|
73006
|
+
*/
|
|
73007
|
+
|
|
73008
|
+
if (value === '{' && opts.nobrace !== true) {
|
|
73009
|
+
increment('braces');
|
|
73010
|
+
|
|
73011
|
+
const open = {
|
|
73012
|
+
type: 'brace',
|
|
73013
|
+
value,
|
|
73014
|
+
output: '(',
|
|
73015
|
+
outputIndex: state.output.length,
|
|
73016
|
+
tokensIndex: state.tokens.length
|
|
73017
|
+
};
|
|
73018
|
+
|
|
73019
|
+
braces.push(open);
|
|
73020
|
+
push(open);
|
|
73021
|
+
continue;
|
|
73022
|
+
}
|
|
73023
|
+
|
|
73024
|
+
if (value === '}') {
|
|
73025
|
+
const brace = braces[braces.length - 1];
|
|
73026
|
+
|
|
73027
|
+
if (opts.nobrace === true || !brace) {
|
|
73028
|
+
push({ type: 'text', value, output: value });
|
|
73029
|
+
continue;
|
|
73030
|
+
}
|
|
73031
|
+
|
|
73032
|
+
let output = ')';
|
|
73033
|
+
|
|
73034
|
+
if (brace.dots === true) {
|
|
73035
|
+
const arr = tokens.slice();
|
|
73036
|
+
const range = [];
|
|
73037
|
+
|
|
73038
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
73039
|
+
tokens.pop();
|
|
73040
|
+
if (arr[i].type === 'brace') {
|
|
73041
|
+
break;
|
|
73042
|
+
}
|
|
73043
|
+
if (arr[i].type !== 'dots') {
|
|
73044
|
+
range.unshift(arr[i].value);
|
|
73045
|
+
}
|
|
73046
|
+
}
|
|
73047
|
+
|
|
73048
|
+
output = expandRange(range, opts);
|
|
73049
|
+
state.backtrack = true;
|
|
73050
|
+
}
|
|
73051
|
+
|
|
73052
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
73053
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
73054
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
73055
|
+
brace.value = brace.output = '\\{';
|
|
73056
|
+
value = output = '\\}';
|
|
73057
|
+
state.output = out;
|
|
73058
|
+
for (const t of toks) {
|
|
73059
|
+
state.output += (t.output || t.value);
|
|
73060
|
+
}
|
|
73061
|
+
}
|
|
73062
|
+
|
|
73063
|
+
push({ type: 'brace', value, output });
|
|
73064
|
+
decrement('braces');
|
|
73065
|
+
braces.pop();
|
|
73066
|
+
continue;
|
|
73067
|
+
}
|
|
73068
|
+
|
|
73069
|
+
/**
|
|
73070
|
+
* Pipes
|
|
73071
|
+
*/
|
|
73072
|
+
|
|
73073
|
+
if (value === '|') {
|
|
73074
|
+
if (extglobs.length > 0) {
|
|
73075
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
73076
|
+
}
|
|
73077
|
+
push({ type: 'text', value });
|
|
73078
|
+
continue;
|
|
73079
|
+
}
|
|
73080
|
+
|
|
73081
|
+
/**
|
|
73082
|
+
* Commas
|
|
73083
|
+
*/
|
|
73084
|
+
|
|
73085
|
+
if (value === ',') {
|
|
73086
|
+
let output = value;
|
|
73087
|
+
|
|
73088
|
+
const brace = braces[braces.length - 1];
|
|
73089
|
+
if (brace && stack[stack.length - 1] === 'braces') {
|
|
73090
|
+
brace.comma = true;
|
|
73091
|
+
output = '|';
|
|
73092
|
+
}
|
|
73093
|
+
|
|
73094
|
+
push({ type: 'comma', value, output });
|
|
73095
|
+
continue;
|
|
73096
|
+
}
|
|
73097
|
+
|
|
73098
|
+
/**
|
|
73099
|
+
* Slashes
|
|
73100
|
+
*/
|
|
73101
|
+
|
|
73102
|
+
if (value === '/') {
|
|
73103
|
+
// if the beginning of the glob is "./", advance the start
|
|
73104
|
+
// to the current index, and don't add the "./" characters
|
|
73105
|
+
// to the state. This greatly simplifies lookbehinds when
|
|
73106
|
+
// checking for BOS characters like "!" and "." (not "./")
|
|
73107
|
+
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
73108
|
+
state.start = state.index + 1;
|
|
73109
|
+
state.consumed = '';
|
|
73110
|
+
state.output = '';
|
|
73111
|
+
tokens.pop();
|
|
73112
|
+
prev = bos; // reset "prev" to the first token
|
|
73113
|
+
continue;
|
|
73114
|
+
}
|
|
73115
|
+
|
|
73116
|
+
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
73117
|
+
continue;
|
|
73118
|
+
}
|
|
73119
|
+
|
|
73120
|
+
/**
|
|
73121
|
+
* Dots
|
|
73122
|
+
*/
|
|
73123
|
+
|
|
73124
|
+
if (value === '.') {
|
|
73125
|
+
if (state.braces > 0 && prev.type === 'dot') {
|
|
73126
|
+
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
73127
|
+
const brace = braces[braces.length - 1];
|
|
73128
|
+
prev.type = 'dots';
|
|
73129
|
+
prev.output += value;
|
|
73130
|
+
prev.value += value;
|
|
73131
|
+
brace.dots = true;
|
|
73132
|
+
continue;
|
|
73133
|
+
}
|
|
73134
|
+
|
|
73135
|
+
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
73136
|
+
push({ type: 'text', value, output: DOT_LITERAL });
|
|
73137
|
+
continue;
|
|
73138
|
+
}
|
|
73139
|
+
|
|
73140
|
+
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
73141
|
+
continue;
|
|
73142
|
+
}
|
|
73143
|
+
|
|
73144
|
+
/**
|
|
73145
|
+
* Question marks
|
|
73146
|
+
*/
|
|
73147
|
+
|
|
73148
|
+
if (value === '?') {
|
|
73149
|
+
const isGroup = prev && prev.value === '(';
|
|
73150
|
+
if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
73151
|
+
extglobOpen('qmark', value);
|
|
73152
|
+
continue;
|
|
73153
|
+
}
|
|
73154
|
+
|
|
73155
|
+
if (prev && prev.type === 'paren') {
|
|
73156
|
+
const next = peek();
|
|
73157
|
+
let output = value;
|
|
73158
|
+
|
|
73159
|
+
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
|
|
73160
|
+
output = `\\${value}`;
|
|
73161
|
+
}
|
|
73162
|
+
|
|
73163
|
+
push({ type: 'text', value, output });
|
|
73164
|
+
continue;
|
|
73165
|
+
}
|
|
73166
|
+
|
|
73167
|
+
if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
|
|
73168
|
+
push({ type: 'qmark', value, output: QMARK_NO_DOT });
|
|
73169
|
+
continue;
|
|
73170
|
+
}
|
|
73171
|
+
|
|
73172
|
+
push({ type: 'qmark', value, output: QMARK });
|
|
73173
|
+
continue;
|
|
73174
|
+
}
|
|
73175
|
+
|
|
73176
|
+
/**
|
|
73177
|
+
* Exclamation
|
|
73178
|
+
*/
|
|
73179
|
+
|
|
73180
|
+
if (value === '!') {
|
|
73181
|
+
if (opts.noextglob !== true && peek() === '(') {
|
|
73182
|
+
if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
|
|
73183
|
+
extglobOpen('negate', value);
|
|
73184
|
+
continue;
|
|
73185
|
+
}
|
|
73186
|
+
}
|
|
73187
|
+
|
|
73188
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
73189
|
+
negate();
|
|
73190
|
+
continue;
|
|
73191
|
+
}
|
|
73192
|
+
}
|
|
73193
|
+
|
|
73194
|
+
/**
|
|
73195
|
+
* Plus
|
|
73196
|
+
*/
|
|
73197
|
+
|
|
73198
|
+
if (value === '+') {
|
|
73199
|
+
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
73200
|
+
extglobOpen('plus', value);
|
|
73201
|
+
continue;
|
|
73202
|
+
}
|
|
73203
|
+
|
|
73204
|
+
if ((prev && prev.value === '(') || opts.regex === false) {
|
|
73205
|
+
push({ type: 'plus', value, output: PLUS_LITERAL });
|
|
73206
|
+
continue;
|
|
73207
|
+
}
|
|
73208
|
+
|
|
73209
|
+
if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
|
|
73210
|
+
push({ type: 'plus', value });
|
|
73211
|
+
continue;
|
|
73212
|
+
}
|
|
73213
|
+
|
|
73214
|
+
push({ type: 'plus', value: PLUS_LITERAL });
|
|
73215
|
+
continue;
|
|
73216
|
+
}
|
|
73217
|
+
|
|
73218
|
+
/**
|
|
73219
|
+
* Plain text
|
|
73220
|
+
*/
|
|
73221
|
+
|
|
73222
|
+
if (value === '@') {
|
|
73223
|
+
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
73224
|
+
push({ type: 'at', extglob: true, value, output: '' });
|
|
73225
|
+
continue;
|
|
73226
|
+
}
|
|
73227
|
+
|
|
73228
|
+
push({ type: 'text', value });
|
|
73229
|
+
continue;
|
|
73230
|
+
}
|
|
73231
|
+
|
|
73232
|
+
/**
|
|
73233
|
+
* Plain text
|
|
73234
|
+
*/
|
|
73235
|
+
|
|
73236
|
+
if (value !== '*') {
|
|
73237
|
+
if (value === '$' || value === '^') {
|
|
73238
|
+
value = `\\${value}`;
|
|
73239
|
+
}
|
|
73240
|
+
|
|
73241
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
73242
|
+
if (match) {
|
|
73243
|
+
value += match[0];
|
|
73244
|
+
state.index += match[0].length;
|
|
73245
|
+
}
|
|
73246
|
+
|
|
73247
|
+
push({ type: 'text', value });
|
|
73248
|
+
continue;
|
|
73249
|
+
}
|
|
73250
|
+
|
|
73251
|
+
/**
|
|
73252
|
+
* Stars
|
|
73253
|
+
*/
|
|
73254
|
+
|
|
73255
|
+
if (prev && (prev.type === 'globstar' || prev.star === true)) {
|
|
73256
|
+
prev.type = 'star';
|
|
73257
|
+
prev.star = true;
|
|
73258
|
+
prev.value += value;
|
|
73259
|
+
prev.output = star;
|
|
73260
|
+
state.backtrack = true;
|
|
73261
|
+
state.globstar = true;
|
|
73262
|
+
consume(value);
|
|
73263
|
+
continue;
|
|
73264
|
+
}
|
|
73265
|
+
|
|
73266
|
+
let rest = remaining();
|
|
73267
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
73268
|
+
extglobOpen('star', value);
|
|
73269
|
+
continue;
|
|
73270
|
+
}
|
|
73271
|
+
|
|
73272
|
+
if (prev.type === 'star') {
|
|
73273
|
+
if (opts.noglobstar === true) {
|
|
73274
|
+
consume(value);
|
|
73275
|
+
continue;
|
|
73276
|
+
}
|
|
73277
|
+
|
|
73278
|
+
const prior = prev.prev;
|
|
73279
|
+
const before = prior.prev;
|
|
73280
|
+
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
73281
|
+
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
73282
|
+
|
|
73283
|
+
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
73284
|
+
push({ type: 'star', value, output: '' });
|
|
73285
|
+
continue;
|
|
73286
|
+
}
|
|
73287
|
+
|
|
73288
|
+
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
73289
|
+
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
73290
|
+
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
73291
|
+
push({ type: 'star', value, output: '' });
|
|
73292
|
+
continue;
|
|
73293
|
+
}
|
|
73294
|
+
|
|
73295
|
+
// strip consecutive `/**/`
|
|
73296
|
+
while (rest.slice(0, 3) === '/**') {
|
|
73297
|
+
const after = input[state.index + 4];
|
|
73298
|
+
if (after && after !== '/') {
|
|
73299
|
+
break;
|
|
73300
|
+
}
|
|
73301
|
+
rest = rest.slice(3);
|
|
73302
|
+
consume('/**', 3);
|
|
73303
|
+
}
|
|
73304
|
+
|
|
73305
|
+
if (prior.type === 'bos' && eos()) {
|
|
73306
|
+
prev.type = 'globstar';
|
|
73307
|
+
prev.value += value;
|
|
73308
|
+
prev.output = globstar(opts);
|
|
73309
|
+
state.output = prev.output;
|
|
73310
|
+
state.globstar = true;
|
|
73311
|
+
consume(value);
|
|
73312
|
+
continue;
|
|
73313
|
+
}
|
|
73314
|
+
|
|
73315
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
73316
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
73317
|
+
prior.output = `(?:${prior.output}`;
|
|
73318
|
+
|
|
73319
|
+
prev.type = 'globstar';
|
|
73320
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
73321
|
+
prev.value += value;
|
|
73322
|
+
state.globstar = true;
|
|
73323
|
+
state.output += prior.output + prev.output;
|
|
73324
|
+
consume(value);
|
|
73325
|
+
continue;
|
|
73326
|
+
}
|
|
73327
|
+
|
|
73328
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
73329
|
+
const end = rest[1] !== void 0 ? '|$' : '';
|
|
73330
|
+
|
|
73331
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
73332
|
+
prior.output = `(?:${prior.output}`;
|
|
73333
|
+
|
|
73334
|
+
prev.type = 'globstar';
|
|
73335
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
73336
|
+
prev.value += value;
|
|
73337
|
+
|
|
73338
|
+
state.output += prior.output + prev.output;
|
|
73339
|
+
state.globstar = true;
|
|
73340
|
+
|
|
73341
|
+
consume(value + advance());
|
|
73342
|
+
|
|
73343
|
+
push({ type: 'slash', value: '/', output: '' });
|
|
73344
|
+
continue;
|
|
73345
|
+
}
|
|
73346
|
+
|
|
73347
|
+
if (prior.type === 'bos' && rest[0] === '/') {
|
|
73348
|
+
prev.type = 'globstar';
|
|
73349
|
+
prev.value += value;
|
|
73350
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
73351
|
+
state.output = prev.output;
|
|
73352
|
+
state.globstar = true;
|
|
73353
|
+
consume(value + advance());
|
|
73354
|
+
push({ type: 'slash', value: '/', output: '' });
|
|
73355
|
+
continue;
|
|
73356
|
+
}
|
|
73357
|
+
|
|
73358
|
+
// remove single star from output
|
|
73359
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
73360
|
+
|
|
73361
|
+
// reset previous token to globstar
|
|
73362
|
+
prev.type = 'globstar';
|
|
73363
|
+
prev.output = globstar(opts);
|
|
73364
|
+
prev.value += value;
|
|
73365
|
+
|
|
73366
|
+
// reset output with globstar
|
|
73367
|
+
state.output += prev.output;
|
|
73368
|
+
state.globstar = true;
|
|
73369
|
+
consume(value);
|
|
73370
|
+
continue;
|
|
73371
|
+
}
|
|
73372
|
+
|
|
73373
|
+
const token = { type: 'star', value, output: star };
|
|
73374
|
+
|
|
73375
|
+
if (opts.bash === true) {
|
|
73376
|
+
token.output = '.*?';
|
|
73377
|
+
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
73378
|
+
token.output = nodot + token.output;
|
|
73379
|
+
}
|
|
73380
|
+
push(token);
|
|
73381
|
+
continue;
|
|
73382
|
+
}
|
|
73383
|
+
|
|
73384
|
+
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
73385
|
+
token.output = value;
|
|
73386
|
+
push(token);
|
|
73387
|
+
continue;
|
|
73388
|
+
}
|
|
73389
|
+
|
|
73390
|
+
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
73391
|
+
if (prev.type === 'dot') {
|
|
73392
|
+
state.output += NO_DOT_SLASH;
|
|
73393
|
+
prev.output += NO_DOT_SLASH;
|
|
73394
|
+
|
|
73395
|
+
} else if (opts.dot === true) {
|
|
73396
|
+
state.output += NO_DOTS_SLASH;
|
|
73397
|
+
prev.output += NO_DOTS_SLASH;
|
|
73398
|
+
|
|
73399
|
+
} else {
|
|
73400
|
+
state.output += nodot;
|
|
73401
|
+
prev.output += nodot;
|
|
73402
|
+
}
|
|
73403
|
+
|
|
73404
|
+
if (peek() !== '*') {
|
|
73405
|
+
state.output += ONE_CHAR;
|
|
73406
|
+
prev.output += ONE_CHAR;
|
|
73407
|
+
}
|
|
73408
|
+
}
|
|
73409
|
+
|
|
73410
|
+
push(token);
|
|
73411
|
+
}
|
|
73412
|
+
|
|
73413
|
+
while (state.brackets > 0) {
|
|
73414
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
|
73415
|
+
state.output = utils$2.escapeLast(state.output, '[');
|
|
73416
|
+
decrement('brackets');
|
|
73417
|
+
}
|
|
73418
|
+
|
|
73419
|
+
while (state.parens > 0) {
|
|
73420
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
|
73421
|
+
state.output = utils$2.escapeLast(state.output, '(');
|
|
73422
|
+
decrement('parens');
|
|
73423
|
+
}
|
|
73424
|
+
|
|
73425
|
+
while (state.braces > 0) {
|
|
73426
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
|
73427
|
+
state.output = utils$2.escapeLast(state.output, '{');
|
|
73428
|
+
decrement('braces');
|
|
73429
|
+
}
|
|
73430
|
+
|
|
73431
|
+
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
|
73432
|
+
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
|
73433
|
+
}
|
|
73434
|
+
|
|
73435
|
+
// rebuild the output if we had to backtrack at any point
|
|
73436
|
+
if (state.backtrack === true) {
|
|
73437
|
+
state.output = '';
|
|
73438
|
+
|
|
73439
|
+
for (const token of state.tokens) {
|
|
73440
|
+
state.output += token.output != null ? token.output : token.value;
|
|
73441
|
+
|
|
73442
|
+
if (token.suffix) {
|
|
73443
|
+
state.output += token.suffix;
|
|
73444
|
+
}
|
|
73445
|
+
}
|
|
73446
|
+
}
|
|
73447
|
+
|
|
73448
|
+
return state;
|
|
73449
|
+
};
|
|
73450
|
+
|
|
73451
|
+
/**
|
|
73452
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
73453
|
+
* This can significantly speed up processing and has very little downside
|
|
73454
|
+
* impact when none of the fast paths match.
|
|
73455
|
+
*/
|
|
73456
|
+
|
|
73457
|
+
parse$1.fastpaths = (input, options) => {
|
|
73458
|
+
const opts = { ...options };
|
|
73459
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
73460
|
+
const len = input.length;
|
|
73461
|
+
if (len > max) {
|
|
73462
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
73463
|
+
}
|
|
73464
|
+
|
|
73465
|
+
input = REPLACEMENTS[input] || input;
|
|
73466
|
+
|
|
73467
|
+
// create constants based on platform, for windows or posix
|
|
73468
|
+
const {
|
|
73469
|
+
DOT_LITERAL,
|
|
73470
|
+
SLASH_LITERAL,
|
|
73471
|
+
ONE_CHAR,
|
|
73472
|
+
DOTS_SLASH,
|
|
73473
|
+
NO_DOT,
|
|
73474
|
+
NO_DOTS,
|
|
73475
|
+
NO_DOTS_SLASH,
|
|
73476
|
+
STAR,
|
|
73477
|
+
START_ANCHOR
|
|
73478
|
+
} = constants$1.globChars(opts.windows);
|
|
73479
|
+
|
|
73480
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
73481
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
73482
|
+
const capture = opts.capture ? '' : '?:';
|
|
73483
|
+
const state = { negated: false, prefix: '' };
|
|
73484
|
+
let star = opts.bash === true ? '.*?' : STAR;
|
|
73485
|
+
|
|
73486
|
+
if (opts.capture) {
|
|
73487
|
+
star = `(${star})`;
|
|
73488
|
+
}
|
|
73489
|
+
|
|
73490
|
+
const globstar = opts => {
|
|
73491
|
+
if (opts.noglobstar === true) return star;
|
|
73492
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
73493
|
+
};
|
|
73494
|
+
|
|
73495
|
+
const create = str => {
|
|
73496
|
+
switch (str) {
|
|
73497
|
+
case '*':
|
|
73498
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
73499
|
+
|
|
73500
|
+
case '.*':
|
|
73501
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
73502
|
+
|
|
73503
|
+
case '*.*':
|
|
73504
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
73505
|
+
|
|
73506
|
+
case '*/*':
|
|
73507
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
73508
|
+
|
|
73509
|
+
case '**':
|
|
73510
|
+
return nodot + globstar(opts);
|
|
73511
|
+
|
|
73512
|
+
case '**/*':
|
|
73513
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
73514
|
+
|
|
73515
|
+
case '**/*.*':
|
|
73516
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
73517
|
+
|
|
73518
|
+
case '**/.*':
|
|
73519
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
73520
|
+
|
|
73521
|
+
default: {
|
|
73522
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
73523
|
+
if (!match) return;
|
|
73524
|
+
|
|
73525
|
+
const source = create(match[1]);
|
|
73526
|
+
if (!source) return;
|
|
73527
|
+
|
|
73528
|
+
return source + DOT_LITERAL + match[2];
|
|
73529
|
+
}
|
|
73530
|
+
}
|
|
73531
|
+
};
|
|
73532
|
+
|
|
73533
|
+
const output = utils$2.removePrefix(input, state);
|
|
73534
|
+
let source = create(output);
|
|
73535
|
+
|
|
73536
|
+
if (source && opts.strictSlashes !== true) {
|
|
73537
|
+
source += `${SLASH_LITERAL}?`;
|
|
73538
|
+
}
|
|
73539
|
+
|
|
73540
|
+
return source;
|
|
73541
|
+
};
|
|
73542
|
+
|
|
73543
|
+
var parse_1 = parse$1;
|
|
73544
|
+
|
|
73545
|
+
parse_1.default;
|
|
73546
|
+
|
|
73547
|
+
const scan = scan_1;
|
|
73548
|
+
const parse = parse_1;
|
|
73549
|
+
const utils$1 = utils$4;
|
|
73550
|
+
const constants = constants$2;
|
|
73551
|
+
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
73552
|
+
|
|
73553
|
+
/**
|
|
73554
|
+
* Creates a matcher function from one or more glob patterns. The
|
|
73555
|
+
* returned function takes a string to match as its first argument,
|
|
73556
|
+
* and returns true if the string is a match. The returned matcher
|
|
73557
|
+
* function also takes a boolean as the second argument that, when true,
|
|
73558
|
+
* returns an object with additional information.
|
|
73559
|
+
*
|
|
73560
|
+
* ```js
|
|
73561
|
+
* const picomatch = require('picomatch');
|
|
73562
|
+
* // picomatch(glob[, options]);
|
|
73563
|
+
*
|
|
73564
|
+
* const isMatch = picomatch('*.!(*a)');
|
|
73565
|
+
* console.log(isMatch('a.a')); //=> false
|
|
73566
|
+
* console.log(isMatch('a.b')); //=> true
|
|
73567
|
+
* ```
|
|
73568
|
+
* @name picomatch
|
|
73569
|
+
* @param {String|Array} `globs` One or more glob patterns.
|
|
73570
|
+
* @param {Object=} `options`
|
|
73571
|
+
* @return {Function=} Returns a matcher function.
|
|
73572
|
+
* @api public
|
|
73573
|
+
*/
|
|
73574
|
+
|
|
73575
|
+
const picomatch$2 = (glob, options, returnState = false) => {
|
|
73576
|
+
if (Array.isArray(glob)) {
|
|
73577
|
+
const fns = glob.map(input => picomatch$2(input, options, returnState));
|
|
73578
|
+
const arrayMatcher = str => {
|
|
73579
|
+
for (const isMatch of fns) {
|
|
73580
|
+
const state = isMatch(str);
|
|
73581
|
+
if (state) return state;
|
|
73582
|
+
}
|
|
73583
|
+
return false;
|
|
73584
|
+
};
|
|
73585
|
+
return arrayMatcher;
|
|
73586
|
+
}
|
|
73587
|
+
|
|
73588
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
73589
|
+
|
|
73590
|
+
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
73591
|
+
throw new TypeError('Expected pattern to be a non-empty string');
|
|
73592
|
+
}
|
|
73593
|
+
|
|
73594
|
+
const opts = options || {};
|
|
73595
|
+
const posix = opts.windows;
|
|
73596
|
+
const regex = isState
|
|
73597
|
+
? picomatch$2.compileRe(glob, options)
|
|
73598
|
+
: picomatch$2.makeRe(glob, options, false, true);
|
|
73599
|
+
|
|
73600
|
+
const state = regex.state;
|
|
73601
|
+
delete regex.state;
|
|
73602
|
+
|
|
73603
|
+
let isIgnored = () => false;
|
|
73604
|
+
if (opts.ignore) {
|
|
73605
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
73606
|
+
isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
|
|
73607
|
+
}
|
|
73608
|
+
|
|
73609
|
+
const matcher = (input, returnObject = false) => {
|
|
73610
|
+
const { isMatch, match, output } = picomatch$2.test(input, regex, options, { glob, posix });
|
|
73611
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
73612
|
+
|
|
73613
|
+
if (typeof opts.onResult === 'function') {
|
|
73614
|
+
opts.onResult(result);
|
|
73615
|
+
}
|
|
73616
|
+
|
|
73617
|
+
if (isMatch === false) {
|
|
73618
|
+
result.isMatch = false;
|
|
73619
|
+
return returnObject ? result : false;
|
|
73620
|
+
}
|
|
73621
|
+
|
|
73622
|
+
if (isIgnored(input)) {
|
|
73623
|
+
if (typeof opts.onIgnore === 'function') {
|
|
73624
|
+
opts.onIgnore(result);
|
|
73625
|
+
}
|
|
73626
|
+
result.isMatch = false;
|
|
73627
|
+
return returnObject ? result : false;
|
|
73628
|
+
}
|
|
73629
|
+
|
|
73630
|
+
if (typeof opts.onMatch === 'function') {
|
|
73631
|
+
opts.onMatch(result);
|
|
73632
|
+
}
|
|
73633
|
+
return returnObject ? result : true;
|
|
73634
|
+
};
|
|
73635
|
+
|
|
73636
|
+
if (returnState) {
|
|
73637
|
+
matcher.state = state;
|
|
73638
|
+
}
|
|
73639
|
+
|
|
73640
|
+
return matcher;
|
|
73641
|
+
};
|
|
73642
|
+
|
|
73643
|
+
/**
|
|
73644
|
+
* Test `input` with the given `regex`. This is used by the main
|
|
73645
|
+
* `picomatch()` function to test the input string.
|
|
73646
|
+
*
|
|
73647
|
+
* ```js
|
|
73648
|
+
* const picomatch = require('picomatch');
|
|
73649
|
+
* // picomatch.test(input, regex[, options]);
|
|
73650
|
+
*
|
|
73651
|
+
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
73652
|
+
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
73653
|
+
* ```
|
|
73654
|
+
* @param {String} `input` String to test.
|
|
73655
|
+
* @param {RegExp} `regex`
|
|
73656
|
+
* @return {Object} Returns an object with matching info.
|
|
73657
|
+
* @api public
|
|
73658
|
+
*/
|
|
73659
|
+
|
|
73660
|
+
picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
73661
|
+
if (typeof input !== 'string') {
|
|
73662
|
+
throw new TypeError('Expected input to be a string');
|
|
73663
|
+
}
|
|
73664
|
+
|
|
73665
|
+
if (input === '') {
|
|
73666
|
+
return { isMatch: false, output: '' };
|
|
73667
|
+
}
|
|
73668
|
+
|
|
73669
|
+
const opts = options || {};
|
|
73670
|
+
const format = opts.format || (posix ? utils$1.toPosixSlashes : null);
|
|
73671
|
+
let match = input === glob;
|
|
73672
|
+
let output = (match && format) ? format(input) : input;
|
|
73673
|
+
|
|
73674
|
+
if (match === false) {
|
|
73675
|
+
output = format ? format(input) : input;
|
|
73676
|
+
match = output === glob;
|
|
73677
|
+
}
|
|
73678
|
+
|
|
73679
|
+
if (match === false || opts.capture === true) {
|
|
73680
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
73681
|
+
match = picomatch$2.matchBase(input, regex, options, posix);
|
|
73682
|
+
} else {
|
|
73683
|
+
match = regex.exec(output);
|
|
73684
|
+
}
|
|
73685
|
+
}
|
|
73686
|
+
|
|
73687
|
+
return { isMatch: Boolean(match), match, output };
|
|
73688
|
+
};
|
|
73689
|
+
|
|
73690
|
+
/**
|
|
73691
|
+
* Match the basename of a filepath.
|
|
73692
|
+
*
|
|
73693
|
+
* ```js
|
|
73694
|
+
* const picomatch = require('picomatch');
|
|
73695
|
+
* // picomatch.matchBase(input, glob[, options]);
|
|
73696
|
+
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
73697
|
+
* ```
|
|
73698
|
+
* @param {String} `input` String to test.
|
|
73699
|
+
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
73700
|
+
* @return {Boolean}
|
|
73701
|
+
* @api public
|
|
73702
|
+
*/
|
|
73703
|
+
|
|
73704
|
+
picomatch$2.matchBase = (input, glob, options) => {
|
|
73705
|
+
const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
|
|
73706
|
+
return regex.test(utils$1.basename(input));
|
|
73707
|
+
};
|
|
73708
|
+
|
|
73709
|
+
/**
|
|
73710
|
+
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
73711
|
+
*
|
|
73712
|
+
* ```js
|
|
73713
|
+
* const picomatch = require('picomatch');
|
|
73714
|
+
* // picomatch.isMatch(string, patterns[, options]);
|
|
73715
|
+
*
|
|
73716
|
+
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
73717
|
+
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
73718
|
+
* ```
|
|
73719
|
+
* @param {String|Array} str The string to test.
|
|
73720
|
+
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
73721
|
+
* @param {Object} [options] See available [options](#options).
|
|
73722
|
+
* @return {Boolean} Returns true if any patterns match `str`
|
|
73723
|
+
* @api public
|
|
73724
|
+
*/
|
|
73725
|
+
|
|
73726
|
+
picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
|
|
73727
|
+
|
|
73728
|
+
/**
|
|
73729
|
+
* Parse a glob pattern to create the source string for a regular
|
|
73730
|
+
* expression.
|
|
73731
|
+
*
|
|
73732
|
+
* ```js
|
|
73733
|
+
* const picomatch = require('picomatch');
|
|
73734
|
+
* const result = picomatch.parse(pattern[, options]);
|
|
73735
|
+
* ```
|
|
73736
|
+
* @param {String} `pattern`
|
|
73737
|
+
* @param {Object} `options`
|
|
73738
|
+
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
73739
|
+
* @api public
|
|
73740
|
+
*/
|
|
73741
|
+
|
|
73742
|
+
picomatch$2.parse = (pattern, options) => {
|
|
73743
|
+
if (Array.isArray(pattern)) return pattern.map(p => picomatch$2.parse(p, options));
|
|
73744
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
73745
|
+
};
|
|
73746
|
+
|
|
73747
|
+
/**
|
|
73748
|
+
* Scan a glob pattern to separate the pattern into segments.
|
|
73749
|
+
*
|
|
73750
|
+
* ```js
|
|
73751
|
+
* const picomatch = require('picomatch');
|
|
73752
|
+
* // picomatch.scan(input[, options]);
|
|
73753
|
+
*
|
|
73754
|
+
* const result = picomatch.scan('!./foo/*.js');
|
|
73755
|
+
* console.log(result);
|
|
73756
|
+
* { prefix: '!./',
|
|
73757
|
+
* input: '!./foo/*.js',
|
|
73758
|
+
* start: 3,
|
|
73759
|
+
* base: 'foo',
|
|
73760
|
+
* glob: '*.js',
|
|
73761
|
+
* isBrace: false,
|
|
73762
|
+
* isBracket: false,
|
|
73763
|
+
* isGlob: true,
|
|
73764
|
+
* isExtglob: false,
|
|
73765
|
+
* isGlobstar: false,
|
|
73766
|
+
* negated: true }
|
|
73767
|
+
* ```
|
|
73768
|
+
* @param {String} `input` Glob pattern to scan.
|
|
73769
|
+
* @param {Object} `options`
|
|
73770
|
+
* @return {Object} Returns an object with
|
|
73771
|
+
* @api public
|
|
73772
|
+
*/
|
|
73773
|
+
|
|
73774
|
+
picomatch$2.scan = (input, options) => scan(input, options);
|
|
73775
|
+
|
|
73776
|
+
/**
|
|
73777
|
+
* Compile a regular expression from the `state` object returned by the
|
|
73778
|
+
* [parse()](#parse) method.
|
|
73779
|
+
*
|
|
73780
|
+
* @param {Object} `state`
|
|
73781
|
+
* @param {Object} `options`
|
|
73782
|
+
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
73783
|
+
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
73784
|
+
* @return {RegExp}
|
|
73785
|
+
* @api public
|
|
73786
|
+
*/
|
|
73787
|
+
|
|
73788
|
+
picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
73789
|
+
if (returnOutput === true) {
|
|
73790
|
+
return state.output;
|
|
73791
|
+
}
|
|
73792
|
+
|
|
73793
|
+
const opts = options || {};
|
|
73794
|
+
const prepend = opts.contains ? '' : '^';
|
|
73795
|
+
const append = opts.contains ? '' : '$';
|
|
73796
|
+
|
|
73797
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
73798
|
+
if (state && state.negated === true) {
|
|
73799
|
+
source = `^(?!${source}).*$`;
|
|
73800
|
+
}
|
|
73801
|
+
|
|
73802
|
+
const regex = picomatch$2.toRegex(source, options);
|
|
73803
|
+
if (returnState === true) {
|
|
73804
|
+
regex.state = state;
|
|
73805
|
+
}
|
|
73806
|
+
|
|
73807
|
+
return regex;
|
|
73808
|
+
};
|
|
73809
|
+
|
|
73810
|
+
/**
|
|
73811
|
+
* Create a regular expression from a parsed glob pattern.
|
|
73812
|
+
*
|
|
73813
|
+
* ```js
|
|
73814
|
+
* const picomatch = require('picomatch');
|
|
73815
|
+
* const state = picomatch.parse('*.js');
|
|
73816
|
+
* // picomatch.compileRe(state[, options]);
|
|
73817
|
+
*
|
|
73818
|
+
* console.log(picomatch.compileRe(state));
|
|
73819
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
73820
|
+
* ```
|
|
73821
|
+
* @param {String} `state` The object returned from the `.parse` method.
|
|
73822
|
+
* @param {Object} `options`
|
|
73823
|
+
* @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.
|
|
73824
|
+
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
73825
|
+
* @return {RegExp} Returns a regex created from the given pattern.
|
|
73826
|
+
* @api public
|
|
73827
|
+
*/
|
|
73828
|
+
|
|
73829
|
+
picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
73830
|
+
if (!input || typeof input !== 'string') {
|
|
73831
|
+
throw new TypeError('Expected a non-empty string');
|
|
73832
|
+
}
|
|
73833
|
+
|
|
73834
|
+
let parsed = { negated: false, fastpaths: true };
|
|
73835
|
+
|
|
73836
|
+
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
73837
|
+
parsed.output = parse.fastpaths(input, options);
|
|
73838
|
+
}
|
|
73839
|
+
|
|
73840
|
+
if (!parsed.output) {
|
|
73841
|
+
parsed = parse(input, options);
|
|
73842
|
+
}
|
|
73843
|
+
|
|
73844
|
+
return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
|
|
73845
|
+
};
|
|
73846
|
+
|
|
73847
|
+
/**
|
|
73848
|
+
* Create a regular expression from the given regex source string.
|
|
73849
|
+
*
|
|
73850
|
+
* ```js
|
|
73851
|
+
* const picomatch = require('picomatch');
|
|
73852
|
+
* // picomatch.toRegex(source[, options]);
|
|
73853
|
+
*
|
|
73854
|
+
* const { output } = picomatch.parse('*.js');
|
|
73855
|
+
* console.log(picomatch.toRegex(output));
|
|
73856
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
73857
|
+
* ```
|
|
73858
|
+
* @param {String} `source` Regular expression source string.
|
|
73859
|
+
* @param {Object} `options`
|
|
73860
|
+
* @return {RegExp}
|
|
73861
|
+
* @api public
|
|
73862
|
+
*/
|
|
73863
|
+
|
|
73864
|
+
picomatch$2.toRegex = (source, options) => {
|
|
73865
|
+
try {
|
|
73866
|
+
const opts = options || {};
|
|
73867
|
+
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
73868
|
+
} catch (err) {
|
|
73869
|
+
if (options && options.debug === true) throw err;
|
|
73870
|
+
return /$^/;
|
|
73871
|
+
}
|
|
73872
|
+
};
|
|
73873
|
+
|
|
73874
|
+
/**
|
|
73875
|
+
* Picomatch constants.
|
|
73876
|
+
* @return {Object}
|
|
73877
|
+
*/
|
|
73878
|
+
|
|
73879
|
+
picomatch$2.constants = constants;
|
|
73880
|
+
|
|
73881
|
+
/**
|
|
73882
|
+
* Expose "picomatch"
|
|
73883
|
+
*/
|
|
73884
|
+
|
|
73885
|
+
var picomatch_1$1 = picomatch$2;
|
|
73886
|
+
|
|
73887
|
+
picomatch_1$1.default;
|
|
73888
|
+
|
|
73889
|
+
const pico = picomatch_1$1;
|
|
73890
|
+
const utils = utils$4;
|
|
73891
|
+
|
|
73892
|
+
function picomatch(glob, options, returnState = false) {
|
|
73893
|
+
// default to os.platform()
|
|
73894
|
+
if (options && (options.windows === null || options.windows === undefined)) {
|
|
73895
|
+
// don't mutate the original options object
|
|
73896
|
+
options = { ...options, windows: utils.isWindows() };
|
|
73897
|
+
}
|
|
73898
|
+
|
|
73899
|
+
return pico(glob, options, returnState);
|
|
73900
|
+
}
|
|
73901
|
+
|
|
73902
|
+
Object.assign(picomatch, pico);
|
|
73903
|
+
var picomatch_1 = picomatch;
|
|
73904
|
+
|
|
73905
|
+
var picomatch$1 = picomatch_1.default;
|
|
73906
|
+
|
|
73907
|
+
const {stringLiteral: stringLiteral$1} = lib_exports;
|
|
73908
|
+
const getValue = ({node}) => node.value;
|
|
73909
|
+
|
|
73910
|
+
const ignore = ({name, property, list, type = __ignore}) => ({
|
|
73911
|
+
report: createReport$1(name),
|
|
73912
|
+
fix: fix$1,
|
|
73913
|
+
traverse: createTraverse$1({
|
|
73914
|
+
type,
|
|
73915
|
+
property,
|
|
73916
|
+
list,
|
|
73917
|
+
}),
|
|
73918
|
+
});
|
|
73919
|
+
|
|
73920
|
+
const addQuotes = (a) => `'${a}'`;
|
|
73921
|
+
|
|
73922
|
+
const createReport$1 = (filename) => ({name, matchedElements}) => {
|
|
73923
|
+
let insteadOf = '';
|
|
73924
|
+
|
|
73925
|
+
if (matchedElements.length) {
|
|
73926
|
+
const replacedNames = matchedElements.map(getValue);
|
|
73927
|
+
const namesLine = replacedNames
|
|
73928
|
+
.map(addQuotes)
|
|
73929
|
+
.join(', ');
|
|
73930
|
+
|
|
73931
|
+
insteadOf = ` instead of ${namesLine}`;
|
|
73932
|
+
}
|
|
73933
|
+
|
|
73934
|
+
return `Add '${name}'${insteadOf} to '${filename}'`;
|
|
73935
|
+
};
|
|
73936
|
+
|
|
73937
|
+
const fix$1 = ({path, name, matchedElements}) => {
|
|
73938
|
+
path.node.elements.push(stringLiteral$1(name));
|
|
73939
|
+
matchedElements.map(remove);
|
|
73940
|
+
};
|
|
73941
|
+
|
|
73942
|
+
const createTraverse$1 = ({type, property, list}) => ({push, options}) => {
|
|
73943
|
+
const {dismiss = []} = options;
|
|
73944
|
+
const newNames = filterNames(list, dismiss);
|
|
73945
|
+
|
|
73946
|
+
if (!newNames.length)
|
|
73947
|
+
return {};
|
|
73948
|
+
|
|
73949
|
+
return {
|
|
73950
|
+
[type]: (path) => {
|
|
73951
|
+
const [parentOfElements, elements] = parseElements$1(path, {
|
|
73952
|
+
property,
|
|
73953
|
+
});
|
|
73954
|
+
|
|
73955
|
+
if (!parentOfElements)
|
|
73956
|
+
return;
|
|
73957
|
+
|
|
73958
|
+
const list = elements.map(getValue);
|
|
73959
|
+
|
|
73960
|
+
for (const name of newNames) {
|
|
73961
|
+
if (list.includes(name))
|
|
73962
|
+
continue;
|
|
73963
|
+
|
|
73964
|
+
const match = picomatch$1(name);
|
|
73965
|
+
const matchedElements = [];
|
|
73966
|
+
|
|
73967
|
+
for (const current of elements.filter(exists)) {
|
|
73968
|
+
const {value} = current.node;
|
|
73969
|
+
|
|
73970
|
+
if (match(value))
|
|
73971
|
+
matchedElements.push(current);
|
|
73972
|
+
}
|
|
73973
|
+
|
|
73974
|
+
push({
|
|
73975
|
+
path: parentOfElements,
|
|
73976
|
+
matchedElements,
|
|
73977
|
+
elements,
|
|
73978
|
+
name,
|
|
73979
|
+
});
|
|
73980
|
+
}
|
|
73981
|
+
},
|
|
73982
|
+
};
|
|
73983
|
+
};
|
|
73984
|
+
|
|
73985
|
+
function filterNames(names, dismiss) {
|
|
73986
|
+
const newNames = [];
|
|
73987
|
+
|
|
73988
|
+
for (const name of names) {
|
|
73989
|
+
if (dismiss.includes(name))
|
|
73990
|
+
continue;
|
|
73991
|
+
|
|
73992
|
+
newNames.push(name);
|
|
73993
|
+
}
|
|
73994
|
+
|
|
73995
|
+
return newNames;
|
|
73996
|
+
}
|
|
73997
|
+
|
|
73998
|
+
const exists = ({node}) => Boolean(node);
|
|
73999
|
+
const emptyList = [];
|
|
74000
|
+
|
|
74001
|
+
function parseElements$1(path, {property}) {
|
|
74002
|
+
if (!property) {
|
|
74003
|
+
const [arg] = path.get('arguments');
|
|
74004
|
+
return [arg, arg.get('elements')];
|
|
74005
|
+
}
|
|
74006
|
+
|
|
74007
|
+
const [prop] = traverseProperties(path, property);
|
|
74008
|
+
|
|
74009
|
+
if (!prop)
|
|
74010
|
+
return [null, emptyList];
|
|
74011
|
+
|
|
74012
|
+
const valuePath = prop.get('value');
|
|
74013
|
+
|
|
74014
|
+
return [valuePath, valuePath.get('elements')];
|
|
74015
|
+
}
|
|
74016
|
+
|
|
74017
|
+
const {
|
|
74018
|
+
parenthesizedExpression,
|
|
74019
|
+
tsParenthesizedType,
|
|
74020
|
+
} = lib_exports;
|
|
74021
|
+
|
|
74022
|
+
const addParens = (path) => {
|
|
74023
|
+
const printer = getPrinter(path);
|
|
74024
|
+
|
|
74025
|
+
if (hasParens(path, printer))
|
|
74026
|
+
return path;
|
|
74027
|
+
|
|
74028
|
+
if (printer !== 'babel') {
|
|
74029
|
+
const {extra = {}} = path.node;
|
|
74030
|
+
|
|
74031
|
+
extra.parenthesized = true;
|
|
74032
|
+
path.node.extra = extra;
|
|
74033
|
+
|
|
74034
|
+
return path;
|
|
74035
|
+
}
|
|
74036
|
+
|
|
74037
|
+
const {node} = path;
|
|
74038
|
+
|
|
74039
|
+
if (path.type.startsWith('TS'))
|
|
74040
|
+
return path.replaceWith(tsParenthesizedType(node));
|
|
74041
|
+
|
|
74042
|
+
path.replaceWith(parenthesizedExpression(node));
|
|
74043
|
+
|
|
74044
|
+
return path;
|
|
74045
|
+
};
|
|
74046
|
+
|
|
74047
|
+
const removeParens = (path) => {
|
|
74048
|
+
const printer = getPrinter(path);
|
|
74049
|
+
|
|
74050
|
+
if (!hasParens(path, printer))
|
|
74051
|
+
return path;
|
|
74052
|
+
|
|
74053
|
+
if (printer !== 'babel') {
|
|
74054
|
+
path.node.extra.parenthesized = false;
|
|
74055
|
+
return path;
|
|
74056
|
+
}
|
|
74057
|
+
|
|
74058
|
+
const {node} = path;
|
|
74059
|
+
path.parentPath.replaceWith(node);
|
|
74060
|
+
|
|
74061
|
+
return path;
|
|
74062
|
+
};
|
|
74063
|
+
|
|
74064
|
+
function getPrinter(path) {
|
|
74065
|
+
const scope = path.scope.getProgramParent();
|
|
74066
|
+
const programPath = scope.path;
|
|
74067
|
+
|
|
74068
|
+
return programPath.node.extra.__putout_printer;
|
|
74069
|
+
}
|
|
74070
|
+
|
|
74071
|
+
function hasParens(path, printer = getPrinter(path)) {
|
|
74072
|
+
if (printer !== 'babel')
|
|
74073
|
+
return path.node.extra?.parenthesized;
|
|
74074
|
+
|
|
74075
|
+
const {type} = path.parentPath;
|
|
74076
|
+
|
|
74077
|
+
return /^(TS)?Parenthesized(Expression|Type)?$/.test(type);
|
|
74078
|
+
}
|
|
74079
|
+
|
|
74080
|
+
const findFileUp = (file, name) => {
|
|
74081
|
+
const parentDirectory = getParentDirectory(file);
|
|
74082
|
+
|
|
74083
|
+
if (!parentDirectory)
|
|
74084
|
+
return null;
|
|
74085
|
+
|
|
74086
|
+
const [currentFile] = getFile(parentDirectory, name, {
|
|
74087
|
+
type: 'file',
|
|
74088
|
+
});
|
|
74089
|
+
|
|
74090
|
+
if (currentFile)
|
|
74091
|
+
return currentFile;
|
|
74092
|
+
|
|
74093
|
+
return findFileUp(parentDirectory, name);
|
|
74094
|
+
};
|
|
74095
|
+
|
|
74096
|
+
const {stringLiteral} = lib_exports;
|
|
74097
|
+
|
|
74098
|
+
const sortIgnore = ({name, property, type = __ignore}) => ({
|
|
74099
|
+
report: createReport({
|
|
74100
|
+
name,
|
|
74101
|
+
property,
|
|
74102
|
+
}),
|
|
74103
|
+
fix,
|
|
74104
|
+
traverse: createTraverse({
|
|
74105
|
+
type,
|
|
74106
|
+
property,
|
|
74107
|
+
}),
|
|
74108
|
+
});
|
|
74109
|
+
|
|
74110
|
+
const createReport = ({name, property}) => () => {
|
|
74111
|
+
if (property)
|
|
74112
|
+
return `Sort '${property}' section of '${name}'`;
|
|
74113
|
+
|
|
74114
|
+
return `Sort '${name}'`;
|
|
74115
|
+
};
|
|
74116
|
+
|
|
74117
|
+
const fix = ({path, sortedElements}) => {
|
|
74118
|
+
path.node.elements = sortedElements;
|
|
74119
|
+
};
|
|
74120
|
+
|
|
74121
|
+
const createTraverse = ({type, property}) => ({push}) => ({
|
|
74122
|
+
[type]: (path) => {
|
|
74123
|
+
const masks = [];
|
|
74124
|
+
const hidden = [];
|
|
74125
|
+
const files = [];
|
|
74126
|
+
const dirs = [];
|
|
74127
|
+
|
|
74128
|
+
const parentOfElements = parseElements(path, {
|
|
74129
|
+
property,
|
|
74130
|
+
});
|
|
74131
|
+
|
|
74132
|
+
if (!parentOfElements)
|
|
74133
|
+
return;
|
|
74134
|
+
|
|
74135
|
+
const {elements} = parentOfElements.node;
|
|
74136
|
+
|
|
74137
|
+
for (const element of elements) {
|
|
74138
|
+
const {value} = element;
|
|
74139
|
+
|
|
74140
|
+
if (!value)
|
|
74141
|
+
continue;
|
|
74142
|
+
|
|
74143
|
+
if (value.startsWith('*')) {
|
|
74144
|
+
masks.push(element);
|
|
74145
|
+
continue;
|
|
74146
|
+
}
|
|
74147
|
+
|
|
74148
|
+
if (value.startsWith('.')) {
|
|
74149
|
+
hidden.push(element);
|
|
74150
|
+
continue;
|
|
74151
|
+
}
|
|
74152
|
+
|
|
74153
|
+
if (value.includes('.')) {
|
|
74154
|
+
files.push(element);
|
|
74155
|
+
continue;
|
|
74156
|
+
}
|
|
74157
|
+
|
|
74158
|
+
if (value.startsWith('#'))
|
|
74159
|
+
continue;
|
|
74160
|
+
|
|
74161
|
+
dirs.push(element);
|
|
74162
|
+
}
|
|
74163
|
+
|
|
74164
|
+
const sortedElements = [
|
|
74165
|
+
...maybeSeparate(masks, property),
|
|
74166
|
+
...maybeSeparate(hidden, property),
|
|
74167
|
+
...maybeSeparate(files, property),
|
|
74168
|
+
...dirs,
|
|
74169
|
+
];
|
|
74170
|
+
|
|
74171
|
+
for (const [index, {value}] of elements.entries()) {
|
|
74172
|
+
const current = sortedElements[index];
|
|
74173
|
+
|
|
74174
|
+
if (current.value !== value) {
|
|
74175
|
+
push({
|
|
74176
|
+
path: parentOfElements,
|
|
74177
|
+
sortedElements,
|
|
74178
|
+
});
|
|
74179
|
+
break;
|
|
74180
|
+
}
|
|
74181
|
+
}
|
|
74182
|
+
},
|
|
74183
|
+
});
|
|
74184
|
+
|
|
74185
|
+
function parseElements(path, {property}) {
|
|
74186
|
+
if (!property) {
|
|
74187
|
+
const [arg] = path.get('arguments');
|
|
74188
|
+
|
|
74189
|
+
if (!arg.node.elements)
|
|
74190
|
+
return null;
|
|
74191
|
+
|
|
74192
|
+
return arg;
|
|
74193
|
+
}
|
|
74194
|
+
|
|
74195
|
+
const [prop] = traverseProperties(path, property);
|
|
74196
|
+
|
|
74197
|
+
if (!prop)
|
|
74198
|
+
return null;
|
|
74199
|
+
|
|
74200
|
+
return prop.get('value');
|
|
74201
|
+
}
|
|
74202
|
+
|
|
74203
|
+
function maybeSeparate(array, property) {
|
|
74204
|
+
if (property)
|
|
74205
|
+
return array;
|
|
74206
|
+
|
|
74207
|
+
if (!array.length)
|
|
74208
|
+
return [];
|
|
74209
|
+
|
|
74210
|
+
return [
|
|
74211
|
+
...array,
|
|
74212
|
+
stringLiteral(''),
|
|
74213
|
+
];
|
|
74214
|
+
}
|
|
74215
|
+
|
|
74216
|
+
var operator = /*#__PURE__*/Object.freeze({
|
|
74217
|
+
__proto__: null,
|
|
74218
|
+
__filesystem: __filesystem,
|
|
74219
|
+
__filesystem_name: __filesystem_name,
|
|
74220
|
+
__ignore: __ignore,
|
|
74221
|
+
__ignore_name: __ignore_name,
|
|
74222
|
+
__json: __json,
|
|
74223
|
+
__json_name: __json_name,
|
|
74224
|
+
__toml: __toml,
|
|
74225
|
+
__toml_name: __toml_name,
|
|
74226
|
+
__yaml: __yaml,
|
|
74227
|
+
__yaml_name: __yaml_name,
|
|
74228
|
+
addArgs: addArgs,
|
|
74229
|
+
addAttribute: addAttribute,
|
|
74230
|
+
addAttributeValue: addAttributeValue,
|
|
74231
|
+
addClassName: addClassName,
|
|
74232
|
+
addParens: addParens,
|
|
74233
|
+
compare: compare,
|
|
74234
|
+
compareAll: compareAll,
|
|
74235
|
+
compareAny: compareAny,
|
|
74236
|
+
compute: compute,
|
|
74237
|
+
contains: contains,
|
|
74238
|
+
containsClassName: containsClassName,
|
|
74239
|
+
copyFile: copyFile,
|
|
74240
|
+
crawlDirectory: crawlDirectory,
|
|
74241
|
+
createDirectory: createDirectory,
|
|
74242
|
+
createFile: createFile,
|
|
74243
|
+
createNestedDirectory: createNestedDirectory,
|
|
74244
|
+
declare: declare$1,
|
|
74245
|
+
extract: extract,
|
|
74246
|
+
findBinding: findBinding,
|
|
74247
|
+
findFile: findFile,
|
|
74248
|
+
findFileUp: findFileUp,
|
|
74249
|
+
findVarsWays: findVarsWays,
|
|
74250
|
+
fix: fix$1,
|
|
72059
74251
|
fromJS: fromJS,
|
|
72060
74252
|
getAttributeNode: getAttributeNode,
|
|
72061
74253
|
getAttributePath: getAttributePath,
|
|
@@ -72090,6 +74282,7 @@ var operator = /*#__PURE__*/Object.freeze({
|
|
|
72090
74282
|
isJSON: isJSON,
|
|
72091
74283
|
isJSONGroup: isJSONGroup,
|
|
72092
74284
|
isKeyword: isKeyword,
|
|
74285
|
+
isLegacyKeyword: isLegacyKeyword,
|
|
72093
74286
|
isModuleDeclarationKeyword: isModuleDeclarationKeyword,
|
|
72094
74287
|
isModuleExports: isModuleExports,
|
|
72095
74288
|
isSimple: isSimple,
|
|
@@ -72118,6 +74311,7 @@ var operator = /*#__PURE__*/Object.freeze({
|
|
|
72118
74311
|
setAttributeValue: setAttributeValue,
|
|
72119
74312
|
setLiteralValue: setLiteralValue,
|
|
72120
74313
|
setValues: setValues,
|
|
74314
|
+
sortIgnore: sortIgnore,
|
|
72121
74315
|
toExpression: toExpression,
|
|
72122
74316
|
toJS: toJS,
|
|
72123
74317
|
transformRegExp: transformRegExp,
|
|
@@ -72149,7 +74343,7 @@ var exports$1 = /*#__PURE__*/Object.freeze({
|
|
|
72149
74343
|
findPlacesAsync: findPlacesAsync,
|
|
72150
74344
|
generate: generate,
|
|
72151
74345
|
operator: operator,
|
|
72152
|
-
parse: parse$
|
|
74346
|
+
parse: parse$4,
|
|
72153
74347
|
print: print,
|
|
72154
74348
|
putoutAsync: putoutAsync,
|
|
72155
74349
|
template: template$1,
|
|
@@ -72161,4 +74355,4 @@ var exports$1 = /*#__PURE__*/Object.freeze({
|
|
|
72161
74355
|
|
|
72162
74356
|
Object.assign(putout, exports$1);
|
|
72163
74357
|
|
|
72164
|
-
export { codeframe, putout as default, findPlaces, findPlacesAsync, generate, operator, parse$
|
|
74358
|
+
export { codeframe, putout as default, findPlaces, findPlacesAsync, generate, operator, parse$4 as parse, print, putout, putoutAsync, template$1 as template, transform, transformAsync, traverse3 as traverse, lib_exports as types };
|