update deps
This commit is contained in:
173
node_modules/uglify-js/lib/output.js
generated
vendored
173
node_modules/uglify-js/lib/output.js
generated
vendored
@@ -91,13 +91,11 @@ function OutputStream(options) {
|
||||
comment_filter = function(comment) {
|
||||
return comment.type != "comment5" && comments.test(comment.value);
|
||||
};
|
||||
}
|
||||
else if (typeof comments === "function") {
|
||||
} else if (typeof comments === "function") {
|
||||
comment_filter = function(comment) {
|
||||
return comment.type != "comment5" && comments(this, comment);
|
||||
};
|
||||
}
|
||||
else if (comments === "some") {
|
||||
} else if (comments === "some") {
|
||||
comment_filter = is_some_comments;
|
||||
} else { // NOTE includes "all" option
|
||||
comment_filter = return_true;
|
||||
@@ -123,7 +121,7 @@ function OutputStream(options) {
|
||||
});
|
||||
} : function(str) {
|
||||
var s = "";
|
||||
for (var i = 0, len = str.length; i < len; i++) {
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
if (is_surrogate_pair_head(str[i]) && !is_surrogate_pair_tail(str[i + 1])
|
||||
|| is_surrogate_pair_tail(str[i]) && !is_surrogate_pair_head(str[i - 1])) {
|
||||
s += "\\u" + str.charCodeAt(i).toString(16);
|
||||
@@ -136,8 +134,7 @@ function OutputStream(options) {
|
||||
|
||||
function make_string(str, quote) {
|
||||
var dq = 0, sq = 0;
|
||||
str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
|
||||
function(s, i) {
|
||||
str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g, function(s, i) {
|
||||
switch (s) {
|
||||
case '"': ++dq; return '"';
|
||||
case "'": ++sq; return "'";
|
||||
@@ -217,23 +214,12 @@ function OutputStream(options) {
|
||||
|
||||
var flush_mappings = mappings ? function() {
|
||||
mappings.forEach(function(mapping) {
|
||||
try {
|
||||
options.source_map.add(
|
||||
mapping.token.file,
|
||||
mapping.line, mapping.col,
|
||||
mapping.token.line, mapping.token.col,
|
||||
!mapping.name && mapping.token.type == "name" ? mapping.token.value : mapping.name
|
||||
);
|
||||
} catch(ex) {
|
||||
AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", {
|
||||
file: mapping.token.file,
|
||||
line: mapping.token.line,
|
||||
col: mapping.token.col,
|
||||
cline: mapping.line,
|
||||
ccol: mapping.col,
|
||||
name: mapping.name || ""
|
||||
})
|
||||
}
|
||||
options.source_map.add(
|
||||
mapping.token.file,
|
||||
mapping.line, mapping.col,
|
||||
mapping.token.line, mapping.token.col,
|
||||
!mapping.name && mapping.token.type == "name" ? mapping.token.value : mapping.name
|
||||
);
|
||||
});
|
||||
mappings = [];
|
||||
} : noop;
|
||||
@@ -283,7 +269,7 @@ function OutputStream(options) {
|
||||
}
|
||||
}
|
||||
newline_insert = -1;
|
||||
var prev = last.charAt(last.length - 1);
|
||||
var prev = last.slice(-1);
|
||||
if (might_need_semicolon) {
|
||||
might_need_semicolon = false;
|
||||
|
||||
@@ -312,16 +298,16 @@ function OutputStream(options) {
|
||||
}
|
||||
|
||||
if (might_need_space) {
|
||||
if ((is_identifier_char(prev)
|
||||
&& (is_identifier_char(ch) || ch == "\\"))
|
||||
if (is_identifier_char(prev) && (is_identifier_char(ch) || ch == "\\")
|
||||
|| (ch == "/" && ch == prev)
|
||||
|| ((ch == "+" || ch == "-") && ch == last))
|
||||
{
|
||||
|| ((ch == "+" || ch == "-") && ch == last)
|
||||
|| str == "--" && last == "!"
|
||||
|| last == "--" && ch == ">") {
|
||||
OUTPUT += " ";
|
||||
current_col++;
|
||||
current_pos++;
|
||||
}
|
||||
might_need_space = false;
|
||||
if (prev != "<" || str != "!") might_need_space = false;
|
||||
}
|
||||
|
||||
if (mapping_token) {
|
||||
@@ -336,7 +322,7 @@ function OutputStream(options) {
|
||||
}
|
||||
|
||||
OUTPUT += str;
|
||||
has_parens = str[str.length - 1] == "(";
|
||||
has_parens = str.slice(-1) == "(";
|
||||
current_pos += str.length;
|
||||
var a = str.split(/\r?\n/), n = a.length - 1;
|
||||
current_line += n;
|
||||
@@ -462,16 +448,11 @@ function OutputStream(options) {
|
||||
|
||||
function prepend_comments(node) {
|
||||
var self = this;
|
||||
var start = node.start;
|
||||
if (!start) return;
|
||||
if (start.comments_before && start.comments_before._dumped === self) return;
|
||||
var comments = start.comments_before;
|
||||
if (!comments) {
|
||||
comments = start.comments_before = [];
|
||||
}
|
||||
comments._dumped = self;
|
||||
var scan = node instanceof AST_Exit && node.value;
|
||||
var comments = dump(node);
|
||||
if (!comments) comments = [];
|
||||
|
||||
if (node instanceof AST_Exit && node.value) {
|
||||
if (scan) {
|
||||
var tw = new TreeWalker(function(node) {
|
||||
var parent = tw.parent();
|
||||
if (parent instanceof AST_Exit
|
||||
@@ -482,11 +463,8 @@ function OutputStream(options) {
|
||||
|| parent instanceof AST_Sequence && parent.expressions[0] === node
|
||||
|| parent instanceof AST_Sub && parent.expression === node
|
||||
|| parent instanceof AST_UnaryPostfix) {
|
||||
var text = node.start.comments_before;
|
||||
if (text && text._dumped !== self) {
|
||||
text._dumped = self;
|
||||
comments = comments.concat(text);
|
||||
}
|
||||
var before = dump(node);
|
||||
if (before) comments = comments.concat(before);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@@ -529,13 +507,29 @@ function OutputStream(options) {
|
||||
}
|
||||
});
|
||||
if (!last_nlb) {
|
||||
if (start.nlb) {
|
||||
if (node.start.nlb) {
|
||||
print("\n");
|
||||
indent();
|
||||
} else {
|
||||
space();
|
||||
}
|
||||
}
|
||||
|
||||
function dump(node) {
|
||||
var token = node.start;
|
||||
if (!token) {
|
||||
if (!scan) return;
|
||||
node.start = token = new AST_Token();
|
||||
}
|
||||
var comments = token.comments_before;
|
||||
if (!comments) {
|
||||
if (!scan) return;
|
||||
token.comments_before = comments = [];
|
||||
}
|
||||
if (comments._dumped === self) return;
|
||||
comments._dumped = self;
|
||||
return comments;
|
||||
}
|
||||
}
|
||||
|
||||
function append_comments(node, tail) {
|
||||
@@ -602,7 +596,6 @@ function OutputStream(options) {
|
||||
}
|
||||
print(encoded);
|
||||
},
|
||||
encode_string : encode_string,
|
||||
next_indent : next_indent,
|
||||
with_indent : with_indent,
|
||||
with_block : with_block,
|
||||
@@ -648,8 +641,7 @@ function OutputStream(options) {
|
||||
var self = this, generator = self._codegen;
|
||||
if (self instanceof AST_Scope) {
|
||||
active_scope = self;
|
||||
}
|
||||
else if (!use_asm && self instanceof AST_Directive && self.value == "use asm") {
|
||||
} else if (!use_asm && self instanceof AST_Directive && self.value == "use asm") {
|
||||
use_asm = active_scope;
|
||||
}
|
||||
function doit() {
|
||||
@@ -719,16 +711,23 @@ function OutputStream(options) {
|
||||
|
||||
PARENS(AST_Sequence, function(output) {
|
||||
var p = output.parent();
|
||||
return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
|
||||
|| p instanceof AST_Unary // !(foo, bar, baz)
|
||||
|| p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
|
||||
|| p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
|
||||
|| p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
|
||||
|| p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
|
||||
|| p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
|
||||
|| p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
|
||||
* ==> 20 (side effect, set a := 10 and b := 20) */
|
||||
;
|
||||
// (foo, bar)() or foo(1, (2, 3), 4)
|
||||
return p instanceof AST_Call
|
||||
// !(foo, bar, baz)
|
||||
|| p instanceof AST_Unary
|
||||
// 1 + (2, 3) + 4 ==> 8
|
||||
|| p instanceof AST_Binary
|
||||
// var a = (1, 2), b = a + a; ==> b == 4
|
||||
|| p instanceof AST_VarDef
|
||||
// (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
|
||||
|| p instanceof AST_PropAccess && p.expression === this
|
||||
// [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
|
||||
|| p instanceof AST_Array
|
||||
// { foo: (1, 2) }.foo ==> 2
|
||||
|| p instanceof AST_ObjectProperty
|
||||
// (false, true) ? (a = 10, b = 20) : (c = 30)
|
||||
// ==> 20 (side effect, set a := 10 and b := 20)
|
||||
|| p instanceof AST_Conditional;
|
||||
});
|
||||
|
||||
PARENS(AST_Binary, function(output) {
|
||||
@@ -1048,11 +1047,9 @@ function OutputStream(options) {
|
||||
return;
|
||||
}
|
||||
b = b.alternative;
|
||||
}
|
||||
else if (b instanceof AST_StatementWithBody) {
|
||||
} else if (b instanceof AST_StatementWithBody) {
|
||||
b = b.body;
|
||||
}
|
||||
else break;
|
||||
} else break;
|
||||
}
|
||||
force_statement(self.body, output);
|
||||
}
|
||||
@@ -1257,29 +1254,10 @@ function OutputStream(options) {
|
||||
output.print(self.operator);
|
||||
});
|
||||
DEFPRINT(AST_Binary, function(self, output) {
|
||||
var op = self.operator;
|
||||
self.left.print(output);
|
||||
if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
|
||||
&& self.left instanceof AST_UnaryPostfix
|
||||
&& self.left.operator == "--") {
|
||||
// space is mandatory to avoid outputting -->
|
||||
output.print(" ");
|
||||
} else {
|
||||
// the space is optional depending on "beautify"
|
||||
output.space();
|
||||
}
|
||||
output.print(op);
|
||||
if ((op == "<" || op == "<<")
|
||||
&& self.right instanceof AST_UnaryPrefix
|
||||
&& self.right.operator == "!"
|
||||
&& self.right.expression instanceof AST_UnaryPrefix
|
||||
&& self.right.expression.operator == "--") {
|
||||
// space is mandatory to avoid outputting <!--
|
||||
output.print(" ");
|
||||
} else {
|
||||
// the space is optional depending on "beautify"
|
||||
output.space();
|
||||
}
|
||||
output.space();
|
||||
output.print(self.operator);
|
||||
output.space();
|
||||
self.right.print(output);
|
||||
});
|
||||
DEFPRINT(AST_Conditional, function(self, output) {
|
||||
@@ -1360,7 +1338,7 @@ function OutputStream(options) {
|
||||
});
|
||||
DEFPRINT(AST_Symbol, function(self, output) {
|
||||
var def = self.definition();
|
||||
output.print_name(def ? def.mangled_name || def.name : self.name);
|
||||
output.print_name(def && def.mangled_name || self.name);
|
||||
});
|
||||
DEFPRINT(AST_Hole, noop);
|
||||
DEFPRINT(AST_This, function(self, output) {
|
||||
@@ -1386,8 +1364,27 @@ function OutputStream(options) {
|
||||
if (regexp.raw_source) {
|
||||
str = "/" + regexp.raw_source + str.slice(str.lastIndexOf("/"));
|
||||
}
|
||||
str = output.to_utf8(str);
|
||||
output.print(str);
|
||||
output.print(output.to_utf8(str).replace(/\\(?:\0(?![0-9])|[^\0])/g, function(seq) {
|
||||
switch (seq[1]) {
|
||||
case "\n": return "\\n";
|
||||
case "\r": return "\\r";
|
||||
case "\t": return "\t";
|
||||
case "\b": return "\b";
|
||||
case "\f": return "\f";
|
||||
case "\0": return "\0";
|
||||
case "\x0B": return "\v";
|
||||
case "\u2028": return "\\u2028";
|
||||
case "\u2029": return "\\u2029";
|
||||
default: return seq;
|
||||
}
|
||||
}).replace(/[\n\r\u2028\u2029]/g, function(c) {
|
||||
switch (c) {
|
||||
case "\n": return "\\n";
|
||||
case "\r": return "\\r";
|
||||
case "\u2028": return "\\u2028";
|
||||
case "\u2029": return "\\u2029";
|
||||
}
|
||||
}));
|
||||
var p = output.parent();
|
||||
if (p instanceof AST_Binary && /^in/.test(p.operator) && p.left === self)
|
||||
output.print(" ");
|
||||
|
Reference in New Issue
Block a user