Update dependencies

This commit is contained in:
Jay Trees 2022-04-11 10:07:00 +02:00
parent 8dacc7e961
commit 31f59a7bf8
17 changed files with 386 additions and 203 deletions

6
node_modules/.yarn-integrity generated vendored
View file

@ -141,7 +141,7 @@
"concat-stream@^1.6.0": "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34", "concat-stream@^1.6.0": "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34",
"concat-with-sourcemaps@^1.0.0": "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e", "concat-with-sourcemaps@^1.0.0": "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e",
"concat-with-sourcemaps@^1.1.0": "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e", "concat-with-sourcemaps@^1.1.0": "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e",
"config-chain@^1.1.12": "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.13.tgz#fad0795aa6a6cdaff9ed1b68e9dff94372c232f4", "config-chain@^1.1.13": "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.13.tgz#fad0795aa6a6cdaff9ed1b68e9dff94372c232f4",
"convert-source-map@^0.3.3": "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-0.3.5.tgz#f1d802950af7dd2631a1febe0596550c86ab3190", "convert-source-map@^0.3.3": "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-0.3.5.tgz#f1d802950af7dd2631a1febe0596550c86ab3190",
"convert-source-map@^1.5.0": "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369", "convert-source-map@^1.5.0": "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369",
"copy-anything@^2.0.1": "https://registry.yarnpkg.com/copy-anything/-/copy-anything-2.0.6.tgz#092454ea9584a7b7ad5573062b2a87f5900fc480", "copy-anything@^2.0.1": "https://registry.yarnpkg.com/copy-anything/-/copy-anything-2.0.6.tgz#092454ea9584a7b7ad5573062b2a87f5900fc480",
@ -375,7 +375,7 @@
"isobject@^3.0.1": "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df", "isobject@^3.0.1": "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df",
"istextorbinary@^3.0.0": "https://registry.yarnpkg.com/istextorbinary/-/istextorbinary-3.3.0.tgz#06b1c57d948da11461bd237c00ce09e9902964f2", "istextorbinary@^3.0.0": "https://registry.yarnpkg.com/istextorbinary/-/istextorbinary-3.3.0.tgz#06b1c57d948da11461bd237c00ce09e9902964f2",
"jquery@^3.4.0": "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470", "jquery@^3.4.0": "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470",
"js-beautify@^1.13.13": "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.14.2.tgz#8180514fd4c7789c4ac4bcc327b6dda634c55666", "js-beautify@^1.13.13": "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.14.3.tgz#3dd11c949178de7f3bdf3f6f752778d3bed95150",
"json-stable-stringify-without-jsonify@^1.0.1": "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651", "json-stable-stringify-without-jsonify@^1.0.1": "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651",
"just-debounce@^1.0.0": "https://registry.yarnpkg.com/just-debounce/-/just-debounce-1.1.0.tgz#2f81a3ad4121a76bc7cb45dbf704c0d76a8e5ddf", "just-debounce@^1.0.0": "https://registry.yarnpkg.com/just-debounce/-/just-debounce-1.1.0.tgz#2f81a3ad4121a76bc7cb45dbf704c0d76a8e5ddf",
"kind-of@^1.1.0": "https://registry.yarnpkg.com/kind-of/-/kind-of-1.1.0.tgz#140a3d2d41a36d2efcfa9377b62c24f8495a5c44", "kind-of@^1.1.0": "https://registry.yarnpkg.com/kind-of/-/kind-of-1.1.0.tgz#140a3d2d41a36d2efcfa9377b62c24f8495a5c44",
@ -707,7 +707,7 @@
"type@^1.0.1": "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0", "type@^1.0.1": "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0",
"type@^2.5.0": "https://registry.yarnpkg.com/type/-/type-2.6.0.tgz#3ca6099af5981d36ca86b78442973694278a219f", "type@^2.5.0": "https://registry.yarnpkg.com/type/-/type-2.6.0.tgz#3ca6099af5981d36ca86b78442973694278a219f",
"typedarray@^0.0.6": "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777", "typedarray@^0.0.6": "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777",
"uglify-js@^3.0.5": "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.3.tgz#9aa82ca22419ba4c0137642ba0df800cb06e0471", "uglify-js@^3.0.5": "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.4.tgz#fa95c257e88f85614915b906204b9623d4fa340d",
"unc-path-regex@^0.1.2": "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa", "unc-path-regex@^0.1.2": "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa",
"undertaker-registry@^1.0.0": "https://registry.yarnpkg.com/undertaker-registry/-/undertaker-registry-1.0.1.tgz#5e4bda308e4a8a2ae584f9b9a4359a499825cc50", "undertaker-registry@^1.0.0": "https://registry.yarnpkg.com/undertaker-registry/-/undertaker-registry-1.0.1.tgz#5e4bda308e4a8a2ae584f9b9a4359a499825cc50",
"undertaker@^1.2.1": "https://registry.yarnpkg.com/undertaker/-/undertaker-1.3.0.tgz#363a6e541f27954d5791d6fa3c1d321666f86d18", "undertaker@^1.2.1": "https://registry.yarnpkg.com/undertaker/-/undertaker-1.3.0.tgz#363a6e541f27954d5791d6fa3c1d321666f86d18",

20
node_modules/js-beautify/README.md generated vendored
View file

