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,1669 @@
|
|
|
1
|
+
// src/babel/dom.js
|
|
2
|
+
import { RAW_TEXT_ELEMENTS as Ye, TEXT_ONLY_ELEMENTS as kn, INNER_HTML_PROPS as Ze, ATTRIBUTE_ALIASES as Cn, attributeName as U, markupName as An, isEnumeratedAttr as Ae } from "../tables/markup-rules.min.js";
|
|
3
|
+
import { t as e } from "./types.min.js";
|
|
4
|
+
import {
|
|
5
|
+
EVENT_OPTION_MODIFIERS as Ln,
|
|
6
|
+
captureEventName as Oe,
|
|
7
|
+
compileError as In,
|
|
8
|
+
componentCallee as Nn,
|
|
9
|
+
createEventHandler as Qe,
|
|
10
|
+
eventType as Ve,
|
|
11
|
+
getAttrName as C,
|
|
12
|
+
getAttributeValue as J,
|
|
13
|
+
getBindingProperty as en,
|
|
14
|
+
hasEventModifiers as pe,
|
|
15
|
+
controlFlowTag as Le,
|
|
16
|
+
isBindingAttribute as Ie,
|
|
17
|
+
isComponentElement as Q,
|
|
18
|
+
isConditionallyEvaluated as Jn,
|
|
19
|
+
isDynamicAttr as nn,
|
|
20
|
+
isEventAttrName as Ee,
|
|
21
|
+
isFieldProp as Ne,
|
|
22
|
+
isHydrateRootArgument as Pn,
|
|
23
|
+
isShadowedAttr as H,
|
|
24
|
+
isSlotAttribute as Xn,
|
|
25
|
+
isStaticChild as rn,
|
|
26
|
+
isVoidHtmlElement as Dn,
|
|
27
|
+
normalizeJsxText as te,
|
|
28
|
+
parseEventModifiers as tn,
|
|
29
|
+
propKey as G,
|
|
30
|
+
addImports as ze,
|
|
31
|
+
helper as h,
|
|
32
|
+
helperLocals as ee,
|
|
33
|
+
readSwitch as Mn,
|
|
34
|
+
uniqueName as P,
|
|
35
|
+
checkElementName as Tn,
|
|
36
|
+
checkIslandProp as Be,
|
|
37
|
+
checkStaticAttribute as Rn,
|
|
38
|
+
checkStaticRawText as jn,
|
|
39
|
+
directiveValue as On,
|
|
40
|
+
islandOptions as Vn,
|
|
41
|
+
renderFunctionChild as zn,
|
|
42
|
+
diagnosticRecord as Bn,
|
|
43
|
+
hostSpreadArgument as _e
|
|
44
|
+
} from "./common.min.js";
|
|
45
|
+
import {
|
|
46
|
+
buildEachValue as Wn,
|
|
47
|
+
buildWhenCondition as sn,
|
|
48
|
+
isHookResultRead as Se,
|
|
49
|
+
isPotentiallyReactive as D,
|
|
50
|
+
isSignalIdentifier as qn,
|
|
51
|
+
isUncertainReactive as on
|
|
52
|
+
} from "./reactivity.min.js";
|
|
53
|
+
import { enterJsxRoot as Gn } from "./jsx-root.min.js";
|
|
54
|
+
import { bindingMetadata as fe, componentMetadata as We } from "./dev-metadata.min.js";
|
|
55
|
+
import { findMappedJsx as Kn, islandKey as Un, keyIndex as Hn, listSlot as Je, liveKey as he, readItemThroughAccessor as Yn, rowField as ln, rowItemUnread as Zn, withItem as qe } from "./lists.min.js";
|
|
56
|
+
import { hasNoSelectorPragma as an, lowerRowSelectors as Qn } from "./auto-selector.min.js";
|
|
57
|
+
var ei = /* @__PURE__ */ new Set([
|
|
58
|
+
"click",
|
|
59
|
+
"input",
|
|
60
|
+
"change",
|
|
61
|
+
"keydown",
|
|
62
|
+
"keyup",
|
|
63
|
+
"submit",
|
|
64
|
+
"focusin",
|
|
65
|
+
"focusout",
|
|
66
|
+
"mousedown",
|
|
67
|
+
"mouseup"
|
|
68
|
+
]);
|
|
69
|
+
function Pe(n, i, r, t = null, s = !1) {
|
|
70
|
+
let o = [], l = (p) => {
|
|
71
|
+
for (let f of p)
|
|
72
|
+
if (e.isJSXText(f)) {
|
|
73
|
+
let E = te(f.value);
|
|
74
|
+
if (!E) continue;
|
|
75
|
+
let g = o[o.length - 1];
|
|
76
|
+
g && g.kind === "text" ? g.text += E : o.push({ kind: "text", text: E, node: f });
|
|
77
|
+
} else e.isJSXFragment(f) ? l(f.children) : e.isJSXExpressionContainer(f) ? e.isJSXEmptyExpression(f.expression) || o.push({ kind: "dynamic", node: f }) : e.isJSXElement(f) && o.push({ kind: Q(f) || he(f, r) !== null ? "dynamic" : "element", node: f });
|
|
78
|
+
};
|
|
79
|
+
l(n);
|
|
80
|
+
let c = "", a = 0, x = !1, d = [];
|
|
81
|
+
for (let p = 0; p < o.length; p++) {
|
|
82
|
+
let f = o[p];
|
|
83
|
+
if (s === 2 && f.kind !== "text") {
|
|
84
|
+
let E = o.slice(p).map(($) => $.kind === "text" ? e.stringLiteral($.text) : e.isJSXExpressionContainer($.node) ? $.node.expression : $.node), g = E.length === 1 ? f.node : e.jsxExpressionContainer(e.arrayExpression(E));
|
|
85
|
+
d.push({ kind: "dynamic", node: g, marker: p === 0 ? void 0 : null, placeholder: !1 });
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (f.kind === "text")
|
|
89
|
+
i && t !== null ? (jn(f.node, t, f.text, r), c += f.text) : i && (c += ti(f.text)), d.push({ kind: "text", index: a }), a++, x = !0;
|
|
90
|
+
else if (f.kind === "element")
|
|
91
|
+
i && (c += be(f.node, r)), d.push({ kind: "element", node: f.node, index: a }), a++, x = !1;
|
|
92
|
+
else {
|
|
93
|
+
let E = o[p + 1], g, $ = !1;
|
|
94
|
+
if (E === void 0)
|
|
95
|
+
g = o.length === 1 ? void 0 : null;
|
|
96
|
+
else if (E.kind === "element" || E.kind === "text" && !x)
|
|
97
|
+
g = a;
|
|
98
|
+
else {
|
|
99
|
+
if (s) return Pe(n, i, r, t, 2);
|
|
100
|
+
i && (c += "<!>"), g = a, $ = !0, a++, x = !1;
|
|
101
|
+
}
|
|
102
|
+
d.push({ kind: "dynamic", node: f.node, marker: g, placeholder: $ });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { html: c, entries: d };
|
|
106
|
+
}
|
|
107
|
+
function cn(n, i) {
|
|
108
|
+
i._noSelector = an(n);
|
|
109
|
+
let r = n, t = !1;
|
|
110
|
+
if (e.isArrowFunctionExpression(n) && n.params.length === 0 && (r = n.body, t = !0), e.isConditionalExpression(r)) {
|
|
111
|
+
let o = oe(r.consequent, i), l = oe(r.alternate, i);
|
|
112
|
+
if (o || l) {
|
|
113
|
+
let c = e.conditionalExpression(
|
|
114
|
+
r.test,
|
|
115
|
+
o || r.consequent,
|
|
116
|
+
l || r.alternate
|
|
117
|
+
);
|
|
118
|
+
return t ? e.arrowFunctionExpression([], c) : c;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
if (e.isLogicalExpression(r) && (r.operator === "&&" || r.operator === "||")) {
|
|
123
|
+
let o = oe(r.right, i);
|
|
124
|
+
if (o) {
|
|
125
|
+
let l = e.logicalExpression(r.operator, r.left, o);
|
|
126
|
+
return t ? e.arrowFunctionExpression([], l) : l;
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return oe(r, i);
|
|
131
|
+
}
|
|
132
|
+
function oe(n, i) {
|
|
133
|
+
let r = Kn(n, i, !0);
|
|
134
|
+
if (!r) return null;
|
|
135
|
+
let { mapFn: t, returnExpr: s, keyAttr: o, keyValue: l } = r, c = s.openingElement.attributes;
|
|
136
|
+
s.openingElement.attributes = c.filter((b) => b !== o);
|
|
137
|
+
let a = n, x = i._noSelector || i.opts?.autoSelector === !1;
|
|
138
|
+
for (; !x && a; )
|
|
139
|
+
x = an(a), a = e.isCallExpression(a) || e.isOptionalCallExpression(a) ? a.callee : e.isMemberExpression(a) || e.isOptionalMemberExpression(a) ? a.object : null;
|
|
140
|
+
x || Qn(s, t, i);
|
|
141
|
+
let d = n.callee.object, p = e.arrowFunctionExpression([], d), f = t.params[0] ? e.cloneNode(t.params[0], !0) : e.identifier("_item"), E = Hn(r), g = e.arrowFunctionExpression(E === null ? [f] : [f, e.identifier(E)], e.cloneNode(l, !0)), $ = P(i, "_item$"), u = Yn(t, l, () => h(i, "_$item"), $, P(i, "_i$"));
|
|
142
|
+
u && (s._whatRowCell = $);
|
|
143
|
+
let m = t;
|
|
144
|
+
if (!u && Zn(t, l)) {
|
|
145
|
+
let b = P(i, "_i$");
|
|
146
|
+
m = e.arrowFunctionExpression(
|
|
147
|
+
[e.identifier($), e.identifier(b)],
|
|
148
|
+
e.callExpression(t, [e.callExpression(h(i, "_$item"), [e.identifier($)]), e.identifier(b)])
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
let _ = [
|
|
152
|
+
e.objectProperty(e.identifier("key"), g),
|
|
153
|
+
e.objectProperty(e.identifier(u || m !== t ? "follow" : "raw"), e.booleanLiteral(!0))
|
|
154
|
+
];
|
|
155
|
+
u && un(t) && _.push(pn(i));
|
|
156
|
+
let S = Je(n);
|
|
157
|
+
S !== null && _.push(e.objectProperty(e.identifier("slot"), S));
|
|
158
|
+
let y = e.callExpression(h(i, "_$mapArray"), [p, m, e.objectExpression(_)]);
|
|
159
|
+
return y._whatList = !0, y;
|
|
160
|
+
}
|
|
161
|
+
function un(n) {
|
|
162
|
+
let i = !1;
|
|
163
|
+
return e.traverseFast(n, (r) => {
|
|
164
|
+
i || (e.isJSXElement(r) && Q(r) ? i = !0 : (e.isJSXElement(r) || e.isJSXFragment(r)) && (i = r.children.some((t) => e.isJSXExpressionContainer(t) && ni(t.expression))));
|
|
165
|
+
}), i;
|
|
166
|
+
}
|
|
167
|
+
function ni(n) {
|
|
168
|
+
if (!X(n) || ln(n) !== null) return !1;
|
|
169
|
+
let i = !1;
|
|
170
|
+
return e.traverseFast(n, (r) => {
|
|
171
|
+
e.isCallExpression(r) && r.callee._whatRowItem === !0 && (i = !0);
|
|
172
|
+
}), i;
|
|
173
|
+
}
|
|
174
|
+
function pn(n) {
|
|
175
|
+
return e.objectProperty(e.identifier("fields"), e.callExpression(h(n, "_$rowFields"), []));
|
|
176
|
+
}
|
|
177
|
+
var ii = /^[^\s"'=<>`&]+$/;
|
|
178
|
+
function Ge(n, i) {
|
|
179
|
+
let r = /* @__PURE__ */ new Set();
|
|
180
|
+
for (let t = i + 1; t < n.length; t++) {
|
|
181
|
+
let s = n[t];
|
|
182
|
+
if (e.isJSXSpreadAttribute(s)) continue;
|
|
183
|
+
let o = C(s);
|
|
184
|
+
if (o === "key" || fn(o)) continue;
|
|
185
|
+
if (Ee(o)) {
|
|
186
|
+
r.add(o.toLowerCase());
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
r.add(o);
|
|
190
|
+
let l = U(o);
|
|
191
|
+
l !== o && r.add(l);
|
|
192
|
+
for (let [c, a] of Cn) a === o && r.add(c);
|
|
193
|
+
if (o.startsWith("xlink") && o.length > 6) {
|
|
194
|
+
let c = o.slice(o[5] === ":" ? 6 : 5).toLowerCase();
|
|
195
|
+
r.add("xlink:" + c).add("xlink" + c[0].toUpperCase() + c.slice(1));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return r.size === 0 ? [] : [e.arrayExpression([...r].map((t) => e.stringLiteral(t)))];
|
|
199
|
+
}
|
|
200
|
+
function fn(n) {
|
|
201
|
+
return n.startsWith("bind:") || n.startsWith("client:");
|
|
202
|
+
}
|
|
203
|
+
function ye(n, i) {
|
|
204
|
+
if (e.isIdentifier(n)) return !1;
|
|
205
|
+
let r = (t) => D(t, i.signalNames, i.importedIdentifiers);
|
|
206
|
+
return e.isCallExpression(n) && n.arguments.length > 0 && n.callee._whatRowItem !== !0 ? !(e.isMemberExpression(n.callee) && !n.callee.computed && e.isIdentifier(n.callee.object) && Se(n.callee, i.signalNames)) && r(n.callee) || n.arguments.some((s) => r(e.isSpreadElement(s) ? s.argument : s)) : r(n);
|
|
207
|
+
}
|
|
208
|
+
function ri(n, i, r) {
|
|
209
|
+
let t = n.findLastIndex((o) => e.isJSXSpreadAttribute(o));
|
|
210
|
+
if (t === -1) return !1;
|
|
211
|
+
let s = !1;
|
|
212
|
+
for (let o = 0; o < n.length; o++) {
|
|
213
|
+
let l = n[o];
|
|
214
|
+
if (e.isJSXSpreadAttribute(l)) {
|
|
215
|
+
o < t && (s = !0);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
let c = C(l);
|
|
219
|
+
dn(c, r) || o < t && c !== "key" && c !== "ref" && (!En(n, o, i) || mn(n, o, r)) && !H(n, o) && (s = !0);
|
|
220
|
+
}
|
|
221
|
+
return s;
|
|
222
|
+
}
|
|
223
|
+
function dn(n, i) {
|
|
224
|
+
return fn(n) || n.includes("|") || Ee(n) && pe(n, i);
|
|
225
|
+
}
|
|
226
|
+
function mn(n, i, r) {
|
|
227
|
+
return n.some((t, s) => s > i && e.isJSXSpreadAttribute(t) && ye(t.argument, r));
|
|
228
|
+
}
|
|
229
|
+
function En(n, i, r) {
|
|
230
|
+
let t = n[i], s = C(t);
|
|
231
|
+
return !e.isJSXExpressionContainer(t.value) && Xe(n, i, r) && !H(n, i) && s !== "key" && !Ee(s) && !s.startsWith("bind:") && !s.includes("|");
|
|
232
|
+
}
|
|
233
|
+
function Xe(n, i, r) {
|
|
234
|
+
if (Ne(r, n, i)) return !1;
|
|
235
|
+
for (let t = 0; t < i; t++) {
|
|
236
|
+
let s = n[t];
|
|
237
|
+
if (e.isJSXSpreadAttribute(s) || C(s) === "classList" && U(C(n[i])) === "class") return !1;
|
|
238
|
+
}
|
|
239
|
+
return !0;
|
|
240
|
+
}
|
|
241
|
+
function be(n, i) {
|
|
242
|
+
if (!e.isJSXElement(n) || Q(n)) return "";
|
|
243
|
+
Tn(n, i);
|
|
244
|
+
let r = n.openingElement, t = r.name.name;
|
|
245
|
+
li(t, r.attributes) && (i.carriesFields = !0);
|
|
246
|
+
let s = `<${t}`, o = !1;
|
|
247
|
+
for (let [c, a] of r.attributes.entries()) {
|
|
248
|
+
if (e.isJSXSpreadAttribute(a) || !Xe(r.attributes, c, t) || H(r.attributes, c)) continue;
|
|
249
|
+
let x = C(a);
|
|
250
|
+
if (x === "key" || Ee(x) || x.startsWith("bind:") || x.includes("|") || e.isJSXExpressionContainer(a.value)) continue;
|
|
251
|
+
let d = An(x);
|
|
252
|
+
Rn(a, d, x, e.isStringLiteral(a.value) ? a.value.value : !0, i);
|
|
253
|
+
let p = o ? "" : " ";
|
|
254
|
+
if (!a.value && Ae(d))
|
|
255
|
+
s += `${p}${d}=true`, o = !1;
|
|
256
|
+
else if (!a.value)
|
|
257
|
+
s += p + d, o = !1;
|
|
258
|
+
else if (e.isStringLiteral(a.value)) {
|
|
259
|
+
let f = a.value.value;
|
|
260
|
+
ii.test(f) ? (s += `${p}${d}=${f}`, o = !1) : (s += `${p}${d}="${si(f)}"`, o = !0);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (n._whatNs !== "svg" && n._whatNs !== "math" && Dn(t))
|
|
264
|
+
return s + ">";
|
|
265
|
+
let l = Ye.has(t) && n._whatNs === "html" ? t : null;
|
|
266
|
+
return `${s}>${Pe(n.children, !0, i, l, hn(n)).html}</${t}>`;
|
|
267
|
+
}
|
|
268
|
+
function hn(n) {
|
|
269
|
+
let i = n.openingElement.name.name;
|
|
270
|
+
return n._whatNs === "html" && (Ye.has(i) || kn.has(i));
|
|
271
|
+
}
|
|
272
|
+
function ti(n) {
|
|
273
|
+
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
274
|
+
}
|
|
275
|
+
function si(n) {
|
|
276
|
+
return n.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
277
|
+
}
|
|
278
|
+
function q(n, i) {
|
|
279
|
+
let { node: r } = n, t = r.openingElement, s = t.name.name, o = Le(r, i);
|
|
280
|
+
if (o === "For") return Ei(n, i);
|
|
281
|
+
if (o === "Show") return hi(n, i);
|
|
282
|
+
if (o === "Switch") return xi(n, i);
|
|
283
|
+
if (Q(r))
|
|
284
|
+
return yn(n, i);
|
|
285
|
+
let l = r._whatKeyed === !0 ? null : he(r, i);
|
|
286
|
+
if (l !== null) {
|
|
287
|
+
r._whatKeyed = !0;
|
|
288
|
+
let _ = i._pendingSetup.length, S = q(n, i), y = i._pendingSetup.splice(_), b = y.length === 0 ? S : e.blockStatement([...y, e.returnStatement(S)]);
|
|
289
|
+
return e.callExpression(h(i, "_$keyed"), [e.arrowFunctionExpression([], l), e.arrowFunctionExpression([], b)]);
|
|
290
|
+
}
|
|
291
|
+
let c = t.attributes, a = r.children, x = a.every(rn), d = c.every((_, S) => !nn(_) && !Ne(s, c, S)), p = c.every((_) => {
|
|
292
|
+
if (e.isJSXSpreadAttribute(_)) return !1;
|
|
293
|
+
let S = C(_);
|
|
294
|
+
return !S?.startsWith("on") && !S?.startsWith("bind:");
|
|
295
|
+
});
|
|
296
|
+
if (x && d && p) {
|
|
297
|
+
let _ = be(r, i);
|
|
298
|
+
if (_) {
|
|
299
|
+
let S = Ue(i, _, r._whatNs, s);
|
|
300
|
+
return i.hydratable ? e.callExpression(h(i, "_$claim"), [e.identifier(S)]) : e.callExpression(e.identifier(S), []);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
let f = be(r, i);
|
|
304
|
+
if (!f) {
|
|
305
|
+
let _ = r.loc, S = i.filename || i.file?.opts?.filename || "<unknown>", y = _ ? `:${_.start.line}:${_.start.column}` : "";
|
|
306
|
+
return console.warn(
|
|
307
|
+
`[what-compiler] Could not extract template for <${s}> at ${S}${y}. Falling back to h() for this element. This element could not be statically analyzed. Consider simplifying the JSX.`
|
|
308
|
+
), $e(n, i);
|
|
309
|
+
}
|
|
310
|
+
let E = Ue(i, f, r._whatNs, s), g = i.nextVarId(), $ = i.hydratable ? e.callExpression(h(i, me.has(s) ? "_$claimControl" : "_$claim"), [e.identifier(E)]) : e.callExpression(e.identifier(E), []), u = [
|
|
311
|
+
e.variableDeclaration("const", [
|
|
312
|
+
e.variableDeclarator(e.identifier(g), $)
|
|
313
|
+
])
|
|
314
|
+
];
|
|
315
|
+
de(u, g, c, i, s, r._whatNs);
|
|
316
|
+
let m = (ve(u, g, a, r, i, r._whatRowCell) ? 1 : 0) | (Sn(c) ? 2 : 0);
|
|
317
|
+
return i.hydratable && xn($, m, me.has(s) ? null : gn(c, s, r._whatNs)), i._pendingSetup || (i._pendingSetup = []), i._pendingSetup.push(...u), e.identifier(g);
|
|
318
|
+
}
|
|
319
|
+
function xn(n, i, r) {
|
|
320
|
+
(i !== 0 || r !== null) && n.arguments.push(e.numericLiteral(i)), r !== null && n.arguments.push(e.stringLiteral(r));
|
|
321
|
+
}
|
|
322
|
+
function gn(n, i, r) {
|
|
323
|
+
if (r !== "html" && r !== "svg" || i.includes("-") || ae.has(i)) return null;
|
|
324
|
+
let t = [];
|
|
325
|
+
for (let [s, o] of n.entries()) {
|
|
326
|
+
if (e.isJSXSpreadAttribute(o)) return null;
|
|
327
|
+
let l = C(o);
|
|
328
|
+
if (l === "classList") return null;
|
|
329
|
+
if (!e.isJSXExpressionContainer(o.value) || H(n, s) || Ie(l)) continue;
|
|
330
|
+
let c = U(l);
|
|
331
|
+
(c === "class" || c === "id" || c === "title" || Ae(c)) && !t.includes(c) && t.push(c);
|
|
332
|
+
}
|
|
333
|
+
return t.length > 0 ? t.join(" ") : null;
|
|
334
|
+
}
|
|
335
|
+
function $e(n, i) {
|
|
336
|
+
let { node: r } = n, t = r.openingElement, s = t.name.name, o = t.attributes, l = r.children, c = [];
|
|
337
|
+
for (let d of o) {
|
|
338
|
+
if (e.isJSXSpreadAttribute(d)) continue;
|
|
339
|
+
let p = C(d), f = J(d.value), E = U(p);
|
|
340
|
+
c.push(
|
|
341
|
+
e.objectProperty(
|
|
342
|
+
/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(E) ? e.identifier(E) : e.stringLiteral(E),
|
|
343
|
+
f
|
|
344
|
+
)
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
let a = [];
|
|
348
|
+
for (let d of l)
|
|
349
|
+
if (e.isJSXText(d)) {
|
|
350
|
+
let p = te(d.value);
|
|
351
|
+
p && a.push(e.stringLiteral(p));
|
|
352
|
+
} else e.isJSXExpressionContainer(d) ? e.isJSXEmptyExpression(d.expression) || a.push(d.expression) : e.isJSXElement(d) ? a.push(q({ node: d }, i)) : e.isJSXFragment(d) && a.push(se({ node: d }, i));
|
|
353
|
+
let x = c.length > 0 ? e.objectExpression(c) : e.nullLiteral();
|
|
354
|
+
return e.callExpression(h(i, "h"), [e.stringLiteral(s), x, ...a]);
|
|
355
|
+
}
|
|
356
|
+
function Ke(n, i, r) {
|
|
357
|
+
if (e.isArrowFunctionExpression(n) || e.isFunctionExpression(n))
|
|
358
|
+
return e.callExpression(n, [e.identifier(i)]);
|
|
359
|
+
let t = e.callExpression(h(r, "_$applyRef"), [n, e.identifier(i)]);
|
|
360
|
+
if (e.isIdentifier(n)) {
|
|
361
|
+
let s = r._jsxScope && r._jsxScope.getBinding(n.name);
|
|
362
|
+
if (s && (s.kind === "let" || s.kind === "var")) {
|
|
363
|
+
let o = n.name;
|
|
364
|
+
return e.assignmentExpression("=", e.identifier(o), e.conditionalExpression(
|
|
365
|
+
e.logicalExpression(
|
|
366
|
+
"&&",
|
|
367
|
+
e.binaryExpression("!=", e.identifier(o), e.nullLiteral()),
|
|
368
|
+
e.binaryExpression(">", e.memberExpression(e.identifier(o), e.identifier("nodeType")), e.numericLiteral(0))
|
|
369
|
+
),
|
|
370
|
+
e.identifier(i),
|
|
371
|
+
t
|
|
372
|
+
));
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return t;
|
|
376
|
+
}
|
|
377
|
+
var oi = /* @__PURE__ */ new Set(["input", "textarea", "select", "option"]), ie = /* @__PURE__ */ new Set(["input", "textarea", "select"]), ae = /* @__PURE__ */ new Set(["select", "option"]);
|
|
378
|
+
function de(n, i, r, t, s, o) {
|
|
379
|
+
o === "svg" && r.some((d) => e.isJSXSpreadAttribute(d) || /^x(?:link|ml(?!ns))/.test(C(d)) && e.isJSXExpressionContainer(d.value)) && (t.writesXlink = !0);
|
|
380
|
+
function l(d, p, f) {
|
|
381
|
+
ae.has(s) && (t.makesSelects = !0);
|
|
382
|
+
let E = f && ie.has(s) ? [e.numericLiteral(1)] : [];
|
|
383
|
+
if (d === "class")
|
|
384
|
+
return o === "svg" ? e.callExpression(h(t, "_$setClass"), [e.identifier(i), p]) : e.callExpression(h(t, "_$className"), [e.identifier(i), p]);
|
|
385
|
+
if (d === "classList")
|
|
386
|
+
return e.callExpression(h(t, "_$setClassList"), [e.identifier(i), p]);
|
|
387
|
+
if (d === "style")
|
|
388
|
+
return e.callExpression(h(t, "_$setStyle"), [e.identifier(i), p]);
|
|
389
|
+
if (d === "value" && s && oi.has(s))
|
|
390
|
+
return e.callExpression(h(t, "_$setValue"), [e.identifier(i), p, ...E]);
|
|
391
|
+
if (d === "checked" && s === "input")
|
|
392
|
+
return e.callExpression(h(t, "_$setChecked"), [e.identifier(i), p, ...E]);
|
|
393
|
+
let g = d.toLowerCase();
|
|
394
|
+
return g === "type" && s === "input" || g === "multiple" && s === "select" ? e.callExpression(h(t, "_$retype"), [e.identifier(i), e.stringLiteral(d), p]) : Ae(d) ? e.callExpression(h(t, "_$setAttr"), [
|
|
395
|
+
e.identifier(i),
|
|
396
|
+
e.stringLiteral(d),
|
|
397
|
+
p
|
|
398
|
+
]) : e.callExpression(h(t, "_$setProp"), [
|
|
399
|
+
e.identifier(i),
|
|
400
|
+
e.stringLiteral(d),
|
|
401
|
+
p
|
|
402
|
+
]);
|
|
403
|
+
}
|
|
404
|
+
function c(d, p, f) {
|
|
405
|
+
let E = [d], g = fe(s, p, f, t);
|
|
406
|
+
return g && E.push(e.objectExpression([
|
|
407
|
+
e.objectProperty(e.identifier("name"), g),
|
|
408
|
+
e.objectProperty(e.identifier("binding"), e.identifier(i))
|
|
409
|
+
])), e.callExpression(h(t, "_$effect"), E);
|
|
410
|
+
}
|
|
411
|
+
let a = !1;
|
|
412
|
+
function x() {
|
|
413
|
+
a || (a = !0, n.push(
|
|
414
|
+
e.expressionStatement(e.callExpression(h(t, "_$delegate$"), [e.identifier(i)]))
|
|
415
|
+
));
|
|
416
|
+
}
|
|
417
|
+
if (ri(r, s, t)) {
|
|
418
|
+
ae.has(s) && (t.makesSelects = !0);
|
|
419
|
+
let d = [], p = null, f = [], E = [], g = r.findLastIndex((u) => e.isJSXSpreadAttribute(u));
|
|
420
|
+
for (let [u, m] of r.entries()) {
|
|
421
|
+
if (e.isJSXSpreadAttribute(m)) {
|
|
422
|
+
d.push(_e(m)), p = null;
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
let _ = C(m);
|
|
426
|
+
if (dn(_, t)) {
|
|
427
|
+
E.push(m);
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if (_ === "key" || En(r, u, s) && !mn(r, u, t) || H(r, u)) continue;
|
|
431
|
+
let S = J(m.value);
|
|
432
|
+
if (_ === "ref") {
|
|
433
|
+
f.push([e.expressionStatement(Ke(S, i, t)), u > g]);
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
let y = e.isJSXExpressionContainer(m.value) && !e.isFunction(S) && D(S, t.signalNames, t.importedIdentifiers);
|
|
437
|
+
p === null && d.push(p = e.objectExpression([e.objectProperty(e.identifier("__proto__"), e.nullLiteral())])), p.properties.push(y ? e.objectMethod("get", G(_), [], e.blockStatement([e.returnStatement(S)])) : e.objectProperty(G(_), S));
|
|
438
|
+
}
|
|
439
|
+
let $ = e.arrayExpression(d);
|
|
440
|
+
n.push(e.expressionStatement(e.callExpression(h(t, "_$spreads"), [
|
|
441
|
+
ie.has(s) ? e.callExpression(h(t, "_$controlled"), [e.identifier(i)]) : e.identifier(i),
|
|
442
|
+
r.some((u) => e.isJSXSpreadAttribute(u) && ye(u.argument, t)) ? e.arrowFunctionExpression([], $) : $,
|
|
443
|
+
// A ref after the last spread is the element's only one.
|
|
444
|
+
...f.some(([, u]) => u) ? [e.arrayExpression([e.stringLiteral("ref")])] : []
|
|
445
|
+
])), ...f.map(([u]) => u)), E.length > 0 && de(n, i, E, t, s, o);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
for (let [d, p] of r.entries()) {
|
|
449
|
+
if (e.isJSXSpreadAttribute(p)) {
|
|
450
|
+
ae.has(s) && (t.makesSelects = !0), n.push(
|
|
451
|
+
e.expressionStatement(
|
|
452
|
+
// A spread on a form field may bind its value or checked to state:
|
|
453
|
+
// the field then shows what they hold after its events (what-core
|
|
454
|
+
// _$controlled).
|
|
455
|
+
// One that may be built again with other keys is read again
|
|
456
|
+
// (liveSpread, what-core _$spreads).
|
|
457
|
+
ye(p.argument, t) ? e.callExpression(h(t, "_$spreads"), [
|
|
458
|
+
ie.has(s) ? e.callExpression(h(t, "_$controlled"), [e.identifier(i)]) : e.identifier(i),
|
|
459
|
+
e.arrowFunctionExpression([], e.arrayExpression([_e(p)])),
|
|
460
|
+
...Ge(r, d)
|
|
461
|
+
]) : e.callExpression(h(t, "_$spread"), [ie.has(s) ? e.callExpression(h(t, "_$controlled"), [e.identifier(i)]) : e.identifier(i), _e(p), ...Ge(r, d)])
|
|
462
|
+
)
|
|
463
|
+
);
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (H(r, d)) continue;
|
|
467
|
+
let f = C(p);
|
|
468
|
+
if (f !== "key") {
|
|
469
|
+
if (f === "ref") {
|
|
470
|
+
n.push(e.expressionStatement(Ke(J(p.value), i, t)));
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (f.startsWith("on") && !f.includes("|") && !pe(f, t)) {
|
|
474
|
+
let E = Oe(f), g = Ve(E ?? f), $ = J(p.value), u = fe(s, f, p, t);
|
|
475
|
+
u && n.push(e.expressionStatement(e.assignmentExpression(
|
|
476
|
+
"=",
|
|
477
|
+
e.memberExpression(e.identifier(i), e.stringLiteral(`_$source_${g}`), !0),
|
|
478
|
+
u
|
|
479
|
+
))), E === null && ei.has(g) ? (t.delegatedEvents || (t.delegatedEvents = /* @__PURE__ */ new Set()), t.delegatedEvents.add(g), x(), n.push(
|
|
480
|
+
e.expressionStatement(
|
|
481
|
+
e.assignmentExpression(
|
|
482
|
+
"=",
|
|
483
|
+
e.memberExpression(
|
|
484
|
+
e.identifier(i),
|
|
485
|
+
e.identifier(`$$${g}`)
|
|
486
|
+
),
|
|
487
|
+
$
|
|
488
|
+
)
|
|
489
|
+
)
|
|
490
|
+
)) : n.push(
|
|
491
|
+
e.expressionStatement(
|
|
492
|
+
e.callExpression(h(t, "_$on"), [
|
|
493
|
+
e.identifier(i),
|
|
494
|
+
e.stringLiteral(g),
|
|
495
|
+
$,
|
|
496
|
+
...E === null ? [] : [e.booleanLiteral(!0)]
|
|
497
|
+
])
|
|
498
|
+
)
|
|
499
|
+
);
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (f.startsWith("on") && (f.includes("|") || pe(f, t))) {
|
|
503
|
+
let { eventName: E, modifiers: g } = tn(f), $ = J(p.value), u = Qe($, g), m = Oe(E), _ = Ve(m ?? E), S = g.filter((b) => Ln.has(b));
|
|
504
|
+
m !== null && !S.includes("capture") && S.push("capture");
|
|
505
|
+
let y = [e.stringLiteral(_), u];
|
|
506
|
+
if (S.length > 0) {
|
|
507
|
+
let b = S.map(
|
|
508
|
+
(F) => e.objectProperty(e.identifier(F), e.booleanLiteral(!0))
|
|
509
|
+
);
|
|
510
|
+
y.push(e.objectExpression(b));
|
|
511
|
+
}
|
|
512
|
+
if (_ === "change") {
|
|
513
|
+
let b = S.filter((A) => A !== "once").map((A) => e.objectProperty(e.identifier(A), e.booleanLiteral(!0))), F = u;
|
|
514
|
+
if (S.includes("once")) {
|
|
515
|
+
let [A, M, R] = [e.identifier("h"), e.identifier("done"), e.identifier("e")];
|
|
516
|
+
F = e.callExpression(e.arrowFunctionExpression([A, M], e.arrowFunctionExpression(
|
|
517
|
+
[R],
|
|
518
|
+
e.logicalExpression("||", M, e.sequenceExpression([e.assignmentExpression("=", e.cloneNode(M), e.booleanLiteral(!0)), e.callExpression(e.cloneNode(A), [R])]))
|
|
519
|
+
)), [u]);
|
|
520
|
+
}
|
|
521
|
+
n.push(e.expressionStatement(e.callExpression(h(t, "_$spread"), [
|
|
522
|
+
e.identifier(i),
|
|
523
|
+
e.objectExpression([e.objectProperty(e.identifier("onchange"), F)]),
|
|
524
|
+
...b.length > 0 ? [e.nullLiteral(), e.objectExpression(b)] : []
|
|
525
|
+
])));
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
n.push(
|
|
529
|
+
e.expressionStatement(
|
|
530
|
+
e.callExpression(h(t, "_$on"), [e.identifier(i), ...y])
|
|
531
|
+
)
|
|
532
|
+
);
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
if (Ie(f)) {
|
|
536
|
+
let E = en(f), g = p.value.expression;
|
|
537
|
+
E === "value" ? (n.push(
|
|
538
|
+
e.expressionStatement(
|
|
539
|
+
c(e.arrowFunctionExpression([], e.assignmentExpression(
|
|
540
|
+
"=",
|
|
541
|
+
e.memberExpression(e.identifier(i), e.identifier("value")),
|
|
542
|
+
e.callExpression(e.cloneNode(g), [])
|
|
543
|
+
)), "value", p)
|
|
544
|
+
)
|
|
545
|
+
), n.push(
|
|
546
|
+
e.expressionStatement(
|
|
547
|
+
e.callExpression(
|
|
548
|
+
e.memberExpression(e.identifier(i), e.identifier("addEventListener")),
|
|
549
|
+
[
|
|
550
|
+
e.stringLiteral("input"),
|
|
551
|
+
e.arrowFunctionExpression(
|
|
552
|
+
[e.identifier("e")],
|
|
553
|
+
e.callExpression(
|
|
554
|
+
e.memberExpression(e.cloneNode(g), e.identifier("set")),
|
|
555
|
+
[e.memberExpression(
|
|
556
|
+
e.memberExpression(e.identifier("e"), e.identifier("target")),
|
|
557
|
+
e.identifier("value")
|
|
558
|
+
)]
|
|
559
|
+
)
|
|
560
|
+
)
|
|
561
|
+
]
|
|
562
|
+
)
|
|
563
|
+
)
|
|
564
|
+
)) : E === "checked" && (n.push(
|
|
565
|
+
e.expressionStatement(
|
|
566
|
+
c(e.arrowFunctionExpression([], e.assignmentExpression(
|
|
567
|
+
"=",
|
|
568
|
+
e.memberExpression(e.identifier(i), e.identifier("checked")),
|
|
569
|
+
e.callExpression(e.cloneNode(g), [])
|
|
570
|
+
)), "checked", p)
|
|
571
|
+
)
|
|
572
|
+
), n.push(
|
|
573
|
+
e.expressionStatement(
|
|
574
|
+
e.callExpression(
|
|
575
|
+
e.memberExpression(e.identifier(i), e.identifier("addEventListener")),
|
|
576
|
+
[
|
|
577
|
+
e.stringLiteral("change"),
|
|
578
|
+
e.arrowFunctionExpression(
|
|
579
|
+
[e.identifier("e")],
|
|
580
|
+
e.callExpression(
|
|
581
|
+
e.memberExpression(e.cloneNode(g), e.identifier("set")),
|
|
582
|
+
[e.memberExpression(
|
|
583
|
+
e.memberExpression(e.identifier("e"), e.identifier("target")),
|
|
584
|
+
e.identifier("checked")
|
|
585
|
+
)]
|
|
586
|
+
)
|
|
587
|
+
)
|
|
588
|
+
]
|
|
589
|
+
)
|
|
590
|
+
)
|
|
591
|
+
));
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
if (e.isJSXExpressionContainer(p.value)) {
|
|
595
|
+
let E = p.value.expression, g = U(f);
|
|
596
|
+
if (D(E, t.signalNames, t.importedIdentifiers)) {
|
|
597
|
+
let $ = t.signalNames && t.signalNames.fromDestructuredProps, u = e.isIdentifier(E) && !($ && $.has(E.name)) && qn(E.name, t.signalNames) ? e.callExpression(E, []) : E, m = c(e.arrowFunctionExpression([], l(g, u, !0)), g, p);
|
|
598
|
+
on(E, t.signalNames, t.importedIdentifiers) && e.addComment(
|
|
599
|
+
m,
|
|
600
|
+
"leading",
|
|
601
|
+
" @what-dev: effect wrapping may be unnecessary \u2014 expression contains a non-signal function call with reactive args ",
|
|
602
|
+
!1
|
|
603
|
+
), n.push(e.expressionStatement(m));
|
|
604
|
+
} else
|
|
605
|
+
n.push(e.expressionStatement(l(g, E)));
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
Xe(r, d, s) || n.push(
|
|
609
|
+
e.expressionStatement(
|
|
610
|
+
l(U(f), J(p.value))
|
|
611
|
+
)
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function Y(n) {
|
|
617
|
+
return e.isCallExpression(n) && (n._whatList === !0 || e.isIdentifier(n.callee, { name: "mapArray" }));
|
|
618
|
+
}
|
|
619
|
+
function _n(n, i) {
|
|
620
|
+
i.needsGeneralMapArray = !0, n._whatList !== !0 && (n.callee = h(i, "_$mapArray"), n._whatList = !0);
|
|
621
|
+
}
|
|
622
|
+
function Z(n) {
|
|
623
|
+
if (!n || typeof n != "object") return !1;
|
|
624
|
+
if (Array.isArray(n)) return n.some(Z);
|
|
625
|
+
if (n.type === "JSXElement" || n.type === "JSXFragment" || Y(n)) return !0;
|
|
626
|
+
for (let i of Object.keys(n)) {
|
|
627
|
+
if (i === "loc" || i === "start" || i === "end" || i === "leadingComments" || i === "trailingComments" || i === "innerComments") continue;
|
|
628
|
+
let r = n[i];
|
|
629
|
+
if (r && typeof r == "object" && Z(r)) return !0;
|
|
630
|
+
}
|
|
631
|
+
return !1;
|
|
632
|
+
}
|
|
633
|
+
function we(n, i, r) {
|
|
634
|
+
return e.isConditionalExpression(n) ? (r.push(n.test), e.conditionalExpression(n.test, we(n.consequent, i, r), we(n.alternate, i, r))) : (i.push(n), e.numericLiteral(i.length - 1));
|
|
635
|
+
}
|
|
636
|
+
function xe(n, i, r) {
|
|
637
|
+
if (!e.isConditionalExpression(n)) return null;
|
|
638
|
+
let t = [], s = [], o = we(n, t, s);
|
|
639
|
+
if (!s.some((a) => D(a, r.signalNames, r.importedIdentifiers)) || !t.some(Z)) return null;
|
|
640
|
+
let l = r.nextMemoId();
|
|
641
|
+
i.push(e.variableDeclaration("const", [
|
|
642
|
+
e.variableDeclarator(e.identifier(l), e.callExpression(h(r, "_$lazyMemo"), [e.arrowFunctionExpression([], o)]))
|
|
643
|
+
]));
|
|
644
|
+
for (let a = 0; a < t.length; a++) t[a] = ce(t[a], i, r) ?? t[a];
|
|
645
|
+
let c = t[t.length - 1];
|
|
646
|
+
for (let a = t.length - 2; a >= 0; a--)
|
|
647
|
+
c = e.conditionalExpression(e.binaryExpression("===", e.callExpression(e.identifier(l), []), e.numericLiteral(a)), t[a], c);
|
|
648
|
+
return c;
|
|
649
|
+
}
|
|
650
|
+
function ce(n, i, r) {
|
|
651
|
+
if (!e.isLogicalExpression(n) || n.operator !== "&&" && n.operator !== "||" || !D(n.left, r.signalNames, r.importedIdentifiers) || !Z(n.right) || n.operator === "||" && Z(n.left)) return null;
|
|
652
|
+
let t = r.nextMemoId();
|
|
653
|
+
i.push(e.variableDeclaration("const", [
|
|
654
|
+
e.variableDeclarator(e.identifier(t), e.callExpression(h(r, "_$lazyMemo"), [
|
|
655
|
+
e.arrowFunctionExpression([], e.unaryExpression("!", e.unaryExpression("!", n.left)))
|
|
656
|
+
]))
|
|
657
|
+
]));
|
|
658
|
+
let s = e.callExpression(e.identifier(t), []), o = e.cloneNode(n.left, !0);
|
|
659
|
+
return n.operator === "&&" ? e.conditionalExpression(s, n.right, o) : e.conditionalExpression(s, o, n.right);
|
|
660
|
+
}
|
|
661
|
+
function K(n, i, r) {
|
|
662
|
+
if (e.isConditionalExpression(n) && (e.isConditionalExpression(n.consequent) || e.isConditionalExpression(n.alternate))) {
|
|
663
|
+
let d = xe(n, i, r);
|
|
664
|
+
if (d !== null) return d;
|
|
665
|
+
}
|
|
666
|
+
let t = ce(n, i, r);
|
|
667
|
+
if (t !== null) return t;
|
|
668
|
+
let s = null, o = !1;
|
|
669
|
+
if (e.isConditionalExpression(n))
|
|
670
|
+
s = n.test, o = !0;
|
|
671
|
+
else if (e.isLogicalExpression(n) && (n.operator === "&&" || n.operator === "||"))
|
|
672
|
+
s = n.left;
|
|
673
|
+
else
|
|
674
|
+
return n;
|
|
675
|
+
if (!D(s, r.signalNames, r.importedIdentifiers) || !(o ? [n.consequent, n.alternate] : [n.right]).some(Z)) return n;
|
|
676
|
+
let c = r.nextMemoId(), a = o ? e.unaryExpression("!", e.unaryExpression("!", s)) : s;
|
|
677
|
+
i.push(
|
|
678
|
+
e.variableDeclaration("const", [
|
|
679
|
+
e.variableDeclarator(
|
|
680
|
+
e.identifier(c),
|
|
681
|
+
e.callExpression(h(r, "_$memo"), [
|
|
682
|
+
e.arrowFunctionExpression([], a)
|
|
683
|
+
])
|
|
684
|
+
)
|
|
685
|
+
])
|
|
686
|
+
);
|
|
687
|
+
let x = e.callExpression(e.identifier(c), []);
|
|
688
|
+
return o ? e.conditionalExpression(x, ce(n.consequent, i, r) ?? n.consequent, ce(n.alternate, i, r) ?? n.alternate) : e.logicalExpression(n.operator, x, n.right);
|
|
689
|
+
}
|
|
690
|
+
function li(n, i) {
|
|
691
|
+
return ie.has(n.toLowerCase()) || i.some((r) => e.isJSXSpreadAttribute(r) || Ze.has(C(r)));
|
|
692
|
+
}
|
|
693
|
+
function Sn(n) {
|
|
694
|
+
return n.some((i) => e.isJSXAttribute(i) && Ze.has(C(i)));
|
|
695
|
+
}
|
|
696
|
+
function ve(n, i, r, t, s, o) {
|
|
697
|
+
let { entries: l } = Pe(r, !1, s, null, hn(t)), c = s.hydratable, a = 0, x = !1, d = () => {
|
|
698
|
+
a > 0 && n.push(e.expressionStatement(e.callExpression(h(s, "_$skip"), [e.numericLiteral(a)]))), a = 0;
|
|
699
|
+
}, p = [];
|
|
700
|
+
for (let u of l)
|
|
701
|
+
if (u.kind === "dynamic")
|
|
702
|
+
typeof u.marker == "number" && p.push(u.marker);
|
|
703
|
+
else if (u.kind === "element") {
|
|
704
|
+
let m = u.node.openingElement.attributes;
|
|
705
|
+
u.hasAnythingDynamic = m.some((_, S) => nn(_) || Ne(u.node.openingElement.name.name, m, S)) || m.some((_) => !e.isJSXSpreadAttribute(_) && C(_)?.startsWith("on")) || !u.node.children.every(rn), u.hasAnythingDynamic && p.push(u.index);
|
|
706
|
+
}
|
|
707
|
+
let f = [...new Set(p)].sort((u, m) => u - m), E = /* @__PURE__ */ new Map();
|
|
708
|
+
if (!c && (f.length >= 2 || p.length > f.length)) {
|
|
709
|
+
let u = null, m = 0;
|
|
710
|
+
for (let _ of f) {
|
|
711
|
+
let S = s.nextVarId();
|
|
712
|
+
E.set(_, S);
|
|
713
|
+
let y;
|
|
714
|
+
if (u === null)
|
|
715
|
+
y = le(i, _);
|
|
716
|
+
else {
|
|
717
|
+
y = e.identifier(u);
|
|
718
|
+
for (let b = m; b < _; b++)
|
|
719
|
+
y = e.memberExpression(y, e.identifier("nextSibling"));
|
|
720
|
+
}
|
|
721
|
+
n.push(
|
|
722
|
+
e.variableDeclaration("const", [
|
|
723
|
+
e.variableDeclarator(e.identifier(S), y)
|
|
724
|
+
])
|
|
725
|
+
), u = S, m = _;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
function g(u, m, _, S, y) {
|
|
729
|
+
if (c) {
|
|
730
|
+
d(), x = !0, u._whatInPlace = !0, B(u);
|
|
731
|
+
let A = m === void 0 ? 3 : m === null ? 2 : S ? 1 : 0, M = [e.identifier(i), u, e.numericLiteral(A)], R = fe(t.openingElement.name.name, "children", _, s);
|
|
732
|
+
return R && M.push(R), e.callExpression(h(s, y ? "_$hplain" : "_$hole"), M);
|
|
733
|
+
}
|
|
734
|
+
let b = [e.identifier(i), u];
|
|
735
|
+
m === null ? b.push(e.nullLiteral()) : m !== void 0 && b.push(E.has(m) ? e.identifier(E.get(m)) : le(i, m));
|
|
736
|
+
let F = fe(t.openingElement.name.name, "children", _, s);
|
|
737
|
+
return F && (m === void 0 && b.push(e.unaryExpression("void", e.numericLiteral(0))), b.push(F)), !y && !e.isArrowFunctionExpression(u) && !e.isFunctionExpression(u) && (s.needsGeneralInsert = !0), e.callExpression(h(s, y ? "_$plain" : "_$insert"), b);
|
|
738
|
+
}
|
|
739
|
+
function $(u, m, _, S) {
|
|
740
|
+
let y = P(s, "_f$");
|
|
741
|
+
s.rowFieldReaders.push({ id: y, fn: e.arrowFunctionExpression([e.identifier("r")], qe(u, m, e.identifier("r"))) });
|
|
742
|
+
let b = qe(u, m, e.identifier(m._whatRowItemName)), F = e.cloneNode(m.arguments[0]), A = o !== void 0 && e.isIdentifier(F, { name: o }) ? [] : [e.numericLiteral(1)];
|
|
743
|
+
if (c) {
|
|
744
|
+
d(), x = !0;
|
|
745
|
+
let R = _ === void 0 ? 3 : _ === null ? 2 : S ? 1 : 0;
|
|
746
|
+
return e.callExpression(h(s, "_$hfield"), [e.identifier(i), F, b, e.numericLiteral(R), e.identifier(y), ...A]);
|
|
747
|
+
}
|
|
748
|
+
let M = _ === void 0 ? e.unaryExpression("void", e.numericLiteral(0)) : _ === null ? e.nullLiteral() : E.has(_) ? e.identifier(E.get(_)) : le(i, _);
|
|
749
|
+
return e.callExpression(h(s, "_$field"), [e.identifier(i), F, b, M, e.identifier(y), ...A]);
|
|
750
|
+
}
|
|
751
|
+
for (let u of l) {
|
|
752
|
+
if (u.kind === "dynamic" && e.isJSXExpressionContainer(u.node)) {
|
|
753
|
+
let m = u.node.expression, _ = ln(m);
|
|
754
|
+
if (_ !== null && e.isCallExpression(_) && _._whatRowItemName) {
|
|
755
|
+
n.push(e.expressionStatement($(m, _, u.marker, u.placeholder)));
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
let S = cn(m, s);
|
|
759
|
+
if (S) {
|
|
760
|
+
let y = Y(S), b = e.isArrowFunctionExpression(S);
|
|
761
|
+
b && e.isExpression(S.body) ? S.body = K(S.body, n, s) : !y && !b && (S = K(S, n, s));
|
|
762
|
+
let F = y || b ? S : e.arrowFunctionExpression([], S);
|
|
763
|
+
n.push(e.expressionStatement(g(F, u.marker, u.node, u.placeholder)));
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
if (Y(m)) {
|
|
767
|
+
_n(m, s), n.push(e.expressionStatement(g(m, u.marker, u.node, u.placeholder)));
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
if (D(m, s.signalNames, s.importedIdentifiers)) {
|
|
771
|
+
m = K(m, n, s);
|
|
772
|
+
let y = c && e.isIdentifier(m) ? m : e.arrowFunctionExpression([], W(m, s, !0)), b = e.isArrowFunctionExpression(y) && !e.isIdentifier(y.body) && X(y.body), F = g(y, u.marker, u.node, u.placeholder, b);
|
|
773
|
+
on(m, s.signalNames, s.importedIdentifiers) && e.addComment(
|
|
774
|
+
F,
|
|
775
|
+
"leading",
|
|
776
|
+
" @what-dev: reactive wrapping may be unnecessary \u2014 expression contains a non-signal function call with reactive args ",
|
|
777
|
+
!1
|
|
778
|
+
), n.push(e.expressionStatement(F));
|
|
779
|
+
} else
|
|
780
|
+
n.push(e.expressionStatement(g(W(m, s, !1), u.marker, u.node, u.placeholder)));
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
if (u.kind === "dynamic") {
|
|
784
|
+
let m = q({ node: u.node }, s);
|
|
785
|
+
n.push(e.expressionStatement(g(m, u.marker, u.node, u.placeholder)));
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
if (c && u.kind !== "dynamic") {
|
|
789
|
+
if (!u.hasAnythingDynamic) {
|
|
790
|
+
a++;
|
|
791
|
+
continue;
|
|
792
|
+
}
|
|
793
|
+
let m = s.nextVarId(), _ = u.node.openingElement, S = e.callExpression(h(s, me.has(_.name.name) ? "_$control" : "_$next"), [e.numericLiteral(a)]);
|
|
794
|
+
a = 0, x = !0, n.push(e.variableDeclaration("const", [e.variableDeclarator(e.identifier(m), S)])), de(n, m, _.attributes, s, _.name.name, u.node._whatNs);
|
|
795
|
+
let y = (ve(n, m, u.node.children, u.node, s, o) ? 1 : 0) | (Sn(_.attributes) ? 2 : 0);
|
|
796
|
+
xn(S, y, me.has(_.name.name) ? null : gn(_.attributes, _.name.name, u.node._whatNs));
|
|
797
|
+
continue;
|
|
798
|
+
}
|
|
799
|
+
if (u.kind === "element" && u.hasAnythingDynamic) {
|
|
800
|
+
let m;
|
|
801
|
+
E.has(u.index) ? m = E.get(u.index) : (m = s.nextVarId(), n.push(
|
|
802
|
+
e.variableDeclaration("const", [
|
|
803
|
+
e.variableDeclarator(
|
|
804
|
+
e.identifier(m),
|
|
805
|
+
le(i, u.index)
|
|
806
|
+
)
|
|
807
|
+
])
|
|
808
|
+
));
|
|
809
|
+
let _ = u.node.openingElement;
|
|
810
|
+
de(n, m, _.attributes, s, _.name.name, u.node._whatNs), ve(n, m, u.node.children, u.node, s, o);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return x && n.push(e.expressionStatement(e.callExpression(h(s, "_$exit"), []))), x;
|
|
814
|
+
}
|
|
815
|
+
var me = /* @__PURE__ */ new Set(["input", "select", "textarea"]);
|
|
816
|
+
function le(n, i) {
|
|
817
|
+
if (i === 0)
|
|
818
|
+
return e.memberExpression(e.identifier(n), e.identifier("firstChild"));
|
|
819
|
+
let r = e.memberExpression(e.identifier(n), e.identifier("firstChild"));
|
|
820
|
+
for (let t = 0; t < i; t++)
|
|
821
|
+
r = e.memberExpression(r, e.identifier("nextSibling"));
|
|
822
|
+
return r;
|
|
823
|
+
}
|
|
824
|
+
function ai(n, i) {
|
|
825
|
+
if (!Fe(n)) return e.arrowFunctionExpression([], n);
|
|
826
|
+
let r = [], t = xe(n, r, i);
|
|
827
|
+
return t === null ? e.arrowFunctionExpression([], n) : e.arrowFunctionExpression([], e.blockStatement([...r, e.returnStatement(e.arrowFunctionExpression([], t))]));
|
|
828
|
+
}
|
|
829
|
+
function Fe(n) {
|
|
830
|
+
return e.isConditionalExpression(n) ? Fe(n.consequent) && Fe(n.alternate) : e.isJSXElement(n) || e.isJSXFragment(n);
|
|
831
|
+
}
|
|
832
|
+
function yn(n, i) {
|
|
833
|
+
let { node: r } = n, t = r.openingElement, s = Nn(t.name);
|
|
834
|
+
s._whatTag = !0;
|
|
835
|
+
let o = t.attributes, l = r.children, c = null, a = [];
|
|
836
|
+
for (let v of o) {
|
|
837
|
+
if (e.isJSXAttribute(v)) {
|
|
838
|
+
let w;
|
|
839
|
+
if (e.isJSXNamespacedName(v.name) ? w = `${v.name.namespace.name}:${v.name.name.name}` : w = v.name.name, w && typeof w == "string" && w.startsWith("client:")) {
|
|
840
|
+
c = { type: w.slice(7), value: On(v) };
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
a.push(v);
|
|
845
|
+
}
|
|
846
|
+
function x() {
|
|
847
|
+
let v = i._pendingSetup ? i._pendingSetup.length : 0, w = [], I = !1;
|
|
848
|
+
for (let L of l)
|
|
849
|
+
if (e.isJSXText(L)) {
|
|
850
|
+
let T = te(L.value);
|
|
851
|
+
T && w.push({ expr: e.stringLiteral(T), setup: [] });
|
|
852
|
+
} else if (e.isJSXExpressionContainer(L))
|
|
853
|
+
e.isJSXEmptyExpression(L.expression) || (I = !0, w.push(j(i, () => De(L.expression, i))));
|
|
854
|
+
else if (e.isJSXElement(L)) {
|
|
855
|
+
let T = Le(L, i);
|
|
856
|
+
T !== "For" && T !== "Show" && T !== "Switch" && (I = !0), w.push(j(i, () => q({ node: L }, i)));
|
|
857
|
+
} else e.isJSXFragment(L) && (I = !0, w.push(j(i, () => se({ node: L }, i))));
|
|
858
|
+
let N = w[0], k = Me(
|
|
859
|
+
w,
|
|
860
|
+
i,
|
|
861
|
+
!1,
|
|
862
|
+
!0,
|
|
863
|
+
w.length > 1 && !re(N, i) && !e.isStringLiteral(N.expr)
|
|
864
|
+
);
|
|
865
|
+
if (wn(k, i) && k.arguments.push(e.numericLiteral(w.length > 1 ? 2 : 1)), I || !e.isArrayExpression(k)) {
|
|
866
|
+
let L = i._pendingSetup ? i._pendingSetup.splice(v) : [];
|
|
867
|
+
k = e.arrowFunctionExpression(
|
|
868
|
+
[],
|
|
869
|
+
L.length > 0 ? e.blockStatement([...L, e.returnStatement(k)]) : k
|
|
870
|
+
);
|
|
871
|
+
}
|
|
872
|
+
return k;
|
|
873
|
+
}
|
|
874
|
+
if (c) {
|
|
875
|
+
let v = [], w = [], I = () => {
|
|
876
|
+
w.length > 0 && (v.push(e.objectExpression(w)), w = []);
|
|
877
|
+
};
|
|
878
|
+
for (let V of a) {
|
|
879
|
+
if (e.isJSXSpreadAttribute(V)) {
|
|
880
|
+
if (e.isObjectExpression(V.argument))
|
|
881
|
+
for (let ne of V.argument.properties)
|
|
882
|
+
e.isObjectProperty(ne) && Be(e.isIdentifier(ne.key) ? ne.key.name : String(ne.key.value), ne.value, r, i);
|
|
883
|
+
I(), v.push(V.argument);
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
let ge = C(V);
|
|
887
|
+
if (ge === "key") continue;
|
|
888
|
+
Be(ge, V.value, r, i);
|
|
889
|
+
let Fn = J(V.value);
|
|
890
|
+
w.push(e.objectProperty(G(ge), Fn));
|
|
891
|
+
}
|
|
892
|
+
let N = null;
|
|
893
|
+
v.length === 0 ? w.length > 0 && (N = e.objectExpression(w)) : (I(), N = e.callExpression(
|
|
894
|
+
e.memberExpression(e.identifier("Object"), e.identifier("assign")),
|
|
895
|
+
[e.objectExpression([]), ...v]
|
|
896
|
+
));
|
|
897
|
+
let k = x();
|
|
898
|
+
He(k) || (i.needsLazyProps = !0);
|
|
899
|
+
let L = [h(i, "_$Island"), Vn(t.name, c.type, c.value, N), k], T = We(r, i);
|
|
900
|
+
T && L.push(...i.hydratable ? [e.unaryExpression("void", e.numericLiteral(0))] : [], T);
|
|
901
|
+
let Re = e.callExpression(h(i, "_$createComponent"), L), je = Un(r, c.type, i);
|
|
902
|
+
return je === null ? Re : e.callExpression(h(i, "_$keyed"), [e.arrowFunctionExpression([], je), e.arrowFunctionExpression([], Re)]);
|
|
903
|
+
}
|
|
904
|
+
let d = Pn(n), p = [], f = [], E = [], g = [], $ = !1, u = () => {
|
|
905
|
+
f.length > 0 && (p.push(e.objectExpression(f)), f = []);
|
|
906
|
+
};
|
|
907
|
+
for (let v of a) {
|
|
908
|
+
if (e.isJSXSpreadAttribute(v)) {
|
|
909
|
+
u(), p.push(v.argument);
|
|
910
|
+
continue;
|
|
911
|
+
}
|
|
912
|
+
let w = C(v);
|
|
913
|
+
if (w === "key") continue;
|
|
914
|
+
if (Ie(w)) {
|
|
915
|
+
let N = en(w), k = v.value.expression;
|
|
916
|
+
N === "value" ? (f.push(
|
|
917
|
+
e.objectProperty(e.identifier("value"), e.callExpression(e.cloneNode(k), []))
|
|
918
|
+
), f.push(
|
|
919
|
+
e.objectProperty(
|
|
920
|
+
e.identifier("onInput"),
|
|
921
|
+
e.arrowFunctionExpression(
|
|
922
|
+
[e.identifier("e")],
|
|
923
|
+
e.callExpression(
|
|
924
|
+
e.memberExpression(e.cloneNode(k), e.identifier("set")),
|
|
925
|
+
[e.memberExpression(
|
|
926
|
+
e.memberExpression(e.identifier("e"), e.identifier("target")),
|
|
927
|
+
e.identifier("value")
|
|
928
|
+
)]
|
|
929
|
+
)
|
|
930
|
+
)
|
|
931
|
+
)
|
|
932
|
+
)) : N === "checked" && (f.push(
|
|
933
|
+
e.objectProperty(e.identifier("checked"), e.callExpression(e.cloneNode(k), []))
|
|
934
|
+
), f.push(
|
|
935
|
+
e.objectProperty(
|
|
936
|
+
e.identifier("onChange"),
|
|
937
|
+
e.arrowFunctionExpression(
|
|
938
|
+
[e.identifier("e")],
|
|
939
|
+
e.callExpression(
|
|
940
|
+
e.memberExpression(e.cloneNode(k), e.identifier("set")),
|
|
941
|
+
[e.memberExpression(
|
|
942
|
+
e.memberExpression(e.identifier("e"), e.identifier("target")),
|
|
943
|
+
e.identifier("checked")
|
|
944
|
+
)]
|
|
945
|
+
)
|
|
946
|
+
)
|
|
947
|
+
)
|
|
948
|
+
));
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
if (w.startsWith("on") && (w.includes("|") || pe(w, i))) {
|
|
952
|
+
let { eventName: N, modifiers: k } = tn(w), L = J(v.value), T = Qe(L, k);
|
|
953
|
+
f.push(e.objectProperty(e.identifier(N), T));
|
|
954
|
+
continue;
|
|
955
|
+
}
|
|
956
|
+
let I = J(v.value);
|
|
957
|
+
if (Xn(r, v, i) && (z(I) || di(I))) {
|
|
958
|
+
E.push(e.objectProperty(G(w), ai(I, i)));
|
|
959
|
+
continue;
|
|
960
|
+
}
|
|
961
|
+
if (ui(w, I, i)) {
|
|
962
|
+
let N = I;
|
|
963
|
+
if (ke(I, i.signalNames)) {
|
|
964
|
+
let k = P(i, "_prop$");
|
|
965
|
+
g.push(e.variableDeclarator(e.identifier(k), e.callExpression(h(i, "_$lazyMemo"), [
|
|
966
|
+
e.arrowFunctionExpression([], I)
|
|
967
|
+
]))), N = e.callExpression(e.identifier(k), []);
|
|
968
|
+
}
|
|
969
|
+
f.push(e.objectMethod("get", G(w), [], e.blockStatement([e.returnStatement(N)]))), $ = !0;
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
f.push(e.objectProperty(G(w), I));
|
|
973
|
+
}
|
|
974
|
+
u();
|
|
975
|
+
let m;
|
|
976
|
+
p.length === 0 ? m = e.nullLiteral() : p.length === 1 && e.isObjectExpression(p[0]) ? m = $ ? fi(p[0], i) : p[0] : m = e.callExpression(h(i, "_$merge"), p.map((v) => e.isObjectExpression(v) && v.properties.some((w) => e.isObjectMethod(w)) ? pi(v) : v)), E.length > 0 && (m = e.callExpression(h(i, "_$slots"), [
|
|
977
|
+
e.isNullLiteral(m) ? e.objectExpression([]) : m,
|
|
978
|
+
e.objectExpression(E)
|
|
979
|
+
]));
|
|
980
|
+
let _ = x();
|
|
981
|
+
(E.length > 0 || !He(_)) && (i.needsLazyProps = !0);
|
|
982
|
+
let S = n.scope ?? i.file?.path?.scope, y = Li(S, t.name, i.translatedMarks);
|
|
983
|
+
y || (i.classComponents = !0);
|
|
984
|
+
let b = !y && Ii(S, t.name);
|
|
985
|
+
b && (i.carriesFields = !0);
|
|
986
|
+
let F = [s, m, _], A = We(r, i), M = i.hydratable && !d ? Je(r) : null;
|
|
987
|
+
(M !== null || A && i.hydratable && !d) && F.push(M ?? e.unaryExpression("void", e.numericLiteral(0))), A && F.push(A);
|
|
988
|
+
let R = b ? "_$hcomponentVNode" : "_$componentVNode", O = e.callExpression(h(i, d ? R : "_$createComponent"), F);
|
|
989
|
+
r._whatPlacedNs !== void 0 && !d && r._whatMayBuildTag !== !1 && (O = e.callExpression(h(i, "_$inNs"), [e.numericLiteral(r._whatPlacedNs), e.arrowFunctionExpression([], O)])), g.length > 0 && (O = e.callExpression(e.arrowFunctionExpression([], e.blockStatement([
|
|
990
|
+
e.variableDeclaration("const", g),
|
|
991
|
+
e.returnStatement(O)
|
|
992
|
+
])), []));
|
|
993
|
+
let Te = d ? null : he(r, i);
|
|
994
|
+
return Te !== null && (O = e.callExpression(h(i, "_$keyed"), [e.arrowFunctionExpression([], Te), e.arrowFunctionExpression([], O)])), O;
|
|
995
|
+
}
|
|
996
|
+
function ci(n, i, r = /* @__PURE__ */ new Set()) {
|
|
997
|
+
if (!e.isJSXIdentifier(i) || n == null) return !0;
|
|
998
|
+
let t = n.getBinding(i.name);
|
|
999
|
+
if (!t || !t.constant) return !0;
|
|
1000
|
+
let s = t.path.node;
|
|
1001
|
+
if (t.kind === "module") return !(e.isImportSpecifier(s) && vn.has(t.path.parent.source.value));
|
|
1002
|
+
let o = e.isFunctionDeclaration(s) ? t.path : e.isVariableDeclarator(s) && e.isFunction(s.init) ? t.path.get("init") : null;
|
|
1003
|
+
if (o === null) return !0;
|
|
1004
|
+
if (r.has(o.node)) return !1;
|
|
1005
|
+
r.add(o.node);
|
|
1006
|
+
let l = !1;
|
|
1007
|
+
return o.traverse({
|
|
1008
|
+
JSXOpeningElement(c) {
|
|
1009
|
+
l || !Q(c.node) || ci(c.scope, c.node.name, r) && (l = !0);
|
|
1010
|
+
}
|
|
1011
|
+
}), l;
|
|
1012
|
+
}
|
|
1013
|
+
function bn(n, i) {
|
|
1014
|
+
return e.isCallExpression(n) && e.isIdentifier(n.callee) && ee(i).get("_$inNs") === n.callee.name && e.isArrowFunctionExpression(n.arguments[1]) ? n.arguments[1].body : n;
|
|
1015
|
+
}
|
|
1016
|
+
function X(n) {
|
|
1017
|
+
switch (n.type) {
|
|
1018
|
+
case "Identifier":
|
|
1019
|
+
case "StringLiteral":
|
|
1020
|
+
case "NumericLiteral":
|
|
1021
|
+
case "BooleanLiteral":
|
|
1022
|
+
case "NullLiteral":
|
|
1023
|
+
case "BigIntLiteral":
|
|
1024
|
+
return !0;
|
|
1025
|
+
case "MemberExpression":
|
|
1026
|
+
case "OptionalMemberExpression":
|
|
1027
|
+
return X(n.object) && (!n.computed || X(n.property));
|
|
1028
|
+
case "TemplateLiteral":
|
|
1029
|
+
return n.expressions.every(X);
|
|
1030
|
+
case "UnaryExpression":
|
|
1031
|
+
return n.operator !== "delete" && X(n.argument);
|
|
1032
|
+
case "BinaryExpression":
|
|
1033
|
+
case "LogicalExpression":
|
|
1034
|
+
return X(n.left) && X(n.right);
|
|
1035
|
+
case "ConditionalExpression":
|
|
1036
|
+
return X(n.test) && X(n.consequent) && X(n.alternate);
|
|
1037
|
+
case "ParenthesizedExpression":
|
|
1038
|
+
case "TSAsExpression":
|
|
1039
|
+
case "TSSatisfiesExpression":
|
|
1040
|
+
case "TSNonNullExpression":
|
|
1041
|
+
case "TSTypeAssertion":
|
|
1042
|
+
return X(n.expression);
|
|
1043
|
+
case "CallExpression":
|
|
1044
|
+
return n.callee._whatRowItem === !0;
|
|
1045
|
+
default:
|
|
1046
|
+
return !1;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function ke(n, i) {
|
|
1050
|
+
return !n || e.isFunction(n) ? !1 : (e.isMemberExpression(n) || e.isOptionalMemberExpression(n)) && Se(n, i) || (e.isCallExpression(n) || e.isOptionalCallExpression(n)) && Se(n.callee, i) ? !0 : (e.VISITOR_KEYS[n.type] || []).some((r) => Array.isArray(n[r]) ? n[r].some((t) => ke(t, i)) : ke(n[r], i));
|
|
1051
|
+
}
|
|
1052
|
+
function ui(n, i, r) {
|
|
1053
|
+
if (n === "ref") return !1;
|
|
1054
|
+
let t = i;
|
|
1055
|
+
for (; e.isTSAsExpression(t) || e.isTSSatisfiesExpression(t) || e.isTSNonNullExpression(t) || e.isTSTypeAssertion(t); ) t = t.expression;
|
|
1056
|
+
let s = e.isLiteral(t) && !(e.isTemplateLiteral(t) && t.expressions.length > 0);
|
|
1057
|
+
return e.isIdentifier(t) || s || e.isFunction(t) || e.isJSXElement(t) || e.isJSXFragment(t) ? !1 : D(t, r.signalNames, r.importedIdentifiers);
|
|
1058
|
+
}
|
|
1059
|
+
function pi(n) {
|
|
1060
|
+
return n.properties.unshift(e.objectProperty(e.identifier("__proto__"), e.nullLiteral())), n;
|
|
1061
|
+
}
|
|
1062
|
+
function fi(n, i) {
|
|
1063
|
+
return e.callExpression(h(i, "_$marked"), [n]);
|
|
1064
|
+
}
|
|
1065
|
+
function ue(n) {
|
|
1066
|
+
return e.isJSXElement(n) || e.isJSXFragment(n) ? !0 : e.isConditionalExpression(n) ? ue(n.consequent) || ue(n.alternate) : e.isLogicalExpression(n) && ue(n.right);
|
|
1067
|
+
}
|
|
1068
|
+
function di(n) {
|
|
1069
|
+
return e.isCallExpression(n) && n.callee._whatPlace === !0;
|
|
1070
|
+
}
|
|
1071
|
+
function z(n) {
|
|
1072
|
+
if (e.isJSXElement(n) || e.isJSXFragment(n)) return !0;
|
|
1073
|
+
if (e.isConditionalExpression(n)) return z(n.consequent) || z(n.alternate);
|
|
1074
|
+
if (e.isLogicalExpression(n)) return z(n.right);
|
|
1075
|
+
if (e.isArrayExpression(n)) return n.elements.some((t) => t !== null && z(e.isSpreadElement(t) ? t.argument : t));
|
|
1076
|
+
if (!(e.isCallExpression(n) || e.isOptionalCallExpression(n))) return !1;
|
|
1077
|
+
let i = n.callee;
|
|
1078
|
+
if (!(e.isMemberExpression(i) || e.isOptionalMemberExpression(i)) || i.computed || !e.isIdentifier(i.property) || i.property.name !== "map" && i.property.name !== "flatMap") return !1;
|
|
1079
|
+
let r = n.arguments[0];
|
|
1080
|
+
return (e.isArrowFunctionExpression(r) || e.isFunctionExpression(r)) && mi(r);
|
|
1081
|
+
}
|
|
1082
|
+
function mi(n) {
|
|
1083
|
+
if (!e.isBlockStatement(n.body)) return z(n.body);
|
|
1084
|
+
let i = !1, r = (t) => {
|
|
1085
|
+
if (!(i || t == null || typeof t.type != "string" || e.isFunction(t))) {
|
|
1086
|
+
if (e.isReturnStatement(t) && t.argument != null && z(t.argument)) {
|
|
1087
|
+
i = !0;
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
for (let s of e.VISITOR_KEYS[t.type] || []) {
|
|
1091
|
+
let o = t[s];
|
|
1092
|
+
Array.isArray(o) ? o.forEach(r) : r(o);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
return n.body.body.forEach(r), i;
|
|
1097
|
+
}
|
|
1098
|
+
function Ei(n, i) {
|
|
1099
|
+
let { node: r } = n, t = r.openingElement.attributes, s = r.children, o = null, l = null, c = null;
|
|
1100
|
+
for (let S of t)
|
|
1101
|
+
if (e.isJSXAttribute(S)) {
|
|
1102
|
+
let y = C(S);
|
|
1103
|
+
y === "each" ? o = J(S.value) : y === "key" ? l = J(S.value) : y === "fallback" && (c = J(S.value));
|
|
1104
|
+
}
|
|
1105
|
+
if (!o)
|
|
1106
|
+
return console.warn('[what-compiler] <For> element missing "each" attribute.'), $e(n, i);
|
|
1107
|
+
let a = null;
|
|
1108
|
+
for (let S of s)
|
|
1109
|
+
if (e.isJSXExpressionContainer(S) && !e.isJSXEmptyExpression(S.expression)) {
|
|
1110
|
+
a = S.expression;
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
1113
|
+
if (!a)
|
|
1114
|
+
return console.warn("[what-compiler] <For> element missing render function child."), $e(n, i);
|
|
1115
|
+
i.needsGeneralMapArray = !0, !e.isIdentifier(o) && !e.isArrowFunctionExpression(o) && !e.isFunctionExpression(o) && D(o, i.signalNames, i.importedIdentifiers) && (o = e.arrowFunctionExpression([], Wn(o, i)));
|
|
1116
|
+
let x = (S) => {
|
|
1117
|
+
let y = [S, a];
|
|
1118
|
+
if (l) {
|
|
1119
|
+
let F = [e.objectProperty(e.identifier("key"), l)];
|
|
1120
|
+
un(a) && F.push(pn(i));
|
|
1121
|
+
let A = Je(r);
|
|
1122
|
+
A !== null && F.push(e.objectProperty(e.identifier("slot"), A)), y.push(e.objectExpression(F));
|
|
1123
|
+
}
|
|
1124
|
+
let b = e.callExpression(h(i, "_$mapArray"), y);
|
|
1125
|
+
return b._whatList = !0, b;
|
|
1126
|
+
};
|
|
1127
|
+
if (!c)
|
|
1128
|
+
return x(o);
|
|
1129
|
+
i._pendingSetup || (i._pendingSetup = []);
|
|
1130
|
+
let d = P(i, "_each$"), p = P(i, "_for$"), f = P(i, "_fb$"), E = i.nextMemoId(), g = n.scope ? n.scope.generateUidIdentifier("list") : e.identifier("_list"), $ = e.conditionalExpression(
|
|
1131
|
+
e.binaryExpression(
|
|
1132
|
+
"===",
|
|
1133
|
+
e.unaryExpression("typeof", e.identifier(d)),
|
|
1134
|
+
e.stringLiteral("function")
|
|
1135
|
+
),
|
|
1136
|
+
e.callExpression(e.identifier(d), []),
|
|
1137
|
+
e.identifier(d)
|
|
1138
|
+
);
|
|
1139
|
+
i._pendingSetup.push(
|
|
1140
|
+
e.variableDeclaration("const", [
|
|
1141
|
+
e.variableDeclarator(e.identifier(d), o)
|
|
1142
|
+
]),
|
|
1143
|
+
e.variableDeclaration("const", [
|
|
1144
|
+
e.variableDeclarator(
|
|
1145
|
+
e.identifier(E),
|
|
1146
|
+
e.callExpression(h(i, "_$memo"), [
|
|
1147
|
+
e.arrowFunctionExpression([], e.blockStatement([
|
|
1148
|
+
e.variableDeclaration("const", [
|
|
1149
|
+
e.variableDeclarator(g, $)
|
|
1150
|
+
]),
|
|
1151
|
+
e.returnStatement(
|
|
1152
|
+
e.unaryExpression("!", e.unaryExpression(
|
|
1153
|
+
"!",
|
|
1154
|
+
e.logicalExpression(
|
|
1155
|
+
"&&",
|
|
1156
|
+
e.cloneNode(g),
|
|
1157
|
+
e.memberExpression(e.cloneNode(g), e.identifier("length"))
|
|
1158
|
+
)
|
|
1159
|
+
))
|
|
1160
|
+
)
|
|
1161
|
+
]))
|
|
1162
|
+
])
|
|
1163
|
+
)
|
|
1164
|
+
]),
|
|
1165
|
+
e.variableDeclaration("const", [
|
|
1166
|
+
e.variableDeclarator(e.identifier(p), x(e.identifier(d)))
|
|
1167
|
+
]),
|
|
1168
|
+
// The fallback thunk is hoisted rather than written inline in the
|
|
1169
|
+
// inserter below so that the inserter's body mentions no user code at
|
|
1170
|
+
// all. Its parameters can then be given fixed names without any risk of
|
|
1171
|
+
// capturing an identifier the fallback expression wanted from an outer
|
|
1172
|
+
// scope — this function is also called with a synthetic `{ node }` path
|
|
1173
|
+
// that carries no scope to generate a unique name from.
|
|
1174
|
+
e.variableDeclaration("const", [
|
|
1175
|
+
e.variableDeclarator(
|
|
1176
|
+
e.identifier(f),
|
|
1177
|
+
e.arrowFunctionExpression([], e.conditionalExpression(
|
|
1178
|
+
e.callExpression(e.identifier(E), []),
|
|
1179
|
+
e.nullLiteral(),
|
|
1180
|
+
c
|
|
1181
|
+
))
|
|
1182
|
+
)
|
|
1183
|
+
])
|
|
1184
|
+
), i.needsGeneralInsert = !0;
|
|
1185
|
+
let u = e.identifier("_parent"), m = e.identifier("_marker"), _ = e.identifier("_end");
|
|
1186
|
+
return e.callExpression(
|
|
1187
|
+
e.memberExpression(e.identifier("Object"), e.identifier("assign")),
|
|
1188
|
+
[
|
|
1189
|
+
e.arrowFunctionExpression(
|
|
1190
|
+
[u, m],
|
|
1191
|
+
e.blockStatement([
|
|
1192
|
+
// The list goes in first so its `<!--/list-->` end marker sits
|
|
1193
|
+
// BEFORE the fallback: rows render above the empty state, and the
|
|
1194
|
+
// return value stays the end marker every other mapArray inserter
|
|
1195
|
+
// hands back.
|
|
1196
|
+
e.variableDeclaration("const", [
|
|
1197
|
+
e.variableDeclarator(_, e.callExpression(e.identifier(p), [
|
|
1198
|
+
e.cloneNode(u),
|
|
1199
|
+
e.cloneNode(m)
|
|
1200
|
+
]))
|
|
1201
|
+
]),
|
|
1202
|
+
// The thunk is wrapped in an ARRAY on purpose. `insert()` has two
|
|
1203
|
+
// ways to mount a function and only one of them survives here:
|
|
1204
|
+
// - passed bare, it takes insert's own reactive branch, whose
|
|
1205
|
+
// effect closes over the `parent` it was handed. When this
|
|
1206
|
+
// inserter is mounted through createDOM (a <For> as a component's
|
|
1207
|
+
// return value, at a fragment root, or inside a <Show> arm)
|
|
1208
|
+
// that parent is a throwaway DocumentFragment which is emptied
|
|
1209
|
+
// into the real container straight after. Every later run then
|
|
1210
|
+
// reconciles against a detached node, so the fallback was never
|
|
1211
|
+
// removed once rows arrived and stayed on screen underneath them.
|
|
1212
|
+
// - wrapped in an array, it goes through valuesToNodes -> createDOM,
|
|
1213
|
+
// whose reactive branch re-reads `endMarker.parentNode` on every
|
|
1214
|
+
// run. That is the same live-parent resolution mapArray does for
|
|
1215
|
+
// exactly this reason, so both halves survive being moved.
|
|
1216
|
+
e.expressionStatement(e.callExpression(h(i, "_$insert"), [
|
|
1217
|
+
e.cloneNode(u),
|
|
1218
|
+
e.arrayExpression([e.identifier(f)]),
|
|
1219
|
+
e.cloneNode(m)
|
|
1220
|
+
])),
|
|
1221
|
+
e.returnStatement(e.cloneNode(_))
|
|
1222
|
+
])
|
|
1223
|
+
),
|
|
1224
|
+
e.identifier(p),
|
|
1225
|
+
// Hydratable output also hands over the fallback, which hydrate()
|
|
1226
|
+
// adopts beside the list's rows (render.js adoptList).
|
|
1227
|
+
...i.hydratable ? [e.objectExpression([e.objectProperty(e.identifier("_fallback"), e.identifier(f))])] : []
|
|
1228
|
+
]
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1231
|
+
function hi(n, i) {
|
|
1232
|
+
let { node: r } = n, t = r.openingElement.attributes, s = r.children, o = null, l = null;
|
|
1233
|
+
for (let E of t)
|
|
1234
|
+
if (e.isJSXAttribute(E)) {
|
|
1235
|
+
let g = C(E);
|
|
1236
|
+
g === "when" ? o = J(E.value) : g === "fallback" && (l = J(E.value));
|
|
1237
|
+
}
|
|
1238
|
+
if (!o)
|
|
1239
|
+
throw In(
|
|
1240
|
+
n,
|
|
1241
|
+
i,
|
|
1242
|
+
'<Show> requires a "when" prop. Example: <Show when={isOpen} fallback={null}>...</Show>'
|
|
1243
|
+
);
|
|
1244
|
+
let c = zn(s);
|
|
1245
|
+
if (!c) {
|
|
1246
|
+
i._pendingSetup || (i._pendingSetup = []);
|
|
1247
|
+
let E = i._pendingSetup.length;
|
|
1248
|
+
c = $n(s, i);
|
|
1249
|
+
let g = i._pendingSetup.splice(E);
|
|
1250
|
+
g.length > 0 && (c = e.callExpression(
|
|
1251
|
+
e.arrowFunctionExpression([], e.blockStatement([...g, e.returnStatement(c)])),
|
|
1252
|
+
[]
|
|
1253
|
+
));
|
|
1254
|
+
}
|
|
1255
|
+
let a = sn(o, i), x = n.scope ? n.scope.generateUidIdentifier("v") : e.identifier("_v"), d = e.isFunction(c), p = d ? e.callExpression(c, [e.cloneNode(x)]) : c;
|
|
1256
|
+
i._pendingSetup || (i._pendingSetup = []);
|
|
1257
|
+
let f = l && xe(l, i._pendingSetup, i) || l || e.nullLiteral();
|
|
1258
|
+
if (D(a, i.signalNames, i.importedIdentifiers)) {
|
|
1259
|
+
let E = i.nextMemoId(), g = d ? a : e.unaryExpression("!", e.unaryExpression("!", a));
|
|
1260
|
+
i._pendingSetup || (i._pendingSetup = []), i._pendingSetup.push(
|
|
1261
|
+
e.variableDeclaration("const", [
|
|
1262
|
+
e.variableDeclarator(
|
|
1263
|
+
e.identifier(E),
|
|
1264
|
+
e.callExpression(h(i, "_$memo"), [
|
|
1265
|
+
e.arrowFunctionExpression([], g)
|
|
1266
|
+
])
|
|
1267
|
+
)
|
|
1268
|
+
])
|
|
1269
|
+
), a = e.callExpression(e.identifier(E), []);
|
|
1270
|
+
}
|
|
1271
|
+
return e.arrowFunctionExpression([], e.blockStatement([
|
|
1272
|
+
e.variableDeclaration("const", [
|
|
1273
|
+
e.variableDeclarator(x, a)
|
|
1274
|
+
]),
|
|
1275
|
+
e.returnStatement(
|
|
1276
|
+
e.conditionalExpression(e.cloneNode(x), p, f)
|
|
1277
|
+
)
|
|
1278
|
+
]));
|
|
1279
|
+
}
|
|
1280
|
+
function $n(n, i) {
|
|
1281
|
+
let r = [];
|
|
1282
|
+
for (let t of n)
|
|
1283
|
+
if (e.isJSXText(t)) {
|
|
1284
|
+
let s = te(t.value);
|
|
1285
|
+
s && r.push({ expr: e.stringLiteral(s), setup: [] });
|
|
1286
|
+
} else e.isJSXExpressionContainer(t) ? e.isJSXEmptyExpression(t.expression) || r.push(j(i, () => De(t.expression, i))) : e.isJSXElement(t) ? r.push(j(i, () => q({ node: t }, i))) : e.isJSXFragment(t) && r.push(j(i, () => se({ node: t }, i)));
|
|
1287
|
+
return r.length === 0 ? e.nullLiteral() : r.length === 1 ? r[0].expr : Me(r, i, !1, !0);
|
|
1288
|
+
}
|
|
1289
|
+
function xi(n, i) {
|
|
1290
|
+
let r = Mn(n, i);
|
|
1291
|
+
if (r === null) return yn(n, i);
|
|
1292
|
+
let { arms: t, fallback: s } = r;
|
|
1293
|
+
i._pendingSetup || (i._pendingSetup = []);
|
|
1294
|
+
let o = [];
|
|
1295
|
+
for (let { when: p, children: f } of t) {
|
|
1296
|
+
let E = i._pendingSetup.length, g = $n(f, i), $ = i._pendingSetup.splice(E);
|
|
1297
|
+
$.length > 0 && (g = e.callExpression(
|
|
1298
|
+
e.arrowFunctionExpression([], e.blockStatement([...$, e.returnStatement(g)])),
|
|
1299
|
+
[]
|
|
1300
|
+
)), o.push([sn(p, i), g]);
|
|
1301
|
+
}
|
|
1302
|
+
let l = o.some(([p]) => D(p, i.signalNames, i.importedIdentifiers)), c = s && xe(s, i._pendingSetup, i) || s || e.nullLiteral();
|
|
1303
|
+
if (!l) {
|
|
1304
|
+
let p = c;
|
|
1305
|
+
for (let f = o.length - 1; f >= 0; f--)
|
|
1306
|
+
p = e.conditionalExpression(o[f][0], o[f][1], p);
|
|
1307
|
+
return e.arrowFunctionExpression([], p);
|
|
1308
|
+
}
|
|
1309
|
+
let a = e.numericLiteral(-1);
|
|
1310
|
+
for (let p = o.length - 1; p >= 0; p--)
|
|
1311
|
+
a = e.conditionalExpression(o[p][0], e.numericLiteral(p), a);
|
|
1312
|
+
let x = i.nextMemoId();
|
|
1313
|
+
i._pendingSetup.push(
|
|
1314
|
+
e.variableDeclaration("const", [
|
|
1315
|
+
e.variableDeclarator(
|
|
1316
|
+
e.identifier(x),
|
|
1317
|
+
e.callExpression(h(i, "_$memo"), [e.arrowFunctionExpression([], a)])
|
|
1318
|
+
)
|
|
1319
|
+
])
|
|
1320
|
+
);
|
|
1321
|
+
let d = c;
|
|
1322
|
+
for (let p = o.length - 1; p >= 0; p--)
|
|
1323
|
+
d = e.conditionalExpression(
|
|
1324
|
+
e.binaryExpression("===", e.callExpression(e.identifier(x), []), e.numericLiteral(p)),
|
|
1325
|
+
o[p][1],
|
|
1326
|
+
d
|
|
1327
|
+
);
|
|
1328
|
+
return e.arrowFunctionExpression([], d);
|
|
1329
|
+
}
|
|
1330
|
+
function De(n, i) {
|
|
1331
|
+
i._pendingSetup || (i._pendingSetup = []);
|
|
1332
|
+
let r = i._pendingSetup, t = cn(n, i);
|
|
1333
|
+
if (t) {
|
|
1334
|
+
let s = Y(t);
|
|
1335
|
+
if (e.isArrowFunctionExpression(t) && e.isExpression(t.body))
|
|
1336
|
+
return t.body = K(t.body, r, i), t;
|
|
1337
|
+
if (s) return t;
|
|
1338
|
+
let l = K(t, r, i);
|
|
1339
|
+
return e.arrowFunctionExpression([], l);
|
|
1340
|
+
}
|
|
1341
|
+
return Y(n) ? (_n(n, i), n) : D(n, i.signalNames, i.importedIdentifiers) ? (n = K(n, r, i), e.arrowFunctionExpression([], W(n, i, !0))) : W(n, i, !1);
|
|
1342
|
+
}
|
|
1343
|
+
function W(n, i, r) {
|
|
1344
|
+
if (!i.hydratable) return n;
|
|
1345
|
+
if (e.isArrayExpression(n) && n.elements.some(ue) && n.elements.every((o) => o !== null && !e.isSpreadElement(o))) {
|
|
1346
|
+
let o = [], l = n.elements.map((a, x) => {
|
|
1347
|
+
let d = e.identifier(P(i, "_m$"));
|
|
1348
|
+
a._whatInPlace = !0, B(a);
|
|
1349
|
+
let p = e.isJSXElement(a) && !gi(a, i) ? a : e.callExpression(h(i, "_$member"), [a, e.numericLiteral(x)]);
|
|
1350
|
+
return o.push(e.variableDeclaration("const", [e.variableDeclarator(d, p)])), e.cloneNode(d);
|
|
1351
|
+
});
|
|
1352
|
+
o.push(e.returnStatement(e.arrayExpression(l)));
|
|
1353
|
+
let c = [e.arrowFunctionExpression([], e.blockStatement(o))];
|
|
1354
|
+
return r || c.push(e.numericLiteral(1)), e.callExpression(h(i, "_$members"), c);
|
|
1355
|
+
}
|
|
1356
|
+
if (e.isConditionalExpression(n))
|
|
1357
|
+
return n.consequent = W(n.consequent, i, r), n.alternate = W(n.alternate, i, r), n;
|
|
1358
|
+
if (e.isLogicalExpression(n))
|
|
1359
|
+
return n.right = W(n.right, i, r), n;
|
|
1360
|
+
if (!r || !e.isCallExpression(n) || !e.isMemberExpression(n.callee) || n.callee.computed || !e.isIdentifier(n.callee.property, { name: "map" })) return n;
|
|
1361
|
+
let t = n.arguments[0];
|
|
1362
|
+
if (!e.isArrowFunctionExpression(t) && !e.isFunctionExpression(t)) return n;
|
|
1363
|
+
let s = t.body;
|
|
1364
|
+
if (e.isBlockStatement(s)) {
|
|
1365
|
+
let o = s.body[s.body.length - 1];
|
|
1366
|
+
s = e.isReturnStatement(o) ? o.argument : null;
|
|
1367
|
+
}
|
|
1368
|
+
return !e.isJSXElement(s) || !Q(s) ? n : e.callExpression(h(i, "_$members"), [e.arrowFunctionExpression([], n)]);
|
|
1369
|
+
}
|
|
1370
|
+
function gi(n, i) {
|
|
1371
|
+
let r = Le(n, i);
|
|
1372
|
+
return r === "For" || r === "Show" || r === "Switch" || r === null && he(n, i) !== null;
|
|
1373
|
+
}
|
|
1374
|
+
function se(n, i) {
|
|
1375
|
+
let { node: r } = n, t = r.children, s = [];
|
|
1376
|
+
for (let l of t)
|
|
1377
|
+
if (e.isJSXText(l)) {
|
|
1378
|
+
let c = te(l.value);
|
|
1379
|
+
c && s.push({ expr: e.stringLiteral(c), setup: [] });
|
|
1380
|
+
} else e.isJSXExpressionContainer(l) ? e.isJSXEmptyExpression(l.expression) || s.push(j(i, () => De(l.expression, i))) : e.isJSXElement(l) ? s.push(j(i, () => q({ node: l }, i))) : e.isJSXFragment(l) && s.push(j(i, () => se({ node: l }, i)));
|
|
1381
|
+
if (s.length === 1) return s[0].expr;
|
|
1382
|
+
let o = n.parentPath ? _i(n) : !1;
|
|
1383
|
+
return Me(s, i, o, !o);
|
|
1384
|
+
}
|
|
1385
|
+
function _i(n) {
|
|
1386
|
+
let i = n;
|
|
1387
|
+
for (; ; ) {
|
|
1388
|
+
let r = i.parentPath;
|
|
1389
|
+
if (!r || r.isArrayExpression()) return r !== null;
|
|
1390
|
+
if (r.isReturnStatement() || r.isArrowFunctionExpression() && i.key === "body") {
|
|
1391
|
+
let s = r.isReturnStatement() ? r.getFunctionParent() : r;
|
|
1392
|
+
return s !== null && s.parentPath.isCallExpression() && s.listKey === "arguments";
|
|
1393
|
+
}
|
|
1394
|
+
if (!(r.isConditionalExpression() && i.key !== "test" || r.isLogicalExpression() && i.key === "right" || r.isParenthesizedExpression() || r.isTSAsExpression() || r.isTSNonNullExpression())) return !1;
|
|
1395
|
+
i = r;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
function j(n, i) {
|
|
1399
|
+
n._pendingSetup || (n._pendingSetup = []);
|
|
1400
|
+
let r = n._pendingSetup.length;
|
|
1401
|
+
return { expr: i(), setup: n._pendingSetup.slice(r) };
|
|
1402
|
+
}
|
|
1403
|
+
function Me(n, i, r = !1, t = !1, s = !1) {
|
|
1404
|
+
if (i.hydratable) for (let x of n) B(x.expr);
|
|
1405
|
+
if (!i.hydratable || !(s || Si(n, i, r, t))) return e.arrayExpression(n.map((x) => x.expr));
|
|
1406
|
+
let o = n.reduce((x, d) => x + d.setup.length, 0);
|
|
1407
|
+
i._pendingSetup.splice(i._pendingSetup.length - o, o);
|
|
1408
|
+
let l = [], c = n.map((x, d) => {
|
|
1409
|
+
if (l.push(...x.setup), e.isIdentifier(x.expr) && re(x, i)) return x.expr;
|
|
1410
|
+
let p = e.identifier(P(i, "_m$"));
|
|
1411
|
+
x.expr._whatInPlace = !0;
|
|
1412
|
+
let f = re(x, i) ? x.expr : e.callExpression(h(i, "_$member"), [x.expr, e.numericLiteral(d)]);
|
|
1413
|
+
return l.push(e.variableDeclaration("const", [e.variableDeclarator(p, f)])), e.cloneNode(p);
|
|
1414
|
+
});
|
|
1415
|
+
l.push(e.returnStatement(e.arrayExpression(c)));
|
|
1416
|
+
let a = [e.arrowFunctionExpression([], e.blockStatement(l))];
|
|
1417
|
+
return r && a.push(e.numericLiteral(1)), e.callExpression(h(i, "_$members"), a);
|
|
1418
|
+
}
|
|
1419
|
+
function Si(n, i, r, t) {
|
|
1420
|
+
if (n.some((l) => wn(l.expr, i)) || t && n.length > 1 && n.some((l) => $i(l.expr, i)) || r && n.some((l) => !re(l, i))) return !0;
|
|
1421
|
+
let s = !1, o = !1;
|
|
1422
|
+
for (let l of n) {
|
|
1423
|
+
let c = l.setup.some((x) => wi(x, i)), a = vi(l.expr);
|
|
1424
|
+
if (s && (c || a) || o && c) return !0;
|
|
1425
|
+
re(l, i) || (s = !0), a && (o = !0);
|
|
1426
|
+
}
|
|
1427
|
+
return !1;
|
|
1428
|
+
}
|
|
1429
|
+
function B(n) {
|
|
1430
|
+
e.isConditionalExpression(n) ? (B(n.consequent), B(n.alternate)) : e.isLogicalExpression(n) ? (B(n.left), B(n.right)) : e.isCallExpression(n) && n.callee._whatPlace === !0 && n.arguments.length === 2 && n.arguments.push(e.numericLiteral(1));
|
|
1431
|
+
}
|
|
1432
|
+
var yi = ["_$claim", "_$claimControl", "_$createComponent", "_$members"];
|
|
1433
|
+
function wn(n, i) {
|
|
1434
|
+
return e.isCallExpression(n) && e.isIdentifier(n.callee) && ee(i).get("_$members") === n.callee.name;
|
|
1435
|
+
}
|
|
1436
|
+
function bi(n, i) {
|
|
1437
|
+
if (!e.isIdentifier(n.callee)) return !1;
|
|
1438
|
+
for (let r of ee(i).values()) if (r === n.callee.name) return !0;
|
|
1439
|
+
return !1;
|
|
1440
|
+
}
|
|
1441
|
+
function $i(n, i) {
|
|
1442
|
+
return n = bn(n, i), e.isCallExpression(n) && e.isIdentifier(n.callee) && ee(i).get("_$createComponent") === n.callee.name;
|
|
1443
|
+
}
|
|
1444
|
+
function Ce(n, i) {
|
|
1445
|
+
return n = bn(n, i), e.isCallExpression(n) && e.isIdentifier(n.callee) && yi.some((r) => ee(i).get(r) === n.callee.name);
|
|
1446
|
+
}
|
|
1447
|
+
function wi(n, i) {
|
|
1448
|
+
let r = !1;
|
|
1449
|
+
return e.traverseFast(n, (t) => {
|
|
1450
|
+
!r && Ce(t, i) && (r = !0);
|
|
1451
|
+
}), r;
|
|
1452
|
+
}
|
|
1453
|
+
function re(n, i) {
|
|
1454
|
+
return Ce(n.expr, i) ? !0 : e.isIdentifier(n.expr) && n.setup.some((r) => e.isVariableDeclaration(r) && r.declarations.some((t) => e.isIdentifier(t.id, { name: n.expr.name }) && Ce(t.init, i)));
|
|
1455
|
+
}
|
|
1456
|
+
function vi(n) {
|
|
1457
|
+
return !(e.isLiteral(n) || e.isFunction(n) || e.isIdentifier(n) || Y(n));
|
|
1458
|
+
}
|
|
1459
|
+
var Fi = /(?:<\/[a-zA-Z][\w:.-]*>)+$/;
|
|
1460
|
+
function Ue(n, i, r, t) {
|
|
1461
|
+
let s = 0;
|
|
1462
|
+
r === "svg" && t !== "svg" ? (i = `<svg>${i}</svg>`, s = 2) : r === "math" && t !== "math" && (i = `<math>${i}</math>`, s = 2), i = i.replace(Fi, "");
|
|
1463
|
+
let o = `${s}:${i}`;
|
|
1464
|
+
if (n.templateMap.has(o))
|
|
1465
|
+
return n.templateMap.get(o);
|
|
1466
|
+
let l = P(n, "_tmpl$");
|
|
1467
|
+
return n.templateMap.set(o, l), n.templates.push({ id: l, html: i, flag: s }), l;
|
|
1468
|
+
}
|
|
1469
|
+
function Oi(n, i) {
|
|
1470
|
+
Gn(n, i), i._pendingSetup = [], i._selectorIds = /* @__PURE__ */ new Map();
|
|
1471
|
+
let r = i.hydratable && !ki(n, i), s = (e.isJSXFragment(n.node) ? se : q)(n, i), o = i._pendingSetup;
|
|
1472
|
+
if (i._pendingSetup = [], i._selectorDecls.length > 0 && (o.unshift(...i._selectorDecls), i._selectorDecls = []), r) {
|
|
1473
|
+
o.push(e.returnStatement(s)), n.replaceWith(e.callExpression(h(i, "_$outside"), [e.arrowFunctionExpression([], e.blockStatement(o))]));
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
if (o.length > 0) {
|
|
1477
|
+
let l = n, c = !1, a = !1;
|
|
1478
|
+
for (; l && !l.isStatement(); )
|
|
1479
|
+
(l.isArrowFunctionExpression() || l.isFunctionExpression()) && (c = !0), Jn(l) && (a = !0), l = l.parentPath;
|
|
1480
|
+
l && l.isStatement() && (l.listKey === "body" || l.listKey === "consequent") && Array.isArray(l.container) && !c && !a ? (l.insertBefore(o), n.replaceWith(s)) : n.parentPath.isArrowFunctionExpression() && n.key === "body" ? (o.push(e.returnStatement(s)), n.replaceWith(e.blockStatement(o))) : (o.push(e.returnStatement(s)), n.replaceWith(
|
|
1481
|
+
e.callExpression(
|
|
1482
|
+
e.arrowFunctionExpression([], e.blockStatement(o)),
|
|
1483
|
+
[]
|
|
1484
|
+
)
|
|
1485
|
+
));
|
|
1486
|
+
} else
|
|
1487
|
+
n.replaceWith(s);
|
|
1488
|
+
}
|
|
1489
|
+
function ki(n, i) {
|
|
1490
|
+
let r = n;
|
|
1491
|
+
for (; ; ) {
|
|
1492
|
+
let t = r.parentPath;
|
|
1493
|
+
if (!t) return !1;
|
|
1494
|
+
if (r.node._whatInPlace) return !0;
|
|
1495
|
+
let s = null;
|
|
1496
|
+
if (t.isReturnStatement() ? s = t.getFunctionParent() : t.isArrowFunctionExpression() && r.key === "body" && (s = t), s !== null) {
|
|
1497
|
+
let l = s.parentPath;
|
|
1498
|
+
if (s.listKey !== "arguments" || !(l.isCallExpression() || l.isOptionalCallExpression()) || bi(l.node, i)) return !0;
|
|
1499
|
+
r = l;
|
|
1500
|
+
continue;
|
|
1501
|
+
}
|
|
1502
|
+
if (!(t.isConditionalExpression() && r.key !== "test" || t.isLogicalExpression() && r.key === "right" || t.isSequenceExpression() && r.key === t.node.expressions.length - 1 || t.isArrayExpression() || t.isParenthesizedExpression() || t.isTSAsExpression() || t.isTSNonNullExpression() || t.isTypeCastExpression() || t.isJSXExpressionContainer() && t.parentPath.isJSXElement())) return !1;
|
|
1503
|
+
r = t;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
function Vi(n) {
|
|
1507
|
+
n.needsGeneralMapArray = !1, n.needsLazyProps = !1, n.needsGeneralInsert = !1, n.classComponents = !1, n.makesSelects = !1, n.writesXlink = !1, n.carriesFields = !1, n.marksPropFields = !1, n._selectorDecls = [], n._selectorIds = /* @__PURE__ */ new Map(), n.delegatedEvents = /* @__PURE__ */ new Set(), n.templates = [], n.templateMap = /* @__PURE__ */ new Map(), n.rowFieldReaders = [], n._pendingSetup = [], n.nextVarId = () => P(n, "_el$"), n.nextMemoId = () => P(n, "_c$"), n.hydratable = n.opts?.hydratable === !0;
|
|
1508
|
+
}
|
|
1509
|
+
var Ci = [
|
|
1510
|
+
// The compiler-internal `_$template`, never the public `template`, which
|
|
1511
|
+
// dev-warns for hand-written calls with dynamic strings.
|
|
1512
|
+
// Hydratable output takes `_$htemplate`, which also hands claims the root.
|
|
1513
|
+
["_$template", null],
|
|
1514
|
+
["_$insert", null],
|
|
1515
|
+
["_$effect", "effect"],
|
|
1516
|
+
["_$mapArray", null],
|
|
1517
|
+
["_$item", "_$item"],
|
|
1518
|
+
["_$field", "_$field"],
|
|
1519
|
+
["_$hfield", "_$hfield"],
|
|
1520
|
+
["_$plain", "_$plain"],
|
|
1521
|
+
["_$hplain", "_$hplain"],
|
|
1522
|
+
["_$rowFields", "_$rowFields"],
|
|
1523
|
+
["_$propField", "_$propField"],
|
|
1524
|
+
["_$createSelector", "createSelector"],
|
|
1525
|
+
["_$spread", "_$spread"],
|
|
1526
|
+
["_$spreads", "_$spreads"],
|
|
1527
|
+
["_$xlink", "_$xlink"],
|
|
1528
|
+
["_$controlled", "_$controlled"],
|
|
1529
|
+
["_$setProp", "_$setProp"],
|
|
1530
|
+
["_$retype", "_$retype"],
|
|
1531
|
+
["_$memo", "_$memo"],
|
|
1532
|
+
["_$lazyMemo", "_$lazyMemo"],
|
|
1533
|
+
["_$untrack", "untrack"],
|
|
1534
|
+
["_$keyed", "_$keyed"],
|
|
1535
|
+
["_$Island", "_$Island"],
|
|
1536
|
+
["_$buildDiagnostics", "_$buildDiagnostics"],
|
|
1537
|
+
["_$setClass", "setClass"],
|
|
1538
|
+
["_$className", "className"],
|
|
1539
|
+
["_$setClassList", "setClassList"],
|
|
1540
|
+
["_$applyRef", "applyRef"],
|
|
1541
|
+
["_$setStyle", "setStyle"],
|
|
1542
|
+
["_$setAttr", "setAttr"],
|
|
1543
|
+
["_$setValue", "_$setValue"],
|
|
1544
|
+
["_$setChecked", "setChecked"],
|
|
1545
|
+
["_$createComponent", null],
|
|
1546
|
+
["_$componentVNode", "_$componentVNode"],
|
|
1547
|
+
["_$hcomponentVNode", "_$hcomponentVNode"],
|
|
1548
|
+
["_$delegateEvents", "delegateEvents"],
|
|
1549
|
+
["_$changes", "_$changes"],
|
|
1550
|
+
["_$own", "_$own"],
|
|
1551
|
+
["_$on", "on"],
|
|
1552
|
+
["_$claim", "_$claim"],
|
|
1553
|
+
["_$next", "_$next"],
|
|
1554
|
+
["_$control", "_$control"],
|
|
1555
|
+
["_$claimControl", "_$claimControl"],
|
|
1556
|
+
["_$skip", "_$skip"],
|
|
1557
|
+
["_$hole", "_$hole"],
|
|
1558
|
+
["_$exit", "_$exit"],
|
|
1559
|
+
["_$outside", "_$outside"],
|
|
1560
|
+
["_$members", "_$members"],
|
|
1561
|
+
["_$member", "_$member"],
|
|
1562
|
+
["_$slots", "_$slots"],
|
|
1563
|
+
["_$place", "_$place"],
|
|
1564
|
+
["_$merge", "_$merge"],
|
|
1565
|
+
["_$marked", "_$marked"],
|
|
1566
|
+
["_$omit", "_$omit"],
|
|
1567
|
+
["_$inNs", "_$inNs"],
|
|
1568
|
+
["_$selects", "_$selects"],
|
|
1569
|
+
["_$carryFields", "_$carryFields"]
|
|
1570
|
+
];
|
|
1571
|
+
function Ai(n, i) {
|
|
1572
|
+
return n === "_$mapArray" ? i.needsGeneralMapArray ? "mapArray" : "_$mapKeyed" : n === "_$template" ? i.hydratable ? "_$htemplate" : "_$template" : n === "_$insert" ? i.needsGeneralInsert ? "insert" : "_$reactive" : i.hydratable ? i.classComponents ? "_$hcreateComponent" : "_$hcreateFn" : i.needsLazyProps ? i.classComponents ? "_$createComponent" : "_$createLazyFn" : i.classComponents ? "_$createLeaf" : "_$createFn";
|
|
1573
|
+
}
|
|
1574
|
+
var vn = /* @__PURE__ */ new Set(["what-framework", "what-core", "what-framework/router", "what-router"]);
|
|
1575
|
+
function Li(n, i, r) {
|
|
1576
|
+
if (!e.isJSXIdentifier(i) || n == null) return !1;
|
|
1577
|
+
let t = n.getBinding(i.name);
|
|
1578
|
+
if (!t || !t.constant) return !1;
|
|
1579
|
+
let s = t.path;
|
|
1580
|
+
if (t.kind === "module")
|
|
1581
|
+
return e.isImportSpecifier(s.node) && vn.has(s.parent.source.value);
|
|
1582
|
+
let o = (a) => e.isCallExpression(a) && e.isIdentifier(a.callee) && r.has(a.callee.name), l = null;
|
|
1583
|
+
if (e.isFunctionDeclaration(s.node)) l = s.node;
|
|
1584
|
+
else if (e.isVariableDeclarator(s.node)) {
|
|
1585
|
+
let a = o(s.node.init) && s.node.init.arguments.length === 1 ? s.node.init.arguments[0] : s.node.init;
|
|
1586
|
+
(e.isArrowFunctionExpression(a) || e.isFunctionExpression(a)) && (l = a);
|
|
1587
|
+
}
|
|
1588
|
+
if (l === null || l.async || l.generator) return !1;
|
|
1589
|
+
if (e.isArrowFunctionExpression(l)) return !0;
|
|
1590
|
+
let c = e.isVariableDeclarator(s.node) ? s.parentPath : s;
|
|
1591
|
+
return e.isExportNamedDeclaration(c.parent) || e.isExportDefaultDeclaration(c.parent) ? !1 : t.referencePaths.every((a) => a.node._whatTag === !0 || e.isJSXOpeningElement(a.parent) || e.isJSXClosingElement(a.parent) || a.listKey === "arguments" && o(a.parent));
|
|
1592
|
+
}
|
|
1593
|
+
function Ii(n, i) {
|
|
1594
|
+
let r = i;
|
|
1595
|
+
for (; e.isJSXMemberExpression(r); ) r = r.object;
|
|
1596
|
+
return (e.isJSXIdentifier(r) && n != null ? n.getBinding(r.name) : null)?.kind !== "module";
|
|
1597
|
+
}
|
|
1598
|
+
function He(n) {
|
|
1599
|
+
return e.isArrayExpression(n) && n.elements.length === 0;
|
|
1600
|
+
}
|
|
1601
|
+
var Ni = ["h"];
|
|
1602
|
+
function zi(n, i) {
|
|
1603
|
+
let r = null;
|
|
1604
|
+
if (i.delegatedEvents.size > 0) {
|
|
1605
|
+
let l = [...i.delegatedEvents].filter((x) => x !== "change"), c = [];
|
|
1606
|
+
l.length > 0 && c.push(e.expressionStatement(
|
|
1607
|
+
e.callExpression(h(i, "_$delegateEvents"), [e.arrayExpression(l.map((x) => e.stringLiteral(x)))])
|
|
1608
|
+
)), i.delegatedEvents.has("change") && c.push(e.expressionStatement(e.callExpression(h(i, "_$changes"), [])));
|
|
1609
|
+
let a = e.functionDeclaration(
|
|
1610
|
+
h(i, "_$delegate$"),
|
|
1611
|
+
[e.identifier("el")],
|
|
1612
|
+
e.blockStatement([
|
|
1613
|
+
e.expressionStatement(e.callExpression(h(i, "_$own"), [e.identifier("el")])),
|
|
1614
|
+
e.ifStatement(
|
|
1615
|
+
h(i, "_$delegated$"),
|
|
1616
|
+
e.returnStatement()
|
|
1617
|
+
),
|
|
1618
|
+
e.expressionStatement(
|
|
1619
|
+
e.assignmentExpression("=", h(i, "_$delegated$"), e.booleanLiteral(!0))
|
|
1620
|
+
),
|
|
1621
|
+
...c
|
|
1622
|
+
])
|
|
1623
|
+
);
|
|
1624
|
+
r = [
|
|
1625
|
+
e.variableDeclaration("let", [
|
|
1626
|
+
e.variableDeclarator(h(i, "_$delegated$"), e.booleanLiteral(!1))
|
|
1627
|
+
]),
|
|
1628
|
+
a
|
|
1629
|
+
];
|
|
1630
|
+
}
|
|
1631
|
+
i.makesSelects && n.unshiftContainer("body", e.expressionStatement(e.callExpression(h(i, "_$selects"), []))), i.writesXlink && n.unshiftContainer("body", e.expressionStatement(e.callExpression(h(i, "_$xlink"), []))), i.carriesFields && n.unshiftContainer("body", e.expressionStatement(e.callExpression(h(i, "_$carryFields"), [])));
|
|
1632
|
+
for (let l of i.rowFieldReaders.reverse())
|
|
1633
|
+
n.unshiftContainer("body", e.variableDeclaration("const", [e.variableDeclarator(e.identifier(l.id), l.fn)]));
|
|
1634
|
+
for (let l of i.templates.reverse()) {
|
|
1635
|
+
let c = e.callExpression(h(i, "_$template"), l.flag ? [e.stringLiteral(l.html), e.numericLiteral(l.flag)] : [e.stringLiteral(l.html)]);
|
|
1636
|
+
e.addComment(c, "leading", " @__PURE__ "), n.unshiftContainer(
|
|
1637
|
+
"body",
|
|
1638
|
+
e.variableDeclaration("const", [
|
|
1639
|
+
e.variableDeclarator(e.identifier(l.id), c)
|
|
1640
|
+
])
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
if (i._buildDiagnostics?.length) {
|
|
1644
|
+
let l = i._buildDiagnostics.map(Bn);
|
|
1645
|
+
n.pushContainer("body", e.expressionStatement(e.callExpression(h(i, "_$buildDiagnostics"), [e.arrayExpression(l)])));
|
|
1646
|
+
}
|
|
1647
|
+
let t = ee(i);
|
|
1648
|
+
i.file?.metadata && (t.has("_$template") || t.has("_$createComponent")) && (i.file.metadata.whatBuildsDom = !0);
|
|
1649
|
+
let s = [];
|
|
1650
|
+
for (let [l, c] of Ci) {
|
|
1651
|
+
let a = t.get(l);
|
|
1652
|
+
if (a === void 0) continue;
|
|
1653
|
+
let x = c ?? Ai(l, i);
|
|
1654
|
+
s.push(e.importSpecifier(e.identifier(a), e.identifier(x)));
|
|
1655
|
+
}
|
|
1656
|
+
ze(n, s, ["what-framework/render", "what-core/render"], "what-framework/render");
|
|
1657
|
+
let o = [];
|
|
1658
|
+
for (let l of Ni) {
|
|
1659
|
+
let c = t.get(l);
|
|
1660
|
+
c !== void 0 && o.push(e.importSpecifier(e.identifier(c), e.identifier(l)));
|
|
1661
|
+
}
|
|
1662
|
+
ze(n, o, ["what-core", "what-framework"], "what-framework"), r && n.unshiftContainer("body", r);
|
|
1663
|
+
}
|
|
1664
|
+
export {
|
|
1665
|
+
zi as finishDomProgram,
|
|
1666
|
+
Vi as initDomState,
|
|
1667
|
+
ci as mayBuildTag,
|
|
1668
|
+
Oi as transformJsxRoot
|
|
1669
|
+
};
|