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,62 @@
|
|
|
1
|
+
// src/framework-files.js
|
|
2
|
+
var f = /* @__PURE__ */ new Set([
|
|
3
|
+
"what-framework",
|
|
4
|
+
"what-core",
|
|
5
|
+
"what-compiler",
|
|
6
|
+
"what-react",
|
|
7
|
+
"what-router",
|
|
8
|
+
"what-server",
|
|
9
|
+
"what-isr",
|
|
10
|
+
"what-devtools",
|
|
11
|
+
"what-devtools-mcp",
|
|
12
|
+
"what-text",
|
|
13
|
+
"what-mcp",
|
|
14
|
+
"eslint-plugin-what",
|
|
15
|
+
"what-framework-cli",
|
|
16
|
+
"create-what"
|
|
17
|
+
]), s = /* @__PURE__ */ new Map();
|
|
18
|
+
function c(t) {
|
|
19
|
+
let n = t.replace(/[\\/][^\\/]*$/, "");
|
|
20
|
+
return n === t || n === "" ? null : n;
|
|
21
|
+
}
|
|
22
|
+
function p(t) {
|
|
23
|
+
let l = String(t).replace(/^\.\//, "").replace(/\/+$/, "").split(/(\*\*\/|\*\*|\*)/).map((e) => e === "**/" ? "(?:.*/)?" : e === "**" ? ".*" : e === "*" ? "[^/]*" : e.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
24
|
+
return new RegExp(`^${l}(?:/.*)?$`);
|
|
25
|
+
}
|
|
26
|
+
function u(t, n) {
|
|
27
|
+
if (s.has(t)) return s.get(t);
|
|
28
|
+
let l, e = null;
|
|
29
|
+
try {
|
|
30
|
+
let a = `${t}/package.json`;
|
|
31
|
+
n.existsSync(a) && (e = JSON.parse(n.readFileSync(a, "utf8")));
|
|
32
|
+
} catch {
|
|
33
|
+
e = null;
|
|
34
|
+
}
|
|
35
|
+
if (e !== null && typeof e.name == "string")
|
|
36
|
+
l = f.has(e.name) ? { name: e.name, root: t, files: Array.isArray(e.files) ? e.files.map(p) : null } : null;
|
|
37
|
+
else {
|
|
38
|
+
let a = c(t);
|
|
39
|
+
l = a === null ? null : u(a, n);
|
|
40
|
+
}
|
|
41
|
+
return s.set(t, l), l;
|
|
42
|
+
}
|
|
43
|
+
function h(t, n, l) {
|
|
44
|
+
if (!n || !t) return !1;
|
|
45
|
+
let e = String(t).replace(/[?#].*$/, "").replace(/\\/g, "/");
|
|
46
|
+
if (e.startsWith("\0") || !e.includes("/")) return !1;
|
|
47
|
+
let a = c(e), r = a === null ? null : u(a, n);
|
|
48
|
+
if (r === null || l !== void 0 && r.name !== l) return !1;
|
|
49
|
+
let o = e.slice(r.root.length + 1);
|
|
50
|
+
return o.startsWith("node_modules/") || o.includes("/node_modules/") ? !1 : r.files === null || r.files.some((i) => i.test(o));
|
|
51
|
+
}
|
|
52
|
+
function w(t) {
|
|
53
|
+
let n = (
|
|
54
|
+
/** @type {any} */
|
|
55
|
+
globalThis.process
|
|
56
|
+
), l = typeof n?.getBuiltinModule == "function" ? n.getBuiltinModule("node:fs") : null;
|
|
57
|
+
return h(t, l);
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
h as isFrameworkFile,
|
|
61
|
+
w as isFrameworkModule
|
|
62
|
+
};
|
package/dist/hot.min.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// src/hot.js
|
|
2
|
+
import { isWhatModuleSource as C } from "./babel/common.min.js";
|
|
3
|
+
var L = "_$hot";
|
|
4
|
+
function F(e) {
|
|
5
|
+
let n = 2166136261;
|
|
6
|
+
for (let t = 0; t < e.length; t++)
|
|
7
|
+
n ^= e.charCodeAt(t), n = Math.imul(n, 16777619);
|
|
8
|
+
return (n >>> 0).toString(36) + e.length.toString(36);
|
|
9
|
+
}
|
|
10
|
+
var M = /^[A-Z]/, T = /^use[A-Z0-9]/, j = /* @__PURE__ */ new Set(["signal", "useState", "useSignal", "useReducer"]);
|
|
11
|
+
function b(e, n) {
|
|
12
|
+
return e.isFunctionExpression(n) || e.isArrowFunctionExpression(n);
|
|
13
|
+
}
|
|
14
|
+
function N(e, n) {
|
|
15
|
+
let t = n.node;
|
|
16
|
+
return e.isFunctionDeclaration(t) || b(e, t) ? t : e.isVariableDeclarator(t) && b(e, t.init) ? t.init : null;
|
|
17
|
+
}
|
|
18
|
+
function K(e, n) {
|
|
19
|
+
if (n === void 0 || n.kind !== "module" || !e.isImportSpecifier(n.path.node)) return null;
|
|
20
|
+
let t = n.path.parent;
|
|
21
|
+
if (!e.isImportDeclaration(t) || !C(t.source.value)) return null;
|
|
22
|
+
let o = n.path.node.imported;
|
|
23
|
+
return e.isIdentifier(o) ? o.name : o.value;
|
|
24
|
+
}
|
|
25
|
+
function P(e, n) {
|
|
26
|
+
if (n == null || typeof n.type != "string") return !1;
|
|
27
|
+
if (n.type === "AwaitExpression" || n.type === "ForOfStatement" && n.await) return !0;
|
|
28
|
+
if (e.isFunction(n)) return !1;
|
|
29
|
+
for (let t of e.VISITOR_KEYS[n.type] || []) {
|
|
30
|
+
let o = n[t];
|
|
31
|
+
if (Array.isArray(o) ? o.some((u) => P(e, u)) : P(e, o)) return !0;
|
|
32
|
+
}
|
|
33
|
+
return !1;
|
|
34
|
+
}
|
|
35
|
+
function _(e, n) {
|
|
36
|
+
let t = !1;
|
|
37
|
+
return e.traverseFast(n, (o) => {
|
|
38
|
+
(o.type === "JSXElement" || o.type === "JSXFragment") && (t = !0);
|
|
39
|
+
}), t;
|
|
40
|
+
}
|
|
41
|
+
var $ = /* @__PURE__ */ new Set(["TSTypeAliasDeclaration", "TSInterfaceDeclaration", "TSDeclareFunction", "EmptyStatement"]);
|
|
42
|
+
function O(e, n) {
|
|
43
|
+
return $.has(n.type) || e.isImportDeclaration(n) || e.isFunctionDeclaration(n) || e.isClassDeclaration(n) || e.isVariableDeclaration(n) || e.isTSEnumDeclaration(n) || e.isTSModuleDeclaration(n) ? !0 : e.isExportAllDeclaration(n) || e.isExportNamedDeclaration(n) ? n.declaration == null || O(e, n.declaration) : !!e.isExportDefaultDeclaration(n);
|
|
44
|
+
}
|
|
45
|
+
function U(e, n, t) {
|
|
46
|
+
let o;
|
|
47
|
+
try {
|
|
48
|
+
o = e.parseSync(n, { filename: t, configFile: !1, babelrc: !1, parserOpts: { plugins: ["jsx", "typescript"] } });
|
|
49
|
+
} catch {
|
|
50
|
+
return !1;
|
|
51
|
+
}
|
|
52
|
+
return o.program.body.some((u) => !O(e.types, u));
|
|
53
|
+
}
|
|
54
|
+
function V(e) {
|
|
55
|
+
let n = e.types;
|
|
56
|
+
return {
|
|
57
|
+
name: "what-hot",
|
|
58
|
+
visitor: {
|
|
59
|
+
Program: {
|
|
60
|
+
enter(t, o) {
|
|
61
|
+
o.hot = R(n, t, o.file.code), o.opts.onMode?.(o.hot.mode);
|
|
62
|
+
},
|
|
63
|
+
exit(t, o) {
|
|
64
|
+
let u = o.hot;
|
|
65
|
+
u.mode !== "reload" && Y(n, t, u, o.opts.file ?? "");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function R(e, n, t) {
|
|
72
|
+
let o = /* @__PURE__ */ new Map(), u = [], f = !1, h = !1, S = 0, p = (r, c, s, x, m) => {
|
|
73
|
+
o.set(r, { name: r, kind: c, node: s, statement: x, order: S++, text: t.slice(s.start, s.end), uses: /* @__PURE__ */ new Map(), ...m });
|
|
74
|
+
}, k = (r, c) => {
|
|
75
|
+
if (e.isFunctionDeclaration(r) || e.isClassDeclaration(r)) {
|
|
76
|
+
if (r.id == null) return;
|
|
77
|
+
let s = r.id.name, x = e.isFunctionDeclaration(r) && M.test(s);
|
|
78
|
+
p(s, x ? "component" : "function", r, c, { hoisted: !0 });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (e.isTSEnumDeclaration(r) || e.isTSModuleDeclaration(r)) {
|
|
82
|
+
e.isIdentifier(r.id) && p(r.id.name, "function", r, c, { hoisted: !1 });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (e.isVariableDeclaration(r))
|
|
86
|
+
for (let s of r.declarations) {
|
|
87
|
+
let x = Object.keys(e.getBindingIdentifiers(s.id)), m = x.some((v) => {
|
|
88
|
+
let I = n.scope.getBinding(v);
|
|
89
|
+
return I !== void 0 && !I.constant;
|
|
90
|
+
}), D = s.init;
|
|
91
|
+
if (e.isIdentifier(s.id) && D != null && b(e, D)) {
|
|
92
|
+
let v = s.id.name;
|
|
93
|
+
m ? p(v, "volatile", s, c) : p(v, M.test(v) ? "component" : "function", s, c, { hoisted: !1 });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
let i = D != null && P(e, D), l = m || i ? "volatile" : "keep", w = x.join(",");
|
|
97
|
+
for (let v of x) p(v, l, s, c, { key: w, declarator: s, awaits: i });
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
for (let r of n.get("body")) {
|
|
101
|
+
let c = r.node;
|
|
102
|
+
if (!O(e, c)) {
|
|
103
|
+
f = !0;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!(e.isImportDeclaration(c) || $.has(c.type))) {
|
|
107
|
+
if (e.isExportAllDeclaration(c)) {
|
|
108
|
+
c.exportKind !== "type" && (h = !0);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (e.isExportNamedDeclaration(c)) {
|
|
112
|
+
if (c.exportKind === "type") continue;
|
|
113
|
+
if (c.source != null) {
|
|
114
|
+
h = !0;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (c.declaration != null) {
|
|
118
|
+
k(c.declaration, r);
|
|
119
|
+
for (let s of Object.keys(e.getOuterBindingIdentifiers(c.declaration))) u.push({ exported: s, local: s });
|
|
120
|
+
}
|
|
121
|
+
for (let s of c.specifiers) {
|
|
122
|
+
if (s.exportKind === "type") continue;
|
|
123
|
+
let x = e.isIdentifier(s.exported) ? s.exported.name : s.exported.value;
|
|
124
|
+
e.isExportSpecifier(s) ? u.push({ exported: x, local: s.local.name }) : h = !0;
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (e.isExportDefaultDeclaration(c)) {
|
|
129
|
+
let s = c.declaration;
|
|
130
|
+
(e.isFunctionDeclaration(s) || e.isClassDeclaration(s)) && s.id != null ? (k(s, r), u.push({ exported: "default", local: s.id.name })) : (e.isFunctionDeclaration(s) || b(e, s)) && _(e, s) ? p("default", "component", s, r, { anonymous: !0 }) : e.isIdentifier(s) ? u.push({ exported: "default", local: s.name }) : h = !0;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
k(c, r);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
let a = /* @__PURE__ */ new Map();
|
|
137
|
+
for (let r of o.values())
|
|
138
|
+
a.has(r.statement.node) || a.set(r.statement.node, []), a.get(r.statement.node).push(r);
|
|
139
|
+
for (let [r, c] of Object.entries(n.scope.bindings)) {
|
|
140
|
+
let s = o.get(r), x = c.kind === "module";
|
|
141
|
+
if (!(s === void 0 && !x))
|
|
142
|
+
for (let m of c.referencePaths) {
|
|
143
|
+
let D = B(e, m, a);
|
|
144
|
+
if (D === null || D.name === r) continue;
|
|
145
|
+
let i = m.parentPath.isCallExpression({ callee: m.node }), l = x ? "import" : s.kind;
|
|
146
|
+
l === "component" && !i || D.uses.set(r, l === "component" ? "function" : l);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
let d = [...o.values()].filter((r) => r.kind === "component");
|
|
150
|
+
for (let { exported: r, local: c } of u) {
|
|
151
|
+
let s = o.get(c);
|
|
152
|
+
s !== void 0 && s.kind === "component" && s.recordKey === void 0 && (s.recordKey = r);
|
|
153
|
+
}
|
|
154
|
+
let y = u.every(({ local: r }) => {
|
|
155
|
+
let c = o.get(r);
|
|
156
|
+
return c !== void 0 && c.kind !== "volatile";
|
|
157
|
+
}), g = f ? "reload" : d.length > 0 && !h && y ? "accept" : "propagate";
|
|
158
|
+
for (let r of o.values()) {
|
|
159
|
+
if (r.kind === "volatile") {
|
|
160
|
+
r.sig = null, r.deps = [];
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
let c = W(r, o);
|
|
164
|
+
r.sig = c.volatile ? null : F(c.text), r.deps = c.deps;
|
|
165
|
+
}
|
|
166
|
+
let E = (n.parent.comments || []).some((r) => /@refresh reset/.test(r.value));
|
|
167
|
+
return { mode: g, bindings: o, exports: u, sites: q(e, n, t, o, E) };
|
|
168
|
+
}
|
|
169
|
+
function q(e, n, t, o, u) {
|
|
170
|
+
let f = /* @__PURE__ */ new Map();
|
|
171
|
+
for (let a of o.values()) {
|
|
172
|
+
if (a.kind !== "component" && !(a.kind === "function" && T.test(a.name))) continue;
|
|
173
|
+
let d = N(e, a);
|
|
174
|
+
d !== null && (a.calls = [], f.set(d, a));
|
|
175
|
+
}
|
|
176
|
+
let h = /* @__PURE__ */ new Map();
|
|
177
|
+
if (f.size === 0) return h;
|
|
178
|
+
let S = [];
|
|
179
|
+
for (let [a, d] of Object.entries(n.scope.bindings)) {
|
|
180
|
+
let y = K(e, d);
|
|
181
|
+
if (!(y !== null ? !j.has(y) : !T.test(a)))
|
|
182
|
+
for (let g of d.referencePaths)
|
|
183
|
+
g.parentPath.isCallExpression({ callee: g.node }) && S.push({ call: g.parentPath, primitive: y, name: a });
|
|
184
|
+
}
|
|
185
|
+
S.sort((a, d) => a.call.node.start - d.call.node.start);
|
|
186
|
+
for (let { call: a, primitive: d, name: y } of S) {
|
|
187
|
+
let g = a.getFunctionParent(), E = g === null ? void 0 : f.get(g.node);
|
|
188
|
+
if (E === void 0) continue;
|
|
189
|
+
if (d === null) {
|
|
190
|
+
E.calls.push({ hook: y });
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (a.findParent((m) => m.node === g.node || m.isLoop()).node !== g.node) continue;
|
|
194
|
+
let r = e.isVariableDeclarator(a.parent) && a.parent.init === a.node ? a.parent : null, c = d === "useReducer" ? a.node.arguments.slice(1) : a.node.arguments, s = (r === null ? "" : t.slice(r.id.start, r.id.end) + "=") + `${d}(${c.map((m) => t.slice(m.start, m.end)).join(", ")})`, x = F(`${E.name}:${E.calls.length}:${s}`);
|
|
195
|
+
E.calls.push({ text: s }), h.set(a.node, { site: x, reducer: d === "useReducer", path: a });
|
|
196
|
+
}
|
|
197
|
+
let p = /* @__PURE__ */ new Map(), k = (a) => {
|
|
198
|
+
if (p.has(a)) return p.get(a);
|
|
199
|
+
p.set(a, "");
|
|
200
|
+
let d = a.calls.map((y) => {
|
|
201
|
+
if (y.hook === void 0) return y.text;
|
|
202
|
+
let g = o.get(y.hook);
|
|
203
|
+
return g !== void 0 && g.calls !== void 0 ? `${y.hook}{${k(g)}}` : y.hook;
|
|
204
|
+
}).join(`
|
|
205
|
+
`);
|
|
206
|
+
return p.set(a, d), d;
|
|
207
|
+
};
|
|
208
|
+
for (let a of f.values()) {
|
|
209
|
+
if (a.kind !== "component") continue;
|
|
210
|
+
let d = k(a);
|
|
211
|
+
a.state = u ? null : d === "" ? void 0 : F(d);
|
|
212
|
+
}
|
|
213
|
+
return h;
|
|
214
|
+
}
|
|
215
|
+
function B(e, n, t) {
|
|
216
|
+
let o = n.find((f) => f.parentPath !== null && f.parentPath.isProgram()), u = o == null ? void 0 : t.get(o.node);
|
|
217
|
+
if (u === void 0) return null;
|
|
218
|
+
for (let f of u)
|
|
219
|
+
if (f.declarator === void 0 && f.node.type !== "VariableDeclarator" || f.node === n.node || n.findParent((h) => h.node === f.node) != null) return f;
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
function W(e, n) {
|
|
223
|
+
let t = /* @__PURE__ */ new Set([e.name]), o = [e], u = [e.text], f = /* @__PURE__ */ new Set(), h = !1;
|
|
224
|
+
for (; o.length > 0; ) {
|
|
225
|
+
let S = o.shift();
|
|
226
|
+
for (let [p, k] of S.uses) {
|
|
227
|
+
if (k === "import") {
|
|
228
|
+
f.add(p);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
let a = n.get(p);
|
|
232
|
+
if (a !== void 0) {
|
|
233
|
+
if (k === "volatile") {
|
|
234
|
+
h = !0;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (k === "keep") {
|
|
238
|
+
e.kind === "keep" && a.order > e.order ? h = !0 : f.add(p);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
t.has(p) || (t.add(p), e.kind === "keep" && !a.hoisted && a.order > e.order && (h = !0), u.push(`${p}=${a.text}`), o.push(a));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return u.sort(), { text: u.join(`
|
|
246
|
+
`), deps: [...f].sort(), volatile: h };
|
|
247
|
+
}
|
|
248
|
+
function z(e, n) {
|
|
249
|
+
if (e.node !== n) return !1;
|
|
250
|
+
let t = e;
|
|
251
|
+
for (; t.parentPath !== null; t = t.parentPath) {
|
|
252
|
+
let o = t.container;
|
|
253
|
+
if (o == null || o[t.key] !== t.node) return !1;
|
|
254
|
+
}
|
|
255
|
+
return t.isProgram();
|
|
256
|
+
}
|
|
257
|
+
function A(e, n) {
|
|
258
|
+
let t = n;
|
|
259
|
+
for (let o = 2; e.scope.hasBinding(t) || e.scope.hasGlobal(t); o++) t = `${n}${o}`;
|
|
260
|
+
return t;
|
|
261
|
+
}
|
|
262
|
+
function J(e) {
|
|
263
|
+
let n = e.node.body.filter((u) => u.type === "ImportDeclaration").map((u) => u.source.value), t = n.some((u) => u === "what-core" || u.startsWith("what-core/")), o = n.some((u) => u === "what-framework" || u.startsWith("what-framework/"));
|
|
264
|
+
return t && !o ? "what-core/hot" : "what-framework/hot";
|
|
265
|
+
}
|
|
266
|
+
function Y(e, n, t, o) {
|
|
267
|
+
let u = e.identifier(A(n, "_$h")), f = e.identifier(A(n, L)), h = () => e.memberExpression(e.metaProperty(e.identifier("import"), e.identifier("meta")), e.identifier("hot")), S = (i, l) => e.callExpression(e.memberExpression(u, e.identifier(i)), l), p = (i) => e.arrowFunctionExpression([], e.arrayExpression(i.deps.map((l) => e.identifier(l)))), k = (i) => i.sig === null ? e.nullLiteral() : e.stringLiteral(i.sig), a = (i, l, w) => S("component", [i, l, k(w), p(w), ...w.state === void 0 ? [] : [w.state === null ? e.nullLiteral() : e.stringLiteral(w.state)]]), d = t.mode === "accept", y = (i, l) => i.replaceWith(S("state", [e.stringLiteral(l.site), e.arrowFunctionExpression([], i.node), ...l.reducer ? [e.numericLiteral(1)] : []]));
|
|
268
|
+
for (let [i, l] of [...t.sites])
|
|
269
|
+
z(l.path, i) && (t.sites.delete(i), y(l.path, l));
|
|
270
|
+
t.sites.size > 0 && n.traverse({
|
|
271
|
+
CallExpression(i) {
|
|
272
|
+
let l = t.sites.get(i.node);
|
|
273
|
+
l !== void 0 && (t.sites.delete(i.node), y(i, l));
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
let g = [
|
|
277
|
+
e.importDeclaration([e.importSpecifier(f, e.identifier(L))], e.stringLiteral(J(n))),
|
|
278
|
+
e.variableDeclaration("const", [e.variableDeclarator(u, e.callExpression(f, [h(), e.numericLiteral(d ? 1 : 0), e.stringLiteral(o)]))])
|
|
279
|
+
];
|
|
280
|
+
d && g.push(e.ifStatement(h(), e.expressionStatement(e.callExpression(e.memberExpression(h(), e.identifier("accept")), [e.memberExpression(u, e.identifier("accept"))]))));
|
|
281
|
+
let E = /* @__PURE__ */ new Map(), r = (i, l) => {
|
|
282
|
+
E.has(i) || E.set(i, []), E.get(i).push(l);
|
|
283
|
+
};
|
|
284
|
+
for (let i of t.bindings.values())
|
|
285
|
+
if (i.kind === "component") {
|
|
286
|
+
if (i.anonymous) {
|
|
287
|
+
let w = i.node, v = e.isFunctionDeclaration(w) ? e.functionExpression(null, w.params, w.body, w.generator, w.async) : w;
|
|
288
|
+
i.statement.node.declaration = a(e.stringLiteral("default"), v, i);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
let l = e.expressionStatement(a(e.stringLiteral(i.recordKey ?? i.name), e.identifier(i.name), i));
|
|
292
|
+
i.hoisted ? g.push(l) : r(i.statement.node, l);
|
|
293
|
+
}
|
|
294
|
+
let c = /* @__PURE__ */ new Set();
|
|
295
|
+
for (let i of t.bindings.values()) {
|
|
296
|
+
if (i.kind !== "keep" && i.kind !== "volatile" || i.declarator.init == null || c.has(i.declarator) || (c.add(i.declarator), i.awaits)) continue;
|
|
297
|
+
let l = t.bindings.get(i.key.split(",")[0]);
|
|
298
|
+
i.declarator.init = S("keep", [e.stringLiteral(i.key), k(l), l.kind === "volatile" ? e.arrowFunctionExpression([], e.arrayExpression([])) : p(l), e.arrowFunctionExpression([], i.declarator.init)]);
|
|
299
|
+
}
|
|
300
|
+
let s = [], x = [];
|
|
301
|
+
for (let { local: i } of t.exports) {
|
|
302
|
+
let l = t.bindings.get(i);
|
|
303
|
+
l === void 0 || l.kind === "component" || (l.kind === "function" && s.push(e.expressionStatement(S("fn", [e.stringLiteral(i), k(l), p(l)]))), x.push(e.stringLiteral(i)));
|
|
304
|
+
}
|
|
305
|
+
s.push(e.expressionStatement(S("done", [e.arrayExpression(x)])));
|
|
306
|
+
let m = n.node.body;
|
|
307
|
+
for (let [i, l] of E) m.splice(m.indexOf(i) + 1, 0, ...l);
|
|
308
|
+
let D = 0;
|
|
309
|
+
for (; D < m.length && m[D].type === "ImportDeclaration"; ) D++;
|
|
310
|
+
m.splice(D, 0, ...g), m.push(...s);
|
|
311
|
+
}
|
|
312
|
+
export {
|
|
313
|
+
V as default,
|
|
314
|
+
U as runsStatements
|
|
315
|
+
};
|