@tamagui/compiler-core 0.0.0-bootstrap.0 → 3.0.0-beta.637.1
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 +57 -1
- package/dist/cjs/ast.cjs +95 -0
- package/dist/cjs/contracts.cjs +62 -0
- package/dist/cjs/diagnostics.cjs +69 -0
- package/dist/cjs/evaluate.cjs +351 -0
- package/dist/cjs/graph.cjs +279 -0
- package/dist/cjs/hash.cjs +49 -0
- package/dist/cjs/index.cjs +44 -0
- package/dist/cjs/ir.cjs +33 -0
- package/dist/cjs/lower.cjs +225 -0
- package/dist/cjs/materialize.cjs +200 -0
- package/dist/cjs/normalize.cjs +622 -0
- package/dist/cjs/output.cjs +149 -0
- package/dist/cjs/planCache.cjs +224 -0
- package/dist/cjs/session.cjs +119 -0
- package/dist/cjs/yuku.cjs +159 -0
- package/dist/cjs/zero.cjs +387 -0
- package/dist/esm/ast.mjs +65 -0
- package/dist/esm/ast.mjs.map +1 -0
- package/dist/esm/contracts.mjs +34 -0
- package/dist/esm/contracts.mjs.map +1 -0
- package/dist/esm/diagnostics.mjs +44 -0
- package/dist/esm/diagnostics.mjs.map +1 -0
- package/dist/esm/evaluate.mjs +327 -0
- package/dist/esm/evaluate.mjs.map +1 -0
- package/dist/esm/graph.mjs +256 -0
- package/dist/esm/graph.mjs.map +1 -0
- package/dist/esm/hash.mjs +26 -0
- package/dist/esm/hash.mjs.map +1 -0
- package/dist/esm/index.mjs +30 -0
- package/dist/esm/ir.mjs +12 -0
- package/dist/esm/ir.mjs.map +1 -0
- package/dist/esm/lower.mjs +202 -0
- package/dist/esm/lower.mjs.map +1 -0
- package/dist/esm/materialize.mjs +179 -0
- package/dist/esm/materialize.mjs.map +1 -0
- package/dist/esm/normalize.mjs +596 -0
- package/dist/esm/normalize.mjs.map +1 -0
- package/dist/esm/output.mjs +119 -0
- package/dist/esm/output.mjs.map +1 -0
- package/dist/esm/planCache.mjs +194 -0
- package/dist/esm/planCache.mjs.map +1 -0
- package/dist/esm/session.mjs +99 -0
- package/dist/esm/session.mjs.map +1 -0
- package/dist/esm/yuku.mjs +136 -0
- package/dist/esm/yuku.mjs.map +1 -0
- package/dist/esm/zero.mjs +352 -0
- package/dist/esm/zero.mjs.map +1 -0
- package/package.json +42 -4
- package/src/ast.ts +86 -0
- package/src/contracts.ts +148 -0
- package/src/diagnostics.ts +96 -0
- package/src/evaluate.ts +497 -0
- package/src/graph.ts +347 -0
- package/src/hash.ts +36 -0
- package/src/index.ts +15 -0
- package/src/ir.ts +154 -0
- package/src/lower.ts +418 -0
- package/src/materialize.ts +330 -0
- package/src/normalize.ts +846 -0
- package/src/output.ts +175 -0
- package/src/planCache.ts +327 -0
- package/src/session.ts +172 -0
- package/src/yuku.ts +189 -0
- package/src/zero.ts +598 -0
- package/types/ast.d.ts +10 -0
- package/types/ast.d.ts.map +1 -0
- package/types/contracts.d.ts +97 -0
- package/types/contracts.d.ts.map +1 -0
- package/types/diagnostics.d.ts +31 -0
- package/types/diagnostics.d.ts.map +1 -0
- package/types/evaluate.d.ts +36 -0
- package/types/evaluate.d.ts.map +1 -0
- package/types/graph.d.ts +37 -0
- package/types/graph.d.ts.map +1 -0
- package/types/hash.d.ts +8 -0
- package/types/hash.d.ts.map +1 -0
- package/types/index.d.ts +16 -0
- package/types/index.d.ts.map +1 -0
- package/types/ir.d.ts +118 -0
- package/types/ir.d.ts.map +1 -0
- package/types/lower.d.ts +99 -0
- package/types/lower.d.ts.map +1 -0
- package/types/materialize.d.ts +104 -0
- package/types/materialize.d.ts.map +1 -0
- package/types/normalize.d.ts +8 -0
- package/types/normalize.d.ts.map +1 -0
- package/types/output.d.ts +32 -0
- package/types/output.d.ts.map +1 -0
- package/types/planCache.d.ts +113 -0
- package/types/planCache.d.ts.map +1 -0
- package/types/session.d.ts +44 -0
- package/types/session.d.ts.map +1 -0
- package/types/yuku.d.ts +4 -0
- package/types/yuku.d.ts.map +1 -0
- package/types/zero.d.ts +98 -0
- package/types/zero.d.ts.map +1 -0
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
import { childNode, childNodes, findAstNode, identifierName, isAstNode, walkAst } from "./ast.mjs";
|
|
2
|
+
import { expressionReference, resolvedModuleId, spanOf } from "./contracts.mjs";
|
|
3
|
+
import { linkedBailout, localBailout } from "./diagnostics.mjs";
|
|
4
|
+
import { hostImportProvenance } from "./ir.mjs";
|
|
5
|
+
|
|
6
|
+
function finalizeElement(base, entries, bailouts) {
|
|
7
|
+
if (bailouts.length === 0) {
|
|
8
|
+
return {
|
|
9
|
+
...base,
|
|
10
|
+
complete: true,
|
|
11
|
+
entries,
|
|
12
|
+
bailouts: []
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
...base,
|
|
17
|
+
complete: false,
|
|
18
|
+
bailedEntries: entries,
|
|
19
|
+
bailouts
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function definitionFromDeclaration(id, name, program, declaration) {
|
|
23
|
+
let identifier = declaration;
|
|
24
|
+
let initializer = null;
|
|
25
|
+
let constant = false;
|
|
26
|
+
if (declaration.type === "VariableDeclarator") {
|
|
27
|
+
identifier = childNode(declaration, "id") ?? declaration;
|
|
28
|
+
initializer = childNode(declaration, "init");
|
|
29
|
+
constant = !!findAstNode(program, (node) => node.type === "VariableDeclaration" && node.kind === "const" && childNodes(node, "declarations").some((candidate) => candidate.start === declaration.start));
|
|
30
|
+
} else if (declaration.type === "Identifier") {
|
|
31
|
+
const declarator = findAstNode(program, (node) => node.type === "VariableDeclarator" && childNode(node, "id")?.start === declaration.start);
|
|
32
|
+
if (declarator) {
|
|
33
|
+
initializer = childNode(declarator, "init");
|
|
34
|
+
constant = !!findAstNode(program, (node) => node.type === "VariableDeclaration" && node.kind === "const" && childNodes(node, "declarations").some((candidate) => candidate.start === declarator.start));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
id: resolvedModuleId(id),
|
|
39
|
+
name,
|
|
40
|
+
start: identifier.start,
|
|
41
|
+
end: identifier.end,
|
|
42
|
+
initializer,
|
|
43
|
+
constant
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function importBinding(program, localName) {
|
|
47
|
+
for (const statement of childNodes(program, "body")) {
|
|
48
|
+
if (statement.type !== "ImportDeclaration") continue;
|
|
49
|
+
const source = childNode(statement, "source");
|
|
50
|
+
const sourceValue = source && typeof source.value === "string" ? source.value : null;
|
|
51
|
+
if (!sourceValue) continue;
|
|
52
|
+
for (const specifier of childNodes(statement, "specifiers")) {
|
|
53
|
+
if (identifierName(childNode(specifier, "local")) !== localName) continue;
|
|
54
|
+
if (specifier.type === "ImportDefaultSpecifier") {
|
|
55
|
+
return {
|
|
56
|
+
source: sourceValue,
|
|
57
|
+
imported: "default"
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
61
|
+
return {
|
|
62
|
+
source: sourceValue,
|
|
63
|
+
imported: "*"
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const imported = childNode(specifier, "imported");
|
|
67
|
+
const importedName = identifierName(imported) ?? (typeof imported?.value === "string" ? imported.value : null);
|
|
68
|
+
return importedName ? {
|
|
69
|
+
source: sourceValue,
|
|
70
|
+
imported: importedName
|
|
71
|
+
} : null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function asStaticValue(node) {
|
|
77
|
+
if (!node) return void 0;
|
|
78
|
+
if (node.type === "NullLiteral") return null;
|
|
79
|
+
if (node.type === "Literal" || node.type.endsWith("Literal")) {
|
|
80
|
+
const value = node.value;
|
|
81
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null) {
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
function elementValue(id, node) {
|
|
88
|
+
const staticValue = asStaticValue(node);
|
|
89
|
+
return staticValue === void 0 ? expressionReference(id, node) : {
|
|
90
|
+
kind: "static",
|
|
91
|
+
value: staticValue,
|
|
92
|
+
span: spanOf(id, node)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function symbolDefinition(definition) {
|
|
96
|
+
if (!definition) return null;
|
|
97
|
+
return {
|
|
98
|
+
id: definition.id,
|
|
99
|
+
name: definition.name,
|
|
100
|
+
span: {
|
|
101
|
+
id: definition.id,
|
|
102
|
+
start: definition.start,
|
|
103
|
+
end: definition.end
|
|
104
|
+
},
|
|
105
|
+
initializer: definition.initializer ? expressionReference(definition.id, definition.initializer) : null,
|
|
106
|
+
constant: definition.constant
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function componentFromNode(candidate, id, program, imports, node, bailouts) {
|
|
110
|
+
const literal = asStaticValue(node);
|
|
111
|
+
if (typeof literal === "string") {
|
|
112
|
+
return {
|
|
113
|
+
kind: "intrinsic",
|
|
114
|
+
name: literal,
|
|
115
|
+
span: spanOf(id, node),
|
|
116
|
+
closingSpan: null,
|
|
117
|
+
definition: null,
|
|
118
|
+
provenance: null
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if ((node.type === "MemberExpression" || node.type === "JSXMemberExpression") && node.computed !== true) {
|
|
122
|
+
const objectName = identifierName(childNode(node, "object"));
|
|
123
|
+
const memberName = identifierName(childNode(node, "property"));
|
|
124
|
+
const binding2 = objectName ? importBinding(program, objectName) : null;
|
|
125
|
+
if (memberName && binding2?.imported === "html") {
|
|
126
|
+
const provenance2 = hostImportProvenance(imports, binding2.source, binding2.imported);
|
|
127
|
+
if (provenance2) {
|
|
128
|
+
return {
|
|
129
|
+
kind: "binding",
|
|
130
|
+
name: memberName,
|
|
131
|
+
span: spanOf(id, node),
|
|
132
|
+
closingSpan: null,
|
|
133
|
+
definition: null,
|
|
134
|
+
provenance: provenance2
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const name = identifierName(node);
|
|
140
|
+
if (!name) {
|
|
141
|
+
bailouts.push(localBailout("local/unsupported-element-name", spanOf(id, node), `Element target ${node.type} is not a stable identifier or intrinsic tag`));
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const intrinsic = /^[a-z]/.test(name);
|
|
145
|
+
const binding = intrinsic ? null : importBinding(program, name);
|
|
146
|
+
const provenance = binding ? hostImportProvenance(imports, binding.source, binding.imported) : null;
|
|
147
|
+
const definition = intrinsic ? null : symbolDefinition(candidate.definitionOf(id, name));
|
|
148
|
+
if (!intrinsic && !definition && !provenance) {
|
|
149
|
+
bailouts.push(linkedBailout("linked/unresolved-component-binding", spanOf(id, node), `Component binding ${name} has no linked definition`));
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
kind: intrinsic ? "intrinsic" : "binding",
|
|
153
|
+
name,
|
|
154
|
+
span: spanOf(id, node),
|
|
155
|
+
closingSpan: null,
|
|
156
|
+
definition,
|
|
157
|
+
provenance
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function jsxComponentNode(opening) {
|
|
161
|
+
return childNode(opening, "name");
|
|
162
|
+
}
|
|
163
|
+
function jsxEntries(id, element, opening, bailouts) {
|
|
164
|
+
const entries = [];
|
|
165
|
+
for (const attribute of childNodes(opening, "attributes")) {
|
|
166
|
+
if (attribute.type === "JSXSpreadAttribute") {
|
|
167
|
+
const argument = childNode(attribute, "argument");
|
|
168
|
+
if (argument) {
|
|
169
|
+
entries.push({
|
|
170
|
+
kind: "spread",
|
|
171
|
+
span: spanOf(id, attribute),
|
|
172
|
+
value: expressionReference(id, argument)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (attribute.type !== "JSXAttribute") continue;
|
|
178
|
+
const nameNode = childNode(attribute, "name");
|
|
179
|
+
const name = identifierName(nameNode);
|
|
180
|
+
if (!name) {
|
|
181
|
+
bailouts.push(localBailout("local/unsupported-prop-key", spanOf(id, attribute), "Namespaced JSX attributes are not statically supported"));
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const rawValue = childNode(attribute, "value");
|
|
185
|
+
let value;
|
|
186
|
+
if (!rawValue) {
|
|
187
|
+
value = {
|
|
188
|
+
kind: "static",
|
|
189
|
+
value: true,
|
|
190
|
+
span: spanOf(id, attribute)
|
|
191
|
+
};
|
|
192
|
+
} else if (rawValue.type === "JSXExpressionContainer") {
|
|
193
|
+
const expression = childNode(rawValue, "expression");
|
|
194
|
+
if (!expression || expression.type === "JSXEmptyExpression") {
|
|
195
|
+
bailouts.push(localBailout("local/unsupported-expression", spanOf(id, rawValue), `JSX prop ${name} has no expression`));
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
value = elementValue(id, expression);
|
|
199
|
+
} else {
|
|
200
|
+
value = elementValue(id, rawValue);
|
|
201
|
+
}
|
|
202
|
+
entries.push({
|
|
203
|
+
kind: "prop",
|
|
204
|
+
name,
|
|
205
|
+
span: spanOf(id, attribute),
|
|
206
|
+
value
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
for (const child of childNodes(element, "children")) {
|
|
210
|
+
let value;
|
|
211
|
+
if (child.type === "JSXText") {
|
|
212
|
+
if (typeof child.value !== "string" || child.value.trim() === "") continue;
|
|
213
|
+
value = {
|
|
214
|
+
kind: "static",
|
|
215
|
+
value: child.value,
|
|
216
|
+
span: spanOf(id, child)
|
|
217
|
+
};
|
|
218
|
+
} else if (child.type === "JSXExpressionContainer") {
|
|
219
|
+
const expression = childNode(child, "expression");
|
|
220
|
+
value = !expression || expression.type === "JSXEmptyExpression" ? {
|
|
221
|
+
kind: "empty",
|
|
222
|
+
span: spanOf(id, child)
|
|
223
|
+
} : elementValue(id, expression);
|
|
224
|
+
} else if (child.type === "JSXElement" || child.type === "JSXFragment") {
|
|
225
|
+
value = {
|
|
226
|
+
kind: "element",
|
|
227
|
+
span: spanOf(id, child)
|
|
228
|
+
};
|
|
229
|
+
} else {
|
|
230
|
+
bailouts.push(localBailout("local/unsupported-child", spanOf(id, child), `JSX child ${child.type} cannot be normalized`));
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
entries.push({
|
|
234
|
+
kind: "child",
|
|
235
|
+
span: spanOf(id, child),
|
|
236
|
+
value
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return entries.sort((left, right) => left.span.start - right.span.start);
|
|
240
|
+
}
|
|
241
|
+
function propertyName(property) {
|
|
242
|
+
if (property.computed === true) return null;
|
|
243
|
+
const key = childNode(property, "key");
|
|
244
|
+
const name = identifierName(key);
|
|
245
|
+
if (name) return name;
|
|
246
|
+
const literal = asStaticValue(key);
|
|
247
|
+
return typeof literal === "string" || typeof literal === "number" ? String(literal) : null;
|
|
248
|
+
}
|
|
249
|
+
function runtimeChildEntries(id, program, node, bailouts) {
|
|
250
|
+
const rawNodes = node.type === "ArrayExpression" ? node.elements : null;
|
|
251
|
+
if (Array.isArray(rawNodes) && rawNodes.some((child) => child === null || !isAstNode(child))) {
|
|
252
|
+
bailouts.push(localBailout("local/unsupported-child", spanOf(id, node), "Sparse compiled children cannot be normalized without changing order"));
|
|
253
|
+
return [];
|
|
254
|
+
}
|
|
255
|
+
const nodes = Array.isArray(rawNodes) ? rawNodes.filter(isAstNode) : [node];
|
|
256
|
+
return nodes.flatMap((child) => {
|
|
257
|
+
if (child.type === "SpreadElement") {
|
|
258
|
+
bailouts.push(localBailout("local/unsupported-child", spanOf(id, child), "Spread children cannot be statically ordered"));
|
|
259
|
+
return [];
|
|
260
|
+
}
|
|
261
|
+
if (child.type === "CallExpression" && runtimeCall(program, child)) {
|
|
262
|
+
return [{
|
|
263
|
+
kind: "child",
|
|
264
|
+
span: spanOf(id, child),
|
|
265
|
+
value: {
|
|
266
|
+
kind: "element",
|
|
267
|
+
span: spanOf(id, child)
|
|
268
|
+
}
|
|
269
|
+
}];
|
|
270
|
+
}
|
|
271
|
+
return [{
|
|
272
|
+
kind: "child",
|
|
273
|
+
span: spanOf(id, child),
|
|
274
|
+
value: elementValue(id, child)
|
|
275
|
+
}];
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
function objectEntries(id, program, object, bailouts) {
|
|
279
|
+
const entries = [];
|
|
280
|
+
for (const property of childNodes(object, "properties")) {
|
|
281
|
+
if (property.type === "SpreadElement") {
|
|
282
|
+
const argument = childNode(property, "argument");
|
|
283
|
+
if (argument) {
|
|
284
|
+
const spread = {
|
|
285
|
+
kind: "spread",
|
|
286
|
+
span: spanOf(id, property),
|
|
287
|
+
value: expressionReference(id, argument)
|
|
288
|
+
};
|
|
289
|
+
entries.push(spread);
|
|
290
|
+
}
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (property.type !== "Property" && property.type !== "ObjectProperty") {
|
|
294
|
+
bailouts.push(localBailout("local/unsupported-prop-key", spanOf(id, property), `Runtime props entry ${property.type} is not a data property`));
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const name = propertyName(property);
|
|
298
|
+
const valueNode = childNode(property, "value");
|
|
299
|
+
if (!name || !valueNode) {
|
|
300
|
+
bailouts.push(localBailout("local/unsupported-prop-key", spanOf(id, property), "Computed runtime prop keys are not statically supported"));
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (name === "children") {
|
|
304
|
+
entries.push(...runtimeChildEntries(id, program, valueNode, bailouts));
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
const prop = {
|
|
308
|
+
kind: "prop",
|
|
309
|
+
name,
|
|
310
|
+
span: spanOf(id, property),
|
|
311
|
+
value: elementValue(id, valueNode)
|
|
312
|
+
};
|
|
313
|
+
entries.push(prop);
|
|
314
|
+
}
|
|
315
|
+
return entries;
|
|
316
|
+
}
|
|
317
|
+
function runtimeCall(program, call) {
|
|
318
|
+
const callee = childNode(call, "callee");
|
|
319
|
+
if (!callee) return null;
|
|
320
|
+
const directName = identifierName(callee);
|
|
321
|
+
if (directName) {
|
|
322
|
+
const provenance2 = importBinding(program, directName);
|
|
323
|
+
if (provenance2?.source === "react/jsx-runtime" && (provenance2.imported === "jsx" || provenance2.imported === "jsxs")) {
|
|
324
|
+
return { form: "jsx-runtime" };
|
|
325
|
+
}
|
|
326
|
+
if (provenance2?.source === "react" && provenance2.imported === "createElement") {
|
|
327
|
+
return { form: "create-element" };
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (callee.type !== "MemberExpression" || callee.computed === true) return null;
|
|
331
|
+
const objectName = identifierName(childNode(callee, "object"));
|
|
332
|
+
const propertyName2 = identifierName(childNode(callee, "property"));
|
|
333
|
+
if (propertyName2 !== "createElement" || !objectName) return null;
|
|
334
|
+
const provenance = importBinding(program, objectName);
|
|
335
|
+
return provenance?.source === "react" && (provenance.imported === "default" || provenance.imported === "*") ? { form: "create-element" } : null;
|
|
336
|
+
}
|
|
337
|
+
function normalizeRuntimeElement(candidate, id, program, imports, call, runtime, bailouts) {
|
|
338
|
+
const bailoutStart = bailouts.length;
|
|
339
|
+
const args = childNodes(call, "arguments");
|
|
340
|
+
const target = args[0];
|
|
341
|
+
if (!target) {
|
|
342
|
+
bailouts.push(localBailout("local/invalid-element-call", spanOf(id, call), `${runtime.form} call has no element target`));
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
const component = componentFromNode(candidate, id, program, imports, target, bailouts);
|
|
346
|
+
if (!component) return null;
|
|
347
|
+
const entries = [];
|
|
348
|
+
const props = args[1];
|
|
349
|
+
if (props && asStaticValue(props) !== null) {
|
|
350
|
+
if (props.type === "ObjectExpression") {
|
|
351
|
+
entries.push(...objectEntries(id, program, props, bailouts));
|
|
352
|
+
} else {
|
|
353
|
+
entries.push({
|
|
354
|
+
kind: "spread",
|
|
355
|
+
span: spanOf(id, props),
|
|
356
|
+
value: expressionReference(id, props)
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (runtime.form === "create-element") {
|
|
361
|
+
for (const child of args.slice(2)) {
|
|
362
|
+
entries.push(...runtimeChildEntries(id, program, child, bailouts));
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return finalizeElement({
|
|
366
|
+
kind: "element",
|
|
367
|
+
form: runtime.form,
|
|
368
|
+
id,
|
|
369
|
+
span: spanOf(id, call),
|
|
370
|
+
propsSpan: props ? spanOf(id, props) : null,
|
|
371
|
+
component
|
|
372
|
+
}, entries.sort((left, right) => left.span.start - right.span.start), bailouts.slice(bailoutStart));
|
|
373
|
+
}
|
|
374
|
+
function styledDefinitions(candidate, id, program, imports, bailouts) {
|
|
375
|
+
const definitions = [];
|
|
376
|
+
walkAst(program, (node) => {
|
|
377
|
+
if (node.type !== "VariableDeclarator") return;
|
|
378
|
+
const identifier = childNode(node, "id");
|
|
379
|
+
const name = identifierName(identifier);
|
|
380
|
+
const call = childNode(node, "init");
|
|
381
|
+
if (!name || !identifier || call?.type !== "CallExpression") return;
|
|
382
|
+
const callee = childNode(call, "callee");
|
|
383
|
+
const factoryName = callee && identifierName(callee);
|
|
384
|
+
if (!factoryName) return;
|
|
385
|
+
const binding = importBinding(program, factoryName);
|
|
386
|
+
if (!binding || binding.imported !== "styled") return;
|
|
387
|
+
const factory = hostImportProvenance(imports, binding.source, binding.imported);
|
|
388
|
+
if (!factory) return;
|
|
389
|
+
const definitionBailouts = [];
|
|
390
|
+
const args = childNodes(call, "arguments");
|
|
391
|
+
const baseNode = args[0];
|
|
392
|
+
const optionsNode = args.length >= 3 ? args[2] : args[1];
|
|
393
|
+
if (!baseNode || !optionsNode) {
|
|
394
|
+
definitionBailouts.push(localBailout("local/unsupported-styled-definition", spanOf(id, call), `styled definition ${name} must provide a base and options object`));
|
|
395
|
+
bailouts.push(...definitionBailouts);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const base = componentFromNode(candidate, id, program, imports, baseNode, definitionBailouts);
|
|
399
|
+
if (!base) {
|
|
400
|
+
bailouts.push(...definitionBailouts);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const baseClassNode = args.length >= 3 ? args[1] : null;
|
|
404
|
+
const baseDefinition = {
|
|
405
|
+
kind: "styled-definition",
|
|
406
|
+
id,
|
|
407
|
+
name,
|
|
408
|
+
span: spanOf(id, call),
|
|
409
|
+
definitionSpan: spanOf(id, identifier),
|
|
410
|
+
factory,
|
|
411
|
+
base,
|
|
412
|
+
baseClassName: baseClassNode ? elementValue(id, baseClassNode) : null,
|
|
413
|
+
options: expressionReference(id, optionsNode)
|
|
414
|
+
};
|
|
415
|
+
definitions.push(definitionBailouts.length === 0 ? {
|
|
416
|
+
...baseDefinition,
|
|
417
|
+
complete: true,
|
|
418
|
+
bailouts: []
|
|
419
|
+
} : {
|
|
420
|
+
...baseDefinition,
|
|
421
|
+
complete: false,
|
|
422
|
+
bailouts: definitionBailouts
|
|
423
|
+
});
|
|
424
|
+
bailouts.push(...definitionBailouts);
|
|
425
|
+
});
|
|
426
|
+
return definitions.sort((left, right) => left.span.start - right.span.start);
|
|
427
|
+
}
|
|
428
|
+
const DOM_STYLE_FRONTENDS = /* @__PURE__ */ new Set([
|
|
429
|
+
"tamagui/dom",
|
|
430
|
+
"@tamagui/core/dom",
|
|
431
|
+
"@tamagui/tailwind"
|
|
432
|
+
]);
|
|
433
|
+
function domStyleDefinitions(id, program, imports) {
|
|
434
|
+
const definitions = [];
|
|
435
|
+
walkAst(program, (node) => {
|
|
436
|
+
if (node.type !== "VariableDeclarator") return;
|
|
437
|
+
const identifier = childNode(node, "id");
|
|
438
|
+
const name = identifierName(identifier);
|
|
439
|
+
const call = childNode(node, "init");
|
|
440
|
+
if (!name || !identifier || call?.type !== "CallExpression") return;
|
|
441
|
+
const callee = childNode(call, "callee");
|
|
442
|
+
const factoryName = callee && identifierName(callee);
|
|
443
|
+
if (!factoryName) return;
|
|
444
|
+
const binding = importBinding(program, factoryName);
|
|
445
|
+
if (!binding || binding.imported !== "style" || !DOM_STYLE_FRONTENDS.has(binding.source)) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const factory = hostImportProvenance(imports, binding.source, binding.imported);
|
|
449
|
+
const value = childNodes(call, "arguments")[0];
|
|
450
|
+
if (!factory || !value) return;
|
|
451
|
+
definitions.push({
|
|
452
|
+
kind: "dom-style-definition",
|
|
453
|
+
id,
|
|
454
|
+
name,
|
|
455
|
+
span: spanOf(id, call),
|
|
456
|
+
definitionSpan: spanOf(id, identifier),
|
|
457
|
+
factory,
|
|
458
|
+
value: expressionReference(id, value)
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
return definitions.sort((left, right) => left.span.start - right.span.start);
|
|
462
|
+
}
|
|
463
|
+
function domStyleArgument(candidate, id, program, node) {
|
|
464
|
+
let call = node;
|
|
465
|
+
if (node.type === "Identifier") {
|
|
466
|
+
const name = identifierName(node);
|
|
467
|
+
const definition = name ? candidate.definitionOf(id, name) : null;
|
|
468
|
+
if (!definition?.constant || !definition.initializer) return null;
|
|
469
|
+
call = definition.initializer;
|
|
470
|
+
}
|
|
471
|
+
if (call.type !== "CallExpression") return null;
|
|
472
|
+
const callee = childNode(call, "callee");
|
|
473
|
+
const factoryName = callee && identifierName(callee);
|
|
474
|
+
if (!factoryName) return null;
|
|
475
|
+
const binding = importBinding(program, factoryName);
|
|
476
|
+
if (!binding || binding.imported !== "style" || !DOM_STYLE_FRONTENDS.has(binding.source)) {
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
return childNodes(call, "arguments")[0] ?? null;
|
|
480
|
+
}
|
|
481
|
+
function domStyleProgram(candidate, id, program, node) {
|
|
482
|
+
if (node.type !== "ArrayExpression" || !Array.isArray(node.elements)) {
|
|
483
|
+
const argument = domStyleArgument(candidate, id, program, node);
|
|
484
|
+
return argument ? {
|
|
485
|
+
kind: "dom-style",
|
|
486
|
+
span: spanOf(id, node),
|
|
487
|
+
items: [{
|
|
488
|
+
condition: null,
|
|
489
|
+
value: expressionReference(id, argument)
|
|
490
|
+
}]
|
|
491
|
+
} : null;
|
|
492
|
+
}
|
|
493
|
+
const items = [];
|
|
494
|
+
for (const rawItem of node.elements) {
|
|
495
|
+
if (!isAstNode(rawItem)) return null;
|
|
496
|
+
let item = rawItem;
|
|
497
|
+
let condition = null;
|
|
498
|
+
if (item.type === "LogicalExpression" && item.operator === "&&") {
|
|
499
|
+
const left = childNode(item, "left");
|
|
500
|
+
const right = childNode(item, "right");
|
|
501
|
+
if (!left || !right) return null;
|
|
502
|
+
condition = expressionReference(id, left);
|
|
503
|
+
item = right;
|
|
504
|
+
}
|
|
505
|
+
const argument = domStyleArgument(candidate, id, program, item);
|
|
506
|
+
if (!argument) {
|
|
507
|
+
const staticValue = asStaticValue(item);
|
|
508
|
+
if (staticValue === false || staticValue === null) continue;
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
items.push({
|
|
512
|
+
condition,
|
|
513
|
+
value: expressionReference(id, argument)
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
return {
|
|
517
|
+
kind: "dom-style",
|
|
518
|
+
span: spanOf(id, node),
|
|
519
|
+
items
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function normalizeElements(candidate, rawId, imports = []) {
|
|
523
|
+
const id = resolvedModuleId(rawId);
|
|
524
|
+
const program = candidate.programOf(id);
|
|
525
|
+
const elements = [];
|
|
526
|
+
const bailouts = [];
|
|
527
|
+
walkAst(program, (node) => {
|
|
528
|
+
if (node.type === "JSXElement") {
|
|
529
|
+
const bailoutStart = bailouts.length;
|
|
530
|
+
const opening = childNode(node, "openingElement");
|
|
531
|
+
const target = opening && jsxComponentNode(opening);
|
|
532
|
+
if (!opening || !target) return;
|
|
533
|
+
const component = componentFromNode(candidate, id, program, imports, target, bailouts);
|
|
534
|
+
if (!component) return;
|
|
535
|
+
const closingElement = childNode(node, "closingElement");
|
|
536
|
+
const closingName = closingElement && childNode(closingElement, "name");
|
|
537
|
+
if (closingName) component.closingSpan = spanOf(id, closingName);
|
|
538
|
+
const entries = jsxEntries(id, node, opening, bailouts);
|
|
539
|
+
for (const entry of entries) {
|
|
540
|
+
if (entry.kind !== "prop" || entry.name !== "style") continue;
|
|
541
|
+
const raw = entry.value.kind === "expression" ? nodeAtSpan(program, entry.value.start, entry.value.end) : null;
|
|
542
|
+
const styleProgram = raw && domStyleProgram(candidate, id, program, raw);
|
|
543
|
+
const argument = raw && domStyleArgument(candidate, id, program, raw);
|
|
544
|
+
if (styleProgram) entry.value = styleProgram;
|
|
545
|
+
else if (argument) entry.value = expressionReference(id, argument);
|
|
546
|
+
}
|
|
547
|
+
elements.push(finalizeElement({
|
|
548
|
+
kind: "element",
|
|
549
|
+
form: "jsx",
|
|
550
|
+
id,
|
|
551
|
+
span: spanOf(id, node),
|
|
552
|
+
propsSpan: spanOf(id, opening),
|
|
553
|
+
component
|
|
554
|
+
}, entries, bailouts.slice(bailoutStart)));
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (node.type !== "CallExpression") return;
|
|
558
|
+
const runtime = runtimeCall(program, node);
|
|
559
|
+
if (!runtime) return;
|
|
560
|
+
const element = normalizeRuntimeElement(candidate, id, program, imports, node, runtime, bailouts);
|
|
561
|
+
if (element) {
|
|
562
|
+
const entries = element.complete ? element.entries : element.bailedEntries;
|
|
563
|
+
for (const entry of entries) {
|
|
564
|
+
if (entry.kind !== "prop" || entry.name !== "style") continue;
|
|
565
|
+
const raw = entry.value.kind === "expression" ? nodeAtSpan(program, entry.value.start, entry.value.end) : null;
|
|
566
|
+
const styleProgram = raw && domStyleProgram(candidate, id, program, raw);
|
|
567
|
+
const argument = raw && domStyleArgument(candidate, id, program, raw);
|
|
568
|
+
if (styleProgram) entry.value = styleProgram;
|
|
569
|
+
else if (argument) entry.value = expressionReference(id, argument);
|
|
570
|
+
}
|
|
571
|
+
elements.push(element);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
return {
|
|
575
|
+
elements: elements.sort((left, right) => left.span.start - right.span.start),
|
|
576
|
+
styledDefinitions: styledDefinitions(candidate, id, program, imports, bailouts),
|
|
577
|
+
domStyleDefinitions: domStyleDefinitions(id, program, imports),
|
|
578
|
+
bailouts: bailouts.sort((left, right) => left.span.start - right.span.start)
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function declarationForName(program, name) {
|
|
582
|
+
return findAstNode(program, (node) => {
|
|
583
|
+
if (node.type !== "VariableDeclarator") return false;
|
|
584
|
+
return identifierName(childNode(node, "id")) === name;
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
function nodeAtSpan(program, start, end) {
|
|
588
|
+
return findAstNode(program, (node) => node.start === start && node.end === end);
|
|
589
|
+
}
|
|
590
|
+
function asAstNode(value, label) {
|
|
591
|
+
if (!isAstNode(value)) throw new Error(`${label} is not an AST node`);
|
|
592
|
+
return value;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export { asAstNode, declarationForName, definitionFromDeclaration, nodeAtSpan, normalizeElements };
|
|
596
|
+
//# sourceMappingURL=normalize.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","names":[],"sources":["esm/normalize.js"],"sourcesContent":["import {\n childNode,\n childNodes,\n findAstNode,\n identifierName,\n isAstNode,\n walkAst\n} from \"./ast\";\nimport {\n expressionReference,\n resolvedModuleId,\n spanOf\n} from \"./contracts\";\nimport { linkedBailout, localBailout } from \"./diagnostics\";\nimport { hostImportProvenance } from \"./ir\";\nfunction finalizeElement(base, entries, bailouts) {\n if (bailouts.length === 0) {\n return { ...base, complete: true, entries, bailouts: [] };\n }\n return {\n ...base,\n complete: false,\n bailedEntries: entries,\n bailouts\n };\n}\nfunction definitionFromDeclaration(id, name, program, declaration) {\n let identifier = declaration;\n let initializer = null;\n let constant = false;\n if (declaration.type === \"VariableDeclarator\") {\n identifier = childNode(declaration, \"id\") ?? declaration;\n initializer = childNode(declaration, \"init\");\n constant = !!findAstNode(\n program,\n (node) => node.type === \"VariableDeclaration\" && node.kind === \"const\" && childNodes(node, \"declarations\").some(\n (candidate) => candidate.start === declaration.start\n )\n );\n } else if (declaration.type === \"Identifier\") {\n const declarator = findAstNode(\n program,\n (node) => node.type === \"VariableDeclarator\" && childNode(node, \"id\")?.start === declaration.start\n );\n if (declarator) {\n initializer = childNode(declarator, \"init\");\n constant = !!findAstNode(\n program,\n (node) => node.type === \"VariableDeclaration\" && node.kind === \"const\" && childNodes(node, \"declarations\").some(\n (candidate) => candidate.start === declarator.start\n )\n );\n }\n }\n return {\n id: resolvedModuleId(id),\n name,\n start: identifier.start,\n end: identifier.end,\n initializer,\n constant\n };\n}\nfunction importBinding(program, localName) {\n for (const statement of childNodes(program, \"body\")) {\n if (statement.type !== \"ImportDeclaration\") continue;\n const source = childNode(statement, \"source\");\n const sourceValue = source && typeof source.value === \"string\" ? source.value : null;\n if (!sourceValue) continue;\n for (const specifier of childNodes(statement, \"specifiers\")) {\n if (identifierName(childNode(specifier, \"local\")) !== localName) continue;\n if (specifier.type === \"ImportDefaultSpecifier\") {\n return { source: sourceValue, imported: \"default\" };\n }\n if (specifier.type === \"ImportNamespaceSpecifier\") {\n return { source: sourceValue, imported: \"*\" };\n }\n const imported = childNode(specifier, \"imported\");\n const importedName = identifierName(imported) ?? (typeof imported?.value === \"string\" ? imported.value : null);\n return importedName ? { source: sourceValue, imported: importedName } : null;\n }\n }\n return null;\n}\nfunction asStaticValue(node) {\n if (!node) return void 0;\n if (node.type === \"NullLiteral\") return null;\n if (node.type === \"Literal\" || node.type.endsWith(\"Literal\")) {\n const value = node.value;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null) {\n return value;\n }\n }\n return void 0;\n}\nfunction elementValue(id, node) {\n const staticValue = asStaticValue(node);\n return staticValue === void 0 ? expressionReference(id, node) : { kind: \"static\", value: staticValue, span: spanOf(id, node) };\n}\nfunction symbolDefinition(definition) {\n if (!definition) return null;\n return {\n id: definition.id,\n name: definition.name,\n span: {\n id: definition.id,\n start: definition.start,\n end: definition.end\n },\n initializer: definition.initializer ? expressionReference(definition.id, definition.initializer) : null,\n constant: definition.constant\n };\n}\nfunction componentFromNode(candidate, id, program, imports, node, bailouts) {\n const literal = asStaticValue(node);\n if (typeof literal === \"string\") {\n return {\n kind: \"intrinsic\",\n name: literal,\n span: spanOf(id, node),\n closingSpan: null,\n definition: null,\n provenance: null\n };\n }\n if ((node.type === \"MemberExpression\" || node.type === \"JSXMemberExpression\") && node.computed !== true) {\n const objectName = identifierName(childNode(node, \"object\"));\n const memberName = identifierName(childNode(node, \"property\"));\n const binding2 = objectName ? importBinding(program, objectName) : null;\n if (memberName && binding2?.imported === \"html\") {\n const provenance2 = hostImportProvenance(imports, binding2.source, binding2.imported);\n if (provenance2) {\n return {\n kind: \"binding\",\n name: memberName,\n span: spanOf(id, node),\n closingSpan: null,\n definition: null,\n provenance: provenance2\n };\n }\n }\n }\n const name = identifierName(node);\n if (!name) {\n bailouts.push(\n localBailout(\n \"local/unsupported-element-name\",\n spanOf(id, node),\n `Element target ${node.type} is not a stable identifier or intrinsic tag`\n )\n );\n return null;\n }\n const intrinsic = /^[a-z]/.test(name);\n const binding = intrinsic ? null : importBinding(program, name);\n const provenance = binding ? hostImportProvenance(imports, binding.source, binding.imported) : null;\n const definition = intrinsic ? null : symbolDefinition(candidate.definitionOf(id, name));\n if (!intrinsic && !definition && !provenance) {\n bailouts.push(\n linkedBailout(\n \"linked/unresolved-component-binding\",\n spanOf(id, node),\n `Component binding ${name} has no linked definition`\n )\n );\n }\n return {\n kind: intrinsic ? \"intrinsic\" : \"binding\",\n name,\n span: spanOf(id, node),\n closingSpan: null,\n definition,\n provenance\n };\n}\nfunction jsxComponentNode(opening) {\n return childNode(opening, \"name\");\n}\nfunction jsxEntries(id, element, opening, bailouts) {\n const entries = [];\n for (const attribute of childNodes(opening, \"attributes\")) {\n if (attribute.type === \"JSXSpreadAttribute\") {\n const argument = childNode(attribute, \"argument\");\n if (argument) {\n entries.push({\n kind: \"spread\",\n span: spanOf(id, attribute),\n value: expressionReference(id, argument)\n });\n }\n continue;\n }\n if (attribute.type !== \"JSXAttribute\") continue;\n const nameNode = childNode(attribute, \"name\");\n const name = identifierName(nameNode);\n if (!name) {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, attribute),\n \"Namespaced JSX attributes are not statically supported\"\n )\n );\n continue;\n }\n const rawValue = childNode(attribute, \"value\");\n let value;\n if (!rawValue) {\n value = { kind: \"static\", value: true, span: spanOf(id, attribute) };\n } else if (rawValue.type === \"JSXExpressionContainer\") {\n const expression = childNode(rawValue, \"expression\");\n if (!expression || expression.type === \"JSXEmptyExpression\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-expression\",\n spanOf(id, rawValue),\n `JSX prop ${name} has no expression`\n )\n );\n continue;\n }\n value = elementValue(id, expression);\n } else {\n value = elementValue(id, rawValue);\n }\n entries.push({ kind: \"prop\", name, span: spanOf(id, attribute), value });\n }\n for (const child of childNodes(element, \"children\")) {\n let value;\n if (child.type === \"JSXText\") {\n if (typeof child.value !== \"string\" || child.value.trim() === \"\") continue;\n value = {\n kind: \"static\",\n value: child.value,\n span: spanOf(id, child)\n };\n } else if (child.type === \"JSXExpressionContainer\") {\n const expression = childNode(child, \"expression\");\n value = !expression || expression.type === \"JSXEmptyExpression\" ? { kind: \"empty\", span: spanOf(id, child) } : elementValue(id, expression);\n } else if (child.type === \"JSXElement\" || child.type === \"JSXFragment\") {\n value = { kind: \"element\", span: spanOf(id, child) };\n } else {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, child),\n `JSX child ${child.type} cannot be normalized`\n )\n );\n continue;\n }\n entries.push({ kind: \"child\", span: spanOf(id, child), value });\n }\n return entries.sort((left, right) => left.span.start - right.span.start);\n}\nfunction propertyName(property) {\n if (property.computed === true) return null;\n const key = childNode(property, \"key\");\n const name = identifierName(key);\n if (name) return name;\n const literal = asStaticValue(key);\n return typeof literal === \"string\" || typeof literal === \"number\" ? String(literal) : null;\n}\nfunction runtimeChildEntries(id, program, node, bailouts) {\n const rawNodes = node.type === \"ArrayExpression\" ? node.elements : null;\n if (Array.isArray(rawNodes) && rawNodes.some((child) => child === null || !isAstNode(child))) {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, node),\n \"Sparse compiled children cannot be normalized without changing order\"\n )\n );\n return [];\n }\n const nodes = Array.isArray(rawNodes) ? rawNodes.filter(isAstNode) : [node];\n return nodes.flatMap((child) => {\n if (child.type === \"SpreadElement\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-child\",\n spanOf(id, child),\n \"Spread children cannot be statically ordered\"\n )\n );\n return [];\n }\n if (child.type === \"CallExpression\" && runtimeCall(program, child)) {\n return [\n {\n kind: \"child\",\n span: spanOf(id, child),\n value: { kind: \"element\", span: spanOf(id, child) }\n }\n ];\n }\n return [{ kind: \"child\", span: spanOf(id, child), value: elementValue(id, child) }];\n });\n}\nfunction objectEntries(id, program, object, bailouts) {\n const entries = [];\n for (const property of childNodes(object, \"properties\")) {\n if (property.type === \"SpreadElement\") {\n const argument = childNode(property, \"argument\");\n if (argument) {\n const spread = {\n kind: \"spread\",\n span: spanOf(id, property),\n value: expressionReference(id, argument)\n };\n entries.push(spread);\n }\n continue;\n }\n if (property.type !== \"Property\" && property.type !== \"ObjectProperty\") {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, property),\n `Runtime props entry ${property.type} is not a data property`\n )\n );\n continue;\n }\n const name = propertyName(property);\n const valueNode = childNode(property, \"value\");\n if (!name || !valueNode) {\n bailouts.push(\n localBailout(\n \"local/unsupported-prop-key\",\n spanOf(id, property),\n \"Computed runtime prop keys are not statically supported\"\n )\n );\n continue;\n }\n if (name === \"children\") {\n entries.push(...runtimeChildEntries(id, program, valueNode, bailouts));\n continue;\n }\n const prop = {\n kind: \"prop\",\n name,\n span: spanOf(id, property),\n value: elementValue(id, valueNode)\n };\n entries.push(prop);\n }\n return entries;\n}\nfunction runtimeCall(program, call) {\n const callee = childNode(call, \"callee\");\n if (!callee) return null;\n const directName = identifierName(callee);\n if (directName) {\n const provenance2 = importBinding(program, directName);\n if (provenance2?.source === \"react/jsx-runtime\" && (provenance2.imported === \"jsx\" || provenance2.imported === \"jsxs\")) {\n return { form: \"jsx-runtime\" };\n }\n if (provenance2?.source === \"react\" && provenance2.imported === \"createElement\") {\n return { form: \"create-element\" };\n }\n }\n if (callee.type !== \"MemberExpression\" || callee.computed === true) return null;\n const objectName = identifierName(childNode(callee, \"object\"));\n const propertyName2 = identifierName(childNode(callee, \"property\"));\n if (propertyName2 !== \"createElement\" || !objectName) return null;\n const provenance = importBinding(program, objectName);\n return provenance?.source === \"react\" && (provenance.imported === \"default\" || provenance.imported === \"*\") ? { form: \"create-element\" } : null;\n}\nfunction normalizeRuntimeElement(candidate, id, program, imports, call, runtime, bailouts) {\n const bailoutStart = bailouts.length;\n const args = childNodes(call, \"arguments\");\n const target = args[0];\n if (!target) {\n bailouts.push(\n localBailout(\n \"local/invalid-element-call\",\n spanOf(id, call),\n `${runtime.form} call has no element target`\n )\n );\n return null;\n }\n const component = componentFromNode(candidate, id, program, imports, target, bailouts);\n if (!component) return null;\n const entries = [];\n const props = args[1];\n if (props && asStaticValue(props) !== null) {\n if (props.type === \"ObjectExpression\") {\n entries.push(...objectEntries(id, program, props, bailouts));\n } else {\n entries.push({\n kind: \"spread\",\n span: spanOf(id, props),\n value: expressionReference(id, props)\n });\n }\n }\n if (runtime.form === \"create-element\") {\n for (const child of args.slice(2)) {\n entries.push(...runtimeChildEntries(id, program, child, bailouts));\n }\n }\n return finalizeElement(\n {\n kind: \"element\",\n form: runtime.form,\n id,\n span: spanOf(id, call),\n propsSpan: props ? spanOf(id, props) : null,\n component\n },\n entries.sort((left, right) => left.span.start - right.span.start),\n bailouts.slice(bailoutStart)\n );\n}\nfunction styledDefinitions(candidate, id, program, imports, bailouts) {\n const definitions = [];\n walkAst(program, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const identifier = childNode(node, \"id\");\n const name = identifierName(identifier);\n const call = childNode(node, \"init\");\n if (!name || !identifier || call?.type !== \"CallExpression\") return;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"styled\") return;\n const factory = hostImportProvenance(imports, binding.source, binding.imported);\n if (!factory) return;\n const definitionBailouts = [];\n const args = childNodes(call, \"arguments\");\n const baseNode = args[0];\n const optionsNode = args.length >= 3 ? args[2] : args[1];\n if (!baseNode || !optionsNode) {\n definitionBailouts.push(\n localBailout(\n \"local/unsupported-styled-definition\",\n spanOf(id, call),\n `styled definition ${name} must provide a base and options object`\n )\n );\n bailouts.push(...definitionBailouts);\n return;\n }\n const base = componentFromNode(\n candidate,\n id,\n program,\n imports,\n baseNode,\n definitionBailouts\n );\n if (!base) {\n bailouts.push(...definitionBailouts);\n return;\n }\n const baseClassNode = args.length >= 3 ? args[1] : null;\n const baseDefinition = {\n kind: \"styled-definition\",\n id,\n name,\n span: spanOf(id, call),\n definitionSpan: spanOf(id, identifier),\n factory,\n base,\n baseClassName: baseClassNode ? elementValue(id, baseClassNode) : null,\n options: expressionReference(id, optionsNode)\n };\n definitions.push(\n definitionBailouts.length === 0 ? { ...baseDefinition, complete: true, bailouts: [] } : {\n ...baseDefinition,\n complete: false,\n bailouts: definitionBailouts\n }\n );\n bailouts.push(...definitionBailouts);\n });\n return definitions.sort((left, right) => left.span.start - right.span.start);\n}\nconst DOM_STYLE_FRONTENDS = /* @__PURE__ */ new Set([\n \"tamagui/dom\",\n \"@tamagui/core/dom\",\n \"@tamagui/tailwind\"\n]);\nfunction domStyleDefinitions(id, program, imports) {\n const definitions = [];\n walkAst(program, (node) => {\n if (node.type !== \"VariableDeclarator\") return;\n const identifier = childNode(node, \"id\");\n const name = identifierName(identifier);\n const call = childNode(node, \"init\");\n if (!name || !identifier || call?.type !== \"CallExpression\") return;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"style\" || !DOM_STYLE_FRONTENDS.has(binding.source)) {\n return;\n }\n const factory = hostImportProvenance(imports, binding.source, binding.imported);\n const value = childNodes(call, \"arguments\")[0];\n if (!factory || !value) return;\n definitions.push({\n kind: \"dom-style-definition\",\n id,\n name,\n span: spanOf(id, call),\n definitionSpan: spanOf(id, identifier),\n factory,\n value: expressionReference(id, value)\n });\n });\n return definitions.sort((left, right) => left.span.start - right.span.start);\n}\nfunction domStyleArgument(candidate, id, program, node) {\n let call = node;\n if (node.type === \"Identifier\") {\n const name = identifierName(node);\n const definition = name ? candidate.definitionOf(id, name) : null;\n if (!definition?.constant || !definition.initializer) return null;\n call = definition.initializer;\n }\n if (call.type !== \"CallExpression\") return null;\n const callee = childNode(call, \"callee\");\n const factoryName = callee && identifierName(callee);\n if (!factoryName) return null;\n const binding = importBinding(program, factoryName);\n if (!binding || binding.imported !== \"style\" || !DOM_STYLE_FRONTENDS.has(binding.source)) {\n return null;\n }\n return childNodes(call, \"arguments\")[0] ?? null;\n}\nfunction domStyleProgram(candidate, id, program, node) {\n if (node.type !== \"ArrayExpression\" || !Array.isArray(node.elements)) {\n const argument = domStyleArgument(candidate, id, program, node);\n return argument ? {\n kind: \"dom-style\",\n span: spanOf(id, node),\n items: [{ condition: null, value: expressionReference(id, argument) }]\n } : null;\n }\n const items = [];\n for (const rawItem of node.elements) {\n if (!isAstNode(rawItem)) return null;\n let item = rawItem;\n let condition = null;\n if (item.type === \"LogicalExpression\" && item.operator === \"&&\") {\n const left = childNode(item, \"left\");\n const right = childNode(item, \"right\");\n if (!left || !right) return null;\n condition = expressionReference(id, left);\n item = right;\n }\n const argument = domStyleArgument(candidate, id, program, item);\n if (!argument) {\n const staticValue = asStaticValue(item);\n if (staticValue === false || staticValue === null) continue;\n return null;\n }\n items.push({ condition, value: expressionReference(id, argument) });\n }\n return { kind: \"dom-style\", span: spanOf(id, node), items };\n}\nfunction normalizeElements(candidate, rawId, imports = []) {\n const id = resolvedModuleId(rawId);\n const program = candidate.programOf(id);\n const elements = [];\n const bailouts = [];\n walkAst(program, (node) => {\n if (node.type === \"JSXElement\") {\n const bailoutStart = bailouts.length;\n const opening = childNode(node, \"openingElement\");\n const target = opening && jsxComponentNode(opening);\n if (!opening || !target) return;\n const component = componentFromNode(\n candidate,\n id,\n program,\n imports,\n target,\n bailouts\n );\n if (!component) return;\n const closingElement = childNode(node, \"closingElement\");\n const closingName = closingElement && childNode(closingElement, \"name\");\n if (closingName) component.closingSpan = spanOf(id, closingName);\n const entries = jsxEntries(id, node, opening, bailouts);\n for (const entry of entries) {\n if (entry.kind !== \"prop\" || entry.name !== \"style\") continue;\n const raw = entry.value.kind === \"expression\" ? nodeAtSpan(program, entry.value.start, entry.value.end) : null;\n const styleProgram = raw && domStyleProgram(candidate, id, program, raw);\n const argument = raw && domStyleArgument(candidate, id, program, raw);\n if (styleProgram) entry.value = styleProgram;\n else if (argument) entry.value = expressionReference(id, argument);\n }\n elements.push(\n finalizeElement(\n {\n kind: \"element\",\n form: \"jsx\",\n id,\n span: spanOf(id, node),\n propsSpan: spanOf(id, opening),\n component\n },\n entries,\n bailouts.slice(bailoutStart)\n )\n );\n return;\n }\n if (node.type !== \"CallExpression\") return;\n const runtime = runtimeCall(program, node);\n if (!runtime) return;\n const element = normalizeRuntimeElement(\n candidate,\n id,\n program,\n imports,\n node,\n runtime,\n bailouts\n );\n if (element) {\n const entries = element.complete ? element.entries : element.bailedEntries;\n for (const entry of entries) {\n if (entry.kind !== \"prop\" || entry.name !== \"style\") continue;\n const raw = entry.value.kind === \"expression\" ? nodeAtSpan(program, entry.value.start, entry.value.end) : null;\n const styleProgram = raw && domStyleProgram(candidate, id, program, raw);\n const argument = raw && domStyleArgument(candidate, id, program, raw);\n if (styleProgram) entry.value = styleProgram;\n else if (argument) entry.value = expressionReference(id, argument);\n }\n elements.push(element);\n }\n });\n return {\n elements: elements.sort((left, right) => left.span.start - right.span.start),\n styledDefinitions: styledDefinitions(candidate, id, program, imports, bailouts),\n domStyleDefinitions: domStyleDefinitions(id, program, imports),\n bailouts: bailouts.sort((left, right) => left.span.start - right.span.start)\n };\n}\nfunction declarationForName(program, name) {\n return findAstNode(program, (node) => {\n if (node.type !== \"VariableDeclarator\") return false;\n return identifierName(childNode(node, \"id\")) === name;\n });\n}\nfunction nodeAtSpan(program, start, end) {\n return findAstNode(program, (node) => node.start === start && node.end === end);\n}\nfunction asAstNode(value, label) {\n if (!isAstNode(value)) throw new Error(`${label} is not an AST node`);\n return value;\n}\nexport {\n asAstNode,\n declarationForName,\n definitionFromDeclaration,\n nodeAtSpan,\n normalizeElements\n};\n//# sourceMappingURL=normalize.js.map\n"],"mappings":";;;;;;AAeA,SAAS,gBAAgB,MAAM,SAAS,UAAU;CAChD,IAAI,SAAS,WAAW,GAAG;EACzB,OAAO;GAAE,GAAG;GAAM,UAAU;GAAM;GAAS,UAAU,CAAC;EAAE;CAC1D;CACA,OAAO;EACL,GAAG;EACH,UAAU;EACV,eAAe;EACf;CACF;AACF;AACA,SAAS,0BAA0B,IAAI,MAAM,SAAS,aAAa;CACjE,IAAI,aAAa;CACjB,IAAI,cAAc;CAClB,IAAI,WAAW;CACf,IAAI,YAAY,SAAS,sBAAsB;EAC7C,aAAa,UAAU,aAAa,IAAI,KAAK;EAC7C,cAAc,UAAU,aAAa,MAAM;EAC3C,WAAW,CAAC,CAAC,YACX,UACC,SAAS,KAAK,SAAS,yBAAyB,KAAK,SAAS,WAAW,WAAW,MAAM,cAAc,EAAE,MACxG,cAAc,UAAU,UAAU,YAAY,KACjD,CACF;CACF,OAAO,IAAI,YAAY,SAAS,cAAc;EAC5C,MAAM,aAAa,YACjB,UACC,SAAS,KAAK,SAAS,wBAAwB,UAAU,MAAM,IAAI,GAAG,UAAU,YAAY,KAC/F;EACA,IAAI,YAAY;GACd,cAAc,UAAU,YAAY,MAAM;GAC1C,WA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