html-minifier-next 1.1.5 → 1.2.0

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.
@@ -9,7 +9,11 @@ function getAugmentedNamespace(n) {
9
9
  var f = n.default;
10
10
  if (typeof f == "function") {
11
11
  var a = function a () {
12
- if (this instanceof a) {
12
+ var isInstance = false;
13
+ try {
14
+ isInstance = this instanceof a;
15
+ } catch {}
16
+ if (isInstance) {
13
17
  return Reflect.construct(f, arguments, this.constructor);
14
18
  }
15
19
  return f.apply(this, arguments);
@@ -26509,7 +26513,6 @@ ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
26509
26513
 
26510
26514
  var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
26511
26515
 
26512
- var RE_NUM_LITERAL = /[0-9a-f]/i;
26513
26516
  var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
26514
26517
  var RE_OCT_NUMBER = /^0[0-7]+$/;
26515
26518
  var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
@@ -26874,15 +26877,16 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
26874
26877
  return after_e;
26875
26878
  case (after_e = false, 46): // .
26876
26879
  return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
26877
- }
26878
-
26879
- if (ch === "n") {
26880
+ case 110: // n
26880
26881
  is_big_int = true;
26881
-
26882
26882
  return true;
26883
26883
  }
26884
26884
 
26885
- return RE_NUM_LITERAL.test(ch);
26885
+ return (
26886
+ code >= 48 && code <= 57 // 0-9
26887
+ || code >= 97 && code <= 102 // a-f
26888
+ || code >= 65 && code <= 70 // A-F
26889
+ );
26886
26890
  });
26887
26891
  if (prefix) num = prefix + num;
26888
26892
 
@@ -26899,7 +26903,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
26899
26903
  }
26900
26904
  num = num.replace(/_/g, "");
26901
26905
  }
26902
- if (num.endsWith("n")) {
26906
+ if (is_big_int) {
26903
26907
  const without_n = num.slice(0, -1);
26904
26908
  const allow_e = RE_HEX_NUMBER.test(without_n);
26905
26909
  const valid = parse_js_number(without_n, allow_e);
@@ -27074,7 +27078,24 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
27074
27078
  return next_token;
27075
27079
  });
27076
27080
 
