what-compiler 0.13.11 → 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,106 @@
|
|
|
1
|
+
// src/babel/dev-metadata.js
|
|
2
|
+
import { t as e } from "./types.min.js";
|
|
3
|
+
import { importedFrom as m } from "./common.min.js";
|
|
4
|
+
function c(n) {
|
|
5
|
+
return n.opts?.devMetadata === !0 && n.opts?.production !== !0;
|
|
6
|
+
}
|
|
7
|
+
function b(n) {
|
|
8
|
+
if (n._devPath !== void 0) return n._devPath;
|
|
9
|
+
let t = String(n.file?.opts?.filename || "<unknown>").replace(/\\/g, "/").replace(/[?#].*$/, ""), r = String(n.opts?.projectRoot || n.file?.opts?.cwd || "").replace(/\\/g, "/").replace(/\/+$/, "");
|
|
10
|
+
return n._devPath = r && t.startsWith(`${r}/`) ? t.slice(r.length + 1) : t, n._devPath;
|
|
11
|
+
}
|
|
12
|
+
function u(n, t, r) {
|
|
13
|
+
let i = t && t.loc && t.loc.start;
|
|
14
|
+
if (!i) return null;
|
|
15
|
+
let o = typeof r.opts?.sourceLoc == "function" ? r.opts.sourceLoc(i.line, i.column) ?? i : i;
|
|
16
|
+
return `${n}@${b(r)}:${o.line}:${o.column + 1}`;
|
|
17
|
+
}
|
|
18
|
+
function g(n) {
|
|
19
|
+
return e.isJSXMemberExpression(n) ? `${g(n.object)}.${n.property.name}` : e.isJSXNamespacedName(n) ? `${n.namespace.name}:${n.name.name}` : n.name;
|
|
20
|
+
}
|
|
21
|
+
function I(n, t, r) {
|
|
22
|
+
if (!c(t)) return null;
|
|
23
|
+
let i = u(r || g(n.openingElement.name), n.openingElement, t);
|
|
24
|
+
return i ? e.stringLiteral(i) : null;
|
|
25
|
+
}
|
|
26
|
+
function v(n, t, r, i) {
|
|
27
|
+
if (!c(i)) return null;
|
|
28
|
+
let o = u(`${n}.${t}`, r, i);
|
|
29
|
+
return o ? e.stringLiteral(o) : null;
|
|
30
|
+
}
|
|
31
|
+
var f = /* @__PURE__ */ new Map([
|
|
32
|
+
// name -> how the name is passed
|
|
33
|
+
["signal", "argument"],
|
|
34
|
+
["effect", "options"],
|
|
35
|
+
["computed", "argument"],
|
|
36
|
+
["useState", "argument"],
|
|
37
|
+
["useSignal", "argument"],
|
|
38
|
+
["useEffect", "third"],
|
|
39
|
+
["h", "vnode"]
|
|
40
|
+
]);
|
|
41
|
+
function h(n) {
|
|
42
|
+
let t = n.node.callee;
|
|
43
|
+
if (e.isIdentifier(t)) {
|
|
44
|
+
let r = n.scope.getBinding(t.name);
|
|
45
|
+
for (let i of f.keys())
|
|
46
|
+
if (m(r, e.isImportSpecifier, i)) return i;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (e.isMemberExpression(t) && !t.computed && e.isIdentifier(t.object) && e.isIdentifier(t.property) && f.has(t.property.name)) {
|
|
50
|
+
let r = n.scope.getBinding(t.object.name);
|
|
51
|
+
if (m(r, e.isImportNamespaceSpecifier, null)) return t.property.name;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
function y(n, t) {
|
|
56
|
+
let r = n.parent;
|
|
57
|
+
if (e.isVariableDeclarator(r) && e.isIdentifier(r.id)) return r.id.name;
|
|
58
|
+
if (e.isVariableDeclarator(r) && e.isArrayPattern(r.id) && e.isIdentifier(r.id.elements[0]))
|
|
59
|
+
return r.id.elements[0].name;
|
|
60
|
+
if ((e.isObjectProperty(r) || e.isClassProperty(r)) && !r.computed && e.isIdentifier(r.key))
|
|
61
|
+
return r.key.name;
|
|
62
|
+
if (e.isAssignmentExpression(r)) {
|
|
63
|
+
if (e.isIdentifier(r.left)) return r.left.name;
|
|
64
|
+
if (e.isMemberExpression(r.left) && !r.left.computed && e.isIdentifier(r.left.property))
|
|
65
|
+
return r.left.property.name;
|
|
66
|
+
}
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
69
|
+
var l = /* @__PURE__ */ new WeakSet();
|
|
70
|
+
function L(n, t) {
|
|
71
|
+
if (!c(t)) return;
|
|
72
|
+
let r = h(n);
|
|
73
|
+
if (r === null) return;
|
|
74
|
+
let i = n.node.arguments;
|
|
75
|
+
if (i.length === 0 || i.some((p) => e.isSpreadElement(p))) return;
|
|
76
|
+
if (r === "h") {
|
|
77
|
+
if (l.has(n.node) || !(e.isIdentifier(i[0]) || e.isMemberExpression(i[0]))) return;
|
|
78
|
+
let p = e.isIdentifier(i[0]) ? i[0].name : e.isIdentifier(i[0].property) && !i[0].computed ? i[0].property.name : "component", s = u(p, n.node, t);
|
|
79
|
+
if (s) {
|
|
80
|
+
l.add(n.node);
|
|
81
|
+
let a = n.scope.generateUidIdentifier("vnode");
|
|
82
|
+
n.replaceWith(e.callExpression(e.arrowFunctionExpression([a], e.sequenceExpression([
|
|
83
|
+
e.assignmentExpression("=", e.memberExpression(a, e.identifier("_loc")), e.stringLiteral(s)),
|
|
84
|
+
a
|
|
85
|
+
])), [n.node]));
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
let o = u(y(n, r), n.node, t);
|
|
90
|
+
if (!o) return;
|
|
91
|
+
if (f.get(r) === "third") {
|
|
92
|
+
i.length === 1 ? i.push(e.identifier("undefined"), e.stringLiteral(o)) : i.length === 2 && i.push(e.stringLiteral(o));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (f.get(r) === "argument") {
|
|
96
|
+
i.length === 1 ? i.push(e.stringLiteral(o)) : r === "signal" && i.length === 2 && i.push(e.stringLiteral(o));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
let d = e.objectProperty(e.identifier("name"), e.stringLiteral(o));
|
|
100
|
+
i.length === 1 ? i.push(e.objectExpression([d])) : i.length === 2 && e.isObjectExpression(i[1]) ? i[1].properties.some((s) => e.isSpreadElement(s) || (e.isObjectProperty(s) || e.isObjectMethod(s)) && !s.computed && (e.isIdentifier(s.key, { name: "name" }) || e.isStringLiteral(s.key, { value: "name" }))) ? i.push(e.stringLiteral(o)) : i[1].properties.push(d) : i.length === 2 && i.push(e.stringLiteral(o));
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
L as annotatePrimitive,
|
|
104
|
+
v as bindingMetadata,
|
|
105
|
+
I as componentMetadata
|
|
106
|
+
};
|