Skip to main content

fallow_extract/cache/
types.rs

1//! Serialization types for the incremental parse cache.
2//!
3//! All types use bitcode `Encode`/`Decode` for fast binary serialization.
4
5use bitcode::{Decode, Encode};
6
7use crate::MemberKind;
8
9/// Cache version. Bump it when the serialized cache shape or the cached
10/// extraction semantics change, and give the reason in the commit message and
11/// the CHANGELOG. A stale version serves old extraction results from a warm
12/// cache. The `assert_cached_type_size!` guards below catch shape changes.
13pub(super) const CACHE_VERSION: u32 = 315;
14
15/// Duplication token cache version. Bump it when duplicate tokenization,
16/// normalization, or the on-disk token cache schema changes, and give the
17/// reason in the commit message and the CHANGELOG.
18pub const DUPES_CACHE_VERSION: u32 = 14;
19
20/// Default maximum cache size (256 MB). Overridable per-project via
21/// `cache.maxSizeMb` in the config file or `FALLOW_CACHE_MAX_SIZE` env var.
22/// Also used as the hard ceiling on load-time deserialization as a defence
23/// against pathological on-disk files.
24pub const DEFAULT_CACHE_MAX_SIZE: usize = 256 * 1024 * 1024;
25
26/// Trigger LRU eviction when the serialized cache exceeds 80% of the cap.
27/// Basis points (1/100 of a percent) for integer arithmetic without floats.
28pub(super) const EVICTION_TRIGGER_BPS: usize = 8000;
29
30/// Evict down to 60% of the cap so subsequent saves leave headroom.
31pub(super) const EVICTION_TARGET_BPS: usize = 6000;
32
33/// Promote the eviction log from `debug!` to `info!` when at least 25% of
34/// entries are removed in a single save. Default-noise concerns mean
35/// small-turnover saves should not be visible without `RUST_LOG=debug`.
36pub(super) const EVICTION_SIGNIFICANT_BPS: usize = 2500;
37
38/// Import kind discriminant for `CachedImport`:
39/// 0 = Named, 1 = Default, 2 = Namespace, 3 = `SideEffect`.
40pub(super) const IMPORT_KIND_NAMED: u8 = 0;
41pub(super) const IMPORT_KIND_DEFAULT: u8 = 1;
42pub(super) const IMPORT_KIND_NAMESPACE: u8 = 2;
43pub(super) const IMPORT_KIND_SIDE_EFFECT: u8 = 3;
44
45macro_rules! assert_cached_type_size {
46    ($ty:ty, $size:expr) => {
47        const _: () = assert!(
48            std::mem::size_of::<$ty>() == $size,
49            concat!(
50                stringify!($ty),
51                " size changed; bump CACHE_VERSION if the cached wire shape or extraction semantics changed, then update this assertion"
52            )
53        );
54    };
55}
56
57assert_cached_type_size!(CachedModule, 1376);
58assert_cached_type_size!(CachedNamespaceObjectAlias, 72);
59assert_cached_type_size!(CachedLocalTypeDeclaration, 32);
60assert_cached_type_size!(CachedPublicSignatureTypeReference, 56);
61assert_cached_type_size!(CachedSuppression, 88);
62assert_cached_type_size!(CachedUnknownSuppressionKind, 56);
63assert_cached_type_size!(CachedExport, 152);
64assert_cached_type_size!(CachedImport, 96);
65assert_cached_type_size!(CachedDynamicImport, 88);
66assert_cached_type_size!(CachedRequireCall, 96);
67assert_cached_type_size!(CachedReExport, 104);
68assert_cached_type_size!(CachedMember, 64);
69assert_cached_type_size!(CachedDynamicImportPattern, 64);
70assert_cached_type_size!(crate::MemberAccess, 48);
71assert_cached_type_size!(fallow_types::extract::SemanticFact, 96);
72assert_cached_type_size!(fallow_types::extract::CalleeUse, 32);
73assert_cached_type_size!(fallow_types::extract::MisplacedDirectiveSite, 8);
74assert_cached_type_size!(fallow_types::extract::SinkSite, 216);
75assert_cached_type_size!(fallow_types::extract::FunctionComplexity, 96);
76assert_cached_type_size!(fallow_types::extract::ComplexityContribution, 16);
77assert_cached_type_size!(fallow_types::extract::FlagUse, 80);
78assert_cached_type_size!(fallow_types::extract::ClassHeritageInfo, 168);
79assert_cached_type_size!(fallow_types::extract::FactoryReturnExport, 48);
80assert_cached_type_size!(fallow_types::extract::TypeMemberTypeEntry, 72);
81assert_cached_type_size!(fallow_types::extract::LoadReturnKey, 32);
82
83/// Cached data for a single module.
84#[derive(Debug, Clone, Encode, Decode)]
85pub struct CachedModule {
86    /// xxh3 hash of the file content.
87    pub content_hash: u64,
88    /// File modification time in nanoseconds for fast cache validation.
89    /// When mtime+ctime+size match the on-disk file, we skip reading file
90    /// content entirely.
91    pub mtime_ns: u64,
92    /// File inode change time in nanoseconds, or `0` on platforms that do not
93    /// report one. Stored beside `mtime_ns` because mtime is writer-controlled:
94    /// a same-length rewrite with a restored mtime is invisible to
95    /// `(mtime, size)` alone, and the metadata-only fast path would then hand
96    /// back analysis of the previous content.
97    pub ctime_ns: u64,
98    /// File size in bytes for fast cache validation.
99    pub file_size: u64,
100    /// Seconds-since-epoch at the time this entry was last WRITTEN
101    /// (first parse or content-change refresh). NOT updated on cache-hit
102    /// reads: `update_cache` already iterates every in-scope file every run,
103    /// so refreshing on read would collapse the LRU to "last run this file
104    /// was discovered" for every retained entry. With write-only refresh,
105    /// the LRU genuinely targets stale (in-scope-but-unchanged-for-many-runs)
106    /// entries. Used by `CacheStore::save` for write-time eviction ordering.
107    pub last_access_secs: u64,
108    /// Exported symbols.
109    pub exports: Vec<CachedExport>,
110    /// Import specifiers.
111    pub imports: Vec<CachedImport>,
112    /// Re-export specifiers.
113    pub re_exports: Vec<CachedReExport>,
114    /// Dynamic import specifiers.
115    pub dynamic_imports: Vec<CachedDynamicImport>,
116    /// `require()` specifiers.
117    pub require_calls: Vec<CachedRequireCall>,
118    /// Package names statically referenced through package path resolution.
119    pub package_path_references: Box<[String]>,
120    /// Static member accesses (e.g., `Status.Active`).
121    pub member_accesses: Vec<crate::MemberAccess>,
122    /// Typed semantic facts produced by extraction for cross-layer analysis.
123    /// `None` means no facts, which keeps the common warm-cache payload lean.
124    pub semantic_facts: Option<Box<[fallow_types::extract::SemanticFact]>>,
125    /// Identifiers used as whole objects (Object.values, for..in, spread, etc.).
126    pub whole_object_uses: Box<[String]>,
127    /// Dynamic import patterns with partial static resolution.
128    pub dynamic_import_patterns: Vec<CachedDynamicImportPattern>,
129    /// Number of parser diagnostics the parse of this file produced.
130    /// Round-trips so a warm load still reports `source-parse-degraded`
131    /// instead of silently inheriting a partial parse.
132    pub parse_error_count: u32,
133    /// Whether the parser abandoned this file instead of recovering.
134    pub parse_panicked: bool,
135    /// Whether this module uses CJS exports.
136    pub has_cjs_exports: bool,
137    /// Whether this module declares at least one Angular `@Component({
138    /// templateUrl: ... })` decorator. Mirrors `ModuleInfo.has_angular_component_template_url`
139    /// so the CRAP-inherit walker's gate survives a warm-cache load.
140    pub has_angular_component_template_url: bool,
141    /// Local names of import bindings that are never referenced in this file.
142    pub unused_import_bindings: Vec<String>,
143    /// Local import bindings referenced from type positions.
144    pub type_referenced_import_bindings: Vec<String>,
145    /// Local import bindings referenced from value positions.
146    pub value_referenced_import_bindings: Vec<String>,
147    /// Inline suppression directives.
148    pub suppressions: Vec<CachedSuppression>,
149    /// Suppression tokens that did not parse to any known `IssueKind`. See #449.
150    pub unknown_suppression_kinds: Vec<CachedUnknownSuppressionKind>,
151    /// Pre-computed line-start byte offsets for O(log N) byte-to-line/col conversion.
152    pub line_offsets: Vec<u32>,
153    /// Per-function complexity metrics.
154    pub complexity: Vec<fallow_types::extract::FunctionComplexity>,
155    /// Whether the run that wrote this entry actually extracted complexity.
156    ///
157    /// An empty `complexity` vector is ambiguous on its own: a `dead-code` run
158    /// passes `need_complexity == false` and produces one, and so does a file
159    /// with no functions at all. Reading emptiness as "not cached" made every
160    /// later `health` run pay a full cold parse for a file that was already
161    /// analyzed. This flag is the honest answer, so a complexity consumer can
162    /// hit on a rich entry and a complexity-blind run can refuse to downgrade
163    /// one.
164    pub complexity_extracted: bool,
165    /// Feature flag use sites.
166    pub flag_uses: Vec<fallow_types::extract::FlagUse>,
167    /// Flag-key registries and registry reads.
168    pub flag_registry_facts: Option<Box<fallow_types::extract::FlagRegistryFacts>>,
169    /// Heritage metadata for exported classes.
170    pub class_heritage: Vec<fallow_types::extract::ClassHeritageInfo>,
171    /// Exported free-function factories that provably return one class instance
172    /// (`export function useApi() { return new RESTApi() }`). Compacted to `None`
173    /// when empty so the common no-factory module pays no payload. See #1441 Part A.
174    pub exported_factory_returns: Option<Box<[fallow_types::extract::FactoryReturnExport]>>,
175    /// Object-literal factory-return shapes (`export function createUi() {
176    /// return { orders: factory.ordersPage } }`). Compacted to `None` when empty
177    /// so the common no-object-factory module pays no payload. See issue #1858.
178    pub exported_factory_return_object_shapes:
179        Option<Box<[fallow_types::extract::FactoryReturnObjectShapeExport]>>,
180    /// Named-type property types declared by top-level interfaces and
181    /// type-literal aliases (`interface Opts { c: OptDep }`). Compacted to
182    /// `None` when empty so the common no-interface module pays no payload.
183    /// See issue #1785.
184    pub type_member_types: Option<Box<[fallow_types::extract::TypeMemberTypeEntry]>>,
185    /// Angular `InjectionToken<Interface>` `(token, interface)` pairs (#920).
186    pub injection_tokens: Vec<(String, String)>,
187    /// Local type-capable declarations.
188    pub local_type_declarations: Vec<CachedLocalTypeDeclaration>,
189    /// Type references from exported public signatures.
190    pub public_signature_type_references: Vec<CachedPublicSignatureTypeReference>,
191    /// Namespace-import aliases re-exported through an object literal
192    /// (`export const API = { foo }` where `foo` is `import * as foo from './bar'`).
193    pub namespace_object_aliases: Vec<CachedNamespaceObjectAlias>,
194    /// Iconify collection prefixes found in static icon props (issue #608).
195    pub iconify_prefixes: Vec<String>,
196    /// Nuxt UI icon class suffixes found in static script-side icon properties
197    /// (issue #955).
198    pub iconify_icon_names: Vec<String>,
199    /// Bare identifier names that are candidates for convention auto-import
200    /// resolution (issue #704). Content-local, so they round-trip through the
201    /// cache; resolution against the plugin table happens at graph-build time.
202    pub auto_import_candidates: Vec<String>,
203    /// File-level string directives (`"use client"`, `"use server"`). Content-local,
204    /// round-trips through the cache so the security `client-server-leak` detector
205    /// sees directives on warm-cache loads.
206    pub directives: Vec<String>,
207    /// Byte-offset starts of `next/dynamic(..., { ssr: false })` dynamic imports.
208    /// Content-local, round-trips so the security `client-server-leak` BFS sees
209    /// the ssr:false client-only escape hatch on warm-cache loads.
210    pub client_only_dynamic_import_spans: Vec<u32>,
211    /// Captured security sink sites (category-blind). Round-trips through the
212    /// cache so the catalogue-driven `tainted_sink` detector sees sinks on
213    /// warm-cache loads.
214    pub security_sinks: Vec<fallow_types::extract::SinkSite>,
215    /// Count of sink-shaped nodes whose callee could not be flattened to a
216    /// static path. Round-trips so the in-band blind-spot count is stable.
217    pub security_sinks_skipped: u32,
218    /// Span-level diagnostics for skipped security sink callees.
219    pub security_unresolved_callee_sites: Vec<fallow_types::extract::SkippedSecurityCalleeSite>,
220    /// Local bindings tied to the member-access path they were sourced from.
221    /// Round-trips so the security `tainted_sink` source-to-sink association
222    /// sees source-tainted bindings on warm-cache loads.
223    pub tainted_bindings: Vec<fallow_types::extract::TaintedBinding>,
224    /// Direct sink arguments recognized as sanitizer calls.
225    pub sanitized_sink_args: Vec<fallow_types::extract::SanitizedSinkArg>,
226    /// Defensive control call sites for security surface output.
227    pub security_control_sites: Vec<fallow_types::extract::SecurityControlSite>,
228    /// Deduped statically flattenable callee paths. Round-trips so the
229    /// `boundaries.calls.forbidden` detector sees call sites on warm-cache
230    /// loads.
231    pub callee_uses: Vec<fallow_types::extract::CalleeUse>,
232    /// Misplaced `"use client"` / `"use server"` directive sites.
233    /// Round-trips so the `misplaced-directive` detector sees them on
234    /// warm-cache loads.
235    pub misplaced_directives: Vec<fallow_types::extract::MisplacedDirectiveSite>,
236    /// Export local names of inline `"use server"` body Server Actions.
237    /// Round-trips so the `unused-server-action` reclassifier sees them on
238    /// warm-cache loads.
239    pub inline_server_action_exports: Vec<String>,
240    /// Vue `provide`/`inject` and Svelte `setContext`/`getContext` key sites.
241    /// Round-trips so the `unprovided-inject` detector sees them on warm-cache
242    /// loads.
243    pub di_key_sites: Vec<fallow_types::extract::DiKeySite>,
244    /// Whether the module had an unknowable-key provide. Round-trips so the
245    /// `unprovided-inject` project-wide abstain holds on warm-cache loads.
246    pub has_dynamic_provide: bool,
247    /// All-action `"use server"` module flag. Round-trips so the security
248    /// `client-server-leak` BFS sees the action boundary on warm-cache loads.
249    pub is_server_action_module: bool,
250    /// Vue `<script setup>` `defineProps` and Svelte 5 `$props()` declared props.
251    /// Round-trips so the `unused-component-prop` detector sees them on
252    /// warm-cache loads.
253    pub component_props: Vec<fallow_types::extract::ComponentProp>,
254    /// Whether the template spreads `$attrs`/`$props`/`props` or the
255    /// `defineProps` return is rest-destructured. Round-trips for the abstain.
256    pub has_props_attrs_fallthrough: bool,
257    /// Whether the SFC calls `defineExpose(...)`. Round-trips for the abstain.
258    pub has_define_expose: bool,
259    /// Whether the SFC calls `defineModel(...)`. Round-trips for the abstain.
260    pub has_define_model: bool,
261    /// Whether `defineProps` had an unharvestable type-reference argument.
262    /// Round-trips for the abstain.
263    pub has_unharvestable_props: bool,
264    /// Vue `<script setup>` `defineEmits` declared events. Round-trips so the
265    /// `unused-component-emit` detector sees them on warm-cache loads.
266    pub component_emits: Vec<fallow_types::extract::ComponentEmit>,
267    /// Angular component/directive inputs (`@Input()` decorators and signal
268    /// `input()` / `model()` initializers). Round-trips so the
269    /// `unused-component-input` detector sees them on warm-cache loads.
270    pub angular_inputs: Vec<fallow_types::extract::AngularInputMember>,
271    /// Angular component/directive outputs (`@Output()` decorators and signal
272    /// `output()` / `outputFromObservable()` initializers). Round-trips so the
273    /// `unused-component-output` detector sees them on warm-cache loads.
274    pub angular_outputs: Vec<fallow_types::extract::AngularOutputMember>,
275    /// Angular `@Component` declarations with their `selector` value(s).
276    /// Round-trips so the Angular `unrendered-component` arm sees them on
277    /// warm-cache loads.
278    pub angular_component_selectors: Vec<fallow_types::extract::AngularComponentSelector>,
279    /// Lit / web-component custom elements registered in this file. Round-trips so
280    /// the Lit `unrendered-component` arm sees them on warm-cache loads.
281    pub registered_custom_elements: Vec<fallow_types::extract::RegisteredCustomElement>,
282    /// Custom-element tag names used (rendered) in this file's `html` templates.
283    /// Round-trips for the Lit `unrendered-component` rendered-tag union.
284    pub used_custom_element_tags: Vec<String>,
285    /// Custom element selector tags referenced in this file's Angular templates.
286    /// Round-trips for the Angular `unrendered-component` used-selector union.
287    pub angular_used_selectors: Vec<String>,
288    /// Angular route / bootstrap component class references. Round-trips for the
289    /// Angular `unrendered-component` entry-point abstain.
290    pub angular_entry_component_refs: Vec<String>,
291    /// Whether this file dynamically renders a component (project-wide abstain
292    /// signal for the Angular `unrendered-component` detector). Round-trips.
293    pub has_dynamic_component_render: bool,
294    /// Whether `defineEmits` had an unharvestable argument. Round-trips for the
295    /// abstain.
296    pub has_unharvestable_emits: bool,
297    /// Whether an `emit(<nonLiteral>)` call was seen. Round-trips for the abstain.
298    pub has_dynamic_emit: bool,
299    /// Whether the emit binding was used as a whole value. Round-trips for the
300    /// abstain.
301    pub has_emit_whole_object_use: bool,
302    /// SvelteKit `load()` return-object keys. Round-trips so the
303    /// `unused-load-data-key` detector sees them on warm-cache loads.
304    pub load_return_keys: Vec<fallow_types::extract::LoadReturnKey>,
305    /// Whether this file's `load()` body could not be harvested safely.
306    /// Round-trips for the abstain.
307    pub has_unharvestable_load: bool,
308    /// Whether this file passes the whole `data` object opaquely. Round-trips
309    /// for the `unused-load-data-key` abstain.
310    pub has_load_data_whole_use: bool,
311    /// React/JSX component definitions. Round-trips so the React-health phases
312    /// see them on warm-cache loads.
313    pub component_functions: Vec<fallow_types::extract::ComponentFunction>,
314    /// React component props. Round-trips so the React `unused-component-prop`
315    /// arm sees them on warm-cache loads.
316    pub react_props: Vec<fallow_types::extract::ComponentProp>,
317    /// React hook call sites. Round-trips for the complexity-fold phase.
318    pub hook_uses: Vec<fallow_types::extract::HookUse>,
319    /// React render edges (child name captured; resolution deferred to graph
320    /// build). Round-trips so the render graph survives a warm cache.
321    pub render_edges: Vec<fallow_types::extract::RenderEdge>,
322    /// Svelte custom events dispatched via `dispatch('<name>')`. Round-trips so
323    /// the `unused-svelte-event` detector sees them on warm-cache loads.
324    pub svelte_dispatched_events: Vec<fallow_types::extract::DispatchedEvent>,
325    /// Svelte template `on:<name>` listener names on component tags. Round-trips
326    /// so the project-wide listened set is correct on warm-cache loads.
327    pub svelte_listened_events: Vec<String>,
328    /// Whether a `dispatch(<nonLiteral>)` call or whole-`dispatch`-value use was
329    /// seen. Round-trips for the `unused-svelte-event` abstain.
330    pub has_dynamic_dispatch: bool,
331}
332
333impl CachedModule {
334    /// Source metadata fingerprint stored with this cache entry.
335    ///
336    #[must_use]
337    pub fn source_fingerprint(&self) -> fallow_types::source_fingerprint::SourceFingerprint {
338        fallow_types::source_fingerprint::SourceFingerprint::with_ctime(
339            self.mtime_ns,
340            self.ctime_ns,
341            self.file_size,
342        )
343    }
344}
345
346/// Cached namespace-object alias.
347#[derive(Debug, Clone, Encode, Decode)]
348pub struct CachedNamespaceObjectAlias {
349    /// Canonical export name on this module.
350    pub via_export_name: String,
351    /// Dotted suffix of the property path relative to the export.
352    pub suffix: String,
353    /// Local name of the namespace import on this module.
354    pub namespace_local: String,
355}
356
357/// Cached local type declaration.
358#[derive(Debug, Clone, Encode, Decode)]
359pub struct CachedLocalTypeDeclaration {
360    /// Local declaration name.
361    pub name: String,
362    /// Byte offset of the declaration span start.
363    pub span_start: u32,
364    /// Byte offset of the declaration span end.
365    pub span_end: u32,
366}
367
368/// Cached public signature type reference.
369#[derive(Debug, Clone, Encode, Decode)]
370pub struct CachedPublicSignatureTypeReference {
371    /// Exported symbol whose signature contains the reference.
372    pub export_name: String,
373    /// Referenced type name.
374    pub type_name: String,
375    /// Byte offset of the reference span start.
376    pub span_start: u32,
377    /// Byte offset of the reference span end.
378    pub span_end: u32,
379}
380
381/// Cached suppression directive.
382#[derive(Debug, Clone, Encode, Decode)]
383pub struct CachedSuppression {
384    /// 1-based line this suppression applies to. 0 = file-wide.
385    pub(crate) line: u32,
386    /// 1-based line where the comment itself appears.
387    pub(crate) comment_line: u32,
388    /// 0 = suppress all, otherwise `IssueKind` discriminant.
389    pub(crate) kind: u8,
390    /// Rule-pack name for scoped policy suppressions. Empty for all other
391    /// suppression targets.
392    pub(crate) policy_pack: String,
393    /// Rule id for scoped policy suppressions. Empty for all other suppression
394    /// targets.
395    pub(crate) policy_rule_id: String,
396    /// Human-authored reason after `--`, when present.
397    pub(crate) reason: Option<String>,
398}
399
400/// Cached unknown suppression kind token (see #449).
401#[derive(Debug, Clone, Encode, Decode)]
402pub struct CachedUnknownSuppressionKind {
403    /// 1-based line where the comment itself appears.
404    pub comment_line: u32,
405    /// True when the marker was `fallow-ignore-file`.
406    pub is_file_level: bool,
407    /// The verbatim token that did not parse.
408    pub token: String,
409    /// Human-authored reason after `--`, when present.
410    pub reason: Option<String>,
411}
412
413/// Cached export data for a single export declaration.
414#[derive(Debug, Clone, Encode, Decode)]
415pub struct CachedExport {
416    /// Export name (or "default" for default exports).
417    pub(crate) name: String,
418    /// Whether this is a default export.
419    pub(crate) is_default: bool,
420    /// Whether this is a type-only export.
421    pub(crate) is_type_only: bool,
422    /// Whether this export is registered through a runtime side effect at
423    /// module load time (Lit `@customElement` decorator or
424    /// `customElements.define` call). Persisted so warm-cache runs continue
425    /// to skip unused-export reporting for these classes.
426    pub(crate) is_side_effect_used: bool,
427    /// Visibility tag discriminant (0=None, 1=Public, 2=Internal, 3=Beta, 4=Alpha).
428    pub(crate) visibility: u8,
429    /// Human-authored reason on `@expected-unused -- <reason>`, when present.
430    pub(crate) expected_unused_reason: Option<String>,
431    /// Whether the leading JSDoc carries a `@deprecated` tag.
432    pub(crate) deprecated: bool,
433    /// Plain-text `@deprecated` message, `None` for a bare tag.
434    pub(crate) deprecated_reason: Option<Box<str>>,
435    /// The local binding name, if different.
436    pub(crate) local_name: Option<String>,
437    /// Byte offset of the export span start.
438    pub(crate) span_start: u32,
439    /// Byte offset of the export span end.
440    pub(crate) span_end: u32,
441    /// Members of this export (for enums and classes).
442    pub(crate) members: Vec<CachedMember>,
443    /// The local name of the parent class from `extends` clause, if any.
444    pub(crate) super_class: Option<String>,
445}
446
447/// Cached import data for a single import declaration.
448#[derive(Debug, Clone, Encode, Decode)]
449pub struct CachedImport {
450    /// The import specifier.
451    pub(crate) source: String,
452    /// For Named imports, the imported symbol name. Empty for other kinds.
453    pub(crate) imported_name: String,
454    /// The local binding name.
455    pub(crate) local_name: String,
456    /// Whether this is a type-only import.
457    pub(crate) is_type_only: bool,
458    /// Whether this whole-module import forwards type meanings only
459    /// (`export type *` inside a `declare module '...'` body).
460    pub(crate) is_type_only_star: bool,
461    /// Whether this import originated from an SFC `<style>` block / `<style src>` (CSS context).
462    pub(crate) from_style: bool,
463    /// Import kind: 0=Named, 1=Default, 2=Namespace, 3=SideEffect.
464    pub(crate) kind: u8,
465    /// Byte offset of the import span start.
466    pub(crate) span_start: u32,
467    /// Byte offset of the import span end.
468    pub(crate) span_end: u32,
469    /// Byte offset of the source string literal span start.
470    pub(crate) source_span_start: u32,
471    /// Byte offset of the source string literal span end.
472    pub(crate) source_span_end: u32,
473}
474
475/// Cached dynamic import data.
476#[derive(Debug, Clone, Encode, Decode)]
477pub struct CachedDynamicImport {
478    /// The import specifier.
479    pub(crate) source: String,
480    /// Byte offset of the span start.
481    pub(crate) span_start: u32,
482    /// Byte offset of the span end.
483    pub(crate) span_end: u32,
484    /// Names destructured from the import result.
485    pub(crate) destructured_names: Vec<String>,
486    /// Local variable name for namespace imports.
487    pub(crate) local_name: Option<String>,
488    /// True when this dynamic import was synthesised by fallow (see
489    /// `DynamicImportInfo::is_speculative`).
490    pub(crate) is_speculative: bool,
491}
492
493/// Cached `require()` call data.
494#[derive(Debug, Clone, Encode, Decode)]
495pub struct CachedRequireCall {
496    /// The require specifier.
497    pub(crate) source: String,
498    /// Byte offset of the span start.
499    pub(crate) span_start: u32,
500    /// Byte offset of the span end.
501    pub(crate) span_end: u32,
502    /// Byte offset of the specifier string-literal span start.
503    pub(crate) source_span_start: u32,
504    /// Byte offset of the specifier string-literal span end.
505    pub(crate) source_span_end: u32,
506    /// Names destructured from the require result.
507    pub(crate) destructured_names: Vec<String>,
508    /// Local variable name for namespace requires.
509    pub(crate) local_name: Option<String>,
510    /// `true` for the type-erased `import type X = require('...')` spelling.
511    pub(crate) is_type_only: bool,
512}
513
514/// Cached re-export data.
515#[derive(Debug, Clone, Encode, Decode)]
516pub struct CachedReExport {
517    /// The module being re-exported from.
518    pub(crate) source: String,
519    /// Name imported from the source.
520    pub(crate) imported_name: String,
521    /// Name exported from this module.
522    pub(crate) exported_name: String,
523    /// Whether this is a type-only re-export.
524    pub(crate) is_type_only: bool,
525    /// Byte offset of the re-export span start (for line-number reporting).
526    pub(crate) span_start: u32,
527    /// Byte offset of the re-export span end.
528    pub(crate) span_end: u32,
529    /// Byte offset of the enclosing statement span start.
530    pub(crate) statement_span_start: u32,
531    /// Byte offset of the enclosing statement span end.
532    pub(crate) statement_span_end: u32,
533    /// Byte offset of the source string-literal span start.
534    pub(crate) source_span_start: u32,
535    /// Byte offset of the source string-literal span end.
536    pub(crate) source_span_end: u32,
537}
538
539/// Cached enum or class member data.
540#[derive(Debug, Clone, Encode, Decode)]
541pub struct CachedMember {
542    /// Member name.
543    pub(crate) name: String,
544    /// Member kind (enum, method, or property).
545    pub(crate) kind: MemberKind,
546    /// Byte offset of the span start.
547    pub(crate) span_start: u32,
548    /// Byte offset of the span end.
549    pub(crate) span_end: u32,
550    /// Whether this member has decorators.
551    pub(crate) has_decorator: bool,
552    /// Full dotted path of each decorator (e.g. `step`, `ns.foo`).
553    /// Empty for undecorated members and decorators with non-identifier
554    /// expressions.
555    pub(crate) decorator_names: Vec<String>,
556    /// True when this is a static method that returns a fresh instance of
557    /// the class: body returns `new this()` / `new <SameClassName>()`, or the
558    /// declared return type matches the class name. Treated as a factory.
559    /// See issues #346, #387.
560    pub(crate) is_instance_returning_static: bool,
561    /// True when this instance method's call result is an instance of the
562    /// same class (declared return type matches the class name, or body's
563    /// last statement is `return this`). Drives fluent-chain credit. See
564    /// issue #387.
565    pub(crate) is_self_returning: bool,
566}
567
568/// Cached dynamic import pattern data (template literals, `import.meta.glob`).
569#[derive(Debug, Clone, Encode, Decode)]
570pub struct CachedDynamicImportPattern {
571    /// Static prefix of the import path.
572    pub(crate) prefix: String,
573    /// Static suffix, if any.
574    pub(crate) suffix: Option<String>,
575    /// Byte offset of the span start.
576    pub(crate) span_start: u32,
577    /// Byte offset of the span end.
578    pub(crate) span_end: u32,
579    /// Runtime mechanism used to load modules matching this pattern.
580    pub(crate) mechanism: crate::ModuleLoadMechanism,
581}