what-compiler 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +181 -2
- package/babel.d.ts +78 -2
- package/dist/babel/auto-selector.min.js +94 -0
- package/dist/babel/common.min.js +2053 -0
- package/dist/babel/dev-metadata.min.js +106 -0
- package/dist/babel/dom.min.js +1669 -0
- package/dist/babel/jsx-root.min.js +13 -0
- package/dist/babel/lists.min.js +492 -0
- package/dist/babel/nesting.min.js +328 -0
- package/dist/babel/reactivity.min.js +1218 -0
- package/dist/babel/server-actions.min.js +85 -0
- package/dist/babel/ssr.min.js +496 -0
- package/dist/babel/types.min.js +9 -0
- package/dist/babel-plugin.min.js +101 -1
- package/dist/file-router.min.js +368 -12
- package/dist/framework-files.min.js +62 -0
- package/dist/hot.min.js +315 -0
- package/dist/index.min.js +13 -414
- package/dist/release.min.js +78 -0
- package/dist/runtime.min.js +9 -1
- package/dist/tables/import-changes.min.js +272 -0
- package/dist/tables/markup-rules.min.js +213 -0
- package/dist/vite-plugin.min.js +432 -399
- package/file-router.d.ts +3 -1
- package/index.d.ts +1 -1
- package/package.json +11 -2
- package/runtime.d.ts +2 -1
- package/src/babel/auto-selector.js +248 -0
- package/src/babel/common.js +3800 -0
- package/src/babel/dev-metadata.js +167 -0
- package/src/babel/dom.js +3386 -0
- package/src/babel/jsx-root.js +27 -0
- package/src/babel/lists.js +704 -0
- package/src/babel/nesting.js +260 -0
- package/src/babel/reactivity.js +1998 -0
- package/src/babel/server-actions.js +144 -0
- package/src/babel/ssr.js +870 -0
- package/src/babel/types.js +10 -0
- package/src/babel-plugin.js +185 -3598
- package/src/file-router.js +58 -38
- package/src/framework-files.js +106 -0
- package/src/hot.js +523 -0
- package/src/release.js +127 -0
- package/src/runtime.js +7 -7
- package/src/tables/import-changes.js +157 -0
- package/src/tables/markup-rules.js +388 -0
- package/src/vite-plugin.js +460 -175
- package/vite.d.ts +47 -3
- package/src/error-overlay.js +0 -428
|
@@ -0,0 +1,2053 @@
|
|
|
1
|
+
// src/babel/common.js
|
|
2
|
+
import {
|
|
3
|
+
HTML_ENCODINGS as nn,
|
|
4
|
+
INNER_HTML_PROPS as tn,
|
|
5
|
+
MATHML_IN_TEXT_POINTS as rn,
|
|
6
|
+
MATHML_TEXT_INTEGRATION_POINTS as sn,
|
|
7
|
+
SVG_HTML_INTEGRATION_POINTS as on,
|
|
8
|
+
VOID_ELEMENTS as an,
|
|
9
|
+
isRefusedAttr as ln,
|
|
10
|
+
isUnsafeUrl as cn,
|
|
11
|
+
isUrlAttr as un,
|
|
12
|
+
attributeName as pn,
|
|
13
|
+
rawTextHazard as fn,
|
|
14
|
+
FIELD_PROPS as dn,
|
|
15
|
+
FIELD_TAGS as mn,
|
|
16
|
+
ATTRIBUTE_VALUE_TYPES as hn
|
|
17
|
+
} from "../tables/markup-rules.min.js";
|
|
18
|
+
import { t as n } from "./types.min.js";
|
|
19
|
+
var gn = /* @__PURE__ */ new Set(["preventDefault", "stopPropagation", "once", "capture", "passive", "self"]), wt = /* @__PURE__ */ new Set(["once", "capture", "passive"]);
|
|
20
|
+
function P(e) {
|
|
21
|
+
return e === "what-framework" || e.startsWith("what-framework/") || e === "what-core" || e.startsWith("what-core/");
|
|
22
|
+
}
|
|
23
|
+
function Se(e) {
|
|
24
|
+
if (!/[\r\n]/.test(e))
|
|
25
|
+
return e.replace(/\t/g, " ");
|
|
26
|
+
let t = e.split(/\r\n|\n|\r/), r = -1;
|
|
27
|
+
for (let s = 0; s < t.length; s++)
|
|
28
|
+
/[^ \t]/.test(t[s]) && (r = s);
|
|
29
|
+
if (r === -1) return "";
|
|
30
|
+
let i = "";
|
|
31
|
+
for (let s = 0; s < t.length; s++) {
|
|
32
|
+
let o = t[s].replace(/\t/g, " "), l = s === 0, a = s === t.length - 1;
|
|
33
|
+
l || (o = o.replace(/^ +/, "")), a || (o = o.replace(/ +$/, "")), o && (s !== r && (o += " "), i += o);
|
|
34
|
+
}
|
|
35
|
+
return i;
|
|
36
|
+
}
|
|
37
|
+
function kt(e) {
|
|
38
|
+
e._usedNames = /* @__PURE__ */ new Set(), e._nameCounters = /* @__PURE__ */ new Map(), e._helperNames = /* @__PURE__ */ new Map();
|
|
39
|
+
}
|
|
40
|
+
function It(e, t) {
|
|
41
|
+
e._usedNames.add(t);
|
|
42
|
+
}
|
|
43
|
+
function En(e, t) {
|
|
44
|
+
let r = e._nameCounters.get(t) || 0, i = `${t}${r++}`;
|
|
45
|
+
for (; e._usedNames.has(i); ) i = `${t}${r++}`;
|
|
46
|
+
return e._nameCounters.set(t, r), e._usedNames.add(i), i;
|
|
47
|
+
}
|
|
48
|
+
function v(e, t) {
|
|
49
|
+
let r = e._helperNames.get(t);
|
|
50
|
+
if (r === void 0) {
|
|
51
|
+
r = t;
|
|
52
|
+
for (let i = 2; e._usedNames.has(r); i++) r = `${t}${i}`;
|
|
53
|
+
e._usedNames.add(r), e._helperNames.set(t, r);
|
|
54
|
+
}
|
|
55
|
+
return n.identifier(r);
|
|
56
|
+
}
|
|
57
|
+
function vt(e) {
|
|
58
|
+
return e._helperNames;
|
|
59
|
+
}
|
|
60
|
+
function Ot(e, t) {
|
|
61
|
+
return !(!e.includes("__") || !e.startsWith("on") || e.split("__").slice(1).filter((s) => s !== "").length === 0);
|
|
62
|
+
}
|
|
63
|
+
function _t(e) {
|
|
64
|
+
let t = e.includes("|") ? "|" : "__", r = e.split(t), i = r[0], s = r.slice(1).filter((o) => gn.has(o));
|
|
65
|
+
return { eventName: i, modifiers: s };
|
|
66
|
+
}
|
|
67
|
+
function Ft(e) {
|
|
68
|
+
return e.endsWith("Capture") && !e.endsWith("PointerCapture") ? e.slice(0, -7) : null;
|
|
69
|
+
}
|
|
70
|
+
function $t(e) {
|
|
71
|
+
let t = e.slice(2).toLowerCase();
|
|
72
|
+
return t === "doubleclick" ? "dblclick" : t;
|
|
73
|
+
}
|
|
74
|
+
function Ct(e) {
|
|
75
|
+
return e.startsWith("bind:");
|
|
76
|
+
}
|
|
77
|
+
function jt(e) {
|
|
78
|
+
return e.slice(5);
|
|
79
|
+
}
|
|
80
|
+
function ae(e) {
|
|
81
|
+
return /^[A-Z]/.test(e);
|
|
82
|
+
}
|
|
83
|
+
function we(e, t, r) {
|
|
84
|
+
if (typeof e?.buildCodeFrameError == "function")
|
|
85
|
+
return e.buildCodeFrameError(r);
|
|
86
|
+
let i = e?.node;
|
|
87
|
+
if (i && typeof t?.file?.buildCodeFrameError == "function")
|
|
88
|
+
return t.file.buildCodeFrameError(i, r);
|
|
89
|
+
let s = i?.loc?.start, o = t?.filename || t?.file?.opts?.filename || "<unknown>";
|
|
90
|
+
return new Error(
|
|
91
|
+
`[what-compiler] ${r} (${s ? `${o}:${s.line}:${s.column + 1}` : o})`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
function ke(e, t, { code: r }, i) {
|
|
95
|
+
let s = e.loc && e.loc.start, o = String(t?.file?.opts?.filename || "<unknown>").replace(/\\/g, "/"), l = String(t?.opts?.projectRoot || t?.file?.opts?.cwd || "").replace(/\\/g, "/").replace(/\/+$/, ""), a = l && o.startsWith(`${l}/`) ? o.slice(l.length + 1) : o, u = s ? ` at ${a}:${s.line}:${s.column + 1}` : "", c = we({ node: e }, t, `${r}${u}: ${i}`);
|
|
96
|
+
return s && (c.loc = { file: o, line: s.line, column: s.column }), c.code = r, c;
|
|
97
|
+
}
|
|
98
|
+
function J(e, t, r) {
|
|
99
|
+
return ke(e, t, { code: "ERR_UNSAFE_STATIC_MARKUP" }, r);
|
|
100
|
+
}
|
|
101
|
+
function G(e) {
|
|
102
|
+
return n.isJSXMemberExpression(e) ? `${G(e.object)}.${e.property.name}` : n.isJSXNamespacedName(e) ? `${e.namespace.name}:${e.name.name}` : e.name;
|
|
103
|
+
}
|
|
104
|
+
function Rt(e, t) {
|
|
105
|
+
let r = e.openingElement.name;
|
|
106
|
+
if (n.isJSXNamespacedName(r))
|
|
107
|
+
throw J(
|
|
108
|
+
e,
|
|
109
|
+
t,
|
|
110
|
+
`<${G(r)}> is a namespaced tag name, which markup does not have. Write <${r.name.name}> inside <${r.namespace.name}>.`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
function At(e, t, r, i, s) {
|
|
114
|
+
let o = i != null && i !== !1;
|
|
115
|
+
if (o && ln(t))
|
|
116
|
+
throw J(e, s, t.toLowerCase() === "srcdoc" ? "srcdoc is parsed by the browser as a whole document, so escaping cannot make it safe; it is never written." : `${t} replaces the element with its value parsed as markup, so escaping cannot make it safe; it is never written.`);
|
|
117
|
+
if (typeof i == "string" && un(t) && cn(i))
|
|
118
|
+
throw J(
|
|
119
|
+
e,
|
|
120
|
+
s,
|
|
121
|
+
`${t}=${JSON.stringify(i)} uses a javascript:, vbscript: or data: URL, which is never written.`
|
|
122
|
+
);
|
|
123
|
+
if (o && tn.has(r))
|
|
124
|
+
throw J(
|
|
125
|
+
e,
|
|
126
|
+
s,
|
|
127
|
+
`${r} takes { __html: trustedString }, never a string, so markup cannot reach the page by accident.`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function Mt(e, t, r, i) {
|
|
131
|
+
if (fn(t, r))
|
|
132
|
+
throw J(e, i, t === "script" ? 'the text of a <script> is written as it is, so it cannot contain "</" or "<!--", which can end the element. Write "<\\/" and "\\x3C!--" in a string, or pass the code as dangerouslySetInnerHTML={{ __html }}.' : 'the text of a <style> is written as it is, so it cannot contain "</", which can end the element. Write "<\\/" in a string instead.');
|
|
133
|
+
}
|
|
134
|
+
function re(e) {
|
|
135
|
+
if (!e || typeof e != "object") return null;
|
|
136
|
+
if (n.isJSXElement(e) || n.isJSXFragment(e)) return e;
|
|
137
|
+
if (n.isFunction(e)) return null;
|
|
138
|
+
for (let t of n.VISITOR_KEYS[e.type] || []) {
|
|
139
|
+
let r = e[t], i = Array.isArray(r) ? r.map(re).find(Boolean) : re(r);
|
|
140
|
+
if (i) return i;
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
function Nt(e, t, r, i) {
|
|
145
|
+
let s = re(t);
|
|
146
|
+
if (s)
|
|
147
|
+
throw ke(
|
|
148
|
+
s,
|
|
149
|
+
i,
|
|
150
|
+
{ code: "ERR_JSX_ISLAND_PROP" },
|
|
151
|
+
`JSX is not an island prop: "${e}" of <${G(r.openingElement.name)}> is serialized to JSON for the browser, and markup is not data. Pass it as a child of the island, or pass the data and build the markup inside the island.`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
function Dt(e) {
|
|
155
|
+
return e.value ? n.isStringLiteral(e.value) ? e.value : n.isJSXExpressionContainer(e.value) && !n.isJSXEmptyExpression(e.value.expression) ? e.value.expression : null : null;
|
|
156
|
+
}
|
|
157
|
+
function Lt(e) {
|
|
158
|
+
let t = e.filter((i) => !(n.isJSXText(i) && !Se(i.value)) && !(n.isJSXExpressionContainer(i) && n.isJSXEmptyExpression(i.expression)));
|
|
159
|
+
if (t.length !== 1) return null;
|
|
160
|
+
let r = t[0];
|
|
161
|
+
return n.isJSXExpressionContainer(r) && n.isFunction(r.expression) ? r.expression : null;
|
|
162
|
+
}
|
|
163
|
+
function le(e) {
|
|
164
|
+
let t = e.openingElement ? e.openingElement.name : e.name;
|
|
165
|
+
return n.isJSXMemberExpression(t) ? !0 : n.isJSXIdentifier(t) && ae(t.name);
|
|
166
|
+
}
|
|
167
|
+
function Ie(e, t) {
|
|
168
|
+
return !!(t.foreignImports && t.foreignImports.has(e));
|
|
169
|
+
}
|
|
170
|
+
function bn(e, t) {
|
|
171
|
+
return !!(t.whatImports && t.whatImports.has(e));
|
|
172
|
+
}
|
|
173
|
+
function yn(e, t) {
|
|
174
|
+
return e.children.some((r) => n.isJSXElement(r) && n.isJSXIdentifier(r.openingElement.name) && (r.openingElement.name.name === "Match" || t != null && Oe(t).get(r.openingElement.name.name) === "Match"));
|
|
175
|
+
}
|
|
176
|
+
var ve = /* @__PURE__ */ new Set(["For", "Show", "Switch", "Match"]);
|
|
177
|
+
function Oe(e) {
|
|
178
|
+
if (e._whatControlFlow) return e._whatControlFlow;
|
|
179
|
+
let t = /* @__PURE__ */ new Map();
|
|
180
|
+
for (let r of e.file?.ast?.program?.body ?? [])
|
|
181
|
+
if (!(!n.isImportDeclaration(r) || r.importKind === "type" || !P(r.source.value)))
|
|
182
|
+
for (let i of r.specifiers) {
|
|
183
|
+
if (!n.isImportSpecifier(i) || i.importKind === "type") continue;
|
|
184
|
+
let s = i.imported.name ?? i.imported.value;
|
|
185
|
+
ve.has(s) && t.set(i.local.name, s);
|
|
186
|
+
}
|
|
187
|
+
return e._whatControlFlow = t, t;
|
|
188
|
+
}
|
|
189
|
+
function ce(e, t) {
|
|
190
|
+
let r = e && e.openingElement ? e.openingElement.name : null;
|
|
191
|
+
if (!n.isJSXIdentifier(r)) return null;
|
|
192
|
+
let i = r.name, s = Oe(t).get(i);
|
|
193
|
+
return s !== void 0 ? s : ve.has(i) ? Ie(i, t) ? i === "Switch" && yn(e, t) ? "Switch" : null : i : null;
|
|
194
|
+
}
|
|
195
|
+
function Bt(e) {
|
|
196
|
+
let t = e.parentPath;
|
|
197
|
+
return !t || typeof t.isCallExpression != "function" || !t.isCallExpression() || t.node.arguments[0] !== e.node ? !1 : xn(t.node.callee, t.scope);
|
|
198
|
+
}
|
|
199
|
+
function xn(e, t) {
|
|
200
|
+
return n.isMemberExpression(e) && !e.computed && n.isIdentifier(e.property, { name: "hydrate" }) && n.isIdentifier(e.object) ? B(t.getBinding(e.object.name), n.isImportNamespaceSpecifier, null) : n.isIdentifier(e) ? B(t.getBinding(e.name), n.isImportSpecifier, "hydrate") : !1;
|
|
201
|
+
}
|
|
202
|
+
function B(e, t, r) {
|
|
203
|
+
if (!e || e.kind !== "module" || !e.path) return !1;
|
|
204
|
+
let i = e.path.node;
|
|
205
|
+
if (!t(i)) return !1;
|
|
206
|
+
if (r !== null) {
|
|
207
|
+
let o = i.imported;
|
|
208
|
+
if ((n.isIdentifier(o) ? o.name : n.isStringLiteral(o) ? o.value : null) !== r) return !1;
|
|
209
|
+
}
|
|
210
|
+
let s = e.path.parent;
|
|
211
|
+
return n.isImportDeclaration(s) && P(s.source.value);
|
|
212
|
+
}
|
|
213
|
+
function _e(e) {
|
|
214
|
+
return n.isJSXMemberExpression(e) ? n.memberExpression(_e(e.object), n.identifier(e.property.name)) : n.identifier(e.name);
|
|
215
|
+
}
|
|
216
|
+
function Tt(e, t, r, i) {
|
|
217
|
+
let s = [
|
|
218
|
+
n.objectProperty(n.identifier("component"), _e(e)),
|
|
219
|
+
n.objectProperty(n.identifier("name"), n.stringLiteral(G(e))),
|
|
220
|
+
n.objectProperty(n.identifier("mode"), n.stringLiteral(t))
|
|
221
|
+
];
|
|
222
|
+
return r && s.push(n.objectProperty(n.identifier("mediaQuery"), r)), i && s.push(n.objectProperty(n.identifier("props"), i)), n.objectExpression(s);
|
|
223
|
+
}
|
|
224
|
+
function Xt(e, t) {
|
|
225
|
+
let r = e.node.params;
|
|
226
|
+
if (r.length === 0 && e.isClassMethod({ kind: "method" }) && !e.node.computed && n.isIdentifier(e.node.key, { name: "render" })) {
|
|
227
|
+
kn(e, t);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (r.length === 0 || r.length > 2 || r.length === 2 && !n.isIdentifier(r[1]) || T(e, t)) return;
|
|
231
|
+
let i = r[0], s = A(e.node), o = s ? je : ue(e, t);
|
|
232
|
+
if (o !== Re && o !== K && void 0, o === null) return;
|
|
233
|
+
o !== K && void 0;
|
|
234
|
+
let l = o !== K;
|
|
235
|
+
if (n.isObjectPattern(i)) {
|
|
236
|
+
let a = Ne(e, i, e.scope, t, l);
|
|
237
|
+
if (a === null || !pt(e, a.others)) return;
|
|
238
|
+
let u = e.scope.generateUidIdentifier("props");
|
|
239
|
+
i.typeAnnotation && (u.typeAnnotation = i.typeAnnotation), Ge(e, a, u, t), r[0] = u, s && (e.node._whatPropsParam = u.name), e.node._whatPropsPattern = !0;
|
|
240
|
+
let c = Qe(e, a, u, t);
|
|
241
|
+
c.length > 0 && (n.isBlockStatement(e.node.body) || (e.node.body = n.blockStatement([n.returnStatement(e.node.body)])), e.node.body.body.unshift(n.variableDeclaration("const", c)), e.node._whatMovedProps = n.objectPattern(a.others));
|
|
242
|
+
} else if (n.isIdentifier(i)) {
|
|
243
|
+
let a = e.scope.getBinding(i.name);
|
|
244
|
+
if (!a || a.constantViolations.length > 0 || (s && (e.node._whatPropsParam = i.name), s && In(e, a) && (e.scope.crawl(), a = e.scope.getBinding(i.name), !a)) || !Fe(e, a, i, t, l)) return;
|
|
245
|
+
} else
|
|
246
|
+
return;
|
|
247
|
+
e.scope.crawl(), wn(e, t, l);
|
|
248
|
+
}
|
|
249
|
+
function Fe(e, t, r, i, s) {
|
|
250
|
+
let o = [], l = [], a = [];
|
|
251
|
+
for (let u of t.referencePaths) {
|
|
252
|
+
let c = u.parentPath;
|
|
253
|
+
if (!i.ssr && s && c.isSpreadElement() && c.parentPath.isObjectExpression())
|
|
254
|
+
!a.includes(c.parentPath) && Sn(c.parentPath, e) && a.push(c.parentPath);
|
|
255
|
+
else if (c.isVariableDeclarator() && u.key === "init" && n.isObjectPattern(c.node.id)) {
|
|
256
|
+
let f = u.getFunctionParent();
|
|
257
|
+
if (f !== e && !A(f.node)) continue;
|
|
258
|
+
if (c.parent.kind === "var") {
|
|
259
|
+
s && (c.node.id, `${[..._(c.node.id)].join(", ")}`, void 0);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
let p = Ne(e, c.node.id, c.scope, i, s);
|
|
263
|
+
p !== null && o.push([c, p]);
|
|
264
|
+
} else !i.ssr && c.isMemberExpression() && u.key === "object" && !n.isNumericLiteral(c.node.property) && y(c.node.property, c.node.computed) !== null && Ee(c, e, i) && l.push(c);
|
|
265
|
+
}
|
|
266
|
+
if (o.length === 0 && l.length === 0 && a.length === 0) return !1;
|
|
267
|
+
for (let u of a) {
|
|
268
|
+
let c = [];
|
|
269
|
+
for (let p of u.node.properties)
|
|
270
|
+
n.isSpreadElement(p) ? c.push(p.argument) : c.length > 0 && n.isObjectExpression(c[c.length - 1]) && !c[c.length - 1]._whatSource ? c[c.length - 1].properties.push(p) : c.push(n.objectExpression([p]));
|
|
271
|
+
for (let p of c) (!n.isObjectExpression(p) || p.properties.some((d) => n.isSpreadElement(d))) && (p._whatSource = !0);
|
|
272
|
+
let f = u.parentPath;
|
|
273
|
+
u.replaceWith(n.callExpression(v(i, "_$merge"), c)), f.isVariableDeclarator() && n.isIdentifier(f.node.id) && (f.node._whatPropsRest = !0, (e.node._whatPropsRests ||= []).push(f.node.id.name));
|
|
274
|
+
}
|
|
275
|
+
for (let [u, c] of o) {
|
|
276
|
+
Ge(e, c, r, i);
|
|
277
|
+
let f = Qe(e, c, r, i);
|
|
278
|
+
f.length > 0 ? u.replaceWithMultiple(f) : u.remove();
|
|
279
|
+
}
|
|
280
|
+
for (let u of l) u.replaceWith(Z(r, y(u.node.property, u.node.computed), i));
|
|
281
|
+
return !0;
|
|
282
|
+
}
|
|
283
|
+
function Sn(e, t) {
|
|
284
|
+
if (!e.node.properties.every((s) => n.isSpreadElement(s) || n.isObjectProperty(s) && !(y(s.key, s.computed) === "__proto__" && !s.computed))) return !1;
|
|
285
|
+
let r = e.parentPath;
|
|
286
|
+
if (r.isJSXSpreadAttribute()) return !0;
|
|
287
|
+
if (!r.isVariableDeclarator() || e.key !== "init" || !n.isIdentifier(r.node.id) || r.parent.kind !== "const" || r.getFunctionParent() !== t) return !1;
|
|
288
|
+
let i = r.scope.getBinding(r.node.id.name);
|
|
289
|
+
return !i || i.constantViolations.length > 0 || i.referencePaths.length === 0 ? !1 : i.referencePaths.every((s) => {
|
|
290
|
+
let o = s.parentPath;
|
|
291
|
+
if (o.isJSXSpreadAttribute()) return !0;
|
|
292
|
+
if (o.isSpreadElement()) return o.parentPath.isObjectExpression();
|
|
293
|
+
if (!(o.isMemberExpression() && s.key === "object" && y(o.node.property, o.node.computed) !== null)) return !1;
|
|
294
|
+
let l = o.parentPath;
|
|
295
|
+
return !(l.isAssignmentExpression() && o.key === "left") && !l.isUpdateExpression() && !l.isUnaryExpression({ operator: "delete" }) && !(l.isCallExpression() && o.key === "callee");
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function wn(e, t, r) {
|
|
299
|
+
let i = /* @__PURE__ */ new Set();
|
|
300
|
+
for (let s = 0; s < 8; s++) {
|
|
301
|
+
let o = [];
|
|
302
|
+
if (e.traverse({
|
|
303
|
+
Function(a) {
|
|
304
|
+
a.skip();
|
|
305
|
+
},
|
|
306
|
+
VariableDeclarator(a) {
|
|
307
|
+
a.node._whatPropsRest === !0 && !i.has(a.node) && o.push(a);
|
|
308
|
+
}
|
|
309
|
+
}), o.length === 0) return;
|
|
310
|
+
let l = !1;
|
|
311
|
+
for (let a of o) {
|
|
312
|
+
i.add(a.node);
|
|
313
|
+
let u = a.scope.getBinding(a.node.id.name);
|
|
314
|
+
!u || u.constantViolations.length > 0 || Fe(e, u, n.identifier(a.node.id.name), t, r) && (l = !0);
|
|
315
|
+
}
|
|
316
|
+
if (!l) return;
|
|
317
|
+
e.scope.crawl();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function kn(e, t) {
|
|
321
|
+
if (!(t.frameworkFile || !A(e.node))) {
|
|
322
|
+
for (let r of e.get("body.body"))
|
|
323
|
+
if (r.isVariableDeclaration({ kind: "const" }))
|
|
324
|
+
for (let i of r.get("declarations")) {
|
|
325
|
+
let { id: s, init: o } = i.node;
|
|
326
|
+
if (!n.isObjectPattern(s) || !n.isMemberExpression(o) || o.computed || !n.isThisExpression(o.object) || !n.isIdentifier(o.property, { name: "props" }) || s.properties.some((a) => n.isRestElement(a))) continue;
|
|
327
|
+
let l = [];
|
|
328
|
+
for (let a of s.properties) {
|
|
329
|
+
let u = n.isObjectProperty(a) ? y(a.key, a.computed) : null, c = u !== null && n.isIdentifier(a.value) ? i.scope.getBinding(a.value.name) : null;
|
|
330
|
+
if (!(c && c.constantViolations.length === 0 && c.referencePaths.every((p) => {
|
|
331
|
+
if (p.isJSXIdentifier()) return !1;
|
|
332
|
+
for (let d = p.getFunctionParent(); d !== e; d = d.getFunctionParent()) if (!d || !d.isArrowFunctionExpression()) return !1;
|
|
333
|
+
return !0;
|
|
334
|
+
}))) {
|
|
335
|
+
l.push(a);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
for (let p of c.referencePaths) {
|
|
339
|
+
p.parentPath.isObjectProperty({ shorthand: !0 }) && p.key === "value" && (p.parent.shorthand = !1);
|
|
340
|
+
let d = n.memberExpression(n.memberExpression(n.thisExpression(), n.identifier("props")), R(u), !n.isIdentifier(R(u))), m = p.key === "callee" && (p.parentPath.isCallExpression() || p.parentPath.isOptionalCallExpression() || p.parentPath.isNewExpression()) || p.key === "tag" && p.parentPath.isTaggedTemplateExpression();
|
|
341
|
+
p.replaceWith(m ? n.sequenceExpression([n.numericLiteral(0), d]) : d);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
l.length !== s.properties.length && (l.length === 0 ? i.remove() : s.properties = l);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function In(e, t) {
|
|
349
|
+
let r = !1;
|
|
350
|
+
for (let i = 0; i < 8; i++) {
|
|
351
|
+
let s = [];
|
|
352
|
+
for (let l of t.referencePaths) {
|
|
353
|
+
let a = vn(l, e);
|
|
354
|
+
a !== null && !s.some((u) => u.binding === a.binding) && s.push(a);
|
|
355
|
+
}
|
|
356
|
+
if (s.length === 0) break;
|
|
357
|
+
for (let { decl: l, binding: a, init: u } of s) {
|
|
358
|
+
for (let c of a.referencePaths)
|
|
359
|
+
c.parentPath.isObjectProperty({ shorthand: !0 }) && c.key === "value" && (c.parent.shorthand = !1), c.replaceWith(n.cloneNode(u, !0));
|
|
360
|
+
l.remove();
|
|
361
|
+
}
|
|
362
|
+
r = !0, e.scope.crawl();
|
|
363
|
+
let o = e.scope.getBinding(
|
|
364
|
+
/** @type {any} */
|
|
365
|
+
t.identifier.name
|
|
366
|
+
);
|
|
367
|
+
if (!o) break;
|
|
368
|
+
t = o;
|
|
369
|
+
}
|
|
370
|
+
return r;
|
|
371
|
+
}
|
|
372
|
+
function vn(e, t) {
|
|
373
|
+
let r = e;
|
|
374
|
+
for (; ; ) {
|
|
375
|
+
let l = r.parentPath;
|
|
376
|
+
if (!(l.isMemberExpression() || l.isOptionalMemberExpression()) || r.key !== "object") break;
|
|
377
|
+
if (l.node.computed && y(l.node.property, !0) === null) return null;
|
|
378
|
+
r = l;
|
|
379
|
+
}
|
|
380
|
+
if (r === e) return null;
|
|
381
|
+
let i = r.parentPath;
|
|
382
|
+
if (!i.isVariableDeclarator() || r.key !== "init" || !n.isIdentifier(i.node.id) || i.parent.kind !== "const" || i.getFunctionParent() !== t) return null;
|
|
383
|
+
let s = i.scope.getBinding(i.node.id.name);
|
|
384
|
+
return !s || s.constantViolations.length > 0 || s.referencePaths.length === 0 || s.referencePaths.some((l) => l.isJSXIdentifier()) || (n.isMemberExpression(r.node) || n.isOptionalMemberExpression(r.node) ? $e(r.node) : null) === "children" || s.referencePaths.some((l) => (l.parentPath.isMemberExpression() || l.parentPath.isOptionalMemberExpression()) && l.key === "object" && l.parent.computed && y(l.parent.property, !0) === null) ? null : { decl: i, binding: s, init: r.node };
|
|
385
|
+
}
|
|
386
|
+
function $e(e) {
|
|
387
|
+
for (; n.isMemberExpression(e.object) || n.isOptionalMemberExpression(e.object); ) e = e.object;
|
|
388
|
+
return y(e.property, e.computed);
|
|
389
|
+
}
|
|
390
|
+
function Jt(e, t) {
|
|
391
|
+
let r = e.node._whatPropsParam;
|
|
392
|
+
if (t.ssr || r === void 0) return;
|
|
393
|
+
let i = e.scope.getBinding(r);
|
|
394
|
+
if (!(!i || i.kind !== "param" || i.constantViolations.length > 0))
|
|
395
|
+
for (let s of i.referencePaths) {
|
|
396
|
+
let o = s.parentPath;
|
|
397
|
+
if (!o.isMemberExpression() || s.key !== "object") continue;
|
|
398
|
+
let l = o.parentPath;
|
|
399
|
+
if (!l.isMemberExpression() || o.key !== "object") continue;
|
|
400
|
+
let a = y(o.node.property, o.node.computed);
|
|
401
|
+
a === null || a === "children" || y(l.node.property, l.node.computed) === null || !Ce(l) || !On(l, e) || (l.node._whatPropField = !0, t.marksPropFields = !0);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function Ce(e) {
|
|
405
|
+
let t = e.parent, r = e.key;
|
|
406
|
+
return (n.isCallExpression(t) || n.isOptionalCallExpression(t) || n.isNewExpression(t)) && r === "callee" || n.isTaggedTemplateExpression(t) && r === "tag" || (n.isAssignmentExpression(t) || n.isForInStatement(t) || n.isForOfStatement(t)) && r === "left" || n.isUpdateExpression(t) || n.isUnaryExpression(t, { operator: "delete" }) ? !1 : !(n.isArrayPattern(t) || n.isRestElement(t) || n.isAssignmentPattern(t) && r === "left" || n.isObjectProperty(t) && n.isObjectPattern(e.parentPath.parent));
|
|
407
|
+
}
|
|
408
|
+
function On(e, t) {
|
|
409
|
+
let r = !1;
|
|
410
|
+
for (let i = e.parentPath; i !== null && i !== t; i = i.parentPath)
|
|
411
|
+
if (i.isFunction()) r = !0;
|
|
412
|
+
else if (i.isJSXExpressionContainer()) {
|
|
413
|
+
let s = i.parentPath;
|
|
414
|
+
return r || !s.isJSXAttribute() || !n.isJSXIdentifier(s.node.name) || s.node.name.name === "key" || s.node.name.name === "ref" ? !1 : le(s.parentPath.parent);
|
|
415
|
+
} else if (i.isJSXElement() || i.isJSXFragment() || i.isJSXSpreadAttribute() || i.isJSXSpreadChild()) return !1;
|
|
416
|
+
return !0;
|
|
417
|
+
}
|
|
418
|
+
function Vt(e, t) {
|
|
419
|
+
for (let i of t._readOnceChecks ?? [])
|
|
420
|
+
if (!i.nodes.every((s) => s._whatPropField === !0)) {
|
|
421
|
+
for (let s of i.nodes) s._whatReadOnce = void 0;
|
|
422
|
+
i.warn();
|
|
423
|
+
}
|
|
424
|
+
if (!t.marksPropFields) return;
|
|
425
|
+
let r = [];
|
|
426
|
+
e.traverse({
|
|
427
|
+
MemberExpression(i) {
|
|
428
|
+
let s = i.node;
|
|
429
|
+
if (s._whatPropField !== !0) return;
|
|
430
|
+
let o = (
|
|
431
|
+
/** @type {any} */
|
|
432
|
+
s.object
|
|
433
|
+
), l = [
|
|
434
|
+
n.identifier(o.object.name),
|
|
435
|
+
n.stringLiteral(
|
|
436
|
+
/** @type {string} */
|
|
437
|
+
y(o.property, o.computed)
|
|
438
|
+
),
|
|
439
|
+
n.stringLiteral(
|
|
440
|
+
/** @type {string} */
|
|
441
|
+
y(s.property, s.computed)
|
|
442
|
+
)
|
|
443
|
+
], a = s._whatReadOnce;
|
|
444
|
+
a && (a.id === null && (a.id = e.scope.generateUidIdentifier("readOnce"), r.push(n.variableDeclarator(a.id, it(a.record)))), l.push(n.identifier(a.id.name))), i.replaceWith(n.callExpression(v(t, "_$propField"), l));
|
|
445
|
+
}
|
|
446
|
+
}), r.length > 0 && e.unshiftContainer("body", n.variableDeclaration("const", r));
|
|
447
|
+
}
|
|
448
|
+
var je = 1, Re = 2, K = 3, _n = 4;
|
|
449
|
+
function ue(e, t) {
|
|
450
|
+
return t.frameworkFile ? null : Ae(e) ? ie(e) || Fn(e) || /^use[A-Z]/.test($(e)) ? Re : null : rt(e, t) ? _n : ie(e) && Me(e) ? K : null;
|
|
451
|
+
}
|
|
452
|
+
function Fn(e) {
|
|
453
|
+
let t = e.parentPath;
|
|
454
|
+
return t.isArrowFunctionExpression() && e.key === "body" ? !0 : t.isReturnStatement() && t.getFunctionParent() !== null;
|
|
455
|
+
}
|
|
456
|
+
function ie(e) {
|
|
457
|
+
if (/^[A-Z]/.test($(e))) return !0;
|
|
458
|
+
let t = e.parentPath;
|
|
459
|
+
for (; t && t.isCallExpression(); ) t = t.parentPath;
|
|
460
|
+
return t ? t.isExportDefaultDeclaration() ? !0 : t.isAssignmentExpression() && n.isMemberExpression(t.node.left) && !t.node.left.computed ? /^[A-Z]/.test(t.node.left.property.name || "") : t.isObjectProperty() && !t.node.computed && n.isIdentifier(t.node.key) && /^[A-Z]/.test(t.node.key.name) : !1;
|
|
461
|
+
}
|
|
462
|
+
function Ae(e) {
|
|
463
|
+
let t = !1;
|
|
464
|
+
return e.traverse({
|
|
465
|
+
CallExpression(r) {
|
|
466
|
+
if (t) return r.stop();
|
|
467
|
+
let i = r.node.callee;
|
|
468
|
+
n.isIdentifier(i) ? t = B(r.scope.getBinding(i.name), n.isImportSpecifier, "h") : n.isMemberExpression(i) && !i.computed && n.isIdentifier(i.property, { name: "h" }) && n.isIdentifier(i.object) && (t = B(r.scope.getBinding(i.object.name), n.isImportNamespaceSpecifier, null)), t && r.stop();
|
|
469
|
+
}
|
|
470
|
+
}), t;
|
|
471
|
+
}
|
|
472
|
+
function Me(e) {
|
|
473
|
+
let t = e.node.params[0], r = (o) => {
|
|
474
|
+
for (; n.isTSAsExpression(o) || n.isTSSatisfiesExpression(o) || n.isTSNonNullExpression(o) || n.isParenthesizedExpression(o); ) o = o.expression;
|
|
475
|
+
if (n.isConditionalExpression(o)) return r(o.consequent) || r(o.alternate);
|
|
476
|
+
if (n.isLogicalExpression(o)) return r(o.left) || r(o.right);
|
|
477
|
+
if (n.isArrayExpression(o)) return o.elements.some((u) => u !== null && r(u));
|
|
478
|
+
if (n.isMemberExpression(o) || n.isOptionalMemberExpression(o)) {
|
|
479
|
+
let u = o;
|
|
480
|
+
for (; n.isMemberExpression(u) || n.isOptionalMemberExpression(u); ) u = u.object;
|
|
481
|
+
return n.isIdentifier(t) && n.isIdentifier(u, { name: t.name }) && e.scope.getBinding(t.name)?.kind === "param";
|
|
482
|
+
}
|
|
483
|
+
if (!n.isIdentifier(o)) return !1;
|
|
484
|
+
let l = e.scope.getBinding(o.name);
|
|
485
|
+
if (!l || l.scope !== e.scope) return !1;
|
|
486
|
+
if (l.kind === "param") return n.isObjectPattern(t) && l.path.parentPath?.node === e.node;
|
|
487
|
+
let a = l.path;
|
|
488
|
+
return a.isVariableDeclarator() && n.isObjectPattern(a.node.id) && n.isIdentifier(t) && n.isIdentifier(a.node.init, { name: t.name });
|
|
489
|
+
}, i = e.node.body;
|
|
490
|
+
if (!n.isBlockStatement(i)) return r(i);
|
|
491
|
+
let s = !1;
|
|
492
|
+
return e.traverse({
|
|
493
|
+
Function(o) {
|
|
494
|
+
o.skip();
|
|
495
|
+
},
|
|
496
|
+
ReturnStatement(o) {
|
|
497
|
+
!s && o.node.argument && r(o.node.argument) && (s = !0);
|
|
498
|
+
}
|
|
499
|
+
}), s;
|
|
500
|
+
}
|
|
501
|
+
function A(e) {
|
|
502
|
+
let t = !1;
|
|
503
|
+
return n.traverseFast(e.body, (r) => {
|
|
504
|
+
(r.type === "JSXElement" || r.type === "JSXFragment") && (t = !0);
|
|
505
|
+
}), t;
|
|
506
|
+
}
|
|
507
|
+
function T(e, t) {
|
|
508
|
+
let r = e.parentPath;
|
|
509
|
+
return r.isCallExpression() && e.listKey === "arguments" ? n.isMemberExpression(r.node.callee) || n.isOptionalMemberExpression(r.node.callee) : r.isJSXExpressionContainer() ? r.parentPath.isJSXAttribute() || r.parentPath.isJSXElement() && Y(r.parentPath.node, "For", t) : !1;
|
|
510
|
+
}
|
|
511
|
+
function Ne(e, t, r, i, s) {
|
|
512
|
+
let o = /* @__PURE__ */ new Map();
|
|
513
|
+
for (let p of t.properties) {
|
|
514
|
+
let d = n.isObjectProperty(p) ? y(p.key, p.computed) : null;
|
|
515
|
+
d !== null && o.set(d, (o.get(d) || 0) + 1);
|
|
516
|
+
}
|
|
517
|
+
let l = [], a = [], u = [];
|
|
518
|
+
for (let p of t.properties) {
|
|
519
|
+
let d = n.isObjectProperty(p) ? Ye(e, p, r) : null, m = d === null && s && n.isObjectProperty(p) ? st(e, p, r) : null;
|
|
520
|
+
if (m !== null && o.get(m[0].key) === 1 && m.every((g) => g.binding.referencePaths.every((E) => !E.isJSXIdentifier()))) {
|
|
521
|
+
a.push(...m);
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
d === null || o.get(d.key) !== 1 ? (u.push(p), s && n.isObjectProperty(p) && $n(e, i, p, o)) : d.binding.referencePaths.every((g) => Ee(g, e, i)) ? l.push(d) : s && d.binding.referencePaths.every((g) => !g.isJSXIdentifier()) ? a.push(d) : u.push(p);
|
|
525
|
+
}
|
|
526
|
+
let c = u[u.length - 1], f = n.isRestElement(c) ? c : null;
|
|
527
|
+
return l.length === 0 && a.length === 0 && f === null ? null : f !== null && (!n.isIdentifier(f.argument) || u.some((p) => n.isObjectProperty(p) && y(p.key, p.computed) === null)) ? (s && n.isIdentifier(f.argument) && (`${f.argument.name}`, `${f.argument.name}`, void 0), null) : { placed: l, live: a, others: u, rest: f };
|
|
528
|
+
}
|
|
529
|
+
function $n(e, t, r, i) {
|
|
530
|
+
let s = y(r.key, r.computed), o = n.isAssignmentPattern(r.value) ? r.value.left : r.value, l = n.isIdentifier(o) ? o.name : s ?? "(pattern)";
|
|
531
|
+
if (n.isIdentifier(o)) {
|
|
532
|
+
let a = e.scope.getBinding(o.name);
|
|
533
|
+
if (!a || a.referencePaths.length === 0 || a.referencePaths.some((u) => u.isJSXIdentifier())) return;
|
|
534
|
+
if (a.constantViolations.length > 0)
|
|
535
|
+
return `${s ?? l}`, void 0;
|
|
536
|
+
}
|
|
537
|
+
if (s === null) return void 0;
|
|
538
|
+
if (i.get(s) !== 1) return `${s}`, void 0;
|
|
539
|
+
if (n.isAssignmentPattern(r.value))
|
|
540
|
+
return `${s}`, void 0;
|
|
541
|
+
if (n.isObjectPattern(o) || n.isArrayPattern(o))
|
|
542
|
+
return `${s}`, void 0;
|
|
543
|
+
}
|
|
544
|
+
var q = /* @__PURE__ */ new Set();
|
|
545
|
+
function De(e) {
|
|
546
|
+
let t = e.node.params[0];
|
|
547
|
+
if (n.isIdentifier(t))
|
|
548
|
+
return (i) => (n.isMemberExpression(i) || n.isOptionalMemberExpression(i)) && n.isIdentifier(i.object, { name: t.name }) && !i.computed && n.isIdentifier(i.property) && e.scope.getBinding(t.name)?.kind === "param" ? `props.${i.property.name}` : null;
|
|
549
|
+
if (!n.isObjectPattern(t)) return null;
|
|
550
|
+
let r = _(t);
|
|
551
|
+
return (i) => n.isIdentifier(i) && r.has(i.name) && e.scope.getBinding(i.name)?.kind === "param" ? i.name : null;
|
|
552
|
+
}
|
|
553
|
+
function C(e, t) {
|
|
554
|
+
let r = null, i = (s) => {
|
|
555
|
+
if (!(r !== null || !s || typeof s != "object")) {
|
|
556
|
+
if (Array.isArray(s)) {
|
|
557
|
+
s.forEach(i);
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
if (!(typeof s.type != "string" || n.isFunction(s)) && (r = t(s), r === null))
|
|
561
|
+
for (let o of n.VISITOR_KEYS[s.type] || []) i(s[o]);
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
return i(e), r;
|
|
565
|
+
}
|
|
566
|
+
function Wt(e, t) {
|
|
567
|
+
if (t.frameworkFile || e.node.async || e.node.generator || !X(e) || T(e, t)) return;
|
|
568
|
+
let r = fe(e, t);
|
|
569
|
+
if (r === null) return;
|
|
570
|
+
let i = r === pe, s = Xe(e), o = e.node.body;
|
|
571
|
+
if (!n.isBlockStatement(o)) {
|
|
572
|
+
let a = U(o);
|
|
573
|
+
(i ? L(a, s) : W(a) && Xn(a, s)) && ((i ? a : n.isConditionalExpression(a) ? a.test : a.left)._whatLive = !0, e.node.body = N(o), e.scope.crawl());
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
!t.ssr && t.opts?.production;
|
|
577
|
+
let l = o.body.findIndex((a) => F(a) && I(a).some((u) => L(u, s)));
|
|
578
|
+
if (l !== -1) {
|
|
579
|
+
for (let a of o.body.slice(l)) for (let u of I(a)) L(u, s) && (u._whatLive = !0);
|
|
580
|
+
Cn(e, t, l, i);
|
|
581
|
+
}
|
|
582
|
+
i && jn(e, s);
|
|
583
|
+
}
|
|
584
|
+
function Cn(e, t, r, i) {
|
|
585
|
+
let s = e.node.body, o = s.body.slice(0, r), l = s.body.slice(r), a = l.filter((p) => n.isFunctionDeclaration(p)), u = l.filter((p) => !n.isFunctionDeclaration(p));
|
|
586
|
+
if (!Wn(e, u)) return;
|
|
587
|
+
let c = t.ssr ? (p) => n.callExpression(n.arrowFunctionExpression([], n.blockStatement(p)), []) : (p) => n.callExpression(v(t, "_$untrack"), [n.arrowFunctionExpression([], n.blockStatement(p))]), f = M(u, c, t);
|
|
588
|
+
f !== null && (s.body = [...o, ...a, n.returnStatement(i && !n.isJSXFragment(f) && f._whatSwitch !== !0 || W(f) ? N(f) : f)], e.scope.crawl());
|
|
589
|
+
}
|
|
590
|
+
function jn(e, t) {
|
|
591
|
+
let r = !1;
|
|
592
|
+
e.traverse({
|
|
593
|
+
Function(i) {
|
|
594
|
+
i.skip();
|
|
595
|
+
},
|
|
596
|
+
ReturnStatement(i) {
|
|
597
|
+
let s = i.node.argument;
|
|
598
|
+
!s || n.isJSXFragment(s) || !L(s, t) || (s._whatLive = !0, i.node.argument = N(s), r = !0);
|
|
599
|
+
}
|
|
600
|
+
}), r && e.scope.crawl();
|
|
601
|
+
}
|
|
602
|
+
var pe = "text";
|
|
603
|
+
function fe(e, t) {
|
|
604
|
+
let r = e.node;
|
|
605
|
+
return r._whatOutput === void 0 && (r._whatOutput = A(r) ? je : Rn(e, t) ? pe : null), r._whatOutput;
|
|
606
|
+
}
|
|
607
|
+
function Rn(e, t) {
|
|
608
|
+
let r = e.node.params;
|
|
609
|
+
if (t.frameworkFile || r.length === 0 || r.length > 2 || !(n.isObjectPattern(r[0]) || n.isIdentifier(r[0])) || Ae(e) || Me(e) || me(e).some((l) => he(e, l))) return !1;
|
|
610
|
+
let i = $(e), s = e.scope.parent?.getBinding(i);
|
|
611
|
+
if (!s || s.constantViolations.length > 0 || s.path.node !== e.node && !(s.path.isVariableDeclarator() && s.path.node.init === e.node)) return !1;
|
|
612
|
+
let o = !1;
|
|
613
|
+
for (let l of s.referencePaths)
|
|
614
|
+
if (l.isJSXIdentifier() && (l.parentPath.isJSXOpeningElement() || l.parentPath.isJSXClosingElement())) o = !0;
|
|
615
|
+
else if (!(l.isExportNamedDeclaration() || l.isExportDefaultDeclaration() || l.parentPath.isExportSpecifier() || l.parentPath.isExportDefaultDeclaration())) return !1;
|
|
616
|
+
return o;
|
|
617
|
+
}
|
|
618
|
+
function Pt(e, t) {
|
|
619
|
+
if (t.frameworkFile || e.node.async || e.node.generator || !X(e) || T(e, t)) return;
|
|
620
|
+
let r = fe(e, t), i = e.node.body;
|
|
621
|
+
if (r === null || !n.isBlockStatement(i)) return;
|
|
622
|
+
let s = Q(e), o = /* @__PURE__ */ new Map(), l = (d) => n.isIdentifier(d) && o.has(d.name) && e.scope.getBinding(d.name)?.scope === e.scope;
|
|
623
|
+
for (let d of e.get("body.body"))
|
|
624
|
+
if (d.isVariableDeclaration({ kind: "const" }))
|
|
625
|
+
for (let m of d.get("declarations")) {
|
|
626
|
+
let { id: g, init: E } = m.node;
|
|
627
|
+
if (!E || n.isFunction(E)) continue;
|
|
628
|
+
let b = te(e, E) && !te(e, E, !0);
|
|
629
|
+
if (!b && (ee(e, E) || te(e, E))) continue;
|
|
630
|
+
let h = n.isIdentifier(g) ? [{ name: g.name, key: null }] : An(g);
|
|
631
|
+
if (h === null || h.some(({ name: S }) => e.scope.getBinding(S)?.referencePaths.some((w) => w.isJSXIdentifier()))) continue;
|
|
632
|
+
let x = /* @__PURE__ */ new Set();
|
|
633
|
+
if (C(E, (S) => (l(S) && x.add(S.name), null)), b || x.size > 0 || L(E, s)) for (let { name: S } of h) o.set(S, { decl: m, reads: x, bound: h });
|
|
634
|
+
}
|
|
635
|
+
if (o.size === 0) return;
|
|
636
|
+
let a = /* @__PURE__ */ new Set(), u = (d) => {
|
|
637
|
+
if (a.has(d)) return;
|
|
638
|
+
let m = (
|
|
639
|
+
/** @type {any} */
|
|
640
|
+
o.get(d)
|
|
641
|
+
);
|
|
642
|
+
for (let { name: g } of m.bound) a.add(g);
|
|
643
|
+
for (let g of m.reads) u(g);
|
|
644
|
+
}, c = [...Je(i), ...r === pe ? Le(i) : []];
|
|
645
|
+
for (let d of c) C(d, (m) => (l(m) && u(m.name), null));
|
|
646
|
+
if (a.size === 0) return;
|
|
647
|
+
let f = e.node._whatLiveMemos ??= { names: /* @__PURE__ */ new Set(), called: !t.ssr };
|
|
648
|
+
if (t.ssr) {
|
|
649
|
+
for (let d of a) f.names.add(d);
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
let p = /* @__PURE__ */ new Set();
|
|
653
|
+
for (let d of a) {
|
|
654
|
+
let { decl: m, bound: g } = (
|
|
655
|
+
/** @type {any} */
|
|
656
|
+
o.get(d)
|
|
657
|
+
);
|
|
658
|
+
if (p.has(m)) continue;
|
|
659
|
+
p.add(m);
|
|
660
|
+
let E = g[0].key === null ? n.identifier(d) : e.scope.generateUidIdentifier(g[0].name);
|
|
661
|
+
f.names.add(E.name);
|
|
662
|
+
for (let { name: b, key: h } of g) {
|
|
663
|
+
let x = e.scope.getBinding(b);
|
|
664
|
+
for (let S of x ? x.referencePaths : []) {
|
|
665
|
+
S.parentPath.isObjectProperty({ shorthand: !0 }) && S.key === "value" && (S.parent.shorthand = !1);
|
|
666
|
+
let w = n.callExpression(n.identifier(E.name), []);
|
|
667
|
+
S.replaceWith(h === null ? w : n.memberExpression(w, R(h), !n.isIdentifier(R(h))));
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
g[0].key !== null && m.get("id").replaceWith(E), m.get("init").replaceWith(n.callExpression(v(t, "_$lazyMemo"), [n.arrowFunctionExpression([], m.node.init)]));
|
|
671
|
+
}
|
|
672
|
+
e.scope.crawl();
|
|
673
|
+
}
|
|
674
|
+
function An(e) {
|
|
675
|
+
if (!n.isObjectPattern(e) || e.properties.length === 0) return null;
|
|
676
|
+
let t = [];
|
|
677
|
+
for (let r of e.properties) {
|
|
678
|
+
let i = n.isObjectProperty(r) ? y(r.key, r.computed) : null;
|
|
679
|
+
if (i === null || !n.isIdentifier(r.value)) return null;
|
|
680
|
+
t.push({ name: r.value.name, key: i });
|
|
681
|
+
}
|
|
682
|
+
return t;
|
|
683
|
+
}
|
|
684
|
+
function Ut(e, t) {
|
|
685
|
+
if (t.frameworkFile || e.node.async || e.node.generator || !X(e) || T(e, t)) return;
|
|
686
|
+
let r = e.node.body;
|
|
687
|
+
if (fe(e, t) === null || !n.isBlockStatement(r)) return;
|
|
688
|
+
let i = Q(e), s = e.get("body.body"), o = [];
|
|
689
|
+
for (let c = 0; c < s.length; c++) {
|
|
690
|
+
let f = s[c];
|
|
691
|
+
if (!f.isVariableDeclaration({ kind: "let" }) || f.node.declarations.length !== 1 || !n.isIdentifier(f.node.declarations[0].id)) continue;
|
|
692
|
+
let p = f.node.declarations[0].id.name, d = e.scope.getBinding(p);
|
|
693
|
+
if (!d || d.scope !== e.scope || d.constantViolations.length === 0) continue;
|
|
694
|
+
let { writers: m, elsewhere: g } = Mn(e, s, c, d);
|
|
695
|
+
if (([f, ...m.map((w) => s[w])].map((w) => C(w.node, i)).find((w) => w !== null) ?? null) === null) continue;
|
|
696
|
+
if (!g && Nn(e, s, c, m, d)) {
|
|
697
|
+
o.push({ name: p, at: c, writers: m });
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
let b = m.map((w) => s[w]).find((w) => !F(w.node) && C(w.node, i) !== null);
|
|
701
|
+
if (b === void 0 || !d.referencePaths.some((w) => Ue(w, e))) continue;
|
|
702
|
+
let h = (
|
|
703
|
+
/** @type {{ name: string, prop: boolean }} */
|
|
704
|
+
C(b.node, i)
|
|
705
|
+
), x = `\`${p}\` is assigned from it in the component body and shown in JSX, so it keeps the value of the first run`, S = `compute it in the JSX where it is shown (\`{${h.name} ? \u2026 : \u2026}\`), or make it a function of the body and call it there (\`const ${p} = () => \u2026\`, then \`${p}()\`)`;
|
|
706
|
+
h.prop && (b.node, h.name, void 0);
|
|
707
|
+
}
|
|
708
|
+
if (o.length === 0) return;
|
|
709
|
+
let l = e.node._whatLiveMemos ??= { names: /* @__PURE__ */ new Set(), called: !t.ssr };
|
|
710
|
+
for (let { name: c } of o) l.names.add(c);
|
|
711
|
+
if (t.ssr) return;
|
|
712
|
+
let a = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map();
|
|
713
|
+
for (let { name: c, at: f, writers: p } of o) {
|
|
714
|
+
let d = (
|
|
715
|
+
/** @type {any} */
|
|
716
|
+
e.scope.getBinding(c)
|
|
717
|
+
), m = [f, ...p].map((b) => s[b]);
|
|
718
|
+
for (let b of d.referencePaths)
|
|
719
|
+
m.some((h) => b.isDescendant(h)) || (b.parentPath.isObjectProperty({ shorthand: !0 }) && b.key === "value" && (b.parent.shorthand = !1), b.replaceWith(n.callExpression(n.identifier(c), [])));
|
|
720
|
+
let g = [...m.map((b) => b.node), n.returnStatement(n.identifier(c))], E = n.variableDeclaration("const", [n.variableDeclarator(
|
|
721
|
+
n.identifier(c),
|
|
722
|
+
n.callExpression(v(t, "_$lazyMemo"), [n.arrowFunctionExpression([], n.blockStatement(g))])
|
|
723
|
+
)]);
|
|
724
|
+
for (let b of m) a.add(b.node);
|
|
725
|
+
u.set(s[p[p.length - 1]].node, E);
|
|
726
|
+
}
|
|
727
|
+
r.body = r.body.flatMap((c) => u.has(c) ? [u.get(c)] : a.has(c) ? [] : [c]), e.scope.crawl();
|
|
728
|
+
}
|
|
729
|
+
function Mn(e, t, r, i) {
|
|
730
|
+
let s = /* @__PURE__ */ new Set(), o = !1;
|
|
731
|
+
for (let l of i.constantViolations) {
|
|
732
|
+
let a = l.getFunctionParent() === e ? t.findIndex((u) => l === u || l.isDescendant(u)) : -1;
|
|
733
|
+
a > r ? s.add(a) : o = !0;
|
|
734
|
+
}
|
|
735
|
+
return { writers: [...s].sort((l, a) => l - a), elsewhere: o };
|
|
736
|
+
}
|
|
737
|
+
function Nn(e, t, r, i, s) {
|
|
738
|
+
let o = i[i.length - 1], l = [t[r], ...i.map((a) => t[a])];
|
|
739
|
+
for (let a of s.referencePaths) {
|
|
740
|
+
if (a.isJSXIdentifier()) return !1;
|
|
741
|
+
if (l.some((c) => a.isDescendant(c))) continue;
|
|
742
|
+
if (t.findIndex((c) => a.isDescendant(c)) <= o || a.findParent((c) => c.isFunctionDeclaration() && c.isDescendant(e)) !== null) return !1;
|
|
743
|
+
}
|
|
744
|
+
for (let a of l) {
|
|
745
|
+
if (a !== t[r] && (a.isDeclaration() || F(a.node))) return !1;
|
|
746
|
+
let u = !0;
|
|
747
|
+
if (a.traverse({
|
|
748
|
+
Function(c) {
|
|
749
|
+
c.skip();
|
|
750
|
+
},
|
|
751
|
+
"JSXElement|JSXFragment|YieldExpression|AwaitExpression|ThrowStatement"(c) {
|
|
752
|
+
u = !1, c.stop();
|
|
753
|
+
},
|
|
754
|
+
"BreakStatement|ContinueStatement"(c) {
|
|
755
|
+
let f = c.node.label ? c.findParent((p) => p.isLabeledStatement() && p.node.label.name === c.node.label.name) : c.findParent((p) => p.isLoop() || c.isBreakStatement() && p.isSwitchStatement());
|
|
756
|
+
(f === null || !f.isDescendant(a)) && (u = !1, c.stop());
|
|
757
|
+
},
|
|
758
|
+
CallExpression(c) {
|
|
759
|
+
ee(e, c.node) && (u = !1, c.stop());
|
|
760
|
+
},
|
|
761
|
+
"AssignmentExpression|UpdateExpression"(c) {
|
|
762
|
+
let f = c.isAssignmentExpression() ? c.node.left : c.node.argument, p = n.isIdentifier(f) ? c.scope.getBinding(f.name) : null;
|
|
763
|
+
p === s || p != null && p.path.isDescendant(a) || (u = !1, c.stop());
|
|
764
|
+
},
|
|
765
|
+
UnaryExpression(c) {
|
|
766
|
+
c.node.operator === "delete" && (u = !1, c.stop());
|
|
767
|
+
},
|
|
768
|
+
// Children are built where they are read: a memo would build them again.
|
|
769
|
+
MemberExpression(c) {
|
|
770
|
+
y(c.node.property, c.node.computed) === "children" && (u = !1, c.stop());
|
|
771
|
+
},
|
|
772
|
+
ReferencedIdentifier(c) {
|
|
773
|
+
let f = c.scope.getBinding(c.node.name);
|
|
774
|
+
if (f && f.scope === e.scope && c.node.name === "children") {
|
|
775
|
+
u = !1, c.stop();
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
f && f !== s && f.scope === e.scope && f.constantViolations.length > 0 && (u = !1, c.stop());
|
|
779
|
+
}
|
|
780
|
+
}), !u) return !1;
|
|
781
|
+
}
|
|
782
|
+
return !0;
|
|
783
|
+
}
|
|
784
|
+
function Le(e) {
|
|
785
|
+
let t = [], r = (i) => {
|
|
786
|
+
if (!(!i || typeof i != "object")) {
|
|
787
|
+
if (Array.isArray(i)) {
|
|
788
|
+
i.forEach(r);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
if (!(typeof i.type != "string" || n.isFunction(i))) {
|
|
792
|
+
if (n.isReturnStatement(i)) {
|
|
793
|
+
i.argument && t.push(i.argument);
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
for (let s of n.VISITOR_KEYS[i.type] || []) r(i[s]);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
return r(e.body), t;
|
|
801
|
+
}
|
|
802
|
+
function te(e, t, r = !1) {
|
|
803
|
+
let i = !1, s = (o) => {
|
|
804
|
+
if (!(i || !o || typeof o != "object")) {
|
|
805
|
+
if (Array.isArray(o)) {
|
|
806
|
+
o.forEach(s);
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
if (!(typeof o.type != "string" || n.isFunction(o))) {
|
|
810
|
+
if (r && n.isCallExpression(o) && D(e, o.callee) === "useContext") {
|
|
811
|
+
s(o.arguments);
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
if (n.isJSXElement(o) || n.isJSXFragment(o) || n.isCallExpression(o) && ee(e, o)) {
|
|
815
|
+
i = !0;
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
for (let l of n.VISITOR_KEYS[o.type] || []) s(o[l]);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
return s(t), i;
|
|
823
|
+
}
|
|
824
|
+
var Dn = /* @__PURE__ */ new Set(["useRef", "useCallback", "useId", "useEffect", "useContext", "useParams", "useSearch", "useRoute", "useNavigate"]);
|
|
825
|
+
function Ln(e, t) {
|
|
826
|
+
let r = U(t);
|
|
827
|
+
if (!n.isCallExpression(r) || !n.isIdentifier(r.callee) || !/^use[A-Z0-9]/.test(r.callee.name)) return null;
|
|
828
|
+
let i = D(e, r.callee), s = e.scope.getBinding(r.callee.name), o = s !== void 0 && (s.kind !== "module" || n.isImportDeclaration(s.path.parent) && s.path.parent.source.value.startsWith("."));
|
|
829
|
+
return { name: i ?? r.callee.name, local: r.callee.name, what: i !== null, own: o };
|
|
830
|
+
}
|
|
831
|
+
function Be(e) {
|
|
832
|
+
let t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
833
|
+
for (let i of n.isBlockStatement(e.node.body) ? e.node.body.body : [])
|
|
834
|
+
if (n.isVariableDeclaration(i, { kind: "const" }))
|
|
835
|
+
for (let s of i.declarations) {
|
|
836
|
+
let o = Ln(e, s.init);
|
|
837
|
+
if (o === null || o.what && (Dn.has(o.name) || Pe.has(o.name))) continue;
|
|
838
|
+
let l = { hook: o.name, local: o.local, own: o.own, keys: [] };
|
|
839
|
+
if (n.isIdentifier(s.id)) t.set(s.id.name, l);
|
|
840
|
+
else if (n.isObjectPattern(s.id))
|
|
841
|
+
for (let a of s.id.properties) {
|
|
842
|
+
if (!n.isObjectProperty(a) || !n.isIdentifier(a.value)) continue;
|
|
843
|
+
let u = y(a.key, a.computed);
|
|
844
|
+
r.set(a.value.name, { ...l, own: l.own && u !== null, keys: u === null ? [] : [u] });
|
|
845
|
+
}
|
|
846
|
+
else if (n.isArrayPattern(s.id))
|
|
847
|
+
for (let [a, u] of s.id.elements.entries()) n.isIdentifier(u) && r.set(u.name, { ...l, keys: [String(a)] });
|
|
848
|
+
}
|
|
849
|
+
return { results: t, parts: r };
|
|
850
|
+
}
|
|
851
|
+
function Ht(e, t) {
|
|
852
|
+
if (!t.frameworkFile)
|
|
853
|
+
for (let r of Be(e).results.keys()) {
|
|
854
|
+
let i = e.scope.getBinding(r);
|
|
855
|
+
i !== void 0 && i.scope === e.scope && i.path.isVariableDeclarator() && (i.path.node._whatHookResult = !0);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
function Bn(e) {
|
|
859
|
+
if (!e) return !1;
|
|
860
|
+
if (e.kind === "module") {
|
|
861
|
+
let t = e.path.node;
|
|
862
|
+
return (n.isImportSpecifier(t) || n.isImportDefaultSpecifier(t)) && n.isImportDeclaration(e.path.parent) && !P(e.path.parent.source.value);
|
|
863
|
+
}
|
|
864
|
+
return e.kind === "const" && e.scope.path.isProgram() && e.path.isVariableDeclarator() && n.isIdentifier(e.path.node.id) && de(e.path, e.path.node.init);
|
|
865
|
+
}
|
|
866
|
+
function Te(e) {
|
|
867
|
+
return e?.kind === "module" && n.isImportDeclaration(e.path.parent) && !P(e.path.parent.source.value);
|
|
868
|
+
}
|
|
869
|
+
function Tn(e, t) {
|
|
870
|
+
if (!t || t.constantViolations.length > 0 || t.scope !== e.scope && !t.scope.path.isProgram()) return null;
|
|
871
|
+
let r = t.path, i = r.isFunctionDeclaration() ? r : r.isVariableDeclarator() && t.kind === "const" ? r.get("init") : null;
|
|
872
|
+
return i?.isFunction() && !i.node.async && !i.node.generator ? i : null;
|
|
873
|
+
}
|
|
874
|
+
function Q(e) {
|
|
875
|
+
let t = e.node.params[0], r = n.isIdentifier(t) && e.scope.getBinding(t.name)?.kind === "param" ? t.name : null, i = /* @__PURE__ */ new Set(), s = H(e), { results: o, parts: l } = Be(e);
|
|
876
|
+
for (let d of [...o.keys(), ...l.keys()]) s.add(d);
|
|
877
|
+
let a = (d) => {
|
|
878
|
+
for (let m of d.properties) {
|
|
879
|
+
let g = n.isRestElement(m) ? null : y(m.key, m.computed);
|
|
880
|
+
if (!(g === null || V.has(g)))
|
|
881
|
+
for (let E of _(m.value)) i.add(E);
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
n.isObjectPattern(t) && a(t);
|
|
885
|
+
let u = e.node._whatLiveMemos;
|
|
886
|
+
if (u !== void 0) for (let d of u.names) (u.called ? s : i).add(d);
|
|
887
|
+
for (let d of n.isBlockStatement(e.node.body) ? e.node.body.body : [])
|
|
888
|
+
if (n.isVariableDeclaration(d, { kind: "const" })) {
|
|
889
|
+
for (let m of d.declarations)
|
|
890
|
+
if (r !== null && n.isObjectPattern(m.id) && n.isIdentifier(m.init, { name: r })) a(m.id);
|
|
891
|
+
else if (r !== null && n.isIdentifier(m.id) && (n.isMemberExpression(m.init) || n.isOptionalMemberExpression(m.init))) {
|
|
892
|
+
let g = m.init;
|
|
893
|
+
for (; n.isMemberExpression(g) || n.isOptionalMemberExpression(g); ) g = g.object;
|
|
894
|
+
let E = $e(m.init);
|
|
895
|
+
n.isIdentifier(g, { name: r }) && E !== null && !V.has(E) && i.add(m.id.name);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
let c = /* @__PURE__ */ new Map(), f = (d) => {
|
|
899
|
+
let m = Tn(e, d);
|
|
900
|
+
if (m === null) return !1;
|
|
901
|
+
if (!c.has(d)) {
|
|
902
|
+
c.set(d, !1);
|
|
903
|
+
let g = m.get("body"), E = p(g.node, g.scope) !== null;
|
|
904
|
+
!E && !g.isFunction() && g.traverse({
|
|
905
|
+
enter(b) {
|
|
906
|
+
b.isFunction() ? b.skip() : p(b.node, b.scope) !== null && (E = !0, b.stop());
|
|
907
|
+
}
|
|
908
|
+
}), c.set(d, E);
|
|
909
|
+
}
|
|
910
|
+
return (
|
|
911
|
+
/** @type {boolean} */
|
|
912
|
+
c.get(d)
|
|
913
|
+
);
|
|
914
|
+
}, p = (d, m = e.scope) => {
|
|
915
|
+
let g = (x) => m.getBinding(x)?.scope === e.scope;
|
|
916
|
+
if (n.isIdentifier(d)) return i.has(d.name) && g(d.name) ? { name: d.name, prop: !0 } : null;
|
|
917
|
+
if (n.isMemberExpression(d) || n.isOptionalMemberExpression(d)) {
|
|
918
|
+
if (!n.isIdentifier(d.object)) return null;
|
|
919
|
+
let x = y(d.property, d.computed);
|
|
920
|
+
return x === null || !g(d.object.name) ? null : d.object.name === r && !V.has(x) ? { name: `props.${x}`, prop: !0 } : o.has(d.object.name) ? { name: `${d.object.name}.${x}`, prop: !1 } : null;
|
|
921
|
+
}
|
|
922
|
+
if (!n.isCallExpression(d) && !n.isOptionalCallExpression(d)) return null;
|
|
923
|
+
let E = d.callee;
|
|
924
|
+
if (n.isIdentifier(E)) {
|
|
925
|
+
let x = m.getBinding(E.name);
|
|
926
|
+
return d.arguments.length === 0 && (s.has(E.name) && g(E.name) || Bn(x)) || f(x) ? { name: `${E.name}()`, prop: !1 } : null;
|
|
927
|
+
}
|
|
928
|
+
if (!n.isMemberExpression(E) && !n.isOptionalMemberExpression(E) || !n.isIdentifier(E.object)) return null;
|
|
929
|
+
let b = y(E.property, E.computed);
|
|
930
|
+
return b === null ? null : o.has(E.object.name) && g(E.object.name) || Te(m.getBinding(E.object.name)) ? { name: `${E.object.name}.${b}()`, prop: !1 } : null;
|
|
931
|
+
};
|
|
932
|
+
return p;
|
|
933
|
+
}
|
|
934
|
+
function Xe(e) {
|
|
935
|
+
let t = Q(e);
|
|
936
|
+
return (r) => t(r) ?? (n.isCallExpression(r) && D(e, r.callee) === "useContext" ? { name: `useContext(${n.isIdentifier(r.arguments[0]) ? r.arguments[0].name : "\u2026"})`, prop: !1 } : null);
|
|
937
|
+
}
|
|
938
|
+
function L(e, t) {
|
|
939
|
+
return C(e, (r) => t(r) ? "" : null) !== null;
|
|
940
|
+
}
|
|
941
|
+
function U(e) {
|
|
942
|
+
for (; n.isParenthesizedExpression(e) || n.isTSAsExpression(e) || n.isTSSatisfiesExpression(e) || n.isTSNonNullExpression(e); ) e = e.expression;
|
|
943
|
+
return e;
|
|
944
|
+
}
|
|
945
|
+
function Xn(e, t) {
|
|
946
|
+
return L(n.isConditionalExpression(e) ? e.test : e.left, t);
|
|
947
|
+
}
|
|
948
|
+
function W(e) {
|
|
949
|
+
let t = U(e);
|
|
950
|
+
return n.isConditionalExpression(t) || n.isLogicalExpression(t);
|
|
951
|
+
}
|
|
952
|
+
function N(e) {
|
|
953
|
+
return n.jsxFragment(n.jsxOpeningFragment(), n.jsxClosingFragment(), [n.jsxExpressionContainer(e)]);
|
|
954
|
+
}
|
|
955
|
+
function F(e) {
|
|
956
|
+
let t = !1, r = (i) => {
|
|
957
|
+
if (!(t || !i || typeof i != "object")) {
|
|
958
|
+
if (Array.isArray(i)) {
|
|
959
|
+
i.forEach(r);
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
if (!(typeof i.type != "string" || n.isFunction(i) || n.isClass(i))) {
|
|
963
|
+
if (n.isReturnStatement(i)) {
|
|
964
|
+
t = !0;
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
for (let s of n.VISITOR_KEYS[i.type] || []) r(i[s]);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
return r(e), t;
|
|
972
|
+
}
|
|
973
|
+
function I(e, t = []) {
|
|
974
|
+
if (!e) return t;
|
|
975
|
+
if (n.isReturnStatement(e)) {
|
|
976
|
+
let r = U(e.argument);
|
|
977
|
+
n.isConditionalExpression(r) ? t.push(r.test) : n.isLogicalExpression(r) && t.push(r.left);
|
|
978
|
+
} else if (n.isIfStatement(e))
|
|
979
|
+
F(e) && t.push(e.test), I(e.consequent, t), I(e.alternate, t);
|
|
980
|
+
else if (n.isBlockStatement(e))
|
|
981
|
+
for (let r of e.body) I(r, t);
|
|
982
|
+
else if (n.isSwitchStatement(e) && F(e)) {
|
|
983
|
+
t.push(e.discriminant);
|
|
984
|
+
for (let r of e.cases) for (let i of r.consequent) I(i, t);
|
|
985
|
+
} else n.isLoop(e) && F(e) ? (t.push(n.isForXStatement(e) ? e.right : e.test), I(e.body, t)) : n.isTryStatement(e) ? (I(e.block, t), I(e.handler?.body, t), I(e.finalizer, t)) : n.isLabeledStatement(e) && (I(e.body, t), F(e.body) && Jn(e.body, e.label.name, t));
|
|
986
|
+
return t;
|
|
987
|
+
}
|
|
988
|
+
function Jn(e, t, r) {
|
|
989
|
+
let i = (s) => {
|
|
990
|
+
if (!(!s || typeof s != "object")) {
|
|
991
|
+
if (Array.isArray(s)) {
|
|
992
|
+
s.forEach(i);
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
if (!(typeof s.type != "string" || n.isFunction(s))) {
|
|
996
|
+
n.isIfStatement(s) && !r.includes(s.test) && Vn(s, t) && r.push(s.test);
|
|
997
|
+
for (let o of n.VISITOR_KEYS[s.type] || []) i(s[o]);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
i(e);
|
|
1002
|
+
}
|
|
1003
|
+
function Vn(e, t) {
|
|
1004
|
+
let r = !1;
|
|
1005
|
+
return n.traverseFast(e, (i) => {
|
|
1006
|
+
n.isBreakStatement(i) && i.label?.name === t && (r = !0);
|
|
1007
|
+
}), r;
|
|
1008
|
+
}
|
|
1009
|
+
function Je(e) {
|
|
1010
|
+
return n.isBlockStatement(e) ? e.body.flatMap((t) => n.isReturnStatement(t) || F(t) ? I(t) : []) : I(n.returnStatement(e));
|
|
1011
|
+
}
|
|
1012
|
+
function j(e) {
|
|
1013
|
+
return n.isReturnStatement(e) || n.isThrowStatement(e) ? !0 : n.isBlockStatement(e) ? e.body.some(j) : n.isIfStatement(e) && e.alternate != null && j(e.consequent) && j(e.alternate);
|
|
1014
|
+
}
|
|
1015
|
+
function Wn(e, t) {
|
|
1016
|
+
let r = !1, i = (o) => {
|
|
1017
|
+
if (!(r || !o || typeof o != "object")) {
|
|
1018
|
+
if (Array.isArray(o)) {
|
|
1019
|
+
o.forEach(i);
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
if (!(typeof o.type != "string" || n.isFunction(o))) {
|
|
1023
|
+
if (n.isVariableDeclaration(o, { kind: "var" })) {
|
|
1024
|
+
r = !0;
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
for (let l of n.VISITOR_KEYS[o.type] || []) i(o[l]);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
if (i(t), r) return !1;
|
|
1032
|
+
let s = (o) => !t.some((l) => o.node === l || o.findParent((a) => a.node === l) !== null);
|
|
1033
|
+
for (let o of t) {
|
|
1034
|
+
let l = n.isVariableDeclaration(o) ? o.declarations.flatMap((a) => [..._(a.id)]) : n.isClassDeclaration(o) && o.id ? [o.id.name] : [];
|
|
1035
|
+
for (let a of l) {
|
|
1036
|
+
let u = e.scope.getBinding(a);
|
|
1037
|
+
if (u && (u.referencePaths.some(s) || u.constantViolations.some(s))) return !1;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
return !0;
|
|
1041
|
+
}
|
|
1042
|
+
var Ve = () => n.unaryExpression("void", n.numericLiteral(0));
|
|
1043
|
+
function M(e, t, r) {
|
|
1044
|
+
let i = e.findIndex(F), s = i === -1 ? e : e.slice(0, i), o = null;
|
|
1045
|
+
return i !== -1 && (o = Pn(e[i], e.slice(i + 1), t, r), o === null) ? null : s.length === 0 ? o ?? Ve() : t(o === null ? s : [...s, n.returnStatement(W(o) ? N(o) : o)]);
|
|
1046
|
+
}
|
|
1047
|
+
function Pn(e, t, r, i) {
|
|
1048
|
+
if (n.isReturnStatement(e)) return e.argument ?? Ve();
|
|
1049
|
+
if (n.isBlockStatement(e))
|
|
1050
|
+
return j(e) ? M(e.body, r, i) : We(e.body) && t.length > 0 ? null : M([...e.body, ...t], r, i);
|
|
1051
|
+
if (n.isIfStatement(e)) {
|
|
1052
|
+
if (!j(e.consequent) && t.length > 0 && !(e.alternate && j(e.alternate))) return null;
|
|
1053
|
+
let o = M(se(e.consequent, t), r, i), l = M(e.alternate ? se(e.alternate, t) : t, r, i);
|
|
1054
|
+
return o === null || l === null ? null : n.conditionalExpression(e.test, o, l);
|
|
1055
|
+
}
|
|
1056
|
+
return n.isSwitchStatement(e) ? Un(e, t, r, i) : null;
|
|
1057
|
+
}
|
|
1058
|
+
function se(e, t) {
|
|
1059
|
+
let r = n.isBlockStatement(e) ? e.body : [e];
|
|
1060
|
+
return j(e) || t.length === 0 ? r : n.isBlockStatement(e) && We(r) ? [n.blockStatement(r), ...t] : [...r, ...t];
|
|
1061
|
+
}
|
|
1062
|
+
function We(e) {
|
|
1063
|
+
return e.some((t) => n.isVariableDeclaration(t) || n.isFunctionDeclaration(t) || n.isClassDeclaration(t));
|
|
1064
|
+
}
|
|
1065
|
+
function Un(e, t, r, i) {
|
|
1066
|
+
let s = (h) => n.isIdentifier(h) || (n.isMemberExpression(h) || n.isOptionalMemberExpression(h)) && (!h.computed || n.isStringLiteral(h.property) || n.isNumericLiteral(h.property)) && s(h.object) || n.isCallExpression(h) && h.arguments.length === 0 && n.isIdentifier(h.callee), o = (h) => n.isStringLiteral(h) || n.isNumericLiteral(h) || n.isBooleanLiteral(h) || n.isNullLiteral(h) || n.isTemplateLiteral(h) && h.expressions.length === 0 || !n.isCallExpression(h) && s(h), l = e.cases, a = l.findIndex((h) => h.test === null);
|
|
1067
|
+
if (a !== -1 && a !== l.length - 1 || l.some((h) => h.test !== null && !o(h.test)) || Hn(e)) return null;
|
|
1068
|
+
let u = a === -1 ? l.length : a;
|
|
1069
|
+
if (l.slice(0, u).some((h) => h.consequent.length > 0 && !h.consequent.some(j))) return null;
|
|
1070
|
+
let c = [], f = [];
|
|
1071
|
+
for (let h of l.slice(0, u)) {
|
|
1072
|
+
let x = [];
|
|
1073
|
+
if (h.consequent.length > 0) {
|
|
1074
|
+
let S = M(h.consequent, r, i);
|
|
1075
|
+
if (S === null) return null;
|
|
1076
|
+
x.push(n.returnStatement(n.numericLiteral(c.length))), c.push(S);
|
|
1077
|
+
}
|
|
1078
|
+
f.push(n.switchCase(h.test, x));
|
|
1079
|
+
}
|
|
1080
|
+
let p = M(a === -1 ? t : se(n.blockStatement(l[a].consequent), t), r, i);
|
|
1081
|
+
if (p === null) return null;
|
|
1082
|
+
W(p) && (p = N(p));
|
|
1083
|
+
let d = n.arrowFunctionExpression([], n.blockStatement([n.switchStatement(e.discriminant, f)])), m = En(i, "_switch$");
|
|
1084
|
+
for (let h = c.length - 1; h >= 0; h--) {
|
|
1085
|
+
let x = i.ssr ? n.identifier(m) : n.callExpression(n.identifier(m), []), S = c[h];
|
|
1086
|
+
p = n.conditionalExpression(
|
|
1087
|
+
n.binaryExpression("===", x, n.numericLiteral(h)),
|
|
1088
|
+
W(S) ? N(S) : S,
|
|
1089
|
+
p
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
let g = n.variableDeclaration("const", [n.variableDeclarator(n.identifier(m), i.ssr ? n.callExpression(d, []) : n.callExpression(v(i, "_$lazyMemo"), [d]))]), E = N(i.ssr ? n.arrowFunctionExpression([], n.blockStatement([g, n.returnStatement(p)])) : n.arrowFunctionExpression([], p));
|
|
1093
|
+
if (i.ssr) return E;
|
|
1094
|
+
let b = n.callExpression(n.arrowFunctionExpression([], n.blockStatement([g, n.returnStatement(E)])), []);
|
|
1095
|
+
return b._whatSwitch = !0, b;
|
|
1096
|
+
}
|
|
1097
|
+
function Hn(e) {
|
|
1098
|
+
let t = !1, r = (i, s) => {
|
|
1099
|
+
if (t || !i || typeof i != "object") return;
|
|
1100
|
+
if (Array.isArray(i)) {
|
|
1101
|
+
i.forEach((l) => r(l, s));
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
if (typeof i.type != "string" || n.isFunction(i)) return;
|
|
1105
|
+
if (n.isBreakStatement(i) && (!s || i.label)) {
|
|
1106
|
+
t = !0;
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
if (n.isContinueStatement(i) && !s) {
|
|
1110
|
+
t = !0;
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
let o = s || i !== e && (n.isLoop(i) || n.isSwitchStatement(i));
|
|
1114
|
+
for (let l of n.VISITOR_KEYS[i.type] || []) r(i[l], o);
|
|
1115
|
+
};
|
|
1116
|
+
for (let i of e.cases) r(i.consequent, !1);
|
|
1117
|
+
return t;
|
|
1118
|
+
}
|
|
1119
|
+
var Pe = /* @__PURE__ */ new Set(["signal", "computed", "useState", "useReducer", "useSignal", "useComputed", "useMemo", "useTransition", "useOptimistic", "useActionState", "createResource"]);
|
|
1120
|
+
function H(e) {
|
|
1121
|
+
let t = /* @__PURE__ */ new Set(), r = e.node.body;
|
|
1122
|
+
if (!n.isBlockStatement(r)) return t;
|
|
1123
|
+
for (let i of r.body)
|
|
1124
|
+
if (n.isVariableDeclaration(i))
|
|
1125
|
+
for (let s of i.declarations) {
|
|
1126
|
+
if (!de(e, s.init)) continue;
|
|
1127
|
+
let o = n.isArrayPattern(s.id) ? s.id.elements[0] : s.id;
|
|
1128
|
+
n.isIdentifier(o) && t.add(o.name);
|
|
1129
|
+
}
|
|
1130
|
+
return t;
|
|
1131
|
+
}
|
|
1132
|
+
function de(e, t) {
|
|
1133
|
+
if (!n.isCallExpression(t) || !n.isIdentifier(t.callee)) return !1;
|
|
1134
|
+
let r = e.scope.getBinding(t.callee.name);
|
|
1135
|
+
if (!r || r.kind !== "module" || !n.isImportSpecifier(r.path.node)) return !1;
|
|
1136
|
+
let i = r.path.node.imported, s = n.isIdentifier(i) ? i.name : i.value;
|
|
1137
|
+
return Pe.has(s) && B(r, n.isImportSpecifier, s);
|
|
1138
|
+
}
|
|
1139
|
+
function zn(e, t) {
|
|
1140
|
+
return C(e, (r) => n.isCallExpression(r) && r.arguments.length === 0 && n.isIdentifier(r.callee) && t.has(r.callee.name) ? `${r.callee.name}()` : null);
|
|
1141
|
+
}
|
|
1142
|
+
function zt(e, t) {
|
|
1143
|
+
}
|
|
1144
|
+
function Kn(e, t) {
|
|
1145
|
+
let r = null;
|
|
1146
|
+
if (e.traverse({
|
|
1147
|
+
Function(o) {
|
|
1148
|
+
X(o) && o.skip();
|
|
1149
|
+
},
|
|
1150
|
+
MemberExpression(o) {
|
|
1151
|
+
let { object: l, property: a } = o.node;
|
|
1152
|
+
if (r !== null || o.node.computed || !n.isIdentifier(l) || !n.isIdentifier(a) || o.parentPath.isCallExpression() && o.key === "callee") return;
|
|
1153
|
+
let u = o.scope.getBinding(l.name), c = u?.kind === "const" && u.scope.path.isProgram() && u.path.isVariableDeclarator() ? u.path.node.init : null;
|
|
1154
|
+
n.isCallExpression(c) && D(e, c.callee) === "createStore" && (r = o.node);
|
|
1155
|
+
}
|
|
1156
|
+
}), r === null) return;
|
|
1157
|
+
let i = r.object.name, s = `${i}.${r.property.name}`;
|
|
1158
|
+
oe(
|
|
1159
|
+
e,
|
|
1160
|
+
t,
|
|
1161
|
+
r,
|
|
1162
|
+
s,
|
|
1163
|
+
`\`${i}\` is the hook createStore() made, not the store's state, so \`${s}\` is a property of that function, which no write to the store changes`,
|
|
1164
|
+
`call the hook in the component and read the field from what it returns (\`const state = ${i}();\`, then \`state.${r.property.name}\`), which follows the store`
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
var V = /* @__PURE__ */ new Set(["children", "params", "route"]);
|
|
1168
|
+
function Kt(e, t) {
|
|
1169
|
+
}
|
|
1170
|
+
function qn(e, t) {
|
|
1171
|
+
let r = [], i = !1, s = (o) => {
|
|
1172
|
+
if (t(o) === null) return !1;
|
|
1173
|
+
let l = o.parentPath;
|
|
1174
|
+
return l.isMemberExpression() && o.key === "object" && y(l.node.property, l.node.computed) !== null && Ce(l) ? r.push(l.node) : i = !0, !0;
|
|
1175
|
+
};
|
|
1176
|
+
return s(e) || e.traverse({
|
|
1177
|
+
enter(o) {
|
|
1178
|
+
(o.isFunction() || o.isJSXElement() || o.isJSXFragment() || s(o)) && o.skip(), i && o.stop();
|
|
1179
|
+
}
|
|
1180
|
+
}), i || r.length === 0 ? null : r;
|
|
1181
|
+
}
|
|
1182
|
+
function Yn(e) {
|
|
1183
|
+
let t = e.node.params[0], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = (a) => {
|
|
1184
|
+
for (let u of a.properties) {
|
|
1185
|
+
let c = n.isRestElement(u) ? null : y(u.key, u.computed);
|
|
1186
|
+
if (!(c !== null && V.has(c)))
|
|
1187
|
+
for (let f of _(n.isRestElement(u) ? u : u.value)) {
|
|
1188
|
+
let p = e.scope.getBinding(f);
|
|
1189
|
+
p && (r.add(p), n.isRestElement(u) && i.add(p));
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}, o = n.isIdentifier(t) ? e.scope.getBinding(t.name) ?? null : null;
|
|
1193
|
+
if (n.isObjectPattern(t)) s(t);
|
|
1194
|
+
else {
|
|
1195
|
+
if (o === null || o.kind !== "param") return null;
|
|
1196
|
+
{
|
|
1197
|
+
let a = o.identifier.name;
|
|
1198
|
+
for (let u of e.node.body.body)
|
|
1199
|
+
if (n.isVariableDeclaration(u))
|
|
1200
|
+
for (let c of u.declarations) n.isObjectPattern(c.id) && n.isIdentifier(c.init, { name: a }) && s(c.id);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
let l = (a, u) => o !== null && n.isIdentifier(a) && u.getBinding(a.name) === o;
|
|
1204
|
+
return {
|
|
1205
|
+
read(a) {
|
|
1206
|
+
if (a.isIdentifier() && a.isReferencedIdentifier()) {
|
|
1207
|
+
let u = a.scope.getBinding(a.node.name);
|
|
1208
|
+
return u && r.has(u) ? a.node.name : null;
|
|
1209
|
+
}
|
|
1210
|
+
if ((a.isMemberExpression() || a.isOptionalMemberExpression()) && l(a.node.object, a.scope)) {
|
|
1211
|
+
let u = y(a.node.property, a.node.computed);
|
|
1212
|
+
return u !== null && !V.has(u) ? `props.${u}` : null;
|
|
1213
|
+
}
|
|
1214
|
+
return null;
|
|
1215
|
+
},
|
|
1216
|
+
callsProp(a) {
|
|
1217
|
+
for (; a.isTSAsExpression() || a.isTSSatisfiesExpression() || a.isTSNonNullExpression() || a.isParenthesizedExpression(); ) a = a.get("expression");
|
|
1218
|
+
return (a.isCallExpression() || a.isOptionalCallExpression()) && this.read(a.get("callee")) !== null;
|
|
1219
|
+
},
|
|
1220
|
+
live(a) {
|
|
1221
|
+
let { id: u, init: c } = a.node;
|
|
1222
|
+
if (!n.isIdentifier(u)) {
|
|
1223
|
+
if (l(c, a.scope)) return !0;
|
|
1224
|
+
let p = n.isIdentifier(c) ? a.scope.getBinding(c.name) : null;
|
|
1225
|
+
return p != null && i.has(p);
|
|
1226
|
+
}
|
|
1227
|
+
if (a.parent.kind !== "const") return !1;
|
|
1228
|
+
let f = c;
|
|
1229
|
+
for (; n.isMemberExpression(f) || n.isOptionalMemberExpression(f); ) {
|
|
1230
|
+
if (y(f.property, f.computed) === null) return !1;
|
|
1231
|
+
f = f.object;
|
|
1232
|
+
}
|
|
1233
|
+
return f !== c && l(f, a.scope);
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
function Zn(e) {
|
|
1238
|
+
let t = e.parentPath;
|
|
1239
|
+
return (t.isCallExpression() || t.isOptionalCallExpression() || t.isTaggedTemplateExpression()) && (e.key === "callee" || e.key === "tag");
|
|
1240
|
+
}
|
|
1241
|
+
function Ue(e, t) {
|
|
1242
|
+
let r = e.parentPath;
|
|
1243
|
+
if (r.isSpreadElement() || r.isJSXSpreadAttribute() || r.isJSXSpreadChild()) return !1;
|
|
1244
|
+
if ((r.isMemberExpression() || r.isOptionalMemberExpression()) && e.key === "object" && !r.node.computed) {
|
|
1245
|
+
let i = r.parentPath;
|
|
1246
|
+
if (!((i.isCallExpression() || i.isOptionalCallExpression()) && r.key === "callee")) return !1;
|
|
1247
|
+
}
|
|
1248
|
+
for (let i = r; i !== null && i !== t; i = i.parentPath) {
|
|
1249
|
+
if (i.isJSXSpreadAttribute() || i.isJSXSpreadChild()) return !0;
|
|
1250
|
+
if (!i.isJSXExpressionContainer()) continue;
|
|
1251
|
+
let s = i.parentPath;
|
|
1252
|
+
if (!s.isJSXAttribute()) return !0;
|
|
1253
|
+
let o = O(s.node), l = s.parentPath.node.name, a = n.isJSXIdentifier(l) && /^[a-z]/.test(l.name);
|
|
1254
|
+
return o !== "ref" && o !== "key" && !/^on[A-Z:]/.test(o) && !(a && /^on[a-z]+$/.test(o));
|
|
1255
|
+
}
|
|
1256
|
+
return !1;
|
|
1257
|
+
}
|
|
1258
|
+
function ee(e, t) {
|
|
1259
|
+
for (; n.isTSAsExpression(t) || n.isTSSatisfiesExpression(t) || n.isTSNonNullExpression(t) || n.isParenthesizedExpression(t); ) t = t.expression;
|
|
1260
|
+
if (!n.isCallExpression(t)) return !1;
|
|
1261
|
+
let r = n.isMemberExpression(t.callee) && !t.callee.computed ? t.callee.property : t.callee;
|
|
1262
|
+
return n.isIdentifier(r) ? /^use[A-Z0-9]/.test(r.name) || r === t.callee && D(e, r) !== null : !1;
|
|
1263
|
+
}
|
|
1264
|
+
function Gn(e, t) {
|
|
1265
|
+
if (e.isFunction() || e.isJSXElement() || e.isJSXFragment()) return null;
|
|
1266
|
+
let r = t(e);
|
|
1267
|
+
return r !== null || e.traverse({
|
|
1268
|
+
enter(i) {
|
|
1269
|
+
if (i.isFunction() || i.isJSXElement() || i.isJSXFragment()) {
|
|
1270
|
+
i.skip();
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
r = t(i), r !== null && i.stop();
|
|
1274
|
+
}
|
|
1275
|
+
}), r;
|
|
1276
|
+
}
|
|
1277
|
+
function qt(e, t) {
|
|
1278
|
+
if (t.ssr || t.frameworkFile || !X(e) || T(e, t) || !n.isBlockStatement(e.node.body)) return;
|
|
1279
|
+
let r = e.node.params[0], i = n.isIdentifier(r) ? e.scope.getBinding(r.name) ?? null : null, s = H(e);
|
|
1280
|
+
for (let l of e.node._whatLiveMemos?.names ?? []) s.add(l);
|
|
1281
|
+
if ((i === null || i.kind !== "param") && s.size === 0) return;
|
|
1282
|
+
let o = (l) => {
|
|
1283
|
+
if ((l.isMemberExpression() || l.isOptionalMemberExpression()) && i !== null && i.kind === "param" && n.isIdentifier(l.node.object) && l.scope.getBinding(l.node.object.name) === i && He(l)) {
|
|
1284
|
+
let a = y(l.node.property, l.node.computed);
|
|
1285
|
+
return a === null ? null : { key: `props.${a}`, name: a };
|
|
1286
|
+
}
|
|
1287
|
+
return l.isCallExpression() && l.node.arguments.length === 0 && n.isIdentifier(l.node.callee) && s.has(l.node.callee.name) && l.scope.getBinding(l.node.callee.name) === e.scope.getBinding(l.node.callee.name) ? { key: `${l.node.callee.name}()`, name: l.node.callee.name } : null;
|
|
1288
|
+
};
|
|
1289
|
+
for (let l of e.get("body.body")) {
|
|
1290
|
+
let a = l.isExpressionStatement() ? l.get("expression") : null;
|
|
1291
|
+
if (a === null || !a.isCallExpression() || D(e, a.node.callee) !== "useEffect") continue;
|
|
1292
|
+
let u = Qn(e, a.get("arguments.0"));
|
|
1293
|
+
u !== null && et(u, t, a.node.arguments.length < 2, o);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
function Qn(e, t) {
|
|
1297
|
+
if (!t.node || t.node.async) return null;
|
|
1298
|
+
if (t.isFunction()) return t;
|
|
1299
|
+
if (!t.isIdentifier()) return null;
|
|
1300
|
+
let r = e.scope.getBinding(t.node.name);
|
|
1301
|
+
if (!r || r.scope !== e.scope || r.constantViolations.length > 0) return null;
|
|
1302
|
+
if (r.path.isFunctionDeclaration()) return r.path.node.async ? null : r.path;
|
|
1303
|
+
let i = r.path.isVariableDeclarator() ? r.path.get("init") : null;
|
|
1304
|
+
return i !== null && i.isFunction() && !i.node.async ? i : null;
|
|
1305
|
+
}
|
|
1306
|
+
function He(e) {
|
|
1307
|
+
let t = e.parentPath;
|
|
1308
|
+
return t.isAssignmentExpression() && e.key === "left" || t.isUpdateExpression() || t.isUnaryExpression({ operator: "delete" }) ? !1 : !((t.isForInStatement() || t.isForOfStatement()) && e.key === "left");
|
|
1309
|
+
}
|
|
1310
|
+
function et(e, t, r, i) {
|
|
1311
|
+
let s = e.get("body"), o = [];
|
|
1312
|
+
if (s.isFunction() ? o.push(s) : s.isBlockStatement() && s.traverse({
|
|
1313
|
+
Function(f) {
|
|
1314
|
+
f.skip();
|
|
1315
|
+
},
|
|
1316
|
+
ReturnStatement(f) {
|
|
1317
|
+
let p = f.get("argument");
|
|
1318
|
+
p.node && p.isFunction() && o.push(p);
|
|
1319
|
+
}
|
|
1320
|
+
}), o.length === 0) return;
|
|
1321
|
+
let l = /* @__PURE__ */ new Map();
|
|
1322
|
+
for (let f of o)
|
|
1323
|
+
f.traverse({
|
|
1324
|
+
"MemberExpression|OptionalMemberExpression|CallExpression"(p) {
|
|
1325
|
+
let d = i(p);
|
|
1326
|
+
if (d === null) return;
|
|
1327
|
+
let m = l.get(d.key);
|
|
1328
|
+
m === void 0 && (m = { id: e.scope.generateUidIdentifier(d.name), value: n.cloneNode(p.node, !0) }, l.set(d.key, m)), p.replaceWith(n.identifier(m.id.name));
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
if (l.size === 0) return;
|
|
1332
|
+
let a = /* @__PURE__ */ new Set();
|
|
1333
|
+
r && s.isBlockStatement() && s.traverse({
|
|
1334
|
+
Function(f) {
|
|
1335
|
+
f.skip();
|
|
1336
|
+
},
|
|
1337
|
+
"MemberExpression|OptionalMemberExpression|CallExpression"(f) {
|
|
1338
|
+
let p = i(f);
|
|
1339
|
+
p !== null && a.add(p.key);
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
let u = [...l].map(([f, { id: p, value: d }]) => n.variableDeclarator(p, r && !a.has(f) ? n.callExpression(v(t, "_$untrack"), [n.arrowFunctionExpression([], d)]) : d)), c = n.variableDeclaration("const", u);
|
|
1343
|
+
s.isBlockStatement() ? s.unshiftContainer("body", c) : s.replaceWith(n.blockStatement([c, n.returnStatement(s.node)]));
|
|
1344
|
+
}
|
|
1345
|
+
function D(e, t) {
|
|
1346
|
+
if (!n.isIdentifier(t)) return null;
|
|
1347
|
+
let r = e.scope.getBinding(t.name);
|
|
1348
|
+
if (!r || r.kind !== "module" || !n.isImportSpecifier(r.path.node)) return null;
|
|
1349
|
+
let i = r.path.node.imported, s = n.isIdentifier(i) ? i.name : i.value;
|
|
1350
|
+
return B(r, n.isImportSpecifier, s) ? s : null;
|
|
1351
|
+
}
|
|
1352
|
+
function be(e, t) {
|
|
1353
|
+
let r = /* @__PURE__ */ new Set(), i = (s) => {
|
|
1354
|
+
if (!s || typeof s != "object") return;
|
|
1355
|
+
if (Array.isArray(s)) {
|
|
1356
|
+
s.forEach(i);
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
if (typeof s.type != "string" || n.isFunction(s)) return;
|
|
1360
|
+
let o = t(s);
|
|
1361
|
+
o !== null && r.add(o);
|
|
1362
|
+
for (let l of n.VISITOR_KEYS[s.type] || []) i(s[l]);
|
|
1363
|
+
};
|
|
1364
|
+
return i(e), r;
|
|
1365
|
+
}
|
|
1366
|
+
function Yt(e, t) {
|
|
1367
|
+
}
|
|
1368
|
+
function nt(e, t) {
|
|
1369
|
+
let r = e.scope.getBinding(t);
|
|
1370
|
+
if (!r || r.scope !== e.scope || r.constantViolations.length > 0) return null;
|
|
1371
|
+
if (n.isFunctionDeclaration(r.path.node)) return r.path.node;
|
|
1372
|
+
let i = n.isVariableDeclarator(r.path.node) ? r.path.node.init : null;
|
|
1373
|
+
return n.isFunction(i) ? i : null;
|
|
1374
|
+
}
|
|
1375
|
+
function oe(e, t, r, i, s, o) {
|
|
1376
|
+
let a = `${t.filename || t.file?.opts?.filename || "<unknown>"}${r.loc ? `:${r.loc.start.line}:${r.loc.start.column + 1}` : ""}`;
|
|
1377
|
+
Ke(t, "ERR_STATE_READ_ONCE", { name: i, component: $(e), reason: s }, r), !q.has(`${a}::${i}`) && (q.add(`${a}::${i}`), console.warn(
|
|
1378
|
+
`[what-compiler] ERR_STATE_READ_ONCE: \`${i}\`, state of <${$(e)}> at ${a}, is read once, when the component runs, because ${s}; the component runs once, so it does not follow the state as a React render would. Fix: ${o}. Run what_fix({ error: 'ERR_STATE_READ_ONCE' }) for the worked example.`
|
|
1379
|
+
));
|
|
1380
|
+
}
|
|
1381
|
+
function me(e) {
|
|
1382
|
+
let t = e.node.body;
|
|
1383
|
+
return (n.isBlockStatement(t) ? Le(t) : [t]).map(U).filter((r) => n.isCallExpression(r));
|
|
1384
|
+
}
|
|
1385
|
+
function he(e, t) {
|
|
1386
|
+
let r = t.callee, i = (l, a) => l?.kind === "module" && a(l.path.node) && n.isImportDeclaration(l.path.parent) && !P(l.path.parent.source.value);
|
|
1387
|
+
if (n.isMemberExpression(r) && !r.computed && n.isIdentifier(r.object) && n.isIdentifier(r.property)) {
|
|
1388
|
+
let l = e.scope.getBinding(r.object.name);
|
|
1389
|
+
return Te(l) || tt(l, r.property.name);
|
|
1390
|
+
}
|
|
1391
|
+
if (!n.isIdentifier(r)) return !1;
|
|
1392
|
+
let s = e.scope.getBinding(r.name);
|
|
1393
|
+
if (!s) return !1;
|
|
1394
|
+
if (s.kind === "module" && !n.isFunctionDeclaration(s.path.node) && !n.isVariableDeclarator(s.path.node))
|
|
1395
|
+
return i(s, (l) => n.isImportSpecifier(l) || n.isImportDefaultSpecifier(l));
|
|
1396
|
+
let o = n.isVariableDeclarator(s.path.node) ? s.path.node.init : s.path.node;
|
|
1397
|
+
return n.isFunction(o) && s.constantViolations.length === 0 && A(o);
|
|
1398
|
+
}
|
|
1399
|
+
function tt(e, t) {
|
|
1400
|
+
if (!e || e.kind !== "const" || !e.path.isVariableDeclarator() || !n.isObjectExpression(e.path.node.init) || e.referencePaths.some((i) => i.parentPath.isMemberExpression() && i.key === "object" && !He(i.parentPath))) return !1;
|
|
1401
|
+
let r = null;
|
|
1402
|
+
for (let i of e.path.node.init.properties)
|
|
1403
|
+
n.isSpreadElement(i) ? r = null : y(i.key, i.computed) === t && (r = n.isObjectMethod(i, { kind: "method" }) ? i : n.isObjectProperty(i) && n.isFunction(i.value) ? i.value : null);
|
|
1404
|
+
return r !== null && A(r);
|
|
1405
|
+
}
|
|
1406
|
+
function ze(e, t) {
|
|
1407
|
+
let r = !1, i = (s) => {
|
|
1408
|
+
if (!(r || !s || typeof s != "object")) {
|
|
1409
|
+
if (Array.isArray(s)) {
|
|
1410
|
+
s.forEach(i);
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
if (!(typeof s.type != "string" || n.isFunction(s) || n.isJSXElement(s) || n.isJSXFragment(s))) {
|
|
1414
|
+
if (t(s)) {
|
|
1415
|
+
r = !0;
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
for (let o of n.VISITOR_KEYS[s.type] || []) i(s[o]);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
return i(e), r;
|
|
1423
|
+
}
|
|
1424
|
+
function Zt(e, t) {
|
|
1425
|
+
if (t.ssr || t.frameworkFile || !X(e) || T(e, t)) return;
|
|
1426
|
+
let r = Q(e);
|
|
1427
|
+
for (let i of me(e))
|
|
1428
|
+
he(e, i) && (i.arguments = i.arguments.map((s) => {
|
|
1429
|
+
if (!n.isObjectExpression(s)) return s;
|
|
1430
|
+
let o = !1;
|
|
1431
|
+
if (s.properties = s.properties.map((u) => {
|
|
1432
|
+
let c = n.isObjectProperty(u) ? y(u.key, u.computed) : null;
|
|
1433
|
+
return c === null || c === "__proto__" && !u.computed || !ze(u.value, r) ? u : (o = !0, n.objectMethod("get", u.key, [], n.blockStatement([n.returnStatement(u.value)]), u.computed));
|
|
1434
|
+
}), !s.properties.some((u) => n.isSpreadElement(u) && ge(e, u.argument))) return o ? n.callExpression(v(t, "_$marked"), [s]) : s;
|
|
1435
|
+
let l = [], a = /* @__PURE__ */ new Set();
|
|
1436
|
+
for (let u of s.properties) {
|
|
1437
|
+
let c = l[l.length - 1];
|
|
1438
|
+
if (n.isSpreadElement(u)) l.push(u.argument);
|
|
1439
|
+
else if (a.has(c)) c.properties.push(u);
|
|
1440
|
+
else {
|
|
1441
|
+
let f = n.objectExpression([u]);
|
|
1442
|
+
a.add(f), l.push(f);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
return n.callExpression(v(t, "_$merge"), l.map((u) => a.has(u) && u.properties.some((c) => n.isObjectMethod(c, { kind: "get" })) ? n.callExpression(v(t, "_$marked"), [u]) : u));
|
|
1446
|
+
}));
|
|
1447
|
+
}
|
|
1448
|
+
function ge(e, t) {
|
|
1449
|
+
if (!n.isIdentifier(t)) return !1;
|
|
1450
|
+
let r = e.scope.getBinding(t.name);
|
|
1451
|
+
if (!r || r.scope !== e.scope || r.constantViolations.length > 0) return !1;
|
|
1452
|
+
let i = e.node.params[0], s = (a) => n.isObjectPattern(a) && a.properties.some((u) => n.isRestElement(u) && n.isIdentifier(u.argument, { name: t.name }));
|
|
1453
|
+
if (r.kind === "param") return n.isIdentifier(i, { name: t.name }) || s(i);
|
|
1454
|
+
if (!r.path.isVariableDeclarator()) return !1;
|
|
1455
|
+
if (r.path.node._whatPropsRest === !0) return !0;
|
|
1456
|
+
let { id: o, init: l } = r.path.node;
|
|
1457
|
+
return s(o) && n.isIdentifier(l) && ge(e, l);
|
|
1458
|
+
}
|
|
1459
|
+
function rt(e, t) {
|
|
1460
|
+
if (t.ssr || !ie(e)) return !1;
|
|
1461
|
+
let r = De(e), i = H(e), s = (o) => r !== null && r(o) !== null || n.isCallExpression(o) && o.arguments.length === 0 && n.isIdentifier(o.callee) && i.has(o.callee.name);
|
|
1462
|
+
return me(e).some((o) => he(e, o) && o.arguments.some((l) => n.isObjectExpression(l) && l.properties.some((a) => n.isObjectProperty(a) && y(a.key, a.computed) !== null && ze(a.value, s) || n.isSpreadElement(a) && ge(e, a.argument))));
|
|
1463
|
+
}
|
|
1464
|
+
function _(e, t = /* @__PURE__ */ new Set()) {
|
|
1465
|
+
if (n.isIdentifier(e)) t.add(e.name);
|
|
1466
|
+
else if (n.isAssignmentPattern(e)) _(e.left, t);
|
|
1467
|
+
else if (n.isRestElement(e)) _(e.argument, t);
|
|
1468
|
+
else if (n.isObjectPattern(e)) for (let r of e.properties) _(n.isRestElement(r) ? r : r.value, t);
|
|
1469
|
+
else if (n.isArrayPattern(e)) for (let r of e.elements) r && _(r, t);
|
|
1470
|
+
return t;
|
|
1471
|
+
}
|
|
1472
|
+
function Ke(e, t, r, i) {
|
|
1473
|
+
let s = qe(e, t, r, i);
|
|
1474
|
+
s !== null && (e._buildDiagnostics ??= []).push(s);
|
|
1475
|
+
}
|
|
1476
|
+
function qe(e, t, r, i) {
|
|
1477
|
+
if (e.opts?.devMetadata !== !0 || e.opts?.production === !0 || e.ssr || !i.loc) return null;
|
|
1478
|
+
let s = String(e.file?.opts?.filename || "").replace(/\\/g, "/").replace(/[?#].*$/, ""), o = String(e.opts?.projectRoot || e.file?.opts?.cwd || "").replace(/\\/g, "/").replace(/\/+$/, ""), l = o && s.startsWith(`${o}/`) ? s.slice(o.length + 1) : s, a = i.loc.start, u = typeof e.opts?.sourceLoc == "function" ? e.opts.sourceLoc(a.line, a.column) ?? a : a;
|
|
1479
|
+
return { code: t, data: r, loc: `${l}:${u.line}:${u.column + 1}` };
|
|
1480
|
+
}
|
|
1481
|
+
function it({ code: e, data: t, loc: r }) {
|
|
1482
|
+
return n.objectExpression([
|
|
1483
|
+
n.objectProperty(n.identifier("code"), n.stringLiteral(e)),
|
|
1484
|
+
n.objectProperty(n.identifier("data"), n.objectExpression(Object.entries(t).map(([i, s]) => n.objectProperty(n.identifier(i), n.stringLiteral(String(s)))))),
|
|
1485
|
+
n.objectProperty(n.identifier("loc"), n.stringLiteral(r))
|
|
1486
|
+
]);
|
|
1487
|
+
}
|
|
1488
|
+
function X(e) {
|
|
1489
|
+
return /^[A-Z]/.test($(e));
|
|
1490
|
+
}
|
|
1491
|
+
function $(e) {
|
|
1492
|
+
if (e.node.id) return e.node.id.name;
|
|
1493
|
+
let t = e.parentPath;
|
|
1494
|
+
for (; t && t.isCallExpression(); ) t = t.parentPath;
|
|
1495
|
+
return t && t.isVariableDeclarator() && n.isIdentifier(t.node.id) ? t.node.id.name : "anonymous";
|
|
1496
|
+
}
|
|
1497
|
+
function Ye(e, t, r) {
|
|
1498
|
+
let i = y(t.key, t.computed);
|
|
1499
|
+
if (i === null) return null;
|
|
1500
|
+
let s = t.value, o = null, l = !1;
|
|
1501
|
+
if (n.isAssignmentPattern(s) && (o = s.right, s = s.left, !ot(o, e.scope))) {
|
|
1502
|
+
if (!k(o, e)) return null;
|
|
1503
|
+
l = !0;
|
|
1504
|
+
}
|
|
1505
|
+
if (!n.isIdentifier(s)) return null;
|
|
1506
|
+
let a = r.getBinding(s.name);
|
|
1507
|
+
return !a || a.constantViolations.length > 0 ? null : { key: i, binding: a, fallback: o, hoist: l };
|
|
1508
|
+
}
|
|
1509
|
+
function k(e, t) {
|
|
1510
|
+
switch (e.type) {
|
|
1511
|
+
case "StringLiteral":
|
|
1512
|
+
case "NumericLiteral":
|
|
1513
|
+
case "BooleanLiteral":
|
|
1514
|
+
case "NullLiteral":
|
|
1515
|
+
case "BigIntLiteral":
|
|
1516
|
+
case "ArrowFunctionExpression":
|
|
1517
|
+
case "FunctionExpression":
|
|
1518
|
+
return !0;
|
|
1519
|
+
case "TemplateLiteral":
|
|
1520
|
+
return e.expressions.every((r) => k(r, t));
|
|
1521
|
+
case "ArrayExpression":
|
|
1522
|
+
return e.elements.every((r) => r === null || k(n.isSpreadElement(r) ? r.argument : r, t));
|
|
1523
|
+
case "ObjectExpression":
|
|
1524
|
+
return e.properties.every((r) => n.isObjectMethod(r) ? !r.computed : n.isSpreadElement(r) ? k(r.argument, t) : (!r.computed || k(r.key, t)) && k(r.value, t));
|
|
1525
|
+
case "Identifier": {
|
|
1526
|
+
let r = t.scope.getBinding(e.name);
|
|
1527
|
+
return !r || !(r.path === t || r.path.isDescendant(t));
|
|
1528
|
+
}
|
|
1529
|
+
case "MemberExpression":
|
|
1530
|
+
return k(e.object, t) && (!e.computed || k(e.property, t));
|
|
1531
|
+
case "UnaryExpression":
|
|
1532
|
+
return e.operator !== "delete" && k(e.argument, t);
|
|
1533
|
+
case "BinaryExpression":
|
|
1534
|
+
case "LogicalExpression":
|
|
1535
|
+
return k(e.left, t) && k(e.right, t);
|
|
1536
|
+
case "ConditionalExpression":
|
|
1537
|
+
return k(e.test, t) && k(e.consequent, t) && k(e.alternate, t);
|
|
1538
|
+
default:
|
|
1539
|
+
return !1;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
function st(e, t, r) {
|
|
1543
|
+
let i = y(t.key, t.computed);
|
|
1544
|
+
if (i === null) return null;
|
|
1545
|
+
let s = [], o = (l, a, u) => {
|
|
1546
|
+
if (n.isAssignmentPattern(l) && n.isObjectPattern(l.left))
|
|
1547
|
+
return !n.isObjectExpression(l.right) || l.right.properties.length > 0 ? !1 : o(l.left, a, !0);
|
|
1548
|
+
if (!n.isObjectPattern(l) || l.properties.length === 0) return !1;
|
|
1549
|
+
for (let c of l.properties) {
|
|
1550
|
+
if (!n.isObjectProperty(c)) return !1;
|
|
1551
|
+
let f = y(c.key, c.computed);
|
|
1552
|
+
if (f === null) return !1;
|
|
1553
|
+
let p = [...a, { name: f, optional: u }];
|
|
1554
|
+
if (n.isObjectPattern(c.value) || n.isAssignmentPattern(c.value) && n.isObjectPattern(c.value.left)) {
|
|
1555
|
+
if (!o(c.value, p, !1)) return !1;
|
|
1556
|
+
continue;
|
|
1557
|
+
}
|
|
1558
|
+
let d = Ye(e, { ...c, key: n.identifier("x"), computed: !1 }, r);
|
|
1559
|
+
if (d === null) return !1;
|
|
1560
|
+
s.push({ key: i, path: p, binding: d.binding, fallback: d.fallback });
|
|
1561
|
+
}
|
|
1562
|
+
return !0;
|
|
1563
|
+
};
|
|
1564
|
+
return o(t.value, [], !1) ? s : null;
|
|
1565
|
+
}
|
|
1566
|
+
function y(e, t) {
|
|
1567
|
+
return n.isIdentifier(e) && !t ? e.name : n.isStringLiteral(e) ? e.value : n.isNumericLiteral(e) ? String(e.value) : null;
|
|
1568
|
+
}
|
|
1569
|
+
function ot(e, t) {
|
|
1570
|
+
return n.isNullLiteral(e) || n.isBooleanLiteral(e) || n.isNumericLiteral(e) || n.isStringLiteral(e) || n.isBigIntLiteral(e) ? !0 : n.isTemplateLiteral(e) ? e.expressions.length === 0 : n.isIdentifier(e, { name: "undefined" }) ? !t.hasBinding("undefined") : n.isUnaryExpression(e, { operator: "void" }) && n.isNumericLiteral(e.argument);
|
|
1571
|
+
}
|
|
1572
|
+
function Ee(e, t, r, i = !1) {
|
|
1573
|
+
let s = e, o = e.parentPath;
|
|
1574
|
+
for (; o.isConditionalExpression() && s.key !== "test" || o.isLogicalExpression() && s.key === "right" || o.isArrayExpression() || o.isTSAsExpression() || o.isTSSatisfiesExpression() || o.isTSNonNullExpression(); )
|
|
1575
|
+
s = o, o = o.parentPath;
|
|
1576
|
+
if (o.isJSXExpressionContainer()) {
|
|
1577
|
+
let a = o.parentPath;
|
|
1578
|
+
return a.isJSXAttribute() ? !(i && Ze(a.parentPath.parent, a.node, r)) && at(a.parentPath.parent, a.node, r) : o.listKey !== "children" ? !1 : a.isJSXFragment() || !Y(a.node, "For", r);
|
|
1579
|
+
}
|
|
1580
|
+
let l = null;
|
|
1581
|
+
return o.isReturnStatement() ? l = o.getFunctionParent() : o.isArrowFunctionExpression() && s.key === "body" && (l = o), l === null ? !1 : l === t ? !0 : (l.isArrowFunctionExpression() || l.isFunctionExpression()) && Ee(l, t, r, !0);
|
|
1582
|
+
}
|
|
1583
|
+
function at(e, t, r) {
|
|
1584
|
+
return Y(e, "Show", r) || Y(e, "Switch", r) ? O(t) === "fallback" : Ze(e, t, r);
|
|
1585
|
+
}
|
|
1586
|
+
function Y(e, t, r) {
|
|
1587
|
+
return ce(e, r) === t;
|
|
1588
|
+
}
|
|
1589
|
+
function Ze(e, t, r) {
|
|
1590
|
+
if (!le(e) || ce(e, r) !== null) return !1;
|
|
1591
|
+
let i = e.openingElement.attributes, s = O(t);
|
|
1592
|
+
for (let o = i.indexOf(t) + 1; o < i.length; o++)
|
|
1593
|
+
if (n.isJSXSpreadAttribute(i[o]) || O(i[o]) === s) return !1;
|
|
1594
|
+
return i.some((o) => n.isJSXAttribute(o) && O(o).startsWith("client:")) ? !1 : s !== "key" && s !== "ref" && s !== "children" && !s.includes(":") && !en(s);
|
|
1595
|
+
}
|
|
1596
|
+
function Z(e, t, r, i = null) {
|
|
1597
|
+
if (r.ssr) return n.memberExpression(n.cloneNode(e), R(t), !n.isIdentifier(R(t)));
|
|
1598
|
+
let s = v(r, "_$place");
|
|
1599
|
+
s._whatPlace = !0;
|
|
1600
|
+
let o = [n.cloneNode(e), n.stringLiteral(t)];
|
|
1601
|
+
return i !== null && o.push(n.unaryExpression("void", n.numericLiteral(0)), n.cloneNode(i)), n.callExpression(s, o);
|
|
1602
|
+
}
|
|
1603
|
+
function Gt(e, t) {
|
|
1604
|
+
if (t.size === 0) return;
|
|
1605
|
+
let r = !1;
|
|
1606
|
+
n.traverseFast(e.node, (i) => {
|
|
1607
|
+
if (i.type !== "JSXSpreadAttribute") return;
|
|
1608
|
+
let s = i.argument;
|
|
1609
|
+
!n.isCallExpression(s) || !n.isIdentifier(s.callee) || !t.has(s.callee.name) || s.arguments.length === 0 || (i._whatHostProps = s, i.argument = s.arguments[0], r = !0);
|
|
1610
|
+
}), r && e.scope.crawl();
|
|
1611
|
+
}
|
|
1612
|
+
function Qt(e) {
|
|
1613
|
+
let t = e._whatHostProps;
|
|
1614
|
+
return t === void 0 ? e.argument : n.callExpression(n.cloneNode(t.callee), [e.argument, ...t.arguments.slice(1)]);
|
|
1615
|
+
}
|
|
1616
|
+
var lt = /* @__PURE__ */ new Set(["textarea", "noscript", "template"]);
|
|
1617
|
+
function er(e, t) {
|
|
1618
|
+
let r = e.node, i = r.openingElement.name;
|
|
1619
|
+
if (!n.isJSXIdentifier(i) || (ae(i.name) ? !t.ssr || !ct(e.scope.getBinding(i.name)) : mt(i.name) || lt.has(i.name))) return;
|
|
1620
|
+
let s = r.openingElement.attributes, o = (c) => n.isObjectExpression(c) && c.properties.every((f) => n.isObjectProperty(f) && !f.computed), l = (c) => c.properties.some((f) => y(f.key, !1) === "children"), a = s.filter((c) => n.isJSXSpreadAttribute(c) && !(o(c.argument) && !l(c.argument)));
|
|
1621
|
+
if (a.length === 0 || s.some((c) => n.isJSXAttribute(c) && O(c) === "children") || r.children.some((c) => !n.isJSXText(c) || /[^ \t\r\n]/.test(c.value)) || !a.every((c) => ut(c.argument) || o(c.argument))) return;
|
|
1622
|
+
let u = a.length === 1 ? a[0].argument : t.ssr ? n.objectExpression(a.map((c) => n.spreadElement(n.cloneNode(c.argument)))) : n.callExpression(v(t, "_$merge"), a.map((c) => n.cloneNode(c.argument)));
|
|
1623
|
+
r.children = [n.jsxExpressionContainer(Z(u, "children", t))], r.openingElement.selfClosing && (r.openingElement.selfClosing = !1, r.closingElement = n.jsxClosingElement(n.jsxIdentifier(i.name)));
|
|
1624
|
+
}
|
|
1625
|
+
function ct(e) {
|
|
1626
|
+
if (!e || e.kind === "module" || e.kind === "hoisted") return !1;
|
|
1627
|
+
let t = e.path.node;
|
|
1628
|
+
if (n.isClassDeclaration(t) || n.isFunction(t)) return !1;
|
|
1629
|
+
let r = n.isVariableDeclarator(t) ? t.init : null;
|
|
1630
|
+
return !(n.isFunction(r) || n.isClassExpression(r));
|
|
1631
|
+
}
|
|
1632
|
+
function ut(e) {
|
|
1633
|
+
for (; n.isMemberExpression(e) && (!e.computed || n.isStringLiteral(e.property)); ) e = e.object;
|
|
1634
|
+
return n.isIdentifier(e) || n.isThisExpression(e);
|
|
1635
|
+
}
|
|
1636
|
+
function pt(e, t) {
|
|
1637
|
+
let r = !0;
|
|
1638
|
+
for (let i of e.get("params.0.properties"))
|
|
1639
|
+
t.includes(i.node) && i.traverse({
|
|
1640
|
+
ReferencedIdentifier(s) {
|
|
1641
|
+
let o = e.scope.getOwnBinding(s.node.name);
|
|
1642
|
+
o && o.kind !== "param" && (r = !1);
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
return r;
|
|
1646
|
+
}
|
|
1647
|
+
function Ge(e, t, r, i) {
|
|
1648
|
+
let s = [
|
|
1649
|
+
...t.placed.map((o) => [o, () => Z(r, o.key, i)]),
|
|
1650
|
+
...t.live.map((o) => [o, () => ft(dt(r, o.key), o.path)])
|
|
1651
|
+
];
|
|
1652
|
+
for (let [o, l] of s) {
|
|
1653
|
+
let { key: a, binding: u } = o, c = o.fallback;
|
|
1654
|
+
if (o.hoist) {
|
|
1655
|
+
let p = e.scope.generateUidIdentifier(`${a}Default`);
|
|
1656
|
+
e.scope.push({ id: p, init: c, kind: "const" }), c = p;
|
|
1657
|
+
}
|
|
1658
|
+
for (let p of u.referencePaths)
|
|
1659
|
+
p.parentPath.isObjectProperty({ shorthand: !0 }) && p.key === "value" && (p.parent.shorthand = !1);
|
|
1660
|
+
if (c === null) {
|
|
1661
|
+
for (let p of u.referencePaths) p.replaceWith(l());
|
|
1662
|
+
continue;
|
|
1663
|
+
}
|
|
1664
|
+
if (!i.ssr && t.placed.some((p) => p.binding === u)) {
|
|
1665
|
+
for (let p of u.referencePaths) p.replaceWith(Z(r, a, i, c));
|
|
1666
|
+
continue;
|
|
1667
|
+
}
|
|
1668
|
+
let f = e.scope.generateUidIdentifier(a);
|
|
1669
|
+
for (let p of u.referencePaths)
|
|
1670
|
+
p.replaceWith(n.conditionalExpression(
|
|
1671
|
+
n.binaryExpression("===", n.assignmentExpression("=", n.cloneNode(f), l()), n.unaryExpression("void", n.numericLiteral(0))),
|
|
1672
|
+
n.cloneNode(c),
|
|
1673
|
+
n.cloneNode(f)
|
|
1674
|
+
));
|
|
1675
|
+
e.scope.push({ id: f });
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
function ft(e, t) {
|
|
1679
|
+
if (t === void 0) return e;
|
|
1680
|
+
for (let { name: r, optional: i } of t) {
|
|
1681
|
+
let s = R(r);
|
|
1682
|
+
e = i ? n.optionalMemberExpression(e, s, !n.isIdentifier(s), !0) : n.memberExpression(e, s, !n.isIdentifier(s));
|
|
1683
|
+
}
|
|
1684
|
+
return e;
|
|
1685
|
+
}
|
|
1686
|
+
function dt(e, t) {
|
|
1687
|
+
let r = R(t);
|
|
1688
|
+
return n.memberExpression(n.cloneNode(e), r, !n.isIdentifier(r));
|
|
1689
|
+
}
|
|
1690
|
+
function Qe(e, t, r, i) {
|
|
1691
|
+
let s = t.rest === null ? t.others : t.others.slice(0, -1), o = [];
|
|
1692
|
+
if (s.length > 0 && o.push(n.variableDeclarator(n.objectPattern(s), n.cloneNode(r))), t.rest !== null) {
|
|
1693
|
+
let l = [.../* @__PURE__ */ new Set([...t.placed.map((f) => f.key), ...t.live.map((f) => f.key), ...s.map((f) => y(f.key, f.computed))])].map((f) => n.stringLiteral(f)), a = i.ssr ? e.hub.addHelper("objectWithoutProperties") : v(i, "_$omit"), u = n.callExpression(a, [n.cloneNode(r), n.arrayExpression(l)]), c = n.variableDeclarator(t.rest.argument, u);
|
|
1694
|
+
c._whatPropsRest = !0, (e.node._whatPropsRests ||= []).push(t.rest.argument.name), o.push(c);
|
|
1695
|
+
}
|
|
1696
|
+
return o;
|
|
1697
|
+
}
|
|
1698
|
+
function mt(e) {
|
|
1699
|
+
return an.has(String(e).toLowerCase());
|
|
1700
|
+
}
|
|
1701
|
+
function ye(e) {
|
|
1702
|
+
return e ? n.isJSXExpressionContainer(e) ? e.expression : n.isStringLiteral(e) ? e : n.stringLiteral(e.value || "") : n.booleanLiteral(!0);
|
|
1703
|
+
}
|
|
1704
|
+
function nr(e, t) {
|
|
1705
|
+
let r = xe(O(e[t]));
|
|
1706
|
+
for (let i = t + 1; i < e.length; i += 1) {
|
|
1707
|
+
let s = e[i];
|
|
1708
|
+
if (!n.isJSXSpreadAttribute(s) && xe(O(s)) === r)
|
|
1709
|
+
return !0;
|
|
1710
|
+
}
|
|
1711
|
+
return !1;
|
|
1712
|
+
}
|
|
1713
|
+
function xe(e) {
|
|
1714
|
+
return en(e) && !e.includes("|") ? e.toLowerCase() : pn(e);
|
|
1715
|
+
}
|
|
1716
|
+
function O(e) {
|
|
1717
|
+
return n.isJSXNamespacedName(e.name) ? `${e.name.namespace.name}:${e.name.name.name}` : typeof e.name.name == "string" ? e.name.name : String(e.name.name);
|
|
1718
|
+
}
|
|
1719
|
+
function R(e) {
|
|
1720
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? n.identifier(e) : n.stringLiteral(e);
|
|
1721
|
+
}
|
|
1722
|
+
function en(e) {
|
|
1723
|
+
return !!e && e.length > 2 && /^on/i.test(e);
|
|
1724
|
+
}
|
|
1725
|
+
function tr(e, t) {
|
|
1726
|
+
if (t.length === 0) return e;
|
|
1727
|
+
let r = e;
|
|
1728
|
+
for (let i of t)
|
|
1729
|
+
switch (i) {
|
|
1730
|
+
case "preventDefault":
|
|
1731
|
+
r = n.arrowFunctionExpression(
|
|
1732
|
+
[n.identifier("e")],
|
|
1733
|
+
n.blockStatement([
|
|
1734
|
+
n.expressionStatement(
|
|
1735
|
+
n.callExpression(
|
|
1736
|
+
n.memberExpression(n.identifier("e"), n.identifier("preventDefault")),
|
|
1737
|
+
[]
|
|
1738
|
+
)
|
|
1739
|
+
),
|
|
1740
|
+
n.expressionStatement(
|
|
1741
|
+
n.callExpression(r, [n.identifier("e")])
|
|
1742
|
+
)
|
|
1743
|
+
])
|
|
1744
|
+
);
|
|
1745
|
+
break;
|
|
1746
|
+
case "stopPropagation":
|
|
1747
|
+
r = n.arrowFunctionExpression(
|
|
1748
|
+
[n.identifier("e")],
|
|
1749
|
+
n.blockStatement([
|
|
1750
|
+
n.expressionStatement(
|
|
1751
|
+
n.callExpression(
|
|
1752
|
+
n.memberExpression(n.identifier("e"), n.identifier("stopPropagation")),
|
|
1753
|
+
[]
|
|
1754
|
+
)
|
|
1755
|
+
),
|
|
1756
|
+
n.expressionStatement(
|
|
1757
|
+
n.callExpression(r, [n.identifier("e")])
|
|
1758
|
+
)
|
|
1759
|
+
])
|
|
1760
|
+
);
|
|
1761
|
+
break;
|
|
1762
|
+
case "self":
|
|
1763
|
+
r = n.arrowFunctionExpression(
|
|
1764
|
+
[n.identifier("e")],
|
|
1765
|
+
n.blockStatement([
|
|
1766
|
+
n.ifStatement(
|
|
1767
|
+
n.binaryExpression(
|
|
1768
|
+
"===",
|
|
1769
|
+
n.memberExpression(n.identifier("e"), n.identifier("target")),
|
|
1770
|
+
n.memberExpression(n.identifier("e"), n.identifier("currentTarget"))
|
|
1771
|
+
),
|
|
1772
|
+
n.expressionStatement(
|
|
1773
|
+
n.callExpression(r, [n.identifier("e")])
|
|
1774
|
+
)
|
|
1775
|
+
)
|
|
1776
|
+
])
|
|
1777
|
+
);
|
|
1778
|
+
break;
|
|
1779
|
+
case "once":
|
|
1780
|
+
case "capture":
|
|
1781
|
+
case "passive":
|
|
1782
|
+
break;
|
|
1783
|
+
}
|
|
1784
|
+
return r;
|
|
1785
|
+
}
|
|
1786
|
+
function ht(e, t, r) {
|
|
1787
|
+
if (!mn.has(e)) return !1;
|
|
1788
|
+
let i = O(t[r]);
|
|
1789
|
+
if (!dn.has(i)) return !1;
|
|
1790
|
+
if (e !== "input" || i !== "value" && i !== "defaultValue") return !0;
|
|
1791
|
+
let s = t.find((o) => !n.isJSXSpreadAttribute(o) && O(o) === "type");
|
|
1792
|
+
return !(s && n.isStringLiteral(s.value) && hn.has(s.value.value.toLowerCase()));
|
|
1793
|
+
}
|
|
1794
|
+
function gt(e) {
|
|
1795
|
+
if (n.isJSXText(e)) return !0;
|
|
1796
|
+
if (n.isJSXExpressionContainer(e)) return !1;
|
|
1797
|
+
if (n.isJSXElement(e)) {
|
|
1798
|
+
let t = e.openingElement;
|
|
1799
|
+
if (le(e)) return !1;
|
|
1800
|
+
for (let [r, i] of t.attributes.entries()) {
|
|
1801
|
+
if (n.isJSXSpreadAttribute(i)) return !1;
|
|
1802
|
+
let s = i.value;
|
|
1803
|
+
if (n.isJSXExpressionContainer(s) || ht(t.name.name, t.attributes, r)) return !1;
|
|
1804
|
+
}
|
|
1805
|
+
return e.children.every(gt);
|
|
1806
|
+
}
|
|
1807
|
+
return !1;
|
|
1808
|
+
}
|
|
1809
|
+
function rr(e) {
|
|
1810
|
+
return n.isJSXSpreadAttribute(e) ? !0 : e.value ? n.isJSXExpressionContainer(e.value) : !1;
|
|
1811
|
+
}
|
|
1812
|
+
var Et = /* @__PURE__ */ new Set([
|
|
1813
|
+
"animate",
|
|
1814
|
+
"animateMotion",
|
|
1815
|
+
"animateTransform",
|
|
1816
|
+
"circle",
|
|
1817
|
+
"clipPath",
|
|
1818
|
+
"defs",
|
|
1819
|
+
"desc",
|
|
1820
|
+
"ellipse",
|
|
1821
|
+
"feBlend",
|
|
1822
|
+
"feColorMatrix",
|
|
1823
|
+
"feComponentTransfer",
|
|
1824
|
+
"feComposite",
|
|
1825
|
+
"feConvolveMatrix",
|
|
1826
|
+
"feDiffuseLighting",
|
|
1827
|
+
"feDisplacementMap",
|
|
1828
|
+
"feDistantLight",
|
|
1829
|
+
"feDropShadow",
|
|
1830
|
+
"feFlood",
|
|
1831
|
+
"feFuncA",
|
|
1832
|
+
"feFuncB",
|
|
1833
|
+
"feFuncG",
|
|
1834
|
+
"feFuncR",
|
|
1835
|
+
"feGaussianBlur",
|
|
1836
|
+
"feImage",
|
|
1837
|
+
"feMerge",
|
|
1838
|
+
"feMergeNode",
|
|
1839
|
+
"feMorphology",
|
|
1840
|
+
"feOffset",
|
|
1841
|
+
"fePointLight",
|
|
1842
|
+
"feSpecularLighting",
|
|
1843
|
+
"feSpotLight",
|
|
1844
|
+
"feTile",
|
|
1845
|
+
"feTurbulence",
|
|
1846
|
+
"filter",
|
|
1847
|
+
"foreignObject",
|
|
1848
|
+
"g",
|
|
1849
|
+
"image",
|
|
1850
|
+
"line",
|
|
1851
|
+
"linearGradient",
|
|
1852
|
+
"marker",
|
|
1853
|
+
"mask",
|
|
1854
|
+
"metadata",
|
|
1855
|
+
"mpath",
|
|
1856
|
+
"path",
|
|
1857
|
+
"pattern",
|
|
1858
|
+
"polygon",
|
|
1859
|
+
"polyline",
|
|
1860
|
+
"radialGradient",
|
|
1861
|
+
"rect",
|
|
1862
|
+
"set",
|
|
1863
|
+
"stop",
|
|
1864
|
+
"switch",
|
|
1865
|
+
"symbol",
|
|
1866
|
+
"text",
|
|
1867
|
+
"textPath",
|
|
1868
|
+
"tspan",
|
|
1869
|
+
"use",
|
|
1870
|
+
"view"
|
|
1871
|
+
]), bt = /* @__PURE__ */ new Set([
|
|
1872
|
+
"annotation",
|
|
1873
|
+
"annotation-xml",
|
|
1874
|
+
"maction",
|
|
1875
|
+
"menclose",
|
|
1876
|
+
"merror",
|
|
1877
|
+
"mfenced",
|
|
1878
|
+
"mfrac",
|
|
1879
|
+
"mi",
|
|
1880
|
+
"mmultiscripts",
|
|
1881
|
+
"mn",
|
|
1882
|
+
"mo",
|
|
1883
|
+
"mover",
|
|
1884
|
+
"mpadded",
|
|
1885
|
+
"mphantom",
|
|
1886
|
+
"mprescripts",
|
|
1887
|
+
"mroot",
|
|
1888
|
+
"mrow",
|
|
1889
|
+
"ms",
|
|
1890
|
+
"mspace",
|
|
1891
|
+
"msqrt",
|
|
1892
|
+
"mstyle",
|
|
1893
|
+
"msub",
|
|
1894
|
+
"msubsup",
|
|
1895
|
+
"msup",
|
|
1896
|
+
"mtable",
|
|
1897
|
+
"mtd",
|
|
1898
|
+
"mtext",
|
|
1899
|
+
"mtr",
|
|
1900
|
+
"munder",
|
|
1901
|
+
"munderover",
|
|
1902
|
+
"semantics"
|
|
1903
|
+
]);
|
|
1904
|
+
function yt(e, t, r) {
|
|
1905
|
+
if (e === "svg") return on.has(t) ? "html" : "svg";
|
|
1906
|
+
if (e !== "math") return e;
|
|
1907
|
+
if (sn.has(t)) return "mathtext";
|
|
1908
|
+
if (t === "annotation-xml") {
|
|
1909
|
+
let i = r.find((s) => n.isJSXAttribute(s) && O(s) === "encoding");
|
|
1910
|
+
if (i && n.isStringLiteral(i.value) && nn.has(i.value.value.toLowerCase()))
|
|
1911
|
+
return "html";
|
|
1912
|
+
}
|
|
1913
|
+
return "math";
|
|
1914
|
+
}
|
|
1915
|
+
function ir(e) {
|
|
1916
|
+
let t = (r, i, s = !1) => {
|
|
1917
|
+
if (!(!r || typeof r != "object")) {
|
|
1918
|
+
if (Array.isArray(r)) {
|
|
1919
|
+
for (let o of r) t(o, i, s);
|
|
1920
|
+
return;
|
|
1921
|
+
}
|
|
1922
|
+
if (r.type === "JSXElement") {
|
|
1923
|
+
let o = r.openingElement.name;
|
|
1924
|
+
if (n.isJSXIdentifier(o) && !ae(o.name)) {
|
|
1925
|
+
let l = o.name, a = l === "svg" ? "svg" : l === "math" ? "math" : i === "mathtext" ? rn.has(l) ? "math" : "html" : i !== null ? i : Et.has(l) ? "svg" : bt.has(l) ? "math" : "html";
|
|
1926
|
+
r._whatNs = a;
|
|
1927
|
+
let u = yt(a, l, r.openingElement.attributes), c = s || a === "svg" || a === "math";
|
|
1928
|
+
t(r.openingElement.attributes, u, c), t(r.children, u, c);
|
|
1929
|
+
} else
|
|
1930
|
+
r._whatNs = i, i === "svg" || i === "math" ? r._whatPlacedNs = i === "svg" ? 1 : 2 : s && (r._whatPlacedNs = 0), t(r.openingElement.attributes, i, s), t(r.children, i, s);
|
|
1931
|
+
return;
|
|
1932
|
+
}
|
|
1933
|
+
if (r.type === "JSXFragment") {
|
|
1934
|
+
r._whatNs = i, t(r.children, i, s);
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1937
|
+
for (let o of n.VISITOR_KEYS[r.type] || []) t(r[o], i, s);
|
|
1938
|
+
}
|
|
1939
|
+
};
|
|
1940
|
+
t(e, null);
|
|
1941
|
+
}
|
|
1942
|
+
function sr(e) {
|
|
1943
|
+
let t = e.parent;
|
|
1944
|
+
return t ? n.isLogicalExpression(t) ? e.key === "right" : n.isConditionalExpression(t) ? e.key === "consequent" || e.key === "alternate" : n.isOptionalCallExpression(t) || n.isOptionalMemberExpression(t) ? e.key !== "callee" && e.key !== "object" : !1 : !1;
|
|
1945
|
+
}
|
|
1946
|
+
function or(e, t) {
|
|
1947
|
+
let { node: r } = e, i = Ie(r.openingElement.name.name, t), s = (u) => n.isJSXElement(u) && (ce(u, t) === "Match" || i && n.isJSXIdentifier(u.openingElement.name, { name: "Match" }));
|
|
1948
|
+
if (!r.children.some(s) && !bn(r.openingElement.name.name, t)) return null;
|
|
1949
|
+
let o = (u) => {
|
|
1950
|
+
throw we(
|
|
1951
|
+
e,
|
|
1952
|
+
t,
|
|
1953
|
+
`<Switch> ${u}. The compiler needs to read its arms statically. Write them out: <Switch fallback={...}><Match when={a}>\u2026</Match><Match when={b}>\u2026</Match></Switch>`
|
|
1954
|
+
);
|
|
1955
|
+
}, l = null;
|
|
1956
|
+
for (let u of r.openingElement.attributes)
|
|
1957
|
+
n.isJSXSpreadAttribute(u) && o("cannot take a spread attribute"), O(u) === "fallback" && (l = ye(u.value));
|
|
1958
|
+
let a = [];
|
|
1959
|
+
for (let u of r.children) {
|
|
1960
|
+
if (n.isJSXText(u)) {
|
|
1961
|
+
Se(u.value) && o("cannot mix text with its <Match> arms");
|
|
1962
|
+
continue;
|
|
1963
|
+
}
|
|
1964
|
+
if (n.isJSXExpressionContainer(u)) {
|
|
1965
|
+
if (n.isJSXEmptyExpression(u.expression)) continue;
|
|
1966
|
+
o("cannot read its arms from an expression child");
|
|
1967
|
+
}
|
|
1968
|
+
s(u) || o("cannot mix other elements with its <Match> arms");
|
|
1969
|
+
let c = null;
|
|
1970
|
+
for (let f of u.openingElement.attributes)
|
|
1971
|
+
n.isJSXAttribute(f) && O(f) === "when" && (c = ye(f.value));
|
|
1972
|
+
c || o('has a <Match> with no "when" prop'), a.push({ when: c, children: u.children });
|
|
1973
|
+
}
|
|
1974
|
+
return a.length === 0 && o("has no <Match> arms"), { fallback: l, arms: a };
|
|
1975
|
+
}
|
|
1976
|
+
function ar(e, t, r, i) {
|
|
1977
|
+
if (t.length === 0) return;
|
|
1978
|
+
let s = null;
|
|
1979
|
+
for (let l of e.node.body)
|
|
1980
|
+
if (n.isImportDeclaration(l) && r.includes(l.source.value)) {
|
|
1981
|
+
s = l;
|
|
1982
|
+
break;
|
|
1983
|
+
}
|
|
1984
|
+
if (!s) {
|
|
1985
|
+
e.unshiftContainer("body", n.importDeclaration(t, n.stringLiteral(i)));
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
let o = new Set(s.specifiers.map((l) => l.local.name));
|
|
1989
|
+
for (let l of t)
|
|
1990
|
+
o.has(l.local.name) || s.specifiers.push(l);
|
|
1991
|
+
}
|
|
1992
|
+
export {
|
|
1993
|
+
wt as EVENT_OPTION_MODIFIERS,
|
|
1994
|
+
ar as addImports,
|
|
1995
|
+
ir as annotateNamespaces,
|
|
1996
|
+
Ft as captureEventName,
|
|
1997
|
+
Rt as checkElementName,
|
|
1998
|
+
Nt as checkIslandProp,
|
|
1999
|
+
At as checkStaticAttribute,
|
|
2000
|
+
Mt as checkStaticRawText,
|
|
2001
|
+
ke as codedCompileError,
|
|
2002
|
+
we as compileError,
|
|
2003
|
+
_e as componentCallee,
|
|
2004
|
+
ce as controlFlowTag,
|
|
2005
|
+
tr as createEventHandler,
|
|
2006
|
+
Xt as deferPlacedProps,
|
|
2007
|
+
it as diagnosticRecord,
|
|
2008
|
+
Dt as directiveValue,
|
|
2009
|
+
$t as eventType,
|
|
2010
|
+
O as getAttrName,
|
|
2011
|
+
ye as getAttributeValue,
|
|
2012
|
+
jt as getBindingProperty,
|
|
2013
|
+
Ot as hasEventModifiers,
|
|
2014
|
+
v as helper,
|
|
2015
|
+
vt as helperLocals,
|
|
2016
|
+
Qt as hostSpreadArgument,
|
|
2017
|
+
B as importedFrom,
|
|
2018
|
+
kt as initFileState,
|
|
2019
|
+
Ct as isBindingAttribute,
|
|
2020
|
+
le as isComponentElement,
|
|
2021
|
+
sr as isConditionallyEvaluated,
|
|
2022
|
+
rr as isDynamicAttr,
|
|
2023
|
+
en as isEventAttrName,
|
|
2024
|
+
ht as isFieldProp,
|
|
2025
|
+
Bt as isHydrateRootArgument,
|
|
2026
|
+
nr as isShadowedAttr,
|
|
2027
|
+
Ze as isSlotAttribute,
|
|
2028
|
+
gt as isStaticChild,
|
|
2029
|
+
mt as isVoidHtmlElement,
|
|
2030
|
+
P as isWhatModuleSource,
|
|
2031
|
+
Tt as islandOptions,
|
|
2032
|
+
qt as keepCleanupValues,
|
|
2033
|
+
Zt as liveHelperArgs,
|
|
2034
|
+
Wt as lowerLiveReturns,
|
|
2035
|
+
Ht as markHookResults,
|
|
2036
|
+
Jt as markPropFieldReads,
|
|
2037
|
+
Pt as memoBranchValues,
|
|
2038
|
+
Ut as memoLiveLets,
|
|
2039
|
+
Se as normalizeJsxText,
|
|
2040
|
+
_t as parseEventModifiers,
|
|
2041
|
+
R as propKey,
|
|
2042
|
+
Vt as readPropFields,
|
|
2043
|
+
or as readSwitch,
|
|
2044
|
+
It as recordName,
|
|
2045
|
+
Lt as renderFunctionChild,
|
|
2046
|
+
er as spreadChildren,
|
|
2047
|
+
En as uniqueName,
|
|
2048
|
+
J as unsafeMarkup,
|
|
2049
|
+
Gt as unwrapHostSpreads,
|
|
2050
|
+
Kt as warnDerivedPropOnce,
|
|
2051
|
+
Yt as warnLiveCleanup,
|
|
2052
|
+
zt as warnStateReadOnce
|
|
2053
|
+
};
|