27077
- var read_name = with_eof_error("Unterminated identifier name", function() {
27081
+ var read_name = function () {
27082
+ let start = S.pos, end = start - 1, ch = "c";
27083
+
27084
+ while (
27085
+ (ch = S.text.charAt(++end))
27086
+ && (ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z")
27087
+ );
27088
+
27089
+ if (end > start + 1 && ch && ch !== "\\" && !is_identifier_char(ch)) {
27090
+ S.pos += end - start;
27091
+ S.col += end - start;
27092
+ return S.text.slice(start, S.pos);
27093
+ }
27094
+
27095
+ return read_name_hard();
27096
+ };
27097
+
27098
+ var read_name_hard = with_eof_error("Unterminated identifier name", function() {
27078
27099
  var name = [], ch, escaped = false;
27079
27100
  var read_escaped_identifier_char = function() {
27080
27101
  escaped = true;
@@ -27865,24 +27886,19 @@ function parse($TEXT, options) {
27865
27886
 
27866
27887
  var body = _function_body(is("punc", "{"), false, is_async);
27867
27888
 
27868
- var end =
27869
- body instanceof Array && body.length ? body[body.length - 1].end :
27870
- body instanceof Array ? start :
27871
- body.end;
27872
-
27873
27889
  return new AST_Arrow({
27874
27890
  start : start,
27875
- end : end,
27891
+ end : body.end,
27876
27892
  async : is_async,
27877
27893
  argnames : argnames,
27878
27894
  body : body
27879
27895
  });
27880
27896
  };
27881
27897
 
27882
- var function_ = function(ctor, is_generator_property, is_async, is_export_default) {
27898
+ var function_ = function(ctor, is_generator, is_async, is_export_default) {
27883
27899
  var in_statement = ctor === AST_Defun;
27884
- var is_generator = is("operator", "*");
27885
- if (is_generator) {
27900
+ if (is("operator", "*")) {
27901
+ is_generator = true;
27886
27902
  next();
27887
27903
  }
27888
27904
 
@@ -27899,7 +27915,7 @@ function parse($TEXT, options) {
27899
27915
  unexpected(prev());
27900
27916
 
27901
27917
  var args = [];
27902
- var body = _function_body(true, is_generator || is_generator_property, is_async, name, args);
27918
+ var body = _function_body(true, is_generator, is_async, name, args);
27903
27919
  return new ctor({
27904
27920
  start : args.start,
27905
27921
  end : body.end,
@@ -28531,7 +28547,12 @@ function parse($TEXT, options) {
28531
28547
  });
28532
28548
  break;
28533
28549
  case "big_int":
28534
- ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
28550
+ ret = new AST_BigInt({
28551
+ start: tok,
28552
+ end: tok,
28553
+ value: tok.value,
28554
+ raw: LATEST_RAW,
28555
+ });
28535
28556
  break;
28536
28557
  case "string":
28537
28558
  ret = new AST_String({
@@ -28795,7 +28816,7 @@ function parse($TEXT, options) {
28795
28816
 
28796
28817
  // Check property and fetch value
28797
28818
  if (!is("punc", ":")) {
28798
- var concise = concise_method_or_getset(name, start);
28819
+ var concise = object_or_class_property(name, start);
28799
28820
  if (concise) {
28800
28821
  a.push(concise);
28801
28822
  continue;
@@ -28830,7 +28851,7 @@ function parse($TEXT, options) {
28830
28851
  const kv = new AST_ObjectKeyVal({
28831
28852
  start: start,
28832
28853
  quote: start.quote,
28833
- key: name instanceof AST_Node ? name : "" + name,
28854
+ key: name,
28834
28855
  value: value,
28835
28856
  end: prev()
28836
28857
  });
@@ -28841,7 +28862,7 @@ function parse($TEXT, options) {
28841
28862
  });
28842
28863
 
28843
28864
  function class_(KindOfClass, is_export_default) {
28844
- var start, method, class_name, extends_, a = [];
28865
+ var start, method, class_name, extends_, properties = [];
28845
28866
 
28846
28867
  S.input.push_directives_stack(); // Push directive stack, but not scope stack
28847
28868
  S.input.add_directive("use strict");
@@ -28870,9 +28891,9 @@ function parse($TEXT, options) {
28870
28891
  while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
28871
28892
  while (!is("punc", "}")) {
28872
28893
  start = S.token;
28873
- method = concise_method_or_getset(as_property_name(), start, true);
28894
+ method = object_or_class_property(as_property_name(), start, true);
28874
28895
  if (!method) { unexpected(); }
28875
- a.push(method);
28896
+ properties.push(method);
28876
28897
  while (is("punc", ";")) { next(); }
28877
28898
  }
28878
28899
  // mark in class feild,
@@ -28886,19 +28907,15 @@ function parse($TEXT, options) {
28886
28907
  start: start,
28887
28908
  name: class_name,
28888
28909
  extends: extends_,
28889
- properties: a,
28910
+ properties: properties,
28890
28911
  end: prev(),
28891
28912
  });
28892
28913
  }
28893
28914
 
28894
- function concise_method_or_getset(name, start, is_class) {
28895
- const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
28896
- if (typeof name === "string" || typeof name === "number") {
28897
- return new SymbolClass({
28898
- start,
28899
- name: "" + name,
28900
- end: prev()
28901
- });
28915
+ function object_or_class_property(name, start, is_class) {
28916
+ const get_symbol_ast = (name, SymbolClass) => {
28917
+ if (typeof name === "string") {
28918
+ return new SymbolClass({ start, name, end: prev() });
28902
28919
  } else if (name === null) {
28903
28920
  unexpected();
28904
28921
  }
@@ -28946,7 +28963,7 @@ function parse($TEXT, options) {
28946
28963
  ? AST_ObjectGetter
28947
28964
  : AST_ObjectSetter;
28948
28965
 
28949
- name = get_symbol_ast(name);
28966
+ name = get_symbol_ast(name, AST_SymbolMethod);
28950
28967
  return annotate(new AccessorClass({
28951
28968
  start,
28952
28969
  static: is_static,
@@ -28963,7 +28980,7 @@ function parse($TEXT, options) {
28963
28980
  return annotate(new AccessorClass({
28964
28981
  start,
28965
28982
  static: is_static,
28966
- key: get_symbol_ast(name),
28983
+ key: get_symbol_ast(name, AST_SymbolMethod),
28967
28984
  value: create_accessor(),
28968
28985
  end: prev(),
28969
28986
  }));
@@ -28971,15 +28988,13 @@ function parse($TEXT, options) {
28971
28988
  }
28972
28989
 
28973
28990
  if (is("punc", "(")) {
28974
- name = get_symbol_ast(name);
28991
+ name = get_symbol_ast(name, AST_SymbolMethod);
28975
28992
  const AST_MethodVariant = is_private
28976
28993
  ? AST_PrivateMethod
28977
28994
  : AST_ConciseMethod;
28978
28995
  var node = new AST_MethodVariant({
28979
28996
  start : start,
28980
28997
  static : is_static,
28981
- is_generator: is_generator,
28982
- async : is_async,
28983
28998
  key : name,
28984
28999
  quote : name instanceof AST_SymbolMethod ?
28985
29000
  property_token.quote : undefined,
@@ -28990,13 +29005,17 @@ function parse($TEXT, options) {
28990
29005
  }
28991
29006
 
28992
29007
  if (is_class) {
28993
- const key = get_symbol_ast(name, AST_SymbolClassProperty);
28994
- const quote = key instanceof AST_SymbolClassProperty
28995
- ? property_token.quote
28996
- : undefined;
29008
+ const AST_SymbolVariant = is_private
29009
+ ? AST_SymbolPrivateProperty
29010
+ : AST_SymbolClassProperty;
28997
29011
  const AST_ClassPropertyVariant = is_private
28998
29012
  ? AST_ClassPrivateProperty
28999
29013
  : AST_ClassProperty;
29014
+
29015
+ const key = get_symbol_ast(name, AST_SymbolVariant);
29016
+ const quote = key instanceof AST_SymbolClassProperty
29017
+ ? property_token.quote
29018
+ : undefined;
29000
29019
  if (is("operator", "=")) {
29001
29020
  next();
29002
29021
  return annotate(
@@ -29016,6 +29035,9 @@ function parse($TEXT, options) {
29016
29035
  || is("operator", "*")
29017
29036
  || is("punc", ";")
29018
29037
  || is("punc", "}")
29038
+ || is("string")
29039
+ || is("num")
29040
+ || is("big_int")
29019
29041
  ) {
29020
29042
  return annotate(
29021
29043
  new AST_ClassPropertyVariant({
@@ -29140,10 +29162,12 @@ function parse($TEXT, options) {
29140
29162
  } else {
29141
29163
  foreign_name = make_symbol(foreign_type, S.token.quote);
29142
29164
  }
29143
- } else if (is_import) {
29144
- name = new type(foreign_name);
29145
29165
  } else {
29146
- foreign_name = new foreign_type(name);
29166
+ if (is_import) {
29167
+ name = new type(foreign_name);
29168
+ } else {
29169
+ foreign_name = new foreign_type(name);
29170
+ }
29147
29171
  }
29148
29172
 
29149
29173
  return new AST_NameMapping({
@@ -29314,12 +29338,14 @@ function parse($TEXT, options) {
29314
29338
  case "name":
29315
29339
  case "privatename":
29316
29340
  case "string":
29317
- case "num":
29318
- case "big_int":
29319
29341
  case "keyword":
29320
29342
  case "atom":
29321
29343
  next();
29322
29344
  return tmp.value;
29345
+ case "num":
29346
+ case "big_int":
29347
+ next();
29348
+ return "" + tmp.value;
29323
29349
  default:
29324
29350
  unexpected(tmp);
29325
29351
  }
@@ -31949,12 +31975,10 @@ var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_Obje
31949
31975
  }
31950
31976
  }, AST_ObjectProperty);
31951
31977
 
31952
- var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator async", function AST_ConciseMethod(props) {
31978
+ var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static", function AST_ConciseMethod(props) {
31953
31979
  if (props) {
31954
31980
  this.quote = props.quote;
31955
31981
  this.static = props.static;
31956
- this.is_generator = props.is_generator;
31957
- this.async = props.async;
31958
31982
  this.key = props.key;
31959
31983
  this.value = props.value;
31960
31984
  this.start = props.start;
@@ -31967,8 +31991,6 @@ var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator asyn
31967
31991
  $propdoc: {
31968
31992
  quote: "[string|undefined] the original quote character, if any",
31969
31993
  static: "[boolean] is this method static (classes only)",
31970
- is_generator: "[boolean] is this a generator method",
31971
- async: "[boolean] is this method async",
31972
31994
  },
31973
31995
  $documentation: "An ES6 concise method inside an object or class",
31974
31996
  computed_key() {
@@ -31976,12 +31998,9 @@ var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator asyn
31976
31998
  }
31977
31999
  }, AST_ObjectProperty);
31978
32000
 
31979
- var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
32001
+ var AST_PrivateMethod = DEFNODE("PrivateMethod", "static", function AST_PrivateMethod(props) {
31980
32002
  if (props) {
31981
- this.quote = props.quote;
31982
32003
  this.static = props.static;
31983
- this.is_generator = props.is_generator;
31984
- this.async = props.async;
31985
32004
  this.key = props.key;
31986
32005
  this.value = props.value;
31987
32006
  this.start = props.start;
@@ -31991,6 +32010,9 @@ var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(
31991
32010
  this.flags = 0;
31992
32011
  }, {
31993
32012
  $documentation: "A private class method inside a class",
32013
+ $propdoc: {
32014
+ static: "[boolean] is this a static private method",
32015
+ },
31994
32016
  computed_key() {
31995
32017
  return false;
31996
32018
  },
@@ -32139,7 +32161,6 @@ var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_Cl
32139
32161
  var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
32140
32162
  if (props) {
32141
32163
  this.static = props.static;
32142
- this.quote = props.quote;
32143
32164
  this.key = props.key;
32144
32165
  this.value = props.value;
32145
32166
  this.start = props.start;
@@ -32499,12 +32520,12 @@ var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(p
32499
32520
  $documentation: "Symbol referring to an imported name",
32500
32521
  }, AST_SymbolBlockDeclaration);
32501
32522
 
32502
- var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
32523
+ var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", "quote", function AST_SymbolImportForeign(props) {
32503
32524
  if (props) {
32525
+ this.quote = props.quote;
32504
32526
  this.scope = props.scope;
32505
32527
  this.name = props.name;
32506
32528
  this.thedef = props.thedef;
32507
- this.quote = props.quote;
32508
32529
  this.start = props.start;
32509
32530
  this.end = props.end;
32510
32531
  }
@@ -32551,12 +32572,12 @@ var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
32551
32572
  $documentation: "Reference to some symbol (not definition/declaration)",
32552
32573
  }, AST_Symbol);
32553
32574
 
32554
- var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
32575
+ var AST_SymbolExport = DEFNODE("SymbolExport", "quote", function AST_SymbolExport(props) {
32555
32576
  if (props) {
32577
+ this.quote = props.quote;
32556
32578
  this.scope = props.scope;
32557
32579
  this.name = props.name;
32558
32580
  this.thedef = props.thedef;
32559
- this.quote = props.quote;
32560
32581
  this.start = props.start;
32561
32582
  this.end = props.end;
32562
32583
  }
@@ -32566,12 +32587,12 @@ var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(p
32566
32587
  $documentation: "Symbol referring to a name to export",
32567
32588
  }, AST_SymbolRef);
32568
32589
 
32569
- var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
32590
+ var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", "quote", function AST_SymbolExportForeign(props) {
32570
32591
  if (props) {
32592
+ this.quote = props.quote;
32571
32593
  this.scope = props.scope;
32572
32594
  this.name = props.name;
32573
32595
  this.thedef = props.thedef;
32574
- this.quote = props.quote;
32575
32596
  this.start = props.start;
32576
32597
  this.end = props.end;
32577
32598
  }
@@ -32686,9 +32707,10 @@ var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
32686
32707
  }
32687
32708
  }, AST_Constant);
32688
32709
 
32689
- var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
32710
+ var AST_BigInt = DEFNODE("BigInt", "value raw", function AST_BigInt(props) {
32690
32711
  if (props) {
32691
32712
  this.value = props.value;
32713
+ this.raw = props.raw;
32692
32714
  this.start = props.start;
32693
32715
  this.end = props.end;
32694
32716
  }
@@ -32697,7 +32719,8 @@ var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
32697
32719
  }, {
32698
32720
  $documentation: "A big int literal",
32699
32721
  $propdoc: {
32700
- value: "[string] big int value"
32722
+ value: "[string] big int value, represented as a string",
32723
+ raw: "[string] the original format preserved"
32701
32724
  }
32702
32725
  }, AST_Constant);
32703
32726
 
@@ -32980,6 +33003,28 @@ class TreeWalker {
32980
33003
  }
32981
33004
  }
32982
33005
 
33006
+ is_within_loop() {
33007
+ let i = this.stack.length - 1;
33008
+ let child = this.stack[i];
33009
+ while (i--) {
33010
+ const node = this.stack[i];
33011
+
33012
+ if (node instanceof AST_Lambda) return false;
33013
+ if (
33014
+ node instanceof AST_IterationStatement
33015
+ // exclude for-loop bits that only run once
33016
+ && !((node instanceof AST_For) && child === node.init)
33017
+ && !((node instanceof AST_ForIn || node instanceof AST_ForOf) && child === node.object)
33018
+ ) {
33019
+ return true;
33020
+ }
33021
+
33022
+ child = node;
33023
+ }
33024
+
33025
+ return false;
33026
+ }
33027
+
32983
33028
  find_scope() {
32984
33029
  var stack = this.stack;
32985
33030
  for (var i = stack.length; --i >= 0;) {
@@ -33357,6 +33402,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33357
33402
  body[i] = new AST_Directive({
33358
33403
  start: body[i].start,
33359
33404
  end: body[i].end,
33405
+ quote: '"',
33360
33406
  value: body[i].body.value
33361
33407
  });
33362
33408
  } else {
@@ -33480,8 +33526,8 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33480
33526
  return new AST_Defun({
33481
33527
  start: my_start_token(M),
33482
33528
  end: my_end_token(M),
33483
- name: from_moz(M.id),
33484
- argnames: M.params.map(from_moz),
33529
+ name: M.id && from_moz_symbol(AST_SymbolDefun, M.id),
33530
+ argnames: M.params.map(M => from_moz_pattern(M, AST_SymbolFunarg)),
33485
33531
  is_generator: M.generator,
33486
33532
  async: M.async,
33487
33533
  body: normalize_directives(from_moz(M.body).body)
@@ -33489,15 +33535,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33489
33535
  },
33490
33536
 
33491
33537
  FunctionExpression: function(M) {
33492
- return new AST_Function({
33493
- start: my_start_token(M),
33494
- end: my_end_token(M),
33495
- name: from_moz(M.id),
33496
- argnames: M.params.map(from_moz),
33497
- is_generator: M.generator,
33498
- async: M.async,
33499
- body: normalize_directives(from_moz(M.body).body)
33500
- });
33538
+ return from_moz_lambda(M, /*is_method=*/false);
33501
33539
  },
33502
33540
 
33503
33541
  ArrowFunctionExpression: function(M) {
@@ -33507,7 +33545,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33507
33545
  return new AST_Arrow({
33508
33546
  start: my_start_token(M),
33509
33547
  end: my_end_token(M),
33510
- argnames: M.params.map(from_moz),
33548
+ argnames: M.params.map(p => from_moz_pattern(p, AST_SymbolFunarg)),
33511
33549
  body,
33512
33550
  async: M.async,
33513
33551
  });
@@ -33536,57 +33574,48 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33536
33574
  },
33537
33575
 
33538
33576
  Property: function(M) {
33539
- var key = M.key;
33540
- var args = {
33541
- start : my_start_token(key || M.value),
33542
- end : my_end_token(M.value),
33543
- key : key.type == "Identifier" ? key.name : key.value,
33544
- value : from_moz(M.value)
33545
- };
33546
- if (M.computed) {
33547
- args.key = from_moz(M.key);
33548
- }
33549
- if (M.method) {
33550
- args.is_generator = M.value.generator;
33551
- args.async = M.value.async;
33552
- if (!M.computed) {
33553
- args.key = new AST_SymbolMethod({ name: args.key });
33554
- } else {
33555
- args.key = from_moz(M.key);
33556
- }
33557
- return new AST_ConciseMethod(args);
33558
- }
33559
- if (M.kind == "init") {
33560
- if (key.type != "Identifier" && key.type != "Literal") {
33561
- args.key = from_moz(key);
33562
- }
33577
+ if (M.kind == "init" && !M.method) {
33578
+ var args = {
33579
+ start : my_start_token(M.key || M.value),
33580
+ end : my_end_token(M.value),
33581
+ key : M.computed
33582
+ ? from_moz(M.key)
33583
+ : M.key.name || String(M.key.value),
33584
+ quote : from_moz_quote(M.key, M.computed),
33585
+ static : false, // always an object
33586
+ value : from_moz(M.value)
33587
+ };
33588
+
33563
33589
  return new AST_ObjectKeyVal(args);
33564
- }
33565
- if (typeof args.key === "string" || typeof args.key === "number") {
33566
- args.key = new AST_SymbolMethod({
33567
- name: args.key
33568
- });
33569
- }
33570
- args.value = new AST_Accessor(args.value);
33571
- if (M.kind == "get") return new AST_ObjectGetter(args);
33572
- if (M.kind == "set") return new AST_ObjectSetter(args);
33573
- if (M.kind == "method") {
33574
- args.async = M.value.async;
33575
- args.is_generator = M.value.generator;
33576
- args.quote = M.computed ? "\"" : null;
33577
- return new AST_ConciseMethod(args);
33590
+ } else {
33591
+ var value = from_moz_lambda(M.value, /*is_method=*/true);
33592
+ var args = {
33593
+ start : my_start_token(M.key || M.value),
33594
+ end : my_end_token(M.value),
33595
+ key : M.computed
33596
+ ? from_moz(M.key)
33597
+ : from_moz_symbol(AST_SymbolMethod, M.key),
33598
+ quote : from_moz_quote(M.key, M.computed),
33599
+ static : false, // always an object
33600
+ value,
33601
+ };
33602
+
33603
+ if (M.kind == "get") return new AST_ObjectGetter(args);
33604
+ if (M.kind == "set") return new AST_ObjectSetter(args);
33605
+ if (M.method) return new AST_ConciseMethod(args);
33578
33606
  }
33579
33607
  },
33580
33608
 
33581
33609
  MethodDefinition: function(M) {
33582
33610
  const is_private = M.key.type === "PrivateIdentifier";
33583
- const key = M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value });
33611
+ const key = M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || String(M.key.value) });
33584
33612
 
33585
33613
  var args = {
33586
33614
  start : my_start_token(M),
33587
33615
  end : my_end_token(M),
33588
33616
  key,
33589
- value : from_moz(M.value),
33617
+ quote : from_moz_quote(M.key, M.computed),
33618
+ value : from_moz_lambda(M.value, /*is_method=*/true),
33590
33619
  static : M.static,
33591
33620
  };
33592
33621
  if (M.kind == "get") {
@@ -33595,8 +33624,6 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33595
33624
  if (M.kind == "set") {
33596
33625
  return new (is_private ? AST_PrivateSetter : AST_ObjectSetter)(args);
33597
33626
  }
33598
- args.is_generator = M.value.generator;
33599
- args.async = M.value.async;
33600
33627
  return new (is_private ? AST_PrivateMethod : AST_ConciseMethod)(args);
33601
33628
  },
33602
33629
 
@@ -33611,6 +33638,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33611
33638
  return new AST_ClassProperty({
33612
33639
  start : my_start_token(M),
33613
33640
  end : my_end_token(M),
33641
+ quote : from_moz_quote(M.key, M.computed),
33614
33642
  key,
33615
33643
  value : from_moz(M.value),
33616
33644
  static : M.static,
@@ -33630,15 +33658,13 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33630
33658
  static : M.static,
33631
33659
  });
33632
33660
  } else {
33633
- if (M.key.type !== "Identifier") {
33634
- throw new Error("Non-Identifier key in PropertyDefinition");
33635
- }
33636
- key = from_moz(M.key);
33661
+ key = from_moz_symbol(AST_SymbolClassProperty, M.key);
33637
33662
  }
33638
33663
 
33639
33664
  return new AST_ClassProperty({
33640
33665
  start : my_start_token(M),
33641
33666
  end : my_end_token(M),
33667
+ quote : from_moz_quote(M.key, M.computed),
33642
33668
  key,
33643
33669
  value : from_moz(M.value),
33644
33670
  static : M.static,
@@ -33730,11 +33756,30 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33730
33756
  },
33731
33757
 
33732
33758
  VariableDeclaration: function(M) {
33733
- return new (M.kind === "const" ? AST_Const :
33734
- M.kind === "let" ? AST_Let : AST_Var)({
33759
+ let decl_type;
33760
+ let sym_type;
33761
+ if (M.kind === "const") {
33762
+ decl_type = AST_Const;
33763
+ sym_type = AST_SymbolConst;
33764
+ } else if (M.kind === "let") {
33765
+ decl_type = AST_Let;
33766
+ sym_type = AST_SymbolLet;
33767
+ } else {
33768
+ decl_type = AST_Var;
33769
+ sym_type = AST_SymbolVar;
33770
+ }
33771
+ const definitions = M.declarations.map(M => {
33772
+ return new AST_VarDef({
33773
+ start: my_start_token(M),
33774
+ end: my_end_token(M),
33775
+ name: from_moz_pattern(M.id, sym_type),
33776
+ value: from_moz(M.init),
33777
+ });
33778
+ });
33779
+ return new decl_type({
33735
33780
  start : my_start_token(M),
33736
33781
  end : my_end_token(M),
33737
- definitions : M.declarations.map(from_moz)
33782
+ definitions : definitions,
33738
33783
  });
33739
33784
  },
33740
33785
 
@@ -33763,13 +33808,13 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33763
33808
  return new AST_NameMapping({
33764
33809
  start: my_start_token(M),
33765
33810
  end: my_end_token(M),
33766
- foreign_name: from_moz(M.imported),
33767
- name: from_moz(M.local)
33811
+ foreign_name: from_moz_symbol(AST_SymbolImportForeign, M.imported, M.imported.type === "Literal"),
33812
+ name: from_moz_symbol(AST_SymbolImport, M.local)
33768
33813
  });
33769
33814
  },
33770
33815
 
33771
33816
  ImportDefaultSpecifier: function(M) {
33772
- return from_moz(M.local);
33817
+ return from_moz_symbol(AST_SymbolImport, M.local);
33773
33818
  },
33774
33819
 
33775
33820
  ImportNamespaceSpecifier: function(M) {
@@ -33777,7 +33822,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33777
33822
  start: my_start_token(M),
33778
33823
  end: my_end_token(M),
33779
33824
  foreign_name: new AST_SymbolImportForeign({ name: "*" }),
33780
- name: from_moz(M.local)
33825
+ name: from_moz_symbol(AST_SymbolImport, M.local)
33781
33826
  });
33782
33827
  },
33783
33828
 
@@ -33799,15 +33844,17 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33799
33844
  },
33800
33845
 
33801
33846
  ExportAllDeclaration: function(M) {
33802
- var foreign_name = M.exported == null ?
33847
+ var foreign_name = M.exported == null ?
33803
33848
  new AST_SymbolExportForeign({ name: "*" }) :
33804
- from_moz(M.exported);
33849
+ from_moz_symbol(AST_SymbolExportForeign, M.exported, M.exported.type === "Literal");
33805
33850
  return new AST_Export({
33806
33851
  start: my_start_token(M),
33807
33852
  end: my_end_token(M),
33808
33853
  exported_names: [
33809
33854
  new AST_NameMapping({
33810
- name: new AST_SymbolExportForeign({ name: "*" }),
33855
+ start: my_start_token(M),
33856
+ end: my_end_token(M),
33857
+ name: new AST_SymbolExport({ name: "*" }),
33811
33858
  foreign_name: foreign_name
33812
33859
  })
33813
33860
  ],
@@ -33817,14 +33864,26 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33817
33864
  },
33818
33865
 
33819
33866
  ExportNamedDeclaration: function(M) {
33820
- return new AST_Export({
33821
- start: my_start_token(M),
33822
- end: my_end_token(M),
33823
- exported_definition: from_moz(M.declaration),
33824
- exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : null,
33825
- module_name: from_moz(M.source),
33826
- attributes: import_attributes_from_moz(M.attributes || M.assertions)
33827
- });
33867
+ if (M.declaration) {
33868
+ // export const, export function, ...
33869
+ return new AST_Export({
33870
+ start: my_start_token(M),
33871
+ end: my_end_token(M),
33872
+ exported_definition: from_moz(M.declaration),
33873
+ exported_names: null,
33874
+ module_name: null,
33875
+ attributes: null,
33876
+ });
33877
+ } else {
33878
+ return new AST_Export({
33879
+ start: my_start_token(M),
33880
+ end: my_end_token(M),
33881
+ exported_definition: null,
33882
+ exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(from_moz) : [],
33883
+ module_name: from_moz(M.source),
33884
+ attributes: import_attributes_from_moz(M.attributes || M.assertions),
33885
+ });
33886
+ }
33828
33887
  },
33829
33888
 
33830
33889
  ExportDefaultDeclaration: function(M) {
@@ -33838,8 +33897,10 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33838
33897
 
33839
33898
  ExportSpecifier: function(M) {
33840
33899
  return new AST_NameMapping({
33841
- foreign_name: from_moz(M.exported),
33842
- name: from_moz(M.local)
33900
+ start: my_start_token(M),
33901
+ end: my_end_token(M),
33902
+ foreign_name: from_moz_symbol(AST_SymbolExportForeign, M.exported, M.exported.type === "Literal"),
33903
+ name: from_moz_symbol(AST_SymbolExport, M.local, M.local.type === "Literal"),
33843
33904
  });
33844
33905
  },
33845
33906
 
@@ -33868,27 +33929,13 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33868
33929
  const bi = typeof M.value === "bigint" ? M.value.toString() : M.bigint;
33869
33930
  if (typeof bi === "string") {
33870
33931
  args.value = bi;
33932
+ args.raw = M.raw;
33871
33933
  return new AST_BigInt(args);
33872
33934
  }
33873
33935
  if (val === null) return new AST_Null(args);
33874
33936
  switch (typeof val) {
33875
33937
  case "string":
33876
33938
  args.quote = "\"";
33877
- var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
33878
- if (p.type == "ImportSpecifier") {
33879
- args.name = val;
33880
- return new AST_SymbolImportForeign(args);
33881
- } else if (p.type == "ExportSpecifier") {
33882
- args.name = val;
33883
- if (M == p.exported) {
33884
- return new AST_SymbolExportForeign(args);
33885
- } else {
33886
- return new AST_SymbolExport(args);
33887
- }
33888
- } else if (p.type == "ExportAllDeclaration" && M == p.exported) {
33889
- args.name = val;
33890
- return new AST_SymbolExportForeign(args);
33891
- }
33892
33939
  args.value = val;
33893
33940
  return new AST_String(args);
33894
33941
  case "number":
@@ -33915,26 +33962,11 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33915
33962
  },
33916
33963
 
33917
33964
  Identifier: function(M) {
33918
- var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
33919
- return new ( p.type == "LabeledStatement" ? AST_Label
33920
- : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
33921
- : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
33922
- : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
33923
- : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
33924
- : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
33925
- : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
33926
- : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
33927
- : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
33928
- : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
33929
- : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
33930
- : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
33931
- : p.type == "CatchClause" ? AST_SymbolCatch
33932
- : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
33933
- : AST_SymbolRef)({
33934
- start : my_start_token(M),
33935
- end : my_end_token(M),
33936
- name : M.name
33937
- });
33965
+ return new AST_SymbolRef({
33966
+ start : my_start_token(M),
33967
+ end : my_end_token(M),
33968
+ name : M.name
33969
+ });
33938
33970
  },
33939
33971
 
33940
33972
  EmptyStatement: function(M) {
@@ -33963,19 +33995,28 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33963
33995
  },
33964
33996
 
33965
33997
  LabeledStatement: function(M) {
33966
- return new AST_LabeledStatement({
33967
- start: my_start_token(M),
33968
- end: my_end_token(M),
33969
- label: from_moz(M.label),
33970
- body: from_moz(M.body)
33971
- });
33998
+ try {
33999
+ const label = from_moz_symbol(AST_Label, M.label);
34000
+ FROM_MOZ_LABELS.push(label);
34001
+
34002
+ const stat = new AST_LabeledStatement({
34003
+ start: my_start_token(M),
34004
+ end: my_end_token(M),
34005
+ label,
34006
+ body: from_moz(M.body)
34007
+ });
34008
+
34009
+ return stat;
34010
+ } finally {
34011
+ FROM_MOZ_LABELS.pop();
34012
+ }
33972
34013
  },
33973
34014
 
33974
34015
  BreakStatement: function(M) {
33975
34016
  return new AST_Break({
33976
34017
  start: my_start_token(M),
33977
34018
  end: my_end_token(M),
33978
- label: from_moz(M.label)
34019
+ label: from_moz_label_ref(M.label),
33979
34020
  });
33980
34021
  },
33981
34022
 
@@ -33983,7 +34024,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
33983
34024
  return new AST_Continue({
33984
34025
  start: my_start_token(M),
33985
34026
  end: my_end_token(M),
33986
- label: from_moz(M.label)
34027
+ label: from_moz_label_ref(M.label),
33987
34028
  });
33988
34029
  },
33989
34030
 
@@ -34095,20 +34136,11 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34095
34136
  });
34096
34137
  },
34097
34138
 
34098
- VariableDeclarator: function(M) {
34099
- return new AST_VarDef({
34100
- start: my_start_token(M),
34101
- end: my_end_token(M),
34102
- name: from_moz(M.id),
34103
- value: from_moz(M.init)
34104
- });
34105
- },
34106
-
34107
34139
  CatchClause: function(M) {
34108
34140
  return new AST_Catch({
34109
34141
  start: my_start_token(M),
34110
34142
  end: my_end_token(M),
34111
- argname: from_moz(M.param),
34143
+ argname: M.param ? from_moz_pattern(M.param, AST_SymbolCatch) : null,
34112
34144
  body: from_moz(M.body).body
34113
34145
  });
34114
34146
  },
@@ -34116,6 +34148,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34116
34148
  ThisExpression: function(M) {
34117
34149
  return new AST_This({
34118
34150
  start: my_start_token(M),
34151
+ name: "this",
34119
34152
  end: my_end_token(M)
34120
34153
  });
34121
34154
  },
@@ -34123,7 +34156,8 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34123
34156
  Super: function(M) {
34124
34157
  return new AST_Super({
34125
34158
  start: my_start_token(M),
34126
- end: my_end_token(M)
34159
+ end: my_end_token(M),
34160
+ name: "super",
34127
34161
  });
34128
34162
  },
34129
34163
 
@@ -34164,6 +34198,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34164
34198
  start: my_start_token(M),
34165
34199
  end: my_end_token(M),
34166
34200
  operator: M.operator,
34201
+ logical: M.operator === "??=" || M.operator === "&&=" || M.operator === "||=",
34167
34202
  left: from_moz(M.left),
34168
34203
  right: from_moz(M.right)
34169
34204
  });
@@ -34216,7 +34251,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34216
34251
  return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
34217
34252
  start : my_start_token(M),
34218
34253
  end : my_end_token(M),
34219
- name : from_moz(M.id),
34254
+ name : M.id && from_moz_symbol(M.type === "ClassDeclaration" ? AST_SymbolDefClass : AST_SymbolClass, M.id),
34220
34255
  extends : from_moz(M.superClass),
34221
34256
  properties: M.body.body.map(from_moz)
34222
34257
  });
@@ -34351,13 +34386,6 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34351
34386
  init: to_moz(M.value)
34352
34387
  };
34353
34388
  });
34354
- def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
34355
- return {
34356
- type: "CatchClause",
34357
- param: to_moz(M.argname),
34358
- body: to_moz_block(M)
34359
- };
34360
- });
34361
34389
 
34362
34390
  def_to_moz(AST_This, function To_Moz_ThisExpression() {
34363
34391
  return {
@@ -34369,30 +34397,6 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34369
34397
  type: "Super"
34370
34398
  };
34371
34399
  });
34372
- def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
34373
- return {
34374
- type: "BinaryExpression",
34375
- operator: M.operator,
34376
- left: to_moz(M.left),
34377
- right: to_moz(M.right)
34378
- };
34379
- });
34380
- def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
34381
- return {
34382
- type: "LogicalExpression",
34383
- operator: M.operator,
34384
- left: to_moz(M.left),
34385
- right: to_moz(M.right)
34386
- };
34387
- });
34388
- def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
34389
- return {
34390
- type: "AssignmentExpression",
34391
- operator: M.operator,
34392
- left: to_moz(M.left),
34393
- right: to_moz(M.right)
34394
- };
34395
- });
34396
34400
  def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
34397
34401
  return {
34398
34402
  type: "ConditionalExpression",
@@ -34414,7 +34418,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34414
34418
  return {
34415
34419
  type: "ImportExpression",
34416
34420
  source,
34417
- options
34421
+ options: options || null
34418
34422
  };
34419
34423
  }
34420
34424
 
@@ -34473,36 +34477,36 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34473
34477
  return {
34474
34478
  type: "FunctionDeclaration",
34475
34479
  id: to_moz(M.name),
34476
- params: M.argnames.map(to_moz),
34480
+ params: M.argnames.map(to_moz_pattern),
34477
34481
  generator: M.is_generator,
34478
34482
  async: M.async,
34479
34483
  body: to_moz_scope("BlockStatement", M)
34480
34484
  };
34481
34485
  });
34482
34486
 
34483
- def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
34484
- var is_generator = parent.is_generator !== undefined ?
34485
- parent.is_generator : M.is_generator;
34487
+ def_to_moz(AST_Function, function To_Moz_FunctionExpression(M) {
34486
34488
  return {
34487
34489
  type: "FunctionExpression",
34488
34490
  id: to_moz(M.name),
34489
- params: M.argnames.map(to_moz),
34490
- generator: is_generator,
34491
- async: M.async,
34491
+ params: M.argnames.map(to_moz_pattern),
34492
+ generator: M.is_generator || false,
34493
+ async: M.async || false,
34492
34494
  body: to_moz_scope("BlockStatement", M)
34493
34495
  };
34494
34496
  });
34495
34497
 
34496
34498
  def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
34497
- var body = {
34498
- type: "BlockStatement",
34499
- body: M.body.map(to_moz)
34500
- };
34499
+ var body = M.body.length === 1 && M.body[0] instanceof AST_Return && M.body[0].value
34500
+ ? to_moz(M.body[0].value)
34501
+ : {
34502
+ type: "BlockStatement",
34503
+ body: M.body.map(to_moz)
34504
+ };
34501
34505
  return {
34502
34506
  type: "ArrowFunctionExpression",
34503
- params: M.argnames.map(to_moz),
34507
+ params: M.argnames.map(to_moz_pattern),
34504
34508
  async: M.async,
34505
- body: body
34509
+ body: body,
34506
34510
  };
34507
34511
  });
34508
34512
 
@@ -34510,12 +34514,39 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34510
34514
  if (M.is_array) {
34511
34515
  return {
34512
34516
  type: "ArrayPattern",
34513
- elements: M.names.map(to_moz)
34517
+ elements: M.names.map(
34518
+ M => M instanceof AST_Hole ? null : to_moz_pattern(M)
34519
+ ),
34514
34520
  };
34515
34521
  }
34516
34522
  return {
34517
34523
  type: "ObjectPattern",
34518
- properties: M.names.map(to_moz)
34524
+ properties: M.names.map(M => {
34525
+ if (M instanceof AST_ObjectKeyVal) {
34526
+ var computed = M.computed_key();
34527
+ const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
34528
+
34529
+ return {
34530
+ type: "Property",
34531
+ computed,
34532
+ kind: "init",
34533
+ key: key,
34534
+ method: false,
34535
+ shorthand,
34536
+ value: to_moz_pattern(M.value)
34537
+ };
34538
+ } else {
34539
+ return to_moz_pattern(M);
34540
+ }
34541
+ }),
34542
+ };
34543
+ });
34544
+
34545
+ def_to_moz(AST_DefaultAssign, function To_Moz_AssignmentExpression(M) {
34546
+ return {
34547
+ type: "AssignmentPattern",
34548
+ left: to_moz_pattern(M.left),
34549
+ right: to_moz(M.right),
34519
34550
  };
34520
34551
  });
34521
34552
 
@@ -34559,8 +34590,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34559
34590
  def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
34560
34591
  return {
34561
34592
  type: "CatchClause",
34562
- param: to_moz(M.argname),
34563
- guard: null,
34593
+ param: M.argname != null ? to_moz_pattern(M.argname) : null,
34564
34594
  body: to_moz_block(M)
34565
34595
  };
34566
34596
  });
@@ -34595,8 +34625,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34595
34625
  def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
34596
34626
  if (M.exported_names) {
34597
34627
  var first_exported = M.exported_names[0];
34598
- var first_exported_name = first_exported.name;
34599
- if (first_exported_name.name === "*" && !first_exported_name.quote) {
34628
+ if (first_exported && first_exported.name.name === "*" && !first_exported.name.quote) {
34600
34629
  var foreign_name = first_exported.foreign_name;
34601
34630
  var exported = foreign_name.name === "*" && !foreign_name.quote
34602
34631
  ? null
@@ -34622,10 +34651,20 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34622
34651
  attributes: import_attributes_to_moz(M.attributes)
34623
34652
  };
34624
34653
  }
34625
- return {
34626
- type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
34627
- declaration: to_moz(M.exported_value || M.exported_definition)
34628
- };
34654
+
34655
+ if (M.is_default) {
34656
+ return {
34657
+ type: "ExportDefaultDeclaration",
34658
+ declaration: to_moz(M.exported_value || M.exported_definition),
34659
+ };
34660
+ } else {
34661
+ return {
34662
+ type: "ExportNamedDeclaration",
34663
+ declaration: to_moz(M.exported_value || M.exported_definition),
34664
+ specifiers: [],
34665
+ source: null,
34666
+ };
34667
+ }
34629
34668
  });
34630
34669
 
34631
34670
  def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
@@ -34743,6 +34782,15 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34743
34782
  };
34744
34783
  });
34745
34784
 
34785
+ def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
34786
+ return {
34787
+ type: "AssignmentExpression",
34788
+ operator: M.operator,
34789
+ left: to_moz(M.left),
34790
+ right: to_moz(M.right)
34791
+ };
34792
+ });
34793
+
34746
34794
  def_to_moz(AST_PrivateIn, function To_Moz_BinaryExpression_PrivateIn(M) {
34747
34795
  return {
34748
34796
  type: "BinaryExpression",
@@ -34767,29 +34815,10 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34767
34815
  });
34768
34816
 
34769
34817
  def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
34770
- var key = M.key instanceof AST_Node ? to_moz(M.key) : {
34771
- type: "Identifier",
34772
- value: M.key
34773
- };
34774
- if (typeof M.key === "number") {
34775
- key = {
34776
- type: "Literal",
34777
- value: Number(M.key)
34778
- };
34779
- }
34780
- if (typeof M.key === "string") {
34781
- key = {
34782
- type: "Identifier",
34783
- name: M.key
34784
- };
34785
- }
34818
+ var computed = M.computed_key();
34819
+ const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
34820
+
34786
34821
  var kind;
34787
- var string_or_num = typeof M.key === "string" || typeof M.key === "number";
34788
- var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
34789
- if (M instanceof AST_ObjectKeyVal) {
34790
- kind = "init";
34791
- computed = !string_or_num;
34792
- } else
34793
34822
  if (M instanceof AST_ObjectGetter) {
34794
34823
  kind = "get";
34795
34824
  } else
@@ -34844,31 +34873,51 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34844
34873
  return {
34845
34874
  type: "Property",
34846
34875
  computed: computed,
34876
+ method: false,
34877
+ shorthand,
34847
34878
  kind: kind,
34848
34879
  key: key,
34849
34880
  value: to_moz(M.value)
34850
34881
  };
34851
34882
  });
