@putout/bundle 4.7.4 → 4.7.6

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 CHANGED
@@ -4381,14 +4381,14 @@ __export(lib_exports, {
4381
4381
  isWhileStatement: () => isWhileStatement,
4382
4382
  isWithStatement: () => isWithStatement,
4383
4383
  isYieldExpression: () => isYieldExpression,
4384
- jsxAttribute: () => jsxAttribute$1,
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$5,
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$5(value) {
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$1(name, value = null) {
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$1,
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$5,
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$5(str), child));
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$5(key.name);
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$5(value);
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$5(key);
20024
+ nodeKey = stringLiteral$6(key);
20025
20025
  } else {
20026
20026
  nodeKey = identifier$3(key);
20027
20027
  }
20028
20028
  } else {
20029
- nodeKey = stringLiteral$5(key);
20029
+ nodeKey = stringLiteral$6(key);
20030
20030
  }
20031
20031
 
20032
20032
  props.push(objectProperty$4(nodeKey, valueToNode(value[key]), computed));
@@ -41744,8 +41744,6 @@ function DeclareExportDeclaration2(node) {
41744
41744
  this.word('default');
41745
41745
  this.space();
41746
41746
  }
41747
-
41748
- FlowExportDeclaration.call(this, node);
41749
41747
  }
41750
41748
 
