use rspack_cacheable::{cacheable, cacheable_dyn};
use rspack_core::{
AsContextDependency, AsModuleDependency, Compilation, Dependency, DependencyCategory,
DependencyCodeGeneration, DependencyId, DependencyRange, DependencyType, RuntimeSpec,
};
use rspack_hash::{RspackHash, RspackHasher, rspack_hash_object};
#[cacheable]
#[derive(Debug, Clone, Copy, PartialEq, Eq, RspackHash)]
pub enum CssIcssSymbolKind {
LocalDeclaration,
LocalReference,
IcssReference,
LocalGridStart,
LocalGridEnd,
}
#[cacheable]
#[derive(Debug)]
pub struct CssIcssSymbolDependency {
id: DependencyId,
pub target: DependencyId,
range: DependencyRange,
pub kind: CssIcssSymbolKind,
}
impl CssIcssSymbolDependency {
pub fn new(target: DependencyId, range: DependencyRange, kind: CssIcssSymbolKind) -> Self {
Self {
id: DependencyId::new(),
target,
range,
kind,
}
}
}
#[cacheable_dyn]
impl Dependency for CssIcssSymbolDependency {
fn id(&self) -> &DependencyId {
&self.id
}
fn category(&self) -> &DependencyCategory {
&DependencyCategory::CssExport
}
fn dependency_type(&self) -> &DependencyType {
&DependencyType::CssIcssSymbol
}
fn range(&self) -> Option<DependencyRange> {
Some(self.range)
}
fn could_affect_referencing_module(&self) -> rspack_core::AffectType {
rspack_core::AffectType::True
}
}
#[cacheable_dyn]
impl DependencyCodeGeneration for CssIcssSymbolDependency {
fn update_hash(
&self,
hasher: &mut RspackHasher,
_compilation: &Compilation,
_runtime: Option<&RuntimeSpec>,
) {
rspack_hash_object!(hasher, {
"range" => &self.range,
"kind" => &self.kind,
});
}
}
impl AsContextDependency for CssIcssSymbolDependency {}
impl AsModuleDependency for CssIcssSymbolDependency {}