use bitcode::{Decode, Encode};
use crate::MemberKind;
pub(super) const CACHE_VERSION: u32 = 40;
pub(super) const MAX_CACHE_SIZE: usize = 256 * 1024 * 1024;
pub(super) const IMPORT_KIND_NAMED: u8 = 0;
pub(super) const IMPORT_KIND_DEFAULT: u8 = 1;
pub(super) const IMPORT_KIND_NAMESPACE: u8 = 2;
pub(super) const IMPORT_KIND_SIDE_EFFECT: u8 = 3;
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedModule {
pub content_hash: u64,
pub mtime_secs: u64,
pub file_size: u64,
pub exports: Vec<CachedExport>,
pub imports: Vec<CachedImport>,
pub re_exports: Vec<CachedReExport>,
pub dynamic_imports: Vec<CachedDynamicImport>,
pub require_calls: Vec<CachedRequireCall>,
pub member_accesses: Vec<crate::MemberAccess>,
pub whole_object_uses: Vec<String>,
pub dynamic_import_patterns: Vec<CachedDynamicImportPattern>,
pub has_cjs_exports: bool,
pub unused_import_bindings: Vec<String>,
pub suppressions: Vec<CachedSuppression>,
pub line_offsets: Vec<u32>,
pub complexity: Vec<fallow_types::extract::FunctionComplexity>,
pub flag_uses: Vec<fallow_types::extract::FlagUse>,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedSuppression {
pub line: u32,
pub comment_line: u32,
pub kind: u8,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedExport {
pub name: String,
pub is_default: bool,
pub is_type_only: bool,
pub visibility: u8,
pub local_name: Option<String>,
pub span_start: u32,
pub span_end: u32,
pub members: Vec<CachedMember>,
pub super_class: Option<String>,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedImport {
pub source: String,
pub imported_name: String,
pub local_name: String,
pub is_type_only: bool,
pub kind: u8,
pub span_start: u32,
pub span_end: u32,
pub source_span_start: u32,
pub source_span_end: u32,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedDynamicImport {
pub source: String,
pub span_start: u32,
pub span_end: u32,
pub destructured_names: Vec<String>,
pub local_name: Option<String>,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedRequireCall {
pub source: String,
pub span_start: u32,
pub span_end: u32,
pub destructured_names: Vec<String>,
pub local_name: Option<String>,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedReExport {
pub source: String,
pub imported_name: String,
pub exported_name: String,
pub is_type_only: bool,
pub span_start: u32,
pub span_end: u32,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedMember {
pub name: String,
pub kind: MemberKind,
pub span_start: u32,
pub span_end: u32,
pub has_decorator: bool,
}
#[derive(Debug, Clone, Encode, Decode)]
pub struct CachedDynamicImportPattern {
pub prefix: String,
pub suffix: Option<String>,
pub span_start: u32,
pub span_end: u32,
}