41751
41749
  function DeclareExportAllDeclaration2(node) {
@@ -41848,35 +41846,6 @@ function EnumStringMember2(node) {
41848
41846
  enumInitializedMember(this, node);
41849
41847
  }
41850
41848
 
41851
- function FlowExportDeclaration(node) {
41852
- if (node.declaration) {
41853
- const declar = node.declaration;
41854
- this.print(declar);
41855
-
41856
- if (!isStatement$12(declar))
41857
- this.semicolon();
41858
- } else {
41859
- this.tokenChar(123);
41860
-
41861
- if (node.specifiers.length) {
41862
- this.space();
41863
- this.printList(node.specifiers);
41864
- this.space();
41865
- }
41866
-
41867
- this.tokenChar(125);
41868
-
41869
- if (node.source) {
41870
- this.space();
41871
- this.word('from');
41872
- this.space();
41873
- this.print(node.source);
41874
- }
41875
-
41876
- this.semicolon();
41877
- }
41878
- }
41879
-
41880
41849
  function ExistsTypeAnnotation2() {
41881
41850
  this.tokenChar(42);
41882
41851
  }
@@ -54737,7 +54706,7 @@ const {
54737
54706
 
54738
54707
  const nodeOrPath = (path) => path.node || path;
54739
54708
 
54740
- function getNode(path) {
54709
+ function getNode$1(path) {
54741
54710
  if (!isObjectExpression$5(path))
54742
54711
  return nodeOrPath(path);
54743
54712
 
@@ -54752,7 +54721,7 @@ function getNode(path) {
54752
54721
 
54753
54722
  traverseProperties$4.traverseProperties = (path, name, {firstLevel = false} = {}) => {
54754
54723
  const collector = [];
54755
- const node = getNode(path);
54724
+ const node = getNode$1(path);
54756
54725
 
54757
54726
  const fn = collect({
54758
54727
  name,
@@ -58296,9 +58265,9 @@ var decorator = {exports: {}};
58296
58265
  var decoratorExports = decorator.exports;
58297
58266
  decoratorExports.default;
58298
58267
 
58299
- var stringLiteral$4 = {};
58268
+ var stringLiteral$5 = {};
58300
58269
 
58301
- stringLiteral$4.StringLiteral = (path, {write}, semantics) => {
58270
+ stringLiteral$5.StringLiteral = (path, {write}, semantics) => {
58302
58271
  const {value, raw = `'${value}'`} = path.node;
58303
58272
 
58304
58273
  if (path.parentPath.isJSXAttribute()) {
@@ -58367,7 +58336,7 @@ const {TemplateLiteral} = templateLiteral;
58367
58336
  const {Identifier} = identifier$2;
58368
58337
 
58369
58338
  const {Decorator} = decoratorExports;
58370
- const {StringLiteral} = stringLiteral$4;
58339
+ const {StringLiteral} = stringLiteral$5;
58371
58340
  const {DirectiveLiteral} = directiveLiteral$1;
58372
58341
  const {VoidPattern} = voidPattern;
58373
58342
 
@@ -59600,11 +59569,11 @@ function isNeedIndent(path) {
59600
59569
  return insideJSX || insideFn && insideCall;
59601
59570
  }
59602
59571
 
59603
- var jsxAttribute = {};
59572
+ var jsxAttribute$1 = {};
59604
59573
 
59605
59574
  const {isCoupleLines: isCoupleLines$2} = is$3;
59606
59575
 
59607
- jsxAttribute.JSXAttribute = {
59576
+ jsxAttribute$1.JSXAttribute = {
59608
59577
  condition(path) {
59609
59578
  return isCoupleLines$2(path.parentPath);
59610
59579
  },
@@ -59743,7 +59712,7 @@ jsxText.JSXText = (path, {write, indent}) => {
59743
59712
  };
59744
59713
 
59745
59714
  const {JSXElement} = jsxElement;
59746
- const {JSXAttribute} = jsxAttribute;
59715
+ const {JSXAttribute} = jsxAttribute$1;
59747
59716
  const {isCoupleLines} = is$3;
59748
59717
  const {JSXOpeningElement} = jsxOpeningElement;
59749
59718
  const fragments = jsxFragment;
@@ -66672,7 +66641,7 @@ record.addDeclarationForESLint = (name, path) => {
66672
66641
  const programPath = getProgramParentPath(path);
66673
66642
  maybeInit(prefix, programPath);
66674
66643
 
66675
- return programPath[prefix][name] = true;
66644
+ programPath[prefix][name] = true;
66676
66645
  };
66677
66646
 
66678
66647
  record.setModuleType = (type, path) => {
@@ -66978,12 +66947,12 @@ var property = {};
66978
66947
  const {types: types$9} = bundle;
66979
66948
  const {
66980
66949
  arrayExpression: arrayExpression$2,
66981
- stringLiteral: stringLiteral$3,
66950
+ stringLiteral: stringLiteral$4,
66982
66951
  objectProperty: objectProperty$2,
66983
66952
  } = types$9;
66984
66953
 
66985
66954
  property.createTypeProperty = (type) => {
66986
- const value = stringLiteral$3(type);
66955
+ const value = stringLiteral$4(type);
66987
66956
  return createProperty$1('type', value);
66988
66957
  };
66989
66958
 
@@ -66993,17 +66962,17 @@ property.createFilesProperty = (files) => {
66993
66962
  };
66994
66963
 
66995
66964
  property.createFilenameProperty = (filename) => {
66996
- const value = stringLiteral$3(filename);
66965
+ const value = stringLiteral$4(filename);
66997
66966
  return createProperty$1('filename', value);
66998
66967
  };
66999
66968
 
67000
66969
  property.createContentProperty = (content) => {
67001
- const value = stringLiteral$3(content);
66970
+ const value = stringLiteral$4(content);
67002
66971
  return createProperty$1('content', value);
67003
66972
  };
67004
66973
 
67005
66974
  function createProperty$1(name, value) {
67006
- const key = stringLiteral$3(name);
66975
+ const key = stringLiteral$4(name);
67007
66976
  return objectProperty$2(key, value);
67008
66977
  }
67009
66978
 
@@ -67467,7 +67436,7 @@ const {replaceWith: replaceWith$1, getProperty: getProperty$1} = operate;
67467
67436
  const {
67468
67437
  objectExpression,
67469
67438
  arrayExpression: arrayExpression$1,
67470
- stringLiteral: stringLiteral$2,
67439
+ stringLiteral: stringLiteral$3,
67471
67440
  isArrayExpression,
67472
67441
  isStringLiteral,
67473
67442
  isTemplateLiteral,
@@ -67480,22 +67449,22 @@ const isDirectory = (a) => a.endsWith('/');
67480
67449
  const getType = (a) => {
67481
67450
  const type = isDirectory(a) ? 'directory' : 'file';
67482
67451
 
67483
- return objectProperty$1(stringLiteral$2('type'), stringLiteral$2(type));
67452
+ return objectProperty$1(stringLiteral$3('type'), stringLiteral$3(type));
67484
67453
  };
67485
67454
 
67486
67455
  const createFilename = (filename) => {
67487
- return objectProperty$1(stringLiteral$2('filename'), stringLiteral$2(filename));
67456
+ return objectProperty$1(stringLiteral$3('filename'), stringLiteral$3(filename));
67488
67457
  };
67489
67458
 
67490
67459
  const getFiles = (a) => {
67491
67460
  if (isDirectory(a))
67492
- return objectProperty$1(stringLiteral$2('files'), arrayExpression$1([]));
67461
+ return objectProperty$1(stringLiteral$3('files'), arrayExpression$1([]));
67493
67462
 
67494
67463
  return null;
67495
67464
  };
67496
67465
 
67497
67466
  const getContent = (a) => {
67498
- return objectProperty$1(stringLiteral$2('content'), stringLiteral$2(a));
67467
+ return objectProperty$1(stringLiteral$3('content'), stringLiteral$3(a));
67499
67468
  };
67500
67469
 
67501
67470
  function parseContent(node, path) {
@@ -67603,7 +67572,7 @@ const {
67603
67572
  } = filesystem;
67604
67573
 
67605
67574
  const {
67606
- stringLiteral: stringLiteral$1,
67575
+ stringLiteral: stringLiteral$2,
67607
67576
  arrayExpression,
67608
67577
  } = types$6;
67609
67578
 
@@ -67639,13 +67608,13 @@ convertFilesystemToSimpleFilesystem.fix = (root, {files}) => {
67639
67608
  for (const name of names) {
67640
67609
  if (isArray$1(name)) {
67641
67610
  list.push(arrayExpression([
67642
- stringLiteral$1(name[0]),
67643
- stringLiteral$1(name[1]),
67611
+ stringLiteral$2(name[0]),
67612
+ stringLiteral$2(name[1]),
67644
67613
  ]));
67645
67614
  continue;
67646
67615
  }
67647
67616
 
67648
- list.push(stringLiteral$1(name));
67617
+ list.push(stringLiteral$2(name));
67649
67618
  }
67650
67619
 
67651
67620
  replaceWith(root, arrayExpression(list));
@@ -68343,10 +68312,17 @@ var jsx = {};
68343
68312
 
68344
68313
  const {setLiteralValue} = operate;
68345
68314
  const {types: types$4} = bundle;
68346
- const {isJSXElement} = types$4;
68315
+ const {
68316
+ isJSXElement,
68317
+ jsxAttribute,
68318
+ jsxIdentifier,
68319
+ stringLiteral: stringLiteral$1,
68320
+ } = types$4;
68321
+
68322
+ const getNode = (a) => a.node || a;
68347
68323
 
68348
68324
  jsx.hasTagName = (path, name) => {
68349
- const node = path.node || path;
68325
+ const node = getNode(path);
68350
68326
 
68351
68327
  if (!isJSXElement(path))
68352
68328
  return false;
@@ -68368,11 +68344,7 @@ jsx.getAttributePath = (path, name) => {
68368
68344
  jsx.getAttributeNode = getAttributeNode;
68369
68345
  function getAttributeNode(path, name) {
68370
68346
  let result = null;
68371
-
68372
- if (!path)
68373
- return result;
68374
-
68375
- const node = path.node || path;
68347
+ const node = getNode(path);
68376
68348
  const {attributes} = node.openingElement;
68377
68349
 
68378
68350
  for (const attr of attributes) {
@@ -68399,12 +68371,26 @@ jsx.addAttributeValue = addAttributeValue;
68399
68371
  function addAttributeValue(path, name, value) {
68400
68372
  const attributeNode = getAttributeNode(path, name);
68401
68373
 
68374
+ if (!attributeNode)
68375
+ return addAttribute(path, name, value);
68376
+
68402
68377
  if (attributeNode.value.value.includes(value))
68403
68378
  return;
68404
68379
 
68405
68380
  setLiteralValue(attributeNode.value, `${attributeNode.value.value} ${value}`);
68406
68381
  }
68407
68382
 
68383
+ jsx.addAttribute = addAttribute;
68384
+ function addAttribute(path, name, value) {
68385
+ const node = getNode(path);
68386
+ let attributeNode = getAttributeNode(node, name);
68387
+
68388
+ if (!attributeNode) {
68389
+ attributeNode = jsxAttribute(jsxIdentifier(name), stringLiteral$1(value));
68390
+ node.openingElement.attributes.push(attributeNode);
68391
+ }
68392
+ }
68393
+
68408
68394
  jsx.removeAttributeValue = removeAttributeValue;
68409
68395
  function removeAttributeValue(path, name, attributeValue) {
68410
68396
  if (!path)
@@ -68415,15 +68401,22 @@ function removeAttributeValue(path, name, attributeValue) {
68415
68401
 
68416
68402
  const {value} = classAttribute.value;
68417
68403
 
68418
- if (value.includes(attributeValue))
68419
- setLiteralValue(classAttribute.value, value.replace(RegExp(`\\s?${attributeValue}`), ''));
68404
+ if (!value.includes(attributeValue))
68405
+ return;
68406
+
68407
+ const newValue = value
68408
+ .replace(RegExp(`\\s?${attributeValue}`), '')
68409
+ .trim();
68410
+ setLiteralValue(classAttribute.value, newValue);
68420
68411
  }
68421
68412
 
68422
- jsx.setAttributeValue = (node, name, value) => {
68423
- const attributeNode = getAttributeNode(node, name);
68413
+ jsx.setAttributeValue = (path, name, value) => {
68414
+ const attributeNode = getAttributeNode(path, name);
68415
+
68416
+ if (!attributeNode)
68417
+ return addAttribute(path, name, value);
68424
68418
 
68425
- if (attributeNode)
68426
- setLiteralValue(attributeNode.value, value);
68419
+ setLiteralValue(attributeNode.value, value);
68427
68420
  };
68428
68421
 
68429
68422
  jsx.addClassName = (path, name) => {