diff --git a/crates/swc/tests/tsc-references/controlFlowOptionalChain.2.minified.js b/crates/swc/tests/tsc-references/controlFlowOptionalChain.2.minified.js index 5676729bde4f..7c29525d3d7b 100644 --- a/crates/swc/tests/tsc-references/controlFlowOptionalChain.2.minified.js +++ b/crates/swc/tests/tsc-references/controlFlowOptionalChain.2.minified.js @@ -4,7 +4,7 @@ import "@swc/helpers/_/_type_of"; function someFunction(someOptionalObject) { (null == someOptionalObject ? void 0 : someOptionalObject.someProperty) !== lastSomeProperty && (console.log(someOptionalObject), console.log(someOptionalObject.someProperty), lastSomeProperty = null == someOptionalObject ? void 0 : someOptionalObject.someProperty); } -null === (_o = o) || void 0 === _o || _o[a = 1], a.toString(), null === (_o1 = o) || void 0 === _o1 || _o1.x[b = 1], b.toString(), null === (_o2 = o) || void 0 === _o2 || _o2(c = 1), c.toString(), null === (_o3 = o) || void 0 === _o3 || _o3.x(d = 1), d.toString(), null === (_f = f) || void 0 === _f || _f(x), x, f, f(x), x, f, f(x), (null === (_o21 = o2) || void 0 === _o21 ? void 0 : _o21.f(x)) ? (x, o2.f, null === (_o23 = o2) || void 0 === _o23 || _o23.f, null === (_o24 = o2) || void 0 === _o24 || _o24.f(x)) : (x, o2, null === (_o25 = o2) || void 0 === _o25 || _o25.f, o2.f), x, o2, null === (_o22 = o2) || void 0 === _o22 || _o22.f, o2.f, (null === (_o31 = o3) || void 0 === _o31 ? void 0 : _o31.x) === 1 ? (o3, o3.x, null === (_o33 = o3) || void 0 === _o33 || _o33.x) : (o3, null === (_o34 = o3) || void 0 === _o34 || _o34.x, o3.x), o3, null === (_o32 = o3) || void 0 === _o32 || _o32.x, o3.x, (null === (_o4_x = o4.x) || void 0 === _o4_x ? void 0 : _o4_x.y) ? (o4.x, o4.x.y, null === (_o4_x2 = o4.x) || void 0 === _o4_x2 || _o4_x2.y) : (o4.x, null === (_o4_x3 = o4.x) || void 0 === _o4_x3 || _o4_x3.y, o4.x.y), o4.x, null === (_o4_x1 = o4.x) || void 0 === _o4_x1 || _o4_x1.y, o4.x.y, (null === (_o5_x = o5.x) || void 0 === _o5_x ? void 0 : null === (_o5_x_y_z = _o5_x.y.z) || void 0 === _o5_x_y_z ? void 0 : _o5_x_y_z.w) ? (o5.x, o5.x.y, o5.x.y.z, o5.x.y.z.w, null === (_o5_x_y_z2 = o5.x.y.z) || void 0 === _o5_x_y_z2 || _o5_x_y_z2.w, null === (_o5_x4 = o5.x) || void 0 === _o5_x4 || _o5_x4.y.z.w, null === (_o5_x5 = o5.x) || void 0 === _o5_x5 || null === (_o5_x_y_z3 = _o5_x5.y.z) || void 0 === _o5_x_y_z3 || _o5_x_y_z3.w) : (o5.x, null === (_o5_x6 = o5.x) || void 0 === _o5_x6 || _o5_x6.y, null === (_o5_x7 = o5.x) || void 0 === _o5_x7 || _o5_x7.y.z, null === (_o5_x8 = o5.x) || void 0 === _o5_x8 || null === (_o5_x_y_z4 = _o5_x8.y.z) || void 0 === _o5_x_y_z4 || _o5_x_y_z4.w, o5.x.y, o5.x.y.z.w), o5.x, null === (_o5_x1 = o5.x) || void 0 === _o5_x1 || _o5_x1.y, null === (_o5_x2 = o5.x) || void 0 === _o5_x2 || _o5_x2.y.z, null === (_o5_x3 = o5.x) || void 0 === _o5_x3 || null === (_o5_x_y_z1 = _o5_x3.y.z) || void 0 === _o5_x_y_z1 || _o5_x_y_z1.w, o5.x.y, o5.x.y.z.w, (null === (_o6 = o6) || void 0 === _o6 ? void 0 : _o6.f()) ? (o6, o6.f) : (o6, null === (_o62 = o6) || void 0 === _o62 || _o62.f, o6.f), o6, null === (_o61 = o6) || void 0 === _o61 || _o61.f, o6.f, someFunction({ +null === (_o = o) || void 0 === _o || _o[a = 1], a.toString(), null === (_o1 = o) || void 0 === _o1 || _o1.x[b = 1], b.toString(), null === (_o2 = o) || void 0 === _o2 || _o2(c = 1), c.toString(), null === (_o3 = o) || void 0 === _o3 || _o3.x(d = 1), d.toString(), null === (_f = f) || void 0 === _f || _f(x), x, f, f(x), x, f, f(x), (null === (_o21 = o2) || void 0 === _o21 ? void 0 : _o21.f(x)) ? (x, o2.f, null === (_o23 = o2) || void 0 === _o23 || _o23.f, null === (_o24 = o2) || void 0 === _o24 || _o24.f(x)) : (x, o2, null === (_o25 = o2) || void 0 === _o25 || _o25.f, o2.f), x, o2, null === (_o22 = o2) || void 0 === _o22 || _o22.f, o2.f, (null === (_o31 = o3) || void 0 === _o31 ? void 0 : _o31.x) === 1 ? (o3, o3.x, null === (_o33 = o3) || void 0 === _o33 || _o33.x) : (o3, null === (_o34 = o3) || void 0 === _o34 || _o34.x, o3.x), o3, null === (_o32 = o3) || void 0 === _o32 || _o32.x, o3.x, (null === (_o4_x = o4.x) || void 0 === _o4_x ? void 0 : _o4_x.y) ? (o4.x, o4.x.y, null === (_o4_x2 = o4.x) || void 0 === _o4_x2 || _o4_x2.y) : (o4.x, null === (_o4_x3 = o4.x) || void 0 === _o4_x3 || _o4_x3.y, o4.x.y), o4.x, null === (_o4_x1 = o4.x) || void 0 === _o4_x1 || _o4_x1.y, o4.x.y, (null === (_o5_x = o5.x) || void 0 === _o5_x ? void 0 : null === (_o5_x_y_z = _o5_x.y.z) || void 0 === _o5_x_y_z ? void 0 : _o5_x_y_z.w) ? (o5.x, o5.x.y, o5.x.y.z, o5.x.y.z.w, null === (_o5_x_y_z2 = o5.x.y.z) || void 0 === _o5_x_y_z2 || _o5_x_y_z2.w, null === (_o5_x4 = o5.x) || void 0 === _o5_x4 || _o5_x4.y.z.w, null === (_o5_x5 = o5.x) || void 0 === _o5_x5 || null === (_o5_x_y_z3 = _o5_x5.y.z) || void 0 === _o5_x_y_z3 || _o5_x_y_z3.w) : (o5.x, null === (_o5_x6 = o5.x) || void 0 === _o5_x6 || _o5_x6.y, null === (_o5_x7 = o5.x) || void 0 === _o5_x7 || _o5_x7.y.z, null === (_o5_x8 = o5.x) || void 0 === _o5_x8 || null === (_o5_x_y_z4 = _o5_x8.y.z) || void 0 === _o5_x_y_z4 || _o5_x_y_z4.w, o5.x.y, o5.x.y.z.w), o5.x, null === (_o5_x1 = o5.x) || void 0 === _o5_x1 || _o5_x1.y, null === (_o5_x2 = o5.x) || void 0 === _o5_x2 || _o5_x2.y.z, null === (_o5_x3 = o5.x) || void 0 === _o5_x3 || null === (_o5_x_y_z1 = _o5_x3.y.z) || void 0 === _o5_x_y_z1 || _o5_x_y_z1.w, o5.x.y, o5.x.y.z.w, (null === (_o6 = o6) || void 0 === _o6 ? void 0 : _o6.f()) ? o6 : (o6, null === (_o62 = o6) || void 0 === _o62 || _o62.f), o6.f, o6, null === (_o61 = o6) || void 0 === _o61 || _o61.f, o6.f, someFunction({ someProperty: 42 }), someFunction(void 0); for(var _o, _o1, _o2, _o3, _f, _o21, _o22, _o31, _o32, _o4_x, _o4_x1, _o5_x_y_z, _o5_x, _o5_x1, _o5_x2, _o5_x_y_z1, _o5_x3, _o6, _o61, _arr_i, a, b, c, d, _o23, _o24, _o25, _o33, _o34, _o4_x2, _o4_x3, _o5_x_y_z2, _o5_x4, _o5_x_y_z3, _o5_x5, _o5_x6, _o5_x7, _o5_x_y_z4, _o5_x8, _o62, lastSomeProperty, _arr_i1, i = 0; (null === (_arr_i = arr[i]) || void 0 === _arr_i ? void 0 : _arr_i.tag) === "left";)i += 1, (null === (_arr_i1 = arr[i]) || void 0 === _arr_i1 ? void 0 : _arr_i1.tag) === "right" && console.log("I should ALSO be reachable"); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/conditionals.rs b/crates/swc_ecma_minifier/src/compress/optimize/conditionals.rs index 69f4aa7ff87e..328d8708cc3e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/conditionals.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/conditionals.rs @@ -616,6 +616,87 @@ impl Optimizer<'_> { })) } + (Expr::Seq(left), Expr::Seq(right)) => { + let left_len = left.exprs.len(); + let right_len = right.exprs.len(); + let min_len = left_len.min(right_len); + + let mut idx = 0; + + while idx < min_len + && left.exprs[left_len - idx - 1] + .eq_ignore_span(&right.exprs[right_len - idx - 1]) + && !matches!( + &*left.exprs[left_len - idx - 1], + Expr::Yield(..) | Expr::Fn(..) + ) + { + idx += 1; + } + + if idx == 0 { + None + } else if idx == left_len { + self.changed = true; + report_change!("conditionals: Reducing similar seq expr in cons"); + + let mut alt = right.exprs.take(); + + alt.truncate(alt.len() - idx); + + let mut seq = vec![Box::new(Expr::Bin(BinExpr { + span: DUMMY_SP, + left: test.take(), + op: op!("||"), + right: Expr::from_exprs(alt), + }))]; + seq.append(&mut left.exprs); + + Some(Expr::Seq(SeqExpr { + span: DUMMY_SP, + exprs: seq, + })) + } else if idx == right_len { + self.changed = true; + report_change!("conditionals: Reducing similar seq expr in alt"); + + let mut cons = left.exprs.take(); + + cons.truncate(cons.len() - idx); + + let mut seq = vec![Box::new(Expr::Bin(BinExpr { + span: DUMMY_SP, + left: test.take(), + op: op!("&&"), + right: Expr::from_exprs(cons), + }))]; + seq.append(&mut right.exprs); + + Some(Expr::Seq(SeqExpr { + span: DUMMY_SP, + exprs: seq, + })) + } else { + self.changed = true; + report_change!("conditionals: Reducing similar seq expr"); + let _ = left.exprs.split_off(left_len - idx); + let mut common = right.exprs.split_off(right_len - idx); + + let mut seq = vec![Box::new(Expr::Cond(CondExpr { + span: DUMMY_SP, + test: test.take(), + cons: Box::new(Expr::Seq(left.take())), + alt: Box::new(Expr::Seq(right.take())), + }))]; + seq.append(&mut common); + + Some(Expr::Seq(SeqExpr { + span: DUMMY_SP, + exprs: seq, + })) + } + } + _ => None, } } diff --git a/crates/swc_ecma_minifier/tests/benches-full/d3.js b/crates/swc_ecma_minifier/tests/benches-full/d3.js index 7c8c96dfe63a..e152f7c68b7c 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/d3.js +++ b/crates/swc_ecma_minifier/tests/benches-full/d3.js @@ -4208,7 +4208,7 @@ (parent[i + 1 & 3] || parent[i + 2 & 3] || parent[i + 3 & 3]) && (retainer = parent, j = i); } for(; node.data !== d;)if (previous = node, !(node = node.next)) return this; - return ((next = node.next) && delete node.next, previous) ? (next ? previous.next = next : delete previous.next, this) : parent ? (next ? parent[i] = next : delete parent[i], (node = parent[0] || parent[1] || parent[2] || parent[3]) && node === (parent[3] || parent[2] || parent[1] || parent[0]) && !node.length && (retainer ? retainer[j] = node : this._root = node), this) : (this._root = next, this); + return ((next = node.next) && delete node.next, previous) ? next ? previous.next = next : delete previous.next : parent ? (next ? parent[i] = next : delete parent[i], (node = parent[0] || parent[1] || parent[2] || parent[3]) && node === (parent[3] || parent[2] || parent[1] || parent[0]) && !node.length && (retainer ? retainer[j] = node : this._root = node)) : this._root = next, this; }, treeProto.removeAll = function(data) { for(var i = 0, n = data.length; i < n; ++i)this.remove(data[i]); return this; @@ -10067,11 +10067,11 @@ return values; }, exports1.interval = function(callback, delay, time) { var t = new Timer, total = delay; - return null == delay ? (t.restart(callback, delay, time), t) : (t._restart = t.restart, t.restart = function(callback, delay, time) { + return null == delay || (t._restart = t.restart, t.restart = function(callback, delay, time) { delay = +delay, time = null == time ? now() : +time, t._restart(function tick(elapsed) { elapsed += total, t._restart(tick, total += delay, time), callback(elapsed); }, delay, time); - }, t.restart(callback, delay, time), t); + }), t.restart(callback, delay, time), t; }, exports1.isoFormat = formatIso, exports1.isoParse = parseIso, exports1.json = function(input, init) { return fetch(input, init).then(responseJson); }, exports1.lab = lab, exports1.lch = function(l, c, h, opacity) { diff --git a/crates/swc_ecma_minifier/tests/benches-full/echarts.js b/crates/swc_ecma_minifier/tests/benches-full/echarts.js index f53b950591fd..a9d0bae48229 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/echarts.js +++ b/crates/swc_ecma_minifier/tests/benches-full/echarts.js @@ -1059,7 +1059,7 @@ } }, Transformable.prototype.getGlobalScale = function(out) { var m = this.transform; - return (out = out || [], m) ? (out[0] = Math.sqrt(m[0] * m[0] + m[1] * m[1]), out[1] = Math.sqrt(m[2] * m[2] + m[3] * m[3]), m[0] < 0 && (out[0] = -out[0]), m[3] < 0 && (out[1] = -out[1]), out) : (out[0] = 1, out[1] = 1, out); + return (out = out || [], m) ? (out[0] = Math.sqrt(m[0] * m[0] + m[1] * m[1]), out[1] = Math.sqrt(m[2] * m[2] + m[3] * m[3]), m[0] < 0 && (out[0] = -out[0]), m[3] < 0 && (out[1] = -out[1])) : (out[0] = 1, out[1] = 1), out; }, Transformable.prototype.transformCoordToLocal = function(x, y) { var v2 = [ x, @@ -4327,12 +4327,12 @@ firstCmpt ] : [], result; } - return 'none' === indexOption || !1 === indexOption ? (assert(opt.enableNone, '`"none"` or `false` is not a valid value on index option.'), result.models = [], result) : ('all' === indexOption && (assert(opt.enableAll, '`"all"` is not a valid value on index option.'), indexOption = idOption = nameOption = null), result.models = ecModel.queryComponents({ + return 'none' === indexOption || !1 === indexOption ? (assert(opt.enableNone, '`"none"` or `false` is not a valid value on index option.'), result.models = []) : ('all' === indexOption && (assert(opt.enableAll, '`"all"` is not a valid value on index option.'), indexOption = idOption = nameOption = null), result.models = ecModel.queryComponents({ mainType: mainType, index: indexOption, id: idOption, name: nameOption - }), result); + })), result; } function setAttribute(dom, key, value) { dom.setAttribute ? dom.setAttribute(key, value) : dom[key] = value; @@ -36753,19 +36753,16 @@ ], xLeft += sizePlusGap), showPrevBtn && (prevBtnPosition = [ xLeft, 0 - ], xLeft += sizePlusGap), showNextBtn && (nextBtnPosition = [ - xRight - controlSize, - 0 - ], xRight -= sizePlusGap)) : (showPlayBtn && (playPosition = [ + ], xLeft += sizePlusGap)) : (showPlayBtn && (playPosition = [ xRight - controlSize, 0 ], xRight -= sizePlusGap), showPrevBtn && (prevBtnPosition = [ 0, 0 - ], xLeft += sizePlusGap), showNextBtn && (nextBtnPosition = [ + ], xLeft += sizePlusGap)), showNextBtn && (nextBtnPosition = [ xRight - controlSize, 0 - ], xRight -= sizePlusGap)); + ], xRight -= sizePlusGap); var axisExtent = [ xLeft, xRight diff --git a/crates/swc_ecma_minifier/tests/benches-full/moment.js b/crates/swc_ecma_minifier/tests/benches-full/moment.js index 0b5f86641b1a..bb0190437a45 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/moment.js +++ b/crates/swc_ecma_minifier/tests/benches-full/moment.js @@ -1522,7 +1522,7 @@ return out; } function listWeekdaysImpl(localeSorted, format, index, field) { - 'boolean' == typeof localeSorted ? (isNumber(format) && (index = format, format = void 0), format = format || '') : (index = format = localeSorted, localeSorted = !1, isNumber(format) && (index = format, format = void 0), format = format || ''); + 'boolean' == typeof localeSorted || (index = format = localeSorted, localeSorted = !1), isNumber(format) && (index = format, format = void 0), format = format || ''; var i, locale = getLocale(), shift = localeSorted ? locale._week.dow : 0, out = []; if (null != index) return get$1(format, (index + shift) % 7, field, 'day'); for(i = 0; i < 7; i++)out[i] = get$1(format, (i + shift) % 7, field, 'day'); diff --git a/crates/swc_ecma_minifier/tests/benches-full/terser.js b/crates/swc_ecma_minifier/tests/benches-full/terser.js index a825276cfc6e..5c392fe7de8f 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/terser.js +++ b/crates/swc_ecma_minifier/tests/benches-full/terser.js @@ -7235,7 +7235,7 @@ var fixed = def.fixed; if (!fixed && "=" != node.operator && !node.logical) return finish_walk(); var eq = "=" == node.operator, value = eq ? node.right : node; - return is_modified(compressor, tw, node, value, 0) ? finish_walk() : (def.references.push(sym), node.logical || (eq || (def.chained = !0), def.fixed = eq ? function() { + return is_modified(compressor, tw, node, value, 0) ? finish_walk() : ((def.references.push(sym), node.logical || (eq || (def.chained = !0), def.fixed = eq ? function() { return node.right; } : function() { return make_node(AST_Binary, node, { @@ -7243,7 +7243,7 @@ left: fixed instanceof AST_Node ? fixed : fixed(), right: node.right }); - }), node.logical) ? (mark(tw, def, !1), push(tw), node.right.walk(tw), pop(tw), !0) : (mark(tw, def, !1), node.right.walk(tw), mark(tw, def, !0), mark_escaped(tw, def, sym.scope, node, value, 0, 1), !0); + }), node.logical) ? (mark(tw, def, !1), push(tw), node.right.walk(tw), pop(tw)) : (mark(tw, def, !1), node.right.walk(tw), mark(tw, def, !0), mark_escaped(tw, def, sym.scope, node, value, 0, 1)), !0); }), def_reduce_vars(AST_Binary, function(tw) { if (lazy_op.has(this.operator)) return this.left.walk(tw), push(tw), this.right.walk(tw), pop(tw), !0; }), def_reduce_vars(AST_Block, function(tw, descend, compressor) { @@ -8705,7 +8705,7 @@ operator: "void", expression: expressions[end] }), expressions.length = end + 1); - }(), 0 == end) ? ((self1 = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0])) instanceof AST_Sequence || (self1 = self1.optimize(compressor)), self1) : (self1.expressions = expressions, self1); + }(), 0 == end) ? (self1 = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0])) instanceof AST_Sequence || (self1 = self1.optimize(compressor)) : self1.expressions = expressions, self1; }), AST_Unary.DEFMETHOD("lift_sequences", function(compressor) { if (compressor.option("sequences") && this.expression instanceof AST_Sequence) { var x = this.expression.expressions.slice(), e = this.clone(); diff --git a/crates/swc_ecma_minifier/tests/benches-full/three.js b/crates/swc_ecma_minifier/tests/benches-full/three.js index 4c55e6596da2..2f665a74cdb5 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/three.js +++ b/crates/swc_ecma_minifier/tests/benches-full/three.js @@ -769,7 +769,7 @@ return this._onChangeCallback(), this; }, _proto.setFromUnitVectors = function(vFrom, vTo) { var r = vFrom.dot(vTo) + 1; - return r < 0.000001 ? (r = 0, Math.abs(vFrom.x) > Math.abs(vFrom.z) ? (this._x = -vFrom.y, this._y = vFrom.x, this._z = 0, this._w = r) : (this._x = 0, this._y = -vFrom.z, this._z = vFrom.y, this._w = r)) : (this._x = vFrom.y * vTo.z - vFrom.z * vTo.y, this._y = vFrom.z * vTo.x - vFrom.x * vTo.z, this._z = vFrom.x * vTo.y - vFrom.y * vTo.x, this._w = r), this.normalize(); + return r < 0.000001 ? (r = 0, Math.abs(vFrom.x) > Math.abs(vFrom.z) ? (this._x = -vFrom.y, this._y = vFrom.x, this._z = 0) : (this._x = 0, this._y = -vFrom.z, this._z = vFrom.y)) : (this._x = vFrom.y * vTo.z - vFrom.z * vTo.y, this._y = vFrom.z * vTo.x - vFrom.x * vTo.z, this._z = vFrom.x * vTo.y - vFrom.y * vTo.x), this._w = r, this.normalize(); }, _proto.angleTo = function(q) { return 2 * Math.acos(Math.abs(MathUtils.clamp(this.dot(q), -1, 1))); }, _proto.rotateTowards = function(q, step) { @@ -1229,7 +1229,7 @@ var deltaLengthSq = this.center.distanceToSquared(point); return void 0 === target && (console.warn('THREE.Sphere: .clampPoint() target is now required'), target = new Vector3()), target.copy(point), deltaLengthSq > this.radius * this.radius && (target.sub(this.center).normalize(), target.multiplyScalar(this.radius).add(this.center)), target; }, _proto.getBoundingBox = function(target) { - return (void 0 === target && (console.warn('THREE.Sphere: .getBoundingBox() target is now required'), target = new Box3()), this.isEmpty()) ? (target.makeEmpty(), target) : (target.set(this.center, this.center), target.expandByScalar(this.radius), target); + return (void 0 === target && (console.warn('THREE.Sphere: .getBoundingBox() target is now required'), target = new Box3()), this.isEmpty()) ? target.makeEmpty() : (target.set(this.center, this.center), target.expandByScalar(this.radius)), target; }, _proto.applyMatrix4 = function(matrix) { return this.center.applyMatrix4(matrix), this.radius = this.radius * matrix.getMaxScaleOnAxis(), this; }, _proto.translate = function(offset) { @@ -1700,7 +1700,7 @@ for(var i = 0; i < arguments.length; i++)this.add(arguments[i]); return this; } - return object === this ? (console.error('THREE.Object3D.add: object can\'t be added as a child of itself.', object), this) : (object && object.isObject3D ? (null !== object.parent && object.parent.remove(object), object.parent = this, this.children.push(object), object.dispatchEvent(_addedEvent)) : console.error('THREE.Object3D.add: object not an instance of THREE.Object3D.', object), this); + return object === this ? console.error('THREE.Object3D.add: object can\'t be added as a child of itself.', object) : object && object.isObject3D ? (null !== object.parent && object.parent.remove(object), object.parent = this, this.children.push(object), object.dispatchEvent(_addedEvent)) : console.error('THREE.Object3D.add: object not an instance of THREE.Object3D.', object), this; }, remove: function(object) { if (arguments.length > 1) { diff --git a/crates/swc_ecma_minifier/tests/benches-full/victory.js b/crates/swc_ecma_minifier/tests/benches-full/victory.js index 63caa5ca041d..963eb8148494 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/victory.js +++ b/crates/swc_ecma_minifier/tests/benches-full/victory.js @@ -5972,9 +5972,9 @@ var _timer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../../node_modules/d3-timer/src/timer.js"); __webpack_exports__.default = function(callback, delay, time) { var t = new _timer_js__WEBPACK_IMPORTED_MODULE_0__.Timer, total = delay; - return null == delay ? (t.restart(callback, delay, time), t) : (delay = +delay, time = null == time ? Object(_timer_js__WEBPACK_IMPORTED_MODULE_0__.now)() : +time, t.restart(function tick(elapsed) { + return null == delay ? t.restart(callback, delay, time) : (delay = +delay, time = null == time ? Object(_timer_js__WEBPACK_IMPORTED_MODULE_0__.now)() : +time, t.restart(function tick(elapsed) { elapsed += total, t.restart(tick, total += delay, time), callback(elapsed); - }, delay, time), t); + }, delay, time)), t; }; }, "../../../node_modules/d3-timer/src/timeout.js": function(module1, __webpack_exports__, __webpack_require__) { @@ -24281,7 +24281,7 @@ return Array.isArray(bins) ? (bin.domain([ bins[0], bins[bins.length - 1] - ]), bin.thresholds(bins.slice(1, bins.length - 1)), bin) : Number.isInteger(bins) ? (bin.domain(niceScale.domain()), bin.thresholds(bins), bin) : dataOrBinsContainsDates ? (bin.domain(niceScale.domain()), bin.thresholds(niceScale.ticks()), bin) : (bin.domain(niceScale.domain()), bin); + ]), bin.thresholds(bins.slice(1, bins.length - 1))) : Number.isInteger(bins) ? (bin.domain(niceScale.domain()), bin.thresholds(bins)) : dataOrBinsContainsDates ? (bin.domain(niceScale.domain()), bin.thresholds(niceScale.ticks())) : bin.domain(niceScale.domain()), bin; }, getFormattedData = (func = function(_ref3) { var _ref3$data = _ref3.data, data = void 0 === _ref3$data ? [] : _ref3$data, x = _ref3.x, bins = _ref3.bins; if ((!data || !data.length) && !Array.isArray(bins)) return []; diff --git a/crates/swc_ecma_minifier/tests/benches-full/vue.js b/crates/swc_ecma_minifier/tests/benches-full/vue.js index a71260e5ec49..6fce558489b9 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/vue.js +++ b/crates/swc_ecma_minifier/tests/benches-full/vue.js @@ -362,7 +362,7 @@ if ((isUndef(target) || isPrimitive(target)) && warn("Cannot set reactive property on undefined, null, or primitive value: " + target), Array.isArray(target) && isValidArrayIndex(key)) return target.length = Math.max(target.length, key), target.splice(key, 1, val), val; if (key in target && !(key in Object.prototype)) return target[key] = val, val; var ob = target.__ob__; - return target._isVue || ob && ob.vmCount ? (warn("Avoid adding reactive properties to a Vue instance or its root $data at runtime - declare it upfront in the data option."), val) : ob ? (defineReactive$$1(ob.value, key, val), ob.dep.notify(), val) : (target[key] = val, val); + return target._isVue || ob && ob.vmCount ? warn("Avoid adding reactive properties to a Vue instance or its root $data at runtime - declare it upfront in the data option.") : ob ? (defineReactive$$1(ob.value, key, val), ob.dep.notify()) : target[key] = val, val; } function del(target, key) { if ((isUndef(target) || isPrimitive(target)) && warn("Cannot delete reactive property on undefined, null, or primitive value: " + target), Array.isArray(target) && isValidArrayIndex(key)) { @@ -2257,7 +2257,7 @@ } }(vnode, insertedVnodeQueue, parentElm, refElm)) { var data = vnode.data, children = vnode.children, tag = vnode.tag; - isDef(tag) ? (data && data.pre && creatingElmInVPre++, isUnknownElement$$1(vnode, creatingElmInVPre) && warn('Unknown custom element: <' + tag + '> - did you register the component correctly? For recursive components, make sure to provide the "name" option.', vnode.context), vnode.elm = vnode.ns ? nodeOps.createElementNS(vnode.ns, tag) : nodeOps.createElement(tag, vnode), setScope(vnode), createChildren(vnode, children, insertedVnodeQueue), isDef(data) && invokeCreateHooks(vnode, insertedVnodeQueue), insert(parentElm, vnode.elm, refElm), data && data.pre && creatingElmInVPre--) : isTrue(vnode.isComment) ? (vnode.elm = nodeOps.createComment(vnode.text), insert(parentElm, vnode.elm, refElm)) : (vnode.elm = nodeOps.createTextNode(vnode.text), insert(parentElm, vnode.elm, refElm)); + isDef(tag) ? (data && data.pre && creatingElmInVPre++, isUnknownElement$$1(vnode, creatingElmInVPre) && warn('Unknown custom element: <' + tag + '> - did you register the component correctly? For recursive components, make sure to provide the "name" option.', vnode.context), vnode.elm = vnode.ns ? nodeOps.createElementNS(vnode.ns, tag) : nodeOps.createElement(tag, vnode), setScope(vnode), createChildren(vnode, children, insertedVnodeQueue), isDef(data) && invokeCreateHooks(vnode, insertedVnodeQueue), insert(parentElm, vnode.elm, refElm), data && data.pre && creatingElmInVPre--) : (isTrue(vnode.isComment) ? vnode.elm = nodeOps.createComment(vnode.text) : vnode.elm = nodeOps.createTextNode(vnode.text), insert(parentElm, vnode.elm, refElm)); } } function initComponent(vnode, insertedVnodeQueue) { @@ -2385,7 +2385,7 @@ } isUndef(vnode.text) ? isDef(oldCh) && isDef(ch) ? oldCh !== ch && function(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { var oldKeyToIdx, idxInOld, vnodeToMove, oldStartIdx = 0, newStartIdx = 0, oldEndIdx = oldCh.length - 1, oldStartVnode = oldCh[0], oldEndVnode = oldCh[oldEndIdx], newEndIdx = newCh.length - 1, newStartVnode = newCh[0], newEndVnode = newCh[newEndIdx], canMove = !removeOnly; - for(checkDuplicateKeys(newCh); oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx;)isUndef(oldStartVnode) ? oldStartVnode = oldCh[++oldStartIdx] : isUndef(oldEndVnode) ? oldEndVnode = oldCh[--oldEndIdx] : sameVnode(oldStartVnode, newStartVnode) ? (patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx), oldStartVnode = oldCh[++oldStartIdx], newStartVnode = newCh[++newStartIdx]) : sameVnode(oldEndVnode, newEndVnode) ? (patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx), oldEndVnode = oldCh[--oldEndIdx], newEndVnode = newCh[--newEndIdx]) : sameVnode(oldStartVnode, newEndVnode) ? (patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx), canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)), oldStartVnode = oldCh[++oldStartIdx], newEndVnode = newCh[--newEndIdx]) : sameVnode(oldEndVnode, newStartVnode) ? (patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx), canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm), oldEndVnode = oldCh[--oldEndIdx], newStartVnode = newCh[++newStartIdx]) : (isUndef(oldKeyToIdx) && (oldKeyToIdx = function(children, beginIdx, endIdx) { + for(checkDuplicateKeys(newCh); oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx;)isUndef(oldStartVnode) ? oldStartVnode = oldCh[++oldStartIdx] : isUndef(oldEndVnode) ? oldEndVnode = oldCh[--oldEndIdx] : sameVnode(oldStartVnode, newStartVnode) ? (patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx), oldStartVnode = oldCh[++oldStartIdx], newStartVnode = newCh[++newStartIdx]) : sameVnode(oldEndVnode, newEndVnode) ? (patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx), oldEndVnode = oldCh[--oldEndIdx], newEndVnode = newCh[--newEndIdx]) : sameVnode(oldStartVnode, newEndVnode) ? (patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx), canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)), oldStartVnode = oldCh[++oldStartIdx], newEndVnode = newCh[--newEndIdx]) : (sameVnode(oldEndVnode, newStartVnode) ? (patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx), canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm), oldEndVnode = oldCh[--oldEndIdx]) : (isUndef(oldKeyToIdx) && (oldKeyToIdx = function(children, beginIdx, endIdx) { var i, key, map = {}; for(i = beginIdx; i <= endIdx; ++i)isDef(key = children[i].key) && (map[key] = i); return map; @@ -2394,7 +2394,7 @@ var c = oldCh[i]; if (isDef(c) && sameVnode(node, c)) return i; } - }(newStartVnode, oldCh, oldStartIdx, oldEndIdx)) ? createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, !1, newCh, newStartIdx) : sameVnode(vnodeToMove = oldCh[idxInOld], newStartVnode) ? (patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx), oldCh[idxInOld] = void 0, canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm)) : createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, !1, newCh, newStartIdx), newStartVnode = newCh[++newStartIdx]); + }(newStartVnode, oldCh, oldStartIdx, oldEndIdx)) ? createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, !1, newCh, newStartIdx) : sameVnode(vnodeToMove = oldCh[idxInOld], newStartVnode) ? (patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx), oldCh[idxInOld] = void 0, canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm)) : createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, !1, newCh, newStartIdx)), newStartVnode = newCh[++newStartIdx]); oldStartIdx > oldEndIdx ? addVnodes(parentElm, isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue) : newStartIdx > newEndIdx && removeVnodes(oldCh, oldStartIdx, oldEndIdx); }(elm, oldCh, ch, insertedVnodeQueue, removeOnly) : isDef(ch) ? (checkDuplicateKeys(ch), isDef(oldVnode.text) && nodeOps.setTextContent(elm, ''), addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue)) : isDef(oldCh) ? removeVnodes(oldCh, 0, oldCh.length - 1) : isDef(oldVnode.text) && nodeOps.setTextContent(elm, '') : oldVnode.text !== vnode.text && nodeOps.setTextContent(elm, vnode.text), isDef(data) && isDef(i = data.hook) && isDef(i = i.postpatch) && i(oldVnode, vnode); } diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js index e92869c45b02..927d263663b4 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js @@ -7290,10 +7290,7 @@ return null === match ? { value: void 0, done: state.done = !0 - } : state.global ? ("" === toString1(match[0]) && (R.lastIndex = advanceStringIndex(S, toLength(R.lastIndex), state.unicode)), { - value: match, - done: !1 - }) : (state.done = !0, { + } : (state.global ? "" === toString1(match[0]) && (R.lastIndex = advanceStringIndex(S, toLength(R.lastIndex), state.unicode)) : state.done = !0, { value: match, done: !1 }); @@ -11421,7 +11418,7 @@ } } function tc(a, b, c, d, e, f) { - return null === a || a.nativeEvent !== f ? (a = rc(b, c, d, e, f), null !== b && null !== (b = Cb(b)) && fc(b), a) : (a.eventSystemFlags |= d, b = a.targetContainers, null !== e && -1 === b.indexOf(e) && b.push(e), a); + return null === a || a.nativeEvent !== f ? (a = rc(b, c, d, e, f), null !== b && null !== (b = Cb(b)) && fc(b)) : (a.eventSystemFlags |= d, b = a.targetContainers, null !== e && -1 === b.indexOf(e) && b.push(e)), a; } function xc(a) { if (null !== a.blockedOn) return !1; @@ -12888,16 +12885,16 @@ return a && null === b.alternate && (b.flags = 2), b; } function h(a, b, c, d) { - return null === b || 6 !== b.tag ? ((b = Ug(c, a.mode, d)).return = a, b) : ((b = e(b, c)).return = a, b); + return null === b || 6 !== b.tag ? (b = Ug(c, a.mode, d)).return = a : (b = e(b, c)).return = a, b; } function k(a, b, c, d) { - return null !== b && b.elementType === c.type ? ((d = e(b, c.props)).ref = Qg(a, b, c), d.return = a, d) : ((d = Vg(c.type, c.key, c.props, null, a.mode, d)).ref = Qg(a, b, c), d.return = a, d); + return null !== b && b.elementType === c.type ? (d = e(b, c.props)).ref = Qg(a, b, c) : (d = Vg(c.type, c.key, c.props, null, a.mode, d)).ref = Qg(a, b, c), d.return = a, d; } function l(a, b, c, d) { - return null === b || 4 !== b.tag || b.stateNode.containerInfo !== c.containerInfo || b.stateNode.implementation !== c.implementation ? ((b = Wg(c, a.mode, d)).return = a, b) : ((b = e(b, c.children || [])).return = a, b); + return null === b || 4 !== b.tag || b.stateNode.containerInfo !== c.containerInfo || b.stateNode.implementation !== c.implementation ? (b = Wg(c, a.mode, d)).return = a : (b = e(b, c.children || [])).return = a, b; } function n(a, b, c, d, f) { - return null === b || 7 !== b.tag ? ((b = Xg(c, a.mode, d, f)).return = a, b) : ((b = e(b, c)).return = a, b); + return null === b || 7 !== b.tag ? (b = Xg(c, a.mode, d, f)).return = a : (b = e(b, c)).return = a, b; } function A(a, b, c) { if ("string" == typeof b || "number" == typeof b) return (b = Ug("" + b, a.mode, c)).return = a, b; @@ -12985,7 +12982,7 @@ } return g(a1); } - if ("string" == typeof f1 || "number" == typeof f1) return f1 = "" + f1, null !== d1 && 6 === d1.tag ? (c(a1, d1.sibling), (d1 = e(d1, f1)).return = a1, a1 = d1) : (c(a1, d1), (d1 = Ug(f1, a1.mode, h)).return = a1, a1 = d1), g(a1); + if ("string" == typeof f1 || "number" == typeof f1) return f1 = "" + f1, null !== d1 && 6 === d1.tag ? (c(a1, d1.sibling), (d1 = e(d1, f1)).return = a1) : (c(a1, d1), (d1 = Ug(f1, a1.mode, h)).return = a1), g(a1 = d1); if (Pg(f1)) return function(e, g, h, k) { for(var l = null, t = null, u = g, z = g = 0, q = null; null !== u && z < h.length; z++){ u.index > z ? (q = u, u = null) : q = u.sibling; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js index fb5e744261b6..ea064828bb3d 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/firebase-firestore/1/output.js @@ -411,7 +411,7 @@ const e = t[s + 1]; if ("\\" !== e && "." !== e && "`" !== e) throw new j(K.INVALID_ARGUMENT, "Path has invalid escape sequence: " + t); n += e, s += 2; - } else "`" === e ? (r = !r, s++) : "." !== e || r ? (n += e, s++) : (i(), s++); + } else "`" === e ? r = !r : "." !== e || r ? n += e : i(), s++; } if (i(), r) throw new j(K.INVALID_ARGUMENT, "Unterminated ` in path: " + t); return new ft(e); diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/moment/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/moment/1/output.js index 1cb607ae04a8..5b9e7255935b 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/moment/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/moment/1/output.js @@ -1522,7 +1522,7 @@ return out; } function listWeekdaysImpl(localeSorted, format, index, field) { - "boolean" == typeof localeSorted ? (isNumber(format) && (index = format, format = void 0), format = format || "") : (index = format = localeSorted, localeSorted = !1, isNumber(format) && (index = format, format = void 0), format = format || ""); + "boolean" == typeof localeSorted || (index = format = localeSorted, localeSorted = !1), isNumber(format) && (index = format, format = void 0), format = format || ""; var i, locale = getLocale(), shift = localeSorted ? locale._week.dow : 0, out = []; if (null != index) return get$1(format, (index + shift) % 7, field, "day"); for(i = 0; i < 7; i++)out[i] = get$1(format, (i + shift) % 7, field, "day"); diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js index f736ce095248..1551ec3ad8d7 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js @@ -596,13 +596,13 @@ function(module1, exports1, __webpack_require__) { var superPropBase = __webpack_require__(227); function _get(target, property, receiver) { - return "undefined" != typeof Reflect && Reflect.get ? (module1.exports = _get = Reflect.get, module1.exports.default = module1.exports, module1.exports.__esModule = !0) : (module1.exports = _get = function(target, property, receiver) { + return "undefined" != typeof Reflect && Reflect.get ? module1.exports = _get = Reflect.get : module1.exports = _get = function(target, property, receiver) { var base = superPropBase(target, property); if (base) { var desc = Object.getOwnPropertyDescriptor(base, property); return desc.get ? desc.get.call(receiver) : desc.value; } - }, module1.exports.default = module1.exports, module1.exports.__esModule = !0), _get(target, property, receiver || target); + }, module1.exports.default = module1.exports, module1.exports.__esModule = !0, _get(target, property, receiver || target); } module1.exports = _get, module1.exports.default = module1.exports, module1.exports.__esModule = !0; }, @@ -633,11 +633,11 @@ }, function(module1, exports1) { function _typeof(obj) { - return "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? (module1.exports = _typeof = function(obj) { + return "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? module1.exports = _typeof = function(obj) { return typeof obj; - }, module1.exports.default = module1.exports, module1.exports.__esModule = !0) : (module1.exports = _typeof = function(obj) { + } : module1.exports = _typeof = function(obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }, module1.exports.default = module1.exports, module1.exports.__esModule = !0), _typeof(obj); + }, module1.exports.default = module1.exports, module1.exports.__esModule = !0, _typeof(obj); } module1.exports = _typeof, module1.exports.default = module1.exports, module1.exports.__esModule = !0; }, @@ -3056,14 +3056,14 @@ function(module1, exports1, __webpack_require__) { var setPrototypeOf = __webpack_require__(41), isNativeReflectConstruct = __webpack_require__(250); function _construct(Parent, args, Class) { - return isNativeReflectConstruct() ? (module1.exports = _construct = Reflect.construct, module1.exports.default = module1.exports, module1.exports.__esModule = !0) : (module1.exports = _construct = function(Parent, args, Class) { + return isNativeReflectConstruct() ? module1.exports = _construct = Reflect.construct : module1.exports = _construct = function(Parent, args, Class) { var a = [ null ]; a.push.apply(a, args); var instance = new (Function.bind.apply(Parent, a))(); return Class && setPrototypeOf(instance, Class.prototype), instance; - }, module1.exports.default = module1.exports, module1.exports.__esModule = !0), _construct.apply(null, arguments); + }, module1.exports.default = module1.exports, module1.exports.__esModule = !0, _construct.apply(null, arguments); } module1.exports = _construct, module1.exports.default = module1.exports, module1.exports.__esModule = !0; }, diff --git a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js index f7294f8f4b06..c8e3539baa26 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js @@ -5891,9 +5891,9 @@ ]); return !sourceTech || ((str1 = sourceTech.tech, str2 = this.techName_, toTitleCase$1(str1) !== toTitleCase$1(str2)) ? (this.changingSrc_ = !0, this.loadTech_(sourceTech.tech, sourceTech.source), this.tech_.ready(function() { _this15.changingSrc_ = !1; - }), !1) : (this.ready(function() { + })) : this.ready(function() { this.tech_.constructor.prototype.hasOwnProperty("setSource") ? this.techCall_("setSource", source) : this.techCall_("src", source.src), this.changingSrc_ = !1; - }, !0), !1)); + }, !0), !1); }, _proto.load = function() { this.techCall_("load"); }, _proto.reset = function() { @@ -8962,7 +8962,7 @@ Object.keys(captionServices).forEach(function(serviceName) { serviceProps = captionServices[serviceName], /^SERVICE/.test(serviceName) && (captionServiceEncodings[serviceName] = serviceProps.encoding); }), this.serviceEncodings = captionServiceEncodings, this.current708Packet = null, this.services = {}, this.push = function(packet) { - 3 === packet.type ? (self1.new708Packet(), self1.add708Bytes(packet)) : (null === self1.current708Packet && self1.new708Packet(), self1.add708Bytes(packet)); + 3 === packet.type ? self1.new708Packet() : null === self1.current708Packet && self1.new708Packet(), self1.add708Bytes(packet); }; }; Cea708Stream.prototype = new Stream(), Cea708Stream.prototype.new708Packet = function() { @@ -9616,7 +9616,7 @@ workingBytes.set(workingData.subarray(position, position + availableBytes)), workingWord = new DataView(workingBytes.buffer).getUint32(0), workingBitsAvailable = 8 * availableBytes, workingBytesAvailable -= availableBytes; }, this.skipBits = function(count) { var skipBytes; - workingBitsAvailable > count ? (workingWord <<= count, workingBitsAvailable -= count) : (count -= workingBitsAvailable, skipBytes = Math.floor(count / 8), count -= 8 * skipBytes, workingBytesAvailable -= skipBytes, this.loadWord(), workingWord <<= count, workingBitsAvailable -= count); + workingBitsAvailable > count || (count -= workingBitsAvailable, skipBytes = Math.floor(count / 8), count -= 8 * skipBytes, workingBytesAvailable -= skipBytes, this.loadWord()), workingWord <<= count, workingBitsAvailable -= count; }, this.readBits = function(size) { var bits = Math.min(workingBitsAvailable, size), valu = workingWord >>> 32 - bits; return ((workingBitsAvailable -= bits) > 0 ? workingWord <<= bits : workingBytesAvailable > 0 && this.loadWord(), (bits = size - bits) > 0) ? valu << bits | this.readBits(bits) : valu; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js index d69c7e4901ea..d01e464606f3 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js @@ -2168,7 +2168,7 @@ NAMESPACE.isHTML(el.uri) && !el.closed ? end = function(source, elStartEnd, tagName, entityReplacer, domBuilder) { if (/^(?:script|textarea)$/i.test(tagName)) { var elEndStart = source.indexOf("" + tagName + ">", elStartEnd), text = source.substring(elStartEnd + 1, elEndStart); - if (/[&<]/.test(text)) return /^script$/i.test(tagName) ? (domBuilder.characters(text, 0, text.length), elEndStart) : (text = text.replace(/?\w+;/g, entityReplacer), domBuilder.characters(text, 0, text.length), elEndStart); + if (/[&<]/.test(text)) return /^script$/i.test(tagName) || (text = text.replace(/?\w+;/g, entityReplacer)), domBuilder.characters(text, 0, text.length), elEndStart; } return elStartEnd + 1; }(source, end, el.tagName, entityReplacer, domBuilder) : end++; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js b/crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js index b0e230c462f2..f5a088becf4a 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/feedback-2/codemirror/output.js @@ -979,9 +979,9 @@ if ("\t" == m[0]) { var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; (txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"))).setAttribute("role", "presentation"), txt$1.setAttribute("cm-text", "\t"), builder.col += tabWidth; - } else "\r" == m[0] || "\n" == m[0] ? ((txt$1 = content.appendChild(elt("span", "\r" == m[0] ? "\u240d" : "\u2424", "cm-invalidchar"))).setAttribute("cm-text", m[0]), builder.col += 1) : ((txt$1 = builder.cm.options.specialCharPlaceholder(m[0])).setAttribute("cm-text", m[0]), ie && ie_version < 9 ? content.appendChild(elt("span", [ + } else "\r" == m[0] || "\n" == m[0] ? (txt$1 = content.appendChild(elt("span", "\r" == m[0] ? "\u240d" : "\u2424", "cm-invalidchar"))).setAttribute("cm-text", m[0]) : ((txt$1 = builder.cm.options.specialCharPlaceholder(m[0])).setAttribute("cm-text", m[0]), ie && ie_version < 9 ? content.appendChild(elt("span", [ txt$1 - ])) : content.appendChild(txt$1), builder.col += 1); + ])) : content.appendChild(txt$1)), builder.col += 1; builder.map.push(builder.pos, builder.pos + 1, txt$1), builder.pos++; } } else builder.col += text.length, content = document.createTextNode(displayText), builder.map.push(builder.pos, builder.pos + text.length, content), ie && ie_version < 9 && (mustWrap = !0), builder.pos += text.length; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js b/crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js index 57104b5e5e35..eaac898bd3cf 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js @@ -54,11 +54,11 @@ }, 8: (t)=>{ function e(r) { - return "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? (t.exports = e = function(t) { + return "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? t.exports = e = function(t) { return typeof t; - }, t.exports.default = t.exports, t.exports.__esModule = !0) : (t.exports = e = function(t) { + } : t.exports = e = function(t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t; - }, t.exports.default = t.exports, t.exports.__esModule = !0), e(r); + }, t.exports.default = t.exports, t.exports.__esModule = !0, e(r); } t.exports = e, t.exports.default = t.exports, t.exports.__esModule = !0; }, @@ -648,7 +648,7 @@ var o = e.length - r.maxStringLength; return t(e.slice(0, r.maxStringLength), r) + "... " + o + " more character" + (o > 1 ? "s" : ""); } - return E(e.replace(/(['\\])/g, "\\$1").replace(/[\x00-\x1f]/g, U), "single", r); + return E(e.replace(/(['\\])/g, "\\$1").replace(/[\x00-\x1f]/g, M), "single", r); }(e, p); if ("number" == typeof e) return 0 === e ? 1 / 0 / e > 0 ? "0" : "-0" : String(e); if ("bigint" == typeof e) return String(e) + "n"; @@ -667,7 +667,7 @@ }; }(p, o); if (void 0 === n) n = []; - else if (M(n, e) >= 0) return "[Circular]"; + else if (U(n, e) >= 0) return "[Circular]"; function O(e, r, i) { if (r && (n = n.slice()).push(r), i) { var a = { @@ -697,7 +697,7 @@ if (0 === e.length) return "[]"; var V = C(e, O); return v && !function(t) { - for(var e = 0; e < t.length; e++)if (M(t[e], "\n") >= 0) return !1; + for(var e = 0; e < t.length; e++)if (U(t[e], "\n") >= 0) return !1; return !0; }(V) ? "[" + T(V, v) + "]" : "[ " + V.join(", ") + " ]"; } @@ -803,12 +803,12 @@ function R(t) { return b.call(t); } - function M(t, e) { + function U(t, e) { if (t.indexOf) return t.indexOf(e); for(var r = 0, o = t.length; r < o; r++)if (t[r] === e) return r; return -1; } - function U(t) { + function M(t) { var e = t.charCodeAt(0), r = { 8: "b", 9: "t", diff --git a/crates/swc_ecma_minifier/tests/fixture/next/octokit/static/chunks/357-72bd409f1472b1b8/output.js b/crates/swc_ecma_minifier/tests/fixture/next/octokit/static/chunks/357-72bd409f1472b1b8/output.js index 7f27a01325d4..a30ad6f52dcf 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/octokit/static/chunks/357-72bd409f1472b1b8/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/octokit/static/chunks/357-72bd409f1472b1b8/output.js @@ -629,7 +629,7 @@ error: error1 }), !1; } - return blocked ? (job.doDrop(), !0) : reachedHWM && (null != (shifted = strategy === Bottleneck.prototype.strategy.LEAK ? this._queues.shiftLastFrom(options.priority) : strategy === Bottleneck.prototype.strategy.OVERFLOW_PRIORITY ? this._queues.shiftLastFrom(options.priority + 1) : strategy === Bottleneck.prototype.strategy.OVERFLOW ? job : void 0) && shifted.doDrop(), null == shifted || strategy === Bottleneck.prototype.strategy.OVERFLOW) ? (null == shifted && job.doDrop(), reachedHWM) : (job.doQueue(reachedHWM, blocked), this._queues.push(job), await this._drainAll(), reachedHWM); + return blocked ? (job.doDrop(), !0) : (reachedHWM && (null != (shifted = strategy === Bottleneck.prototype.strategy.LEAK ? this._queues.shiftLastFrom(options.priority) : strategy === Bottleneck.prototype.strategy.OVERFLOW_PRIORITY ? this._queues.shiftLastFrom(options.priority + 1) : strategy === Bottleneck.prototype.strategy.OVERFLOW ? job : void 0) && shifted.doDrop(), null == shifted || strategy === Bottleneck.prototype.strategy.OVERFLOW) ? null == shifted && job.doDrop() : (job.doQueue(reachedHWM, blocked), this._queues.push(job), await this._drainAll()), reachedHWM); } _receive(job) { return null != this._states.jobStatus(job.options.id) ? (job._reject(new Bottleneck.prototype.BottleneckError(`A job with the same id already exists (id=${job.options.id})`)), !1) : (job.doReceive(), this._submitLock.schedule(this._addToQueue, job)); diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js index 540ccb6b5cd2..1910a24fcb9b 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js @@ -11809,7 +11809,7 @@ margin: 0 10px;\ var startW, textW, endW, isLeftAligned = !0, isRightAligned = !0; return lines.map(function(line) { var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/); - return m ? null == startW ? (startW = m[1].length, textW = m[2].length, endW = m[3].length, m) : (startW + textW + endW != m[1].length + m[2].length + m[3].length && (isRightAligned = !1), startW != m[1].length && (isLeftAligned = !1), startW > m[1].length && (startW = m[1].length), textW < m[2].length && (textW = m[2].length), endW > m[3].length && (endW = m[3].length), m) : [ + return m ? (null == startW ? (startW = m[1].length, textW = m[2].length, endW = m[3].length) : (startW + textW + endW != m[1].length + m[2].length + m[3].length && (isRightAligned = !1), startW != m[1].length && (isLeftAligned = !1), startW > m[1].length && (startW = m[1].length), textW < m[2].length && (textW = m[2].length), endW > m[3].length && (endW = m[3].length)), m) : [ line ]; }).map(forceLeft ? alignLeft : isLeftAligned ? isRightAligned ? function(m) { diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js index 35323d35a3b9..f24265543aff 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js @@ -21698,9 +21698,9 @@ e.exports = { destroy: function(e, o) { var a = this, u = this._readableState && this._readableState.destroyed, l = this._writableState && this._writableState.destroyed; - return u || l ? (o ? o(e) : e && (this._writableState ? this._writableState.errorEmitted || (this._writableState.errorEmitted = !0, n.nextTick(i, this, e)) : n.nextTick(i, this, e)), this) : (this._readableState && (this._readableState.destroyed = !0), this._writableState && (this._writableState.destroyed = !0), this._destroy(e || null, function(e) { + return u || l ? o ? o(e) : e && (this._writableState ? this._writableState.errorEmitted || (this._writableState.errorEmitted = !0, n.nextTick(i, this, e)) : n.nextTick(i, this, e)) : (this._readableState && (this._readableState.destroyed = !0), this._writableState && (this._writableState.destroyed = !0), this._destroy(e || null, function(e) { !o && e ? a._writableState ? a._writableState.errorEmitted ? n.nextTick(r, a) : (a._writableState.errorEmitted = !0, n.nextTick(t, a, e)) : n.nextTick(t, a, e) : o ? (n.nextTick(r, a), o(e)) : n.nextTick(r, a); - }), this); + })), this; }, undestroy: function() { this._readableState && (this._readableState.destroyed = !1, this._readableState.reading = !1, this._readableState.ended = !1, this._readableState.endEmitted = !1), this._writableState && (this._writableState.destroyed = !1, this._writableState.ended = !1, this._writableState.ending = !1, this._writableState.finalCalled = !1, this._writableState.prefinished = !1, this._writableState.finished = !1, this._writableState.errorEmitted = !1); @@ -24758,16 +24758,16 @@ return e && null === t.alternate && (t.effectTag = 2), t; } function u(e, t, r, n) { - return null === t || 6 !== t.tag ? ((t = iv(r, e.mode, n)).return = e, t) : ((t = i(t, r, n)).return = e, t); + return null === t || 6 !== t.tag ? (t = iv(r, e.mode, n)).return = e : (t = i(t, r, n)).return = e, t; } function l(e, t, r, n) { - return null !== t && t.elementType === r.type ? ((n = i(t, r.props, n)).ref = tX(e, t, r), n.return = e, n) : ((n = iy(r.type, r.key, r.props, null, e.mode, n)).ref = tX(e, t, r), n.return = e, n); + return null !== t && t.elementType === r.type ? (n = i(t, r.props, n)).ref = tX(e, t, r) : (n = iy(r.type, r.key, r.props, null, e.mode, n)).ref = tX(e, t, r), n.return = e, n; } function s(e, t, r, n) { - return null === t || 4 !== t.tag || t.stateNode.containerInfo !== r.containerInfo || t.stateNode.implementation !== r.implementation ? ((t = ib(r, e.mode, n)).return = e, t) : ((t = i(t, r.children || [], n)).return = e, t); + return null === t || 4 !== t.tag || t.stateNode.containerInfo !== r.containerInfo || t.stateNode.implementation !== r.implementation ? (t = ib(r, e.mode, n)).return = e : (t = i(t, r.children || [], n)).return = e, t; } function c(e, t, r, n, o) { - return null === t || 7 !== t.tag ? ((t = ig(r, e.mode, n, o)).return = e, t) : ((t = i(t, r, n)).return = e, t); + return null === t || 7 !== t.tag ? (t = ig(r, e.mode, n, o)).return = e : (t = i(t, r, n)).return = e, t; } function f(e, t, r) { if ("string" == typeof t || "number" == typeof t) return (t = iv("" + t, e.mode, r)).return = e, t; @@ -24850,7 +24850,7 @@ } return a(u); } - if ("string" == typeof s || "number" == typeof s) return s = "" + s, null !== l && 6 === l.tag ? (r(u, l.sibling), (l = i(l, s, c)).return = u, u = l) : (r(u, l), (l = iv(s, u.mode, c)).return = u, u = l), a(u); + if ("string" == typeof s || "number" == typeof s) return s = "" + s, null !== l && 6 === l.tag ? (r(u, l.sibling), (l = i(l, s, c)).return = u) : (r(u, l), (l = iv(s, u.mode, c)).return = u), a(u = l); if (tZ(s)) return function(i, a, u, l) { for(var s = null, c = null, d = a, y = a = 0, g = null; null !== d && y < u.length; y++){ d.index > y ? (g = d, d = null) : g = d.sibling; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/regression-1/framework-798bab57daac3897/output.js b/crates/swc_ecma_minifier/tests/fixture/next/regression-1/framework-798bab57daac3897/output.js index 959692dcee17..3b838f7ea85c 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/regression-1/framework-798bab57daac3897/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/regression-1/framework-798bab57daac3897/output.js @@ -813,7 +813,7 @@ targetContainers: [ e ] - }, null !== b && null !== (b = Bb(b)) && Ec(b), a) : (a.eventSystemFlags |= d, b = a.targetContainers, null !== e && -1 === b.indexOf(e) && b.push(e), a); + }, null !== b && null !== (b = Bb(b)) && Ec(b)) : (a.eventSystemFlags |= d, b = a.targetContainers, null !== e && -1 === b.indexOf(e) && b.push(e)), a; } function Uc(a) { var b = Vc(a.target); @@ -2407,17 +2407,17 @@ return a && null === b.alternate && (b.flags |= 2), b; } function h(a, b, c, d) { - return null === b || 6 !== b.tag ? ((b = uh(c, a.mode, d)).return = a, b) : ((b = e(b, c)).return = a, b); + return null === b || 6 !== b.tag ? (b = uh(c, a.mode, d)).return = a : (b = e(b, c)).return = a, b; } function k(a, b, c, d) { var f = c.type; - return f === wa ? n(a, b, c.props.children, d, c.key) : null !== b && (b.elementType === f || "object" == typeof f && null !== f && f.$$typeof === Ga && rh(f) === b.type) ? ((d = e(b, c.props)).ref = ph(a, b, c), d.return = a, d) : ((d = vh(c.type, c.key, c.props, null, a.mode, d)).ref = ph(a, b, c), d.return = a, d); + return f === wa ? n(a, b, c.props.children, d, c.key) : (null !== b && (b.elementType === f || "object" == typeof f && null !== f && f.$$typeof === Ga && rh(f) === b.type) ? (d = e(b, c.props)).ref = ph(a, b, c) : (d = vh(c.type, c.key, c.props, null, a.mode, d)).ref = ph(a, b, c), d.return = a, d); } function l(a, b, c, d) { - return null === b || 4 !== b.tag || b.stateNode.containerInfo !== c.containerInfo || b.stateNode.implementation !== c.implementation ? ((b = wh(c, a.mode, d)).return = a, b) : ((b = e(b, c.children || [])).return = a, b); + return null === b || 4 !== b.tag || b.stateNode.containerInfo !== c.containerInfo || b.stateNode.implementation !== c.implementation ? (b = wh(c, a.mode, d)).return = a : (b = e(b, c.children || [])).return = a, b; } function n(a, b, c, d, f) { - return null === b || 7 !== b.tag ? ((b = xh(c, a.mode, d, f)).return = a, b) : ((b = e(b, c)).return = a, b); + return null === b || 7 !== b.tag ? (b = xh(c, a.mode, d, f)).return = a : (b = e(b, c)).return = a, b; } function u(a, b, c) { if ("string" == typeof b && "" !== b || "number" == typeof b) return (b = uh("" + b, a.mode, c)).return = a, b; @@ -2557,7 +2557,7 @@ }(a1, d1, f1, h); qh(a1, f1); } - return "string" == typeof f1 && "" !== f1 || "number" == typeof f1 ? (f1 = "" + f1, null !== d1 && 6 === d1.tag ? (c(a1, d1.sibling), (d1 = e(d1, f1)).return = a1, a1 = d1) : (c(a1, d1), (d1 = uh(f1, a1.mode, h)).return = a1, a1 = d1), g(a1)) : c(a1, d1); + return "string" == typeof f1 && "" !== f1 || "number" == typeof f1 ? (f1 = "" + f1, null !== d1 && 6 === d1.tag ? (c(a1, d1.sibling), (d1 = e(d1, f1)).return = a1) : (c(a1, d1), (d1 = uh(f1, a1.mode, h)).return = a1), g(a1 = d1)) : c(a1, d1); }; } var yh = sh(!0), zh = sh(!1), Ah = {}, Bh = Tf(Ah), Ch = Tf(Ah), Dh = Tf(Ah); @@ -3190,7 +3190,7 @@ return null; } function Si(a, b, c, d, e) { - return 0 == (1 & a.mode) ? (a === b ? a.flags |= 65536 : (a.flags |= 128, c.flags |= 131072, c.flags &= -52805, 1 === c.tag && (null === c.alternate ? c.tag = 17 : ((b = zg(-1, 1)).tag = 2, Ag(c, b))), c.lanes |= 1), a) : (a.flags |= 65536, a.lanes = e, a); + return 0 == (1 & a.mode) ? a === b ? a.flags |= 65536 : (a.flags |= 128, c.flags |= 131072, c.flags &= -52805, 1 === c.tag && (null === c.alternate ? c.tag = 17 : ((b = zg(-1, 1)).tag = 2, Ag(c, b))), c.lanes |= 1) : (a.flags |= 65536, a.lanes = e), a; } function Xi(a, b) { if (!I) switch(a.tailMode){ diff --git a/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js b/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js index 35475b0ad632..d1cdcbf5c585 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js @@ -7713,7 +7713,7 @@ var ele = this.reactElement; ele && !this.isAppendCalled && (this.isAppendCalled = !0, this.appendTo(ele)); }, ComponentBase.prototype.shouldComponentUpdate = function(nextProps) { - return (this.isshouldComponentUpdateCalled = !0, this.initRenderCalled) ? (this.isAppendCalled || (clearTimeout(this.cachedTimeOut), this.isAppendCalled = !0, this.appendTo(this.reactElement)), this.updateProperties(nextProps), !0) : (this.updateProperties(nextProps, !0), !0); + return (this.isshouldComponentUpdateCalled = !0, this.initRenderCalled) ? (this.isAppendCalled || (clearTimeout(this.cachedTimeOut), this.isAppendCalled = !0, this.appendTo(this.reactElement)), this.updateProperties(nextProps)) : this.updateProperties(nextProps, !0), !0; }, ComponentBase.prototype.updateProperties = function(nextProps, silent) { for(var _this = this, dProps = (0, ej2_base.l7)({}, nextProps), keys = Object.keys(nextProps), _i = 0; _i < keys.length; _i++){ var propkey = keys[_i], isClassName = 'className' === propkey; @@ -8240,7 +8240,7 @@ baseToolbar: this.parent.getBaseToolbarObject() }); var serializeValue = this.parent.serializeValue(editHTML.value); - value = null === serializeValue || '' === serializeValue ? 'DIV' === this.parent.enterKey ? '
a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sB(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sF(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sB(s.x 0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;i a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sB(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sF(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sB(s.x1)for(let i=0;i100)y=d.mult(-1);else{const i=b*u.add(d).mag()/u.sub(d).mag();y._perp()._mult(i*(E?-1:1))}this.addCurrentVertex(l,y,0,0,g),this.addCurrentVertex(l,y.mult(-1),0,0,g)}else if("bevel"===I||"fakeround"===I){const i=-Math.sqrt(b*b-1),r=E?i:0,n=E?0:i;if(c&&this.addCurrentVertex(l,u,r,n,g),"fakeround"===I){const i=Math.round(180*w/Math.PI/20);for(let r=1;r2*_){const r=l.add(h.sub(l)._mult(_/i)._round());this.updateDistance(l,r),this.addCurrentVertex(r,d,0,0,g),l=r}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}rj("LineBucket",a_,{omit:["layers","patternFeatures"]});const ag=new nN({"line-cap":new nF(tt.layout_line["line-cap"]),"line-join":new nF(tt.layout_line["line-join"]),"line-miter-limit":new nR(tt.layout_line["line-miter-limit"]),"line-round-limit":new nR(tt.layout_line["line-round-limit"]),"line-sort-key":new nF(tt.layout_line["line-sort-key"])});var ay={paint:new nN({"line-opacity":new nF(tt.paint_line["line-opacity"]),"line-color":new nF(tt.paint_line["line-color"]),"line-translate":new nR(tt.paint_line["line-translate"]),"line-translate-anchor":new nR(tt.paint_line["line-translate-anchor"]),"line-width":new nF(tt.paint_line["line-width"]),"line-gap-width":new nF(tt.paint_line["line-gap-width"]),"line-offset":new nF(tt.paint_line["line-offset"]),"line-blur":new nF(tt.paint_line["line-blur"]),"line-dasharray":new nO(tt.paint_line["line-dasharray"]),"line-pattern":new nO(tt.paint_line["line-pattern"]),"line-gradient":new nV(tt.paint_line["line-gradient"])}),layout:ag};const ax=new class extends nF{possiblyEvaluate(i,r){return r=new nM(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(ay.paint.properties["line-width"].specification);ax.useIntegerZoom=!0;const av=nq([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),ab=nq([{name:"a_projected_pos",components:3,type:"Float32"}],4);nq([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aw=nq([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aT=nq([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nq([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const aE=nq([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),aS=nq([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function aI(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nM(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:r,interpolationType:o}=n;let s=0;for(;s0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aD(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aD.Varint=0,aD.Fixed64=1,aD.Bytes=2,aD.Fixed32=5;var aL="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aB(i){return i.type===aD.Bytes?i.readVarint()+i.pos:i.pos+1}function aR(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aF(i,r){for(var n=0;n0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let r=n.vertexStartIndex;r{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cg.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oS(r,l,c),oS(n,3*l,3*c),oS(n,3*l+1,3*c+1),oS(n,3*l+2,3*c+2)}c-o1)for(let i=0;i