@putout/bundle 3.19.0 → 3.19.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 CHANGED
@@ -9437,7 +9437,7 @@ __export(lib_exports, {
9437
9437
  return tsUndefinedKeyword;
9438
9438
  },
9439
9439
  TSUnionType: function() {
9440
- return tsUnionType;
9440
+ return tsUnionType$1;
9441
9441
  },
9442
9442
  TSUnknownKeyword: function() {
9443
9443
  return tsUnknownKeyword;
@@ -11171,7 +11171,7 @@ __export(lib_exports, {
11171
11171
  return isJSX;
11172
11172
  },
11173
11173
  isJSXAttribute: function() {
11174
- return isJSXAttribute$2;
11174
+ return isJSXAttribute$3;
11175
11175
  },
11176
11176
  isJSXClosingElement: function() {
11177
11177
  return isJSXClosingElement;
@@ -11192,7 +11192,7 @@ __export(lib_exports, {
11192
11192
  return isJSXFragment;
11193
11193
  },
11194
11194
  isJSXIdentifier: function() {
11195
- return isJSXIdentifier$1;
11195
+ return isJSXIdentifier$3;
11196
11196
  },
11197
11197
  isJSXMemberExpression: function() {
11198
11198
  return isJSXMemberExpression;
@@ -12233,7 +12233,7 @@ __export(lib_exports, {
12233
12233
  return tsUndefinedKeyword;
12234
12234
  },
12235
12235
  tsUnionType: function() {
12236
- return tsUnionType;
12236
+ return tsUnionType$1;
12237
12237
  },
12238
12238
  tsUnknownKeyword: function() {
12239
12239
  return tsUnknownKeyword;
@@ -14418,7 +14418,7 @@ function isOptionalIndexedAccessType(node, opts) {
14418
14418
  if (node.type !== "OptionalIndexedAccessType") return false;
14419
14419
  return opts == null || shallowEqual(node, opts);
14420
14420
  }
14421
- function isJSXAttribute$2(node, opts) {
14421
+ function isJSXAttribute$3(node, opts) {
14422
14422
  if (!node) return false;
14423
14423
  if (node.type !== "JSXAttribute") return false;
14424
14424
  return opts == null || shallowEqual(node, opts);
@@ -14448,7 +14448,7 @@ function isJSXSpreadChild(node, opts) {
14448
14448
  if (node.type !== "JSXSpreadChild") return false;
14449
14449
  return opts == null || shallowEqual(node, opts);
14450
14450
  }
14451
- function isJSXIdentifier$1(node, opts) {
14451
+ function isJSXIdentifier$3(node, opts) {
14452
14452
  if (!node) return false;
14453
14453
  if (node.type !== "JSXIdentifier") return false;
14454
14454
  return opts == null || shallowEqual(node, opts);
@@ -23458,7 +23458,7 @@ function tsNamedTupleMember$1(label, elementType) {
23458
23458
  validate$4(defs.optional, node, "optional", optional);
23459
23459
  return node;
23460
23460
  }
23461
- function tsUnionType(types2) {
23461
+ function tsUnionType$1(types2) {
23462
23462
  var node = {
23463
23463
  type: "TSUnionType",
23464
23464
  types: types2
@@ -25026,7 +25026,7 @@ function createTSUnionType(typeAnnotations) {
25026
25026
  if (flattened.length === 1) {
25027
25027
  return flattened[0];
25028
25028
  } else {
25029
- return tsUnionType(flattened);
25029
+ return tsUnionType$1(flattened);
25030
25030
  }
25031
25031
  }
25032
25032
  function buildUndefinedNode() {
@@ -49874,7 +49874,7 @@ function TSNamedTupleMember$1(node) {
49874
49874
  this.space();
49875
49875
  this.print(node.elementType);
49876
49876
  }
49877
- function TSUnionType(node) {
49877
+ function TSUnionType$2(node) {
49878
49878
  tsPrintUnionOrIntersectionType(this, node, "|");
49879
49879
  }
49880
49880
  function TSIntersectionType$1(node) {
@@ -50460,7 +50460,7 @@ var generatorFunctions = /* @__PURE__ */ Object.freeze({
50460
50460
  TSTypeQuery: TSTypeQuery,
50461
50461
  TSTypeReference: TSTypeReference$1,
50462
50462
  TSUndefinedKeyword: TSUndefinedKeyword,
50463
- TSUnionType: TSUnionType,
50463
+ TSUnionType: TSUnionType$2,
50464
50464
  TSUnknownKeyword: TSUnknownKeyword,
50465
50465
  TSVoidKeyword: TSVoidKeyword,
50466
50466
  TaggedTemplateExpression: TaggedTemplateExpression$1,
@@ -80040,7 +80040,7 @@ function isParens$5(path) {
80040
80040
 
80041
80041
  var objectProperty = {};
80042
80042
 
80043
- var concatanate$1 = {};
80043
+ var concatenate$1 = {};
80044
80044
 
80045
80045
  const {
80046
80046
  isStringLiteral: isStringLiteral$7,
@@ -80055,7 +80055,7 @@ const isStringLike = (a) => {
80055
80055
  return isTemplateLiteral$3(a);
80056
80056
  };
80057
80057
 
80058
- concatanate$1.isConcatenation = (path) => {
80058
+ concatenate$1.isConcatenation = (path) => {
80059
80059
  const {parentPath} = path;
80060
80060
  const {operator} = path.node;
80061
80061
 
@@ -80077,7 +80077,7 @@ concatanate$1.isConcatenation = (path) => {
80077
80077
  return isBinaryExpression(left) && isStringLike(right);
80078
80078
  };
80079
80079
 
80080
- concatanate$1.concatanate = (path, {print, indent}) => {
80080
+ concatenate$1.concatenate = (path, {print, indent}) => {
80081
80081
  if (!path.parentPath.isBinaryExpression()) {
80082
80082
  indent.inc();
80083
80083
  print.breakline();
@@ -80093,7 +80093,7 @@ concatanate$1.concatanate = (path, {print, indent}) => {
80093
80093
  indent.dec();
80094
80094
  };
80095
80095
 
80096
- const {isConcatenation: isConcatenation$2} = concatanate$1;
80096
+ const {isConcatenation: isConcatenation$2} = concatenate$1;
80097
80097
  const {isOneLine} = objectExpression;
80098
80098
  const {printKey: printKey$4} = printKey$7;
80099
80099
 
@@ -80643,7 +80643,8 @@ const {
80643
80643
  isClassMethod,
80644
80644
  isTemplateLiteral: isTemplateLiteral$2,
80645
80645
  isJSXText: isJSXText$3,
80646
- isJSXAttribute: isJSXAttribute$1,
80646
+ isJSXAttribute: isJSXAttribute$2,
80647
+ isJSXIdentifier: isJSXIdentifier$2,
80647
80648
  isTSTypeReference: isTSTypeReference$2,
80648
80649
  isTSTypeParameter,
80649
80650
  } = types$q;
@@ -80656,6 +80657,9 @@ function extract$5(node) {
80656
80657
  if (isIdentifier$7(node))
80657
80658
  return node.name;
80658
80659
 
80660
+ if (isJSXIdentifier$2(node))
80661
+ return node.name;
80662
+
80659
80663
  if (isRegExpLiteral$1(node))
80660
80664
  return node.pattern;
80661
80665
 
@@ -80677,7 +80681,7 @@ function extract$5(node) {
80677
80681
  if (isJSXText$3(node))
80678
80682
  return node.value;
80679
80683
 
80680
- if (isJSXAttribute$1(node))
80684
+ if (isJSXAttribute$2(node))
80681
80685
  return node.name.name;
80682
80686
 
80683
80687
  if (isClassMethod(node))
@@ -80697,6 +80701,7 @@ function extract$5(node) {
80697
80701
  'RegExpLiteral',
80698
80702
  'ArrayExpression',
80699
80703
  'MemberExpression',
80704
+ 'JSXIdentifier',
80700
80705
  'JSXAttribute',
80701
80706
  'JSXText',
80702
80707
  'TSTypeParameter',
@@ -82149,9 +82154,9 @@ maybeSpace$1.maybeSpace = (path, {print}) => {
82149
82154
  };
82150
82155
 
82151
82156
  const {
82152
- concatanate,
82157
+ concatenate,
82153
82158
  isConcatenation: isConcatenation$1,
82154
- } = concatanate$1;
82159
+ } = concatenate$1;
82155
82160
 
82156
82161
  const {maybeSpace} = maybeSpace$1;
82157
82162
  const {isParens: isParens$2} = parens;
@@ -82186,7 +82191,7 @@ const BinaryExpression$1 = {
82186
82191
  }
82187
82192
 
82188
82193
  if (isConcatenation$1(path))
82189
- return concatanate(path, {
82194
+ return concatenate(path, {
82190
82195
  print,
82191
82196
  indent,
82192
82197
  maybe,
@@ -82660,7 +82665,7 @@ const {hasPrevNewline: hasPrevNewline$2} = mark;
82660
82665
  const {isExportDeclaration: isExportDeclaration$3} = bundle.types;
82661
82666
  const {maybeSpaceAfterKeyword: maybeSpaceAfterKeyword$2} = maybeSpaceAfterKeyword$3;
82662
82667
 
82663
- const {isConcatenation} = concatanate$1;
82668
+ const {isConcatenation} = concatenate$1;
82664
82669
  const {parseLeadingComments: parseLeadingComments$2} = comment;
82665
82670
  const {maybeDeclare: maybeDeclare$4} = maybeDeclare$6;
82666
82671
 
@@ -84947,6 +84952,53 @@ tsMethodSignature.TSMethodSignature = (path, printer, semantics) => {
84947
84952
  write.newline();
84948
84953
  };
84949
84954
 
84955
+ var tsUnionType = {};
84956
+
84957
+ const {
84958
+ maybeParenOpen,
84959
+ maybeParenClose,
84960
+ } = parens;
84961
+
84962
+ tsUnionType.TSUnionType = (path, printer, semantics) => {
84963
+ const types = path.get('types');
84964
+
84965
+ maybeParenOpen(path, printer);
84966
+
84967
+ if (types.length <= semantics.maxTypesInOneLine)
84968
+ printInOneLine(types, printer);
84969
+ else
84970
+ printInCoupleLines(types, printer);
84971
+
84972
+ maybeParenClose(path, printer);
84973
+ };
84974
+
84975
+ function printInOneLine(types, {traverse, write}) {
84976
+ const n = types.length - 1;
84977
+
84978
+ for (const [i, type] of types.entries()) {
84979
+ traverse(type);
84980
+
84981
+ if (i < n) {
84982
+ write.space();
84983
+ write('|');
84984
+ write.space();
84985
+ }
84986
+ }
84987
+ }
84988
+
84989
+ function printInCoupleLines(types, {traverse, write, indent}) {
84990
+ indent.inc();
84991
+
84992
+ for (const type of types) {
84993
+ write.breakline();
84994
+ write('|');
84995
+ write.space();
84996
+ traverse(type);
84997
+ }
84998
+
84999
+ indent.dec();
85000
+ }
85001
+
84950
85002
  var tsImportType = {};
84951
85003
 
84952
85004
  const {createImportExpression} = importExpression;
@@ -85055,11 +85107,7 @@ const {TSConstructorType} = tsConstructorType;
85055
85107
  const {TSCallSignatureDeclaration} = tsCallSignatureDeclaration;
85056
85108
  const {TSConstructSignatureDeclaration} = tsConstructSignatureDeclaration;
85057
85109
  const {TSMethodSignature} = tsMethodSignature;
85058
-
85059
- const {
85060
- maybeParenOpen,
85061
- maybeParenClose,
85062
- } = parens;
85110
+ const {TSUnionType} = tsUnionType;
85063
85111
 
85064
85112
  const {maybePrintTypeAnnotation} = maybeTypeAnnotation$4;
85065
85113
  const {TSImportType} = tsImportType;
@@ -85081,6 +85129,7 @@ var typescript$1 = {
85081
85129
  TSModuleBlock,
85082
85130
  TSIntersectionType,
85083
85131
  TSImportType,
85132
+ TSUnionType,
85084
85133
  TSBigIntKeyword(path, {write}) {
85085
85134
  write('bigint');
85086
85135
  },
@@ -85153,26 +85202,6 @@ var typescript$1 = {
85153
85202
  print(' satisfies ');
85154
85203
  print('__typeAnnotation');
85155
85204
  },
85156
- TSUnionType(path, printer) {
85157
- const {traverse, write} = printer;
85158
-
85159
- const types = path.get('types');
85160
- const n = types.length - 1;
85161
-
85162
- maybeParenOpen(path, printer);
85163
-
85164
- for (const [i, type] of types.entries()) {
85165
- traverse(type);
85166
-
85167
- if (i < n) {
85168
- write.space();
85169
- write('|');
85170
- write.space();
85171
- }
85172
- }
85173
-
85174
- maybeParenClose(path, printer);
85175
- },
85176
85205
  TSNumberKeyword(path, {write}) {
85177
85206
  write('number');
85178
85207
  },
@@ -85722,6 +85751,7 @@ function initSemantics(semantics = {}) {
85722
85751
  maxSpecifiersInOneLine: 2,
85723
85752
  maxElementsInOneLine: 5,
85724
85753
  maxVariablesInOneLine: 4,
85754
+ maxTypesInOneLine: 3,
85725
85755
  trailingComma: true,
85726
85756
  encodeSingleQuote: true,
85727
85757
  encodeDoubleQuote: false,
@@ -114820,8 +114850,8 @@ const {
114820
114850
  isExportSpecifier,
114821
114851
  isRegExpLiteral,
114822
114852
  isJSXText: isJSXText$2,
114823
- isJSXIdentifier,
114824
- isJSXAttribute,
114853
+ isJSXIdentifier: isJSXIdentifier$1,
114854
+ isJSXAttribute: isJSXAttribute$1,
114825
114855
  isTSTypeReference: isTSTypeReference$1,
114826
114856
  isTSTypeParameterDeclaration,
114827
114857
  } = types$f;
@@ -115002,10 +115032,10 @@ is$2.isJSXChildren = (a) => {
115002
115032
  is$2.isJSXAttributes = (a) => {
115003
115033
  const b = !isArray$6(a) ? a : a[0];
115004
115034
 
115005
- if (!isJSXAttribute(b))
115035
+ if (!isJSXAttribute$1(b))
115006
115036
  return false;
115007
115037
 
115008
- return isJSXIdentifier(b.name, {
115038
+ return isJSXIdentifier$1(b.name, {
115009
115039
  name: JSX_ATTRIBUTES,
115010
115040
  });
115011
115041
  };
@@ -115139,7 +115169,7 @@ is$2.isLinkedNode = (a) => {
115139
115169
  if (isJSXText$2(a) && LINKED_NODE.test(a.value))
115140
115170
  return true;
115141
115171
 
115142
- if (isJSXIdentifier(a) && LINKED_NODE.test(a.name))
115172
+ if (isJSXIdentifier$1(a) && LINKED_NODE.test(a.name))
115143
115173
  return true;
115144
115174
 
115145
115175
  if (isTemplateElement$2(a) && LINKED_NODE.test(a.value.raw))
@@ -115188,6 +115218,7 @@ const {
115188
115218
  isIdentifier: isIdentifier$3,
115189
115219
  isStatement: isStatement$1,
115190
115220
  isJSXElement,
115221
+ isJSXAttribute,
115191
115222
  isStringLiteral: isStringLiteral$3,
115192
115223
  isTemplateLiteral: isTemplateLiteral$1,
115193
115224
  TemplateElement,
@@ -115231,12 +115262,15 @@ function findVarsWays$2(node) {
115231
115262
 
115232
115263
  traverse$7(node, {
115233
115264
  noScope: true,
115234
- 'Identifier|BooleanLiteral|StringLiteral|TemplateElement|RegExpLiteral|JSXText|JSXAttribute|TSTypeReference|TSTypeParameter'(path) {
115265
+ 'Identifier|JSXIdentifier|BooleanLiteral|StringLiteral|TemplateElement|RegExpLiteral|JSXText|JSXAttribute|TSTypeReference|TSTypeParameter'(path) {
115235
115266
  if (isInsideTypeReference(path))
115236
115267
  return;
115237
115268
 
115238
115269
  const {node} = path;
115239
115270
 
115271
+ if (isJSXAttribute(path.parentPath) && path.parentPath.node.name === node)
115272
+ return;
115273
+
115240
115274
  const way = [];
115241
115275
  const name = extract(node);
115242
115276
 
@@ -115394,13 +115428,14 @@ const {
115394
115428
  isTemplateElement: isTemplateElement$1,
115395
115429
  isTSTypeReference,
115396
115430
  isJSXText: isJSXText$1,
115431
+ isJSXIdentifier,
115397
115432
  } = types$d;
115398
115433
 
115399
115434
  const parseName = (node) => {
115400
115435
  node = node[0] || node;
115401
115436
  const {name, value} = node;
115402
115437
 
115403
- if (isIdentifier$2(node))
115438
+ if (isIdentifier$2(node) || isJSXIdentifier(node))
115404
115439
  return name;
115405
115440
 
115406
115441
  if (isLiteral(node))
@@ -115414,6 +115449,8 @@ const parseName = (node) => {
115414
115449
 
115415
115450
  if (isJSXText$1(node))
115416
115451
  return node.value;
115452
+
115453
+ throw Error(`☝️ Looks like type of node '${node.type}' not supported by 'compare -> link -> parseName()'`);
115417
115454
  };
115418
115455
 
115419
115456
  link$1.exports = ({add, value, nodeValue, templateStore}) => {
@@ -115603,7 +115640,9 @@ function compareTemplateElements(node, template) {
115603
115640
  }
115604
115641
 
115605
115642
  function linkNodes(node, template, {add, templateStore}) {
115606
- if (node && isLinkedNode$1(template) || isLinkedArgs(template) || isLinkedId$1(node, template) || isLinkedBool(node, template))
115643
+ const is = node && (isLinkedNode$1(template) || isLinkedArgs(template) || isLinkedId$1(node, template) || isLinkedBool(node, template));
115644
+
115645
+ if (is)
115607
115646
  return link({
115608
115647
  add,
115609
115648
  value: template,