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

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

@ -851,6 +851,9 @@ var AST_DefClass = DEFNODE("DefClass", null, {
$propdoc: {
name: "[AST_SymbolDefClass] the name of this class",
},
resolve: function(def_class) {
return def_class ? this : this.parent_scope.resolve();
},
_validate: function() {
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) {
var scanner = new TreeWalker(function(node) {
if (node instanceof AST_DefaultValue) {
@ -759,15 +787,7 @@ Compressor.prototype.compress = function(node) {
node.value.walk(tw);
pop(tw);
var save = fixed;
if (save) fixed = function() {
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;
};
if (save) fixed = make_fixed_default(compressor, node, save);
node.name.walk(scanner);
fixed = save;
return true;
@ -777,18 +797,17 @@ Compressor.prototype.compress = function(node) {
var save = fixed;
node.elements.forEach(function(node, index) {
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, {
expression: save(),
expression: value,
property: make_node(AST_Number, node, { value: index }),
});
};
});
node.walk(scanner);
});
if (node.rest) {
var fixed_node;
if (save) fixed = compressor.option("rests") && function() {
var value = save();
if (save) fixed = compressor.option("rests") && make_fixed(save, function(value) {
if (!(value instanceof AST_Array)) return node;
for (var i = 0, len = node.elements.length; i < len; i++) {
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);
fixed_node.elements = value.elements.slice(len);
return fixed_node;
};
});
node.rest.walk(scanner);
}
fixed = save;
@ -812,7 +831,7 @@ Compressor.prototype.compress = function(node) {
node.key.walk(tw);
pop(tw);
}
if (save) fixed = function() {
if (save) fixed = make_fixed(save, function(value) {
var key = node.key;
var type = AST_Sub;
if (typeof key == "string") {
@ -823,10 +842,10 @@ Compressor.prototype.compress = function(node) {
}
}
return make_node(type, node, {
expression: save(),
property: key
expression: value,
property: key,
});
};
});
node.value.walk(scanner);
});
if (node.rest) {
@ -2040,13 +2059,17 @@ Compressor.prototype.compress = function(node) {
if (is_lhs(node, parent)) {
if (value_def && !hit_rhs) assign_used = true;
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 (!hit_rhs) replaced++;
return node;
} else {
replaced++;
}
replaced++;
changed = abort = true;
AST_Node.info("Collapsing {node} [{file}:{line},{col}]", {
node: node,
@ -2221,6 +2244,7 @@ Compressor.prototype.compress = function(node) {
var candidate = hit_stack[hit_stack.length - 1];
var assign_pos = -1;
var assign_used = false;
var verify_ref = false;
var remaining;
var value_def = null;
var stop_after = null;
@ -2248,8 +2272,11 @@ Compressor.prototype.compress = function(node) {
var lvalues = get_lvalues(candidate);
var lhs_local = is_lhs_local(lhs);
var rhs_value = get_rvalue(candidate);
var rvalue = !compound && rhs_value instanceof AST_Sequence ? rhs_value.tail_node() : rhs_value;
if (!side_effects) side_effects = value_has_side_effects();
var rvalue = rhs_value;
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) {
return node instanceof AST_Destructured;
} : return_false;
@ -2936,6 +2963,7 @@ Compressor.prototype.compress = function(node) {
if (matches < remaining) {
remaining = matches;
assign_pos = 0;
verify_ref = true;
}
}
if (expr.operator == "=") mangleable_var(expr.right);
@ -3163,47 +3191,42 @@ Compressor.prototype.compress = function(node) {
return;
}
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) {
if (hit) return node;
if (node !== hit_stack[hit_index]) return node;
hit_index++;
if (hit_index <= end) return handle_custom_scan_order(node, tt);
hit = true;
if (node instanceof AST_VarDef) {
declare_only.set(node.name.name, (declare_only.get(node.name.name) || 0) + 1);
if (node instanceof AST_Definitions) {
declare_only.set(last.name.name, (declare_only.get(last.name.name) || 0) + 1);
if (value_def) value_def.replaced++;
node = node.clone();
node.value = null;
return value ? List.splice([ value, node ]) : node;
var defns = node.definitions;
var index = defns.indexOf(last);
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;
return is_statement(node) ? make_node(AST_SimpleStatement, value, { body: value }) : value;
}, 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);
return patch_sequence(node, this);
function flush() {
if (pos < index) {
var cropped = node.clone();
cropped.definitions = defns.slice(pos, index);
body.push(cropped);
}
}
return patch_sequence(node, tt);
});
abort = false;
hit = false;
@ -3249,9 +3272,13 @@ Compressor.prototype.compress = function(node) {
}
var def = lhs.definition();
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;
}).length == referenced;
}).length != referenced) return false;
verify_ref = true;
return true;
}
function symbol_in_lvalues(sym, parent) {
@ -3269,7 +3296,7 @@ Compressor.prototype.compress = function(node) {
if (def.scope.resolve() !== scope) return true;
if (modify_toplevel && compressor.exposed(def)) return true;
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) {
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);
});
function modified(node) {
@ -5425,7 +5453,6 @@ Compressor.prototype.compress = function(node) {
return !(prop instanceof AST_ObjectGetter || prop instanceof AST_Spread);
});
});
def(AST_ObjectIdentity, return_true);
def(AST_Sequence, function() {
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 (drop_funcs && node !== self && node instanceof AST_DefClass) {
var def = node.name.definition();
@ -7114,6 +7148,7 @@ Compressor.prototype.compress = function(node) {
if (def.orig.length > 1) return null;
if (def.assignments > 0) return false;
if (def.name == name) return def;
if (compressor.option("keep_fnames")) return false;
var forbidden;
switch (name) {
case "await":
@ -7818,7 +7853,7 @@ Compressor.prototype.compress = function(node) {
var consts = new Dictionary();
var dirs = [];
var hoisted = [];
var vars = new Dictionary(), vars_found = 0;
var vars = new Dictionary();
var tt = new TreeTransformer(function(node, descend, in_list) {
if (node === self) return;
if (node instanceof AST_Directive) {
@ -7846,7 +7881,6 @@ Compressor.prototype.compress = function(node) {
})) return node;
node.definitions.forEach(function(defn) {
vars.set(defn.name.name, defn);
++vars_found;
});
var seq = node.to_assignments();
if (p instanceof AST_ForEnumeration && p.init === node) {
@ -7865,7 +7899,7 @@ Compressor.prototype.compress = function(node) {
}
});
self.transform(tt);
if (vars_found > 0) {
if (vars.size() > 0) {
// collect only vars which don't show up in self's arguments list
var defns = [];
if (self instanceof AST_Lambda) self.each_argname(function(argname) {
@ -9633,8 +9667,16 @@ Compressor.prototype.compress = function(node) {
fixed.escaped = def.escaped;
name.fixed = fixed;
def.references.forEach(function(ref) {
var assigns = ref.fixed && ref.fixed.assigns;
if (assigns && assigns[0] === defn) assigns[0] = assign;
if (!ref.fixed) return;
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);
}
@ -12901,43 +12943,44 @@ Compressor.prototype.compress = function(node) {
AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
if (!compressor.option("properties")) return;
if (key === "__proto__") return;
var expr = this.expression;
if (expr instanceof AST_Object) {
var props = expr.properties;
for (var i = props.length; --i >= 0;) {
var prop = props[i];
if (prop.key !== key) continue;
if (!all(props, can_hoist_property)) return;
if (!safe_to_flatten(prop.value, compressor)) return;
var scope, values = [];
for (var j = 0; j < props.length; j++) {
var value = props[j].value;
if (props[j] instanceof AST_ObjectMethod) {
var arrow = !(value.uses_arguments || is_generator(value) || value.contains_this());
if (arrow) {
if (!scope) scope = compressor.find_parent(AST_Scope);
var avoid = avoid_await_yield(scope);
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);
var self = this;
var expr = self.expression;
if (!(expr instanceof AST_Object)) return;
var props = expr.properties;
for (var i = props.length; --i >= 0;) {
var prop = props[i];
if (prop.key !== key) continue;
if (!all(props, can_hoist_property)) return;
if (!safe_to_flatten(prop.value, compressor)) return;
var call, scope, values = [];
for (var j = 0; j < props.length; j++) {
var value = props[j].value;
if (props[j] instanceof AST_ObjectMethod) {
var arrow = !(value.uses_arguments || is_generator(value) || value.contains_this());
if (arrow) {
if (!scope) scope = compressor.find_parent(AST_Scope);
var avoid = avoid_await_yield(scope);
value.each_argname(function(argname) {
if (avoid[argname.name]) arrow = false;
});
}
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, {
expression: make_node(AST_Array, expr, { elements: values }),
property: make_node(AST_Number, this, { value: i }),
});
values.push(value);
}
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;
}
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) {
var sym = make_node(AST_SymbolRef, name, name);
var assign = make_node(AST_Assign, name, {
@ -13147,16 +13203,7 @@ Compressor.prototype.compress = function(node) {
return assign.right;
};
sym.fixed.assigns = [ 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 ];
}
});
insert_assign(def, assign);
}
def.assignments++;
def.references.push(sym);
@ -13260,6 +13307,7 @@ Compressor.prototype.compress = function(node) {
if (fn.body[0] instanceof AST_Directive) return;
if (fn.contains_this()) return;
if (!scope) scope = find_scope(compressor);
if (in_async_generator(scope)) return;
var defined = new Dictionary();
defined.set("NaN", true);
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 }));
return;
}
body.push(make_node(AST_Var, call, {
definitions: [ make_node(AST_VarDef, call, {
name: argname.convert_symbol(AST_SymbolVar, process),
value: value || make_node(AST_Undefined, call).transform(compressor),
}) ],
}));
var defn = make_node(AST_VarDef, call, {
name: argname.convert_symbol(AST_SymbolVar, process),
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, {
body: make_sequence(call, values),
@ -13500,6 +13548,12 @@ Compressor.prototype.compress = function(node) {
def(AST_LabeledStatement, function(compressor, scope, no_return, in_loop) {
var body = this.body.try_inline(compressor, scope, no_return, in_loop);
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;
return this;
});

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

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

View file

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