34852
34883
 
34884
+ def_to_moz(AST_ObjectKeyVal, function To_Moz_Property(M) {
34885
+ var computed = M.computed_key();
34886
+ const [shorthand, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
34887
+
34888
+ return {
34889
+ type: "Property",
34890
+ computed: computed,
34891
+ shorthand: shorthand,
34892
+ method: false,
34893
+ kind: "init",
34894
+ key: key,
34895
+ value: to_moz(M.value)
34896
+ };
34897
+ });
34898
+
34853
34899
  def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
34900
+ const computed = M.computed_key();
34901
+ const [_always_false, key] = to_moz_property_key(M.key, computed, M.quote, M.value);
34902
+
34854
34903
  if (parent instanceof AST_Object) {
34855
34904
  return {
34856
34905
  type: "Property",
34857
- computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
34858
34906
  kind: "init",
34907
+ computed,
34859
34908
  method: true,
34860
34909
  shorthand: false,
34861
- key: to_moz(M.key),
34862
- value: to_moz(M.value)
34910
+ key,
34911
+ value: to_moz(M.value),
34863
34912
  };
34864
34913
  }
34865
34914
 
34866
34915
  return {
34867
34916
  type: "MethodDefinition",
34868
- kind: M.key === "constructor" ? "constructor" : "method",
34869
- key: to_moz(M.key),
34917
+ kind: !computed && M.key.name === "constructor" ? "constructor" : "method",
34918
+ computed,
34919
+ key,
34870
34920
  value: to_moz(M.value),
34871
- computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
34872
34921
  static: M.static,
34873
34922
  };
34874
34923
  });
