mirror of
https://github.com/swc-project/swc.git
synced 2025-01-03 02:54:43 +03:00
fix(es/minifier): Don't inline into arrow heads (#7099)
**Related issue:** - https://github.com/vercel/next.js/issues/47005
This commit is contained in:
parent
1aa9a98b27
commit
610e1bb581
@ -19,7 +19,7 @@ crates/swc_css_parser/tests/
|
||||
crates/swc_css_prefixer/tests/
|
||||
crates/swc_ecma_codegen/tests/
|
||||
crates/swc_ecma_lints/tests/
|
||||
crates/swc_ecma_minifier/tests/
|
||||
crates/swc_ecma_minifier/tests/**/output.js
|
||||
crates/swc_ecma_parser/tests/
|
||||
crates/swc_estree_compat/tests/
|
||||
crates/swc_html_codegen/tests/
|
||||
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"defaults": true,
|
||||
"conditionals": false,
|
||||
"sequences": false,
|
||||
"booleans": false,
|
||||
"dead_code": false,
|
||||
"reduce_vars": false,
|
||||
"join_vars": false,
|
||||
"comparisons": false,
|
||||
"computed_props": false,
|
||||
"evaluate": false,
|
||||
"if_return": false,
|
||||
"loops": false,
|
||||
"collapse_vars": true,
|
||||
"unused": true,
|
||||
"inline": true,
|
||||
"passes": 1
|
||||
}
|
539
crates/swc_ecma_minifier/tests/fixture/next/47005/input.js
Normal file
539
crates/swc_ecma_minifier/tests/fixture/next/47005/input.js
Normal file
@ -0,0 +1,539 @@
|
||||
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
|
||||
[502], {
|
||||
|
||||
/***/
|
||||
9145:
|
||||
/***/
|
||||
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
/* harmony export */
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */
|
||||
"u": function () {
|
||||
return /* binding */ Ne;
|
||||
}
|
||||
/* harmony export */
|
||||
});
|
||||
/* unused harmony exports TooltipProvider, TooltipWrapper */
|
||||
/* harmony import */
|
||||
var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7294);
|
||||
/* harmony import */
|
||||
var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5893);
|
||||
var Ke = Object.create;
|
||||
var me = Object.defineProperty;
|
||||
var Ie = Object.getOwnPropertyDescriptor;
|
||||
var Ve = Object.getOwnPropertyNames;
|
||||
var $e = Object.getPrototypeOf,
|
||||
ze = Object.prototype.hasOwnProperty;
|
||||
var je = (t, e) => () => (e || t((e = {
|
||||
exports: {}
|
||||
}).exports, e), e.exports);
|
||||
var Xe = (t, e, n, o) => {
|
||||
if (e && typeof e == "object" || typeof e == "function")
|
||||
for (let l of Ve(e)) !ze.call(t, l) && l !== n && me(t, l, {
|
||||
get: () => e[l],
|
||||
enumerable: !(o = Ie(e, l)) || o.enumerable
|
||||
});
|
||||
return t
|
||||
};
|
||||
var he = (t, e, n) => (n = t != null ? Ke($e(t)) : {}, Xe(e || !t || !t.__esModule ? me(n, "default", {
|
||||
}) : n, t));
|
||||
var Ut = je(() => {
|
||||
});
|
||||
var ae = he(Ut());
|
||||
var Ue = () => {
|
||||
},
|
||||
Yt = Ue;
|
||||
var qt = "DEFAULT_TOOLTIP_ID",
|
||||
Ze = {
|
||||
},
|
||||
to = {
|
||||
},
|
||||
ge = (0, react__WEBPACK_IMPORTED_MODULE_0__.createContext)(to);
|
||||
|
||||
function at(t = qt) {
|
||||
}
|
||||
var Te = he(Ut());
|
||||
var ao = typeof window != "undefined" ? react__WEBPACK_IMPORTED_MODULE_0__.useLayoutEffect : react__WEBPACK_IMPORTED_MODULE_0__.useEffect,
|
||||
ve = ao;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var Ee = async () => {
|
||||
};
|
||||
|
||||
|
||||
|
||||
var te = t => ({
|
||||
});
|
||||
var ee = function () {
|
||||
};
|
||||
var oe = function (t) {
|
||||
return t === void 0 && (t = 0), {
|
||||
name: "offset",
|
||||
options: t,
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var ne = function () {
|
||||
|
||||
};
|
||||
|
||||
function V(t) {
|
||||
}
|
||||
|
||||
function G(t) {
|
||||
}
|
||||
var Kt = Math.round;
|
||||
|
||||
function Ce(t) {
|
||||
|
||||
}
|
||||
|
||||
function rt(t) {
|
||||
}
|
||||
var Ft;
|
||||
|
||||
function ke() {
|
||||
if (Ft) return Ft;
|
||||
let t = navigator.userAgentData;
|
||||
return t && Array.isArray(t.brands) ? (Ft = t.brands.map(e => e.brand + "/" + e.version).join(" "), Ft) : navigator.userAgent
|
||||
}
|
||||
|
||||
function Y(t) {
|
||||
}
|
||||
|
||||
function ot(t) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
function It(t) {
|
||||
}
|
||||
|
||||
|
||||
function re(t) {
|
||||
let e = /firefox/i.test(ke()),
|
||||
n = G(t),
|
||||
o = n.backdropFilter || n.WebkitBackdropFilter;
|
||||
return n.transform !== "none" || n.perspective !== "none" || !!o && o !== "none" || e && n.willChange === "filter" || e && !!n.filter && n.filter !== "none" || ["transform", "perspective"].some(l => n.willChange.includes(l)) || ["paint", "layout", "strict", "content"].some(l => {
|
||||
let r = n.contain;
|
||||
return r != null && r.includes(l)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function le(t) {
|
||||
}
|
||||
|
||||
|
||||
function Tt(t) {
|
||||
}
|
||||
|
||||
|
||||
function nt(t) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
function kt(t) {
|
||||
}
|
||||
|
||||
function Oe(t) {
|
||||
}
|
||||
|
||||
function We(t, e) {
|
||||
}
|
||||
|
||||
function _e(t, e, n) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function Pe(t, e) {
|
||||
}
|
||||
|
||||
function To(t, e, n) {
|
||||
|
||||
}
|
||||
var xo = {
|
||||
getClippingRect: function (t) {
|
||||
let {
|
||||
element: e,
|
||||
boundary: n,
|
||||
rootBoundary: o,
|
||||
strategy: l
|
||||
} = t, r = n === "clippingAncestors" ? function (u, a) {
|
||||
let c = a.get(u);
|
||||
if (c) return c;
|
||||
let d = We(u).filter(w => ot(w) && rt(w) !== "body"),
|
||||
p = null,
|
||||
y = G(u).position === "fixed",
|
||||
g = y ? kt(u) : u;
|
||||
for (; ot(g) && !le(g);) {
|
||||
let w = G(g),
|
||||
T = re(g);
|
||||
w.position === "fixed" ? p = null : (y ? T || p : T || w.position !== "static" || !p || !["absolute", "fixed"].includes(p.position)) ? p = w : d = d.filter(x => x !== g), g = kt(g)
|
||||
}
|
||||
return a.set(u, d), d
|
||||
}(e, this._c) : [].concat(n), i = [...r, o], s = i[0], f = i.reduce(() => {
|
||||
}, _e(e, s, l));
|
||||
return {
|
||||
width: f.right - f.left,
|
||||
height: f.bottom - f.top,
|
||||
x: f.left,
|
||||
y: f.top
|
||||
}
|
||||
},
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect: function () {
|
||||
|
||||
},
|
||||
isElement: ot,
|
||||
getDimensions: function (t) {
|
||||
return Y(t) ? Ce(t) : t.getBoundingClientRect()
|
||||
},
|
||||
getOffsetParent: Pe,
|
||||
getDocumentElement: nt,
|
||||
getScale: Tt,
|
||||
async getElementRects(t) {
|
||||
let {
|
||||
reference: e,
|
||||
floating: n,
|
||||
strategy: o
|
||||
} = t, l = this.getOffsetParent || Pe, r = this.getDimensions;
|
||||
return {
|
||||
reference: To(e, await l(n), o),
|
||||
floating: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
...await r(n)
|
||||
}
|
||||
}
|
||||
},
|
||||
getClientRects: t => Array.from(t.getClientRects()),
|
||||
isRTL: t => G(t).direction === "rtl"
|
||||
};
|
||||
var se = (t, e, n) => {
|
||||
let o = new Map,
|
||||
l = {
|
||||
platform: xo,
|
||||
...n
|
||||
},
|
||||
r = {
|
||||
...l.platform,
|
||||
_c: o
|
||||
};
|
||||
return Ee(t, e, {
|
||||
...l,
|
||||
platform: r
|
||||
})
|
||||
};
|
||||
var ce = async ({
|
||||
elementReference: t = null,
|
||||
tooltipReference: e = null,
|
||||
tooltipArrowReference: n = null,
|
||||
place: o = "top",
|
||||
offset: l = 10,
|
||||
strategy: r = "absolute",
|
||||
middlewares: i = [oe(Number(l)), ee(), ne({
|
||||
padding: 5
|
||||
})]
|
||||
}) => {
|
||||
if (!t) return {
|
||||
tooltipStyles: {},
|
||||
tooltipArrowStyles: {},
|
||||
place: o
|
||||
};
|
||||
if (e === null) return {
|
||||
tooltipStyles: {},
|
||||
tooltipArrowStyles: {},
|
||||
place: o
|
||||
};
|
||||
let s = i;
|
||||
return n ? (s.push(te({
|
||||
element: n,
|
||||
padding: 5
|
||||
})), se(t, e, {
|
||||
placement: o,
|
||||
strategy: r,
|
||||
middleware: s
|
||||
}).then(() => {
|
||||
})) : se(t, e, {
|
||||
placement: "bottom",
|
||||
strategy: r,
|
||||
middleware: s
|
||||
}).then(({
|
||||
x: f,
|
||||
y: u,
|
||||
placement: a
|
||||
}) => ({
|
||||
tooltipStyles: {
|
||||
left: `${f}px`,
|
||||
top: `${u}px`
|
||||
},
|
||||
tooltipArrowStyles: {},
|
||||
place: a
|
||||
}))
|
||||
};
|
||||
var it = {
|
||||
arrow: "react-tooltip__arrow_KtSkBq",
|
||||
clickable: "react-tooltip__clickable_KtSkBq",
|
||||
dark: "react-tooltip__dark_KtSkBq",
|
||||
error: "react-tooltip__error_KtSkBq",
|
||||
fixed: "react-tooltip__fixed_KtSkBq",
|
||||
info: "react-tooltip__info_KtSkBq",
|
||||
light: "react-tooltip__light_KtSkBq",
|
||||
noArrow: "react-tooltip__no-arrow_KtSkBq",
|
||||
show: "react-tooltip__show_KtSkBq",
|
||||
success: "react-tooltip__success_KtSkBq",
|
||||
tooltip: "react-tooltip__tooltip_KtSkBq",
|
||||
warning: "react-tooltip__warning_KtSkBq"
|
||||
};
|
||||
var vo = ({
|
||||
}) => {
|
||||
let E = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null),
|
||||
M = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null),
|
||||
C = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null),
|
||||
S = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null),
|
||||
[H, J] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(i),
|
||||
[Q, ut] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)({}),
|
||||
[pt, st] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)({}),
|
||||
[$, dt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(!1),
|
||||
[Dt, mt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(!1),
|
||||
vt = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null),
|
||||
{
|
||||
anchorRefs: Ht } = at(t),
|
||||
bt = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(!1),
|
||||
[et, Et] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)([]),
|
||||
ct = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(!1),
|
||||
ht = u || f.includes("click");
|
||||
ve(() => (ct.current = !0, () => {
|
||||
ct.current = !1
|
||||
}), []), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
if (!$) {
|
||||
let m = setTimeout(() => {
|
||||
mt(!1)
|
||||
}, 150);
|
||||
return () => {
|
||||
clearTimeout(m)
|
||||
}
|
||||
}
|
||||
return () => null
|
||||
}, [$]);
|
||||
let N = m => {
|
||||
ct.current && (m && mt(!0), setTimeout(() => {
|
||||
ct.current && (U == null || U(m), q === void 0 && dt(m))
|
||||
}, 10))
|
||||
};
|
||||
(0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
if (q === void 0) return () => null;
|
||||
q && mt(!0);
|
||||
return () => {
|
||||
}
|
||||
}, [q]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
}, [$]);
|
||||
let yt = (m = y) => {
|
||||
},
|
||||
At = () => {
|
||||
|
||||
},
|
||||
Lt = () => {
|
||||
},
|
||||
gt = ({
|
||||
}) => {
|
||||
|
||||
},
|
||||
wt = m => {
|
||||
if (!m) return;
|
||||
let A = m,
|
||||
L = {
|
||||
x: A.clientX,
|
||||
y: A.clientY
|
||||
};
|
||||
gt(L), vt.current = L
|
||||
},
|
||||
pe = m => {
|
||||
At(m), y && yt()
|
||||
},
|
||||
B = m => {
|
||||
var k;
|
||||
[document.querySelector(`[id='${l}']`), ...et].some(O => O == null ? void 0 : O.contains(m.target)) || (k = E.current) != null && k.contains(m.target) || N(!1)
|
||||
},
|
||||
I = m => {
|
||||
m.key === "Escape" && N(!1)
|
||||
},
|
||||
h = Yt(At, 50),
|
||||
D = Yt(Lt, 50);
|
||||
(0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
var F, z;
|
||||
let m = new Set(Ht);
|
||||
et.forEach(j => {
|
||||
m.add({
|
||||
current: j
|
||||
})
|
||||
});
|
||||
let A = document.querySelector(`[id='${l}']`);
|
||||
A && m.add({
|
||||
current: A
|
||||
}), x && window.addEventListener("keydown", I);
|
||||
let L = [];
|
||||
ht ? (window.addEventListener("click", B), L.push({
|
||||
event: "click",
|
||||
listener: pe
|
||||
})) : (L.push({
|
||||
event: "mouseenter",
|
||||
listener: h
|
||||
}, {
|
||||
event: "mouseleave",
|
||||
listener: D
|
||||
}, {
|
||||
event: "focus",
|
||||
listener: h
|
||||
}, {
|
||||
event: "blur",
|
||||
listener: D
|
||||
}), g && L.push({
|
||||
event: "mousemove",
|
||||
listener: wt
|
||||
}));
|
||||
let k = () => {
|
||||
bt.current = !0
|
||||
},
|
||||
O = () => {
|
||||
bt.current = !1, Lt()
|
||||
};
|
||||
return T && !ht && ((F = E.current) == null || F.addEventListener("mouseenter", k), (z = E.current) == null || z.addEventListener("mouseleave", O)), L.forEach(({
|
||||
event: j,
|
||||
listener: Bt
|
||||
}) => {
|
||||
m.forEach(Xt => {
|
||||
var Ot;
|
||||
(Ot = Xt.current) == null || Ot.addEventListener(j, Bt)
|
||||
})
|
||||
}), () => {
|
||||
var j, Bt;
|
||||
ht && window.removeEventListener("click", B), x && window.removeEventListener("keydown", I), T && !ht && ((j = E.current) == null || j.removeEventListener("mouseenter", k), (Bt = E.current) == null || Bt.removeEventListener("mouseleave", O)), L.forEach(({
|
||||
event: Xt,
|
||||
listener: Ot
|
||||
}) => {
|
||||
m.forEach(Fe => {
|
||||
var de;
|
||||
(de = Fe.current) == null || de.removeEventListener(Xt, Ot)
|
||||
})
|
||||
})
|
||||
}
|
||||
}, [Dt, Ht, et, x, f]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
let m = r != null ? r : "";
|
||||
!m && t && (m = `[data-tooltip-id='${t}']`);
|
||||
let A = k => {
|
||||
let O = [];
|
||||
k.forEach(F => {
|
||||
if (F.type === "attributes" && F.attributeName === "data-tooltip-id" && F.target.getAttribute("data-tooltip-id") === t && O.push(F.target), F.type === "childList" && (_ && [...F.removedNodes].some(z => z.contains(_) ? (mt(!1), N(!1), b(null), !0) : !1), !!m)) try {
|
||||
let z = [...F.addedNodes].filter(j => j.nodeType === 1);
|
||||
O.push(...z.filter(j => j.matches(m))), O.push(...z.flatMap(j => [...j.querySelectorAll(m)]))
|
||||
} catch (z) { }
|
||||
}), O.length && Et(F => [...F, ...O])
|
||||
},
|
||||
L = new MutationObserver(A);
|
||||
return L.observe(document.body, {
|
||||
childList: !0,
|
||||
subtree: !0,
|
||||
attributes: !0,
|
||||
attributeFilter: ["data-tooltip-id"]
|
||||
}), () => {
|
||||
L.disconnect()
|
||||
}
|
||||
}, [t, r, _]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
if (P) {
|
||||
gt(P);
|
||||
return
|
||||
}
|
||||
if (g) {
|
||||
vt.current && gt(vt.current);
|
||||
return
|
||||
}
|
||||
ce({
|
||||
place: i,
|
||||
offset: s,
|
||||
elementReference: _,
|
||||
tooltipReference: E.current,
|
||||
tooltipArrowReference: M.current,
|
||||
strategy: a,
|
||||
middlewares: c
|
||||
}).then(m => {
|
||||
ct.current && (Object.keys(m.tooltipStyles).length && ut(m.tooltipStyles), Object.keys(m.tooltipArrowStyles).length && st(m.tooltipArrowStyles), J(m.place))
|
||||
})
|
||||
}, [$, _, K, i, s, a, P]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
var L;
|
||||
let m = document.querySelector(`[id='${l}']`),
|
||||
A = [...et, m];
|
||||
(!_ || !A.includes(_)) && b((L = et[0]) != null ? L : m)
|
||||
}, [l, et, _]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => () => {
|
||||
C.current && clearTimeout(C.current), S.current && clearTimeout(S.current)
|
||||
}, []), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
let m = r;
|
||||
if (!m && t && (m = `[data-tooltip-id='${t}']`), !!m) try {
|
||||
let A = Array.from(document.querySelectorAll(m));
|
||||
Et(A)
|
||||
} catch (A) {
|
||||
Et([])
|
||||
}
|
||||
}, [t, r]);
|
||||
let Z = K && $ && Object.keys(Q).length > 0;
|
||||
return Dt ? (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(d, {
|
||||
id: t,
|
||||
role: "tooltip",
|
||||
className: (0, ae.default)("react-tooltip", it.tooltip, it[o], e, `react-tooltip__place-${H}`, {
|
||||
[it.show]: Z,
|
||||
[it.fixed]: a === "fixed",
|
||||
[it.clickable]: T
|
||||
}),
|
||||
style: {
|
||||
...v,
|
||||
...Q
|
||||
},
|
||||
ref: E,
|
||||
children: [K, (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(d, {
|
||||
className: (0, ae.default)("react-tooltip-arrow", it.arrow, n, {
|
||||
[it.noArrow]: w
|
||||
}),
|
||||
style: pt,
|
||||
ref: M
|
||||
})]
|
||||
}) : null
|
||||
},
|
||||
fe = vo;
|
||||
var Ao = ({
|
||||
content: t
|
||||
}) => (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span", {
|
||||
dangerouslySetInnerHTML: {
|
||||
__html: t
|
||||
}
|
||||
}),
|
||||
ue = Ao;
|
||||
var Ro = ({
|
||||
|
||||
setIsOpen: _ }) => {
|
||||
let [M, C] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(o), [S, H] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(l), [J, Q] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(u), [ut, pt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(f), [st, $] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(a), [dt, Dt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(T), [mt, Mt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(x), [vt, Ht] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(v), [zt, bt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(c), [et, Et] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(p), [ct, ht] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(g), [N, jt] = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(null), {
|
||||
} = at(t);
|
||||
(0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
}, [o]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
}, [l]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
}, [u]), (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
}, [yt, At, N, e, n]);
|
||||
let wt = d;
|
||||
return r ? wt = r({
|
||||
}) : M && (wt = M), S && (wt = (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(ue, {
|
||||
})), (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(fe, {
|
||||
})
|
||||
},
|
||||
Ne = Ro;
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
]);
|
@ -0,0 +1 @@
|
||||
{}
|
432
crates/swc_ecma_minifier/tests/fixture/next/47005/output.js
Normal file
432
crates/swc_ecma_minifier/tests/fixture/next/47005/output.js
Normal file
@ -0,0 +1,432 @@
|
||||
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([
|
||||
[
|
||||
502
|
||||
],
|
||||
{
|
||||
9145: function(m, S, h) {
|
||||
"use strict";
|
||||
h.d(S, {
|
||||
u: function() {
|
||||
return eu;
|
||||
}
|
||||
});
|
||||
var E, k, R, A = h(7294);
|
||||
var O = h(5893);
|
||||
var L = Object.create;
|
||||
var j = Object.defineProperty;
|
||||
var B = Object.getOwnPropertyDescriptor;
|
||||
var C = Object.getOwnPropertyNames;
|
||||
var N = Object.getPrototypeOf, $ = Object.prototype.hasOwnProperty;
|
||||
var D = (m, S, h, E)=>{
|
||||
if (S && "object" == typeof S || "function" == typeof S) for (let k of C(S))$.call(m, k) || k === h || j(m, k, {
|
||||
get: ()=>S[k],
|
||||
enumerable: !(E = B(S, k)) || E.enumerable
|
||||
});
|
||||
return m;
|
||||
};
|
||||
var M = (m, S, h)=>(h = null != m ? L(N(m)) : {}, D(!S && m && m.__esModule ? h : j(h, "default", {}), m));
|
||||
var F = (E = ()=>{}, ()=>(k || E((k = {
|
||||
exports: {}
|
||||
}).exports, k), k.exports));
|
||||
var I = M(F());
|
||||
var H = ()=>{};
|
||||
(0, A.createContext)({});
|
||||
function V(m = "DEFAULT_TOOLTIP_ID") {}
|
||||
M(F());
|
||||
var W = "undefined" != typeof window ? A.useLayoutEffect : A.useEffect;
|
||||
var X = async ()=>{};
|
||||
var Y = (m)=>({});
|
||||
var z = function() {};
|
||||
var G = function(m) {
|
||||
return void 0 === m && (m = 0), {
|
||||
name: "offset",
|
||||
options: m
|
||||
};
|
||||
};
|
||||
var J = function() {};
|
||||
function Q(m) {}
|
||||
function Z(m) {}
|
||||
function ee(m) {}
|
||||
function et(m, S) {}
|
||||
var er = {
|
||||
getClippingRect: function(m) {
|
||||
var S, h, E;
|
||||
let { element: k , boundary: A , rootBoundary: O , strategy: L } = m, j = [
|
||||
..."clippingAncestors" === A ? function(m, S) {
|
||||
var h, E, k;
|
||||
let A = S.get(m);
|
||||
if (A) return A;
|
||||
let O = (void (h = 0)).filter((m)=>{
|
||||
var S;
|
||||
return Z(m) && (S = 0, true);
|
||||
}), L = null, j = "fixed" === Q(m).position, B = j ? ee(m) : m;
|
||||
for(; Z(B) && (k = 0, true);){
|
||||
let m = Q(B), S = function(m) {
|
||||
let S = /firefox/i.test(function() {
|
||||
if (R) return R;
|
||||
let m = navigator.userAgentData;
|
||||
return m && Array.isArray(m.brands) ? R = m.brands.map((m)=>m.brand + "/" + m.version).join(" ") : navigator.userAgent;
|
||||
}()), h = Q(m), E = h.backdropFilter || h.WebkitBackdropFilter;
|
||||
return "none" !== h.transform || "none" !== h.perspective || !!E && "none" !== E || S && "filter" === h.willChange || S && !!h.filter && "none" !== h.filter || [
|
||||
"transform",
|
||||
"perspective"
|
||||
].some((m)=>h.willChange.includes(m)) || [
|
||||
"paint",
|
||||
"layout",
|
||||
"strict",
|
||||
"content"
|
||||
].some((m)=>{
|
||||
let S = h.contain;
|
||||
return null != S && S.includes(m);
|
||||
});
|
||||
}(B);
|
||||
"fixed" === m.position ? L = null : (j ? S || L : S || "static" !== m.position || !L || ![
|
||||
"absolute",
|
||||
"fixed"
|
||||
].includes(L.position)) ? L = m : O = O.filter((m)=>m !== B), B = ee(B);
|
||||
}
|
||||
return S.set(m, O), O;
|
||||
}(k, this._c) : [].concat(A),
|
||||
O
|
||||
], B = j[0], C = j.reduce(()=>{}, (S = 0, h = 0, void (E = 0)));
|
||||
return {
|
||||
width: C.right - C.left,
|
||||
height: C.bottom - C.top,
|
||||
x: C.left,
|
||||
y: C.top
|
||||
};
|
||||
},
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect: function() {},
|
||||
isElement: Z,
|
||||
getDimensions: function(m) {
|
||||
var S, h;
|
||||
return (S = 0), m.getBoundingClientRect();
|
||||
},
|
||||
getOffsetParent: et,
|
||||
getDocumentElement: function(m) {},
|
||||
getScale: function(m) {},
|
||||
async getElementRects (m) {
|
||||
var S, h, E;
|
||||
let { reference: k , floating: R , strategy: A } = m, O = this.getOffsetParent || et, L = this.getDimensions;
|
||||
return {
|
||||
reference: (S = 0, h = await O(R), void (E = 0)),
|
||||
floating: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
...await L(R)
|
||||
}
|
||||
};
|
||||
},
|
||||
getClientRects: (m)=>Array.from(m.getClientRects()),
|
||||
isRTL: (m)=>"rtl" === Q(m).direction
|
||||
};
|
||||
var en = (m, S, h)=>{
|
||||
let E = new Map, k = {
|
||||
platform: er,
|
||||
...h
|
||||
}, R = {
|
||||
...k.platform,
|
||||
_c: E
|
||||
};
|
||||
return X(m, S, {
|
||||
...k,
|
||||
platform: R
|
||||
});
|
||||
};
|
||||
var eo = async ({ elementReference: m = null , tooltipReference: S = null , tooltipArrowReference: h = null , place: E = "top" , offset: k = 10 , strategy: R = "absolute" , middlewares: A = [
|
||||
G(Number(k)),
|
||||
z(),
|
||||
J({
|
||||
padding: 5
|
||||
})
|
||||
] })=>{
|
||||
if (!m) return {
|
||||
tooltipStyles: {},
|
||||
tooltipArrowStyles: {},
|
||||
place: E
|
||||
};
|
||||
if (null === S) return {
|
||||
tooltipStyles: {},
|
||||
tooltipArrowStyles: {},
|
||||
place: E
|
||||
};
|
||||
return h ? (A.push(Y({
|
||||
element: h,
|
||||
padding: 5
|
||||
})), en(m, S, {
|
||||
placement: E,
|
||||
strategy: R,
|
||||
middleware: A
|
||||
}).then(()=>{})) : en(m, S, {
|
||||
placement: "bottom",
|
||||
strategy: R,
|
||||
middleware: A
|
||||
}).then(({ x: m , y: S , placement: h })=>({
|
||||
tooltipStyles: {
|
||||
left: `${m}px`,
|
||||
top: `${S}px`
|
||||
},
|
||||
tooltipArrowStyles: {},
|
||||
place: h
|
||||
}));
|
||||
};
|
||||
var el = {
|
||||
arrow: "react-tooltip__arrow_KtSkBq",
|
||||
clickable: "react-tooltip__clickable_KtSkBq",
|
||||
dark: "react-tooltip__dark_KtSkBq",
|
||||
error: "react-tooltip__error_KtSkBq",
|
||||
fixed: "react-tooltip__fixed_KtSkBq",
|
||||
info: "react-tooltip__info_KtSkBq",
|
||||
light: "react-tooltip__light_KtSkBq",
|
||||
noArrow: "react-tooltip__no-arrow_KtSkBq",
|
||||
show: "react-tooltip__show_KtSkBq",
|
||||
success: "react-tooltip__success_KtSkBq",
|
||||
tooltip: "react-tooltip__tooltip_KtSkBq",
|
||||
warning: "react-tooltip__warning_KtSkBq"
|
||||
};
|
||||
var ei = ({})=>{
|
||||
let m = (0, A.useRef)(null), S = (0, A.useRef)(null), h = (0, A.useRef)(null), E = (0, A.useRef)(null), [k, R] = (0, A.useState)(i), [L, j] = (0, A.useState)({}), [B, C] = (0, A.useState)({}), [N, $] = (0, A.useState)(!1), [D, M] = (0, A.useState)(!1), F = (0, A.useRef)(null), { anchorRefs: X } = V(t), Y = (0, A.useRef)(!1), [z, G] = (0, A.useState)([]), J = (0, A.useRef)(!1), Q = u || f.includes("click");
|
||||
W(()=>(J.current = !0, ()=>{
|
||||
J.current = !1;
|
||||
}), []), (0, A.useEffect)(()=>{
|
||||
if (!N) {
|
||||
let m = setTimeout(()=>{
|
||||
M(!1);
|
||||
}, 150);
|
||||
return ()=>{
|
||||
clearTimeout(m);
|
||||
};
|
||||
}
|
||||
return ()=>null;
|
||||
}, [
|
||||
N
|
||||
]);
|
||||
let Z = (m)=>{
|
||||
J.current && (m && M(!0), setTimeout(()=>{
|
||||
J.current && (null == U || U(m), void 0 === q && $(m));
|
||||
}, 10));
|
||||
};
|
||||
(0, A.useEffect)(()=>{
|
||||
if (void 0 === q) return ()=>null;
|
||||
q && M(!0);
|
||||
return ()=>{};
|
||||
}, [
|
||||
q
|
||||
]), (0, A.useEffect)(()=>{}, [
|
||||
N
|
||||
]);
|
||||
let ee = (m = y)=>{}, et = ()=>{}, er = ()=>{}, en = ({})=>{}, ei = (m)=>{
|
||||
if (!m) return;
|
||||
let S = {
|
||||
x: m.clientX,
|
||||
y: m.clientY
|
||||
};
|
||||
en(S), F.current = S;
|
||||
}, ea = (m)=>{
|
||||
et(m), y && ee();
|
||||
}, eu = (S)=>{
|
||||
var h;
|
||||
[
|
||||
document.querySelector(`[id='${l}']`),
|
||||
...z
|
||||
].some((m)=>null == m ? void 0 : m.contains(S.target)) || null != (h = m.current) && h.contains(S.target) || Z(!1);
|
||||
}, es = (m)=>{
|
||||
"Escape" === m.key && Z(!1);
|
||||
}, ec = H(et, 50), ef = H(er, 50);
|
||||
(0, A.useEffect)(()=>{
|
||||
var S, h;
|
||||
let E = new Set(X);
|
||||
z.forEach((m)=>{
|
||||
E.add({
|
||||
current: m
|
||||
});
|
||||
});
|
||||
let k = document.querySelector(`[id='${l}']`);
|
||||
k && E.add({
|
||||
current: k
|
||||
}), x && window.addEventListener("keydown", es);
|
||||
let R = [];
|
||||
Q ? (window.addEventListener("click", eu), R.push({
|
||||
event: "click",
|
||||
listener: ea
|
||||
})) : (R.push({
|
||||
event: "mouseenter",
|
||||
listener: ec
|
||||
}, {
|
||||
event: "mouseleave",
|
||||
listener: ef
|
||||
}, {
|
||||
event: "focus",
|
||||
listener: ec
|
||||
}, {
|
||||
event: "blur",
|
||||
listener: ef
|
||||
}), g && R.push({
|
||||
event: "mousemove",
|
||||
listener: ei
|
||||
}));
|
||||
let A = ()=>{
|
||||
Y.current = !0;
|
||||
}, O = ()=>{
|
||||
Y.current = !1, er();
|
||||
};
|
||||
return T && !Q && (null == (S = m.current) || S.addEventListener("mouseenter", A), null == (h = m.current) || h.addEventListener("mouseleave", O)), R.forEach(({ event: m , listener: S })=>{
|
||||
E.forEach((h)=>{
|
||||
var E;
|
||||
null == (E = h.current) || E.addEventListener(m, S);
|
||||
});
|
||||
}), ()=>{
|
||||
var S, h;
|
||||
Q && window.removeEventListener("click", eu), x && window.removeEventListener("keydown", es), T && !Q && (null == (S = m.current) || S.removeEventListener("mouseenter", A), null == (h = m.current) || h.removeEventListener("mouseleave", O)), R.forEach(({ event: m , listener: S })=>{
|
||||
E.forEach((h)=>{
|
||||
var E;
|
||||
null == (E = h.current) || E.removeEventListener(m, S);
|
||||
});
|
||||
});
|
||||
};
|
||||
}, [
|
||||
D,
|
||||
X,
|
||||
z,
|
||||
x,
|
||||
f
|
||||
]), (0, A.useEffect)(()=>{
|
||||
let m = null != r ? r : "";
|
||||
!m && t && (m = `[data-tooltip-id='${t}']`);
|
||||
let S = (S)=>{
|
||||
let h = [];
|
||||
S.forEach((S)=>{
|
||||
if ("attributes" === S.type && "data-tooltip-id" === S.attributeName && S.target.getAttribute("data-tooltip-id") === t && h.push(S.target), "childList" === S.type && (_ && [
|
||||
...S.removedNodes
|
||||
].some((m)=>!!m.contains(_) && (M(!1), Z(!1), b(null), !0)), !!m)) try {
|
||||
let E = [
|
||||
...S.addedNodes
|
||||
].filter((m)=>1 === m.nodeType);
|
||||
h.push(...E.filter((S)=>S.matches(m))), h.push(...E.flatMap((S)=>[
|
||||
...S.querySelectorAll(m)
|
||||
]));
|
||||
} catch (m) {}
|
||||
}), h.length && G((m)=>[
|
||||
...m,
|
||||
...h
|
||||
]);
|
||||
}, h = new MutationObserver(S);
|
||||
return h.observe(document.body, {
|
||||
childList: !0,
|
||||
subtree: !0,
|
||||
attributes: !0,
|
||||
attributeFilter: [
|
||||
"data-tooltip-id"
|
||||
]
|
||||
}), ()=>{
|
||||
h.disconnect();
|
||||
};
|
||||
}, [
|
||||
t,
|
||||
r,
|
||||
_
|
||||
]), (0, A.useEffect)(()=>{
|
||||
if (P) {
|
||||
en(P);
|
||||
return;
|
||||
}
|
||||
if (g) {
|
||||
F.current && en(F.current);
|
||||
return;
|
||||
}
|
||||
eo({
|
||||
place: i,
|
||||
offset: s,
|
||||
elementReference: _,
|
||||
tooltipReference: m.current,
|
||||
tooltipArrowReference: S.current,
|
||||
strategy: a,
|
||||
middlewares: c
|
||||
}).then((m)=>{
|
||||
J.current && (Object.keys(m.tooltipStyles).length && j(m.tooltipStyles), Object.keys(m.tooltipArrowStyles).length && C(m.tooltipArrowStyles), R(m.place));
|
||||
});
|
||||
}, [
|
||||
N,
|
||||
_,
|
||||
K,
|
||||
i,
|
||||
s,
|
||||
a,
|
||||
P
|
||||
]), (0, A.useEffect)(()=>{
|
||||
var m;
|
||||
let S = document.querySelector(`[id='${l}']`), h = [
|
||||
...z,
|
||||
S
|
||||
];
|
||||
_ && h.includes(_) || b(null != (m = z[0]) ? m : S);
|
||||
}, [
|
||||
l,
|
||||
z,
|
||||
_
|
||||
]), (0, A.useEffect)(()=>()=>{
|
||||
h.current && clearTimeout(h.current), E.current && clearTimeout(E.current);
|
||||
}, []), (0, A.useEffect)(()=>{
|
||||
let m = r;
|
||||
if (!m && t && (m = `[data-tooltip-id='${t}']`), !!m) try {
|
||||
let S = Array.from(document.querySelectorAll(m));
|
||||
G(S);
|
||||
} catch (m) {
|
||||
G([]);
|
||||
}
|
||||
}, [
|
||||
t,
|
||||
r
|
||||
]);
|
||||
let ep = K && N && Object.keys(L).length > 0;
|
||||
return D ? (0, O.jsxs)(d, {
|
||||
id: t,
|
||||
role: "tooltip",
|
||||
className: (0, I.default)("react-tooltip", el.tooltip, el[o], e, `react-tooltip__place-${k}`, {
|
||||
[el.show]: ep,
|
||||
[el.fixed]: "fixed" === a,
|
||||
[el.clickable]: T
|
||||
}),
|
||||
style: {
|
||||
...v,
|
||||
...L
|
||||
},
|
||||
ref: m,
|
||||
children: [
|
||||
K,
|
||||
(0, O.jsx)(d, {
|
||||
className: (0, I.default)("react-tooltip-arrow", el.arrow, n, {
|
||||
[el.noArrow]: w
|
||||
}),
|
||||
style: B,
|
||||
ref: S
|
||||
})
|
||||
]
|
||||
}) : null;
|
||||
};
|
||||
var ea = ({ content: m })=>(0, O.jsx)("span", {
|
||||
dangerouslySetInnerHTML: {
|
||||
__html: m
|
||||
}
|
||||
});
|
||||
var eu = ({ setIsOpen: m })=>{
|
||||
let [S, h] = (0, A.useState)(o), [E, k] = (0, A.useState)(l), [R, L] = (0, A.useState)(u), [j, B] = (0, A.useState)(f), [C, N] = (0, A.useState)(a), [$, D] = (0, A.useState)(T), [M, F] = (0, A.useState)(x), [I, H] = (0, A.useState)(v), [W, X] = (0, A.useState)(c), [Y, z] = (0, A.useState)(p), [G, J] = (0, A.useState)(g), [Q, Z] = (0, A.useState)(null), {} = V(t);
|
||||
(0, A.useEffect)(()=>{}, [
|
||||
o
|
||||
]), (0, A.useEffect)(()=>{}, [
|
||||
l
|
||||
]), (0, A.useEffect)(()=>{}, [
|
||||
u
|
||||
]), (0, A.useEffect)(()=>{}, [
|
||||
yt,
|
||||
At,
|
||||
Q,
|
||||
e,
|
||||
n
|
||||
]);
|
||||
let ee = d;
|
||||
return r && r({}), E && (0, O.jsx)(ea, {}), (0, O.jsx)(ei, {});
|
||||
};
|
||||
}
|
||||
}
|
||||
]);
|
@ -191,6 +191,7 @@ where
|
||||
let ctx = Ctx {
|
||||
in_pat_of_param: true,
|
||||
is_delete_arg: false,
|
||||
inline_prevented: true,
|
||||
..child.ctx
|
||||
};
|
||||
n.params.visit_with(&mut *child.with_ctx(ctx));
|
||||
|
Loading…
Reference in New Issue
Block a user