@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.js
CHANGED
|
@@ -3444,7 +3444,7 @@ __export(lib_exports, {
|
|
|
3444
3444
|
isExportNamespaceSpecifier: () => isExportNamespaceSpecifier$1,
|
|
3445
3445
|
isExportSpecifier: () => isExportSpecifier$1,
|
|
3446
3446
|
isExpression: () => isExpression$2,
|
|
3447
|
-
isExpressionStatement: () => isExpressionStatement$
|
|
3447
|
+
isExpressionStatement: () => isExpressionStatement$b,
|
|
3448
3448
|
isExpressionWrapper: () => isExpressionWrapper,
|
|
3449
3449
|
isFile: () => isFile$2,
|
|
3450
3450
|
isFlow: () => isFlow,
|
|
@@ -3651,7 +3651,7 @@ __export(lib_exports, {
|
|
|
3651
3651
|
isThisTypeAnnotation: () => isThisTypeAnnotation,
|
|
3652
3652
|
isThrowStatement: () => isThrowStatement,
|
|
3653
3653
|
isTopicReference: () => isTopicReference,
|
|
3654
|
-
isTryStatement: () => isTryStatement,
|
|
3654
|
+
isTryStatement: () => isTryStatement$1,
|
|
3655
3655
|
isTupleTypeAnnotation: () => isTupleTypeAnnotation,
|
|
3656
3656
|
isType: () => isType,
|
|
3657
3657
|
isTypeAlias: () => isTypeAlias,
|
|
@@ -3745,7 +3745,7 @@ __export(lib_exports, {
|
|
|
3745
3745
|
spreadElement: () => spreadElement,
|
|
3746
3746
|
spreadProperty: () => SpreadProperty,
|
|
3747
3747
|
staticBlock: () => staticBlock,
|
|
3748
|
-
stringLiteral: () => stringLiteral$
|
|
3748
|
+
stringLiteral: () => stringLiteral$6,
|
|
3749
3749
|
stringLiteralTypeAnnotation: () => stringLiteralTypeAnnotation,
|
|
3750
3750
|
stringTypeAnnotation: () => stringTypeAnnotation,
|
|
3751
3751
|
super: () => _super,
|
|
@@ -5492,7 +5492,7 @@ function isEmptyStatement(node, opts) {
|
|
|
5492
5492
|
return opts == null || shallowEqual(node, opts);
|
|
5493
5493
|
}
|
|
5494
5494
|
|
|
5495
|
-
function isExpressionStatement$
|
|
5495
|
+
function isExpressionStatement$b(node, opts) {
|
|
5496
5496
|
if (!node)
|
|
5497
5497
|
return false;
|
|
5498
5498
|
|
|
@@ -5782,7 +5782,7 @@ function isThrowStatement(node, opts) {
|
|
|
5782
5782
|
return opts == null || shallowEqual(node, opts);
|
|
5783
5783
|
}
|
|
5784
5784
|
|
|
5785
|
-
function isTryStatement(node, opts) {
|
|
5785
|
+
function isTryStatement$1(node, opts) {
|
|
5786
5786
|
if (!node)
|
|
5787
5787
|
return false;
|
|
5788
5788
|
|
|
@@ -9762,7 +9762,7 @@ function defineType$5(type, opts = {}) {
|
|
|
9762
9762
|
store[type] = opts;
|
|
9763
9763
|
}
|
|
9764
9764
|
|
|
9765
|
-
var utils$
|
|
9765
|
+
var utils$6 = /* @__PURE__ */Object.freeze({
|
|
9766
9766
|
__proto__: null,
|
|
9767
9767
|
ALIAS_KEYS,
|
|
9768
9768
|
BUILDER_KEYS,
|
|
@@ -13687,7 +13687,7 @@ var _validate = /* @__PURE__ */Object.freeze({
|
|
|
13687
13687
|
|
|
13688
13688
|
var {validateInternal: validate$3} = _validate;
|
|
13689
13689
|
|
|
13690
|
-
var {NODE_FIELDS} = utils$
|
|
13690
|
+
var {NODE_FIELDS} = utils$6;
|
|
13691
13691
|
|
|
13692
13692
|
function arrayExpression$3(elements) {
|
|
13693
13693
|
const node = {
|
|
@@ -13999,7 +13999,7 @@ function labeledStatement(label, body) {
|
|
|
13999
13999
|
return node;
|
|
14000
14000
|
}
|
|
14001
14001
|
|
|
14002
|
-
function stringLiteral$
|
|
14002
|
+
function stringLiteral$6(value) {
|
|
14003
14003
|
const node = {
|
|
14004
14004
|
type: 'StringLiteral',
|
|
14005
14005
|
value,
|
|
@@ -16890,7 +16890,7 @@ var b = /* @__PURE__ */Object.freeze({
|
|
|
16890
16890
|
spreadElement,
|
|
16891
16891
|
spreadProperty: SpreadProperty,
|
|
16892
16892
|
staticBlock,
|
|
16893
|
-
stringLiteral: stringLiteral$
|
|
16893
|
+
stringLiteral: stringLiteral$6,
|
|
16894
16894
|
stringLiteralTypeAnnotation,
|
|
16895
16895
|
stringTypeAnnotation,
|
|
16896
16896
|
super: _super,
|
|
@@ -17287,7 +17287,7 @@ function cleanJSXElementLiteralChild(child, args) {
|
|
|
17287
17287
|
}
|
|
17288
17288
|
|
|
17289
17289
|
if (str)
|
|
17290
|
-
args.push(inherits(stringLiteral$
|
|
17290
|
+
args.push(inherits(stringLiteral$6(str), child));
|
|
17291
17291
|
}
|
|
17292
17292
|
|
|
17293
17293
|
function buildChildren(node) {
|
|
@@ -19062,13 +19062,13 @@ function toBindingIdentifierName(name) {
|
|
|
19062
19062
|
|
|
19063
19063
|
function toComputedKey(node, key = node.key || node.property) {
|
|
19064
19064
|
if (!node.computed && isIdentifier$h(key))
|
|
19065
|
-
key = stringLiteral$
|
|
19065
|
+
key = stringLiteral$6(key.name);
|
|
19066
19066
|
|
|
19067
19067
|
return key;
|
|
19068
19068
|
}
|
|
19069
19069
|
|
|
19070
19070
|
function toExpression$1(node) {
|
|
19071
|
-
if (isExpressionStatement$
|
|
19071
|
+
if (isExpressionStatement$b(node)) {
|
|
19072
19072
|
node = node.expression;
|
|
19073
19073
|
}
|
|
19074
19074
|
|
|
@@ -19272,7 +19272,7 @@ function valueToNode(value) {
|
|
|
19272
19272
|
}
|
|
19273
19273
|
|
|
19274
19274
|
if (typeof value === 'string') {
|
|
19275
|
-
return stringLiteral$
|
|
19275
|
+
return stringLiteral$6(value);
|
|
19276
19276
|
}
|
|
19277
19277
|
|
|
19278
19278
|
if (typeof value === 'number') {
|
|
@@ -19327,12 +19327,12 @@ function valueToNode(value) {
|
|
|
19327
19327
|
if (isValidIdentifier(key)) {
|
|
19328
19328
|
if (key === '__proto__') {
|
|
19329
19329
|
computed = true;
|
|
19330
|
-
nodeKey = stringLiteral$
|
|
19330
|
+
nodeKey = stringLiteral$6(key);
|
|
19331
19331
|
} else {
|
|
19332
19332
|
nodeKey = identifier$2(key);
|
|
19333
19333
|
}
|
|
19334
19334
|
} else {
|
|
19335
|
-
nodeKey = stringLiteral$
|
|
19335
|
+
nodeKey = stringLiteral$6(key);
|
|
19336
19336
|
}
|
|
19337
19337
|
|
|
19338
19338
|
props.push(objectProperty$3(nodeKey, valueToNode(value[key]), computed));
|
|
@@ -20731,14 +20731,6 @@ var estree = (superClass) => class ESTreeParserMixin extends superClass {
|
|
|
20731
20731
|
return node;
|
|
20732
20732
|
}
|
|
20733
20733
|
|
|
20734
|
-
toReferencedArguments(node) {
|
|
20735
|
-
if (node.type === 'ImportExpression') {
|
|
20736
|
-
return;
|
|
20737
|
-
}
|
|
20738
|
-
|
|
20739
|
-
super.toReferencedArguments(node);
|
|
20740
|
-
}
|
|
20741
|
-
|
|
20742
20734
|
parseExport(unfinished, decorators) {
|
|
20743
20735
|
const exportStartLoc = this.state.lastTokStartLoc;
|
|
20744
20736
|
const node = super.parseExport(unfinished, decorators);
|
|
@@ -23262,7 +23254,7 @@ var jsx = (superClass) => class JSXParserMixin extends superClass {
|
|
|
23262
23254
|
|
|
23263
23255
|
do {
|
|
23264
23256
|
ch = this.input.charCodeAt(++this.state.pos);
|
|
23265
|
-
} while (isIdentifierChar2(ch) || ch === 45)
|
|
23257
|
+
} while (isIdentifierChar2(ch) || ch === 45);
|
|
23266
23258
|
this.finishToken(136, this.input.slice(start, this.state.pos));
|
|
23267
23259
|
}
|
|
23268
23260
|
|
|
@@ -24021,7 +24013,7 @@ var CommentsParser = class extends BaseParser {
|
|
|
24021
24013
|
};
|
|
24022
24014
|
|
|
24023
24015
|
var State$2 = class _State {
|
|
24024
|
-
flags =
|
|
24016
|
+
flags = 512;
|
|
24025
24017
|
get strict() {
|
|
24026
24018
|
return (this.flags & 1) > 0;
|
|
24027
24019
|
}
|
|
@@ -24051,107 +24043,96 @@ var State$2 = class _State {
|
|
|
24051
24043
|
potentialArrowAt = -1;
|
|
24052
24044
|
noArrowAt = [];
|
|
24053
24045
|
noArrowParamsConversionAt = [];
|
|
24054
|
-
get
|
|
24046
|
+
get inType() {
|
|
24055
24047
|
return (this.flags & 2) > 0;
|
|
24056
24048
|
}
|
|
24057
24049
|
|
|
24058
|
-
set
|
|
24050
|
+
set inType(v) {
|
|
24059
24051
|
if (v)
|
|
24060
24052
|
this.flags |= 2;
|
|
24061
24053
|
else
|
|
24062
24054
|
this.flags &= -3;
|
|
24063
24055
|
}
|
|
24064
24056
|
|
|
24065
|
-
get
|
|
24057
|
+
get noAnonFunctionType() {
|
|
24066
24058
|
return (this.flags & 4) > 0;
|
|
24067
24059
|
}
|
|
24068
24060
|
|
|
24069
|
-
set
|
|
24061
|
+
set noAnonFunctionType(v) {
|
|
24070
24062
|
if (v)
|
|
24071
24063
|
this.flags |= 4;
|
|
24072
24064
|
else
|
|
24073
24065
|
this.flags &= -5;
|
|
24074
24066
|
}
|
|
24075
24067
|
|
|
24076
|
-
get
|
|
24068
|
+
get hasFlowComment() {
|
|
24077
24069
|
return (this.flags & 8) > 0;
|
|
24078
24070
|
}
|
|
24079
24071
|
|
|
24080
|
-
set
|
|
24072
|
+
set hasFlowComment(v) {
|
|
24081
24073
|
if (v)
|
|
24082
24074
|
this.flags |= 8;
|
|
24083
24075
|
else
|
|
24084
24076
|
this.flags &= -9;
|
|
24085
24077
|
}
|
|
24086
24078
|
|
|
24087
|
-
get
|
|
24079
|
+
get isAmbientContext() {
|
|
24088
24080
|
return (this.flags & 16) > 0;
|
|
24089
24081
|
}
|
|
24090
24082
|
|
|
24091
|
-
set
|
|
24083
|
+
set isAmbientContext(v) {
|
|
24092
24084
|
if (v)
|
|
24093
24085
|
this.flags |= 16;
|
|
24094
24086
|
else
|
|
24095
24087
|
this.flags &= -17;
|
|
24096
24088
|
}
|
|
24097
24089
|
|
|
24098
|
-
get
|
|
24090
|
+
get inAbstractClass() {
|
|
24099
24091
|
return (this.flags & 32) > 0;
|
|
24100
24092
|
}
|
|
24101
24093
|
|
|
24102
|
-
set
|
|
24094
|
+
set inAbstractClass(v) {
|
|
24103
24095
|
if (v)
|
|
24104
24096
|
this.flags |= 32;
|
|
24105
24097
|
else
|
|
24106
24098
|
this.flags &= -33;
|
|
24107
24099
|
}
|
|
24108
24100
|
|
|
24109
|
-
get
|
|
24101
|
+
get inDisallowConditionalTypesContext() {
|
|
24110
24102
|
return (this.flags & 64) > 0;
|
|
24111
24103
|
}
|
|
24112
24104
|
|
|
24113
|
-
set
|
|
24105
|
+
set inDisallowConditionalTypesContext(v) {
|
|
24114
24106
|
if (v)
|
|
24115
24107
|
this.flags |= 64;
|
|
24116
24108
|
else
|
|
24117
24109
|
this.flags &= -65;
|
|
24118
24110
|
}
|
|
24119
24111
|
|
|
24120
|
-
get inDisallowConditionalTypesContext() {
|
|
24121
|
-
return (this.flags & 128) > 0;
|
|
24122
|
-
}
|
|
24123
|
-
|
|
24124
|
-
set inDisallowConditionalTypesContext(v) {
|
|
24125
|
-
if (v)
|
|
24126
|
-
this.flags |= 128;
|
|
24127
|
-
else
|
|
24128
|
-
this.flags &= -129;
|
|
24129
|
-
}
|
|
24130
|
-
|
|
24131
24112
|
topicContext = {
|
|
24132
24113
|
maxNumOfResolvableTopics: 0,
|
|
24133
24114
|
maxTopicIndex: null,
|
|
24134
24115
|
};
|
|
24135
24116
|
get soloAwait() {
|
|
24136
|
-
return (this.flags &
|
|
24117
|
+
return (this.flags & 128) > 0;
|
|
24137
24118
|
}
|
|
24138
24119
|
|
|
24139
24120
|
set soloAwait(v) {
|
|
24140
24121
|
if (v)
|
|
24141
|
-
this.flags |=
|
|
24122
|
+
this.flags |= 128;
|
|
24142
24123
|
else
|
|
24143
|
-
this.flags &= -
|
|
24124
|
+
this.flags &= -129;
|
|
24144
24125
|
}
|
|
24145
24126
|
|
|
24146
24127
|
get inFSharpPipelineDirectBody() {
|
|
24147
|
-
return (this.flags &
|
|
24128
|
+
return (this.flags & 256) > 0;
|
|
24148
24129
|
}
|
|
24149
24130
|
|
|
24150
24131
|
set inFSharpPipelineDirectBody(v) {
|
|
24151
24132
|
if (v)
|
|
24152
|
-
this.flags |=
|
|
24133
|
+
this.flags |= 256;
|
|
24153
24134
|
else
|
|
24154
|
-
this.flags &= -
|
|
24135
|
+
this.flags &= -257;
|
|
24155
24136
|
}
|
|
24156
24137
|
|
|
24157
24138
|
labels = [];
|
|
@@ -24166,37 +24147,37 @@ var State$2 = class _State {
|
|
|
24166
24147
|
lastTokStartLoc = null;
|
|
24167
24148
|
context = [types.brace];
|
|
24168
24149
|
get canStartJSXElement() {
|
|
24169
|
-
return (this.flags &
|
|
24150
|
+
return (this.flags & 512) > 0;
|
|
24170
24151
|
}
|
|
24171
24152
|
|
|
24172
24153
|
set canStartJSXElement(v) {
|
|
24173
24154
|
if (v)
|
|
24174
|
-
this.flags |=
|
|
24155
|
+
this.flags |= 512;
|
|
24175
24156
|
else
|
|
24176
|
-
this.flags &= -
|
|
24157
|
+
this.flags &= -513;
|
|
24177
24158
|
}
|
|
24178
24159
|
|
|
24179
24160
|
get containsEsc() {
|
|
24180
|
-
return (this.flags &
|
|
24161
|
+
return (this.flags & 1024) > 0;
|
|
24181
24162
|
}
|
|
24182
24163
|
|
|
24183
24164
|
set containsEsc(v) {
|
|
24184
24165
|
if (v)
|
|
24185
|
-
this.flags |=
|
|
24166
|
+
this.flags |= 1024;
|
|
24186
24167
|
else
|
|
24187
|
-
this.flags &= -
|
|
24168
|
+
this.flags &= -1025;
|
|
24188
24169
|
}
|
|
24189
24170
|
|
|
24190
24171
|
firstInvalidTemplateEscapePos = null;
|
|
24191
24172
|
get hasTopLevelAwait() {
|
|
24192
|
-
return (this.flags &
|
|
24173
|
+
return (this.flags & 2048) > 0;
|
|
24193
24174
|
}
|
|
24194
24175
|
|
|
24195
24176
|
set hasTopLevelAwait(v) {
|
|
24196
24177
|
if (v)
|
|
24197
|
-
this.flags |=
|
|
24178
|
+
this.flags |= 2048;
|
|
24198
24179
|
else
|
|
24199
|
-
this.flags &= -
|
|
24180
|
+
this.flags &= -2049;
|
|
24200
24181
|
}
|
|
24201
24182
|
|
|
24202
24183
|
strictErrors = /* @__PURE__ */new Map();
|
|
@@ -26656,15 +26637,6 @@ var LValParser = class extends NodeUtils {
|
|
|
26656
26637
|
return exprList;
|
|
26657
26638
|
}
|
|
26658
26639
|
|
|
26659
|
-
toReferencedListDeep(exprList, isParenthesizedExpr) {
|
|
26660
|
-
this.toReferencedList(exprList, isParenthesizedExpr);
|
|
26661
|
-
for (const expr of exprList) {
|
|
26662
|
-
if (expr?.type === 'ArrayExpression') {
|
|
26663
|
-
this.toReferencedListDeep(expr.elements);
|
|
26664
|
-
}
|
|
26665
|
-
}
|
|
26666
|
-
}
|
|
26667
|
-
|
|
26668
26640
|
parseSpread(refExpressionErrors) {
|
|
26669
26641
|
const node = this.startNode();
|
|
26670
26642
|
this.next();
|
|
@@ -28227,7 +28199,7 @@ var typescript$1 = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
28227
28199
|
|
|
28228
28200
|
do {
|
|
28229
28201
|
types2.push(parseConstituentType());
|
|
28230
|
-
} while (this.eat(operator))
|
|
28202
|
+
} while (this.eat(operator));
|
|
28231
28203
|
if (types2.length === 1 && !hasLeadingOperator) {
|
|
28232
28204
|
return types2[0];
|
|
28233
28205
|
}
|
|
@@ -28905,9 +28877,6 @@ var typescript$1 = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
28905
28877
|
if (!this.match(43))
|
|
28906
28878
|
return;
|
|
28907
28879
|
|
|
28908
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
28909
|
-
|
|
28910
|
-
this.state.maybeInArrowParameters = true;
|
|
28911
28880
|
const res = this.tsTryParseAndCatch(() => {
|
|
28912
28881
|
const node = this.startNodeAt(startLoc);
|
|
28913
28882
|
|
|
@@ -28918,8 +28887,6 @@ var typescript$1 = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
28918
28887
|
return node;
|
|
28919
28888
|
});
|
|
28920
28889
|
|
|
28921
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
28922
|
-
|
|
28923
28890
|
if (!res)
|
|
28924
28891
|
return;
|
|
28925
28892
|
|
|
@@ -29604,7 +29571,7 @@ var typescript$1 = (superClass) => class TypeScriptParserMixin extends superClas
|
|
|
29604
29571
|
if (!this.match(13))
|
|
29605
29572
|
return expr;
|
|
29606
29573
|
|
|
29607
|
-
if (
|
|
29574
|
+
if (refExpressionErrors != null) {
|
|
29608
29575
|
const nextCh = this.lookaheadCharCode();
|
|
29609
29576
|
|
|
29610
29577
|
if (nextCh === 44 || nextCh === 61 || nextCh === 58 || nextCh === 41) {
|
|
@@ -31504,7 +31471,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
31504
31471
|
do {
|
|
31505
31472
|
base = this.parseSubscript(base, startLoc, noCalls, state);
|
|
31506
31473
|
state.maybeAsyncArrow = false;
|
|
31507
|
-
} while (!state.stop)
|
|
31474
|
+
} while (!state.stop);
|
|
31508
31475
|
|
|
31509
31476
|
return base;
|
|
31510
31477
|
}
|
|
@@ -31591,10 +31558,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
31591
31558
|
}
|
|
31592
31559
|
|
|
31593
31560
|
parseCoverCallAndAsyncArrowHead(base, startLoc, state, optional) {
|
|
31594
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
31595
31561
|
let refExpressionErrors = null;
|
|
31596
|
-
|
|
31597
|
-
this.state.maybeInArrowParameters = true;
|
|
31598
31562
|
this.next();
|
|
31599
31563
|
const node = this.startNodeAt(startLoc);
|
|
31600
31564
|
|
|
@@ -31633,17 +31597,12 @@ var ExpressionParser = class extends LValParser {
|
|
|
31633
31597
|
this.expressionScope.exit();
|
|
31634
31598
|
}
|
|
31635
31599
|
|
|
31636
|
-
this.
|
|
31600
|
+
this.toReferencedList(node.arguments);
|
|
31637
31601
|
}
|
|
31638
31602
|
|
|
31639
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
31640
31603
|
return finishedNode;
|
|
31641
31604
|
}
|
|
31642
31605
|
|
|
31643
|
-
toReferencedArguments(node, isParenthesizedExpr) {
|
|
31644
|
-
this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
|
|
31645
|
-
}
|
|
31646
|
-
|
|
31647
31606
|
parseTaggedTemplateExpression(base, startLoc, state) {
|
|
31648
31607
|
const node = this.startNodeAt(startLoc);
|
|
31649
31608
|
|
|
@@ -32162,10 +32121,8 @@ var ExpressionParser = class extends LValParser {
|
|
|
32162
32121
|
let val;
|
|
32163
32122
|
this.next();
|
|
32164
32123
|
this.expressionScope.enter(newArrowHeadScope());
|
|
32165
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
32166
32124
|
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
|
|
32167
32125
|
|
|
32168
|
-
this.state.maybeInArrowParameters = true;
|
|
32169
32126
|
this.state.inFSharpPipelineDirectBody = false;
|
|
32170
32127
|
const innerStartLoc = this.state.startLoc;
|
|
32171
32128
|
const exprList = [];
|
|
@@ -32209,7 +32166,6 @@ var ExpressionParser = class extends LValParser {
|
|
|
32209
32166
|
|
|
32210
32167
|
const innerEndLoc = this.state.lastTokEndLoc;
|
|
32211
32168
|
this.expect(7);
|
|
32212
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
32213
32169
|
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
|
|
32214
32170
|
let arrowNode = this.startNodeAt(startLoc);
|
|
32215
32171
|
|
|
@@ -32234,7 +32190,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
32234
32190
|
this.unexpected(spreadStartLoc);
|
|
32235
32191
|
|
|
32236
32192
|
this.checkExpressionErrors(refExpressionErrors, true);
|
|
32237
|
-
this.
|
|
32193
|
+
this.toReferencedList(exprList, true);
|
|
32238
32194
|
|
|
32239
32195
|
if (exprList.length > 1) {
|
|
32240
32196
|
val = this.startNodeAt(innerStartLoc);
|
|
@@ -32680,18 +32636,14 @@ var ExpressionParser = class extends LValParser {
|
|
|
32680
32636
|
|
|
32681
32637
|
this.prodParam.enter(flags);
|
|
32682
32638
|
this.initFunction(node, isAsync);
|
|
32683
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
32684
32639
|
|
|
32685
32640
|
if (params) {
|
|
32686
|
-
this.state.maybeInArrowParameters = true;
|
|
32687
32641
|
this.setArrowFunctionParameters(node, params, trailingCommaLoc);
|
|
32688
32642
|
}
|
|
32689
32643
|
|
|
32690
|
-
this.state.maybeInArrowParameters = false;
|
|
32691
32644
|
this.parseFunctionBody(node, true);
|
|
32692
32645
|
this.prodParam.exit();
|
|
32693
32646
|
this.scope.exit();
|
|
32694
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
32695
32647
|
return this.finishNode(node, 'ArrowFunctionExpression');
|
|
32696
32648
|
}
|
|
32697
32649
|
|
|
@@ -33012,7 +32964,7 @@ var ExpressionParser = class extends LValParser {
|
|
|
33012
32964
|
if (!this.match(7)) {
|
|
33013
32965
|
do {
|
|
33014
32966
|
this.parseMaybeAssignAllowIn();
|
|
33015
|
-
} while (this.eat(8) && !this.match(7))
|
|
32967
|
+
} while (this.eat(8) && !this.match(7));
|
|
33016
32968
|
this.raise(Errors.ImportCallArity, node);
|
|
33017
32969
|
}
|
|
33018
32970
|
}
|
|
@@ -33594,7 +33546,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
33594
33546
|
|
|
33595
33547
|
do {
|
|
33596
33548
|
decorators.push(this.parseDecorator());
|
|
33597
|
-
} while (this.match(22))
|
|
33549
|
+
} while (this.match(22));
|
|
33598
33550
|
if (this.match(78)) {
|
|
33599
33551
|
if (!allowExport) {
|
|
33600
33552
|
this.unexpected();
|
|
@@ -34224,9 +34176,6 @@ var StatementParser = class extends ExpressionParser {
|
|
|
34224
34176
|
node.id = this.parseFunctionId(requireId);
|
|
34225
34177
|
}
|
|
34226
34178
|
|
|
34227
|
-
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
|
|
34228
|
-
|
|
34229
|
-
this.state.maybeInArrowParameters = false;
|
|
34230
34179
|
this.scope.enter(514);
|
|
34231
34180
|
this.prodParam.enter(functionFlags(isAsync, node.generator));
|
|
34232
34181
|
|
|
@@ -34243,7 +34192,6 @@ var StatementParser = class extends ExpressionParser {
|
|
|
34243
34192
|
this.registerFunctionStatementId(node);
|
|
34244
34193
|
}
|
|
34245
34194
|
|
|
34246
|
-
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
|
|
34247
34195
|
return node;
|
|
34248
34196
|
}
|
|
34249
34197
|
|
|
@@ -35232,7 +35180,7 @@ var StatementParser = class extends ExpressionParser {
|
|
|
35232
35180
|
|
|
35233
35181
|
node.value = this.parseStringLiteral(this.state.value);
|
|
35234
35182
|
attrs.push(this.finishNode(node, 'ImportAttribute'));
|
|
35235
|
-
} while (this.eat(8))
|
|
35183
|
+
} while (this.eat(8));
|
|
35236
35184
|
this.expect(4);
|
|
35237
35185
|
return attrs;
|
|
35238
35186
|
}
|
|
@@ -35424,7 +35372,7 @@ var Parser = class extends StatementParser {
|
|
|
35424
35372
|
}
|
|
35425
35373
|
};
|
|
35426
35374
|
|
|
35427
|
-
function parse$
|
|
35375
|
+
function parse$b(input, options) {
|
|
35428
35376
|
if (options?.sourceType === 'unambiguous') {
|
|
35429
35377
|
options = {
|
|
35430
35378
|
...options,
|
|
@@ -36664,7 +36612,7 @@ function parseWithCodeFrame(code2, parserOpts, syntacticPlaceholders) {
|
|
|
36664
36612
|
plugins,
|
|
36665
36613
|
};
|
|
36666
36614
|
try {
|
|
36667
|
-
return parse$
|
|
36615
|
+
return parse$b(code2, parserOpts);
|
|
36668
36616
|
} catch(err) {
|
|
36669
36617
|
const loc = err.loc;
|
|
36670
36618
|
|
|
@@ -36885,7 +36833,7 @@ function buildLiteralData(formatter, tpl, opts) {
|
|
|
36885
36833
|
|
|
36886
36834
|
do {
|
|
36887
36835
|
prefix2 = '$$' + prefix2;
|
|
36888
|
-
} while (raw.includes(prefix2))
|
|
36836
|
+
} while (raw.includes(prefix2));
|
|
36889
36837
|
const {names: names2, code: code2} = buildTemplateCode(tpl, prefix2);
|
|
36890
36838
|
|
|
36891
36839
|
const metadata = parseAndBuildMetadata(formatter, formatter.code(code2), {
|
|
@@ -37037,7 +36985,7 @@ function decodeInteger(reader, relative) {
|
|
|
37037
36985
|
integer = charToInt[c];
|
|
37038
36986
|
value |= (integer & 31) << shift;
|
|
37039
36987
|
shift += 5;
|
|
37040
|
-
} while (integer & 32)
|
|
36988
|
+
} while (integer & 32);
|
|
37041
36989
|
const shouldNegate = value & 1;
|
|
37042
36990
|
|
|
37043
36991
|
value >>>= 1;
|
|
@@ -37062,7 +37010,7 @@ function encodeInteger(builder, num, relative) {
|
|
|
37062
37010
|
clamped |= 32;
|
|
37063
37011
|
|
|
37064
37012
|
builder.write(intToChar[clamped]);
|
|
37065
|
-
} while (delta > 0)
|
|
37013
|
+
} while (delta > 0);
|
|
37066
37014
|
|
|
37067
37015
|
return num;
|
|
37068
37016
|
}
|
|
@@ -37205,7 +37153,7 @@ function decode(mappings) {
|
|
|
37205
37153
|
|
|
37206
37154
|
decoded.push(line);
|
|
37207
37155
|
reader.pos = semi + 1;
|
|
37208
|
-
} while (reader.pos <= length)
|
|
37156
|
+
} while (reader.pos <= length);
|
|
37209
37157
|
|
|
37210
37158
|
return decoded;
|
|
37211
37159
|
}
|
|
@@ -38923,6 +38871,14 @@ function ConditionalExpression2(node) {
|
|
|
38923
38871
|
this.print(node.alternate);
|
|
38924
38872
|
}
|
|
38925
38873
|
|
|
38874
|
+
function _printExpressionArguments(node) {
|
|
38875
|
+
this.tokenChar(40);
|
|
38876
|
+
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
|
38877
|
+
this.printList(node.arguments, this.shouldPrintTrailingComma(')'), void 0, void 0, void 0, true);
|
|
38878
|
+
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
|
38879
|
+
this.rightParens(node);
|
|
38880
|
+
}
|
|
38881
|
+
|
|
38926
38882
|
function NewExpression2(node, parent) {
|
|
38927
38883
|
this.word('new');
|
|
38928
38884
|
this.space();
|
|
@@ -38938,11 +38894,7 @@ function NewExpression2(node, parent) {
|
|
|
38938
38894
|
return;
|
|
38939
38895
|
}
|
|
38940
38896
|
|
|
38941
|
-
|
|
38942
|
-
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
|
38943
|
-
this.printList(node.arguments, this.shouldPrintTrailingComma(')'), void 0, void 0, void 0, true);
|
|
38944
|
-
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
|
38945
|
-
this.rightParens(node);
|
|
38897
|
+
_printExpressionArguments.call(this, node);
|
|
38946
38898
|
}
|
|
38947
38899
|
|
|
38948
38900
|
function SequenceExpression2(node) {
|
|
@@ -39009,21 +38961,13 @@ function OptionalCallExpression2(node) {
|
|
|
39009
38961
|
}
|
|
39010
38962
|
|
|
39011
38963
|
this.print(node.typeArguments);
|
|
39012
|
-
|
|
39013
|
-
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
|
39014
|
-
this.printList(node.arguments, void 0, void 0, void 0, void 0, true);
|
|
39015
|
-
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
|
39016
|
-
this.rightParens(node);
|
|
38964
|
+
_printExpressionArguments.call(this, node);
|
|
39017
38965
|
}
|
|
39018
38966
|
|
|
39019
38967
|
function CallExpression2(node) {
|
|
39020
38968
|
this.print(node.callee);
|
|
39021
38969
|
this.print(node.typeArguments);
|
|
39022
|
-
|
|
39023
|
-
const oldNoLineTerminatorAfterNode = this.enterDelimited();
|
|
39024
|
-
this.printList(node.arguments, this.shouldPrintTrailingComma(')'), void 0, void 0, void 0, true);
|
|
39025
|
-
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
|
39026
|
-
this.rightParens(node);
|
|
38970
|
+
_printExpressionArguments.call(this, node);
|
|
39027
38971
|
}
|
|
39028
38972
|
|
|
39029
38973
|
function Import2() {
|
|
@@ -45485,7 +45429,7 @@ var Scope2 = class _Scope {
|
|
|
45485
45429
|
|
|
45486
45430
|
if (path?.isScope())
|
|
45487
45431
|
parent = path;
|
|
45488
|
-
} while (path && !parent)
|
|
45432
|
+
} while (path && !parent);
|
|
45489
45433
|
|
|
45490
45434
|
return parent?.scope;
|
|
45491
45435
|
}
|
|
@@ -45529,7 +45473,7 @@ var Scope2 = class _Scope {
|
|
|
45529
45473
|
uid2 += i + 1;
|
|
45530
45474
|
|
|
45531
45475
|
i++;
|
|
45532
|
-
} while (this.hasLabel(uid2) || this.hasBinding(uid2) || this.hasGlobal(uid2) || this.hasReference(uid2))
|
|
45476
|
+
} while (this.hasLabel(uid2) || this.hasBinding(uid2) || this.hasGlobal(uid2) || this.hasReference(uid2));
|
|
45533
45477
|
const program3 = this.getProgramParent();
|
|
45534
45478
|
program3.referencesSet.add(uid2);
|
|
45535
45479
|
program3.uidsSet.add(uid2);
|
|
@@ -45632,7 +45576,7 @@ var Scope2 = class _Scope {
|
|
|
45632
45576
|
kind: binding.kind,
|
|
45633
45577
|
});
|
|
45634
45578
|
}
|
|
45635
|
-
} while (scope2 = scope2.parent)
|
|
45579
|
+
} while (scope2 = scope2.parent);
|
|
45636
45580
|
console.log(sep);
|
|
45637
45581
|
}
|
|
45638
45582
|
|
|
@@ -45764,7 +45708,7 @@ var Scope2 = class _Scope {
|
|
|
45764
45708
|
do {
|
|
45765
45709
|
if (scope2.globals[name])
|
|
45766
45710
|
return true;
|
|
45767
|
-
} while (scope2 = scope2.parent)
|
|
45711
|
+
} while (scope2 = scope2.parent);
|
|
45768
45712
|
|
|
45769
45713
|
return false;
|
|
45770
45714
|
}
|
|
@@ -45904,7 +45848,7 @@ var Scope2 = class _Scope {
|
|
|
45904
45848
|
|
|
45905
45849
|
if (data != null)
|
|
45906
45850
|
return data;
|
|
45907
|
-
} while (scope2 = scope2.parent)
|
|
45851
|
+
} while (scope2 = scope2.parent);
|
|
45908
45852
|
}
|
|
45909
45853
|
|
|
45910
45854
|
removeData(key) {
|
|
@@ -45915,7 +45859,7 @@ var Scope2 = class _Scope {
|
|
|
45915
45859
|
|
|
45916
45860
|
if (data != null)
|
|
45917
45861
|
scope2.data[key] = null;
|
|
45918
|
-
} while (scope2 = scope2.parent)
|
|
45862
|
+
} while (scope2 = scope2.parent);
|
|
45919
45863
|
}
|
|
45920
45864
|
|
|
45921
45865
|
init() {
|
|
@@ -45938,7 +45882,7 @@ var Scope2 = class _Scope {
|
|
|
45938
45882
|
if (scope2.path.isProgram()) {
|
|
45939
45883
|
break;
|
|
45940
45884
|
}
|
|
45941
|
-
} while (scope2 = scope2.parent)
|
|
45885
|
+
} while (scope2 = scope2.parent);
|
|
45942
45886
|
const programParent = scope2;
|
|
45943
45887
|
|
|
45944
45888
|
const state = {
|
|
@@ -46054,7 +45998,7 @@ collectorVisitor]);
|
|
|
46054
45998
|
if (scope2.path.isProgram()) {
|
|
46055
45999
|
return scope2;
|
|
46056
46000
|
}
|
|
46057
|
-
} while (scope2 = scope2.parent)
|
|
46001
|
+
} while (scope2 = scope2.parent);
|
|
46058
46002
|
throw new Error('Couldn\'t find a Program');
|
|
46059
46003
|
}
|
|
46060
46004
|
|
|
@@ -46065,7 +46009,7 @@ collectorVisitor]);
|
|
|
46065
46009
|
if (scope2.path.isFunctionParent()) {
|
|
46066
46010
|
return scope2;
|
|
46067
46011
|
}
|
|
46068
|
-
} while (scope2 = scope2.parent)
|
|
46012
|
+
} while (scope2 = scope2.parent);
|
|
46069
46013
|
|
|
46070
46014
|
return null;
|
|
46071
46015
|
}
|
|
@@ -46077,7 +46021,7 @@ collectorVisitor]);
|
|
|
46077
46021
|
if (scope2.path.isBlockParent()) {
|
|
46078
46022
|
return scope2;
|
|
46079
46023
|
}
|
|
46080
|
-
} while (scope2 = scope2.parent)
|
|
46024
|
+
} while (scope2 = scope2.parent);
|
|
46081
46025
|
throw new Error('We couldn\'t find a BlockStatement, For, Switch, Function, Loop or Program...');
|
|
46082
46026
|
}
|
|
46083
46027
|
|
|
@@ -46088,7 +46032,7 @@ collectorVisitor]);
|
|
|
46088
46032
|
if (!scope2.path.isPattern()) {
|
|
46089
46033
|
return scope2.getBlockParent();
|
|
46090
46034
|
}
|
|
46091
|
-
} while (scope2 = scope2.parent.parent)
|
|
46035
|
+
} while (scope2 = scope2.parent.parent);
|
|
46092
46036
|
throw new Error('We couldn\'t find a BlockStatement, For, Switch, Function, Loop or Program...');
|
|
46093
46037
|
}
|
|
46094
46038
|
|
|
@@ -46104,7 +46048,7 @@ collectorVisitor]);
|
|
|
46104
46048
|
}
|
|
46105
46049
|
|
|
46106
46050
|
scope2 = scope2.parent;
|
|
46107
|
-
} while (scope2)
|
|
46051
|
+
} while (scope2);
|
|
46108
46052
|
|
|
46109
46053
|
return ids;
|
|
46110
46054
|
}
|
|
@@ -46130,7 +46074,7 @@ collectorVisitor]);
|
|
|
46130
46074
|
}
|
|
46131
46075
|
|
|
46132
46076
|
previousPath = scope2.path;
|
|
46133
|
-
} while (scope2 = scope2.parent)
|
|
46077
|
+
} while (scope2 = scope2.parent);
|
|
46134
46078
|
}
|
|
46135
46079
|
|
|
46136
46080
|
getOwnBinding(name) {
|
|
@@ -46176,7 +46120,7 @@ collectorVisitor]);
|
|
|
46176
46120
|
if (scope2.hasOwnBinding(name)) {
|
|
46177
46121
|
return true;
|
|
46178
46122
|
}
|
|
46179
|
-
} while (scope2 = scope2.parent)
|
|
46123
|
+
} while (scope2 = scope2.parent);
|
|
46180
46124
|
if (!noUids && this.hasUid(name))
|
|
46181
46125
|
return true;
|
|
46182
46126
|
|
|
@@ -46291,7 +46235,7 @@ function find(callback) {
|
|
|
46291
46235
|
do {
|
|
46292
46236
|
if (callback(path))
|
|
46293
46237
|
return path;
|
|
46294
|
-
} while (path = path.parentPath)
|
|
46238
|
+
} while (path = path.parentPath);
|
|
46295
46239
|
|
|
46296
46240
|
return null;
|
|
46297
46241
|
}
|
|
@@ -46309,7 +46253,7 @@ function getStatementParent() {
|
|
|
46309
46253
|
} else {
|
|
46310
46254
|
path = path.parentPath;
|
|
46311
46255
|
}
|
|
46312
|
-
} while (path)
|
|
46256
|
+
} while (path);
|
|
46313
46257
|
if (path && (path.isProgram() || path.isFile())) {
|
|
46314
46258
|
throw new Error('File/Program node, we can\'t possibly find a statement parent to this');
|
|
46315
46259
|
}
|
|
@@ -46366,7 +46310,7 @@ function getDeepestCommonAncestorFrom(paths, filter) {
|
|
|
46366
46310
|
|
|
46367
46311
|
do {
|
|
46368
46312
|
ancestry.unshift(path);
|
|
46369
|
-
} while ((path = path.parentPath) && path !== this)
|
|
46313
|
+
} while ((path = path.parentPath) && path !== this);
|
|
46370
46314
|
if (ancestry.length < minDepth) {
|
|
46371
46315
|
minDepth = ancestry.length;
|
|
46372
46316
|
}
|
|
@@ -46405,7 +46349,7 @@ function getAncestry() {
|
|
|
46405
46349
|
|
|
46406
46350
|
do {
|
|
46407
46351
|
paths.push(path);
|
|
46408
|
-
} while (path = path.parentPath)
|
|
46352
|
+
} while (path = path.parentPath);
|
|
46409
46353
|
|
|
46410
46354
|
return paths;
|
|
46411
46355
|
}
|
|
@@ -47474,7 +47418,7 @@ function replaceWithSourceString(replacement) {
|
|
|
47474
47418
|
|
|
47475
47419
|
try {
|
|
47476
47420
|
replacement = `(${replacement})`;
|
|
47477
|
-
ast = parse$
|
|
47421
|
+
ast = parse$b(replacement);
|
|
47478
47422
|
} catch(err) {
|
|
47479
47423
|
const loc = err.loc;
|
|
47480
47424
|
|
|
@@ -48765,7 +48709,7 @@ var getScopeInformationVisitor = environmentVisitor({
|
|
|
48765
48709
|
if (curr.path.isFunction() && !curr.path.isArrowFunctionExpression()) {
|
|
48766
48710
|
break;
|
|
48767
48711
|
}
|
|
48768
|
-
} while (curr = curr.parent)
|
|
48712
|
+
} while (curr = curr.parent);
|
|
48769
48713
|
argumentsPaths.push(child);
|
|
48770
48714
|
},
|
|
48771
48715
|
MetaProperty(child, {newTargetPaths}) {
|
|
@@ -49027,7 +48971,7 @@ function isCompletionRecord(allowInsideFunction) {
|
|
|
49027
48971
|
if (Array.isArray(container) && path.key !== container.length - 1) {
|
|
49028
48972
|
return false;
|
|
49029
48973
|
}
|
|
49030
|
-
} while ((path = path.parentPath) && !path.isProgram() && !path.isDoExpression())
|
|
48974
|
+
} while ((path = path.parentPath) && !path.isProgram() && !path.isDoExpression());
|
|
49031
48975
|
|
|
49032
48976
|
return true;
|
|
49033
48977
|
}
|
|
@@ -50080,7 +50024,7 @@ var NodePath_Final = class NodePath {
|
|
|
50080
50024
|
key = `${path.listKey}[${key}]`;
|
|
50081
50025
|
|
|
50082
50026
|
parts.unshift(key);
|
|
50083
|
-
} while (path = path.parentPath)
|
|
50027
|
+
} while (path = path.parentPath);
|
|
50084
50028
|
|
|
50085
50029
|
return parts.join('.');
|
|
50086
50030
|
}
|
|
@@ -50541,6 +50485,7 @@ const {
|
|
|
50541
50485
|
isArrayExpression: isArrayExpression$9,
|
|
50542
50486
|
isObjectExpression: isObjectExpression$c,
|
|
50543
50487
|
isLabeledStatement: isLabeledStatement$1,
|
|
50488
|
+
isTryStatement,
|
|
50544
50489
|
} = lib_exports;
|
|
50545
50490
|
|
|
50546
50491
|
const isParentProgram = (path) => path.parentPath?.isProgram();
|
|
@@ -50555,6 +50500,12 @@ const isNext = (path) => {
|
|
|
50555
50500
|
return !next.isEmptyStatement();
|
|
50556
50501
|
};
|
|
50557
50502
|
|
|
50503
|
+
const isNextTry = (path) => {
|
|
50504
|
+
return isTryStatement(path.getNextSibling());
|
|
50505
|
+
};
|
|
50506
|
+
|
|
50507
|
+
const isPrevTry = (path) => isTryStatement(path.getPrevSibling());
|
|
50508
|
+
|
|
50558
50509
|
const isPrev = (path) => {
|
|
50559
50510
|
const next = path.getPrevSibling();
|
|
50560
50511
|
return next.node;
|
|
@@ -50594,7 +50545,7 @@ function isCoupleLines(path) {
|
|
|
50594
50545
|
return end !== start;
|
|
50595
50546
|
}
|
|
50596
50547
|
|
|
50597
|
-
const exists = (a) => a.node;
|
|
50548
|
+
const exists$1 = (a) => a.node;
|
|
50598
50549
|
|
|
50599
50550
|
function isStringAndIdentifier([a, b]) {
|
|
50600
50551
|
return isStringLiteral$a(a) && isIdentifier$g(b);
|
|
@@ -51201,7 +51152,7 @@ const isIfUp = (path) => {
|
|
|
51201
51152
|
const {
|
|
51202
51153
|
isDecorator,
|
|
51203
51154
|
isMemberExpression: isMemberExpression$7,
|
|
51204
|
-
isExpressionStatement: isExpressionStatement$
|
|
51155
|
+
isExpressionStatement: isExpressionStatement$a,
|
|
51205
51156
|
isCallExpression: isCallExpression$8,
|
|
51206
51157
|
} = lib_exports;
|
|
51207
51158
|
|
|
@@ -51344,7 +51295,7 @@ const parseTrailingComments = (path, printer, semantics, {currentTraverse} = {})
|
|
|
51344
51295
|
function isPrevCall(path) {
|
|
51345
51296
|
const prev = path.getPrevSibling();
|
|
51346
51297
|
|
|
51347
|
-
if (isExpressionStatement$
|
|
51298
|
+
if (isExpressionStatement$a(prev))
|
|
51348
51299
|
return false;
|
|
51349
51300
|
|
|
51350
51301
|
const {expression} = path.node;
|
|
@@ -51488,7 +51439,7 @@ const ArrowFunctionExpression = maybeParens((path, printer, semantics) => {
|
|
|
51488
51439
|
|
|
51489
51440
|
const returnType = path.get('returnType');
|
|
51490
51441
|
|
|
51491
|
-
if (exists(returnType)) {
|
|
51442
|
+
if (exists$1(returnType)) {
|
|
51492
51443
|
write(':');
|
|
51493
51444
|
write.space();
|
|
51494
51445
|
traverse(returnType);
|
|
@@ -51514,7 +51465,7 @@ const {
|
|
|
51514
51465
|
isTSModuleBlock: isTSModuleBlock$3,
|
|
51515
51466
|
isBlockStatement: isBlockStatement$6,
|
|
51516
51467
|
isExportNamedDeclaration: isExportNamedDeclaration$2,
|
|
51517
|
-
isExpressionStatement: isExpressionStatement$
|
|
51468
|
+
isExpressionStatement: isExpressionStatement$9,
|
|
51518
51469
|
isFunctionDeclaration: isFunctionDeclaration$2,
|
|
51519
51470
|
isExportDefaultDeclaration,
|
|
51520
51471
|
} = lib_exports;
|
|
@@ -51572,7 +51523,7 @@ const isNextFunction = (path) => {
|
|
|
51572
51523
|
const isNextAssign$1 = (path) => {
|
|
51573
51524
|
const next = path.getNextSibling();
|
|
51574
51525
|
|
|
51575
|
-
if (!isExpressionStatement$
|
|
51526
|
+
if (!isExpressionStatement$9(next))
|
|
51576
51527
|
return false;
|
|
51577
51528
|
|
|
51578
51529
|
return isAssignmentExpression$3(next.node.expression);
|
|
@@ -51833,7 +51784,7 @@ const FunctionExpression = maybeParens((path, printer, semantics) => {
|
|
|
51833
51784
|
|
|
51834
51785
|
const id = path.get('id');
|
|
51835
51786
|
|
|
51836
|
-
if (exists(id)) {
|
|
51787
|
+
if (exists$1(id)) {
|
|
51837
51788
|
write(' ');
|
|
51838
51789
|
traverse(id);
|
|
51839
51790
|
}
|
|
@@ -52089,7 +52040,7 @@ const CallExpression = maybeParens((path, {indent, print, maybe, traverse}) => {
|
|
|
52089
52040
|
|
|
52090
52041
|
traverse(callee);
|
|
52091
52042
|
|
|
52092
|
-
if (exists(typeParameters))
|
|
52043
|
+
if (exists$1(typeParameters))
|
|
52093
52044
|
traverse(typeParameters);
|
|
52094
52045
|
|
|
52095
52046
|
if (path.node.optional)
|
|
@@ -52140,12 +52091,12 @@ function tooLong$1(args) {
|
|
|
52140
52091
|
}
|
|
52141
52092
|
|
|
52142
52093
|
const {
|
|
52143
|
-
isExpressionStatement: isExpressionStatement$
|
|
52094
|
+
isExpressionStatement: isExpressionStatement$8,
|
|
52144
52095
|
isMemberExpression: isMemberExpression$6,
|
|
52145
52096
|
} = lib_exports;
|
|
52146
52097
|
|
|
52147
|
-
const isInsideExpressionStatement = ({parentPath}) => isExpressionStatement$
|
|
52148
|
-
const notFirst = ({parentPath}) => exists(parentPath.getPrevSibling());
|
|
52098
|
+
const isInsideExpressionStatement = ({parentPath}) => isExpressionStatement$8(parentPath);
|
|
52099
|
+
const notFirst = ({parentPath}) => exists$1(parentPath.getPrevSibling());
|
|
52149
52100
|
const isInsideMember = ({parentPath}) => isMemberExpression$6(parentPath);
|
|
52150
52101
|
|
|
52151
52102
|
const getPrev = ({parentPath}) => {
|
|
@@ -52370,7 +52321,7 @@ const ObjectExpression = (path, printer, semantics) => {
|
|
|
52370
52321
|
const hasNextLeadingComment = (path) => {
|
|
52371
52322
|
const next = path.getNextSibling();
|
|
52372
52323
|
|
|
52373
|
-
if (!exists(next))
|
|
52324
|
+
if (!exists$1(next))
|
|
52374
52325
|
return false;
|
|
52375
52326
|
|
|
52376
52327
|
return hasLeadingComment(next);
|
|
@@ -52845,7 +52796,7 @@ const isCoupleProperties = ({path, valuePath, property}) => {
|
|
|
52845
52796
|
if (!isCoupleLines(valuePath))
|
|
52846
52797
|
return false;
|
|
52847
52798
|
|
|
52848
|
-
if (exists(property.getPrevSibling()))
|
|
52799
|
+
if (exists$1(property.getPrevSibling()))
|
|
52849
52800
|
return false;
|
|
52850
52801
|
|
|
52851
52802
|
const properties = path.get('properties');
|
|
@@ -53036,7 +52987,7 @@ const condition$4 = (path, printer, semantics) => {
|
|
|
53036
52987
|
|
|
53037
52988
|
const {
|
|
53038
52989
|
isAssignmentExpression: isAssignmentExpression$2,
|
|
53039
|
-
isExpressionStatement: isExpressionStatement$
|
|
52990
|
+
isExpressionStatement: isExpressionStatement$7,
|
|
53040
52991
|
} = lib_exports;
|
|
53041
52992
|
|
|
53042
52993
|
const printSeparator = (path, {print}) => {
|
|
@@ -53049,7 +53000,7 @@ const printSeparator = (path, {print}) => {
|
|
|
53049
53000
|
function isMultiline(path) {
|
|
53050
53001
|
const {right} = path.node;
|
|
53051
53002
|
|
|
53052
|
-
if (!path.parentPath.find(isExpressionStatement$
|
|
53003
|
+
if (!path.parentPath.find(isExpressionStatement$7))
|
|
53053
53004
|
return false;
|
|
53054
53005
|
|
|
53055
53006
|
return isAssignmentExpression$2(right);
|
|
@@ -54897,7 +54848,7 @@ const processClassProperty = maybeDecorators$1((path, printer, semantics, {acces
|
|
|
54897
54848
|
|
|
54898
54849
|
maybePrintTypeAnnotation(path, printer);
|
|
54899
54850
|
|
|
54900
|
-
if (exists(value)) {
|
|
54851
|
+
if (exists$1(value)) {
|
|
54901
54852
|
print.space();
|
|
54902
54853
|
print('=');
|
|
54903
54854
|
print.space();
|
|
@@ -55026,6 +54977,7 @@ const DoWhileStatement = {
|
|
|
55026
54977
|
print('(');
|
|
55027
54978
|
print('__test');
|
|
55028
54979
|
print(')');
|
|
54980
|
+
print(';');
|
|
55029
54981
|
},
|
|
55030
54982
|
afterSatisfy: () => [notLast],
|
|
55031
54983
|
after(path, {print}) {
|
|
@@ -55163,7 +55115,7 @@ const SwitchStatement = {
|
|
|
55163
55115
|
|
|
55164
55116
|
parseLeadingComments(switchCase, printer, semantics);
|
|
55165
55117
|
|
|
55166
|
-
if (exists(test)) {
|
|
55118
|
+
if (exists$1(test)) {
|
|
55167
55119
|
write('case');
|
|
55168
55120
|
maybeSpaceAfterKeyword$1(test, printer, semantics);
|
|
55169
55121
|
traverse(test);
|
|
@@ -55363,7 +55315,7 @@ const ExportNamedDeclaration = {
|
|
|
55363
55315
|
}
|
|
55364
55316
|
|
|
55365
55317
|
const n = specifiers.length;
|
|
55366
|
-
const isNewline = !exists(source) || n > maxOneLineSpecifiers;
|
|
55318
|
+
const isNewline = !exists$1(source) || n > maxOneLineSpecifiers;
|
|
55367
55319
|
|
|
55368
55320
|
if (specifiers && !path.node.declaration) {
|
|
55369
55321
|
print.space();
|
|
@@ -55413,7 +55365,7 @@ const ExportNamedDeclaration = {
|
|
|
55413
55365
|
|
|
55414
55366
|
const source = path.get('source');
|
|
55415
55367
|
|
|
55416
|
-
if (exists(source)) {
|
|
55368
|
+
if (exists$1(source)) {
|
|
55417
55369
|
print(' from ');
|
|
55418
55370
|
traverse(source);
|
|
55419
55371
|
printAttributes(path, printer);
|
|
@@ -55685,7 +55637,7 @@ const ForStatement = {
|
|
|
55685
55637
|
}
|
|
55686
55638
|
},
|
|
55687
55639
|
afterIf(path) {
|
|
55688
|
-
return exists(path.getNextSibling());
|
|
55640
|
+
return exists$1(path.getNextSibling());
|
|
55689
55641
|
},
|
|
55690
55642
|
after(path, {print}) {
|
|
55691
55643
|
print.linebreak();
|
|
@@ -55710,8 +55662,10 @@ const DebuggerStatement = {
|
|
|
55710
55662
|
},
|
|
55711
55663
|
};
|
|
55712
55664
|
|
|
55665
|
+
const {isExpressionStatement: isExpressionStatement$6} = lib_exports;
|
|
55666
|
+
|
|
55713
55667
|
const TryStatement = {
|
|
55714
|
-
print(path, {print}) {
|
|
55668
|
+
print(path, {print, maybe}) {
|
|
55715
55669
|
const finalizer = path.get('finalizer');
|
|
55716
55670
|
print.indent();
|
|
55717
55671
|
print('try');
|
|
@@ -55724,16 +55678,22 @@ const TryStatement = {
|
|
|
55724
55678
|
print('finally');
|
|
55725
55679
|
print.space();
|
|
55726
55680
|
print(finalizer);
|
|
55727
|
-
print.newline();
|
|
55681
|
+
maybe.print.newline(!isNext(path));
|
|
55728
55682
|
}
|
|
55729
55683
|
},
|
|
55730
55684
|
afterSatisfy: () => [isNext],
|
|
55731
|
-
after(path, {
|
|
55732
|
-
|
|
55733
|
-
|
|
55685
|
+
after(path, {print}) {
|
|
55686
|
+
print.newline();
|
|
55687
|
+
|
|
55688
|
+
if (isNextExpression(path) || isNextTry(path))
|
|
55689
|
+
print.breakline();
|
|
55734
55690
|
},
|
|
55735
55691
|
};
|
|
55736
55692
|
|
|
55693
|
+
const isNextExpression = (path) => {
|
|
55694
|
+
return isExpressionStatement$6(path.getNextSibling());
|
|
55695
|
+
};
|
|
55696
|
+
|
|
55737
55697
|
const CatchClause = (path, {print, maybe}) => {
|
|
55738
55698
|
const param = path.get('param');
|
|
55739
55699
|
const body = path.get('body');
|
|
@@ -55765,6 +55725,9 @@ const isInsideIfWithElse = ({parentPath}) => parentPath.isIfStatement() && paren
|
|
|
55765
55725
|
|
|
55766
55726
|
const ReturnStatement = {
|
|
55767
55727
|
beforeIf(path) {
|
|
55728
|
+
if (isPrevTry(path))
|
|
55729
|
+
return true;
|
|
55730
|
+
|
|
55768
55731
|
return !hasPrevNewline(path) && isBodyLength(path) || isPrevBody(path);
|
|
55769
55732
|
},
|
|
55770
55733
|
before(path, {print}) {
|
|
@@ -55829,7 +55792,7 @@ const insideIfWithNoBody = (path) => {
|
|
|
55829
55792
|
|
|
55830
55793
|
const next = path.parentPath?.parentPath.getNextSibling();
|
|
55831
55794
|
|
|
55832
|
-
return !exists(next);
|
|
55795
|
+
return !exists$1(next);
|
|
55833
55796
|
};
|
|
55834
55797
|
|
|
55835
55798
|
const {
|
|
@@ -56049,7 +56012,7 @@ function isNextIfAlternate(path) {
|
|
|
56049
56012
|
if (path === alternate)
|
|
56050
56013
|
return false;
|
|
56051
56014
|
|
|
56052
|
-
return exists(alternate);
|
|
56015
|
+
return exists$1(alternate);
|
|
56053
56016
|
}
|
|
56054
56017
|
|
|
56055
56018
|
function isTry({parentPath}) {
|
|
@@ -56210,7 +56173,7 @@ const IfStatement = {
|
|
|
56210
56173
|
|
|
56211
56174
|
write('else ');
|
|
56212
56175
|
traverse(alternate);
|
|
56213
|
-
} else if (exists(alternate)) {
|
|
56176
|
+
} else if (exists$1(alternate)) {
|
|
56214
56177
|
maybe.write.newline(isVar || isStatementNotExpression(consequent));
|
|
56215
56178
|
maybe.indent(!isConsequentBlock);
|
|
56216
56179
|
maybe.write.space(isConsequentBlock);
|
|
@@ -56289,7 +56252,7 @@ const VariableDeclaration = {
|
|
|
56289
56252
|
|
|
56290
56253
|
traverse(id);
|
|
56291
56254
|
|
|
56292
|
-
if (exists(init)) {
|
|
56255
|
+
if (exists$1(init)) {
|
|
56293
56256
|
write.space();
|
|
56294
56257
|
write('=');
|
|
56295
56258
|
maybe.write.space(!isConcatenation(init));
|
|
@@ -56381,7 +56344,7 @@ function notLastPrevVarNotNextVar(path) {
|
|
|
56381
56344
|
const prev = path.getPrevSibling();
|
|
56382
56345
|
const next = path.getNextSibling();
|
|
56383
56346
|
|
|
56384
|
-
if (!exists(prev.getPrevSibling()))
|
|
56347
|
+
if (!exists$1(prev.getPrevSibling()))
|
|
56385
56348
|
return false;
|
|
56386
56349
|
|
|
56387
56350
|
if (path.node.loc?.start.line === prev.node?.loc?.start.line + 2)
|
|
@@ -56394,7 +56357,7 @@ function isNextCoupleLines(path) {
|
|
|
56394
56357
|
const next = path.getNextSibling();
|
|
56395
56358
|
const prev = path.getPrevSibling();
|
|
56396
56359
|
|
|
56397
|
-
if (!exists(prev.getPrevSibling()) && next.isVariableDeclaration())
|
|
56360
|
+
if (!exists$1(prev.getPrevSibling()) && next.isVariableDeclaration())
|
|
56398
56361
|
return false;
|
|
56399
56362
|
|
|
56400
56363
|
if (path.node.loc?.start.line === prev.node?.loc?.start?.line + 2)
|
|
@@ -57048,14 +57011,14 @@ const TSTypeParameter = (path, {write, traverse}) => {
|
|
|
57048
57011
|
|
|
57049
57012
|
write(path.node.name.name);
|
|
57050
57013
|
|
|
57051
|
-
if (exists(constraint)) {
|
|
57014
|
+
if (exists$1(constraint)) {
|
|
57052
57015
|
write(' extends ');
|
|
57053
57016
|
traverse(constraint);
|
|
57054
57017
|
}
|
|
57055
57018
|
|
|
57056
57019
|
const defaultPath = path.get('default');
|
|
57057
57020
|
|
|
57058
|
-
if (exists(defaultPath)) {
|
|
57021
|
+
if (exists$1(defaultPath)) {
|
|
57059
57022
|
write.space();
|
|
57060
57023
|
write('=');
|
|
57061
57024
|
write.space();
|
|
@@ -58519,7 +58482,7 @@ function createStore$1() {
|
|
|
58519
58482
|
};
|
|
58520
58483
|
}
|
|
58521
58484
|
|
|
58522
|
-
const isObject$
|
|
58485
|
+
const isObject$7 = (a) => a && typeof a === 'object';
|
|
58523
58486
|
const isBool$3 = (a) => typeof a === 'boolean';
|
|
58524
58487
|
|
|
58525
58488
|
const ROUND_BRACES_DEFAULTS = {
|
|
@@ -58544,7 +58507,7 @@ const ROUND_BRACES_DISABLED = {
|
|
|
58544
58507
|
};
|
|
58545
58508
|
|
|
58546
58509
|
const parseRoundBraces = ({roundBraces}) => {
|
|
58547
|
-
if (isObject$
|
|
58510
|
+
if (isObject$7(roundBraces))
|
|
58548
58511
|
return {
|
|
58549
58512
|
...ROUND_BRACES_DEFAULTS,
|
|
58550
58513
|
...roundBraces,
|
|
@@ -58614,7 +58577,7 @@ const initSemantics = (format, semantics = {}) => ({
|
|
|
58614
58577
|
roundBraces: parseRoundBraces(semantics),
|
|
58615
58578
|
});
|
|
58616
58579
|
|
|
58617
|
-
const isObject$
|
|
58580
|
+
const isObject$6 = (a) => a && typeof a === 'object';
|
|
58618
58581
|
const {round} = Math;
|
|
58619
58582
|
const isString$b = (a) => typeof a === 'string';
|
|
58620
58583
|
const {assign: assign$9, freeze} = Object;
|
|
@@ -58852,7 +58815,7 @@ const createPrint = (path, {traverse, write}) => (maybeLine) => {
|
|
|
58852
58815
|
|
|
58853
58816
|
const computed = computePath(path, maybeLine);
|
|
58854
58817
|
|
|
58855
|
-
if (isObject$
|
|
58818
|
+
if (isObject$6(computed))
|
|
58856
58819
|
return traverse(computed);
|
|
58857
58820
|
|
|
58858
58821
|
return write(computed);
|
|
@@ -58862,7 +58825,7 @@ const computePath = (path, maybeLine) => {
|
|
|
58862
58825
|
if (isString$b(maybeLine) && maybeLine.startsWith(GET))
|
|
58863
58826
|
return get(path, maybeLine);
|
|
58864
58827
|
|
|
58865
|
-
if (isObject$
|
|
58828
|
+
if (isObject$6(maybeLine))
|
|
58866
58829
|
return maybeLine;
|
|
58867
58830
|
|
|
58868
58831
|
return maybeLine;
|
|
@@ -59788,7 +59751,7 @@ const initAcorn = once$4(() => {
|
|
|
59788
59751
|
return Parser.extend(typescript(), stage3);
|
|
59789
59752
|
});
|
|
59790
59753
|
|
|
59791
|
-
var parse$
|
|
59754
|
+
var parse$a = (source) => {
|
|
59792
59755
|
const parser = initAcorn();
|
|
59793
59756
|
const options = {
|
|
59794
59757
|
locations: true,
|
|
@@ -59846,7 +59809,7 @@ const {assign: assign$5} = Object;
|
|
|
59846
59809
|
const getFlow = (a) => !a.indexOf('// @flow');
|
|
59847
59810
|
const clean = (a) => a.filter(Boolean);
|
|
59848
59811
|
|
|
59849
|
-
const parse$
|
|
59812
|
+
const parse$9 = (source, overrides) => {
|
|
59850
59813
|
const {
|
|
59851
59814
|
sourceFileName,
|
|
59852
59815
|
isTS,
|
|
@@ -59877,7 +59840,7 @@ const parse$7 = (source, overrides) => {
|
|
|
59877
59840
|
tokens: true,
|
|
59878
59841
|
});
|
|
59879
59842
|
|
|
59880
|
-
const ast = parse$
|
|
59843
|
+
const ast = parse$b(source, parserOptions);
|
|
59881
59844
|
|
|
59882
59845
|
ast.program.extra.__putout_printer = printer;
|
|
59883
59846
|
return ast;
|
|
@@ -59898,7 +59861,7 @@ const once$3 = onceExports;
|
|
|
59898
59861
|
|
|
59899
59862
|
const initEspree = once$3(() => require$$1);
|
|
59900
59863
|
|
|
59901
|
-
var parse$
|
|
59864
|
+
var parse$8 = (source) => {
|
|
59902
59865
|
const {parse} = initEspree();
|
|
59903
59866
|
const preventUsingEsprima = true;
|
|
59904
59867
|
|
|
@@ -59918,7 +59881,7 @@ const once$2 = onceExports;
|
|
|
59918
59881
|
|
|
59919
59882
|
const initEsprima = once$2(() => require$$1);
|
|
59920
59883
|
|
|
59921
|
-
var parse$
|
|
59884
|
+
var parse$7 = (source) => {
|
|
59922
59885
|
const {parse} = initEsprima();
|
|
59923
59886
|
|
|
59924
59887
|
return parse(source, {
|
|
@@ -59934,7 +59897,7 @@ const once$1 = onceExports;
|
|
|
59934
59897
|
|
|
59935
59898
|
const initTenko = once$1(() => require$$1);
|
|
59936
59899
|
|
|
59937
|
-
var parse$
|
|
59900
|
+
var parse$6 = (source) => {
|
|
59938
59901
|
const {Tenko} = initTenko();
|
|
59939
59902
|
const {ast} = Tenko(source, {
|
|
59940
59903
|
goalMode: 'module',
|
|
@@ -59948,7 +59911,7 @@ var parse$4 = (source) => {
|
|
|
59948
59911
|
const once = onceExports;
|
|
59949
59912
|
const initHermes = once(() => require$$1);
|
|
59950
59913
|
|
|
59951
|
-
var parse$
|
|
59914
|
+
var parse$5 = (source) => {
|
|
59952
59915
|
const parser = initHermes();
|
|
59953
59916
|
const options = {
|
|
59954
59917
|
babel: true,
|
|
@@ -59998,7 +59961,7 @@ function checkError(error, messages) {
|
|
|
59998
59961
|
return false;
|
|
59999
59962
|
}
|
|
60000
59963
|
|
|
60001
|
-
const isObject$
|
|
59964
|
+
const isObject$5 = (a) => typeof a === 'object';
|
|
60002
59965
|
|
|
60003
59966
|
const MESSAGES = [
|
|
60004
59967
|
'has already been declared',
|
|
@@ -60031,33 +59994,33 @@ var customParser = (source, parser, {isTS, isJSX, printer}) => {
|
|
|
60031
59994
|
|
|
60032
59995
|
function customParse(source, {parser, printer, isTS, isJSX, isRecovery}) {
|
|
60033
59996
|
if (parser === 'babel')
|
|
60034
|
-
return parse$
|
|
59997
|
+
return parse$9(source, {
|
|
60035
59998
|
isTS,
|
|
60036
59999
|
isJSX,
|
|
60037
60000
|
isRecovery,
|
|
60038
60001
|
printer,
|
|
60039
60002
|
});
|
|
60040
60003
|
|
|
60041
|
-
if (isObject$
|
|
60004
|
+
if (isObject$5(parser))
|
|
60042
60005
|
return parser.parse(source, {
|
|
60043
60006
|
isJSX,
|
|
60044
60007
|
isTS,
|
|
60045
60008
|
});
|
|
60046
60009
|
|
|
60047
60010
|
if (parser === 'espree')
|
|
60048
|
-
return parse$
|
|
60011
|
+
return parse$8(source);
|
|
60049
60012
|
|
|
60050
60013
|
if (parser === 'acorn')
|
|
60051
|
-
return parse$
|
|
60014
|
+
return parse$a(source);
|
|
60052
60015
|
|
|
60053
60016
|
if (parser === 'esprima')
|
|
60054
|
-
return parse$
|
|
60017
|
+
return parse$7(source);
|
|
60055
60018
|
|
|
60056
60019
|
if (parser === 'tenko')
|
|
60057
|
-
return parse$
|
|
60020
|
+
return parse$6(source);
|
|
60058
60021
|
|
|
60059
60022
|
if (parser === 'hermes')
|
|
60060
|
-
return parse$
|
|
60023
|
+
return parse$5(source);
|
|
60061
60024
|
|
|
60062
60025
|
const require = _module.createRequire(import.meta.url);
|
|
60063
60026
|
|
|
@@ -60078,7 +60041,7 @@ const tryThrowWithReason$1 = (fn, ...args) => {
|
|
|
60078
60041
|
const {assign: assign$4} = Object;
|
|
60079
60042
|
const isString$8 = (a) => typeof a === 'string';
|
|
60080
60043
|
|
|
60081
|
-
const parse$
|
|
60044
|
+
const parse$4 = (source, options) => {
|
|
60082
60045
|
check$b(source);
|
|
60083
60046
|
|
|
60084
60047
|
const {
|
|
@@ -61712,7 +61675,7 @@ function createListStore(returns = id) {
|
|
|
61712
61675
|
const {merge: merge$2} = traverse3.visitors;
|
|
61713
61676
|
const {assign: assign$1} = Object;
|
|
61714
61677
|
|
|
61715
|
-
const parse$
|
|
61678
|
+
const parse$3 = (name, plugin, options) => {
|
|
61716
61679
|
const list = [];
|
|
61717
61680
|
|
|
61718
61681
|
if (plugin[name]) {
|
|
@@ -61764,8 +61727,8 @@ var mergeVisitors = (pluginsToMerge, {fix, shebang, template}) => {
|
|
|
61764
61727
|
throw Error(`☝️ Visitors cannot be empty in "${rule}"`);
|
|
61765
61728
|
|
|
61766
61729
|
assign$1(options, {
|
|
61767
|
-
include: parse$
|
|
61768
|
-
exclude: parse$
|
|
61730
|
+
include: parse$3('include', plugin, options),
|
|
61731
|
+
exclude: parse$3('exclude', plugin, options),
|
|
61769
61732
|
});
|
|
61770
61733
|
|
|
61771
61734
|
mergeItems.push(...template({
|
|
@@ -61842,7 +61805,7 @@ function superFind({rule, find, ast, options, template, traverse = traverse3}) {
|
|
|
61842
61805
|
};
|
|
61843
61806
|
|
|
61844
61807
|
const returnItems = find(ast, {
|
|
61845
|
-
traverse: createTraverse$
|
|
61808
|
+
traverse: createTraverse$4({
|
|
61846
61809
|
rule,
|
|
61847
61810
|
options,
|
|
61848
61811
|
template,
|
|
@@ -61860,7 +61823,7 @@ function superFind({rule, find, ast, options, template, traverse = traverse3}) {
|
|
|
61860
61823
|
];
|
|
61861
61824
|
}
|
|
61862
61825
|
|
|
61863
|
-
const createTraverse$
|
|
61826
|
+
const createTraverse$4 = ({rule, options, template, traverse}) => (ast, visitor) => {
|
|
61864
61827
|
const templateVisitors = merge$1(template({
|
|
61865
61828
|
rule,
|
|
61866
61829
|
visitor,
|
|
@@ -62195,7 +62158,7 @@ const isLinkedRegExp = (a, b) => {
|
|
|
62195
62158
|
|
|
62196
62159
|
const isPath$1 = (path) => Boolean(path.node);
|
|
62197
62160
|
|
|
62198
|
-
const isObject$
|
|
62161
|
+
const isObject$4 = (a) => {
|
|
62199
62162
|
if (!a)
|
|
62200
62163
|
return false;
|
|
62201
62164
|
|
|
@@ -62526,7 +62489,7 @@ const createDebug = (namespace) => {
|
|
|
62526
62489
|
const debug$3 = createDebug('putout:compare');
|
|
62527
62490
|
|
|
62528
62491
|
const {isArray: isArray$4} = Array;
|
|
62529
|
-
const isObject$
|
|
62492
|
+
const isObject$3 = (a) => a && typeof a === 'object';
|
|
62530
62493
|
|
|
62531
62494
|
var log$4 = (a, b) => {
|
|
62532
62495
|
if (!debug$3.enabled)
|
|
@@ -62549,7 +62512,7 @@ function parseValue(a) {
|
|
|
62549
62512
|
return `${type}: ["${name || value}"]`;
|
|
62550
62513
|
}
|
|
62551
62514
|
|
|
62552
|
-
if (isObject$
|
|
62515
|
+
if (isObject$3(a)) {
|
|
62553
62516
|
const {
|
|
62554
62517
|
type,
|
|
62555
62518
|
name,
|
|
@@ -62636,7 +62599,7 @@ const comparePlain = (node, template, {add}) => {
|
|
|
62636
62599
|
if (isIdentifier$1(node) && node.name === template.name)
|
|
62637
62600
|
return true;
|
|
62638
62601
|
|
|
62639
|
-
if (isObject$
|
|
62602
|
+
if (isObject$4(template) && !Array.isArray(template))
|
|
62640
62603
|
return add(node, template, {
|
|
62641
62604
|
plain: true,
|
|
62642
62605
|
});
|
|
@@ -62752,7 +62715,7 @@ function linkNodes(node, template, {add, templateStore}) {
|
|
|
62752
62715
|
}
|
|
62753
62716
|
|
|
62754
62717
|
function addObject(node, template, {add}) {
|
|
62755
|
-
const is = isObject$
|
|
62718
|
+
const is = isObject$4(template);
|
|
62756
62719
|
|
|
62757
62720
|
if (is)
|
|
62758
62721
|
add(node, template);
|
|
@@ -63782,7 +63745,7 @@ const {stringify: stringify$1} = JSON;
|
|
|
63782
63745
|
const stub = () => [];
|
|
63783
63746
|
const stubMatch = () => ({});
|
|
63784
63747
|
const packKeys = (a) => () => keys$1(a);
|
|
63785
|
-
const isObject$
|
|
63748
|
+
const isObject$2 = (a) => typeof a === 'object';
|
|
63786
63749
|
|
|
63787
63750
|
const replace = ({rule, plugin, msg, options}) => {
|
|
63788
63751
|
const maybeMatch = plugin.match || stubMatch;
|
|
@@ -63836,7 +63799,7 @@ const parseExpression = (nodeFrom, {node}) => {
|
|
|
63836
63799
|
return node;
|
|
63837
63800
|
};
|
|
63838
63801
|
|
|
63839
|
-
const fix$
|
|
63802
|
+
const fix$9 = (from, to, path) => {
|
|
63840
63803
|
const nodeFrom = template$1.ast(from);
|
|
63841
63804
|
const mark = watermark(from, to, path);
|
|
63842
63805
|
|
|
@@ -63891,7 +63854,7 @@ const getFix = (items, match) => (path) => {
|
|
|
63891
63854
|
const matchFn = match[from];
|
|
63892
63855
|
|
|
63893
63856
|
if (!matchFn || runMatch(path, nodeFrom, matchFn))
|
|
63894
|
-
fix$
|
|
63857
|
+
fix$9(from, to, path);
|
|
63895
63858
|
}
|
|
63896
63859
|
}
|
|
63897
63860
|
};
|
|
@@ -63931,7 +63894,7 @@ function parseTo(to, values, path) {
|
|
|
63931
63894
|
if (!toStr)
|
|
63932
63895
|
return null;
|
|
63933
63896
|
|
|
63934
|
-
if (isObject$
|
|
63897
|
+
if (isObject$2(toStr) && toStr.type) {
|
|
63935
63898
|
toStr.__putout_replace_cooked = true;
|
|
63936
63899
|
return toStr;
|
|
63937
63900
|
}
|
|
@@ -64036,7 +63999,7 @@ const TS_EXCLUDE = [
|
|
|
64036
63999
|
const declare$1 = (declarations) => ({
|
|
64037
64000
|
report: report$4,
|
|
64038
64001
|
include,
|
|
64039
|
-
fix: fix$
|
|
64002
|
+
fix: fix$8(declarations),
|
|
64040
64003
|
filter: filter(declarations),
|
|
64041
64004
|
});
|
|
64042
64005
|
|
|
@@ -64080,7 +64043,7 @@ const filter = (declarations) => (path, {options}) => {
|
|
|
64080
64043
|
return parseCode(type, allDeclarations[name]);
|
|
64081
64044
|
};
|
|
64082
64045
|
|
|
64083
|
-
const fix$
|
|
64046
|
+
const fix$8 = (declarations) => (path, {options}) => {
|
|
64084
64047
|
const type = getModuleType(path);
|
|
64085
64048
|
|
|
64086
64049
|
const allDeclarations = {
|
|
@@ -64263,7 +64226,7 @@ const {entries: entries$2} = Object;
|
|
|
64263
64226
|
|
|
64264
64227
|
const isPath = (path) => Boolean(path.node);
|
|
64265
64228
|
|
|
64266
|
-
const createTraverse$
|
|
64229
|
+
const createTraverse$3 = (path) => {
|
|
64267
64230
|
if (isPath(path))
|
|
64268
64231
|
return path.traverse.bind(path);
|
|
64269
64232
|
|
|
@@ -64280,7 +64243,7 @@ const createTraverse$1 = (path) => {
|
|
|
64280
64243
|
const getTemplate = ([a]) => a;
|
|
64281
64244
|
|
|
64282
64245
|
function traverse$3(basePath, visitor) {
|
|
64283
|
-
const traverse = createTraverse$
|
|
64246
|
+
const traverse = createTraverse$3(basePath);
|
|
64284
64247
|
const items = [];
|
|
64285
64248
|
const parsedVisitors = entries$2(visitor);
|
|
64286
64249
|
|
|
@@ -64354,12 +64317,12 @@ const getRootFromAst = (ast) => {
|
|
|
64354
64317
|
|
|
64355
64318
|
const {
|
|
64356
64319
|
arrayExpression: arrayExpression$2,
|
|
64357
|
-
stringLiteral: stringLiteral$
|
|
64320
|
+
stringLiteral: stringLiteral$5,
|
|
64358
64321
|
objectProperty: objectProperty$2,
|
|
64359
64322
|
} = lib_exports;
|
|
64360
64323
|
|
|
64361
64324
|
const createTypeProperty = (type) => {
|
|
64362
|
-
const value = stringLiteral$
|
|
64325
|
+
const value = stringLiteral$5(type);
|
|
64363
64326
|
return createProperty$1('type', value);
|
|
64364
64327
|
};
|
|
64365
64328
|
|
|
@@ -64369,17 +64332,17 @@ const createFilesProperty = (files) => {
|
|
|
64369
64332
|
};
|
|
64370
64333
|
|
|
64371
64334
|
const createFilenameProperty = (filename) => {
|
|
64372
|
-
const value = stringLiteral$
|
|
64335
|
+
const value = stringLiteral$5(filename);
|
|
64373
64336
|
return createProperty$1('filename', value);
|
|
64374
64337
|
};
|
|
64375
64338
|
|
|
64376
64339
|
const createContentProperty = (content) => {
|
|
64377
|
-
const value = stringLiteral$
|
|
64340
|
+
const value = stringLiteral$5(content);
|
|
64378
64341
|
return createProperty$1('content', value);
|
|
64379
64342
|
};
|
|
64380
64343
|
|
|
64381
64344
|
function createProperty$1(name, value) {
|
|
64382
|
-
const key = stringLiteral$
|
|
64345
|
+
const key = stringLiteral$5(name);
|
|
64383
64346
|
return objectProperty$2(key, value);
|
|
64384
64347
|
}
|
|
64385
64348
|
|
|
@@ -64861,7 +64824,7 @@ function getFile(directoryPath, name, {type} = {}) {
|
|
|
64861
64824
|
const {
|
|
64862
64825
|
objectExpression,
|
|
64863
64826
|
arrayExpression: arrayExpression$1,
|
|
64864
|
-
stringLiteral: stringLiteral$
|
|
64827
|
+
stringLiteral: stringLiteral$4,
|
|
64865
64828
|
isArrayExpression,
|
|
64866
64829
|
isStringLiteral,
|
|
64867
64830
|
isTemplateLiteral,
|
|
@@ -64872,22 +64835,22 @@ const isDirectory = (a) => a.endsWith('/');
|
|
|
64872
64835
|
const getType = (a) => {
|
|
64873
64836
|
const type = isDirectory(a) ? 'directory' : 'file';
|
|
64874
64837
|
|
|
64875
|
-
return objectProperty$1(stringLiteral$
|
|
64838
|
+
return objectProperty$1(stringLiteral$4('type'), stringLiteral$4(type));
|
|
64876
64839
|
};
|
|
64877
64840
|
|
|
64878
64841
|
const createFilename = (filename) => {
|
|
64879
|
-
return objectProperty$1(stringLiteral$
|
|
64842
|
+
return objectProperty$1(stringLiteral$4('filename'), stringLiteral$4(filename));
|
|
64880
64843
|
};
|
|
64881
64844
|
|
|
64882
64845
|
const getFiles = (a) => {
|
|
64883
64846
|
if (isDirectory(a))
|
|
64884
|
-
return objectProperty$1(stringLiteral$
|
|
64847
|
+
return objectProperty$1(stringLiteral$4('files'), arrayExpression$1([]));
|
|
64885
64848
|
|
|
64886
64849
|
return null;
|
|
64887
64850
|
};
|
|
64888
64851
|
|
|
64889
64852
|
const getContent = (a) => {
|
|
64890
|
-
return objectProperty$1(stringLiteral$
|
|
64853
|
+
return objectProperty$1(stringLiteral$4('content'), stringLiteral$4(a));
|
|
64891
64854
|
};
|
|
64892
64855
|
|
|
64893
64856
|
function parseContent(node, path) {
|
|
@@ -64900,7 +64863,7 @@ function parseContent(node, path) {
|
|
|
64900
64863
|
throw Error(`☝️ Looks like wrong content type: '${node.type}' from file: '${path}'`);
|
|
64901
64864
|
}
|
|
64902
64865
|
|
|
64903
|
-
const fix$
|
|
64866
|
+
const fix$7 = (path) => {
|
|
64904
64867
|
const array = arrayExpression$1([]);
|
|
64905
64868
|
|
|
64906
64869
|
for (const element of path.get('elements')) {
|
|
@@ -65014,19 +64977,19 @@ function check$3(filename) {
|
|
|
65014
64977
|
|
|
65015
64978
|
var fromSimple = /*#__PURE__*/Object.freeze({
|
|
65016
64979
|
__proto__: null,
|
|
65017
|
-
fix: fix$
|
|
64980
|
+
fix: fix$7,
|
|
65018
64981
|
traverse: traverse$2
|
|
65019
64982
|
});
|
|
65020
64983
|
|
|
65021
64984
|
const {
|
|
65022
|
-
stringLiteral: stringLiteral$
|
|
64985
|
+
stringLiteral: stringLiteral$3,
|
|
65023
64986
|
arrayExpression,
|
|
65024
64987
|
} = lib_exports;
|
|
65025
64988
|
|
|
65026
64989
|
const {isArray} = Array;
|
|
65027
64990
|
const maybeAddSlash = (a) => a === '/' ? a : `${a}/`;
|
|
65028
64991
|
|
|
65029
|
-
const fix$
|
|
64992
|
+
const fix$6 = (root, {files}) => {
|
|
65030
64993
|
const names = [];
|
|
65031
64994
|
|
|
65032
64995
|
for (const file of files) {
|
|
@@ -65053,13 +65016,13 @@ const fix$4 = (root, {files}) => {
|
|
|
65053
65016
|
for (const name of names) {
|
|
65054
65017
|
if (isArray(name)) {
|
|
65055
65018
|
list.push(arrayExpression([
|
|
65056
|
-
stringLiteral$
|
|
65057
|
-
stringLiteral$
|
|
65019
|
+
stringLiteral$3(name[0]),
|
|
65020
|
+
stringLiteral$3(name[1]),
|
|
65058
65021
|
]));
|
|
65059
65022
|
continue;
|
|
65060
65023
|
}
|
|
65061
65024
|
|
|
65062
|
-
list.push(stringLiteral$
|
|
65025
|
+
list.push(stringLiteral$3(name));
|
|
65063
65026
|
}
|
|
65064
65027
|
|
|
65065
65028
|
replaceWith(root, arrayExpression(list));
|
|
@@ -65078,13 +65041,13 @@ const traverse$1 = ({push}) => ({
|
|
|
65078
65041
|
|
|
65079
65042
|
var toSimple = /*#__PURE__*/Object.freeze({
|
|
65080
65043
|
__proto__: null,
|
|
65081
|
-
fix: fix$
|
|
65044
|
+
fix: fix$6,
|
|
65082
65045
|
traverse: traverse$1
|
|
65083
65046
|
});
|
|
65084
65047
|
|
|
65085
65048
|
const log = createDebug$1('putout:runner:scanner');
|
|
65086
65049
|
|
|
65087
|
-
const scan = ({rule, plugin, msg, options}, {progress}) => {
|
|
65050
|
+
const scan$2 = ({rule, plugin, msg, options}, {progress}) => {
|
|
65088
65051
|
const {
|
|
65089
65052
|
scan,
|
|
65090
65053
|
report,
|
|
@@ -65093,7 +65056,7 @@ const scan = ({rule, plugin, msg, options}, {progress}) => {
|
|
|
65093
65056
|
|
|
65094
65057
|
progress.inc();
|
|
65095
65058
|
|
|
65096
|
-
const traverse = createTraverse({
|
|
65059
|
+
const traverse = createTraverse$2({
|
|
65097
65060
|
scan,
|
|
65098
65061
|
rule,
|
|
65099
65062
|
progress,
|
|
@@ -65150,7 +65113,7 @@ const createTrackFile = ({fileProgress, crawled}) => function*(...a) {
|
|
|
65150
65113
|
}
|
|
65151
65114
|
};
|
|
65152
65115
|
|
|
65153
|
-
const createTraverse = ({scan, rule, progress}) => ({push, options}) => ({
|
|
65116
|
+
const createTraverse$2 = ({scan, rule, progress}) => ({push, options}) => ({
|
|
65154
65117
|
[`${__filesystem_name}(__)`](path) {
|
|
65155
65118
|
log(rule);
|
|
65156
65119
|
progress.start(rule);
|
|
@@ -65409,7 +65372,7 @@ function splitPlugins(plugins, {progress}) {
|
|
|
65409
65372
|
}
|
|
65410
65373
|
|
|
65411
65374
|
if (plugin.scan) {
|
|
65412
|
-
pluginsTraverse.push(scan(item, {
|
|
65375
|
+
pluginsTraverse.push(scan$2(item, {
|
|
65413
65376
|
progress,
|
|
65414
65377
|
}));
|
|
65415
65378
|
continue;
|
|
@@ -65572,7 +65535,7 @@ const putout = (source, opts) => {
|
|
|
65572
65535
|
|
|
65573
65536
|
const [clearSource, shebang] = cutShebang(source);
|
|
65574
65537
|
|
|
65575
|
-
const ast = parse$
|
|
65538
|
+
const ast = parse$4(clearSource, {
|
|
65576
65539
|
parser,
|
|
65577
65540
|
isTS,
|
|
65578
65541
|
isJSX,
|
|
@@ -65613,7 +65576,7 @@ const putoutAsync = async (source, opts) => {
|
|
|
65613
65576
|
|
|
65614
65577
|
const [clearSource, shebang] = cutShebang(source);
|
|
65615
65578
|
|
|
65616
|
-
const ast = parse$
|
|
65579
|
+
const ast = parse$4(clearSource, {
|
|
65617
65580
|
parser,
|
|
65618
65581
|
isTS,
|
|
65619
65582
|
isJSX,
|
|
@@ -65651,7 +65614,7 @@ const {
|
|
|
65651
65614
|
isJSXElement,
|
|
65652
65615
|
jsxAttribute,
|
|
65653
65616
|
jsxIdentifier,
|
|
65654
|
-
stringLiteral: stringLiteral$
|
|
65617
|
+
stringLiteral: stringLiteral$2,
|
|
65655
65618
|
} = lib_exports;
|
|
65656
65619
|
|
|
65657
65620
|
const getNode = (a) => a.node || a;
|
|
@@ -65717,7 +65680,7 @@ function addAttribute(path, name, value) {
|
|
|
65717
65680
|
let attributeNode = getAttributeNode(node, name);
|
|
65718
65681
|
|
|
65719
65682
|
if (!attributeNode) {
|
|
65720
|
-
attributeNode = jsxAttribute(jsxIdentifier(name), stringLiteral$
|
|
65683
|
+
attributeNode = jsxAttribute(jsxIdentifier(name), stringLiteral$2(value));
|
|
65721
65684
|
node.openingElement.attributes.push(attributeNode);
|
|
65722
65685
|
}
|
|
65723
65686
|
}
|
|
@@ -68601,7 +68564,7 @@ function increaseQuantifierByOne$2(quantifier) {
|
|
|
68601
68564
|
}
|
|
68602
68565
|
}
|
|
68603
68566
|
|
|
68604
|
-
var utils = {
|
|
68567
|
+
var utils$5 = {
|
|
68605
68568
|
disjunctionToList: disjunctionToList$1,
|
|
68606
68569
|
listToDisjunction: listToDisjunction$1,
|
|
68607
68570
|
increaseQuantifierByOne: increaseQuantifierByOne$2
|
|
@@ -68612,7 +68575,7 @@ var utils = {
|
|
|
68612
68575
|
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
|
68613
68576
|
*/
|
|
68614
68577
|
|
|
68615
|
-
var _require$5 = utils,
|
|
68578
|
+
var _require$5 = utils$5,
|
|
68616
68579
|
increaseQuantifierByOne$1 = _require$5.increaseQuantifierByOne;
|
|
68617
68580
|
|
|
68618
68581
|
/**
|
|
@@ -69610,7 +69573,7 @@ function isMetaWCharOrCode(expression) {
|
|
|
69610
69573
|
|
|
69611
69574
|
var NodePath$1 = nodePath;
|
|
69612
69575
|
|
|
69613
|
-
var _require$4 = utils,
|
|
69576
|
+
var _require$4 = utils$5,
|
|
69614
69577
|
disjunctionToList = _require$4.disjunctionToList,
|
|
69615
69578
|
listToDisjunction = _require$4.listToDisjunction;
|
|
69616
69579
|
|
|
@@ -69868,7 +69831,7 @@ function _toConsumableArray$3(arr) { if (Array.isArray(arr)) { for (var i = 0, a
|
|
|
69868
69831
|
|
|
69869
69832
|
var NodePath = nodePath;
|
|
69870
69833
|
|
|
69871
|
-
var _require$3 = utils,
|
|
69834
|
+
var _require$3 = utils$5,
|
|
69872
69835
|
increaseQuantifierByOne = _require$3.increaseQuantifierByOne;
|
|
69873
69836
|
|
|
69874
69837
|
/**
|
|
@@ -71685,11 +71648,11 @@ const report$3 = ({name}) => `Argument '${name}' is missing`;
|
|
|
71685
71648
|
|
|
71686
71649
|
const addArgs = (args) => ({
|
|
71687
71650
|
report: report$3,
|
|
71688
|
-
fix: fix$
|
|
71651
|
+
fix: fix$5,
|
|
71689
71652
|
traverse: traverse(args),
|
|
71690
71653
|
});
|
|
71691
71654
|
|
|
71692
|
-
const fix$
|
|
71655
|
+
const fix$5 = ({declaration, path, pattern, params, index}) => {
|
|
71693
71656
|
const declarationNode = template$1.ast.fresh(declaration);
|
|
71694
71657
|
|
|
71695
71658
|
if (isSequenceExpression(declarationNode)) {
|
|
@@ -71804,10 +71767,11 @@ function getObjectPattern(params) {
|
|
|
71804
71767
|
const moduleDeclarations = [
|
|
71805
71768
|
'import',
|
|
71806
71769
|
'export',
|
|
71807
|
-
'assert',
|
|
71808
71770
|
'with',
|
|
71809
71771
|
];
|
|
71810
71772
|
|
|
71773
|
+
const legacyKeywords = ['assert'];
|
|
71774
|
+
|
|
71811
71775
|
const declarations = [
|
|
71812
71776
|
'const',
|
|
71813
71777
|
'var',
|
|
@@ -71893,6 +71857,10 @@ const isTSKeyword = (name) => {
|
|
|
71893
71857
|
return ts || tsReserved;
|
|
71894
71858
|
};
|
|
71895
71859
|
|
|
71860
|
+
const isLegacyKeyword = (name) => {
|
|
71861
|
+
return legacyKeywords.includes(name);
|
|
71862
|
+
};
|
|
71863
|
+
|
|
71896
71864
|
const findPlaces = (ast, source, opts) => {
|
|
71897
71865
|
return transform(ast, source, {
|
|
71898
71866
|
...opts,
|
|
@@ -71935,7 +71903,7 @@ function mergeIgnores(ignores) {
|
|
|
71935
71903
|
|
|
71936
71904
|
const {join} = path;
|
|
71937
71905
|
|
|
71938
|
-
const isObject = (a) => a && typeof a === 'object';
|
|
71906
|
+
const isObject$1 = (a) => a && typeof a === 'object';
|
|
71939
71907
|
const {entries} = Object;
|
|
71940
71908
|
const report$2 = (path, {message}) => message;
|
|
71941
71909
|
|
|
@@ -71953,13 +71921,13 @@ const matchFiles = (options) => {
|
|
|
71953
71921
|
});
|
|
71954
71922
|
|
|
71955
71923
|
return {
|
|
71956
|
-
fix: fix$
|
|
71924
|
+
fix: fix$4,
|
|
71957
71925
|
scan,
|
|
71958
71926
|
report: report$2,
|
|
71959
71927
|
};
|
|
71960
71928
|
};
|
|
71961
71929
|
|
|
71962
|
-
function fix$
|
|
71930
|
+
function fix$4(inputFile, {dirPath, matchInputFilename, outputFilename, matchedJS, matchedAST, options, rawOptions}) {
|
|
71963
71931
|
transform(matchedAST, matchedJS, options);
|
|
71964
71932
|
|
|
71965
71933
|
const matchedJSON = magicPrint(outputFilename, matchedAST, rawOptions);
|
|
@@ -72054,20 +72022,20 @@ const createScan$2 = ({files, exclude, defaultFilename}) => (mainPath, {push, pr
|
|
|
72054
72022
|
function magicParse(name, content) {
|
|
72055
72023
|
if (name.endsWith('.json')) {
|
|
72056
72024
|
const js = toJS(content);
|
|
72057
|
-
const ast = parse$
|
|
72025
|
+
const ast = parse$4(js);
|
|
72058
72026
|
|
|
72059
72027
|
return [js, ast];
|
|
72060
72028
|
}
|
|
72061
72029
|
|
|
72062
72030
|
if (/\.[cm]?ts(x)?$/.test(name)) {
|
|
72063
|
-
const ast = parse$
|
|
72031
|
+
const ast = parse$4(content, {
|
|
72064
72032
|
isTS: true,
|
|
72065
72033
|
});
|
|
72066
72034
|
|
|
72067
72035
|
return [content, ast];
|
|
72068
72036
|
}
|
|
72069
72037
|
|
|
72070
|
-
return [content, parse$
|
|
72038
|
+
return [content, parse$4(content)];
|
|
72071
72039
|
}
|
|
72072
72040
|
|
|
72073
72041
|
function magicPrint(name, ast, options) {
|
|
@@ -72082,7 +72050,7 @@ function magicPrint(name, ast, options) {
|
|
|
72082
72050
|
|
|
72083
72051
|
function check(files) {
|
|
72084
72052
|
for (const [, plugin] of entries(files)) {
|
|
72085
|
-
if (!isObject(plugin))
|
|
72053
|
+
if (!isObject$1(plugin))
|
|
72086
72054
|
throw Error(`☝️ Looks like provided to 'matchFiles()' typeof of plugin is not an 'object' but '${typeof plugin}'`);
|
|
72087
72055
|
}
|
|
72088
72056
|
}
|
|
@@ -72129,11 +72097,11 @@ function parseOptions(inputFilename, rawOptions) {
|
|
|
72129
72097
|
};
|
|
72130
72098
|
}
|
|
72131
72099
|
|
|
72132
|
-
const {parse} = JSON;
|
|
72100
|
+
const {parse: parse$2} = JSON;
|
|
72133
72101
|
|
|
72134
72102
|
const report$1 = (file, {from, to}) => `Rename '${from}' to '${to}'`;
|
|
72135
72103
|
|
|
72136
|
-
const fix$
|
|
72104
|
+
const fix$3 = (file, {to}) => {
|
|
72137
72105
|
renameFile(file, to);
|
|
72138
72106
|
};
|
|
72139
72107
|
|
|
@@ -72166,7 +72134,7 @@ function checkType(type, file) {
|
|
|
72166
72134
|
if (!packageContent)
|
|
72167
72135
|
return false;
|
|
72168
72136
|
|
|
72169
|
-
const info = parse(packageContent);
|
|
72137
|
+
const info = parse$2(packageContent);
|
|
72170
72138
|
const infoType = info.type || 'commonjs';
|
|
72171
72139
|
|
|
72172
72140
|
return infoType === type;
|
|
@@ -72187,7 +72155,7 @@ function findUpPackage(file) {
|
|
|
72187
72155
|
var renameFileWithFn = /*#__PURE__*/Object.freeze({
|
|
72188
72156
|
__proto__: null,
|
|
72189
72157
|
createScan: createScan$1,
|
|
72190
|
-
fix: fix$
|
|
72158
|
+
fix: fix$3,
|
|
72191
72159
|
report: report$1
|
|
72192
72160
|
});
|
|
72193
72161
|
|
|
@@ -72200,7 +72168,7 @@ const report = (path, {mask, from, to}) => {
|
|
|
72200
72168
|
return `Rename '${mask}' to '${mask.replace(from, to)}'`;
|
|
72201
72169
|
};
|
|
72202
72170
|
|
|
72203
|
-
const fix = (path, {from, to}) => {
|
|
72171
|
+
const fix$2 = (path, {from, to}) => {
|
|
72204
72172
|
const filename = getFilename(path);
|
|
72205
72173
|
const newFilename = filename.replace(from, to);
|
|
72206
72174
|
|
|
@@ -72248,7 +72216,7 @@ const createCheckNear = (near) => (file) => {
|
|
|
72248
72216
|
var renameFileByMask = /*#__PURE__*/Object.freeze({
|
|
72249
72217
|
__proto__: null,
|
|
72250
72218
|
createScan: createScan,
|
|
72251
|
-
fix: fix,
|
|
72219
|
+
fix: fix$2,
|
|
72252
72220
|
report: report
|
|
72253
72221
|
});
|
|
72254
72222
|
|
|
@@ -72289,220 +72257,2444 @@ const renameFiles = ({type, mask, rename, from, to, near} = {}) => {
|
|
|
72289
72257
|
};
|
|
72290
72258
|
};
|
|
72291
72259
|
|
|
72292
|
-
|
|
72293
|
-
const getValue = ({value}) => value;
|
|
72260
|
+
var utils$4 = {};
|
|
72294
72261
|
|
|
72295
|
-
const
|
|
72296
|
-
|
|
72297
|
-
|
|
72298
|
-
|
|
72299
|
-
|
|
72300
|
-
|
|
72301
|
-
|
|
72302
|
-
|
|
72303
|
-
|
|
72304
|
-
|
|
72305
|
-
|
|
72306
|
-
|
|
72307
|
-
|
|
72308
|
-
|
|
72309
|
-
|
|
72310
|
-
|
|
72311
|
-
|
|
72312
|
-
|
|
72262
|
+
const WIN_SLASH = '\\\\/';
|
|
72263
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
72264
|
+
|
|
72265
|
+
/**
|
|
72266
|
+
* Posix glob regex
|
|
72267
|
+
*/
|
|
72268
|
+
|
|
72269
|
+
const DOT_LITERAL = '\\.';
|
|
72270
|
+
const PLUS_LITERAL = '\\+';
|
|
72271
|
+
const QMARK_LITERAL = '\\?';
|
|
72272
|
+
const SLASH_LITERAL = '\\/';
|
|
72273
|
+
const ONE_CHAR = '(?=.)';
|
|
72274
|
+
const QMARK = '[^/]';
|
|
72275
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
72276
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
72277
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
72278
|
+
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
72279
|
+
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
72280
|
+
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
72281
|
+
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
72282
|
+
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
72283
|
+
const STAR = `${QMARK}*?`;
|
|
72284
|
+
const SEP = '/';
|
|
72285
|
+
|
|
72286
|
+
const POSIX_CHARS = {
|
|
72287
|
+
DOT_LITERAL,
|
|
72288
|
+
PLUS_LITERAL,
|
|
72289
|
+
QMARK_LITERAL,
|
|
72290
|
+
SLASH_LITERAL,
|
|
72291
|
+
ONE_CHAR,
|
|
72292
|
+
QMARK,
|
|
72293
|
+
END_ANCHOR,
|
|
72294
|
+
DOTS_SLASH,
|
|
72295
|
+
NO_DOT,
|
|
72296
|
+
NO_DOTS,
|
|
72297
|
+
NO_DOT_SLASH,
|
|
72298
|
+
NO_DOTS_SLASH,
|
|
72299
|
+
QMARK_NO_DOT,
|
|
72300
|
+
STAR,
|
|
72301
|
+
START_ANCHOR,
|
|
72302
|
+
SEP
|
|
72313
72303
|
};
|
|
72314
72304
|
|
|
72315
|
-
|
|
72305
|
+
/**
|
|
72306
|
+
* Windows glob regex
|
|
72307
|
+
*/
|
|
72316
72308
|
|
|
72317
|
-
const
|
|
72318
|
-
|
|
72319
|
-
|
|
72320
|
-
|
|
72321
|
-
|
|
72322
|
-
|
|
72323
|
-
|
|
72324
|
-
|
|
72325
|
-
|
|
72326
|
-
|
|
72327
|
-
|
|
72328
|
-
|
|
72329
|
-
|
|
72330
|
-
|
|
72331
|
-
|
|
72332
|
-
|
|
72333
|
-
for (const name of newNames) {
|
|
72334
|
-
if (!list.includes(name))
|
|
72335
|
-
return true;
|
|
72336
|
-
}
|
|
72337
|
-
|
|
72338
|
-
return false;
|
|
72339
|
-
},
|
|
72340
|
-
};
|
|
72309
|
+
const WINDOWS_CHARS = {
|
|
72310
|
+
...POSIX_CHARS,
|
|
72311
|
+
|
|
72312
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
72313
|
+
QMARK: WIN_NO_SLASH,
|
|
72314
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
72315
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
72316
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
72317
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
72318
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
72319
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
72320
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
72321
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
72322
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
72323
|
+
SEP: '\\'
|
|
72341
72324
|
};
|
|
72342
72325
|
|
|
72343
|
-
|
|
72344
|
-
|
|
72345
|
-
|
|
72346
|
-
|
|
72326
|
+
/**
|
|
72327
|
+
* POSIX Bracket Regex
|
|
72328
|
+
*/
|
|
72329
|
+
|
|
72330
|
+
const POSIX_REGEX_SOURCE$1 = {
|
|
72331
|
+
alnum: 'a-zA-Z0-9',
|
|
72332
|
+
alpha: 'a-zA-Z',
|
|
72333
|
+
ascii: '\\x00-\\x7F',
|
|
72334
|
+
blank: ' \\t',
|
|
72335
|
+
cntrl: '\\x00-\\x1F\\x7F',
|
|
72336
|
+
digit: '0-9',
|
|
72337
|
+
graph: '\\x21-\\x7E',
|
|
72338
|
+
lower: 'a-z',
|
|
72339
|
+
print: '\\x20-\\x7E ',
|
|
72340
|
+
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
72341
|
+
space: ' \\t\\r\\n\\v\\f',
|
|
72342
|
+
upper: 'A-Z',
|
|
72343
|
+
word: 'A-Za-z0-9_',
|
|
72344
|
+
xdigit: 'A-Fa-f0-9'
|
|
72345
|
+
};
|
|
72346
|
+
|
|
72347
|
+
var constants$2 = {
|
|
72348
|
+
MAX_LENGTH: 1024 * 64,
|
|
72349
|
+
POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
|
|
72350
|
+
|
|
72351
|
+
// regular expressions
|
|
72352
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
72353
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
72354
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
72355
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
72356
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
72357
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
72358
|
+
|
|
72359
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
72360
|
+
REPLACEMENTS: {
|
|
72361
|
+
__proto__: null,
|
|
72362
|
+
'***': '*',
|
|
72363
|
+
'**/**': '**',
|
|
72364
|
+
'**/**/**': '**'
|
|
72365
|
+
},
|
|
72366
|
+
|
|
72367
|
+
// Digits
|
|
72368
|
+
CHAR_0: 48, /* 0 */
|
|
72369
|
+
CHAR_9: 57, /* 9 */
|
|
72370
|
+
|
|
72371
|
+
// Alphabet chars.
|
|
72372
|
+
CHAR_UPPERCASE_A: 65, /* A */
|
|
72373
|
+
CHAR_LOWERCASE_A: 97, /* a */
|
|
72374
|
+
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
72375
|
+
CHAR_LOWERCASE_Z: 122, /* z */
|
|
72376
|
+
|
|
72377
|
+
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
72378
|
+
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
72379
|
+
|
|
72380
|
+
CHAR_ASTERISK: 42, /* * */
|
|
72381
|
+
|
|
72382
|
+
// Non-alphabetic chars.
|
|
72383
|
+
CHAR_AMPERSAND: 38, /* & */
|
|
72384
|
+
CHAR_AT: 64, /* @ */
|
|
72385
|
+
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
72386
|
+
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
72387
|
+
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
72388
|
+
CHAR_COLON: 58, /* : */
|
|
72389
|
+
CHAR_COMMA: 44, /* , */
|
|
72390
|
+
CHAR_DOT: 46, /* . */
|
|
72391
|
+
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
72392
|
+
CHAR_EQUAL: 61, /* = */
|
|
72393
|
+
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
72394
|
+
CHAR_FORM_FEED: 12, /* \f */
|
|
72395
|
+
CHAR_FORWARD_SLASH: 47, /* / */
|
|
72396
|
+
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
72397
|
+
CHAR_HASH: 35, /* # */
|
|
72398
|
+
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
72399
|
+
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
72400
|
+
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
72401
|
+
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
72402
|
+
CHAR_LINE_FEED: 10, /* \n */
|
|
72403
|
+
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
72404
|
+
CHAR_PERCENT: 37, /* % */
|
|
72405
|
+
CHAR_PLUS: 43, /* + */
|
|
72406
|
+
CHAR_QUESTION_MARK: 63, /* ? */
|
|
72407
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
72408
|
+
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
72409
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
72410
|
+
CHAR_SEMICOLON: 59, /* ; */
|
|
72411
|
+
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
72412
|
+
CHAR_SPACE: 32, /* */
|
|
72413
|
+
CHAR_TAB: 9, /* \t */
|
|
72414
|
+
CHAR_UNDERSCORE: 95, /* _ */
|
|
72415
|
+
CHAR_VERTICAL_LINE: 124, /* | */
|
|
72416
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
72417
|
+
|
|
72418
|
+
/**
|
|
72419
|
+
* Create EXTGLOB_CHARS
|
|
72420
|
+
*/
|
|
72421
|
+
|
|
72422
|
+
extglobChars(chars) {
|
|
72347
72423
|
return {
|
|
72348
|
-
|
|
72349
|
-
|
|
72350
|
-
|
|
72351
|
-
|
|
72352
|
-
|
|
72353
|
-
|
|
72354
|
-
const list = elements.map(getValue);
|
|
72355
|
-
|
|
72356
|
-
for (const name of newNames) {
|
|
72357
|
-
if (!list.includes(name))
|
|
72358
|
-
elements.push(stringLiteral(name));
|
|
72359
|
-
}
|
|
72360
|
-
|
|
72361
|
-
return path;
|
|
72362
|
-
},
|
|
72424
|
+
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
72425
|
+
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
72426
|
+
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
72427
|
+
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
72428
|
+
'@': { type: 'at', open: '(?:', close: ')' }
|
|
72363
72429
|
};
|
|
72430
|
+
},
|
|
72431
|
+
|
|
72432
|
+
/**
|
|
72433
|
+
* Create GLOB_CHARS
|
|
72434
|
+
*/
|
|
72435
|
+
|
|
72436
|
+
globChars(win32) {
|
|
72437
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
72438
|
+
}
|
|
72364
72439
|
};
|
|
72365
72440
|
|
|
72366
|
-
|
|
72367
|
-
|
|
72368
|
-
|
|
72369
|
-
|
|
72370
|
-
|
|
72441
|
+
constants$2.default;
|
|
72442
|
+
|
|
72443
|
+
(function (exports$1) {
|
|
72444
|
+
|
|
72445
|
+
const {
|
|
72446
|
+
REGEX_BACKSLASH,
|
|
72447
|
+
REGEX_REMOVE_BACKSLASH,
|
|
72448
|
+
REGEX_SPECIAL_CHARS,
|
|
72449
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
72450
|
+
} = constants$2;
|
|
72451
|
+
|
|
72452
|
+
exports$1.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
72453
|
+
exports$1.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
72454
|
+
exports$1.isRegexChar = str => str.length === 1 && exports$1.hasRegexChars(str);
|
|
72455
|
+
exports$1.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
72456
|
+
exports$1.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
72457
|
+
|
|
72458
|
+
exports$1.isWindows = () => {
|
|
72459
|
+
if (typeof navigator !== 'undefined' && navigator.platform) {
|
|
72460
|
+
const platform = navigator.platform.toLowerCase();
|
|
72461
|
+
return platform === 'win32' || platform === 'windows';
|
|
72462
|
+
}
|
|
72463
|
+
|
|
72464
|
+
if (typeof browser$1 !== 'undefined' && "unix") {
|
|
72465
|
+
return "unix" === 'win32';
|
|
72466
|
+
}
|
|
72467
|
+
|
|
72468
|
+
return false;
|
|
72469
|
+
};
|
|
72470
|
+
|
|
72471
|
+
exports$1.removeBackslashes = str => {
|
|
72472
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
|
72473
|
+
return match === '\\' ? '' : match;
|
|
72474
|
+
});
|
|
72475
|
+
};
|
|
72476
|
+
|
|
72477
|
+
exports$1.escapeLast = (input, char, lastIdx) => {
|
|
72478
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
72479
|
+
if (idx === -1) return input;
|
|
72480
|
+
if (input[idx - 1] === '\\') return exports$1.escapeLast(input, char, idx - 1);
|
|
72481
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
72482
|
+
};
|
|
72483
|
+
|
|
72484
|
+
exports$1.removePrefix = (input, state = {}) => {
|
|
72485
|
+
let output = input;
|
|
72486
|
+
if (output.startsWith('./')) {
|
|
72487
|
+
output = output.slice(2);
|
|
72488
|
+
state.prefix = './';
|
|
72489
|
+
}
|
|
72490
|
+
return output;
|
|
72491
|
+
};
|
|
72492
|
+
|
|
72493
|
+
exports$1.wrapOutput = (input, state = {}, options = {}) => {
|
|
72494
|
+
const prepend = options.contains ? '' : '^';
|
|
72495
|
+
const append = options.contains ? '' : '$';
|
|
72496
|
+
|
|
72497
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
72498
|
+
if (state.negated === true) {
|
|
72499
|
+
output = `(?:^(?!${output}).*$)`;
|
|
72500
|
+
}
|
|
72501
|
+
return output;
|
|
72502
|
+
};
|
|
72503
|
+
|
|
72504
|
+
exports$1.basename = (path, { windows } = {}) => {
|
|
72505
|
+
const segs = path.split(windows ? /[\\/]/ : '/');
|
|
72506
|
+
const last = segs[segs.length - 1];
|
|
72507
|
+
|
|
72508
|
+
if (last === '') {
|
|
72509
|
+
return segs[segs.length - 2];
|
|
72510
|
+
}
|
|
72511
|
+
|
|
72512
|
+
return last;
|
|
72513
|
+
};
|
|
72514
|
+
} (utils$4));
|
|
72515
|
+
|
|
72516
|
+
utils$4.default;
|
|
72517
|
+
|
|
72518
|
+
const utils$3 = utils$4;
|
|
72519
|
+
const {
|
|
72520
|
+
CHAR_ASTERISK, /* * */
|
|
72521
|
+
CHAR_AT, /* @ */
|
|
72522
|
+
CHAR_BACKWARD_SLASH, /* \ */
|
|
72523
|
+
CHAR_COMMA, /* , */
|
|
72524
|
+
CHAR_DOT, /* . */
|
|
72525
|
+
CHAR_EXCLAMATION_MARK, /* ! */
|
|
72526
|
+
CHAR_FORWARD_SLASH, /* / */
|
|
72527
|
+
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
72528
|
+
CHAR_LEFT_PARENTHESES, /* ( */
|
|
72529
|
+
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
72530
|
+
CHAR_PLUS, /* + */
|
|
72531
|
+
CHAR_QUESTION_MARK, /* ? */
|
|
72532
|
+
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
72533
|
+
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
72534
|
+
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
72535
|
+
} = constants$2;
|
|
72536
|
+
|
|
72537
|
+
const isPathSeparator = code => {
|
|
72538
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
72539
|
+
};
|
|
72540
|
+
|
|
72541
|
+
const depth = token => {
|
|
72542
|
+
if (token.isPrefix !== true) {
|
|
72543
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
72544
|
+
}
|
|
72545
|
+
};
|
|
72546
|
+
|
|
72547
|
+
/**
|
|
72548
|
+
* Quickly scans a glob pattern and returns an object with a handful of
|
|
72549
|
+
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
72550
|
+
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
72551
|
+
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
72552
|
+
*
|
|
72553
|
+
* ```js
|
|
72554
|
+
* const pm = require('picomatch');
|
|
72555
|
+
* console.log(pm.scan('foo/bar/*.js'));
|
|
72556
|
+
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
72557
|
+
* ```
|
|
72558
|
+
* @param {String} `str`
|
|
72559
|
+
* @param {Object} `options`
|
|
72560
|
+
* @return {Object} Returns an object with tokens and regex source string.
|
|
72561
|
+
* @api public
|
|
72562
|
+
*/
|
|
72563
|
+
|
|
72564
|
+
const scan$1 = (input, options) => {
|
|
72565
|
+
const opts = options || {};
|
|
72566
|
+
|
|
72567
|
+
const length = input.length - 1;
|
|
72568
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
72569
|
+
const slashes = [];
|
|
72570
|
+
const tokens = [];
|
|
72571
|
+
const parts = [];
|
|
72572
|
+
|
|
72573
|
+
let str = input;
|
|
72574
|
+
let index = -1;
|
|
72575
|
+
let start = 0;
|
|
72576
|
+
let lastIndex = 0;
|
|
72577
|
+
let isBrace = false;
|
|
72578
|
+
let isBracket = false;
|
|
72579
|
+
let isGlob = false;
|
|
72580
|
+
let isExtglob = false;
|
|
72581
|
+
let isGlobstar = false;
|
|
72582
|
+
let braceEscaped = false;
|
|
72583
|
+
let backslashes = false;
|
|
72584
|
+
let negated = false;
|
|
72585
|
+
let negatedExtglob = false;
|
|
72586
|
+
let finished = false;
|
|
72587
|
+
let braces = 0;
|
|
72588
|
+
let prev;
|
|
72589
|
+
let code;
|
|
72590
|
+
let token = { value: '', depth: 0, isGlob: false };
|
|
72591
|
+
|
|
72592
|
+
const eos = () => index >= length;
|
|
72593
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
72594
|
+
const advance = () => {
|
|
72595
|
+
prev = code;
|
|
72596
|
+
return str.charCodeAt(++index);
|
|
72597
|
+
};
|
|
72598
|
+
|
|
72599
|
+
while (index < length) {
|
|
72600
|
+
code = advance();
|
|
72601
|
+
let next;
|
|
72602
|
+
|
|
72603
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
72604
|
+
backslashes = token.backslashes = true;
|
|
72605
|
+
code = advance();
|
|
72606
|
+
|
|
72607
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
72608
|
+
braceEscaped = true;
|
|
72609
|
+
}
|
|
72610
|
+
continue;
|
|
72611
|
+
}
|
|
72612
|
+
|
|
72613
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
72614
|
+
braces++;
|
|
72615
|
+
|
|
72616
|
+
while (eos() !== true && (code = advance())) {
|
|
72617
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
72618
|
+
backslashes = token.backslashes = true;
|
|
72619
|
+
advance();
|
|
72620
|
+
continue;
|
|
72621
|
+
}
|
|
72622
|
+
|
|
72623
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
72624
|
+
braces++;
|
|
72625
|
+
continue;
|
|
72626
|
+
}
|
|
72627
|
+
|
|
72628
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
72629
|
+
isBrace = token.isBrace = true;
|
|
72630
|
+
isGlob = token.isGlob = true;
|
|
72631
|
+
finished = true;
|
|
72632
|
+
|
|
72633
|
+
if (scanToEnd === true) {
|
|
72371
72634
|
continue;
|
|
72372
|
-
|
|
72373
|
-
|
|
72635
|
+
}
|
|
72636
|
+
|
|
72637
|
+
break;
|
|
72638
|
+
}
|
|
72639
|
+
|
|
72640
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
72641
|
+
isBrace = token.isBrace = true;
|
|
72642
|
+
isGlob = token.isGlob = true;
|
|
72643
|
+
finished = true;
|
|
72644
|
+
|
|
72645
|
+
if (scanToEnd === true) {
|
|
72646
|
+
continue;
|
|
72647
|
+
}
|
|
72648
|
+
|
|
72649
|
+
break;
|
|
72650
|
+
}
|
|
72651
|
+
|
|
72652
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
72653
|
+
braces--;
|
|
72654
|
+
|
|
72655
|
+
if (braces === 0) {
|
|
72656
|
+
braceEscaped = false;
|
|
72657
|
+
isBrace = token.isBrace = true;
|
|
72658
|
+
finished = true;
|
|
72659
|
+
break;
|
|
72660
|
+
}
|
|
72661
|
+
}
|
|
72662
|
+
}
|
|
72663
|
+
|
|
72664
|
+
if (scanToEnd === true) {
|
|
72665
|
+
continue;
|
|
72666
|
+
}
|
|
72667
|
+
|
|
72668
|
+
break;
|
|
72374
72669
|
}
|
|
72375
|
-
|
|
72376
|
-
return newNames;
|
|
72377
|
-
}
|
|
72378
72670
|
|
|
72379
|
-
|
|
72380
|
-
|
|
72381
|
-
|
|
72382
|
-
|
|
72383
|
-
return node.elements;
|
|
72384
|
-
|
|
72385
|
-
const [prop] = traverseProperties(node, property);
|
|
72386
|
-
|
|
72387
|
-
if (!prop)
|
|
72388
|
-
return null;
|
|
72389
|
-
|
|
72390
|
-
return prop.node.value.elements;
|
|
72391
|
-
}
|
|
72671
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
72672
|
+
slashes.push(index);
|
|
72673
|
+
tokens.push(token);
|
|
72674
|
+
token = { value: '', depth: 0, isGlob: false };
|
|
72392
72675
|
|
|
72393
|
-
|
|
72394
|
-
|
|
72395
|
-
|
|
72396
|
-
|
|
72676
|
+
if (finished === true) continue;
|
|
72677
|
+
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
72678
|
+
start += 2;
|
|
72679
|
+
continue;
|
|
72680
|
+
}
|
|
72397
72681
|
|
|
72398
|
-
|
|
72399
|
-
|
|
72400
|
-
|
|
72401
|
-
if (hasParens(path, printer))
|
|
72402
|
-
return path;
|
|
72403
|
-
|
|
72404
|
-
if (printer !== 'babel') {
|
|
72405
|
-
const {extra = {}} = path.node;
|
|
72406
|
-
|
|
72407
|
-
extra.parenthesized = true;
|
|
72408
|
-
path.node.extra = extra;
|
|
72409
|
-
|
|
72410
|
-
return path;
|
|
72682
|
+
lastIndex = index + 1;
|
|
72683
|
+
continue;
|
|
72411
72684
|
}
|
|
72412
|
-
|
|
72413
|
-
const {node} = path;
|
|
72414
|
-
|
|
72415
|
-
if (path.type.startsWith('TS'))
|
|
72416
|
-
return path.replaceWith(tsParenthesizedType(node));
|
|
72417
|
-
|
|
72418
|
-
path.replaceWith(parenthesizedExpression(node));
|
|
72419
|
-
|
|
72420
|
-
return path;
|
|
72421
|
-
};
|
|
72422
72685
|
|
|
72423
|
-
|
|
72424
|
-
|
|
72425
|
-
|
|
72426
|
-
|
|
72427
|
-
|
|
72428
|
-
|
|
72429
|
-
|
|
72430
|
-
|
|
72431
|
-
|
|
72686
|
+
if (opts.noext !== true) {
|
|
72687
|
+
const isExtglobChar = code === CHAR_PLUS
|
|
72688
|
+
|| code === CHAR_AT
|
|
72689
|
+
|| code === CHAR_ASTERISK
|
|
72690
|
+
|| code === CHAR_QUESTION_MARK
|
|
72691
|
+
|| code === CHAR_EXCLAMATION_MARK;
|
|
72692
|
+
|
|
72693
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
72694
|
+
isGlob = token.isGlob = true;
|
|
72695
|
+
isExtglob = token.isExtglob = true;
|
|
72696
|
+
finished = true;
|
|
72697
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
72698
|
+
negatedExtglob = true;
|
|
72699
|
+
}
|
|
72700
|
+
|
|
72701
|
+
if (scanToEnd === true) {
|
|
72702
|
+
while (eos() !== true && (code = advance())) {
|
|
72703
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
72704
|
+
backslashes = token.backslashes = true;
|
|
72705
|
+
code = advance();
|
|
72706
|
+
continue;
|
|
72707
|
+
}
|
|
72708
|
+
|
|
72709
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
72710
|
+
isGlob = token.isGlob = true;
|
|
72711
|
+
finished = true;
|
|
72712
|
+
break;
|
|
72713
|
+
}
|
|
72714
|
+
}
|
|
72715
|
+
continue;
|
|
72716
|
+
}
|
|
72717
|
+
break;
|
|
72718
|
+
}
|
|
72432
72719
|
}
|
|
72433
|
-
|
|
72434
|
-
|
|
72435
|
-
|
|
72436
|
-
|
|
72437
|
-
|
|
72720
|
+
|
|
72721
|
+
if (code === CHAR_ASTERISK) {
|
|
72722
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
72723
|
+
isGlob = token.isGlob = true;
|
|
72724
|
+
finished = true;
|
|
72725
|
+
|
|
72726
|
+
if (scanToEnd === true) {
|
|
72727
|
+
continue;
|
|
72728
|
+
}
|
|
72729
|
+
break;
|
|
72730
|
+
}
|
|
72731
|
+
|
|
72732
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
72733
|
+
isGlob = token.isGlob = true;
|
|
72734
|
+
finished = true;
|
|
72735
|
+
|
|
72736
|
+
if (scanToEnd === true) {
|
|
72737
|
+
continue;
|
|
72738
|
+
}
|
|
72739
|
+
break;
|
|
72740
|
+
}
|
|
72741
|
+
|
|
72742
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
72743
|
+
while (eos() !== true && (next = advance())) {
|
|
72744
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
72745
|
+
backslashes = token.backslashes = true;
|
|
72746
|
+
advance();
|
|
72747
|
+
continue;
|
|
72748
|
+
}
|
|
72749
|
+
|
|
72750
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
72751
|
+
isBracket = token.isBracket = true;
|
|
72752
|
+
isGlob = token.isGlob = true;
|
|
72753
|
+
finished = true;
|
|
72754
|
+
break;
|
|
72755
|
+
}
|
|
72756
|
+
}
|
|
72757
|
+
|
|
72758
|
+
if (scanToEnd === true) {
|
|
72759
|
+
continue;
|
|
72760
|
+
}
|
|
72761
|
+
|
|
72762
|
+
break;
|
|
72763
|
+
}
|
|
72764
|
+
|
|
72765
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
72766
|
+
negated = token.negated = true;
|
|
72767
|
+
start++;
|
|
72768
|
+
continue;
|
|
72769
|
+
}
|
|
72770
|
+
|
|
72771
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
72772
|
+
isGlob = token.isGlob = true;
|
|
72773
|
+
|
|
72774
|
+
if (scanToEnd === true) {
|
|
72775
|
+
while (eos() !== true && (code = advance())) {
|
|
72776
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
72777
|
+
backslashes = token.backslashes = true;
|
|
72778
|
+
code = advance();
|
|
72779
|
+
continue;
|
|
72780
|
+
}
|
|
72781
|
+
|
|
72782
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
72783
|
+
finished = true;
|
|
72784
|
+
break;
|
|
72785
|
+
}
|
|
72786
|
+
}
|
|
72787
|
+
continue;
|
|
72788
|
+
}
|
|
72789
|
+
break;
|
|
72790
|
+
}
|
|
72791
|
+
|
|
72792
|
+
if (isGlob === true) {
|
|
72793
|
+
finished = true;
|
|
72794
|
+
|
|
72795
|
+
if (scanToEnd === true) {
|
|
72796
|
+
continue;
|
|
72797
|
+
}
|
|
72798
|
+
|
|
72799
|
+
break;
|
|
72800
|
+
}
|
|
72801
|
+
}
|
|
72802
|
+
|
|
72803
|
+
if (opts.noext === true) {
|
|
72804
|
+
isExtglob = false;
|
|
72805
|
+
isGlob = false;
|
|
72806
|
+
}
|
|
72807
|
+
|
|
72808
|
+
let base = str;
|
|
72809
|
+
let prefix = '';
|
|
72810
|
+
let glob = '';
|
|
72811
|
+
|
|
72812
|
+
if (start > 0) {
|
|
72813
|
+
prefix = str.slice(0, start);
|
|
72814
|
+
str = str.slice(start);
|
|
72815
|
+
lastIndex -= start;
|
|
72816
|
+
}
|
|
72817
|
+
|
|
72818
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
72819
|
+
base = str.slice(0, lastIndex);
|
|
72820
|
+
glob = str.slice(lastIndex);
|
|
72821
|
+
} else if (isGlob === true) {
|
|
72822
|
+
base = '';
|
|
72823
|
+
glob = str;
|
|
72824
|
+
} else {
|
|
72825
|
+
base = str;
|
|
72826
|
+
}
|
|
72827
|
+
|
|
72828
|
+
if (base && base !== '' && base !== '/' && base !== str) {
|
|
72829
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
72830
|
+
base = base.slice(0, -1);
|
|
72831
|
+
}
|
|
72832
|
+
}
|
|
72833
|
+
|
|
72834
|
+
if (opts.unescape === true) {
|
|
72835
|
+
if (glob) glob = utils$3.removeBackslashes(glob);
|
|
72836
|
+
|
|
72837
|
+
if (base && backslashes === true) {
|
|
72838
|
+
base = utils$3.removeBackslashes(base);
|
|
72839
|
+
}
|
|
72840
|
+
}
|
|
72841
|
+
|
|
72842
|
+
const state = {
|
|
72843
|
+
prefix,
|
|
72844
|
+
input,
|
|
72845
|
+
start,
|
|
72846
|
+
base,
|
|
72847
|
+
glob,
|
|
72848
|
+
isBrace,
|
|
72849
|
+
isBracket,
|
|
72850
|
+
isGlob,
|
|
72851
|
+
isExtglob,
|
|
72852
|
+
isGlobstar,
|
|
72853
|
+
negated,
|
|
72854
|
+
negatedExtglob
|
|
72855
|
+
};
|
|
72856
|
+
|
|
72857
|
+
if (opts.tokens === true) {
|
|
72858
|
+
state.maxDepth = 0;
|
|
72859
|
+
if (!isPathSeparator(code)) {
|
|
72860
|
+
tokens.push(token);
|
|
72861
|
+
}
|
|
72862
|
+
state.tokens = tokens;
|
|
72863
|
+
}
|
|
72864
|
+
|
|
72865
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
72866
|
+
let prevIndex;
|
|
72867
|
+
|
|
72868
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
72869
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
72870
|
+
const i = slashes[idx];
|
|
72871
|
+
const value = input.slice(n, i);
|
|
72872
|
+
if (opts.tokens) {
|
|
72873
|
+
if (idx === 0 && start !== 0) {
|
|
72874
|
+
tokens[idx].isPrefix = true;
|
|
72875
|
+
tokens[idx].value = prefix;
|
|
72876
|
+
} else {
|
|
72877
|
+
tokens[idx].value = value;
|
|
72878
|
+
}
|
|
72879
|
+
depth(tokens[idx]);
|
|
72880
|
+
state.maxDepth += tokens[idx].depth;
|
|
72881
|
+
}
|
|
72882
|
+
if (idx !== 0 || value !== '') {
|
|
72883
|
+
parts.push(value);
|
|
72884
|
+
}
|
|
72885
|
+
prevIndex = i;
|
|
72886
|
+
}
|
|
72887
|
+
|
|
72888
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
72889
|
+
const value = input.slice(prevIndex + 1);
|
|
72890
|
+
parts.push(value);
|
|
72891
|
+
|
|
72892
|
+
if (opts.tokens) {
|
|
72893
|
+
tokens[tokens.length - 1].value = value;
|
|
72894
|
+
depth(tokens[tokens.length - 1]);
|
|
72895
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
72896
|
+
}
|
|
72897
|
+
}
|
|
72898
|
+
|
|
72899
|
+
state.slashes = slashes;
|
|
72900
|
+
state.parts = parts;
|
|
72901
|
+
}
|
|
72902
|
+
|
|
72903
|
+
return state;
|
|
72438
72904
|
};
|
|
72439
72905
|
|
|
72440
|
-
|
|
72441
|
-
const scope = path.scope.getProgramParent();
|
|
72442
|
-
const programPath = scope.path;
|
|
72443
|
-
|
|
72444
|
-
return programPath.node.extra.__putout_printer;
|
|
72445
|
-
}
|
|
72906
|
+
var scan_1 = scan$1;
|
|
72446
72907
|
|
|
72447
|
-
|
|
72448
|
-
|
|
72449
|
-
return path.node.extra?.parenthesized;
|
|
72450
|
-
|
|
72451
|
-
const {type} = path.parentPath;
|
|
72452
|
-
|
|
72453
|
-
return /^(TS)?Parenthesized(Expression|Type)?$/.test(type);
|
|
72454
|
-
}
|
|
72908
|
+
const constants$1 = constants$2;
|
|
72909
|
+
const utils$2 = utils$4;
|
|
72455
72910
|
|
|
72456
|
-
|
|
72457
|
-
|
|
72458
|
-
|
|
72459
|
-
|
|
72460
|
-
|
|
72461
|
-
|
|
72462
|
-
|
|
72463
|
-
|
|
72464
|
-
|
|
72465
|
-
|
|
72466
|
-
|
|
72467
|
-
|
|
72468
|
-
|
|
72469
|
-
|
|
72911
|
+
/**
|
|
72912
|
+
* Constants
|
|
72913
|
+
*/
|
|
72914
|
+
|
|
72915
|
+
const {
|
|
72916
|
+
MAX_LENGTH,
|
|
72917
|
+
POSIX_REGEX_SOURCE,
|
|
72918
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
72919
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
72920
|
+
REPLACEMENTS
|
|
72921
|
+
} = constants$1;
|
|
72922
|
+
|
|
72923
|
+
/**
|
|
72924
|
+
* Helpers
|
|
72925
|
+
*/
|
|
72926
|
+
|
|
72927
|
+
const expandRange = (args, options) => {
|
|
72928
|
+
if (typeof options.expandRange === 'function') {
|
|
72929
|
+
return options.expandRange(...args, options);
|
|
72930
|
+
}
|
|
72931
|
+
|
|
72932
|
+
args.sort();
|
|
72933
|
+
const value = `[${args.join('-')}]`;
|
|
72934
|
+
|
|
72935
|
+
try {
|
|
72936
|
+
/* eslint-disable-next-line no-new */
|
|
72937
|
+
new RegExp(value);
|
|
72938
|
+
} catch (ex) {
|
|
72939
|
+
return args.map(v => utils$2.escapeRegex(v)).join('..');
|
|
72940
|
+
}
|
|
72941
|
+
|
|
72942
|
+
return value;
|
|
72470
72943
|
};
|
|
72471
72944
|
|
|
72472
|
-
|
|
72473
|
-
|
|
72474
|
-
|
|
72475
|
-
|
|
72476
|
-
|
|
72477
|
-
|
|
72478
|
-
|
|
72479
|
-
|
|
72480
|
-
|
|
72481
|
-
|
|
72482
|
-
|
|
72483
|
-
|
|
72484
|
-
|
|
72485
|
-
|
|
72486
|
-
|
|
72487
|
-
|
|
72488
|
-
|
|
72489
|
-
|
|
72490
|
-
|
|
72491
|
-
|
|
72492
|
-
|
|
72493
|
-
|
|
72494
|
-
|
|
72495
|
-
|
|
72496
|
-
|
|
72497
|
-
|
|
72498
|
-
|
|
72499
|
-
|
|
72500
|
-
|
|
72501
|
-
|
|
72502
|
-
|
|
72503
|
-
|
|
72504
|
-
|
|
72505
|
-
|
|
72945
|
+
/**
|
|
72946
|
+
* Create the message for a syntax error
|
|
72947
|
+
*/
|
|
72948
|
+
|
|
72949
|
+
const syntaxError = (type, char) => {
|
|
72950
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
72951
|
+
};
|
|
72952
|
+
|
|
72953
|
+
/**
|
|
72954
|
+
* Parse the given input string.
|
|
72955
|
+
* @param {String} input
|
|
72956
|
+
* @param {Object} options
|
|
72957
|
+
* @return {Object}
|
|
72958
|
+
*/
|
|
72959
|
+
|
|
72960
|
+
const parse$1 = (input, options) => {
|
|
72961
|
+
if (typeof input !== 'string') {
|
|
72962
|
+
throw new TypeError('Expected a string');
|
|
72963
|
+
}
|
|
72964
|
+
|
|
72965
|
+
input = REPLACEMENTS[input] || input;
|
|
72966
|
+
|
|
72967
|
+
const opts = { ...options };
|
|
72968
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
72969
|
+
|
|
72970
|
+
let len = input.length;
|
|
72971
|
+
if (len > max) {
|
|
72972
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
72973
|
+
}
|
|
72974
|
+
|
|
72975
|
+
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
72976
|
+
const tokens = [bos];
|
|
72977
|
+
|
|
72978
|
+
const capture = opts.capture ? '' : '?:';
|
|
72979
|
+
|
|
72980
|
+
// create constants based on platform, for windows or posix
|
|
72981
|
+
const PLATFORM_CHARS = constants$1.globChars(opts.windows);
|
|
72982
|
+
const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
|
|
72983
|
+
|
|
72984
|
+
const {
|
|
72985
|
+
DOT_LITERAL,
|
|
72986
|
+
PLUS_LITERAL,
|
|
72987
|
+
SLASH_LITERAL,
|
|
72988
|
+
ONE_CHAR,
|
|
72989
|
+
DOTS_SLASH,
|
|
72990
|
+
NO_DOT,
|
|
72991
|
+
NO_DOT_SLASH,
|
|
72992
|
+
NO_DOTS_SLASH,
|
|
72993
|
+
QMARK,
|
|
72994
|
+
QMARK_NO_DOT,
|
|
72995
|
+
STAR,
|
|
72996
|
+
START_ANCHOR
|
|
72997
|
+
} = PLATFORM_CHARS;
|
|
72998
|
+
|
|
72999
|
+
const globstar = opts => {
|
|
73000
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
73001
|
+
};
|
|
73002
|
+
|
|
73003
|
+
const nodot = opts.dot ? '' : NO_DOT;
|
|
73004
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
73005
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
73006
|
+
|
|
73007
|
+
if (opts.capture) {
|
|
73008
|
+
star = `(${star})`;
|
|
73009
|
+
}
|
|
73010
|
+
|
|
73011
|
+
// minimatch options support
|
|
73012
|
+
if (typeof opts.noext === 'boolean') {
|
|
73013
|
+
opts.noextglob = opts.noext;
|
|
73014
|
+
}
|
|
73015
|
+
|
|
73016
|
+
const state = {
|
|
73017
|
+
input,
|
|
73018
|
+
index: -1,
|
|
73019
|
+
start: 0,
|
|
73020
|
+
dot: opts.dot === true,
|
|
73021
|
+
consumed: '',
|
|
73022
|
+
output: '',
|
|
73023
|
+
prefix: '',
|
|
73024
|
+
backtrack: false,
|
|
73025
|
+
negated: false,
|
|
73026
|
+
brackets: 0,
|
|
73027
|
+
braces: 0,
|
|
73028
|
+
parens: 0,
|
|
73029
|
+
quotes: 0,
|
|
73030
|
+
globstar: false,
|
|
73031
|
+
tokens
|
|
73032
|
+
};
|
|
73033
|
+
|
|
73034
|
+
input = utils$2.removePrefix(input, state);
|
|
73035
|
+
len = input.length;
|
|
73036
|
+
|
|
73037
|
+
const extglobs = [];
|
|
73038
|
+
const braces = [];
|
|
73039
|
+
const stack = [];
|
|
73040
|
+
let prev = bos;
|
|
73041
|
+
let value;
|
|
73042
|
+
|
|
73043
|
+
/**
|
|
73044
|
+
* Tokenizing helpers
|
|
73045
|
+
*/
|
|
73046
|
+
|
|
73047
|
+
const eos = () => state.index === len - 1;
|
|
73048
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
73049
|
+
const advance = state.advance = () => input[++state.index] || '';
|
|
73050
|
+
const remaining = () => input.slice(state.index + 1);
|
|
73051
|
+
const consume = (value = '', num = 0) => {
|
|
73052
|
+
state.consumed += value;
|
|
73053
|
+
state.index += num;
|
|
73054
|
+
};
|
|
73055
|
+
|
|
73056
|
+
const append = token => {
|
|
73057
|
+
state.output += token.output != null ? token.output : token.value;
|
|
73058
|
+
consume(token.value);
|
|
73059
|
+
};
|
|
73060
|
+
|
|
73061
|
+
const negate = () => {
|
|
73062
|
+
let count = 1;
|
|
73063
|
+
|
|
73064
|
+
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
73065
|
+
advance();
|
|
73066
|
+
state.start++;
|
|
73067
|
+
count++;
|
|
73068
|
+
}
|
|
73069
|
+
|
|
73070
|
+
if (count % 2 === 0) {
|
|
73071
|
+
return false;
|
|
73072
|
+
}
|
|
73073
|
+
|
|
73074
|
+
state.negated = true;
|
|
73075
|
+
state.start++;
|
|
73076
|
+
return true;
|
|
73077
|
+
};
|
|
73078
|
+
|
|
73079
|
+
const increment = type => {
|
|
73080
|
+
state[type]++;
|
|
73081
|
+
stack.push(type);
|
|
73082
|
+
};
|
|
73083
|
+
|
|
73084
|
+
const decrement = type => {
|
|
73085
|
+
state[type]--;
|
|
73086
|
+
stack.pop();
|
|
73087
|
+
};
|
|
73088
|
+
|
|
73089
|
+
/**
|
|
73090
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
73091
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
73092
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
73093
|
+
* characters are plain text. This improves performance and simplifies
|
|
73094
|
+
* lookbehinds.
|
|
73095
|
+
*/
|
|
73096
|
+
|
|
73097
|
+
const push = tok => {
|
|
73098
|
+
if (prev.type === 'globstar') {
|
|
73099
|
+
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
73100
|
+
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
73101
|
+
|
|
73102
|
+
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
73103
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
73104
|
+
prev.type = 'star';
|
|
73105
|
+
prev.value = '*';
|
|
73106
|
+
prev.output = star;
|
|
73107
|
+
state.output += prev.output;
|
|
73108
|
+
}
|
|
73109
|
+
}
|
|
73110
|
+
|
|
73111
|
+
if (extglobs.length && tok.type !== 'paren') {
|
|
73112
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
73113
|
+
}
|
|
73114
|
+
|
|
73115
|
+
if (tok.value || tok.output) append(tok);
|
|
73116
|
+
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
73117
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
73118
|
+
prev.value += tok.value;
|
|
73119
|
+
return;
|
|
73120
|
+
}
|
|
73121
|
+
|
|
73122
|
+
tok.prev = prev;
|
|
73123
|
+
tokens.push(tok);
|
|
73124
|
+
prev = tok;
|
|
73125
|
+
};
|
|
73126
|
+
|
|
73127
|
+
const extglobOpen = (type, value) => {
|
|
73128
|
+
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
73129
|
+
|
|
73130
|
+
token.prev = prev;
|
|
73131
|
+
token.parens = state.parens;
|
|
73132
|
+
token.output = state.output;
|
|
73133
|
+
const output = (opts.capture ? '(' : '') + token.open;
|
|
73134
|
+
|
|
73135
|
+
increment('parens');
|
|
73136
|
+
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
73137
|
+
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
73138
|
+
extglobs.push(token);
|
|
73139
|
+
};
|
|
73140
|
+
|
|
73141
|
+
const extglobClose = token => {
|
|
73142
|
+
let output = token.close + (opts.capture ? ')' : '');
|
|
73143
|
+
let rest;
|
|
73144
|
+
|
|
73145
|
+
if (token.type === 'negate') {
|
|
73146
|
+
let extglobStar = star;
|
|
73147
|
+
|
|
73148
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
73149
|
+
extglobStar = globstar(opts);
|
|
73150
|
+
}
|
|
73151
|
+
|
|
73152
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
73153
|
+
output = token.close = `)$))${extglobStar}`;
|
|
73154
|
+
}
|
|
73155
|
+
|
|
73156
|
+
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
73157
|
+
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
73158
|
+
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
73159
|
+
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
73160
|
+
//
|
|
73161
|
+
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
73162
|
+
const expression = parse$1(rest, { ...options, fastpaths: false }).output;
|
|
73163
|
+
|
|
73164
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
73165
|
+
}
|
|
73166
|
+
|
|
73167
|
+
if (token.prev.type === 'bos') {
|
|
73168
|
+
state.negatedExtglob = true;
|
|
73169
|
+
}
|
|
73170
|
+
}
|
|
73171
|
+
|
|
73172
|
+
push({ type: 'paren', extglob: true, value, output });
|
|
73173
|
+
decrement('parens');
|
|
73174
|
+
};
|
|
73175
|
+
|
|
73176
|
+
/**
|
|
73177
|
+
* Fast paths
|
|
73178
|
+
*/
|
|
73179
|
+
|
|
73180
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
73181
|
+
let backslashes = false;
|
|
73182
|
+
|
|
73183
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
73184
|
+
if (first === '\\') {
|
|
73185
|
+
backslashes = true;
|
|
73186
|
+
return m;
|
|
73187
|
+
}
|
|
73188
|
+
|
|
73189
|
+
if (first === '?') {
|
|
73190
|
+
if (esc) {
|
|
73191
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
73192
|
+
}
|
|
73193
|
+
if (index === 0) {
|
|
73194
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
73195
|
+
}
|
|
73196
|
+
return QMARK.repeat(chars.length);
|
|
73197
|
+
}
|
|
73198
|
+
|
|
73199
|
+
if (first === '.') {
|
|
73200
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
73201
|
+
}
|
|
73202
|
+
|
|
73203
|
+
if (first === '*') {
|
|
73204
|
+
if (esc) {
|
|
73205
|
+
return esc + first + (rest ? star : '');
|
|
73206
|
+
}
|
|
73207
|
+
return star;
|
|
73208
|
+
}
|
|
73209
|
+
return esc ? m : `\\${m}`;
|
|
73210
|
+
});
|
|
73211
|
+
|
|
73212
|
+
if (backslashes === true) {
|
|
73213
|
+
if (opts.unescape === true) {
|
|
73214
|
+
output = output.replace(/\\/g, '');
|
|
73215
|
+
} else {
|
|
73216
|
+
output = output.replace(/\\+/g, m => {
|
|
73217
|
+
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
73218
|
+
});
|
|
73219
|
+
}
|
|
73220
|
+
}
|
|
73221
|
+
|
|
73222
|
+
if (output === input && opts.contains === true) {
|
|
73223
|
+
state.output = input;
|
|
73224
|
+
return state;
|
|
73225
|
+
}
|
|
73226
|
+
|
|
73227
|
+
state.output = utils$2.wrapOutput(output, state, options);
|
|
73228
|
+
return state;
|
|
73229
|
+
}
|
|
73230
|
+
|
|
73231
|
+
/**
|
|
73232
|
+
* Tokenize input until we reach end-of-string
|
|
73233
|
+
*/
|
|
73234
|
+
|
|
73235
|
+
while (!eos()) {
|
|
73236
|
+
value = advance();
|
|
73237
|
+
|
|
73238
|
+
if (value === '\u0000') {
|
|
73239
|
+
continue;
|
|
73240
|
+
}
|
|
73241
|
+
|
|
73242
|
+
/**
|
|
73243
|
+
* Escaped characters
|
|
73244
|
+
*/
|
|
73245
|
+
|
|
73246
|
+
if (value === '\\') {
|
|
73247
|
+
const next = peek();
|
|
73248
|
+
|
|
73249
|
+
if (next === '/' && opts.bash !== true) {
|
|
73250
|
+
continue;
|
|
73251
|
+
}
|
|
73252
|
+
|
|
73253
|
+
if (next === '.' || next === ';') {
|
|
73254
|
+
continue;
|
|
73255
|
+
}
|
|
73256
|
+
|
|
73257
|
+
if (!next) {
|
|
73258
|
+
value += '\\';
|
|
73259
|
+
push({ type: 'text', value });
|
|
73260
|
+
continue;
|
|
73261
|
+
}
|
|
73262
|
+
|
|
73263
|
+
// collapse slashes to reduce potential for exploits
|
|
73264
|
+
const match = /^\\+/.exec(remaining());
|
|
73265
|
+
let slashes = 0;
|
|
73266
|
+
|
|
73267
|
+
if (match && match[0].length > 2) {
|
|
73268
|
+
slashes = match[0].length;
|
|
73269
|
+
state.index += slashes;
|
|
73270
|
+
if (slashes % 2 !== 0) {
|
|
73271
|
+
value += '\\';
|
|
73272
|
+
}
|
|
73273
|
+
}
|
|
73274
|
+
|
|
73275
|
+
if (opts.unescape === true) {
|
|
73276
|
+
value = advance();
|
|
73277
|
+
} else {
|
|
73278
|
+
value += advance();
|
|
73279
|
+
}
|
|
73280
|
+
|
|
73281
|
+
if (state.brackets === 0) {
|
|
73282
|
+
push({ type: 'text', value });
|
|
73283
|
+
continue;
|
|
73284
|
+
}
|
|
73285
|
+
}
|
|
73286
|
+
|
|
73287
|
+
/**
|
|
73288
|
+
* If we're inside a regex character class, continue
|
|
73289
|
+
* until we reach the closing bracket.
|
|
73290
|
+
*/
|
|
73291
|
+
|
|
73292
|
+
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
73293
|
+
if (opts.posix !== false && value === ':') {
|
|
73294
|
+
const inner = prev.value.slice(1);
|
|
73295
|
+
if (inner.includes('[')) {
|
|
73296
|
+
prev.posix = true;
|
|
73297
|
+
|
|
73298
|
+
if (inner.includes(':')) {
|
|
73299
|
+
const idx = prev.value.lastIndexOf('[');
|
|
73300
|
+
const pre = prev.value.slice(0, idx);
|
|
73301
|
+
const rest = prev.value.slice(idx + 2);
|
|
73302
|
+
const posix = POSIX_REGEX_SOURCE[rest];
|
|
73303
|
+
if (posix) {
|
|
73304
|
+
prev.value = pre + posix;
|
|
73305
|
+
state.backtrack = true;
|
|
73306
|
+
advance();
|
|
73307
|
+
|
|
73308
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
73309
|
+
bos.output = ONE_CHAR;
|
|
73310
|
+
}
|
|
73311
|
+
continue;
|
|
73312
|
+
}
|
|
73313
|
+
}
|
|
73314
|
+
}
|
|
73315
|
+
}
|
|
73316
|
+
|
|
73317
|
+
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
73318
|
+
value = `\\${value}`;
|
|
73319
|
+
}
|
|
73320
|
+
|
|
73321
|
+
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
73322
|
+
value = `\\${value}`;
|
|
73323
|
+
}
|
|
73324
|
+
|
|
73325
|
+
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
73326
|
+
value = '^';
|
|
73327
|
+
}
|
|
73328
|
+
|
|
73329
|
+
prev.value += value;
|
|
73330
|
+
append({ value });
|
|
73331
|
+
continue;
|
|
73332
|
+
}
|
|
73333
|
+
|
|
73334
|
+
/**
|
|
73335
|
+
* If we're inside a quoted string, continue
|
|
73336
|
+
* until we reach the closing double quote.
|
|
73337
|
+
*/
|
|
73338
|
+
|
|
73339
|
+
if (state.quotes === 1 && value !== '"') {
|
|
73340
|
+
value = utils$2.escapeRegex(value);
|
|
73341
|
+
prev.value += value;
|
|
73342
|
+
append({ value });
|
|
73343
|
+
continue;
|
|
73344
|
+
}
|
|
73345
|
+
|
|
73346
|
+
/**
|
|
73347
|
+
* Double quotes
|
|
73348
|
+
*/
|
|
73349
|
+
|
|
73350
|
+
if (value === '"') {
|
|
73351
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
73352
|
+
if (opts.keepQuotes === true) {
|
|
73353
|
+
push({ type: 'text', value });
|
|
73354
|
+
}
|
|
73355
|
+
continue;
|
|
73356
|
+
}
|
|
73357
|
+
|
|
73358
|
+
/**
|
|
73359
|
+
* Parentheses
|
|
73360
|
+
*/
|
|
73361
|
+
|
|
73362
|
+
if (value === '(') {
|
|
73363
|
+
increment('parens');
|
|
73364
|
+
push({ type: 'paren', value });
|
|
73365
|
+
continue;
|
|
73366
|
+
}
|
|
73367
|
+
|
|
73368
|
+
if (value === ')') {
|
|
73369
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
73370
|
+
throw new SyntaxError(syntaxError('opening', '('));
|
|
73371
|
+
}
|
|
73372
|
+
|
|
73373
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
73374
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
73375
|
+
extglobClose(extglobs.pop());
|
|
73376
|
+
continue;
|
|
73377
|
+
}
|
|
73378
|
+
|
|
73379
|
+
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
73380
|
+
decrement('parens');
|
|
73381
|
+
continue;
|
|
73382
|
+
}
|
|
73383
|
+
|
|
73384
|
+
/**
|
|
73385
|
+
* Square brackets
|
|
73386
|
+
*/
|
|
73387
|
+
|
|
73388
|
+
if (value === '[') {
|
|
73389
|
+
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
73390
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
73391
|
+
throw new SyntaxError(syntaxError('closing', ']'));
|
|
73392
|
+
}
|
|
73393
|
+
|
|
73394
|
+
value = `\\${value}`;
|
|
73395
|
+
} else {
|
|
73396
|
+
increment('brackets');
|
|
73397
|
+
}
|
|
73398
|
+
|
|
73399
|
+
push({ type: 'bracket', value });
|
|
73400
|
+
continue;
|
|
73401
|
+
}
|
|
73402
|
+
|
|
73403
|
+
if (value === ']') {
|
|
73404
|
+
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
73405
|
+
push({ type: 'text', value, output: `\\${value}` });
|
|
73406
|
+
continue;
|
|
73407
|
+
}
|
|
73408
|
+
|
|
73409
|
+
if (state.brackets === 0) {
|
|
73410
|
+
if (opts.strictBrackets === true) {
|
|
73411
|
+
throw new SyntaxError(syntaxError('opening', '['));
|
|
73412
|
+
}
|
|
73413
|
+
|
|
73414
|
+
push({ type: 'text', value, output: `\\${value}` });
|
|
73415
|
+
continue;
|
|
73416
|
+
}
|
|
73417
|
+
|
|
73418
|
+
decrement('brackets');
|
|
73419
|
+
|
|
73420
|
+
const prevValue = prev.value.slice(1);
|
|
73421
|
+
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
73422
|
+
value = `/${value}`;
|
|
73423
|
+
}
|
|
73424
|
+
|
|
73425
|
+
prev.value += value;
|
|
73426
|
+
append({ value });
|
|
73427
|
+
|
|
73428
|
+
// when literal brackets are explicitly disabled
|
|
73429
|
+
// assume we should match with a regex character class
|
|
73430
|
+
if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) {
|
|
73431
|
+
continue;
|
|
73432
|
+
}
|
|
73433
|
+
|
|
73434
|
+
const escaped = utils$2.escapeRegex(prev.value);
|
|
73435
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
73436
|
+
|
|
73437
|
+
// when literal brackets are explicitly enabled
|
|
73438
|
+
// assume we should escape the brackets to match literal characters
|
|
73439
|
+
if (opts.literalBrackets === true) {
|
|
73440
|
+
state.output += escaped;
|
|
73441
|
+
prev.value = escaped;
|
|
73442
|
+
continue;
|
|
73443
|
+
}
|
|
73444
|
+
|
|
73445
|
+
// when the user specifies nothing, try to match both
|
|
73446
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
73447
|
+
state.output += prev.value;
|
|
73448
|
+
continue;
|
|
73449
|
+
}
|
|
73450
|
+
|
|
73451
|
+
/**
|
|
73452
|
+
* Braces
|
|
73453
|
+
*/
|
|
73454
|
+
|
|
73455
|
+
if (value === '{' && opts.nobrace !== true) {
|
|
73456
|
+
increment('braces');
|
|
73457
|
+
|
|
73458
|
+
const open = {
|
|
73459
|
+
type: 'brace',
|
|
73460
|
+
value,
|
|
73461
|
+
output: '(',
|
|
73462
|
+
outputIndex: state.output.length,
|
|
73463
|
+
tokensIndex: state.tokens.length
|
|
73464
|
+
};
|
|
73465
|
+
|
|
73466
|
+
braces.push(open);
|
|
73467
|
+
push(open);
|
|
73468
|
+
continue;
|
|
73469
|
+
}
|
|
73470
|
+
|
|
73471
|
+
if (value === '}') {
|
|
73472
|
+
const brace = braces[braces.length - 1];
|
|
73473
|
+
|
|
73474
|
+
if (opts.nobrace === true || !brace) {
|
|
73475
|
+
push({ type: 'text', value, output: value });
|
|
73476
|
+
continue;
|
|
73477
|
+
}
|
|
73478
|
+
|
|
73479
|
+
let output = ')';
|
|
73480
|
+
|
|
73481
|
+
if (brace.dots === true) {
|
|
73482
|
+
const arr = tokens.slice();
|
|
73483
|
+
const range = [];
|
|
73484
|
+
|
|
73485
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
73486
|
+
tokens.pop();
|
|
73487
|
+
if (arr[i].type === 'brace') {
|
|
73488
|
+
break;
|
|
73489
|
+
}
|
|
73490
|
+
if (arr[i].type !== 'dots') {
|
|
73491
|
+
range.unshift(arr[i].value);
|
|
73492
|
+
}
|
|
73493
|
+
}
|
|
73494
|
+
|
|
73495
|
+
output = expandRange(range, opts);
|
|
73496
|
+
state.backtrack = true;
|
|
73497
|
+
}
|
|
73498
|
+
|
|
73499
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
73500
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
73501
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
73502
|
+
brace.value = brace.output = '\\{';
|
|
73503
|
+
value = output = '\\}';
|
|
73504
|
+
state.output = out;
|
|
73505
|
+
for (const t of toks) {
|
|
73506
|
+
state.output += (t.output || t.value);
|
|
73507
|
+
}
|
|
73508
|
+
}
|
|
73509
|
+
|
|
73510
|
+
push({ type: 'brace', value, output });
|
|
73511
|
+
decrement('braces');
|
|
73512
|
+
braces.pop();
|
|
73513
|
+
continue;
|
|
73514
|
+
}
|
|
73515
|
+
|
|
73516
|
+
/**
|
|
73517
|
+
* Pipes
|
|
73518
|
+
*/
|
|
73519
|
+
|
|
73520
|
+
if (value === '|') {
|
|
73521
|
+
if (extglobs.length > 0) {
|
|
73522
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
73523
|
+
}
|
|
73524
|
+
push({ type: 'text', value });
|
|
73525
|
+
continue;
|
|
73526
|
+
}
|
|
73527
|
+
|
|
73528
|
+
/**
|
|
73529
|
+
* Commas
|
|
73530
|
+
*/
|
|
73531
|
+
|
|
73532
|
+
if (value === ',') {
|
|
73533
|
+
let output = value;
|
|
73534
|
+
|
|
73535
|
+
const brace = braces[braces.length - 1];
|
|
73536
|
+
if (brace && stack[stack.length - 1] === 'braces') {
|
|
73537
|
+
brace.comma = true;
|
|
73538
|
+
output = '|';
|
|
73539
|
+
}
|
|
73540
|
+
|
|
73541
|
+
push({ type: 'comma', value, output });
|
|
73542
|
+
continue;
|
|
73543
|
+
}
|
|
73544
|
+
|
|
73545
|
+
/**
|
|
73546
|
+
* Slashes
|
|
73547
|
+
*/
|
|
73548
|
+
|
|
73549
|
+
if (value === '/') {
|
|
73550
|
+
// if the beginning of the glob is "./", advance the start
|
|
73551
|
+
// to the current index, and don't add the "./" characters
|
|
73552
|
+
// to the state. This greatly simplifies lookbehinds when
|
|
73553
|
+
// checking for BOS characters like "!" and "." (not "./")
|
|
73554
|
+
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
73555
|
+
state.start = state.index + 1;
|
|
73556
|
+
state.consumed = '';
|
|
73557
|
+
state.output = '';
|
|
73558
|
+
tokens.pop();
|
|
73559
|
+
prev = bos; // reset "prev" to the first token
|
|
73560
|
+
continue;
|
|
73561
|
+
}
|
|
73562
|
+
|
|
73563
|
+
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
73564
|
+
continue;
|
|
73565
|
+
}
|
|
73566
|
+
|
|
73567
|
+
/**
|
|
73568
|
+
* Dots
|
|
73569
|
+
*/
|
|
73570
|
+
|
|
73571
|
+
if (value === '.') {
|
|
73572
|
+
if (state.braces > 0 && prev.type === 'dot') {
|
|
73573
|
+
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
73574
|
+
const brace = braces[braces.length - 1];
|
|
73575
|
+
prev.type = 'dots';
|
|
73576
|
+
prev.output += value;
|
|
73577
|
+
prev.value += value;
|
|
73578
|
+
brace.dots = true;
|
|
73579
|
+
continue;
|
|
73580
|
+
}
|
|
73581
|
+
|
|
73582
|
+
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
73583
|
+
push({ type: 'text', value, output: DOT_LITERAL });
|
|
73584
|
+
continue;
|
|
73585
|
+
}
|
|
73586
|
+
|
|
73587
|
+
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
73588
|
+
continue;
|
|
73589
|
+
}
|
|
73590
|
+
|
|
73591
|
+
/**
|
|
73592
|
+
* Question marks
|
|
73593
|
+
*/
|
|
73594
|
+
|
|
73595
|
+
if (value === '?') {
|
|
73596
|
+
const isGroup = prev && prev.value === '(';
|
|
73597
|
+
if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
73598
|
+
extglobOpen('qmark', value);
|
|
73599
|
+
continue;
|
|
73600
|
+
}
|
|
73601
|
+
|
|
73602
|
+
if (prev && prev.type === 'paren') {
|
|
73603
|
+
const next = peek();
|
|
73604
|
+
let output = value;
|
|
73605
|
+
|
|
73606
|
+
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
|
|
73607
|
+
output = `\\${value}`;
|
|
73608
|
+
}
|
|
73609
|
+
|
|
73610
|
+
push({ type: 'text', value, output });
|
|
73611
|
+
continue;
|
|
73612
|
+
}
|
|
73613
|
+
|
|
73614
|
+
if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
|
|
73615
|
+
push({ type: 'qmark', value, output: QMARK_NO_DOT });
|
|
73616
|
+
continue;
|
|
73617
|
+
}
|
|
73618
|
+
|
|
73619
|
+
push({ type: 'qmark', value, output: QMARK });
|
|
73620
|
+
continue;
|
|
73621
|
+
}
|
|
73622
|
+
|
|
73623
|
+
/**
|
|
73624
|
+
* Exclamation
|
|
73625
|
+
*/
|
|
73626
|
+
|
|
73627
|
+
if (value === '!') {
|
|
73628
|
+
if (opts.noextglob !== true && peek() === '(') {
|
|
73629
|
+
if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
|
|
73630
|
+
extglobOpen('negate', value);
|
|
73631
|
+
continue;
|
|
73632
|
+
}
|
|
73633
|
+
}
|
|
73634
|
+
|
|
73635
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
73636
|
+
negate();
|
|
73637
|
+
continue;
|
|
73638
|
+
}
|
|
73639
|
+
}
|
|
73640
|
+
|
|
73641
|
+
/**
|
|
73642
|
+
* Plus
|
|
73643
|
+
*/
|
|
73644
|
+
|
|
73645
|
+
if (value === '+') {
|
|
73646
|
+
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
73647
|
+
extglobOpen('plus', value);
|
|
73648
|
+
continue;
|
|
73649
|
+
}
|
|
73650
|
+
|
|
73651
|
+
if ((prev && prev.value === '(') || opts.regex === false) {
|
|
73652
|
+
push({ type: 'plus', value, output: PLUS_LITERAL });
|
|
73653
|
+
continue;
|
|
73654
|
+
}
|
|
73655
|
+
|
|
73656
|
+
if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
|
|
73657
|
+
push({ type: 'plus', value });
|
|
73658
|
+
continue;
|
|
73659
|
+
}
|
|
73660
|
+
|
|
73661
|
+
push({ type: 'plus', value: PLUS_LITERAL });
|
|
73662
|
+
continue;
|
|
73663
|
+
}
|
|
73664
|
+
|
|
73665
|
+
/**
|
|
73666
|
+
* Plain text
|
|
73667
|
+
*/
|
|
73668
|
+
|
|
73669
|
+
if (value === '@') {
|
|
73670
|
+
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
73671
|
+
push({ type: 'at', extglob: true, value, output: '' });
|
|
73672
|
+
continue;
|
|
73673
|
+
}
|
|
73674
|
+
|
|
73675
|
+
push({ type: 'text', value });
|
|
73676
|
+
continue;
|
|
73677
|
+
}
|
|
73678
|
+
|
|
73679
|
+
/**
|
|
73680
|
+
* Plain text
|
|
73681
|
+
*/
|
|
73682
|
+
|
|
73683
|
+
if (value !== '*') {
|
|
73684
|
+
if (value === '$' || value === '^') {
|
|
73685
|
+
value = `\\${value}`;
|
|
73686
|
+
}
|
|
73687
|
+
|
|
73688
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
73689
|
+
if (match) {
|
|
73690
|
+
value += match[0];
|
|
73691
|
+
state.index += match[0].length;
|
|
73692
|
+
}
|
|
73693
|
+
|
|
73694
|
+
push({ type: 'text', value });
|
|
73695
|
+
continue;
|
|
73696
|
+
}
|
|
73697
|
+
|
|
73698
|
+
/**
|
|
73699
|
+
* Stars
|
|
73700
|
+
*/
|
|
73701
|
+
|
|
73702
|
+
if (prev && (prev.type === 'globstar' || prev.star === true)) {
|
|
73703
|
+
prev.type = 'star';
|
|
73704
|
+
prev.star = true;
|
|
73705
|
+
prev.value += value;
|
|
73706
|
+
prev.output = star;
|
|
73707
|
+
state.backtrack = true;
|
|
73708
|
+
state.globstar = true;
|
|
73709
|
+
consume(value);
|
|
73710
|
+
continue;
|
|
73711
|
+
}
|
|
73712
|
+
|
|
73713
|
+
let rest = remaining();
|
|
73714
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
73715
|
+
extglobOpen('star', value);
|
|
73716
|
+
continue;
|
|
73717
|
+
}
|
|
73718
|
+
|
|
73719
|
+
if (prev.type === 'star') {
|
|
73720
|
+
if (opts.noglobstar === true) {
|
|
73721
|
+
consume(value);
|
|
73722
|
+
continue;
|
|
73723
|
+
}
|
|
73724
|
+
|
|
73725
|
+
const prior = prev.prev;
|
|
73726
|
+
const before = prior.prev;
|
|
73727
|
+
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
73728
|
+
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
73729
|
+
|
|
73730
|
+
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
73731
|
+
push({ type: 'star', value, output: '' });
|
|
73732
|
+
continue;
|
|
73733
|
+
}
|
|
73734
|
+
|
|
73735
|
+
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
73736
|
+
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
73737
|
+
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
73738
|
+
push({ type: 'star', value, output: '' });
|
|
73739
|
+
continue;
|
|
73740
|
+
}
|
|
73741
|
+
|
|
73742
|
+
// strip consecutive `/**/`
|
|
73743
|
+
while (rest.slice(0, 3) === '/**') {
|
|
73744
|
+
const after = input[state.index + 4];
|
|
73745
|
+
if (after && after !== '/') {
|
|
73746
|
+
break;
|
|
73747
|
+
}
|
|
73748
|
+
rest = rest.slice(3);
|
|
73749
|
+
consume('/**', 3);
|
|
73750
|
+
}
|
|
73751
|
+
|
|
73752
|
+
if (prior.type === 'bos' && eos()) {
|
|
73753
|
+
prev.type = 'globstar';
|
|
73754
|
+
prev.value += value;
|
|
73755
|
+
prev.output = globstar(opts);
|
|
73756
|
+
state.output = prev.output;
|
|
73757
|
+
state.globstar = true;
|
|
73758
|
+
consume(value);
|
|
73759
|
+
continue;
|
|
73760
|
+
}
|
|
73761
|
+
|
|
73762
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
73763
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
73764
|
+
prior.output = `(?:${prior.output}`;
|
|
73765
|
+
|
|
73766
|
+
prev.type = 'globstar';
|
|
73767
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
73768
|
+
prev.value += value;
|
|
73769
|
+
state.globstar = true;
|
|
73770
|
+
state.output += prior.output + prev.output;
|
|
73771
|
+
consume(value);
|
|
73772
|
+
continue;
|
|
73773
|
+
}
|
|
73774
|
+
|
|
73775
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
73776
|
+
const end = rest[1] !== void 0 ? '|$' : '';
|
|
73777
|
+
|
|
73778
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
73779
|
+
prior.output = `(?:${prior.output}`;
|
|
73780
|
+
|
|
73781
|
+
prev.type = 'globstar';
|
|
73782
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
73783
|
+
prev.value += value;
|
|
73784
|
+
|
|
73785
|
+
state.output += prior.output + prev.output;
|
|
73786
|
+
state.globstar = true;
|
|
73787
|
+
|
|
73788
|
+
consume(value + advance());
|
|
73789
|
+
|
|
73790
|
+
push({ type: 'slash', value: '/', output: '' });
|
|
73791
|
+
continue;
|
|
73792
|
+
}
|
|
73793
|
+
|
|
73794
|
+
if (prior.type === 'bos' && rest[0] === '/') {
|
|
73795
|
+
prev.type = 'globstar';
|
|
73796
|
+
prev.value += value;
|
|
73797
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
73798
|
+
state.output = prev.output;
|
|
73799
|
+
state.globstar = true;
|
|
73800
|
+
consume(value + advance());
|
|
73801
|
+
push({ type: 'slash', value: '/', output: '' });
|
|
73802
|
+
continue;
|
|
73803
|
+
}
|
|
73804
|
+
|
|
73805
|
+
// remove single star from output
|
|
73806
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
73807
|
+
|
|
73808
|
+
// reset previous token to globstar
|
|
73809
|
+
prev.type = 'globstar';
|
|
73810
|
+
prev.output = globstar(opts);
|
|
73811
|
+
prev.value += value;
|
|
73812
|
+
|
|
73813
|
+
// reset output with globstar
|
|
73814
|
+
state.output += prev.output;
|
|
73815
|
+
state.globstar = true;
|
|
73816
|
+
consume(value);
|
|
73817
|
+
continue;
|
|
73818
|
+
}
|
|
73819
|
+
|
|
73820
|
+
const token = { type: 'star', value, output: star };
|
|
73821
|
+
|
|
73822
|
+
if (opts.bash === true) {
|
|
73823
|
+
token.output = '.*?';
|
|
73824
|
+
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
73825
|
+
token.output = nodot + token.output;
|
|
73826
|
+
}
|
|
73827
|
+
push(token);
|
|
73828
|
+
continue;
|
|
73829
|
+
}
|
|
73830
|
+
|
|
73831
|
+
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
73832
|
+
token.output = value;
|
|
73833
|
+
push(token);
|
|
73834
|
+
continue;
|
|
73835
|
+
}
|
|
73836
|
+
|
|
73837
|
+
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
73838
|
+
if (prev.type === 'dot') {
|
|
73839
|
+
state.output += NO_DOT_SLASH;
|
|
73840
|
+
prev.output += NO_DOT_SLASH;
|
|
73841
|
+
|
|
73842
|
+
} else if (opts.dot === true) {
|
|
73843
|
+
state.output += NO_DOTS_SLASH;
|
|
73844
|
+
prev.output += NO_DOTS_SLASH;
|
|
73845
|
+
|
|
73846
|
+
} else {
|
|
73847
|
+
state.output += nodot;
|
|
73848
|
+
prev.output += nodot;
|
|
73849
|
+
}
|
|
73850
|
+
|
|
73851
|
+
if (peek() !== '*') {
|
|
73852
|
+
state.output += ONE_CHAR;
|
|
73853
|
+
prev.output += ONE_CHAR;
|
|
73854
|
+
}
|
|
73855
|
+
}
|
|
73856
|
+
|
|
73857
|
+
push(token);
|
|
73858
|
+
}
|
|
73859
|
+
|
|
73860
|
+
while (state.brackets > 0) {
|
|
73861
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
|
73862
|
+
state.output = utils$2.escapeLast(state.output, '[');
|
|
73863
|
+
decrement('brackets');
|
|
73864
|
+
}
|
|
73865
|
+
|
|
73866
|
+
while (state.parens > 0) {
|
|
73867
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
|
73868
|
+
state.output = utils$2.escapeLast(state.output, '(');
|
|
73869
|
+
decrement('parens');
|
|
73870
|
+
}
|
|
73871
|
+
|
|
73872
|
+
while (state.braces > 0) {
|
|
73873
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
|
73874
|
+
state.output = utils$2.escapeLast(state.output, '{');
|
|
73875
|
+
decrement('braces');
|
|
73876
|
+
}
|
|
73877
|
+
|
|
73878
|
+
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
|
73879
|
+
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
|
73880
|
+
}
|
|
73881
|
+
|
|
73882
|
+
// rebuild the output if we had to backtrack at any point
|
|
73883
|
+
if (state.backtrack === true) {
|
|
73884
|
+
state.output = '';
|
|
73885
|
+
|
|
73886
|
+
for (const token of state.tokens) {
|
|
73887
|
+
state.output += token.output != null ? token.output : token.value;
|
|
73888
|
+
|
|
73889
|
+
if (token.suffix) {
|
|
73890
|
+
state.output += token.suffix;
|
|
73891
|
+
}
|
|
73892
|
+
}
|
|
73893
|
+
}
|
|
73894
|
+
|
|
73895
|
+
return state;
|
|
73896
|
+
};
|
|
73897
|
+
|
|
73898
|
+
/**
|
|
73899
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
73900
|
+
* This can significantly speed up processing and has very little downside
|
|
73901
|
+
* impact when none of the fast paths match.
|
|
73902
|
+
*/
|
|
73903
|
+
|
|
73904
|
+
parse$1.fastpaths = (input, options) => {
|
|
73905
|
+
const opts = { ...options };
|
|
73906
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
73907
|
+
const len = input.length;
|
|
73908
|
+
if (len > max) {
|
|
73909
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
73910
|
+
}
|
|
73911
|
+
|
|
73912
|
+
input = REPLACEMENTS[input] || input;
|
|
73913
|
+
|
|
73914
|
+
// create constants based on platform, for windows or posix
|
|
73915
|
+
const {
|
|
73916
|
+
DOT_LITERAL,
|
|
73917
|
+
SLASH_LITERAL,
|
|
73918
|
+
ONE_CHAR,
|
|
73919
|
+
DOTS_SLASH,
|
|
73920
|
+
NO_DOT,
|
|
73921
|
+
NO_DOTS,
|
|
73922
|
+
NO_DOTS_SLASH,
|
|
73923
|
+
STAR,
|
|
73924
|
+
START_ANCHOR
|
|
73925
|
+
} = constants$1.globChars(opts.windows);
|
|
73926
|
+
|
|
73927
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
73928
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
73929
|
+
const capture = opts.capture ? '' : '?:';
|
|
73930
|
+
const state = { negated: false, prefix: '' };
|
|
73931
|
+
let star = opts.bash === true ? '.*?' : STAR;
|
|
73932
|
+
|
|
73933
|
+
if (opts.capture) {
|
|
73934
|
+
star = `(${star})`;
|
|
73935
|
+
}
|
|
73936
|
+
|
|
73937
|
+
const globstar = opts => {
|
|
73938
|
+
if (opts.noglobstar === true) return star;
|
|
73939
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
73940
|
+
};
|
|
73941
|
+
|
|
73942
|
+
const create = str => {
|
|
73943
|
+
switch (str) {
|
|
73944
|
+
case '*':
|
|
73945
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
73946
|
+
|
|
73947
|
+
case '.*':
|
|
73948
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
73949
|
+
|
|
73950
|
+
case '*.*':
|
|
73951
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
73952
|
+
|
|
73953
|
+
case '*/*':
|
|
73954
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
73955
|
+
|
|
73956
|
+
case '**':
|
|
73957
|
+
return nodot + globstar(opts);
|
|
73958
|
+
|
|
73959
|
+
case '**/*':
|
|
73960
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
73961
|
+
|
|
73962
|
+
case '**/*.*':
|
|
73963
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
73964
|
+
|
|
73965
|
+
case '**/.*':
|
|
73966
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
73967
|
+
|
|
73968
|
+
default: {
|
|
73969
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
73970
|
+
if (!match) return;
|
|
73971
|
+
|
|
73972
|
+
const source = create(match[1]);
|
|
73973
|
+
if (!source) return;
|
|
73974
|
+
|
|
73975
|
+
return source + DOT_LITERAL + match[2];
|
|
73976
|
+
}
|
|
73977
|
+
}
|
|
73978
|
+
};
|
|
73979
|
+
|
|
73980
|
+
const output = utils$2.removePrefix(input, state);
|
|
73981
|
+
let source = create(output);
|
|
73982
|
+
|
|
73983
|
+
if (source && opts.strictSlashes !== true) {
|
|
73984
|
+
source += `${SLASH_LITERAL}?`;
|
|
73985
|
+
}
|
|
73986
|
+
|
|
73987
|
+
return source;
|
|
73988
|
+
};
|
|
73989
|
+
|
|
73990
|
+
var parse_1 = parse$1;
|
|
73991
|
+
|
|
73992
|
+
parse_1.default;
|
|
73993
|
+
|
|
73994
|
+
const scan = scan_1;
|
|
73995
|
+
const parse = parse_1;
|
|
73996
|
+
const utils$1 = utils$4;
|
|
73997
|
+
const constants = constants$2;
|
|
73998
|
+
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
73999
|
+
|
|
74000
|
+
/**
|
|
74001
|
+
* Creates a matcher function from one or more glob patterns. The
|
|
74002
|
+
* returned function takes a string to match as its first argument,
|
|
74003
|
+
* and returns true if the string is a match. The returned matcher
|
|
74004
|
+
* function also takes a boolean as the second argument that, when true,
|
|
74005
|
+
* returns an object with additional information.
|
|
74006
|
+
*
|
|
74007
|
+
* ```js
|
|
74008
|
+
* const picomatch = require('picomatch');
|
|
74009
|
+
* // picomatch(glob[, options]);
|
|
74010
|
+
*
|
|
74011
|
+
* const isMatch = picomatch('*.!(*a)');
|
|
74012
|
+
* console.log(isMatch('a.a')); //=> false
|
|
74013
|
+
* console.log(isMatch('a.b')); //=> true
|
|
74014
|
+
* ```
|
|
74015
|
+
* @name picomatch
|
|
74016
|
+
* @param {String|Array} `globs` One or more glob patterns.
|
|
74017
|
+
* @param {Object=} `options`
|
|
74018
|
+
* @return {Function=} Returns a matcher function.
|
|
74019
|
+
* @api public
|
|
74020
|
+
*/
|
|
74021
|
+
|
|
74022
|
+
const picomatch$2 = (glob, options, returnState = false) => {
|
|
74023
|
+
if (Array.isArray(glob)) {
|
|
74024
|
+
const fns = glob.map(input => picomatch$2(input, options, returnState));
|
|
74025
|
+
const arrayMatcher = str => {
|
|
74026
|
+
for (const isMatch of fns) {
|
|
74027
|
+
const state = isMatch(str);
|
|
74028
|
+
if (state) return state;
|
|
74029
|
+
}
|
|
74030
|
+
return false;
|
|
74031
|
+
};
|
|
74032
|
+
return arrayMatcher;
|
|
74033
|
+
}
|
|
74034
|
+
|
|
74035
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
74036
|
+
|
|
74037
|
+
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
74038
|
+
throw new TypeError('Expected pattern to be a non-empty string');
|
|
74039
|
+
}
|
|
74040
|
+
|
|
74041
|
+
const opts = options || {};
|
|
74042
|
+
const posix = opts.windows;
|
|
74043
|
+
const regex = isState
|
|
74044
|
+
? picomatch$2.compileRe(glob, options)
|
|
74045
|
+
: picomatch$2.makeRe(glob, options, false, true);
|
|
74046
|
+
|
|
74047
|
+
const state = regex.state;
|
|
74048
|
+
delete regex.state;
|
|
74049
|
+
|
|
74050
|
+
let isIgnored = () => false;
|
|
74051
|
+
if (opts.ignore) {
|
|
74052
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
74053
|
+
isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
|
|
74054
|
+
}
|
|
74055
|
+
|
|
74056
|
+
const matcher = (input, returnObject = false) => {
|
|
74057
|
+
const { isMatch, match, output } = picomatch$2.test(input, regex, options, { glob, posix });
|
|
74058
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
74059
|
+
|
|
74060
|
+
if (typeof opts.onResult === 'function') {
|
|
74061
|
+
opts.onResult(result);
|
|
74062
|
+
}
|
|
74063
|
+
|
|
74064
|
+
if (isMatch === false) {
|
|
74065
|
+
result.isMatch = false;
|
|
74066
|
+
return returnObject ? result : false;
|
|
74067
|
+
}
|
|
74068
|
+
|
|
74069
|
+
if (isIgnored(input)) {
|
|
74070
|
+
if (typeof opts.onIgnore === 'function') {
|
|
74071
|
+
opts.onIgnore(result);
|
|
74072
|
+
}
|
|
74073
|
+
result.isMatch = false;
|
|
74074
|
+
return returnObject ? result : false;
|
|
74075
|
+
}
|
|
74076
|
+
|
|
74077
|
+
if (typeof opts.onMatch === 'function') {
|
|
74078
|
+
opts.onMatch(result);
|
|
74079
|
+
}
|
|
74080
|
+
return returnObject ? result : true;
|
|
74081
|
+
};
|
|
74082
|
+
|
|
74083
|
+
if (returnState) {
|
|
74084
|
+
matcher.state = state;
|
|
74085
|
+
}
|
|
74086
|
+
|
|
74087
|
+
return matcher;
|
|
74088
|
+
};
|
|
74089
|
+
|
|
74090
|
+
/**
|
|
74091
|
+
* Test `input` with the given `regex`. This is used by the main
|
|
74092
|
+
* `picomatch()` function to test the input string.
|
|
74093
|
+
*
|
|
74094
|
+
* ```js
|
|
74095
|
+
* const picomatch = require('picomatch');
|
|
74096
|
+
* // picomatch.test(input, regex[, options]);
|
|
74097
|
+
*
|
|
74098
|
+
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
74099
|
+
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
74100
|
+
* ```
|
|
74101
|
+
* @param {String} `input` String to test.
|
|
74102
|
+
* @param {RegExp} `regex`
|
|
74103
|
+
* @return {Object} Returns an object with matching info.
|
|
74104
|
+
* @api public
|
|
74105
|
+
*/
|
|
74106
|
+
|
|
74107
|
+
picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
74108
|
+
if (typeof input !== 'string') {
|
|
74109
|
+
throw new TypeError('Expected input to be a string');
|
|
74110
|
+
}
|
|
74111
|
+
|
|
74112
|
+
if (input === '') {
|
|
74113
|
+
return { isMatch: false, output: '' };
|
|
74114
|
+
}
|
|
74115
|
+
|
|
74116
|
+
const opts = options || {};
|
|
74117
|
+
const format = opts.format || (posix ? utils$1.toPosixSlashes : null);
|
|
74118
|
+
let match = input === glob;
|
|
74119
|
+
let output = (match && format) ? format(input) : input;
|
|
74120
|
+
|
|
74121
|
+
if (match === false) {
|
|
74122
|
+
output = format ? format(input) : input;
|
|
74123
|
+
match = output === glob;
|
|
74124
|
+
}
|
|
74125
|
+
|
|
74126
|
+
if (match === false || opts.capture === true) {
|
|
74127
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
74128
|
+
match = picomatch$2.matchBase(input, regex, options, posix);
|
|
74129
|
+
} else {
|
|
74130
|
+
match = regex.exec(output);
|
|
74131
|
+
}
|
|
74132
|
+
}
|
|
74133
|
+
|
|
74134
|
+
return { isMatch: Boolean(match), match, output };
|
|
74135
|
+
};
|
|
74136
|
+
|
|
74137
|
+
/**
|
|
74138
|
+
* Match the basename of a filepath.
|
|
74139
|
+
*
|
|
74140
|
+
* ```js
|
|
74141
|
+
* const picomatch = require('picomatch');
|
|
74142
|
+
* // picomatch.matchBase(input, glob[, options]);
|
|
74143
|
+
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
74144
|
+
* ```
|
|
74145
|
+
* @param {String} `input` String to test.
|
|
74146
|
+
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
74147
|
+
* @return {Boolean}
|
|
74148
|
+
* @api public
|
|
74149
|
+
*/
|
|
74150
|
+
|
|
74151
|
+
picomatch$2.matchBase = (input, glob, options) => {
|
|
74152
|
+
const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
|
|
74153
|
+
return regex.test(utils$1.basename(input));
|
|
74154
|
+
};
|
|
74155
|
+
|
|
74156
|
+
/**
|
|
74157
|
+
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
74158
|
+
*
|
|
74159
|
+
* ```js
|
|
74160
|
+
* const picomatch = require('picomatch');
|
|
74161
|
+
* // picomatch.isMatch(string, patterns[, options]);
|
|
74162
|
+
*
|
|
74163
|
+
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
74164
|
+
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
74165
|
+
* ```
|
|
74166
|
+
* @param {String|Array} str The string to test.
|
|
74167
|
+
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
74168
|
+
* @param {Object} [options] See available [options](#options).
|
|
74169
|
+
* @return {Boolean} Returns true if any patterns match `str`
|
|
74170
|
+
* @api public
|
|
74171
|
+
*/
|
|
74172
|
+
|
|
74173
|
+
picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
|
|
74174
|
+
|
|
74175
|
+
/**
|
|
74176
|
+
* Parse a glob pattern to create the source string for a regular
|
|
74177
|
+
* expression.
|
|
74178
|
+
*
|
|
74179
|
+
* ```js
|
|
74180
|
+
* const picomatch = require('picomatch');
|
|
74181
|
+
* const result = picomatch.parse(pattern[, options]);
|
|
74182
|
+
* ```
|
|
74183
|
+
* @param {String} `pattern`
|
|
74184
|
+
* @param {Object} `options`
|
|
74185
|
+
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
74186
|
+
* @api public
|
|
74187
|
+
*/
|
|
74188
|
+
|
|
74189
|
+
picomatch$2.parse = (pattern, options) => {
|
|
74190
|
+
if (Array.isArray(pattern)) return pattern.map(p => picomatch$2.parse(p, options));
|
|
74191
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
74192
|
+
};
|
|
74193
|
+
|
|
74194
|
+
/**
|
|
74195
|
+
* Scan a glob pattern to separate the pattern into segments.
|
|
74196
|
+
*
|
|
74197
|
+
* ```js
|
|
74198
|
+
* const picomatch = require('picomatch');
|
|
74199
|
+
* // picomatch.scan(input[, options]);
|
|
74200
|
+
*
|
|
74201
|
+
* const result = picomatch.scan('!./foo/*.js');
|
|
74202
|
+
* console.log(result);
|
|
74203
|
+
* { prefix: '!./',
|
|
74204
|
+
* input: '!./foo/*.js',
|
|
74205
|
+
* start: 3,
|
|
74206
|
+
* base: 'foo',
|
|
74207
|
+
* glob: '*.js',
|
|
74208
|
+
* isBrace: false,
|
|
74209
|
+
* isBracket: false,
|
|
74210
|
+
* isGlob: true,
|
|
74211
|
+
* isExtglob: false,
|
|
74212
|
+
* isGlobstar: false,
|
|
74213
|
+
* negated: true }
|
|
74214
|
+
* ```
|
|
74215
|
+
* @param {String} `input` Glob pattern to scan.
|
|
74216
|
+
* @param {Object} `options`
|
|
74217
|
+
* @return {Object} Returns an object with
|
|
74218
|
+
* @api public
|
|
74219
|
+
*/
|
|
74220
|
+
|
|
74221
|
+
picomatch$2.scan = (input, options) => scan(input, options);
|
|
74222
|
+
|
|
74223
|
+
/**
|
|
74224
|
+
* Compile a regular expression from the `state` object returned by the
|
|
74225
|
+
* [parse()](#parse) method.
|
|
74226
|
+
*
|
|
74227
|
+
* @param {Object} `state`
|
|
74228
|
+
* @param {Object} `options`
|
|
74229
|
+
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
74230
|
+
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
74231
|
+
* @return {RegExp}
|
|
74232
|
+
* @api public
|
|
74233
|
+
*/
|
|
74234
|
+
|
|
74235
|
+
picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
74236
|
+
if (returnOutput === true) {
|
|
74237
|
+
return state.output;
|
|
74238
|
+
}
|
|
74239
|
+
|
|
74240
|
+
const opts = options || {};
|
|
74241
|
+
const prepend = opts.contains ? '' : '^';
|
|
74242
|
+
const append = opts.contains ? '' : '$';
|
|
74243
|
+
|
|
74244
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
74245
|
+
if (state && state.negated === true) {
|
|
74246
|
+
source = `^(?!${source}).*$`;
|
|
74247
|
+
}
|
|
74248
|
+
|
|
74249
|
+
const regex = picomatch$2.toRegex(source, options);
|
|
74250
|
+
if (returnState === true) {
|
|
74251
|
+
regex.state = state;
|
|
74252
|
+
}
|
|
74253
|
+
|
|
74254
|
+
return regex;
|
|
74255
|
+
};
|
|
74256
|
+
|
|
74257
|
+
/**
|
|
74258
|
+
* Create a regular expression from a parsed glob pattern.
|
|
74259
|
+
*
|
|
74260
|
+
* ```js
|
|
74261
|
+
* const picomatch = require('picomatch');
|
|
74262
|
+
* const state = picomatch.parse('*.js');
|
|
74263
|
+
* // picomatch.compileRe(state[, options]);
|
|
74264
|
+
*
|
|
74265
|
+
* console.log(picomatch.compileRe(state));
|
|
74266
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
74267
|
+
* ```
|
|
74268
|
+
* @param {String} `state` The object returned from the `.parse` method.
|
|
74269
|
+
* @param {Object} `options`
|
|
74270
|
+
* @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.
|
|
74271
|
+
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
74272
|
+
* @return {RegExp} Returns a regex created from the given pattern.
|
|
74273
|
+
* @api public
|
|
74274
|
+
*/
|
|
74275
|
+
|
|
74276
|
+
picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
74277
|
+
if (!input || typeof input !== 'string') {
|
|
74278
|
+
throw new TypeError('Expected a non-empty string');
|
|
74279
|
+
}
|
|
74280
|
+
|
|
74281
|
+
let parsed = { negated: false, fastpaths: true };
|
|
74282
|
+
|
|
74283
|
+
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
74284
|
+
parsed.output = parse.fastpaths(input, options);
|
|
74285
|
+
}
|
|
74286
|
+
|
|
74287
|
+
if (!parsed.output) {
|
|
74288
|
+
parsed = parse(input, options);
|
|
74289
|
+
}
|
|
74290
|
+
|
|
74291
|
+
return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
|
|
74292
|
+
};
|
|
74293
|
+
|
|
74294
|
+
/**
|
|
74295
|
+
* Create a regular expression from the given regex source string.
|
|
74296
|
+
*
|
|
74297
|
+
* ```js
|
|
74298
|
+
* const picomatch = require('picomatch');
|
|
74299
|
+
* // picomatch.toRegex(source[, options]);
|
|
74300
|
+
*
|
|
74301
|
+
* const { output } = picomatch.parse('*.js');
|
|
74302
|
+
* console.log(picomatch.toRegex(output));
|
|
74303
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
74304
|
+
* ```
|
|
74305
|
+
* @param {String} `source` Regular expression source string.
|
|
74306
|
+
* @param {Object} `options`
|
|
74307
|
+
* @return {RegExp}
|
|
74308
|
+
* @api public
|
|
74309
|
+
*/
|
|
74310
|
+
|
|
74311
|
+
picomatch$2.toRegex = (source, options) => {
|
|
74312
|
+
try {
|
|
74313
|
+
const opts = options || {};
|
|
74314
|
+
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
74315
|
+
} catch (err) {
|
|
74316
|
+
if (options && options.debug === true) throw err;
|
|
74317
|
+
return /$^/;
|
|
74318
|
+
}
|
|
74319
|
+
};
|
|
74320
|
+
|
|
74321
|
+
/**
|
|
74322
|
+
* Picomatch constants.
|
|
74323
|
+
* @return {Object}
|
|
74324
|
+
*/
|
|
74325
|
+
|
|
74326
|
+
picomatch$2.constants = constants;
|
|
74327
|
+
|
|
74328
|
+
/**
|
|
74329
|
+
* Expose "picomatch"
|
|
74330
|
+
*/
|
|
74331
|
+
|
|
74332
|
+
var picomatch_1$1 = picomatch$2;
|
|
74333
|
+
|
|
74334
|
+
picomatch_1$1.default;
|
|
74335
|
+
|
|
74336
|
+
const pico = picomatch_1$1;
|
|
74337
|
+
const utils = utils$4;
|
|
74338
|
+
|
|
74339
|
+
function picomatch(glob, options, returnState = false) {
|
|
74340
|
+
// default to os.platform()
|
|
74341
|
+
if (options && (options.windows === null || options.windows === undefined)) {
|
|
74342
|
+
// don't mutate the original options object
|
|
74343
|
+
options = { ...options, windows: utils.isWindows() };
|
|
74344
|
+
}
|
|
74345
|
+
|
|
74346
|
+
return pico(glob, options, returnState);
|
|
74347
|
+
}
|
|
74348
|
+
|
|
74349
|
+
Object.assign(picomatch, pico);
|
|
74350
|
+
var picomatch_1 = picomatch;
|
|
74351
|
+
|
|
74352
|
+
var picomatch$1 = picomatch_1.default;
|
|
74353
|
+
|
|
74354
|
+
const {stringLiteral: stringLiteral$1} = lib_exports;
|
|
74355
|
+
const getValue = ({node}) => node.value;
|
|
74356
|
+
|
|
74357
|
+
const ignore = ({name, property, list, type = __ignore}) => ({
|
|
74358
|
+
report: createReport$1(name),
|
|
74359
|
+
fix: fix$1,
|
|
74360
|
+
traverse: createTraverse$1({
|
|
74361
|
+
type,
|
|
74362
|
+
property,
|
|
74363
|
+
list,
|
|
74364
|
+
}),
|
|
74365
|
+
});
|
|
74366
|
+
|
|
74367
|
+
const addQuotes = (a) => `'${a}'`;
|
|
74368
|
+
|
|
74369
|
+
const createReport$1 = (filename) => ({name, matchedElements}) => {
|
|
74370
|
+
let insteadOf = '';
|
|
74371
|
+
|
|
74372
|
+
if (matchedElements.length) {
|
|
74373
|
+
const replacedNames = matchedElements.map(getValue);
|
|
74374
|
+
const namesLine = replacedNames
|
|
74375
|
+
.map(addQuotes)
|
|
74376
|
+
.join(', ');
|
|
74377
|
+
|
|
74378
|
+
insteadOf = ` instead of ${namesLine}`;
|
|
74379
|
+
}
|
|
74380
|
+
|
|
74381
|
+
return `Add '${name}'${insteadOf} to '${filename}'`;
|
|
74382
|
+
};
|
|
74383
|
+
|
|
74384
|
+
const fix$1 = ({path, name, matchedElements}) => {
|
|
74385
|
+
path.node.elements.push(stringLiteral$1(name));
|
|
74386
|
+
matchedElements.map(remove);
|
|
74387
|
+
};
|
|
74388
|
+
|
|
74389
|
+
const createTraverse$1 = ({type, property, list}) => ({push, options}) => {
|
|
74390
|
+
const {dismiss = []} = options;
|
|
74391
|
+
const newNames = filterNames(list, dismiss);
|
|
74392
|
+
|
|
74393
|
+
if (!newNames.length)
|
|
74394
|
+
return {};
|
|
74395
|
+
|
|
74396
|
+
return {
|
|
74397
|
+
[type]: (path) => {
|
|
74398
|
+
const [parentOfElements, elements] = parseElements$1(path, {
|
|
74399
|
+
property,
|
|
74400
|
+
});
|
|
74401
|
+
|
|
74402
|
+
if (!parentOfElements)
|
|
74403
|
+
return;
|
|
74404
|
+
|
|
74405
|
+
const list = elements.map(getValue);
|
|
74406
|
+
|
|
74407
|
+
for (const name of newNames) {
|
|
74408
|
+
if (list.includes(name))
|
|
74409
|
+
continue;
|
|
74410
|
+
|
|
74411
|
+
const match = picomatch$1(name);
|
|
74412
|
+
const matchedElements = [];
|
|
74413
|
+
|
|
74414
|
+
for (const current of elements.filter(exists)) {
|
|
74415
|
+
const {value} = current.node;
|
|
74416
|
+
|
|
74417
|
+
if (match(value))
|
|
74418
|
+
matchedElements.push(current);
|
|
74419
|
+
}
|
|
74420
|
+
|
|
74421
|
+
push({
|
|
74422
|
+
path: parentOfElements,
|
|
74423
|
+
matchedElements,
|
|
74424
|
+
elements,
|
|
74425
|
+
name,
|
|
74426
|
+
});
|
|
74427
|
+
}
|
|
74428
|
+
},
|
|
74429
|
+
};
|
|
74430
|
+
};
|
|
74431
|
+
|
|
74432
|
+
function filterNames(names, dismiss) {
|
|
74433
|
+
const newNames = [];
|
|
74434
|
+
|
|
74435
|
+
for (const name of names) {
|
|
74436
|
+
if (dismiss.includes(name))
|
|
74437
|
+
continue;
|
|
74438
|
+
|
|
74439
|
+
newNames.push(name);
|
|
74440
|
+
}
|
|
74441
|
+
|
|
74442
|
+
return newNames;
|
|
74443
|
+
}
|
|
74444
|
+
|
|
74445
|
+
const exists = ({node}) => Boolean(node);
|
|
74446
|
+
const emptyList = [];
|
|
74447
|
+
|
|
74448
|
+
function parseElements$1(path, {property}) {
|
|
74449
|
+
if (!property) {
|
|
74450
|
+
const [arg] = path.get('arguments');
|
|
74451
|
+
return [arg, arg.get('elements')];
|
|
74452
|
+
}
|
|
74453
|
+
|
|
74454
|
+
const [prop] = traverseProperties(path, property);
|
|
74455
|
+
|
|
74456
|
+
if (!prop)
|
|
74457
|
+
return [null, emptyList];
|
|
74458
|
+
|
|
74459
|
+
const valuePath = prop.get('value');
|
|
74460
|
+
|
|
74461
|
+
return [valuePath, valuePath.get('elements')];
|
|
74462
|
+
}
|
|
74463
|
+
|
|
74464
|
+
const {
|
|
74465
|
+
parenthesizedExpression,
|
|
74466
|
+
tsParenthesizedType,
|
|
74467
|
+
} = lib_exports;
|
|
74468
|
+
|
|
74469
|
+
const addParens = (path) => {
|
|
74470
|
+
const printer = getPrinter(path);
|
|
74471
|
+
|
|
74472
|
+
if (hasParens(path, printer))
|
|
74473
|
+
return path;
|
|
74474
|
+
|
|
74475
|
+
if (printer !== 'babel') {
|
|
74476
|
+
const {extra = {}} = path.node;
|
|
74477
|
+
|
|
74478
|
+
extra.parenthesized = true;
|
|
74479
|
+
path.node.extra = extra;
|
|
74480
|
+
|
|
74481
|
+
return path;
|
|
74482
|
+
}
|
|
74483
|
+
|
|
74484
|
+
const {node} = path;
|
|
74485
|
+
|
|
74486
|
+
if (path.type.startsWith('TS'))
|
|
74487
|
+
return path.replaceWith(tsParenthesizedType(node));
|
|
74488
|
+
|
|
74489
|
+
path.replaceWith(parenthesizedExpression(node));
|
|
74490
|
+
|
|
74491
|
+
return path;
|
|
74492
|
+
};
|
|
74493
|
+
|
|
74494
|
+
const removeParens = (path) => {
|
|
74495
|
+
const printer = getPrinter(path);
|
|
74496
|
+
|
|
74497
|
+
if (!hasParens(path, printer))
|
|
74498
|
+
return path;
|
|
74499
|
+
|
|
74500
|
+
if (printer !== 'babel') {
|
|
74501
|
+
path.node.extra.parenthesized = false;
|
|
74502
|
+
return path;
|
|
74503
|
+
}
|
|
74504
|
+
|
|
74505
|
+
const {node} = path;
|
|
74506
|
+
path.parentPath.replaceWith(node);
|
|
74507
|
+
|
|
74508
|
+
return path;
|
|
74509
|
+
};
|
|
74510
|
+
|
|
74511
|
+
function getPrinter(path) {
|
|
74512
|
+
const scope = path.scope.getProgramParent();
|
|
74513
|
+
const programPath = scope.path;
|
|
74514
|
+
|
|
74515
|
+
return programPath.node.extra.__putout_printer;
|
|
74516
|
+
}
|
|
74517
|
+
|
|
74518
|
+
function hasParens(path, printer = getPrinter(path)) {
|
|
74519
|
+
if (printer !== 'babel')
|
|
74520
|
+
return path.node.extra?.parenthesized;
|
|
74521
|
+
|
|
74522
|
+
const {type} = path.parentPath;
|
|
74523
|
+
|
|
74524
|
+
return /^(TS)?Parenthesized(Expression|Type)?$/.test(type);
|
|
74525
|
+
}
|
|
74526
|
+
|
|
74527
|
+
const findFileUp = (file, name) => {
|
|
74528
|
+
const parentDirectory = getParentDirectory(file);
|
|
74529
|
+
|
|
74530
|
+
if (!parentDirectory)
|
|
74531
|
+
return null;
|
|
74532
|
+
|
|
74533
|
+
const [currentFile] = getFile(parentDirectory, name, {
|
|
74534
|
+
type: 'file',
|
|
74535
|
+
});
|
|
74536
|
+
|
|
74537
|
+
if (currentFile)
|
|
74538
|
+
return currentFile;
|
|
74539
|
+
|
|
74540
|
+
return findFileUp(parentDirectory, name);
|
|
74541
|
+
};
|
|
74542
|
+
|
|
74543
|
+
const {stringLiteral} = lib_exports;
|
|
74544
|
+
|
|
74545
|
+
const sortIgnore = ({name, property, type = __ignore}) => ({
|
|
74546
|
+
report: createReport({
|
|
74547
|
+
name,
|
|
74548
|
+
property,
|
|
74549
|
+
}),
|
|
74550
|
+
fix,
|
|
74551
|
+
traverse: createTraverse({
|
|
74552
|
+
type,
|
|
74553
|
+
property,
|
|
74554
|
+
}),
|
|
74555
|
+
});
|
|
74556
|
+
|
|
74557
|
+
const createReport = ({name, property}) => () => {
|
|
74558
|
+
if (property)
|
|
74559
|
+
return `Sort '${property}' section of '${name}'`;
|
|
74560
|
+
|
|
74561
|
+
return `Sort '${name}'`;
|
|
74562
|
+
};
|
|
74563
|
+
|
|
74564
|
+
const fix = ({path, sortedElements}) => {
|
|
74565
|
+
path.node.elements = sortedElements;
|
|
74566
|
+
};
|
|
74567
|
+
|
|
74568
|
+
const createTraverse = ({type, property}) => ({push}) => ({
|
|
74569
|
+
[type]: (path) => {
|
|
74570
|
+
const masks = [];
|
|
74571
|
+
const hidden = [];
|
|
74572
|
+
const files = [];
|
|
74573
|
+
const dirs = [];
|
|
74574
|
+
|
|
74575
|
+
const parentOfElements = parseElements(path, {
|
|
74576
|
+
property,
|
|
74577
|
+
});
|
|
74578
|
+
|
|
74579
|
+
if (!parentOfElements)
|
|
74580
|
+
return;
|
|
74581
|
+
|
|
74582
|
+
const {elements} = parentOfElements.node;
|
|
74583
|
+
|
|
74584
|
+
for (const element of elements) {
|
|
74585
|
+
const {value} = element;
|
|
74586
|
+
|
|
74587
|
+
if (!value)
|
|
74588
|
+
continue;
|
|
74589
|
+
|
|
74590
|
+
if (value.startsWith('*')) {
|
|
74591
|
+
masks.push(element);
|
|
74592
|
+
continue;
|
|
74593
|
+
}
|
|
74594
|
+
|
|
74595
|
+
if (value.startsWith('.')) {
|
|
74596
|
+
hidden.push(element);
|
|
74597
|
+
continue;
|
|
74598
|
+
}
|
|
74599
|
+
|
|
74600
|
+
if (value.includes('.')) {
|
|
74601
|
+
files.push(element);
|
|
74602
|
+
continue;
|
|
74603
|
+
}
|
|
74604
|
+
|
|
74605
|
+
if (value.startsWith('#'))
|
|
74606
|
+
continue;
|
|
74607
|
+
|
|
74608
|
+
dirs.push(element);
|
|
74609
|
+
}
|
|
74610
|
+
|
|
74611
|
+
const sortedElements = [
|
|
74612
|
+
...maybeSeparate(masks, property),
|
|
74613
|
+
...maybeSeparate(hidden, property),
|
|
74614
|
+
...maybeSeparate(files, property),
|
|
74615
|
+
...dirs,
|
|
74616
|
+
];
|
|
74617
|
+
|
|
74618
|
+
for (const [index, {value}] of elements.entries()) {
|
|
74619
|
+
const current = sortedElements[index];
|
|
74620
|
+
|
|
74621
|
+
if (current.value !== value) {
|
|
74622
|
+
push({
|
|
74623
|
+
path: parentOfElements,
|
|
74624
|
+
sortedElements,
|
|
74625
|
+
});
|
|
74626
|
+
break;
|
|
74627
|
+
}
|
|
74628
|
+
}
|
|
74629
|
+
},
|
|
74630
|
+
});
|
|
74631
|
+
|
|
74632
|
+
function parseElements(path, {property}) {
|
|
74633
|
+
if (!property) {
|
|
74634
|
+
const [arg] = path.get('arguments');
|
|
74635
|
+
|
|
74636
|
+
if (!arg.node.elements)
|
|
74637
|
+
return null;
|
|
74638
|
+
|
|
74639
|
+
return arg;
|
|
74640
|
+
}
|
|
74641
|
+
|
|
74642
|
+
const [prop] = traverseProperties(path, property);
|
|
74643
|
+
|
|
74644
|
+
if (!prop)
|
|
74645
|
+
return null;
|
|
74646
|
+
|
|
74647
|
+
return prop.get('value');
|
|
74648
|
+
}
|
|
74649
|
+
|
|
74650
|
+
function maybeSeparate(array, property) {
|
|
74651
|
+
if (property)
|
|
74652
|
+
return array;
|
|
74653
|
+
|
|
74654
|
+
if (!array.length)
|
|
74655
|
+
return [];
|
|
74656
|
+
|
|
74657
|
+
return [
|
|
74658
|
+
...array,
|
|
74659
|
+
stringLiteral(''),
|
|
74660
|
+
];
|
|
74661
|
+
}
|
|
74662
|
+
|
|
74663
|
+
var operator = /*#__PURE__*/Object.freeze({
|
|
74664
|
+
__proto__: null,
|
|
74665
|
+
__filesystem: __filesystem,
|
|
74666
|
+
__filesystem_name: __filesystem_name,
|
|
74667
|
+
__ignore: __ignore,
|
|
74668
|
+
__ignore_name: __ignore_name,
|
|
74669
|
+
__json: __json,
|
|
74670
|
+
__json_name: __json_name,
|
|
74671
|
+
__toml: __toml,
|
|
74672
|
+
__toml_name: __toml_name,
|
|
74673
|
+
__yaml: __yaml,
|
|
74674
|
+
__yaml_name: __yaml_name,
|
|
74675
|
+
addArgs: addArgs,
|
|
74676
|
+
addAttribute: addAttribute,
|
|
74677
|
+
addAttributeValue: addAttributeValue,
|
|
74678
|
+
addClassName: addClassName,
|
|
74679
|
+
addParens: addParens,
|
|
74680
|
+
compare: compare,
|
|
74681
|
+
compareAll: compareAll,
|
|
74682
|
+
compareAny: compareAny,
|
|
74683
|
+
compute: compute,
|
|
74684
|
+
contains: contains,
|
|
74685
|
+
containsClassName: containsClassName,
|
|
74686
|
+
copyFile: copyFile,
|
|
74687
|
+
crawlDirectory: crawlDirectory,
|
|
74688
|
+
createDirectory: createDirectory,
|
|
74689
|
+
createFile: createFile,
|
|
74690
|
+
createNestedDirectory: createNestedDirectory,
|
|
74691
|
+
declare: declare$1,
|
|
74692
|
+
extract: extract,
|
|
74693
|
+
findBinding: findBinding,
|
|
74694
|
+
findFile: findFile,
|
|
74695
|
+
findFileUp: findFileUp,
|
|
74696
|
+
findVarsWays: findVarsWays,
|
|
74697
|
+
fix: fix$1,
|
|
72506
74698
|
fromJS: fromJS,
|
|
72507
74699
|
getAttributeNode: getAttributeNode,
|
|
72508
74700
|
getAttributePath: getAttributePath,
|
|
@@ -72537,6 +74729,7 @@ var operator = /*#__PURE__*/Object.freeze({
|
|
|
72537
74729
|
isJSON: isJSON,
|
|
72538
74730
|
isJSONGroup: isJSONGroup,
|
|
72539
74731
|
isKeyword: isKeyword,
|
|
74732
|
+
isLegacyKeyword: isLegacyKeyword,
|
|
72540
74733
|
isModuleDeclarationKeyword: isModuleDeclarationKeyword,
|
|
72541
74734
|
isModuleExports: isModuleExports,
|
|
72542
74735
|
isSimple: isSimple,
|
|
@@ -72565,6 +74758,7 @@ var operator = /*#__PURE__*/Object.freeze({
|
|
|
72565
74758
|
setAttributeValue: setAttributeValue,
|
|
72566
74759
|
setLiteralValue: setLiteralValue,
|
|
72567
74760
|
setValues: setValues,
|
|
74761
|
+
sortIgnore: sortIgnore,
|
|
72568
74762
|
toExpression: toExpression,
|
|
72569
74763
|
toJS: toJS,
|
|
72570
74764
|
transformRegExp: transformRegExp,
|
|
@@ -72596,7 +74790,7 @@ var exports$1 = /*#__PURE__*/Object.freeze({
|
|
|
72596
74790
|
findPlacesAsync: findPlacesAsync,
|
|
72597
74791
|
generate: generate,
|
|
72598
74792
|
operator: operator,
|
|
72599
|
-
parse: parse$
|
|
74793
|
+
parse: parse$4,
|
|
72600
74794
|
print: print,
|
|
72601
74795
|
putoutAsync: putoutAsync,
|
|
72602
74796
|
template: template$1,
|
|
@@ -72608,4 +74802,4 @@ var exports$1 = /*#__PURE__*/Object.freeze({
|
|
|
72608
74802
|
|
|
72609
74803
|
Object.assign(putout, exports$1);
|
|
72610
74804
|
|
|
72611
|
-
export { codeframe, putout as default, findPlaces, findPlacesAsync, generate, operator, parse$
|
|
74805
|
+
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 };
|