@ -58,17 +58,17 @@ JS Beautifier is hosted on two CDN services: [cdnjs](https://cdnjs.com/libraries
To pull the latest version from one of these services include one set of the script tags below in your document: To pull the latest version from one of these services include one set of the script tags below in your document:
```html ```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.2/beautify.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.3/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.2/beautify-css.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.3/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.2/beautify-html.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.3/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.2/beautify.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.3/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.2/beautify-css.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.3/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.2/beautify-html.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.3/beautify-html.min.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.14.2/js/lib/beautify.js"></script> <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.14.3/js/lib/beautify.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.14.2/js/lib/beautify-css.js"></script> <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.14.3/js/lib/beautify-css.js"></script>
<script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.14.2/js/lib/beautify-html.js"></script> <script src="https://cdn.rawgit.com/beautify-web/js-beautify/v1.14.3/js/lib/beautify-html.js"></script>
``` ```
Older versions are available by changing the version number. Older versions are available by changing the version number.
@ -401,4 +401,4 @@ Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, D
Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull, Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull,
Mathias Bynens, Vittorio Gambaletta and others. Mathias Bynens, Vittorio Gambaletta and others.
(README.md: js-beautify@1.14.2) (README.md: js-beautify@1.14.3)

View file

@ -805,10 +805,10 @@ Beautifier.prototype.handle_start_block = function(current_token) {
)) { )) {
// We don't support TypeScript,but we didn't break it for a very long time. // We don't support TypeScript,but we didn't break it for a very long time.
// We'll try to keep not breaking it. // We'll try to keep not breaking it.
if (!in_array(this._last_last_text, ['class', 'interface'])) { if (in_array(this._last_last_text, ['class', 'interface']) && !in_array(second_token.text, [':', ','])) {
this.set_mode(MODE.ObjectLiteral);
} else {
this.set_mode(MODE.BlockStatement); this.set_mode(MODE.BlockStatement);
} else {
this.set_mode(MODE.ObjectLiteral);
} }
} else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') { } else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') {
// arrow function: (param1, paramN) => { statements } // arrow function: (param1, paramN) => { statements }
@ -924,7 +924,7 @@ Beautifier.prototype.handle_word = function(current_token) {
if (current_token.type === TOKEN.RESERVED) { if (current_token.type === TOKEN.RESERVED) {
if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) { if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;
} else if (current_token.text === 'import' && this._tokens.peek().text === '(') { } else if (current_token.text === 'import' && in_array(this._tokens.peek().text, ['(', '.'])) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;
} else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) { } else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;
@ -2502,7 +2502,7 @@ var digit = /[0-9]/;
var dot_pattern = /[^\d\.]/; var dot_pattern = /[^\d\.]/;
var positionable_operators = ( var positionable_operators = (
">>> === !== " + ">>> === !== &&= ??= ||= " +
"<< && >= ** != == <= >> || ?? |> " + "<< && >= ** != == <= >> || ?? |> " +
"< / - + > : & % ? ^ | *").split(' '); "< / - + > : & % ? ^ | *").split(' ');
@ -2510,7 +2510,7 @@ var positionable_operators = (
// Also, you must update possitionable operators separately from punct // Also, you must update possitionable operators separately from punct
var punct = var punct =
">>>= " + ">>>= " +
"... >>= <<= === >>> !== **= " + "... >>= <<= === >>> !== **= &&= ??= ||= " +
"=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " + "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " +
"= ! ? > < : / ^ - + * & % ~ |"; "= ! ? > < : / ^ - + * & % ~ |";
@ -4039,6 +4039,9 @@ function Beautifier(source_text, options) {
"@supports": true, "@supports": true,
"@document": true "@document": true
}; };
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
"grid-template"
];
} }
@ -4163,7 +4166,9 @@ Beautifier.prototype.beautify = function() {
var enteringConditionalGroup = false; var enteringConditionalGroup = false;
var insideAtExtend = false; var insideAtExtend = false;
var insideAtImport = false; var insideAtImport = false;
var insideScssMap = false;
var topCharacter = this._ch; var topCharacter = this._ch;
var insideNonSemiColonValues = false;
var whitespace; var whitespace;
var isAfterSpace; var isAfterSpace;
var previous_ch; var previous_ch;
@ -4215,7 +4220,7 @@ Beautifier.prototype.beautify = function() {
// Ensures any new lines following the comment are preserved // Ensures any new lines following the comment are preserved
this.eatWhitespace(true); this.eatWhitespace(true);
} else if (this._ch === '@') { } else if (this._ch === '@' || this._ch === '$') {
this.preserveSingleSpace(isAfterSpace); this.preserveSingleSpace(isAfterSpace);
// deal with less propery mixins @{...} // deal with less propery mixins @{...}
@ -4286,7 +4291,12 @@ Beautifier.prototype.beautify = function() {
this.indent(); this.indent();
this._output.set_indent(this._indentLevel); this._output.set_indent(this._indentLevel);
} else { } else {
this.indent(); // inside mixin and first param is object
if (previous_ch === '(') {
this._output.space_before_token = false;
} else if (previous_ch !== ',') {
this.indent();
}
this.print_string(this._ch); this.print_string(this._ch);
} }
@ -4318,7 +4328,21 @@ Beautifier.prototype.beautify = function() {
this._output.add_new_line(true); this._output.add_new_line(true);
} }
} }
if (this._input.peek() === ')') {
this._output.trim(true);
if (this._options.brace_style === "expand") {
this._output.add_new_line(true);
}
}
} else if (this._ch === ":") { } else if (this._ch === ":") {
for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
insideNonSemiColonValues = true;
break;
}
}
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) { if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
// 'property: value' delimiter // 'property: value' delimiter
// which could be in a conditional group query // which could be in a conditional group query
@ -4351,6 +4375,7 @@ Beautifier.prototype.beautify = function() {
this.print_string(this._ch + this.eatString(this._ch)); this.print_string(this._ch + this.eatString(this._ch));
this.eatWhitespace(true); this.eatWhitespace(true);
} else if (this._ch === ';') { } else if (this._ch === ';') {
insideNonSemiColonValues = false;
if (parenLevel === 0) { if (parenLevel === 0) {
if (insidePropertyValue) { if (insidePropertyValue) {
this.outdent(); this.outdent();
@ -4392,20 +4417,32 @@ Beautifier.prototype.beautify = function() {
} else { } else {
this.preserveSingleSpace(isAfterSpace); this.preserveSingleSpace(isAfterSpace);
this.print_string(this._ch); this.print_string(this._ch);
this.eatWhitespace();
parenLevel++; // handle scss/sass map
this.indent(); if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
this._output.add_new_line();
insideScssMap = true;
} else {
this.eatWhitespace();
parenLevel++;
this.indent();
}
} }
} else if (this._ch === ')') { } else if (this._ch === ')') {
if (parenLevel) { if (parenLevel) {
parenLevel--; parenLevel--;
this.outdent(); this.outdent();
} }
if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
insideScssMap = false;
this.outdent();
this._output.add_new_line();
}
this.print_string(this._ch); this.print_string(this._ch);
} else if (this._ch === ',') { } else if (this._ch === ',') {
this.print_string(this._ch); this.print_string(this._ch);
this.eatWhitespace(true); this.eatWhitespace(true);
if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) { if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
this._output.add_new_line(); this._output.add_new_line();
} else { } else {
this._output.space_before_token = true; this._output.space_before_token = true;
@ -4439,8 +4476,13 @@ Beautifier.prototype.beautify = function() {
this.print_string(' '); this.print_string(' ');
this.print_string(this._ch); this.print_string(this._ch);
} else { } else {
this.preserveSingleSpace(isAfterSpace); var preserveAfterSpace = previous_ch === '"' || previous_ch === '\'';
this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
this.print_string(this._ch); this.print_string(this._ch);
if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) {
this._output.add_new_line();
}
} }
} }

File diff suppressed because one or more lines are too long

View file