@@ -34974,6 +35023,7 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
34974
35023
  // `M.value` is a string that may be a hex number representation.
34975
35024
  // but "bigint" property should have only decimal digits
34976
35025
  bigint: typeof BigInt === "function" ? BigInt(M.value).toString() : M.value,
35026
+ raw: M.raw,
34977
35027
  }));
34978
35028
 
34979
35029
  AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
@@ -35017,20 +35067,133 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
35017
35067
  );
35018
35068
  }
35019
35069
 
35020
- var FROM_MOZ_STACK = null;
35070
+ var FROM_MOZ_LABELS = null;
35021
35071
 
35022
35072
  function from_moz(node) {
35023
- FROM_MOZ_STACK.push(node);
35024
- var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
35025
- FROM_MOZ_STACK.pop();
35026
- return ret;
35073
+ if (node == null) return null;
35074
+ return MOZ_TO_ME[node.type](node);
35075
+ }
35076
+
35077
+ function from_moz_quote(moz_key, computed) {
35078
+ if (!computed && moz_key.type === "Literal" && typeof moz_key.value === "string") {
35079
+ return '"';
35080
+ } else {
35081
+ return "";
35082
+ }
35083
+ }
35084
+
35085
+ function from_moz_symbol(symbol_type, M, has_quote) {
35086
+ return new symbol_type({
35087
+ start: my_start_token(M),
35088
+ quote: has_quote ? '"' : undefined,
35089
+ name: M.type === "Identifier" ? M.name : String(M.value),
35090
+ end: my_end_token(M),
35091
+ });
35092
+ }
35093
+
35094
+ function from_moz_lambda(M, is_method) {
35095
+ return new (is_method ? AST_Accessor : AST_Function)({
35096
+ start: my_start_token(M),
35097
+ end: my_end_token(M),
35098
+ name: M.id && from_moz_symbol(is_method ? AST_SymbolMethod : AST_SymbolLambda, M.id),
35099
+ argnames: M.params.map(M => from_moz_pattern(M, AST_SymbolFunarg)),
35100
+ is_generator: M.generator,
35101
+ async: M.async,
35102
+ body: normalize_directives(from_moz(M.body).body)
35103
+ });
35104
+ }
35105
+
35106
+ function from_moz_pattern(M, sym_type) {
35107
+ switch (M.type) {
35108
+ case "ObjectPattern":
35109
+ return new AST_Destructuring({
35110
+ start: my_start_token(M),
35111
+ end: my_end_token(M),
35112
+ names: M.properties.map(p => from_moz_pattern(p, sym_type)),
35113
+ is_array: false
35114
+ });
35115
+
35116
+ case "Property":
35117
+ var key = M.key;
35118
+ var args = {
35119
+ start : my_start_token(key || M.value),
35120
+ end : my_end_token(M.value),
35121
+ key : key.type == "Identifier" ? key.name : String(key.value),
35122
+ quote : !M.computed && key.type === "Literal" && typeof key.value === "string"
35123
+ ? '"'
35124
+ : "",
35125
+ value : from_moz_pattern(M.value, sym_type)
35126
+ };
35127
+ if (M.computed) {
35128
+ args.key = from_moz(M.key);
35129
+ }
35130
+ return new AST_ObjectKeyVal(args);
35131
+
35132
+ case "ArrayPattern":
35133
+ return new AST_Destructuring({
35134
+ start: my_start_token(M),
35135
+ end: my_end_token(M),
35136
+ names: M.elements.map(function(elm) {
35137
+ if (elm === null) {
35138
+ return new AST_Hole();
35139
+ }
35140
+ return from_moz_pattern(elm, sym_type);
35141
+ }),
35142
+ is_array: true
35143
+ });
35144
+
35145
+ case "SpreadElement":
35146
+ case "RestElement":
35147
+ return new AST_Expansion({
35148
+ start: my_start_token(M),
35149
+ end: my_end_token(M),
35150
+ expression: from_moz_pattern(M.argument, sym_type),
35151
+ });
35152
+
35153
+ case "AssignmentPattern":
35154
+ return new AST_DefaultAssign({
35155
+ start : my_start_token(M),
35156
+ end : my_end_token(M),
35157
+ left : from_moz_pattern(M.left, sym_type),
35158
+ operator: "=",
35159
+ right : from_moz(M.right),
35160
+ });
35161
+
35162
+ case "Identifier":
35163
+ return new sym_type({
35164
+ start : my_start_token(M),
35165
+ end : my_end_token(M),
35166
+ name : M.name,
35167
+ });
35168
+
35169
+ default:
35170
+ throw new Error("Invalid node type for destructuring: " + M.type);
35171
+ }
35172
+ }
35173
+
35174
+ function from_moz_label_ref(m_label) {
35175
+ if (!m_label) return null;
35176
+
35177
+ const label = from_moz_symbol(AST_LabelRef, m_label);
35178
+
35179
+ let i = FROM_MOZ_LABELS.length;
35180
+ while (i--) {
35181
+ const label_origin = FROM_MOZ_LABELS[i];
35182
+
35183
+ if (label.name === label_origin.name) {
35184
+ label.thedef = label_origin;
35185
+ break;
35186
+ }
35187
+ }
35188
+
35189
+ return label;
35027
35190
  }
