1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//! Persisted syntactic evidence for conservative component-input analysis.
/// Framework owning a statically extracted component contract.
#[derive(Debug, Clone, Copy, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub enum ComponentFramework {
/// React JSX.
React,
/// Preact JSX.
Preact,
/// Solid JSX.
Solid,
/// Qwik JSX.
Qwik,
/// Vue and Nuxt single-file components.
Vue,
/// Svelte components.
Svelte,
/// Astro components.
Astro,
/// Angular components and directives.
Angular,
/// Lit custom elements.
Lit,
/// Ember and Glimmer components.
Ember,
}
/// Stable component binding identity, independent of transient parser symbols.
#[derive(Debug, Clone, PartialEq, Eq, Hash, bitcode::Encode, bitcode::Decode)]
pub enum ComponentReference {
/// A same-module declaration, including resolved immutable local aliases.
Local {
/// Declaration binding name.
name: String,
/// Start byte of the declaration binding.
span_start: u32,
},
/// An import binding. Analysis resolves its effective export via the graph.
Import {
/// Local name of the actual import binding, never a shadowing identifier.
local: String,
/// Start byte of the import binding declaration.
span_start: u32,
},
/// A direct member of a proven namespace import.
NamespaceMember {
/// Local namespace import binding name.
local: String,
/// Namespace import binding byte anchor.
span_start: u32,
/// Effective value export requested by the member access.
member: String,
},
/// A statically registered Angular selector or custom-element tag.
Selector(String),
/// Dynamic or unsupported component identity.
Unknown,
}
/// A declared public input, kept distinct from legacy unused-prop facts.
#[derive(Debug, Clone, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct ComponentPropDeclaration {
/// Component declaration name. Empty denotes the sole SFC default export.
pub component: String,
/// Stable declaration binding byte anchor.
pub component_span: u32,
/// Public input name.
pub name: String,
/// Local binding name used by destructured template reads.
pub local: String,
/// Additional public attribute names supplying the same input.
pub aliases: Vec<String>,
/// Declaration byte anchor in the original source.
pub span_start: u32,
/// Whether the declaration explicitly permits omission.
pub optional: bool,
/// Whether omission has a syntactically declared default value.
pub has_default: bool,
/// Whether the input is consumed within the component.
pub is_used: bool,
/// Producer framework.
pub framework: ComponentFramework,
/// Unsupported declarations, forwarding, or open consumers prohibit absence claims.
pub incomplete: bool,
}
/// One inspected render invocation and its supplied input names.
#[derive(Debug, Clone, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct ComponentInvocation {
/// Binding or selector used by the invocation.
pub target: ComponentReference,
/// Original source byte anchor of the opening tag or call.
pub span_start: u32,
/// Supplied names, independent of values and including proven spread keys.
pub supplied: Vec<String>,
/// Case-sensitive Lit JavaScript property bindings, distinct from HTML attributes.
pub supplied_properties: Vec<String>,
/// A spread or dynamic attribute may supply additional names.
pub unknown_props: bool,
/// Framework syntax of this caller.
pub framework: ComponentFramework,
}
/// Persisted syntactic evidence for conservative component-input analysis.
#[derive(Debug, Clone, Default, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct ComponentContractFacts {
/// Immutable root script aliases resolved to their semantic targets.
pub aliases: Vec<ComponentAliasBinding>,
/// Exact Angular templateUrl source owned by each component binding.
pub external_templates: Vec<ComponentExternalTemplate>,
/// Original component bodies that own embedded Glimmer templates.
pub template_owners: Vec<ComponentTemplateOwner>,
/// Effective local export bindings retained after graph payload release.
pub exports: Vec<ComponentExportBinding>,
/// Immutable local object shapes retained for template spread resolution.
pub spread_bindings: Vec<ComponentSpreadBinding>,
/// Known declaration contracts.
pub declarations: Vec<ComponentPropDeclaration>,
/// Inspected render sites, including module-level invocations.
pub invocations: Vec<ComponentInvocation>,
/// Component bindings used opaquely outside inspected renders.
pub escapes: Vec<ComponentReference>,
/// Frameworks with a dynamic consumer whose affected target is unknowable.
pub incomplete_frameworks: Vec<ComponentFramework>,
}
/// An immutable, unescaped local object with statically known own keys.
#[derive(Debug, Clone, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct ComponentSpreadBinding {
/// Root script binding name, resolved before template scopes are applied.
pub local: String,
/// Script binding declaration anchor.
pub span_start: u32,
/// Complete own property names.
pub keys: Vec<String>,
}
/// An export name resolved to its syntactic component or import binding.
#[derive(Debug, Clone, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct ComponentExportBinding {
/// Public export name, including `default`.
pub export_name: String,
/// Original export declaration byte anchor.
pub export_span: u32,
/// Proven local binding, canonicalizing immutable aliases.
pub target: ComponentReference,
}
/// A semantic component declaration body containing an embedded template.
#[derive(Debug, Clone, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct ComponentTemplateOwner {
/// Owning component binding anchor.
pub component_span: u32,
/// Original class body start.
pub start: u32,
/// Original class body end.
pub end: u32,
}
/// A statically declared external template owned by one component.
#[derive(Debug, Clone, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct ComponentExternalTemplate {
/// Owning component binding anchor.
pub component_span: u32,
/// Literal templateUrl source, resolved through the graph import edge.
pub source: String,
}
/// An immutable root binding that aliases a component or import.
#[derive(Debug, Clone, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct ComponentAliasBinding {
/// Root script binding spelling used by template expressions.
pub local: String,
/// Canonical semantic binding target, including its source anchor.
pub target: ComponentReference,
}