@putout/bundle 4.7.4 → 4.7.5
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 +74 -50
- package/bundle/putout.min.js +1 -1
- package/package.json +2 -2
package/bundle/putout.js
CHANGED
|
@@ -4381,14 +4381,14 @@ __export(lib_exports, {
|
|
|
4381
4381
|
isWhileStatement: () => isWhileStatement,
|
|
4382
4382
|
isWithStatement: () => isWithStatement,
|
|
4383
4383
|
isYieldExpression: () => isYieldExpression,
|
|
4384
|
-
jsxAttribute: () => jsxAttribute$
|
|
4384
|
+
jsxAttribute: () => jsxAttribute$2,
|
|
4385
4385
|
jsxClosingElement: () => jsxClosingElement,
|
|
4386
4386
|
jsxClosingFragment: () => jsxClosingFragment,
|
|
4387
4387
|
jsxElement: () => jsxElement$1,
|
|
4388
4388
|
jsxEmptyExpression: () => jsxEmptyExpression,
|
|
4389
4389
|
jsxExpressionContainer: () => jsxExpressionContainer,
|
|
4390
4390
|
jsxFragment: () => jsxFragment$1,
|
|
4391
|
-
jsxIdentifier: () => jsxIdentifier,
|
|
4391
|
+
jsxIdentifier: () => jsxIdentifier$1,
|
|
4392
4392
|
jsxMemberExpression: () => jsxMemberExpression,
|
|
4393
4393
|
jsxNamespacedName: () => jsxNamespacedName,
|
|
4394
4394
|
jsxOpeningElement: () => jsxOpeningElement$1,
|
|
@@ -4450,7 +4450,7 @@ __export(lib_exports, {
|
|
|
4450
4450
|
spreadElement: () => spreadElement$1,
|
|
4451
4451
|
spreadProperty: () => SpreadProperty,
|
|
4452
4452
|
staticBlock: () => staticBlock$1,
|
|
4453
|
-
stringLiteral: () => stringLiteral$
|
|
4453
|
+
stringLiteral: () => stringLiteral$6,
|
|
4454
4454
|
stringLiteralTypeAnnotation: () => stringLiteralTypeAnnotation,
|
|
4455
4455
|
stringTypeAnnotation: () => stringTypeAnnotation,
|
|
4456
4456
|
super: () => _super,
|
|
@@ -14633,7 +14633,7 @@ function labeledStatement$1(label, body) {
|
|
|
14633
14633
|
return node;
|
|
14634
14634
|
}
|
|
14635
14635
|
|
|
14636
|
-
function stringLiteral$
|
|
14636
|
+
function stringLiteral$6(value) {
|
|
14637
14637
|
const node = {
|
|
14638
14638
|
type: 'StringLiteral',
|
|
14639
14639
|
value,
|
|
@@ -16275,7 +16275,7 @@ function optionalIndexedAccessType(objectType, indexType) {
|
|
|
16275
16275
|
return node;
|
|
16276
16276
|
}
|
|
16277
16277
|
|
|
16278
|
-
function jsxAttribute$
|
|
16278
|
+
function jsxAttribute$2(name, value = null) {
|
|
16279
16279
|
const node = {
|
|
16280
16280
|
type: 'JSXAttribute',
|
|
16281
16281
|
name,
|
|
@@ -16342,7 +16342,7 @@ function jsxSpreadChild(expression2) {
|
|
|
16342
16342
|
return node;
|
|
16343
16343
|
}
|
|
16344
16344
|
|
|
16345
|
-
function jsxIdentifier(name) {
|
|
16345
|
+
function jsxIdentifier$1(name) {
|
|
16346
16346
|
const node = {
|
|
16347
16347
|
type: 'JSXIdentifier',
|
|
16348
16348
|
name,
|
|
@@ -17497,14 +17497,14 @@ var b = /* @__PURE__ */Object.freeze({
|
|
|
17497
17497
|
interfaceTypeAnnotation,
|
|
17498
17498
|
interpreterDirective,
|
|
17499
17499
|
intersectionTypeAnnotation,
|
|
17500
|
-
jsxAttribute: jsxAttribute$
|
|
17500
|
+
jsxAttribute: jsxAttribute$2,
|
|
17501
17501
|
jsxClosingElement,
|
|
17502
17502
|
jsxClosingFragment,
|
|
17503
17503
|
jsxElement: jsxElement$1,
|
|
17504
17504
|
jsxEmptyExpression,
|
|
17505
17505
|
jsxExpressionContainer,
|
|
17506
17506
|
jsxFragment: jsxFragment$1,
|
|
17507
|
-
jsxIdentifier,
|
|
17507
|
+
jsxIdentifier: jsxIdentifier$1,
|
|
17508
17508
|
jsxMemberExpression,
|
|
17509
17509
|
jsxNamespacedName,
|
|
17510
17510
|
jsxOpeningElement: jsxOpeningElement$1,
|
|
@@ -17558,7 +17558,7 @@ var b = /* @__PURE__ */Object.freeze({
|
|
|
17558
17558
|
spreadElement: spreadElement$1,
|
|
17559
17559
|
spreadProperty: SpreadProperty,
|
|
17560
17560
|
staticBlock: staticBlock$1,
|
|
17561
|
-
stringLiteral: stringLiteral$
|
|
17561
|
+
stringLiteral: stringLiteral$6,
|
|
17562
17562
|
stringLiteralTypeAnnotation,
|
|
17563
17563
|
stringTypeAnnotation,
|
|
17564
17564
|
super: _super,
|
|
@@ -17963,7 +17963,7 @@ function cleanJSXElementLiteralChild(child, args) {
|
|
|
17963
17963
|
}
|
|
17964
17964
|
|
|
17965
17965
|
if (str)
|
|
17966
|
-
args.push(inherits(stringLiteral$
|
|
17966
|
+
args.push(inherits(stringLiteral$6(str), child));
|
|
17967
17967
|
}
|
|
17968
17968
|
|
|
17969
17969
|
function buildChildren(node) {
|
|
@@ -19756,7 +19756,7 @@ function toBindingIdentifierName(name) {
|
|
|
19756
19756
|
|
|
19757
19757
|
function toComputedKey(node, key = node.key || node.property) {
|
|
19758
19758
|
if (!node.computed && isIdentifier$g(key))
|
|
19759
|
-
key = stringLiteral$
|
|
19759
|
+
key = stringLiteral$6(key.name);
|
|
19760
19760
|
|
|
19761
19761
|
return key;
|
|
19762
19762
|
}
|
|
@@ -19966,7 +19966,7 @@ function valueToNode(value) {
|
|
|
19966
19966
|
}
|
|
19967
19967
|
|
|
19968
19968
|
if (typeof value === 'string') {
|
|
19969
|
-
return stringLiteral$
|
|
19969
|
+
return stringLiteral$6(value);
|
|
19970
19970
|
}
|
|
19971
19971
|
|
|
19972
19972
|
if (typeof value === 'number') {
|
|
@@ -20021,12 +20021,12 @@ function valueToNode(value) {
|
|
|
20021
20021
|
if (isValidIdentifier(key)) {
|
|
20022
20022
|
if (key === '__proto__') {
|
|
20023
20023
|
computed = true;
|
|
20024
|
-
nodeKey = stringLiteral$
|
|
20024
|
+
nodeKey = stringLiteral$6(key);
|
|
20025
20025
|
} else {
|
|
20026
20026
|
nodeKey = identifier$3(key);
|
|
20027
20027
|
}
|
|
20028
20028
|
} else {
|
|
20029
|
-
nodeKey = stringLiteral$
|
|
20029
|
+
nodeKey = stringLiteral$6(key);
|
|
20030
20030
|
}
|
|
20031
20031
|
|
|
20032
20032
|
props.push(objectProperty$4(nodeKey, valueToNode(value[key]), computed));
|
|
@@ -54737,7 +54737,7 @@ const {
|
|
|
54737
54737
|
|
|
54738
54738
|
const nodeOrPath = (path) => path.node || path;
|
|
54739
54739
|
|
|
54740
|
-
function getNode(path) {
|
|
54740
|
+
function getNode$1(path) {
|
|
54741
54741
|
if (!isObjectExpression$5(path))
|
|
54742
54742
|
return nodeOrPath(path);
|
|
54743
54743
|
|
|
@@ -54752,7 +54752,7 @@ function getNode(path) {
|
|
|
54752
54752
|
|
|
54753
54753
|
traverseProperties$4.traverseProperties = (path, name, {firstLevel = false} = {}) => {
|
|
54754
54754
|
const collector = [];
|
|
54755
|
-
const node = getNode(path);
|
|
54755
|
+
const node = getNode$1(path);
|
|
54756
54756
|
|
|
54757
54757
|
const fn = collect({
|
|
54758
54758
|
name,
|
|
@@ -58296,9 +58296,9 @@ var decorator = {exports: {}};
|
|
|
58296
58296
|
var decoratorExports = decorator.exports;
|
|
58297
58297
|
decoratorExports.default;
|
|
58298
58298
|
|
|
58299
|
-
var stringLiteral$
|
|
58299
|
+
var stringLiteral$5 = {};
|
|
58300
58300
|
|
|
58301
|
-
stringLiteral$
|
|
58301
|
+
stringLiteral$5.StringLiteral = (path, {write}, semantics) => {
|
|
58302
58302
|
const {value, raw = `'${value}'`} = path.node;
|
|
58303
58303
|
|
|
58304
58304
|
if (path.parentPath.isJSXAttribute()) {
|
|
@@ -58367,7 +58367,7 @@ const {TemplateLiteral} = templateLiteral;
|
|
|
58367
58367
|
const {Identifier} = identifier$2;
|
|
58368
58368
|
|
|
58369
58369
|
const {Decorator} = decoratorExports;
|
|
58370
|
-
const {StringLiteral} = stringLiteral$
|
|
58370
|
+
const {StringLiteral} = stringLiteral$5;
|
|
58371
58371
|
const {DirectiveLiteral} = directiveLiteral$1;
|
|
58372
58372
|
const {VoidPattern} = voidPattern;
|
|
58373
58373
|
|
|
@@ -59600,11 +59600,11 @@ function isNeedIndent(path) {
|
|
|
59600
59600
|
return insideJSX || insideFn && insideCall;
|
|
59601
59601
|
}
|
|
59602
59602
|
|
|
59603
|
-
var jsxAttribute = {};
|
|
59603
|
+
var jsxAttribute$1 = {};
|
|
59604
59604
|
|
|
59605
59605
|
const {isCoupleLines: isCoupleLines$2} = is$3;
|
|
59606
59606
|
|
|
59607
|
-
jsxAttribute.JSXAttribute = {
|
|
59607
|
+
jsxAttribute$1.JSXAttribute = {
|
|
59608
59608
|
condition(path) {
|
|
59609
59609
|
return isCoupleLines$2(path.parentPath);
|
|
59610
59610
|
},
|
|
@@ -59743,7 +59743,7 @@ jsxText.JSXText = (path, {write, indent}) => {
|
|
|
59743
59743
|
};
|
|
59744
59744
|
|
|
59745
59745
|
const {JSXElement} = jsxElement;
|
|
59746
|
-
const {JSXAttribute} = jsxAttribute;
|
|
59746
|
+
const {JSXAttribute} = jsxAttribute$1;
|
|
59747
59747
|
const {isCoupleLines} = is$3;
|
|
59748
59748
|
const {JSXOpeningElement} = jsxOpeningElement;
|
|
59749
59749
|
const fragments = jsxFragment;
|
|
@@ -66672,7 +66672,7 @@ record.addDeclarationForESLint = (name, path) => {
|
|
|
66672
66672
|
const programPath = getProgramParentPath(path);
|
|
66673
66673
|
maybeInit(prefix, programPath);
|
|
66674
66674
|
|
|
66675
|
-
|
|
66675
|
+
programPath[prefix][name] = true;
|
|
66676
66676
|
};
|
|
66677
66677
|
|
|
66678
66678
|
record.setModuleType = (type, path) => {
|
|
@@ -66978,12 +66978,12 @@ var property = {};
|
|
|
66978
66978
|
const {types: types$9} = bundle;
|
|
66979
66979
|
const {
|
|
66980
66980
|
arrayExpression: arrayExpression$2,
|
|
66981
|
-
stringLiteral: stringLiteral$
|
|
66981
|
+
stringLiteral: stringLiteral$4,
|
|
66982
66982
|
objectProperty: objectProperty$2,
|
|
66983
66983
|
} = types$9;
|
|
66984
66984
|
|
|
66985
66985
|
property.createTypeProperty = (type) => {
|
|
66986
|
-
const value = stringLiteral$
|
|
66986
|
+
const value = stringLiteral$4(type);
|
|
66987
66987
|
return createProperty$1('type', value);
|
|
66988
66988
|
};
|
|
66989
66989
|
|
|
@@ -66993,17 +66993,17 @@ property.createFilesProperty = (files) => {
|
|
|
66993
66993
|
};
|
|
66994
66994
|
|
|
66995
66995
|
property.createFilenameProperty = (filename) => {
|
|
66996
|
-
const value = stringLiteral$
|
|
66996
|
+
const value = stringLiteral$4(filename);
|
|
66997
66997
|
return createProperty$1('filename', value);
|
|
66998
66998
|
};
|
|
66999
66999
|
|
|
67000
67000
|
property.createContentProperty = (content) => {
|
|
67001
|
-
const value = stringLiteral$
|
|
67001
|
+
const value = stringLiteral$4(content);
|
|
67002
67002
|
return createProperty$1('content', value);
|
|
67003
67003
|
};
|
|
67004
67004
|
|
|
67005
67005
|
function createProperty$1(name, value) {
|
|
67006
|
-
const key = stringLiteral$
|
|
67006
|
+
const key = stringLiteral$4(name);
|
|
67007
67007
|
return objectProperty$2(key, value);
|
|
67008
67008
|
}
|
|
67009
67009
|
|
|
@@ -67467,7 +67467,7 @@ const {replaceWith: replaceWith$1, getProperty: getProperty$1} = operate;
|
|
|
67467
67467
|
const {
|
|
67468
67468
|
objectExpression,
|
|
67469
67469
|
arrayExpression: arrayExpression$1,
|
|
67470
|
-
stringLiteral: stringLiteral$
|
|
67470
|
+
stringLiteral: stringLiteral$3,
|
|
67471
67471
|
isArrayExpression,
|
|
67472
67472
|
isStringLiteral,
|
|
67473
67473
|
isTemplateLiteral,
|
|
@@ -67480,22 +67480,22 @@ const isDirectory = (a) => a.endsWith('/');
|
|
|
67480
67480
|
const getType = (a) => {
|
|
67481
67481
|
const type = isDirectory(a) ? 'directory' : 'file';
|
|
67482
67482
|
|
|
67483
|
-
return objectProperty$1(stringLiteral$
|
|
67483
|
+
return objectProperty$1(stringLiteral$3('type'), stringLiteral$3(type));
|
|
67484
67484
|
};
|
|
67485
67485
|
|
|
67486
67486
|
const createFilename = (filename) => {
|
|
67487
|
-
return objectProperty$1(stringLiteral$
|
|
67487
|
+
return objectProperty$1(stringLiteral$3('filename'), stringLiteral$3(filename));
|
|
67488
67488
|
};
|
|
67489
67489
|
|
|
67490
67490
|
const getFiles = (a) => {
|
|
67491
67491
|
if (isDirectory(a))
|
|
67492
|
-
return objectProperty$1(stringLiteral$
|
|
67492
|
+
return objectProperty$1(stringLiteral$3('files'), arrayExpression$1([]));
|
|
67493
67493
|
|
|
67494
67494
|
return null;
|
|
67495
67495
|
};
|
|
67496
67496
|
|
|
67497
67497
|
const getContent = (a) => {
|
|
67498
|
-
return objectProperty$1(stringLiteral$
|
|
67498
|
+
return objectProperty$1(stringLiteral$3('content'), stringLiteral$3(a));
|
|
67499
67499
|
};
|
|
67500
67500
|
|
|
67501
67501
|
function parseContent(node, path) {
|
|
@@ -67603,7 +67603,7 @@ const {
|
|
|
67603
67603
|
} = filesystem;
|
|
67604
67604
|
|
|
67605
67605
|
const {
|
|
67606
|
-
stringLiteral: stringLiteral$
|
|
67606
|
+
stringLiteral: stringLiteral$2,
|
|
67607
67607
|
arrayExpression,
|
|
67608
67608
|
} = types$6;
|
|
67609
67609
|
|
|
@@ -67639,13 +67639,13 @@ convertFilesystemToSimpleFilesystem.fix = (root, {files}) => {
|
|
|
67639
67639
|
for (const name of names) {
|
|
67640
67640
|
if (isArray$1(name)) {
|
|
67641
67641
|
list.push(arrayExpression([
|
|
67642
|
-
stringLiteral$
|
|
67643
|
-
stringLiteral$
|
|
67642
|
+
stringLiteral$2(name[0]),
|
|
67643
|
+
stringLiteral$2(name[1]),
|
|
67644
67644
|
]));
|
|
67645
67645
|
continue;
|
|
67646
67646
|
}
|
|
67647
67647
|
|
|
67648
|
-
list.push(stringLiteral$
|
|
67648
|
+
list.push(stringLiteral$2(name));
|
|
67649
67649
|
}
|
|
67650
67650
|
|
|
67651
67651
|
replaceWith(root, arrayExpression(list));
|
|
@@ -68343,10 +68343,17 @@ var jsx = {};
|
|
|
68343
68343
|
|
|
68344
68344
|
const {setLiteralValue} = operate;
|
|
68345
68345
|
const {types: types$4} = bundle;
|
|
68346
|
-
const {
|
|
68346
|
+
const {
|
|
68347
|
+
isJSXElement,
|
|
68348
|
+
jsxAttribute,
|
|
68349
|
+
jsxIdentifier,
|
|
68350
|
+
stringLiteral: stringLiteral$1,
|
|
68351
|
+
} = types$4;
|
|
68352
|
+
|
|
68353
|
+
const getNode = (a) => a.node || a;
|
|
68347
68354
|
|
|
68348
68355
|
jsx.hasTagName = (path, name) => {
|
|
68349
|
-
const node = path
|
|
68356
|
+
const node = getNode(path);
|
|
68350
68357
|
|
|
68351
68358
|
if (!isJSXElement(path))
|
|
68352
68359
|
return false;
|
|
@@ -68368,11 +68375,7 @@ jsx.getAttributePath = (path, name) => {
|
|
|
68368
68375
|
jsx.getAttributeNode = getAttributeNode;
|
|
68369
68376
|
function getAttributeNode(path, name) {
|
|
68370
68377
|
let result = null;
|
|
68371
|
-
|
|
68372
|
-
if (!path)
|
|
68373
|
-
return result;
|
|
68374
|
-
|
|
68375
|
-
const node = path.node || path;
|
|
68378
|
+
const node = getNode(path);
|
|
68376
68379
|
const {attributes} = node.openingElement;
|
|
68377
68380
|
|
|
68378
68381
|
for (const attr of attributes) {
|
|
@@ -68399,12 +68402,26 @@ jsx.addAttributeValue = addAttributeValue;
|
|
|
68399
68402
|
function addAttributeValue(path, name, value) {
|
|
68400
68403
|
const attributeNode = getAttributeNode(path, name);
|
|
68401
68404
|
|
|
68405
|
+
if (!attributeNode)
|
|
68406
|
+
return addAttribute(path, name, value);
|
|
68407
|
+
|
|
68402
68408
|
if (attributeNode.value.value.includes(value))
|
|
68403
68409
|
return;
|
|
68404
68410
|
|
|
68405
68411
|
setLiteralValue(attributeNode.value, `${attributeNode.value.value} ${value}`);
|
|
68406
68412
|
}
|
|
68407
68413
|
|
|
68414
|
+
jsx.addAttribute = addAttribute;
|
|
68415
|
+
function addAttribute(path, name, value) {
|
|
68416
|
+
const node = getNode(path);
|
|
68417
|
+
let attributeNode = getAttributeNode(node, name);
|
|
68418
|
+
|
|
68419
|
+
if (!attributeNode) {
|
|
68420
|
+
attributeNode = jsxAttribute(jsxIdentifier(name), stringLiteral$1(value));
|
|
68421
|
+
node.openingElement.attributes.push(attributeNode);
|
|
68422
|
+
}
|
|
68423
|
+
}
|
|
68424
|
+
|
|
68408
68425
|
jsx.removeAttributeValue = removeAttributeValue;
|
|
68409
68426
|
function removeAttributeValue(path, name, attributeValue) {
|
|
68410
68427
|
if (!path)
|
|
@@ -68415,15 +68432,22 @@ function removeAttributeValue(path, name, attributeValue) {
|
|
|
68415
68432
|
|
|
68416
68433
|
const {value} = classAttribute.value;
|
|
68417
68434
|
|
|
68418
|
-
if (value.includes(attributeValue))
|
|
68419
|
-
|
|
68435
|
+
if (!value.includes(attributeValue))
|
|
68436
|
+
return;
|
|
68437
|
+
|
|
68438
|
+
const newValue = value
|
|
68439
|
+
.replace(RegExp(`\\s?${attributeValue}`), '')
|
|
68440
|
+
.trim();
|
|
68441
|
+
setLiteralValue(classAttribute.value, newValue);
|
|
68420
68442
|
}
|
|
68421
68443
|
|
|
68422
|
-
jsx.setAttributeValue = (
|
|
68423
|
-
const attributeNode = getAttributeNode(
|
|
68444
|
+
jsx.setAttributeValue = (path, name, value) => {
|
|
68445
|
+
const attributeNode = getAttributeNode(path, name);
|
|
68446
|
+
|
|
68447
|
+
if (!attributeNode)
|
|
68448
|
+
return addAttribute(path, name, value);
|
|
68424
68449
|
|
|
68425
|
-
|
|
68426
|
-
setLiteralValue(attributeNode.value, value);
|
|
68450
|
+
setLiteralValue(attributeNode.value, value);
|
|
68427
68451
|
};
|
|
68428
68452
|
|
|
68429
68453
|
jsx.addClassName = (path, name) => {
|