35028
35191
 
35029
35192
  AST_Node.from_mozilla_ast = function(node) {
35030
- var save_stack = FROM_MOZ_STACK;
35031
- FROM_MOZ_STACK = [];
35193
+ var save_labels = FROM_MOZ_LABELS;
35194
+ FROM_MOZ_LABELS = [];
35032
35195
  var ast = from_moz(node);
35033
- FROM_MOZ_STACK = save_stack;
35196
+ FROM_MOZ_LABELS = save_labels;
35034
35197
  return ast;
35035
35198
  };
35036
35199
 
@@ -35072,6 +35235,52 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
35072
35235
  return ast;
35073
35236
  }
35074
35237
 
35238
+ /** Object property keys can be number literals, string literals, or raw names. Additionally they can be shorthand. We decide that here. */
35239
+ function to_moz_property_key(key, computed = false, quote = false, value = null) {
35240
+ if (computed) {
35241
+ return [false, to_moz(key)];
35242
+ }
35243
+
35244
+ const key_name = typeof key === "string" ? key : key.name;
35245
+ let moz_key;
35246
+ if (quote) {
35247
+ moz_key = { type: "Literal", value: key_name, raw: JSON.stringify(key_name) };
35248
+ } else if ("" + +key_name === key_name && +key_name >= 0) {
35249
+ // representable as a number
35250
+ moz_key = { type: "Literal", value: +key_name, raw: JSON.stringify(+key_name) };
35251
+ } else {
35252
+ moz_key = { type: "Identifier", name: key_name };
35253
+ }
35254
+
35255
+ const shorthand =
35256
+ moz_key.type === "Identifier"
35257
+ && moz_key.name === key_name
35258
+ && (value instanceof AST_Symbol && value.name === key_name
35259
+ || value instanceof AST_DefaultAssign && value.left.name === key_name);
35260
+ return [shorthand, moz_key];
35261
+ }
35262
+
35263
+ function to_moz_pattern(node) {
35264
+ if (node instanceof AST_Expansion) {
35265
+ return {
35266
+ type: "RestElement",
35267
+ argument: to_moz_pattern(node.expression),
35268
+ };
35269
+ }
35270
+
35271
+ if ((
35272
+ node instanceof AST_Symbol
35273
+ || node instanceof AST_Destructuring
35274
+ || node instanceof AST_DefaultAssign
35275
+ || node instanceof AST_PropAccess
35276
+ )) {
35277
+ // Plain translation
35278
+ return to_moz(node);
35279
+ }
35280
+
35281
+ throw new Error(node.TYPE);
35282
+ }
35283
+
35075
35284
  function to_moz_in_destructuring() {
35076
35285
  var i = TO_MOZ_STACK.length;
35077
35286
  while (i--) {
@@ -35305,7 +35514,7 @@ function OutputStream(options) {
35305
35514
  webkit : false,
35306
35515
  width : 80,
35307
35516
  wrap_iife : false,
35308
- wrap_func_args : true,
35517
+ wrap_func_args : false,
35309
35518
 
35310
35519
  _destroy_ast : false
35311
35520
  }, true);
@@ -36829,11 +37038,11 @@ function OutputStream(options) {
36829
37038
  foreign_name.name;
36830
37039
  if (!names_are_different &&
36831
37040
  foreign_name.name === "*" &&
36832
- foreign_name.quote != self.name.quote) {
37041
+ !!foreign_name.quote != !!self.name.quote) {
36833
37042
  // export * as "*"
36834
37043
  names_are_different = true;
36835
37044
  }
36836
- var foreign_name_is_name = foreign_name.quote == null;
37045
+ var foreign_name_is_name = !foreign_name.quote;
36837
37046
  if (names_are_different) {
36838
37047
  if (is_import) {
36839
37048
  if (foreign_name_is_name) {
@@ -36842,7 +37051,7 @@ function OutputStream(options) {
36842
37051
  output.print_string(foreign_name.name, foreign_name.quote);
36843
37052
  }
36844
37053
  } else {
36845
- if (self.name.quote == null) {
37054
+ if (!self.name.quote) {
36846
37055
  self.name.print(output);
36847
37056
  } else {
36848
37057
  output.print_string(self.name.name, self.name.quote);
@@ -36862,7 +37071,7 @@ function OutputStream(options) {
36862
37071
  }
36863
37072
  }
36864
37073
  } else {
36865
- if (self.name.quote == null) {
37074
+ if (!self.name.quote) {
36866
37075
  self.name.print(output);
36867
37076
  } else {
36868
37077
  output.print_string(self.name.name, self.name.quote);
@@ -37251,7 +37460,7 @@ function OutputStream(options) {
37251
37460
 
37252
37461
  output.print("#");
37253
37462
 
37254
- print_property_name(self.key.name, self.quote, output);
37463
+ print_property_name(self.key.name, undefined, output);
37255
37464
 
37256
37465
  if (self.value) {
37257
37466
  output.print("=");
@@ -37316,22 +37525,22 @@ function OutputStream(options) {
37316
37525
  });
37317
37526
  DEFPRINT(AST_ConciseMethod, function(self, output) {
37318
37527
  var type;
37319
- if (self.is_generator && self.async) {
37528
+ if (self.value.is_generator && self.value.async) {
37320
37529
  type = "async*";
37321
- } else if (self.is_generator) {
37530
+ } else if (self.value.is_generator) {
37322
37531
  type = "*";
37323
- } else if (self.async) {
37532
+ } else if (self.value.async) {
37324
37533
  type = "async";
37325
37534
  }
37326
37535
  self._print_getter_setter(type, false, output);
37327
37536
  });
37328
37537
  DEFPRINT(AST_PrivateMethod, function(self, output) {
37329
37538
  var type;
37330
- if (self.is_generator && self.async) {
37539
+ if (self.value.is_generator && self.value.async) {
37331
37540
  type = "async*";
37332
- } else if (self.is_generator) {
37541
+ } else if (self.value.is_generator) {
37333
37542
  type = "*";
37334
- } else if (self.async) {
37543
+ } else if (self.value.async) {
37335
37544
  type = "async";
37336
37545
  }
37337
37546
  self._print_getter_setter(type, true, output);
@@ -37379,7 +37588,11 @@ function OutputStream(options) {
37379
37588
  }
37380
37589
  });
37381
37590
  DEFPRINT(AST_BigInt, function(self, output) {
37382
- output.print(self.getValue() + "n");
37591
+ if (output.option("keep_numbers") && self.raw) {
37592
+ output.print(self.raw);
37593
+ } else {
37594
+ output.print(self.getValue() + "n");
37595
+ }
37383
37596
  });
37384
37597
 
37385
37598
  const r_slash_script = /(<\s*\/\s*script)/i;
@@ -37667,13 +37880,13 @@ AST_VarDef.prototype.shallow_cmp = function(other) {
37667
37880
  AST_NameMapping.prototype.shallow_cmp = pass_through;
37668
37881
 
37669
37882
  AST_Import.prototype.shallow_cmp = function(other) {
37670
- return (this.imported_name == null ? other.imported_name == null : this.imported_name === other.imported_name) && (this.imported_names == null ? other.imported_names == null : this.imported_names === other.imported_names);
37883
+ return (this.imported_name == null ? other.imported_name == null : this.imported_name === other.imported_name) && (this.imported_names == null ? other.imported_names == null : this.imported_names === other.imported_names) && (this.attributes == null ? other.attributes == null : this.attributes === other.attributes);
37671
37884
  };
37672
37885
 
37673
37886
  AST_ImportMeta.prototype.shallow_cmp = pass_through;
37674
37887
 
37675
37888
  AST_Export.prototype.shallow_cmp = function(other) {
37676
- return (this.exported_definition == null ? other.exported_definition == null : this.exported_definition === other.exported_definition) && (this.exported_value == null ? other.exported_value == null : this.exported_value === other.exported_value) && (this.exported_names == null ? other.exported_names == null : this.exported_names === other.exported_names) && this.module_name === other.module_name && this.is_default === other.is_default;
37889
+ return (this.exported_definition == null ? other.exported_definition == null : this.exported_definition === other.exported_definition) && (this.exported_value == null ? other.exported_value == null : this.exported_value === other.exported_value) && (this.exported_names == null ? other.exported_names == null : this.exported_names === other.exported_names) && (this.attributes == null ? other.attributes == null : this.attributes === other.attributes) && this.module_name === other.module_name && this.is_default === other.is_default;
37677
37890
  };
37678
37891
 
37679
37892
  AST_Call.prototype.shallow_cmp = pass_through;
@@ -37700,6 +37913,8 @@ AST_Binary.prototype.shallow_cmp = function(other) {
37700
37913
  return this.operator === other.operator;
37701
37914
  };
37702
37915
 
37916
+ AST_PrivateIn.prototype.shallow_cmp = pass_through;
37917
+
37703
37918
  AST_Conditional.prototype.shallow_cmp = pass_through;
37704
37919
 
37705
37920
  AST_Array.prototype.shallow_cmp = pass_through;
@@ -37709,7 +37924,7 @@ AST_Object.prototype.shallow_cmp = pass_through;
37709
37924
  AST_ObjectProperty.prototype.shallow_cmp = pass_through;
37710
37925
 
37711
37926
  AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
37712
- return this.key === other.key;
37927
+ return this.key === other.key && this.quote === other.quote;
37713
37928
  };
37714
37929
 
37715
37930
  AST_ObjectSetter.prototype.shallow_cmp = function(other) {
@@ -37721,11 +37936,11 @@ AST_ObjectGetter.prototype.shallow_cmp = function(other) {
37721
37936
  };
37722
37937
 
37723
37938
  AST_ConciseMethod.prototype.shallow_cmp = function(other) {
37724
- return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
37939
+ return this.static === other.static;
37725
37940
  };
37726
37941
 
37727
37942
  AST_PrivateMethod.prototype.shallow_cmp = function(other) {
37728
- return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
37943
+ return this.static === other.static;
37729
37944
  };
37730
37945
 
37731
37946
  AST_Class.prototype.shallow_cmp = function(other) {
@@ -39062,7 +39277,7 @@ AST_ObjectSetter.prototype._size = function () {
39062
39277
  };
39063
39278
 
39064
39279
  AST_ConciseMethod.prototype._size = function () {
39065
- return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
39280
+ return static_size(this.static) + key_size(this.key);
39066
39281
  };
39067
39282
 
39068
39283
  AST_PrivateMethod.prototype._size = function () {
@@ -41036,7 +41251,7 @@ def_eval(AST_UnaryPrefix, function (compressor, depth) {
41036
41251
  if (e instanceof RegExp)
41037
41252
  return this;
41038
41253
  return typeof e;
41039
- case "void": return void 0;
41254
+ case "void": return void e;
41040
41255
  case "~": return ~e;
41041
41256
  case "-": return -e;
41042
41257
  case "+": return +e;
@@ -43812,7 +44027,7 @@ function tighten_body(statements, compressor) {
43812
44027
  stat = stat.clone();
43813
44028
  stat.condition = stat.condition.negate(compressor);
43814
44029
  stat.body = make_node(AST_BlockStatement, stat, {
43815
- body: as_statement_array(stat.alternative).concat(extract_functions())
44030
+ body: as_statement_array(stat.alternative).concat(extract_defuns())
43816
44031
  });
43817
44032
  stat.alternative = make_node(AST_BlockStatement, stat, {
43818
44033
  body: new_else
@@ -43832,7 +44047,7 @@ function tighten_body(statements, compressor) {
43832
44047
  CHANGED = true;
43833
44048
  stat = stat.clone();
43834
44049
  stat.body = make_node(AST_BlockStatement, stat.body, {
43835
- body: as_statement_array(stat.body).concat(extract_functions())
44050
+ body: as_statement_array(stat.body).concat(extract_defuns())
43836
44051
  });
43837
44052
  stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
43838
44053
  body: new_else
@@ -43937,7 +44152,7 @@ function tighten_body(statements, compressor) {
43937
44152
  || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
43938
44153
  }
43939
44154
 
43940
- function extract_functions() {
44155
+ function extract_defuns() {
43941
44156
  var tail = statements.slice(i + 1);
43942
44157
  statements.length = i + 1;
43943
44158
  return tail.filter(function (stat) {
@@ -43955,6 +44170,9 @@ function tighten_body(statements, compressor) {
43955
44170
  return undefined;
43956
44171
  }
43957
44172
  body = body.slice(0, -1);
44173
+ if (!body.every(stat => can_be_evicted_from_block(stat))) {
44174
+ return undefined;
44175
+ }
43958
44176
  if (ab.value) {
43959
44177
  body.push(make_node(AST_SimpleStatement, ab.value, {
43960
44178
  body: ab.value.expression
@@ -44414,6 +44632,8 @@ function inline_into_symbolref(self, compressor) {
44414
44632
  return self;
44415
44633
  }
44416
44634
 
44635
+ if (dont_inline_lambda_in_loop(compressor, fixed)) return self;
44636
+
44417
44637
  let single_use = def.single_use
44418
44638
  && !(parent instanceof AST_Call
44419
44639
  && (parent.is_callee_pure(compressor))
@@ -44567,6 +44787,11 @@ function inline_into_call(self, compressor) {
44567
44787
  fn = fixed;
44568
44788
  }
44569
44789
 
44790
+ if (
44791
+ dont_inline_lambda_in_loop(compressor, fn)
44792
+ && !has_annotation(self, _INLINE)
44793
+ ) return self;
44794
+
44570
44795
  var is_func = fn instanceof AST_Lambda;
44571
44796
 
44572
44797
  var stat = is_func && fn.body[0];
@@ -44895,6 +45120,14 @@ function inline_into_call(self, compressor) {
44895
45120
  }
44896
45121
  }
44897
45122
 
45123
+ /** prevent inlining functions into loops, for performance reasons */
45124
+ function dont_inline_lambda_in_loop(compressor, maybe_lambda) {
45125
+ return (
45126
+ (maybe_lambda instanceof AST_Lambda || maybe_lambda instanceof AST_Class)
45127
+ && !!compressor.is_within_loop()
45128
+ );
45129
+ }
45130
+
44898
45131
  (function(def_find_defs) {
44899
45132
  function to_node(value, orig) {
44900
45133
  if (value instanceof AST_Node) {
@@ -48322,7 +48555,7 @@ AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
48322
48555
  if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
48323
48556
  const all_props_flattenable = props.every((p) =>
48324
48557
  (p instanceof AST_ObjectKeyVal
48325
- || arrows && p instanceof AST_ConciseMethod && !p.is_generator
48558
+ || arrows && p instanceof AST_ConciseMethod && !p.value.is_generator
48326
48559
  )
48327
48560
  && !p.computed_key()
48328
48561
  );
@@ -48808,7 +49041,7 @@ def_optimize(AST_ConciseMethod, function(self, compressor) {
48808
49041
  // p(){return x;} ---> p:()=>x
48809
49042
  if (compressor.option("arrows")
48810
49043
  && compressor.parent() instanceof AST_Object
48811
- && !self.is_generator
49044
+ && !self.value.is_generator
48812
49045
  && !self.value.uses_arguments
48813
49046
  && !self.value.pinned()
48814
49047
  && self.value.body.length == 1
@@ -48816,8 +49049,8 @@ def_optimize(AST_ConciseMethod, function(self, compressor) {
48816
49049
  && self.value.body[0].value
48817
49050
  && !self.value.contains_this()) {
48818
49051
  var arrow = make_node(AST_Arrow, self.value, self.value);
48819
- arrow.async = self.async;
48820
- arrow.is_generator = self.is_generator;
49052
+ arrow.async = self.value.async;
49053
+ arrow.is_generator = self.value.is_generator;
48821
49054
  return make_node(AST_ObjectKeyVal, self, {
48822
49055
  key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
48823
49056
  value: arrow,
@@ -48845,8 +49078,6 @@ def_optimize(AST_ObjectKeyVal, function(self, compressor) {
48845
49078
  && !value.contains_this();
48846
49079
  if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
48847
49080
  return make_node(AST_ConciseMethod, self, {
48848
- async: value.async,
48849
- is_generator: value.is_generator,
48850
49081
  key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
48851
49082
  name: key,
48852
49083
  }),
@@ -60148,9 +60379,7 @@ class TokenChain {
60148
60379
  }
60149
60380
  }
60150
60381
 
60151
- function trimWhitespace(str) {
60152
- return str && str.replace(/^[ \n\r\t\f]+/, '').replace(/[ \n\r\t\f]+$/, '');
60153
- }
60382
+ const trimWhitespace = str => str && str.replace(/^[ \n\r\t\f]+/, '').replace(/[ \n\r\t\f]+$/, '');
60154
60383
 
60155
60384
  function collapseWhitespaceAll(str) {
60156
60385
  // Non-breaking space is specifically handled inside the replacer function here:
@@ -60202,14 +60431,14 @@ function collapseWhitespace(str, options, trimLeft, trimRight, collapseAll) {
60202
60431
  return lineBreakBefore + str + lineBreakAfter;
60203
60432
  }
60204
60433
 
60205
- // non-empty tags that will maintain whitespace around them
60206
- const inlineTags = new Set(['a', 'abbr', 'acronym', 'b', 'bdi', 'bdo', 'big', 'button', 'cite', 'code', 'del', 'dfn', 'em', 'font', 'i', 'ins', 'kbd', 'label', 'mark', 'math', 'nobr', 'object', 'q', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'select', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'svg', 'textarea', 'time', 'tt', 'u', 'var']);
60207
- // non-empty tags that will maintain whitespace within them
60434
+ // non-empty elements that will maintain whitespace around them
60435
+ const inlineHtmlElements = ['a', 'abbr', 'acronym', 'b', 'bdi', 'bdo', 'big', 'button', 'cite', 'code', 'del', 'dfn', 'em', 'font', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'mark', 'math', 'meter', 'nobr', 'object', 'output', 'progress', 'q', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'select', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'svg', 'textarea', 'time', 'tt', 'u', 'var', 'wbr'];
60436
+ // non-empty elements that will maintain whitespace within them
60208
60437
  const inlineTextTags = new Set(['a', 'abbr', 'acronym', 'b', 'big', 'del', 'em', 'font', 'i', 'ins', 'kbd', 'mark', 'nobr', 'rp', 's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'time', 'tt', 'u', 'var']);
60209
- // self-closing tags that will maintain whitespace around them
60438
+ // self-closing elements that will maintain whitespace around them
60210
60439
  const selfClosingInlineTags = new Set(['comment', 'img', 'input', 'wbr']);
60211
60440
 
60212
- function collapseWhitespaceSmart(str, prevTag, nextTag, options) {
60441
+ function collapseWhitespaceSmart(str, prevTag, nextTag, options, inlineTags) {
60213
60442
  let trimLeft = prevTag && !selfClosingInlineTags.has(prevTag);
60214
60443
  if (trimLeft && !options.collapseInlineTagWhitespace) {
60215
60444
  trimLeft = prevTag.charAt(0) === '/' ? !inlineTags.has(prevTag.slice(1)) : !inlineTextTags.has(prevTag);
@@ -61009,6 +61238,7 @@ async function minifyHTML(value, options, partialMarkup) {
61009
61238
  let uidIgnore;
61010
61239
  let uidAttr;
61011
61240
  let uidPattern;
61241
+ let inlineTags = new Set([...inlineHtmlElements, ...(options.inlineCustomElements ?? [])]);
61012
61242
 
61013
61243
  // temporarily replace ignored chunks with comments,
61014
61244
  // so that we don't have to worry what's there.
@@ -61140,7 +61370,7 @@ async function minifyHTML(value, options, partialMarkup) {
61140
61370
  const match = str.match(/^<\/([\w:-]+)>$/);
61141
61371
  if (match) {
61142
61372
  endTag = match[1];
61143
- } else if (/>$/.test(str) || (buffer[index] = collapseWhitespaceSmart(str, null, nextTag, options))) {
61373
+ } else if (/>$/.test(str) || (buffer[index] = collapseWhitespaceSmart(str, null, nextTag, options, inlineTags))) {
61144
61374
  break;
61145
61375
  }
61146
61376
  }
@@ -61351,7 +61581,7 @@ async function minifyHTML(value, options, partialMarkup) {
61351
61581
  }
61352
61582
  }
61353
61583
  if (prevTag || nextTag) {
61354
- text = collapseWhitespaceSmart(text, prevTag, nextTag, options);
61584
+ text = collapseWhitespaceSmart(text, prevTag, nextTag, options, inlineTags);
61355
61585
  } else {
61356
61586
  text = collapseWhitespace(text, options, true, true);
61357
61587
  }