@ -1090,6 +1090,9 @@ function Beautifier(source_text, options) {
"@supports": true, "@supports": true,
"@document": true "@document": true
}; };
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
"grid-template"
];
} }
@ -1214,7 +1217,9 @@ Beautifier.prototype.beautify = function() {
var enteringConditionalGroup = false; var enteringConditionalGroup = false;
var insideAtExtend = false; var insideAtExtend = false;
var insideAtImport = false; var insideAtImport = false;
var insideScssMap = false;
var topCharacter = this._ch; var topCharacter = this._ch;
var insideNonSemiColonValues = false;
var whitespace; var whitespace;
var isAfterSpace; var isAfterSpace;
var previous_ch; var previous_ch;
@ -1266,7 +1271,7 @@ Beautifier.prototype.beautify = function() {
// Ensures any new lines following the comment are preserved // Ensures any new lines following the comment are preserved
this.eatWhitespace(true); this.eatWhitespace(true);
} else if (this._ch === '@') { } else if (this._ch === '@' || this._ch === '$') {
this.preserveSingleSpace(isAfterSpace); this.preserveSingleSpace(isAfterSpace);
// deal with less propery mixins @{...} // deal with less propery mixins @{...}
@ -1337,7 +1342,12 @@ Beautifier.prototype.beautify = function() {
this.indent(); this.indent();
this._output.set_indent(this._indentLevel); this._output.set_indent(this._indentLevel);
} else { } else {
this.indent(); // inside mixin and first param is object
if (previous_ch === '(') {
this._output.space_before_token = false;
} else if (previous_ch !== ',') {
this.indent();
}
this.print_string(this._ch); this.print_string(this._ch);
} }
@ -1369,7 +1379,21 @@ Beautifier.prototype.beautify = function() {
this._output.add_new_line(true); this._output.add_new_line(true);
} }
} }
if (this._input.peek() === ')') {
this._output.trim(true);
if (this._options.brace_style === "expand") {
this._output.add_new_line(true);
}
}
} else if (this._ch === ":") { } else if (this._ch === ":") {
for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
insideNonSemiColonValues = true;
break;
}
}
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) { if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
// 'property: value' delimiter // 'property: value' delimiter
// which could be in a conditional group query // which could be in a conditional group query
@ -1402,6 +1426,7 @@ Beautifier.prototype.beautify = function() {
this.print_string(this._ch + this.eatString(this._ch)); this.print_string(this._ch + this.eatString(this._ch));
this.eatWhitespace(true); this.eatWhitespace(true);
} else if (this._ch === ';') { } else if (this._ch === ';') {
insideNonSemiColonValues = false;
if (parenLevel === 0) { if (parenLevel === 0) {
if (insidePropertyValue) { if (insidePropertyValue) {
this.outdent(); this.outdent();
@ -1443,20 +1468,32 @@ Beautifier.prototype.beautify = function() {
} else { } else {
this.preserveSingleSpace(isAfterSpace); this.preserveSingleSpace(isAfterSpace);
this.print_string(this._ch); this.print_string(this._ch);
this.eatWhitespace();
parenLevel++; // handle scss/sass map
this.indent(); if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
this._output.add_new_line();
insideScssMap = true;
} else {
this.eatWhitespace();
parenLevel++;
this.indent();
}
} }
} else if (this._ch === ')') { } else if (this._ch === ')') {
if (parenLevel) { if (parenLevel) {
parenLevel--; parenLevel--;
this.outdent(); this.outdent();
} }
if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
insideScssMap = false;
this.outdent();
this._output.add_new_line();
}
this.print_string(this._ch); this.print_string(this._ch);
} else if (this._ch === ',') { } else if (this._ch === ',') {
this.print_string(this._ch); this.print_string(this._ch);
this.eatWhitespace(true); this.eatWhitespace(true);
if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) { if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
this._output.add_new_line(); this._output.add_new_line();
} else { } else {
this._output.space_before_token = true; this._output.space_before_token = true;
@ -1490,8 +1527,13 @@ Beautifier.prototype.beautify = function() {
this.print_string(' '); this.print_string(' ');
this.print_string(this._ch); this.print_string(this._ch);
} else { } else {
this.preserveSingleSpace(isAfterSpace); var preserveAfterSpace = previous_ch === '"' || previous_ch === '\'';
this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
this.print_string(this._ch); this.print_string(this._ch);
if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) {
this._output.add_new_line();
}
} }
} }

View file

@ -836,10 +836,10 @@ Beautifier.prototype.handle_start_block = function(current_token) {
)) { )) {
// We don't support TypeScript,but we didn't break it for a very long time. // We don't support TypeScript,but we didn't break it for a very long time.
// We'll try to keep not breaking it. // We'll try to keep not breaking it.
if (!in_array(this._last_last_text, ['class', 'interface'])) { if (in_array(this._last_last_text, ['class', 'interface']) && !in_array(second_token.text, [':', ','])) {
this.set_mode(MODE.ObjectLiteral);
} else {
this.set_mode(MODE.BlockStatement); this.set_mode(MODE.BlockStatement);
} else {
this.set_mode(MODE.ObjectLiteral);
} }
} else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') { } else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') {
// arrow function: (param1, paramN) => { statements } // arrow function: (param1, paramN) => { statements }
@ -955,7 +955,7 @@ Beautifier.prototype.handle_word = function(current_token) {
if (current_token.type === TOKEN.RESERVED) { if (current_token.type === TOKEN.RESERVED) {
if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) { if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;
} else if (current_token.text === 'import' && this._tokens.peek().text === '(') { } else if (current_token.text === 'import' && in_array(this._tokens.peek().text, ['(', '.'])) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;
} else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) { } else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;
@ -2533,7 +2533,7 @@ var digit = /[0-9]/;
var dot_pattern = /[^\d\.]/; var dot_pattern = /[^\d\.]/;
var positionable_operators = ( var positionable_operators = (
">>> === !== " + ">>> === !== &&= ??= ||= " +
"<< && >= ** != == <= >> || ?? |> " + "<< && >= ** != == <= >> || ?? |> " +
"< / - + > : & % ? ^ | *").split(' '); "< / - + > : & % ? ^ | *").split(' ');
@ -2541,7 +2541,7 @@ var positionable_operators = (
// Also, you must update possitionable operators separately from punct // Also, you must update possitionable operators separately from punct
var punct = var punct =
">>>= " + ">>>= " +
"... >>= <<= === >>> !== **= " + "... >>= <<= === >>> !== **= &&= ??= ||= " +
"=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " + "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " +
"= ! ? > < : / ^ - + * & % ~ |"; "= ! ? > < : / ^ - + * & % ~ |";

View file

@ -67,6 +67,9 @@ function Beautifier(source_text, options) {
"@supports": true, "@supports": true,
"@document": true "@document": true
}; };
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
"grid-template"
];
} }
@ -191,7 +194,9 @@ Beautifier.prototype.beautify = function() {
var enteringConditionalGroup = false; var enteringConditionalGroup = false;
var insideAtExtend = false; var insideAtExtend = false;
var insideAtImport = false; var insideAtImport = false;
var insideScssMap = false;
var topCharacter = this._ch; var topCharacter = this._ch;
var insideNonSemiColonValues = false;
var whitespace; var whitespace;
var isAfterSpace; var isAfterSpace;
var previous_ch; var previous_ch;
@ -243,7 +248,7 @@ Beautifier.prototype.beautify = function() {
// Ensures any new lines following the comment are preserved // Ensures any new lines following the comment are preserved
this.eatWhitespace(true); this.eatWhitespace(true);
} else if (this._ch === '@') { } else if (this._ch === '@' || this._ch === '$') {
this.preserveSingleSpace(isAfterSpace); this.preserveSingleSpace(isAfterSpace);
// deal with less propery mixins @{...} // deal with less propery mixins @{...}
@ -314,7 +319,12 @@ Beautifier.prototype.beautify = function() {
this.indent(); this.indent();
this._output.set_indent(this._indentLevel); this._output.set_indent(this._indentLevel);
} else { } else {
this.indent(); // inside mixin and first param is object
if (previous_ch === '(') {
this._output.space_before_token = false;
} else if (previous_ch !== ',') {
this.indent();
}
this.print_string(this._ch); this.print_string(this._ch);
} }
@ -346,7 +356,21 @@ Beautifier.prototype.beautify = function() {
this._output.add_new_line(true); this._output.add_new_line(true);
} }
} }
if (this._input.peek() === ')') {
this._output.trim(true);
if (this._options.brace_style === "expand") {
this._output.add_new_line(true);
}
}
} else if (this._ch === ":") { } else if (this._ch === ":") {
for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
insideNonSemiColonValues = true;
break;
}
}
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) { if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
// 'property: value' delimiter // 'property: value' delimiter
// which could be in a conditional group query // which could be in a conditional group query
@ -379,6 +403,7 @@ Beautifier.prototype.beautify = function() {
this.print_string(this._ch + this.eatString(this._ch)); this.print_string(this._ch + this.eatString(this._ch));
this.eatWhitespace(true); this.eatWhitespace(true);
} else if (this._ch === ';') { } else if (this._ch === ';') {
insideNonSemiColonValues = false;
if (parenLevel === 0) { if (parenLevel === 0) {
if (insidePropertyValue) { if (insidePropertyValue) {
this.outdent(); this.outdent();
@ -420,20 +445,32 @@ Beautifier.prototype.beautify = function() {
} else { } else {
this.preserveSingleSpace(isAfterSpace); this.preserveSingleSpace(isAfterSpace);
this.print_string(this._ch); this.print_string(this._ch);
this.eatWhitespace();
parenLevel++; // handle scss/sass map
this.indent(); if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
this._output.add_new_line();
insideScssMap = true;
} else {
this.eatWhitespace();
parenLevel++;
this.indent();
}
} }
} else if (this._ch === ')') { } else if (this._ch === ')') {
if (parenLevel) { if (parenLevel) {
parenLevel--; parenLevel--;
this.outdent(); this.outdent();
} }
if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
insideScssMap = false;
this.outdent();
this._output.add_new_line();
}
this.print_string(this._ch); this.print_string(this._ch);
} else if (this._ch === ',') { } else if (this._ch === ',') {
this.print_string(this._ch); this.print_string(this._ch);
this.eatWhitespace(true); this.eatWhitespace(true);
if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) { if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
this._output.add_new_line(); this._output.add_new_line();
} else { } else {
this._output.space_before_token = true; this._output.space_before_token = true;
@ -467,8 +504,13 @@ Beautifier.prototype.beautify = function() {
this.print_string(' '); this.print_string(' ');
this.print_string(this._ch); this.print_string(this._ch);
} else { } else {
this.preserveSingleSpace(isAfterSpace); var preserveAfterSpace = previous_ch === '"' || previous_ch === '\'';
this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
this.print_string(this._ch); this.print_string(this._ch);
if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) {
this._output.add_new_line();
}
} }
} }

