@fluixi/compiler 1.0.0-alpha.82 → 1.0.0-alpha.84
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/dist/analyze/expr-shape.cjs +62 -1
- package/dist/analyze/expr-shape.d.cts +14 -0
- package/dist/analyze/expr-shape.mjs +41 -1
- package/dist/analyze/intrinsics.cjs +80 -1
- package/dist/analyze/intrinsics.d.cts +66 -0
- package/dist/analyze/intrinsics.mjs +59 -1
- package/dist/analyze/paren.cjs +134 -0
- package/dist/analyze/paren.d.cts +23 -0
- package/dist/analyze/paren.d.ts +24 -0
- package/dist/analyze/paren.d.ts.map +1 -0
- package/dist/analyze/paren.js +168 -0
- package/dist/analyze/paren.mjs +113 -0
- package/dist/analyze/props-destructure.cjs +226 -1
- package/dist/analyze/props-destructure.d.cts +83 -0
- package/dist/analyze/props-destructure.mjs +205 -1
- package/dist/analyze/reactive-bindings.cjs +190 -1
- package/dist/analyze/reactive-bindings.d.cts +42 -0
- package/dist/analyze/reactive-bindings.mjs +167 -1
- package/dist/analyze/reactive-expr.cjs +38 -1
- package/dist/analyze/reactive-expr.d.cts +38 -0
- package/dist/analyze/reactive-expr.mjs +17 -1
- package/dist/analyze/static-graph.cjs +811 -0
- package/dist/analyze/static-graph.d.cts +102 -0
- package/dist/analyze/static-graph.d.ts +103 -0
- package/dist/analyze/static-graph.d.ts.map +1 -0
- package/dist/analyze/static-graph.js +869 -0
- package/dist/analyze/static-graph.mjs +793 -0
- package/dist/babel-NRW4EFTG.mjs +636 -0
- package/dist/chunk-3YKZ4GNH.mjs +11 -0
- package/dist/chunk-EZR7NZOY.mjs +1718 -0
- package/dist/chunk-FSSWUXUR.mjs +16 -0
- package/dist/chunk-MJV3UXIL.mjs +158 -0
- package/dist/chunk-R2VHAZAX.mjs +1078 -0
- package/dist/codegen/backend.cjs +18 -1
- package/dist/codegen/backend.d.cts +35 -0
- package/dist/codegen/backends/imperative.cjs +542 -1
- package/dist/codegen/backends/imperative.d.cts +11 -0
- package/dist/codegen/backends/imperative.d.ts.map +1 -1
- package/dist/codegen/backends/imperative.js +68 -13
- package/dist/codegen/backends/imperative.mjs +519 -1
- package/dist/codegen/contract.cjs +52 -1
- package/dist/codegen/contract.d.cts +24 -0
- package/dist/codegen/contract.mjs +31 -1
- package/dist/codegen/partial-template.cjs +176 -1
- package/dist/codegen/partial-template.d.cts +61 -0
- package/dist/codegen/partial-template.mjs +153 -1
- package/dist/codegen/serialize-static.cjs +125 -1
- package/dist/codegen/serialize-static.d.cts +38 -0
- package/dist/codegen/serialize-static.d.ts +16 -0
- package/dist/codegen/serialize-static.d.ts.map +1 -1
- package/dist/codegen/serialize-static.js +25 -0
- package/dist/codegen/serialize-static.mjs +104 -1
- package/dist/frontend/babel/build-ir-lit.cjs +1509 -1
- package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
- package/dist/frontend/babel/build-ir-lit.mjs +1478 -1
- package/dist/frontend/babel/build-ir.cjs +1524 -1
- package/dist/frontend/babel/build-ir.d.cts +35 -0
- package/dist/frontend/babel/build-ir.mjs +1495 -1
- package/dist/frontend/babel/index.cjs +2186 -1
- package/dist/frontend/babel/index.d.cts +33 -0
- package/dist/frontend/babel/index.mjs +2156 -1
- package/dist/frontend/babel/lower-template.cjs +1507 -1
- package/dist/frontend/babel/lower-template.d.cts +23 -0
- package/dist/frontend/babel/lower-template.mjs +1478 -1
- package/dist/frontend/babel/plugin.cjs +2132 -1
- package/dist/frontend/babel/plugin.d.cts +95 -0
- package/dist/frontend/babel/plugin.mjs +2103 -1
- package/dist/frontend/babel/server-functions.cjs +110 -1
- package/dist/frontend/babel/server-functions.d.cts +10 -0
- package/dist/frontend/babel/server-functions.mjs +89 -1
- package/dist/frontend/babel/types.cjs +18 -1
- package/dist/frontend/babel/types.d.cts +33 -0
- package/dist/frontend/types.cjs +18 -1
- package/dist/frontend/types.d.cts +25 -0
- package/dist/frontend/vocabulary.cjs +98 -0
- package/dist/frontend/vocabulary.d.cts +79 -0
- package/dist/frontend/vocabulary.d.ts +80 -0
- package/dist/frontend/vocabulary.d.ts.map +1 -0
- package/dist/frontend/vocabulary.js +124 -0
- package/dist/frontend/vocabulary.mjs +77 -0
- package/dist/index.cjs +1594 -13
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.mjs +1574 -13
- package/dist/integrations.cjs +4307 -25
- package/dist/integrations.d.cts +215 -0
- package/dist/integrations.d.ts +16 -0
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +21 -2
- package/dist/integrations.mjs +531 -17
- package/dist/ir/nodes.cjs +18 -1
- package/dist/ir/nodes.d.cts +168 -0
- package/dist/ir/nodes.d.ts +46 -0
- package/dist/ir/nodes.d.ts.map +1 -1
- package/dist/lower/compile-template.cjs +1356 -1
- package/dist/lower/compile-template.d.cts +69 -0
- package/dist/lower/compile-template.d.ts +12 -0
- package/dist/lower/compile-template.d.ts.map +1 -1
- package/dist/lower/compile-template.js +5 -1
- package/dist/lower/compile-template.mjs +1336 -1
- package/dist/lower/jsx.cjs +529 -1
- package/dist/lower/jsx.d.cts +25 -0
- package/dist/lower/jsx.d.ts +2 -0
- package/dist/lower/jsx.d.ts.map +1 -1
- package/dist/lower/jsx.js +27 -4
- package/dist/lower/jsx.mjs +506 -1
- package/dist/lower/template.cjs +1061 -1
- package/dist/lower/template.d.cts +53 -0
- package/dist/lower/template.d.ts +14 -1
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +106 -19
- package/dist/lower/template.mjs +1042 -1
- package/dist/lower/text.cjs +42 -1
- package/dist/lower/text.d.cts +10 -0
- package/dist/lower/text.mjs +21 -1
- package/dist/optimize/analyze-static.cjs +112 -1
- package/dist/optimize/analyze-static.d.cts +39 -0
- package/dist/optimize/analyze-static.mjs +91 -1
- package/dist/optimize/collapse-strategies.cjs +90 -1
- package/dist/optimize/collapse-strategies.d.cts +30 -0
- package/dist/optimize/collapse-strategies.mjs +67 -1
- package/dist/options.cjs +33 -1
- package/dist/options.d.cts +39 -0
- package/dist/options.mjs +12 -1
- package/dist/resolve/builtins.cjs +73 -1
- package/dist/resolve/builtins.d.cts +68 -0
- package/dist/resolve/builtins.mjs +53 -1
- package/dist/resolve/component-globals.cjs +233 -13
- package/dist/resolve/component-globals.d.cts +80 -0
- package/dist/resolve/component-globals.mjs +210 -13
- package/dist/resolve/component-resolver.cjs +80 -1
- package/dist/resolve/component-resolver.d.cts +68 -0
- package/dist/resolve/component-resolver.mjs +59 -1
- package/dist/resolve/load-directive.cjs +93 -1
- package/dist/resolve/load-directive.d.cts +53 -0
- package/dist/resolve/load-directive.mjs +72 -1
- package/dist/resolve/resolve-ir.cjs +108 -1
- package/dist/resolve/resolve-ir.d.cts +53 -0
- package/dist/resolve/resolve-ir.mjs +85 -1
- package/dist/resolve/write-globals.cjs +318 -13
- package/dist/resolve/write-globals.d.cts +30 -0
- package/dist/resolve/write-globals.mjs +297 -13
- package/dist/server-fns-4ZXN6DYU.mjs +78 -0
- package/dist/server-functions-V6D6DRIA.mjs +82 -0
- package/dist/transform/bindings.cjs +71 -1
- package/dist/transform/bindings.d.cts +16 -0
- package/dist/transform/bindings.mjs +50 -1
- package/dist/transform/index.cjs +2732 -8
- package/dist/transform/index.d.cts +15 -0
- package/dist/transform/index.mjs +3773 -17
- package/dist/transform/intrinsics.cjs +216 -3
- package/dist/transform/intrinsics.d.cts +21 -0
- package/dist/transform/intrinsics.mjs +193 -3
- package/dist/transform/props.cjs +441 -3
- package/dist/transform/props.d.cts +45 -0
- package/dist/transform/props.mjs +1482 -12
- package/dist/transform/server-fn-id.cjs +35 -1
- package/dist/transform/server-fn-id.d.cts +9 -0
- package/dist/transform/server-fn-id.mjs +14 -1
- package/dist/transform/server-fns.cjs +114 -2
- package/dist/transform/server-fns.d.cts +12 -0
- package/dist/transform/server-fns.mjs +1155 -11
- package/dist/transform/source-locations.cjs +330 -0
- package/dist/transform/source-locations.d.cts +43 -0
- package/dist/transform/source-locations.d.ts +44 -0
- package/dist/transform/source-locations.d.ts.map +1 -0
- package/dist/transform/source-locations.js +238 -0
- package/dist/transform/source-locations.mjs +307 -0
- package/dist/transform/templates.cjs +2701 -7
- package/dist/transform/templates.d.cts +69 -0
- package/dist/transform/templates.d.ts +12 -4
- package/dist/transform/templates.d.ts.map +1 -1
- package/dist/transform/templates.js +72 -7
- package/dist/transform/templates.mjs +3743 -16
- package/dist/transform-BT4MMASR.mjs +893 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/dist/babel-4JUDAR2G.mjs +0 -1
- package/dist/chunk-3SAEGOMQ.mjs +0 -1
- package/dist/chunk-IBRM4W7I.mjs +0 -10
- package/dist/chunk-OHHZCYIQ.mjs +0 -1
- package/dist/chunk-PVR2SN3B.mjs +0 -1
- package/dist/chunk-QUIYULS2.mjs +0 -1
- package/dist/chunk-YR3SAEO7.mjs +0 -1
- package/dist/server-fns-6QM243HC.mjs +0 -2
- package/dist/server-functions-E3LKCZ4R.mjs +0 -1
- package/dist/transform-5WC4FWJE.mjs +0 -8
package/dist/lower/jsx.cjs
CHANGED
|
@@ -1 +1,529 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lower/jsx.ts
|
|
21
|
+
var jsx_exports = {};
|
|
22
|
+
__export(jsx_exports, {
|
|
23
|
+
SVG_TAGS: () => SVG_TAGS,
|
|
24
|
+
buildJsxIR: () => buildJsxIR
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(jsx_exports);
|
|
27
|
+
|
|
28
|
+
// src/resolve/load-directive.ts
|
|
29
|
+
var EAGER = { kind: "eager" };
|
|
30
|
+
var DEFAULT_INTERACTION_EVENTS = ["pointerdown", "focusin", "keydown"];
|
|
31
|
+
var STRATEGIES = /* @__PURE__ */ new Set(["eager", "idle", "visible", "interaction", "media", "never"]);
|
|
32
|
+
var LoadDirectiveError = class extends Error {
|
|
33
|
+
};
|
|
34
|
+
function isLoadDirective(name) {
|
|
35
|
+
return name.startsWith("load:");
|
|
36
|
+
}
|
|
37
|
+
function parseLoadDirective(name, value) {
|
|
38
|
+
const strategy = name.slice("load:".length);
|
|
39
|
+
if (!STRATEGIES.has(strategy)) {
|
|
40
|
+
throw new LoadDirectiveError(
|
|
41
|
+
`Unknown load strategy 'load:${strategy}'. Expected one of ${[...STRATEGIES].join(", ")}.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
switch (strategy) {
|
|
45
|
+
case "eager":
|
|
46
|
+
return EAGER;
|
|
47
|
+
case "idle":
|
|
48
|
+
return { kind: "idle" };
|
|
49
|
+
case "never":
|
|
50
|
+
return { kind: "never" };
|
|
51
|
+
case "visible":
|
|
52
|
+
return value ? { kind: "visible", rootMargin: value } : { kind: "visible" };
|
|
53
|
+
case "interaction":
|
|
54
|
+
return {
|
|
55
|
+
kind: "interaction",
|
|
56
|
+
events: value ? splitEvents(value) : [...DEFAULT_INTERACTION_EVENTS]
|
|
57
|
+
};
|
|
58
|
+
case "media":
|
|
59
|
+
if (!value) {
|
|
60
|
+
throw new LoadDirectiveError(
|
|
61
|
+
`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return { kind: "media", query: value };
|
|
65
|
+
default:
|
|
66
|
+
throw new LoadDirectiveError(`Unhandled load strategy '${strategy}'.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function splitEvents(value) {
|
|
70
|
+
const events = value.split(/[\s,]+/).map((e) => e.trim()).filter(Boolean);
|
|
71
|
+
if (events.length === 0) {
|
|
72
|
+
throw new LoadDirectiveError(`'load:interaction' was given no event names.`);
|
|
73
|
+
}
|
|
74
|
+
return events;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/analyze/reactive-expr.ts
|
|
78
|
+
var STABLE_MEMBER = "children";
|
|
79
|
+
function isReactiveShape(shape) {
|
|
80
|
+
switch (shape.kind) {
|
|
81
|
+
case "call":
|
|
82
|
+
return true;
|
|
83
|
+
case "member":
|
|
84
|
+
return shape.property !== STABLE_MEMBER;
|
|
85
|
+
case "compound":
|
|
86
|
+
return shape.parts.some(isReactiveShape);
|
|
87
|
+
case "opaque":
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/analyze/expr-shape.ts
|
|
93
|
+
var CALL = /* @__PURE__ */ new Set(["CallExpression", "OptionalCallExpression"]);
|
|
94
|
+
var MEMBER = /* @__PURE__ */ new Set(["MemberExpression", "OptionalMemberExpression"]);
|
|
95
|
+
function shapeOf(node) {
|
|
96
|
+
if (!node) return { kind: "opaque" };
|
|
97
|
+
if (CALL.has(node.type)) return { kind: "call" };
|
|
98
|
+
if (MEMBER.has(node.type)) {
|
|
99
|
+
const property = node.property;
|
|
100
|
+
const computed = node.computed === true;
|
|
101
|
+
return {
|
|
102
|
+
kind: "member",
|
|
103
|
+
property: !computed && property?.type === "Identifier" ? property.name : null
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (node.type === "ConditionalExpression") {
|
|
107
|
+
return { kind: "compound", parts: [node.test, node.consequent, node.alternate].map(part) };
|
|
108
|
+
}
|
|
109
|
+
if (node.type === "LogicalExpression" || node.type === "BinaryExpression") {
|
|
110
|
+
return { kind: "compound", parts: [node.left, node.right].map(part) };
|
|
111
|
+
}
|
|
112
|
+
if (node.type === "TemplateLiteral") {
|
|
113
|
+
return { kind: "compound", parts: node.expressions.map(part) };
|
|
114
|
+
}
|
|
115
|
+
if (node.type === "ObjectExpression") {
|
|
116
|
+
const props = node.properties.filter(
|
|
117
|
+
(p) => (p.type === "ObjectProperty" || p.type === "Property") && p.computed !== true
|
|
118
|
+
);
|
|
119
|
+
return { kind: "compound", parts: props.map((p) => part(p.value)) };
|
|
120
|
+
}
|
|
121
|
+
if (node.type === "ArrayExpression") {
|
|
122
|
+
const items = node.elements.filter(
|
|
123
|
+
(e) => e != null && e.type !== "SpreadElement"
|
|
124
|
+
);
|
|
125
|
+
return { kind: "compound", parts: items.map(part) };
|
|
126
|
+
}
|
|
127
|
+
return { kind: "opaque" };
|
|
128
|
+
}
|
|
129
|
+
var part = (n) => shapeOf(n);
|
|
130
|
+
|
|
131
|
+
// src/optimize/analyze-static.ts
|
|
132
|
+
function propReason(prop) {
|
|
133
|
+
switch (prop.kind) {
|
|
134
|
+
case "event":
|
|
135
|
+
return "event";
|
|
136
|
+
case "ref":
|
|
137
|
+
return "ref";
|
|
138
|
+
case "spread":
|
|
139
|
+
return "spread";
|
|
140
|
+
case "class":
|
|
141
|
+
case "style":
|
|
142
|
+
return "class-or-style-directive";
|
|
143
|
+
case "attr":
|
|
144
|
+
case "prop":
|
|
145
|
+
if (prop.reactive) return "reactive-prop";
|
|
146
|
+
if (prop.expr !== void 0) return "expression-prop";
|
|
147
|
+
return void 0;
|
|
148
|
+
/* c8 ignore next 2 */
|
|
149
|
+
default:
|
|
150
|
+
return "expression-prop";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function analyzeStatic(root) {
|
|
154
|
+
const staticElements = [];
|
|
155
|
+
const reasons = /* @__PURE__ */ new Map();
|
|
156
|
+
const visit = (node) => {
|
|
157
|
+
switch (node.kind) {
|
|
158
|
+
case "text":
|
|
159
|
+
return true;
|
|
160
|
+
case "expr":
|
|
161
|
+
return false;
|
|
162
|
+
case "component":
|
|
163
|
+
case "control":
|
|
164
|
+
for (const child of node.children) visit(child);
|
|
165
|
+
return false;
|
|
166
|
+
case "fragment":
|
|
167
|
+
for (const child of node.children) visit(child);
|
|
168
|
+
return false;
|
|
169
|
+
case "element": {
|
|
170
|
+
let childrenStatic = true;
|
|
171
|
+
for (const child of node.children) {
|
|
172
|
+
if (!visit(child)) childrenStatic = false;
|
|
173
|
+
}
|
|
174
|
+
let reason;
|
|
175
|
+
for (const prop of node.props) {
|
|
176
|
+
reason = propReason(prop);
|
|
177
|
+
if (reason) break;
|
|
178
|
+
}
|
|
179
|
+
if (!reason && !childrenStatic) {
|
|
180
|
+
reason = childReason(node);
|
|
181
|
+
}
|
|
182
|
+
node.static = !reason;
|
|
183
|
+
if (reason) reasons.set(node, reason);
|
|
184
|
+
else staticElements.push(node);
|
|
185
|
+
return node.static;
|
|
186
|
+
}
|
|
187
|
+
/* c8 ignore next 2 */
|
|
188
|
+
default:
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
for (const node of Array.isArray(root) ? root : [root]) visit(node);
|
|
193
|
+
return { staticElements, reasons };
|
|
194
|
+
}
|
|
195
|
+
function childReason(node) {
|
|
196
|
+
for (const child of node.children) {
|
|
197
|
+
if (child.kind === "expr") return "expression-child";
|
|
198
|
+
if (child.kind === "component") return "component-child";
|
|
199
|
+
if (child.kind === "control") return "control-child";
|
|
200
|
+
if (child.kind === "element" && !child.static) return "expression-child";
|
|
201
|
+
if (child.kind === "fragment") return "expression-child";
|
|
202
|
+
}
|
|
203
|
+
return "expression-child";
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/lower/text.ts
|
|
207
|
+
function cleanTemplateText(value) {
|
|
208
|
+
const lines = value.split(/\r\n|\n|\r/);
|
|
209
|
+
let lastNonEmpty = 0;
|
|
210
|
+
for (let i = 0; i < lines.length; i++) {
|
|
211
|
+
if (/[^ \t]/.test(lines[i])) lastNonEmpty = i;
|
|
212
|
+
}
|
|
213
|
+
let out = "";
|
|
214
|
+
for (let i = 0; i < lines.length; i++) {
|
|
215
|
+
let line = lines[i].replace(/\t/g, " ");
|
|
216
|
+
if (i !== 0) line = line.replace(/^ +/, "");
|
|
217
|
+
if (i !== lines.length - 1) line = line.replace(/ +$/, "");
|
|
218
|
+
if (!line) continue;
|
|
219
|
+
if (i !== lastNonEmpty) line += " ";
|
|
220
|
+
out += line;
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/analyze/paren.ts
|
|
226
|
+
function skipQuoted(src, start) {
|
|
227
|
+
const quote = src[start];
|
|
228
|
+
for (let i = start + 1; i < src.length; i++) {
|
|
229
|
+
const c = src[i];
|
|
230
|
+
if (c === "\\") i++;
|
|
231
|
+
else if (c === quote) return i + 1;
|
|
232
|
+
else if (c === "\n") return -1;
|
|
233
|
+
}
|
|
234
|
+
return -1;
|
|
235
|
+
}
|
|
236
|
+
function skipTemplate(src, start) {
|
|
237
|
+
let i = start + 1;
|
|
238
|
+
while (i < src.length) {
|
|
239
|
+
const c = src[i];
|
|
240
|
+
if (c === "\\") {
|
|
241
|
+
i += 2;
|
|
242
|
+
} else if (c === "`") {
|
|
243
|
+
return i + 1;
|
|
244
|
+
} else if (c === "$" && src[i + 1] === "{") {
|
|
245
|
+
let depth = 1;
|
|
246
|
+
i += 2;
|
|
247
|
+
while (i < src.length && depth > 0) {
|
|
248
|
+
const k = src[i];
|
|
249
|
+
if (k === "\\") i += 2;
|
|
250
|
+
else if (k === "`") {
|
|
251
|
+
const end = skipTemplate(src, i);
|
|
252
|
+
if (end < 0) return -1;
|
|
253
|
+
i = end;
|
|
254
|
+
} else if (k === '"' || k === "'") {
|
|
255
|
+
const end = skipQuoted(src, i);
|
|
256
|
+
if (end < 0) return -1;
|
|
257
|
+
i = end;
|
|
258
|
+
} else {
|
|
259
|
+
if (k === "{") depth++;
|
|
260
|
+
else if (k === "}") depth--;
|
|
261
|
+
i++;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
i++;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return -1;
|
|
269
|
+
}
|
|
270
|
+
function skipRegex(src, start) {
|
|
271
|
+
let inClass = false;
|
|
272
|
+
for (let i = start + 1; i < src.length; i++) {
|
|
273
|
+
const c = src[i];
|
|
274
|
+
if (c === "\\") i++;
|
|
275
|
+
else if (c === "[") inClass = true;
|
|
276
|
+
else if (c === "]") inClass = false;
|
|
277
|
+
else if (c === "\n") return -1;
|
|
278
|
+
else if (c === "/" && !inClass) {
|
|
279
|
+
let end = i + 1;
|
|
280
|
+
while (end < src.length && /[a-z]/i.test(src[end])) end++;
|
|
281
|
+
return end;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return -1;
|
|
285
|
+
}
|
|
286
|
+
function divides(prev) {
|
|
287
|
+
return prev !== "" && /[A-Za-z0-9_$)\]]/.test(prev);
|
|
288
|
+
}
|
|
289
|
+
function topLevelComma(src) {
|
|
290
|
+
let depth = 0;
|
|
291
|
+
let prev = "";
|
|
292
|
+
let i = 0;
|
|
293
|
+
while (i < src.length) {
|
|
294
|
+
const c = src[i];
|
|
295
|
+
if (c === '"' || c === "'") {
|
|
296
|
+
const end = skipQuoted(src, i);
|
|
297
|
+
if (end < 0) return null;
|
|
298
|
+
i = end;
|
|
299
|
+
prev = c;
|
|
300
|
+
} else if (c === "`") {
|
|
301
|
+
const end = skipTemplate(src, i);
|
|
302
|
+
if (end < 0) return null;
|
|
303
|
+
i = end;
|
|
304
|
+
prev = c;
|
|
305
|
+
} else if (c === "/" && src[i + 1] === "/") {
|
|
306
|
+
return null;
|
|
307
|
+
} else if (c === "/" && src[i + 1] === "*") {
|
|
308
|
+
const end = src.indexOf("*/", i + 2);
|
|
309
|
+
if (end < 0) return null;
|
|
310
|
+
i = end + 2;
|
|
311
|
+
} else if (c === "/" && !divides(prev)) {
|
|
312
|
+
const end = skipRegex(src, i);
|
|
313
|
+
if (end < 0) return null;
|
|
314
|
+
i = end;
|
|
315
|
+
prev = "/";
|
|
316
|
+
} else {
|
|
317
|
+
if (c === "(" || c === "[" || c === "{") depth++;
|
|
318
|
+
else if (c === ")" || c === "]" || c === "}") {
|
|
319
|
+
depth--;
|
|
320
|
+
if (depth < 0) return null;
|
|
321
|
+
} else if (c === "," && depth === 0) return true;
|
|
322
|
+
if (!/\s/.test(c)) prev = c;
|
|
323
|
+
i++;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return depth === 0 ? false : null;
|
|
327
|
+
}
|
|
328
|
+
function paren(code, position) {
|
|
329
|
+
const src = code.trim();
|
|
330
|
+
if (src === "") return `(${code})`;
|
|
331
|
+
if (position === "arrowBody" && src[0] === "{") return `(${code})`;
|
|
332
|
+
return topLevelComma(src) === false ? code : `(${code})`;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/lower/jsx.ts
|
|
336
|
+
var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
337
|
+
"svg",
|
|
338
|
+
"path",
|
|
339
|
+
"circle",
|
|
340
|
+
"rect",
|
|
341
|
+
"line",
|
|
342
|
+
"polygon",
|
|
343
|
+
"polyline",
|
|
344
|
+
"ellipse",
|
|
345
|
+
"g",
|
|
346
|
+
"defs",
|
|
347
|
+
"clipPath",
|
|
348
|
+
"text"
|
|
349
|
+
]);
|
|
350
|
+
var EVENT_RE = /^on[A-Z]/;
|
|
351
|
+
var DELEGATED = /* @__PURE__ */ new Set([
|
|
352
|
+
"click",
|
|
353
|
+
"dblclick",
|
|
354
|
+
"input",
|
|
355
|
+
"change",
|
|
356
|
+
"submit",
|
|
357
|
+
"focus",
|
|
358
|
+
"blur",
|
|
359
|
+
"keydown",
|
|
360
|
+
"keyup",
|
|
361
|
+
"keypress",
|
|
362
|
+
"mousedown",
|
|
363
|
+
"mouseup"
|
|
364
|
+
]);
|
|
365
|
+
var isReactive = (node) => isReactiveShape(shapeOf(node));
|
|
366
|
+
var posOf = (node, ctx) => {
|
|
367
|
+
if (!ctx.sourceFile) return void 0;
|
|
368
|
+
const at = node.loc?.start;
|
|
369
|
+
return at ? { line: at.line, column: at.column } : void 0;
|
|
370
|
+
};
|
|
371
|
+
function literalOf(node) {
|
|
372
|
+
if (node.type === "StringLiteral" || node.type === "NumericLiteral" || node.type === "BooleanLiteral") {
|
|
373
|
+
return node.value;
|
|
374
|
+
}
|
|
375
|
+
if (node.type === "Literal" && (typeof node.value === "string" || typeof node.value === "number" || typeof node.value === "boolean")) {
|
|
376
|
+
return node.value;
|
|
377
|
+
}
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
var isString = (node) => !!node && typeof literalOf(node) === "string";
|
|
381
|
+
function tagInfo(name, ctx) {
|
|
382
|
+
if (name.type === "JSXIdentifier") {
|
|
383
|
+
return { tag: name.name, component: name.name[0] !== name.name[0].toLowerCase() };
|
|
384
|
+
}
|
|
385
|
+
if (name.type === "JSXMemberExpression") return { tag: ctx.code(name), component: true };
|
|
386
|
+
if (name.type === "JSXNamespacedName") {
|
|
387
|
+
return { tag: `${name.namespace.name}:${name.name.name}`, component: false };
|
|
388
|
+
}
|
|
389
|
+
return { tag: "div", component: false };
|
|
390
|
+
}
|
|
391
|
+
function attrName(name) {
|
|
392
|
+
if (name.type === "JSXIdentifier") return name.name === "class" ? "className" : name.name;
|
|
393
|
+
if (name.type === "JSXNamespacedName") return `${name.namespace.name}:${name.name.name}`;
|
|
394
|
+
return "unknown";
|
|
395
|
+
}
|
|
396
|
+
function buildAttr(attr, ctx) {
|
|
397
|
+
const name = attrName(attr.name);
|
|
398
|
+
const isEvent = EVENT_RE.test(name);
|
|
399
|
+
const isHandler = isEvent || name.startsWith("on:") || name === "ref";
|
|
400
|
+
const kind = isEvent ? "event" : "attr";
|
|
401
|
+
const base = { name, kind };
|
|
402
|
+
if (isEvent) {
|
|
403
|
+
const evt = name.slice(2).toLowerCase();
|
|
404
|
+
base.event = { name: evt, delegated: DELEGATED.has(evt) };
|
|
405
|
+
}
|
|
406
|
+
const v = attr.value;
|
|
407
|
+
if (v == null) {
|
|
408
|
+
base.literal = true;
|
|
409
|
+
base.at = posOf(attr, ctx);
|
|
410
|
+
return base;
|
|
411
|
+
}
|
|
412
|
+
if (isString(v)) {
|
|
413
|
+
base.literal = literalOf(v);
|
|
414
|
+
base.at = posOf(v, ctx);
|
|
415
|
+
return base;
|
|
416
|
+
}
|
|
417
|
+
if (v.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression") {
|
|
418
|
+
const expr = v.expression;
|
|
419
|
+
const literal = literalOf(expr);
|
|
420
|
+
if (literal !== void 0) {
|
|
421
|
+
base.literal = literal;
|
|
422
|
+
base.at = posOf(expr, ctx);
|
|
423
|
+
return base;
|
|
424
|
+
}
|
|
425
|
+
base.expr = ctx.code(expr);
|
|
426
|
+
base.reactive = isHandler ? false : isReactive(expr);
|
|
427
|
+
base.at = posOf(expr, ctx);
|
|
428
|
+
if (expr.type === "JSXElement" || expr.type === "JSXFragment") base.jsxElement = true;
|
|
429
|
+
return base;
|
|
430
|
+
}
|
|
431
|
+
base.literal = true;
|
|
432
|
+
return base;
|
|
433
|
+
}
|
|
434
|
+
function attrExprCode(attr, ctx) {
|
|
435
|
+
const v = attr.value;
|
|
436
|
+
if (v == null) return null;
|
|
437
|
+
if (isString(v)) return JSON.stringify(literalOf(v));
|
|
438
|
+
if (v.type === "JSXExpressionContainer" && v.expression?.type !== "JSXEmptyExpression") {
|
|
439
|
+
return ctx.code(v.expression);
|
|
440
|
+
}
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
function buildProps(attrs, ctx) {
|
|
444
|
+
const props = [];
|
|
445
|
+
const usePairs = [];
|
|
446
|
+
for (const a of attrs) {
|
|
447
|
+
if (a.type === "JSXSpreadAttribute") {
|
|
448
|
+
props.push({ name: "", kind: "spread", expr: ctx.code(a.argument) });
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
if (a.type !== "JSXAttribute") continue;
|
|
452
|
+
if (isLoadDirective(attrName(a.name))) continue;
|
|
453
|
+
const ns = a.name.type === "JSXNamespacedName" ? a.name.namespace.name : null;
|
|
454
|
+
if (ns === "use") {
|
|
455
|
+
const dir = a.name.name.name;
|
|
456
|
+
ctx.used.add(dir);
|
|
457
|
+
const opts = attrExprCode(a, ctx);
|
|
458
|
+
usePairs.push(opts != null ? `[${dir}, () => ${paren(opts, "arrowBody")}]` : `[${dir}]`);
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
if (ns === "oncapture") {
|
|
462
|
+
const evt = a.name.name.name.toLowerCase();
|
|
463
|
+
const h = attrExprCode(a, ctx) ?? "undefined";
|
|
464
|
+
props.push({ name: "on:" + evt, kind: "attr", expr: `[${h}, { capture: true }]` });
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
props.push(buildAttr(a, ctx));
|
|
468
|
+
}
|
|
469
|
+
if (usePairs.length > 0) props.push({ name: "use", kind: "attr", expr: `[${usePairs.join(", ")}]` });
|
|
470
|
+
return props;
|
|
471
|
+
}
|
|
472
|
+
function buildChildren(children, ctx) {
|
|
473
|
+
const out = [];
|
|
474
|
+
for (const child of children) {
|
|
475
|
+
if (child.type === "JSXText") {
|
|
476
|
+
const text = cleanTemplateText(child.value);
|
|
477
|
+
if (text) out.push({ kind: "text", value: text });
|
|
478
|
+
} else if (child.type === "JSXExpressionContainer") {
|
|
479
|
+
if (child.expression?.type !== "JSXEmptyExpression") {
|
|
480
|
+
const expr = child.expression;
|
|
481
|
+
const reactive = isReactive(expr);
|
|
482
|
+
out.push({
|
|
483
|
+
kind: "expr",
|
|
484
|
+
code: ctx.code(expr),
|
|
485
|
+
reactive,
|
|
486
|
+
...reactive ? { at: posOf(expr, ctx) } : {}
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
} else if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
490
|
+
out.push(buildNode(child, ctx));
|
|
491
|
+
} else if (child.type === "JSXSpreadChild") {
|
|
492
|
+
out.push({ kind: "expr", code: ctx.code(child.expression), reactive: false });
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return out;
|
|
496
|
+
}
|
|
497
|
+
function readLoad(attrs) {
|
|
498
|
+
for (const a of attrs) {
|
|
499
|
+
if (a.type !== "JSXAttribute") continue;
|
|
500
|
+
const name = attrName(a.name);
|
|
501
|
+
if (!isLoadDirective(name)) continue;
|
|
502
|
+
if (a.value && !isString(a.value)) {
|
|
503
|
+
throw new LoadDirectiveError(
|
|
504
|
+
`'${name}' needs a literal value, not an expression — the strategy is compile-time.`
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
return parseLoadDirective(name, a.value ? literalOf(a.value) : null);
|
|
508
|
+
}
|
|
509
|
+
return void 0;
|
|
510
|
+
}
|
|
511
|
+
function buildNode(node, ctx) {
|
|
512
|
+
if (node.type === "JSXFragment") {
|
|
513
|
+
return { kind: "fragment", children: buildChildren(node.children, ctx) };
|
|
514
|
+
}
|
|
515
|
+
const { tag, component } = tagInfo(node.openingElement.name, ctx);
|
|
516
|
+
const props = buildProps(node.openingElement.attributes, ctx);
|
|
517
|
+
const children = buildChildren(node.children, ctx);
|
|
518
|
+
const at = ctx.sourceFile && node.loc?.start ? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column } : void 0;
|
|
519
|
+
if (component) {
|
|
520
|
+
const load = readLoad(node.openingElement.attributes);
|
|
521
|
+
return { kind: "component", name: tag, props, children, ...load ? { load } : {}, ...at ? { at } : {} };
|
|
522
|
+
}
|
|
523
|
+
return { kind: "element", tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...at ? { at } : {} };
|
|
524
|
+
}
|
|
525
|
+
function buildJsxIR(node, ctx) {
|
|
526
|
+
const ir = buildNode(node, ctx);
|
|
527
|
+
analyzeStatic(ir);
|
|
528
|
+
return ir;
|
|
529
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build IR from a JSX tree.
|
|
3
|
+
*
|
|
4
|
+
* Reads `node.type` rather than a parser's helpers, and asks the caller for the
|
|
5
|
+
* source of an expression through `code()` — a front-end that can slice the
|
|
6
|
+
* original text returns that, one that reprints returns the printed form. Either
|
|
7
|
+
* way the IR is the same, which is what keeps one builder for both.
|
|
8
|
+
*/
|
|
9
|
+
import type { IRNode } from '../ir/nodes.cjs';
|
|
10
|
+
interface Node {
|
|
11
|
+
type: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export interface JsxContext {
|
|
15
|
+
/** The source of an expression node, with anything nested already compiled. */
|
|
16
|
+
code(node: Node): string;
|
|
17
|
+
/** Runtime symbols the emitted code needs; `use:` directives register here too. */
|
|
18
|
+
used: Set<string>;
|
|
19
|
+
/** The file being compiled, when component usage sites are to be recorded. */
|
|
20
|
+
sourceFile?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const SVG_TAGS: Set<string>;
|
|
23
|
+
/** Build IR from a JSXElement or JSXFragment. */
|
|
24
|
+
export declare function buildJsxIR(node: Node, ctx: JsxContext): IRNode;
|
|
25
|
+
export {};
|
package/dist/lower/jsx.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface JsxContext {
|
|
|
16
16
|
code(node: Node): string;
|
|
17
17
|
/** Runtime symbols the emitted code needs; `use:` directives register here too. */
|
|
18
18
|
used: Set<string>;
|
|
19
|
+
/** The file being compiled, when component usage sites are to be recorded. */
|
|
20
|
+
sourceFile?: string;
|
|
19
21
|
}
|
|
20
22
|
export declare const SVG_TAGS: Set<string>;
|
|
21
23
|
/** Build IR from a JSXElement or JSXFragment. */
|
package/dist/lower/jsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/lower/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAkB,MAAM,EAAsB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../src/lower/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAkB,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AAQjF,UAAU,IAAI;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,+EAA+E;IAC/E,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,mFAAmF;IACnF,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,QAAQ,aAGnB,CAAC;AA4MH,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAM9D"}
|
package/dist/lower/jsx.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isReactiveShape } from '../analyze/reactive-expr.js';
|
|
|
3
3
|
import { shapeOf } from '../analyze/expr-shape.js';
|
|
4
4
|
import { analyzeStatic } from '../optimize/analyze-static.js';
|
|
5
5
|
import { cleanTemplateText } from './text.js';
|
|
6
|
+
import { paren } from '../analyze/paren.js';
|
|
6
7
|
export const SVG_TAGS = new Set([
|
|
7
8
|
'svg', 'path', 'circle', 'rect', 'line', 'polygon', 'polyline',
|
|
8
9
|
'ellipse', 'g', 'defs', 'clipPath', 'text',
|
|
@@ -13,6 +14,13 @@ const DELEGATED = new Set([
|
|
|
13
14
|
'keydown', 'keyup', 'keypress', 'mousedown', 'mouseup',
|
|
14
15
|
]);
|
|
15
16
|
const isReactive = (node) => isReactiveShape(shapeOf(node));
|
|
17
|
+
/** Only when the host asked for source locations — the flag that records usage sites too. */
|
|
18
|
+
const posOf = (node, ctx) => {
|
|
19
|
+
if (!ctx.sourceFile)
|
|
20
|
+
return undefined;
|
|
21
|
+
const at = node.loc?.start;
|
|
22
|
+
return at ? { line: at.line, column: at.column } : undefined;
|
|
23
|
+
};
|
|
16
24
|
/** A literal value, or undefined when the node is not one. */
|
|
17
25
|
function literalOf(node) {
|
|
18
26
|
if (node.type === 'StringLiteral' || node.type === 'NumericLiteral' || node.type === 'BooleanLiteral') {
|
|
@@ -60,10 +68,12 @@ function buildAttr(attr, ctx) {
|
|
|
60
68
|
const v = attr.value;
|
|
61
69
|
if (v == null) {
|
|
62
70
|
base.literal = true; // valueless attribute
|
|
71
|
+
base.at = posOf(attr, ctx);
|
|
63
72
|
return base;
|
|
64
73
|
}
|
|
65
74
|
if (isString(v)) {
|
|
66
75
|
base.literal = literalOf(v);
|
|
76
|
+
base.at = posOf(v, ctx);
|
|
67
77
|
return base;
|
|
68
78
|
}
|
|
69
79
|
if (v.type === 'JSXExpressionContainer' && v.expression?.type !== 'JSXEmptyExpression') {
|
|
@@ -71,10 +81,14 @@ function buildAttr(attr, ctx) {
|
|
|
71
81
|
const literal = literalOf(expr);
|
|
72
82
|
if (literal !== undefined) {
|
|
73
83
|
base.literal = literal;
|
|
84
|
+
base.at = posOf(expr, ctx);
|
|
74
85
|
return base;
|
|
75
86
|
}
|
|
76
87
|
base.expr = ctx.code(expr);
|
|
77
88
|
base.reactive = isHandler ? false : isReactive(expr);
|
|
89
|
+
// Every prop, not only the ones that move: a panel names the line for each of them.
|
|
90
|
+
// Nothing treats this as a binding position — that asks for `reactive` as well.
|
|
91
|
+
base.at = posOf(expr, ctx);
|
|
78
92
|
if (expr.type === 'JSXElement' || expr.type === 'JSXFragment')
|
|
79
93
|
base.jsxElement = true;
|
|
80
94
|
return base;
|
|
@@ -114,7 +128,7 @@ function buildProps(attrs, ctx) {
|
|
|
114
128
|
ctx.used.add(dir); // keep the import
|
|
115
129
|
const opts = attrExprCode(a, ctx);
|
|
116
130
|
// parens round the body so an object literal is not read as a block
|
|
117
|
-
usePairs.push(opts != null ? `[${dir}, () =>
|
|
131
|
+
usePairs.push(opts != null ? `[${dir}, () => ${paren(opts, 'arrowBody')}]` : `[${dir}]`);
|
|
118
132
|
continue;
|
|
119
133
|
}
|
|
120
134
|
// oncapture:name -> native on:name with { capture: true }
|
|
@@ -143,7 +157,13 @@ function buildChildren(children, ctx) {
|
|
|
143
157
|
else if (child.type === 'JSXExpressionContainer') {
|
|
144
158
|
if (child.expression?.type !== 'JSXEmptyExpression') {
|
|
145
159
|
const expr = child.expression;
|
|
146
|
-
|
|
160
|
+
const reactive = isReactive(expr);
|
|
161
|
+
out.push({
|
|
162
|
+
kind: 'expr',
|
|
163
|
+
code: ctx.code(expr),
|
|
164
|
+
reactive,
|
|
165
|
+
...(reactive ? { at: posOf(expr, ctx) } : {}),
|
|
166
|
+
});
|
|
147
167
|
}
|
|
148
168
|
}
|
|
149
169
|
else if (child.type === 'JSXElement' || child.type === 'JSXFragment') {
|
|
@@ -177,11 +197,14 @@ function buildNode(node, ctx) {
|
|
|
177
197
|
const { tag, component } = tagInfo(node.openingElement.name, ctx);
|
|
178
198
|
const props = buildProps(node.openingElement.attributes, ctx);
|
|
179
199
|
const children = buildChildren(node.children, ctx);
|
|
200
|
+
const at = ctx.sourceFile && node.loc?.start
|
|
201
|
+
? { file: ctx.sourceFile, line: node.loc.start.line, column: node.loc.start.column }
|
|
202
|
+
: undefined;
|
|
180
203
|
if (component) {
|
|
181
204
|
const load = readLoad(node.openingElement.attributes);
|
|
182
|
-
return { kind: 'component', name: tag, props, children, ...(load ? { load } : {}) };
|
|
205
|
+
return { kind: 'component', name: tag, props, children, ...(load ? { load } : {}), ...(at ? { at } : {}) };
|
|
183
206
|
}
|
|
184
|
-
return { kind: 'element', tag, svg: SVG_TAGS.has(tag), props, children, static: false };
|
|
207
|
+
return { kind: 'element', tag, svg: SVG_TAGS.has(tag), props, children, static: false, ...(at ? { at } : {}) };
|
|
185
208
|
}
|
|
186
209
|
/** Build IR from a JSXElement or JSXFragment. */
|
|
187
210
|
export function buildJsxIR(node, ctx) {
|