View file

@ -691,10 +691,10 @@ Beautifier.prototype.handle_start_block = function(current_token) {
)) { )) {
// We don't support TypeScript,but we didn't break it for a very long time. // We don't support TypeScript,but we didn't break it for a very long time.
// We'll try to keep not breaking it. // We'll try to keep not breaking it.
if (!in_array(this._last_last_text, ['class', 'interface'])) { if (in_array(this._last_last_text, ['class', 'interface']) && !in_array(second_token.text, [':', ','])) {
this.set_mode(MODE.ObjectLiteral);
} else {
this.set_mode(MODE.BlockStatement); this.set_mode(MODE.BlockStatement);
} else {
this.set_mode(MODE.ObjectLiteral);
} }
} else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') { } else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') {
// arrow function: (param1, paramN) => { statements } // arrow function: (param1, paramN) => { statements }
@ -810,7 +810,7 @@ Beautifier.prototype.handle_word = function(current_token) {
if (current_token.type === TOKEN.RESERVED) { if (current_token.type === TOKEN.RESERVED) {
if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) { if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;
} else if (current_token.text === 'import' && this._tokens.peek().text === '(') { } else if (current_token.text === 'import' && in_array(this._tokens.peek().text, ['(', '.'])) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;
} else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) { } else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) {
current_token.type = TOKEN.WORD; current_token.type = TOKEN.WORD;

View file

@ -74,7 +74,7 @@ var digit = /[0-9]/;
var dot_pattern = /[^\d\.]/; var dot_pattern = /[^\d\.]/;
var positionable_operators = ( var positionable_operators = (
">>> === !== " + ">>> === !== &&= ??= ||= " +
"<< && >= ** != == <= >> || ?? |> " + "<< && >= ** != == <= >> || ?? |> " +
"< / - + > : & % ? ^ | *").split(' '); "< / - + > : & % ? ^ | *").split(' ');
@ -82,7 +82,7 @@ var positionable_operators = (
// Also, you must update possitionable operators separately from punct // Also, you must update possitionable operators separately from punct
var punct = var punct =
">>>= " + ">>>= " +
"... >>= <<= === >>> !== **= " + "... >>= <<= === >>> !== **= &&= ??= ||= " +
"=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " + "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " +
"= ! ? > < : / ^ - + * & % ~ |"; "= ! ? > < : / ^ - + * & % ~ |";

View file

@ -1,6 +1,6 @@
{ {
"name": "js-beautify", "name": "js-beautify",
"version": "1.14.2", "version": "1.14.3",
"description": "beautifier.io for node", "description": "beautifier.io for node",
"main": "js/index.js", "main": "js/index.js",
"bin": { "bin": {
@ -49,24 +49,24 @@
}, },
"browserslist": "ie 11", "browserslist": "ie 11",
"dependencies": { "dependencies": {
"config-chain": "^1.1.12", "config-chain": "^1.1.13",
"editorconfig": "^0.15.3", "editorconfig": "^0.15.3",
"glob": "^7.1.3", "glob": "^7.1.3",
"nopt": "^5.0.0" "nopt": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"ansi-regex": ">=6.0.1", "ansi-regex": "^6.0.1",
"benchmark": "^2.1.4", "benchmark": "^2.1.4",
"codemirror": "^5.56.0", "codemirror": "^5.65.2",
"jquery": "^3.5.1", "jquery": "^3.6.0",
"jshint": "^2.12.0", "jshint": "^2.13.4",
"minimist": ">=1.2.5", "minimist": "^1.2.6",
"mocha": "^9.0.1", "mocha": "^9.2.2",
"mustache": "^4.0.1", "mustache": "^4.2.0",
"requirejs": "^2.3.6", "requirejs": "^2.3.6",
"serve": "^13.0.2", "serve": "^13.0.2",
"strip-ansi": ">=7.0.1", "strip-ansi": "^7.0.1",
"webpack": "^5.32.0", "webpack": "^5.70.0",
"webpack-cli": "^4.6.0" "webpack-cli": "^4.9.2"
} }
} }

3
node_modules/uglify-js/lib/ast.js generated vendored
View file

@ -851,6 +851,9 @@ var AST_DefClass = DEFNODE("DefClass", null, {
$propdoc: { $propdoc: {
name: "[AST_SymbolDefClass] the name of this class", name: "[AST_SymbolDefClass] the name of this class",
}, },
resolve: function(def_class) {
return def_class ? this : this.parent_scope.resolve();
},
_validate: function() { _validate: function() {
if (!(this.name instanceof AST_SymbolDefClass)) throw new Error("name must be AST_SymbolDefClass"); if (!(this.name instanceof AST_SymbolDefClass)) throw new Error("name must be AST_SymbolDefClass");
}, },

View file

@ -751,6 +751,34 @@ Compressor.prototype.compress = function(node) {
}); });
} }
function make_fixed(save, fn) {
var prev_save, prev_value;
return function() {
var current = save();
if (prev_save !== current) {
prev_save = current;
prev_value = fn(current);
}
return prev_value;
};
}
function make_fixed_default(compressor, node, save) {
var prev_save, prev_seq;
return function() {
var current = save();
var ev;
if (!is_undefined(current, compressor) && (ev = fuzzy_eval(compressor, current, true)) !== undefined) {
return ev instanceof AST_Node ? node : current;
}
if (prev_save !== current) {
prev_save = current;
prev_seq = make_sequence(node, [ current, node.value ]);
}
return prev_seq;
};
}
function scan_declaration(tw, compressor, lhs, fixed, visit) { function scan_declaration(tw, compressor, lhs, fixed, visit) {
var scanner = new TreeWalker(function(node) { var scanner = new TreeWalker(function(node) {
if (node instanceof AST_DefaultValue) { if (node instanceof AST_DefaultValue) {
@ -759,15 +787,7 @@ Compressor.prototype.compress = function(node) {
node.value.walk(tw); node.value.walk(tw);
pop(tw); pop(tw);
var save = fixed; var save = fixed;
if (save) fixed = function() { if (save) fixed = make_fixed_default(compressor, node, save);
var value = save();
var ev;
if (is_undefined(value, compressor)
|| (ev = fuzzy_eval(compressor, value, true)) === undefined) {
return make_sequence(node, [ value, node.value ]);
}
return ev instanceof AST_Node ? node : value;
};
node.name.walk(scanner); node.name.walk(scanner);
fixed = save; fixed = save;
return true; return true;
@ -777,18 +797,17 @@ Compressor.prototype.compress = function(node) {
var save = fixed; var save = fixed;
node.elements.forEach(function(node, index) { node.elements.forEach(function(node, index) {
if (node instanceof AST_Hole) return reset_flags(node); if (node instanceof AST_Hole) return reset_flags(node);
if (save) fixed = function() { if (save) fixed = make_fixed(save, function(value) {
return make_node(AST_Sub, node, { return make_node(AST_Sub, node, {
expression: save(), expression: value,
property: make_node(AST_Number, node, { value: index }), property: make_node(AST_Number, node, { value: index }),
}); });
}; });
node.walk(scanner); node.walk(scanner);
}); });
if (node.rest) { if (node.rest) {
var fixed_node; var fixed_node;
if (save) fixed = compressor.option("rests") && function() { if (save) fixed = compressor.option("rests") && make_fixed(save, function(value) {
var value = save();
if (!(value instanceof AST_Array)) return node; if (!(value instanceof AST_Array)) return node;
for (var i = 0, len = node.elements.length; i < len; i++) { for (var i = 0, len = node.elements.length; i < len; i++) {
if (value.elements[i] instanceof AST_Spread) return node; if (value.elements[i] instanceof AST_Spread) return node;
@ -796,7 +815,7 @@ Compressor.prototype.compress = function(node) {
if (!fixed_node) fixed_node = make_node(AST_Array, node); if (!fixed_node) fixed_node = make_node(AST_Array, node);
fixed_node.elements = value.elements.slice(len); fixed_node.elements = value.elements.slice(len);
return fixed_node; return fixed_node;
}; });
node.rest.walk(scanner); node.rest.walk(scanner);
} }
fixed = save; fixed = save;
@ -812,7 +831,7 @@ Compressor.prototype.compress = function(node) {
node.key.walk(tw); node.key.walk(tw);
pop(tw); pop(tw);
} }
if (save) fixed = function() { if (save) fixed = make_fixed(save, function(value) {
var key = node.key; var key = node.key;
var type = AST_Sub; var type = AST_Sub;
if (typeof key == "string") { if (typeof key == "string") {
@ -823,10 +842,10 @@ Compressor.prototype.compress = function(node) {
} }
} }
return make_node(type, node, { return make_node(type, node, {
expression: save(), expression: value,
property: key property: key,
}); });
}; });
node.value.walk(scanner); node.value.walk(scanner);
}); });
if (node.rest) { if (node.rest) {
@ -2040,13 +2059,17 @@ Compressor.prototype.compress = function(node) {
if (is_lhs(node, parent)) { if (is_lhs(node, parent)) {
if (value_def && !hit_rhs) assign_used = true; if (value_def && !hit_rhs) assign_used = true;
return node; return node;
} else if (value_def) { }
if (!hit_rhs && verify_ref && node.fixed !== lhs.fixed) {
abort = true;
return node;
}
if (value_def) {
if (stop_if_hit && assign_pos == 0) assign_pos = remaining - replaced; if (stop_if_hit && assign_pos == 0) assign_pos = remaining - replaced;
if (!hit_rhs) replaced++; if (!hit_rhs) replaced++;
return node; return node;
} else {
replaced++;
} }
replaced++;
changed = abort = true; changed = abort = true;
AST_Node.info("Collapsing {node} [{file}:{line},{col}]", { AST_Node.info("Collapsing {node} [{file}:{line},{col}]", {
node: node, node: node,
@ -2221,6 +2244,7 @@ Compressor.prototype.compress = function(node) {
var candidate = hit_stack[hit_stack.length - 1]; var candidate = hit_stack[hit_stack.length - 1];
var assign_pos = -1; var assign_pos = -1;
var assign_used = false; var assign_used = false;
var verify_ref = false;
var remaining; var remaining;
var value_def = null; var value_def = null;
var stop_after = null; var stop_after = null;
@ -2248,8 +2272,11 @@ Compressor.prototype.compress = function(node) {
var lvalues = get_lvalues(candidate); var lvalues = get_lvalues(candidate);
var lhs_local = is_lhs_local(lhs); var lhs_local = is_lhs_local(lhs);
var rhs_value = get_rvalue(candidate); var rhs_value = get_rvalue(candidate);
var rvalue = !compound && rhs_value instanceof AST_Sequence ? rhs_value.tail_node() : rhs_value; var rvalue = rhs_value;
if (!side_effects) side_effects = value_has_side_effects(); if (!side_effects) {
if (!compound && rvalue instanceof AST_Sequence) rvalue = rvalue.tail_node();
side_effects = value_has_side_effects();
}
var check_destructured = in_try || !lhs_local ? function(node) { var check_destructured = in_try || !lhs_local ? function(node) {
return node instanceof AST_Destructured; return node instanceof AST_Destructured;
} : return_false; } : return_false;
@ -2936,6 +2963,7 @@ Compressor.prototype.compress = function(node) {
if (matches < remaining) { if (matches < remaining) {
remaining = matches; remaining = matches;
assign_pos = 0; assign_pos = 0;
verify_ref = true;
} }
} }
if (expr.operator == "=") mangleable_var(expr.right); if (expr.operator == "=") mangleable_var(expr.right);
@ -3163,47 +3191,42 @@ Compressor.prototype.compress = function(node) {
return; return;
} }
var end = hit_stack.length - 1; var end = hit_stack.length - 1;
if (hit_stack[end - 1].body === hit_stack[end]) end--; var last = hit_stack[end];
if (last instanceof AST_VarDef || hit_stack[end - 1].body === last) end--;
var tt = new TreeTransformer(function(node, descend, in_list) { var tt = new TreeTransformer(function(node, descend, in_list) {
if (hit) return node; if (hit) return node;
if (node !== hit_stack[hit_index]) return node; if (node !== hit_stack[hit_index]) return node;
hit_index++; hit_index++;
if (hit_index <= end) return handle_custom_scan_order(node, tt); if (hit_index <= end) return handle_custom_scan_order(node, tt);
hit = true; hit = true;
if (node instanceof AST_VarDef) { if (node instanceof AST_Definitions) {
declare_only.set(node.name.name, (declare_only.get(node.name.name) || 0) + 1); declare_only.set(last.name.name, (declare_only.get(last.name.name) || 0) + 1);
if (value_def) value_def.replaced++; if (value_def) value_def.replaced++;
node = node.clone(); var defns = node.definitions;
node.value = null; var index = defns.indexOf(last);
return value ? List.splice([ value, node ]) : node; var defn = last.clone();
defn.value = null;
if (!value) {
node.definitions[index] = defn;
return node;
}
var body = [ make_node(AST_SimpleStatement, value, { body: value }) ];
if (index > 0) {
var head = node.clone();
head.definitions = defns.slice(0, index);
body.unshift(head);
node = node.clone();
node.definitions = defns.slice(index);
}
body.push(node);
node.definitions[0] = defn;
return in_list ? List.splice(body) : make_node(AST_BlockStatement, node, { body: body });
} }
if (!value) return in_list ? List.skip : null; if (!value) return in_list ? List.skip : null;
return is_statement(node) ? make_node(AST_SimpleStatement, value, { body: value }) : value; return is_statement(node) ? make_node(AST_SimpleStatement, value, { body: value }) : value;
}, function(node, in_list) { }, function(node, in_list) {
if (node instanceof AST_Definitions) {
var body = [], defns = node.definitions;
for (var index = 0, pos = 0; index < defns.length; index++) {
var defn = defns[index];
if (defn instanceof AST_VarDef) continue;
flush();
pos = index + 1;
body.push(make_node(AST_SimpleStatement, defn, { body: defn }));
}
if (pos == 0) return;
flush();
if (body.length == 1) return body[0];
return in_list ? List.splice(body) : make_node(AST_BlockStatement, node, { body: body });
}
if (node instanceof AST_For) return patch_for_init(node, in_list); if (node instanceof AST_For) return patch_for_init(node, in_list);
return patch_sequence(node, this); return patch_sequence(node, tt);
function flush() {
if (pos < index) {
var cropped = node.clone();
cropped.definitions = defns.slice(pos, index);
body.push(cropped);
}
}
}); });
abort = false; abort = false;
hit = false; hit = false;
@ -3249,9 +3272,13 @@ Compressor.prototype.compress = function(node) {
} }
var def = lhs.definition(); var def = lhs.definition();
if (def.references.length - def.replaced == referenced) return true; if (def.references.length - def.replaced == referenced) return true;
return def.fixed && lhs.fixed && def.references.filter(function(ref) { if (!def.fixed) return false;
if (!lhs.fixed) return false;
if (def.references.filter(function(ref) {
return ref.fixed === lhs.fixed; return ref.fixed === lhs.fixed;
}).length == referenced; }).length != referenced) return false;
verify_ref = true;
return true;
} }
function symbol_in_lvalues(sym, parent) { function symbol_in_lvalues(sym, parent) {
@ -3269,7 +3296,7 @@ Compressor.prototype.compress = function(node) {
if (def.scope.resolve() !== scope) return true; if (def.scope.resolve() !== scope) return true;
if (modify_toplevel && compressor.exposed(def)) return true; if (modify_toplevel && compressor.exposed(def)) return true;
return !all(def.references, function(ref) { return !all(def.references, function(ref) {
return ref.scope.resolve() === scope; return ref.scope.resolve(true) === scope;
}); });
} }
@ -4767,6 +4794,7 @@ Compressor.prototype.compress = function(node) {
}); });
var scan_modified = new TreeWalker(function(node) { var scan_modified = new TreeWalker(function(node) {
if (node instanceof AST_Assign) modified(node.left); if (node instanceof AST_Assign) modified(node.left);
if (node instanceof AST_ForEnumeration) modified(node.init);
if (node instanceof AST_Unary && UNARY_POSTFIX[node.operator]) modified(node.expression); if (node instanceof AST_Unary && UNARY_POSTFIX[node.operator]) modified(node.expression);
}); });
function modified(node) { function modified(node) {
@ -5425,7 +5453,6 @@ Compressor.prototype.compress = function(node) {
return !(prop instanceof AST_ObjectGetter || prop instanceof AST_Spread); return !(prop instanceof AST_ObjectGetter || prop instanceof AST_Spread);
}); });
}); });
def(AST_ObjectIdentity, return_true);
def(AST_Sequence, function() { def(AST_Sequence, function() {
return this.tail_node().safe_to_spread(); return this.tail_node().safe_to_spread();
}); });
@ -6847,7 +6874,14 @@ Compressor.prototype.compress = function(node) {
}); });
} }
} }
if (node instanceof AST_Call) calls_to_drop_args.push(node); if (node instanceof AST_Call) {
calls_to_drop_args.push(node);
node.args = node.args.map(function(arg) {
return arg.transform(tt);
});
node.expression = node.expression.transform(tt);
return node;
}
if (scope !== self) return; if (scope !== self) return;
if (drop_funcs && node !== self && node instanceof AST_DefClass) { if (drop_funcs && node !== self && node instanceof AST_DefClass) {
var def = node.name.definition(); var def = node.name.definition();
@ -7114,6 +7148,7 @@ Compressor.prototype.compress = function(node) {
if (def.orig.length > 1) return null; if (def.orig.length > 1) return null;
if (def.assignments > 0) return false; if (def.assignments > 0) return false;
if (def.name == name) return def; if (def.name == name) return def;
if (compressor.option("keep_fnames")) return false;
var forbidden; var forbidden;
switch (name) { switch (name) {
case "await": case "await":
@ -7818,7 +7853,7 @@ Compressor.prototype.compress = function(node) {
var consts = new Dictionary(); var consts = new Dictionary();
var dirs = []; var dirs = [];
var hoisted = []; var hoisted = [];
var vars = new Dictionary(), vars_found = 0; var vars = new Dictionary();
var tt = new TreeTransformer(function(node, descend, in_list) { var tt = new TreeTransformer(function(node, descend, in_list) {
if (node === self) return; if (node === self) return;
if (node instanceof AST_Directive) { if (node instanceof AST_Directive) {
@ -7846,7 +7881,6 @@ Compressor.prototype.compress = function(node) {
})) return node; })) return node;
node.definitions.forEach(function(defn) { node.definitions.forEach(function(defn) {
vars.set(defn.name.name, defn); vars.set(defn.name.name, defn);
++vars_found;
}); });
var seq = node.to_assignments(); var seq = node.to_assignments();
if (p instanceof AST_ForEnumeration && p.init === node) { if (p instanceof AST_ForEnumeration && p.init === node) {
@ -7865,7 +7899,7 @@ Compressor.prototype.compress = function(node) {
} }
}); });
self.transform(tt); self.transform(tt);
if (vars_found > 0) { if (vars.size() > 0) {
// collect only vars which don't show up in self's arguments list // collect only vars which don't show up in self's arguments list
var defns = []; var defns = [];
if (self instanceof AST_Lambda) self.each_argname(function(argname) { if (self instanceof AST_Lambda) self.each_argname(function(argname) {
@ -9633,8 +9667,16 @@ Compressor.prototype.compress = function(node) {
fixed.escaped = def.escaped; fixed.escaped = def.escaped;
name.fixed = fixed; name.fixed = fixed;
def.references.forEach(function(ref) { def.references.forEach(function(ref) {
var assigns = ref.fixed && ref.fixed.assigns; if (!ref.fixed) return;
if (assigns && assigns[0] === defn) assigns[0] = assign; var assigns = ref.fixed.assigns;
if (!assigns) return;
if (assigns[0] !== defn) return;
if (assigns.length > 1 || ref.fixed.to_binary || ref.fixed.to_prefix) {
assigns[0] = assign;
} else {
ref.fixed = fixed;
if (def.fixed === ref.fixed) def.fixed = fixed;
}
}); });
def.references.push(name); def.references.push(name);
} }
@ -12901,43 +12943,44 @@ Compressor.prototype.compress = function(node) {
AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) { AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
if (!compressor.option("properties")) return; if (!compressor.option("properties")) return;
if (key === "__proto__") return; if (key === "__proto__") return;
var expr = this.expression; var self = this;
if (expr instanceof AST_Object) { var expr = self.expression;
var props = expr.properties; if (!(expr instanceof AST_Object)) return;
for (var i = props.length; --i >= 0;) { var props = expr.properties;
var prop = props[i]; for (var i = props.length; --i >= 0;) {
if (prop.key !== key) continue; var prop = props[i];
if (!all(props, can_hoist_property)) return; if (prop.key !== key) continue;
if (!safe_to_flatten(prop.value, compressor)) return; if (!all(props, can_hoist_property)) return;
var scope, values = []; if (!safe_to_flatten(prop.value, compressor)) return;
for (var j = 0; j < props.length; j++) { var call, scope, values = [];
var value = props[j].value; for (var j = 0; j < props.length; j++) {
if (props[j] instanceof AST_ObjectMethod) { var value = props[j].value;
var arrow = !(value.uses_arguments || is_generator(value) || value.contains_this()); if (props[j] instanceof AST_ObjectMethod) {
if (arrow) { var arrow = !(value.uses_arguments || is_generator(value) || value.contains_this());
if (!scope) scope = compressor.find_parent(AST_Scope); if (arrow) {
var avoid = avoid_await_yield(scope); if (!scope) scope = compressor.find_parent(AST_Scope);
value.each_argname(function(argname) { var avoid = avoid_await_yield(scope);
if (avoid[argname.name]) arrow = false; value.each_argname(function(argname) {
}); if (avoid[argname.name]) arrow = false;
} });
var ctor;
if (arrow) {
ctor = is_async(value) ? AST_AsyncArrow : AST_Arrow;
} else if (i === j && !(compressor.parent() instanceof AST_Call)) {
return;
} else {
ctor = value.CTOR;
}
value = make_node(ctor, value, value);
} }
values.push(value); var ctor;
if (arrow) {
ctor = is_async(value) ? AST_AsyncArrow : AST_Arrow;
} else if (i != j
|| (call = compressor.parent()) instanceof AST_Call && call.expression === self) {
ctor = value.CTOR;
} else {
return;
}
value = make_node(ctor, value, value);
} }
return make_node(AST_Sub, this, { values.push(value);
expression: make_node(AST_Array, expr, { elements: values }),
property: make_node(AST_Number, this, { value: i }),
});
} }
return make_node(AST_Sub, self, {
expression: make_node(AST_Array, expr, { elements: values }),
property: make_node(AST_Number, self, { value: i }),
});
} }
}); });
@ -13134,6 +13177,19 @@ Compressor.prototype.compress = function(node) {
return found; return found;
} }
function insert_assign(def, assign) {
var visited = [];
def.references.forEach(function(ref) {
var fixed = ref.fixed;
if (!fixed || !push_uniq(visited, fixed)) return;
if (fixed.assigns) {
fixed.assigns.unshift(assign);
} else {
fixed.assigns = [ assign ];
}
});
}
function init_ref(compressor, name) { function init_ref(compressor, name) {
var sym = make_node(AST_SymbolRef, name, name); var sym = make_node(AST_SymbolRef, name, name);
var assign = make_node(AST_Assign, name, { var assign = make_node(AST_Assign, name, {
@ -13147,16 +13203,7 @@ Compressor.prototype.compress = function(node) {
return assign.right; return assign.right;
}; };
sym.fixed.assigns = [ assign ]; sym.fixed.assigns = [ assign ];
var visited = []; insert_assign(def, assign);
def.references.forEach(function(ref) {
var fixed = ref.fixed;
if (!fixed || !push_uniq(visited, fixed)) return;
if (fixed.assigns) {
fixed.assigns.unshift(assign);
} else {
fixed.assigns = [ assign ];
}
});
} }
def.assignments++; def.assignments++;
def.references.push(sym); def.references.push(sym);
@ -13260,6 +13307,7 @@ Compressor.prototype.compress = function(node) {
if (fn.body[0] instanceof AST_Directive) return; if (fn.body[0] instanceof AST_Directive) return;
if (fn.contains_this()) return; if (fn.contains_this()) return;
if (!scope) scope = find_scope(compressor); if (!scope) scope = find_scope(compressor);
if (in_async_generator(scope)) return;
var defined = new Dictionary(); var defined = new Dictionary();
defined.set("NaN", true); defined.set("NaN", true);
while (!(scope instanceof AST_Scope)) { while (!(scope instanceof AST_Scope)) {
@ -13364,12 +13412,12 @@ Compressor.prototype.compress = function(node) {
if (value) body.push(make_node(AST_SimpleStatement, call, { body: value })); if (value) body.push(make_node(AST_SimpleStatement, call, { body: value }));
return; return;
} }
body.push(make_node(AST_Var, call, { var defn = make_node(AST_VarDef, call, {
definitions: [ make_node(AST_VarDef, call, { name: argname.convert_symbol(AST_SymbolVar, process),
name: argname.convert_symbol(AST_SymbolVar, process), value: value || make_node(AST_Undefined, call).transform(compressor),
value: value || make_node(AST_Undefined, call).transform(compressor), });
}) ], if (argname instanceof AST_SymbolFunarg) insert_assign(argname.definition(), defn);
})); body.push(make_node(AST_Var, call, { definitions: [ defn ] }));
}); });
if (values.length) body.push(make_node(AST_SimpleStatement, call, { if (values.length) body.push(make_node(AST_SimpleStatement, call, {
body: make_sequence(call, values), body: make_sequence(call, values),
@ -13500,6 +13548,12 @@ Compressor.prototype.compress = function(node) {
def(AST_LabeledStatement, function(compressor, scope, no_return, in_loop) { def(AST_LabeledStatement, function(compressor, scope, no_return, in_loop) {
var body = this.body.try_inline(compressor, scope, no_return, in_loop); var body = this.body.try_inline(compressor, scope, no_return, in_loop);
if (!body) return; if (!body) return;
if (this.body instanceof AST_IterationStatement && body instanceof AST_BlockStatement) {
var loop = body.body.pop();
this.body = loop;
body.body.push(this);
return body;
}
this.body = body; this.body = body;
return this; return this;
}); });

18
node_modules/uglify-js/lib/minify.js generated vendored
View file

@ -96,15 +96,14 @@ function minify(files, options) {
}, true); }, true);
if (options.validate) AST_Node.enable_validation(); if (options.validate) AST_Node.enable_validation();
var timings = options.timings && { start: Date.now() }; var timings = options.timings && { start: Date.now() };
if (options.rename === undefined) options.rename = options.compress && options.mangle;
if (options.annotations !== undefined) set_shorthand("annotations", options, [ "compress", "output" ]); if (options.annotations !== undefined) set_shorthand("annotations", options, [ "compress", "output" ]);
if (options.ie8) options.ie = options.ie || options.ie8; if (options.ie8) options.ie = options.ie || options.ie8;
if (options.ie) set_shorthand("ie", options, [ "compress", "mangle", "output" ]); if (options.ie) set_shorthand("ie", options, [ "compress", "mangle", "output", "rename" ]);
if (options.keep_fargs) set_shorthand("keep_fargs", options, [ "compress", "mangle" ]); if (options.keep_fargs) set_shorthand("keep_fargs", options, [ "compress", "mangle", "rename" ]);
if (options.keep_fnames) set_shorthand("keep_fnames", options, [ "compress", "mangle" ]); if (options.keep_fnames) set_shorthand("keep_fnames", options, [ "compress", "mangle", "rename" ]);
if (options.toplevel) set_shorthand("toplevel", options, [ "compress", "mangle" ]); if (options.toplevel) set_shorthand("toplevel", options, [ "compress", "mangle", "rename" ]);
if (options.v8) set_shorthand("v8", options, [ "mangle", "output" ]); if (options.v8) set_shorthand("v8", options, [ "mangle", "output", "rename" ]);
if (options.webkit) set_shorthand("webkit", options, [ "compress", "mangle", "output" ]); if (options.webkit) set_shorthand("webkit", options, [ "compress", "mangle", "output", "rename" ]);
var quoted_props; var quoted_props;
if (options.mangle) { if (options.mangle) {
options.mangle = defaults(options.mangle, { options.mangle = defaults(options.mangle, {
@ -135,6 +134,7 @@ function minify(files, options) {
init_cache(options.mangle.cache); init_cache(options.mangle.cache);
init_cache(options.mangle.properties.cache); init_cache(options.mangle.properties.cache);
} }
if (options.rename === undefined) options.rename = options.compress && options.mangle;
if (options.sourceMap) { if (options.sourceMap) {
options.sourceMap = defaults(options.sourceMap, { options.sourceMap = defaults(options.sourceMap, {
content: null, content: null,
@ -190,8 +190,8 @@ function minify(files, options) {
if (options.validate) toplevel.validate_ast(); if (options.validate) toplevel.validate_ast();
if (timings) timings.rename = Date.now(); if (timings) timings.rename = Date.now();
if (options.rename) { if (options.rename) {
toplevel.figure_out_scope(options.mangle); toplevel.figure_out_scope(options.rename);
toplevel.expand_names(options.mangle); toplevel.expand_names(options.rename);
} }
if (timings) timings.compress = Date.now(); if (timings) timings.compress = Date.now();
if (options.compress) { if (options.compress) {

View file

@ -1194,10 +1194,10 @@ function parse($TEXT, options) {
} }
function for_() { function for_() {
var await = is("name", "await") && next(); var await_token = is("name", "await") && next();
expect("("); expect("(");
var init = null; var init = null;
if (await || !is("punc", ";")) { if (await_token || !is("punc", ";")) {
init = is("keyword", "const") init = is("keyword", "const")
? (next(), const_(true)) ? (next(), const_(true))
: is("name", "let") && is_vardefs() : is("name", "let") && is_vardefs()
@ -1206,7 +1206,7 @@ function parse($TEXT, options) {
? (next(), var_(true)) ? (next(), var_(true))
: expression(true); : expression(true);
var ctor; var ctor;
if (await) { if (await_token) {
expect_token("name", "of"); expect_token("name", "of");
ctor = AST_ForAwaitOf; ctor = AST_ForAwaitOf;
} else if (is("operator", "in")) { } else if (is("operator", "in")) {

View file

@ -3,7 +3,7 @@
"description": "JavaScript parser, mangler/compressor and beautifier toolkit", "description": "JavaScript parser, mangler/compressor and beautifier toolkit",
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)", "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"version": "3.15.3", "version": "3.15.4",
"engines": { "engines": {
"node": ">=0.8.0" "node": ">=0.8.0"
}, },

View file

@ -5,7 +5,7 @@
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
'reference' => '3ef2272400709ef0c5dc143d1fabaf31d5f681c1', 'reference' => '8dacc7e961dbc4e4233f2a94721f7d2db2f2f8b7',
'name' => '__root__', 'name' => '__root__',
'dev' => true, 'dev' => true,
), ),
@ -16,7 +16,7 @@
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
'reference' => '3ef2272400709ef0c5dc143d1fabaf31d5f681c1', 'reference' => '8dacc7e961dbc4e4233f2a94721f7d2db2f2f8b7',
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'composer/ca-bundle' => array( 'composer/ca-bundle' => array(
@ -172,8 +172,8 @@
'psr/http-factory-implementation' => array( 'psr/http-factory-implementation' => array(
'dev_requirement' => false, 'dev_requirement' => false,
'provided' => array( 'provided' => array(
0 => '^1.0', 0 => '1.0',
1 => '1.0', 1 => '^1.0',
), ),
), ),
'psr/http-message' => array( 'psr/http-message' => array(

View file

@ -812,7 +812,7 @@ concat-with-sourcemaps@^1.0.0, concat-with-sourcemaps@^1.1.0:
dependencies: dependencies:
source-map "^0.6.1" source-map "^0.6.1"
config-chain@^1.1.12: config-chain@^1.1.13:
version "1.1.13" version "1.1.13"
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.13.tgz#fad0795aa6a6cdaff9ed1b68e9dff94372c232f4" resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.13.tgz#fad0795aa6a6cdaff9ed1b68e9dff94372c232f4"
integrity sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ== integrity sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==
@ -2326,11 +2326,11 @@ jquery@^3.4.0:
integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw== integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==
js-beautify@^1.13.13: js-beautify@^1.13.13:
version "1.14.2" version "1.14.3"
resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.14.2.tgz#8180514fd4c7789c4ac4bcc327b6dda634c55666" resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.14.3.tgz#3dd11c949178de7f3bdf3f6f752778d3bed95150"
integrity sha512-H85kX95a53os+q1OCqtYe8AXAmgy3BvtysA/V83S3fdhznm6WlUpGi14DqSPbKFsL3dXZFXYl7YQwW9U1+76ng== integrity sha512-f1ra8PHtOEu/70EBnmiUlV8nJePS58y9qKjl4JHfYWlFH6bo7ogZBz//FAZp7jDuXtYnGYKymZPlrg2I/9Zo4g==
dependencies: dependencies:
config-chain "^1.1.12" config-chain "^1.1.13"
editorconfig "^0.15.3" editorconfig "^0.15.3"
glob "^7.1.3" glob "^7.1.3"
nopt "^5.0.0" nopt "^5.0.0"
@ -4140,9 +4140,9 @@ typedarray@^0.0.6:
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
uglify-js@^3.0.5: uglify-js@^3.0.5:
version "3.15.3" version "3.15.4"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.3.tgz#9aa82ca22419ba4c0137642ba0df800cb06e0471" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.15.4.tgz#fa95c257e88f85614915b906204b9623d4fa340d"
integrity sha512-6iCVm2omGJbsu3JWac+p6kUiOpg3wFO2f8lIXjfEb8RrmLjzog1wTPMmwKB7swfzzqxj9YM+sGUM++u1qN4qJg== integrity sha512-vMOPGDuvXecPs34V74qDKk4iJ/SN4vL3Ow/23ixafENYvtrNvtbcgUeugTcUGRGsOF/5fU8/NYSL5Hyb3l1OJA==
unc-path-regex@^0.1.2: unc-path-regex@^0.1.2:
version "0.1.2" version "0.1.2"