File size: 1,727 Bytes
1e92f2d |
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 |
use serde::{Deserialize, Serialize};
use turbo_tasks::{NonLocalValue, ResolvedVc, Vc, trace::TraceRawVcs};
use crate::{asset::Asset, ident::AssetIdent, reference::ModuleReferences};
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, TraceRawVcs, NonLocalValue)]
pub enum StyleType {
IsolatedStyle,
GlobalStyle,
}
#[turbo_tasks::value(transparent)]
pub struct OptionStyleType(Option<StyleType>);
/// A module. This usually represents parsed source code, which has references
/// to other modules.
#[turbo_tasks::value_trait]
pub trait Module: Asset {
/// The identifier of the [Module]. It's expected to be unique and capture
/// all properties of the [Module].
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent>;
/// Other [Module]s or [OutputAsset]s referenced from this [Module].
// TODO refactor to avoid returning [OutputAsset]s here
#[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<ModuleReferences> {
ModuleReferences::empty()
}
/// Signifies the module itself is async, e.g. it uses top-level await, is a wasm module, etc.
#[turbo_tasks::function]
fn is_self_async(self: Vc<Self>) -> Vc<bool> {
Vc::cell(false)
}
/// The style type of the module.
#[turbo_tasks::function]
fn style_type(self: Vc<Self>) -> Vc<OptionStyleType> {
Vc::cell(None)
}
}
#[turbo_tasks::value(transparent)]
pub struct OptionModule(Option<ResolvedVc<Box<dyn Module>>>);
#[turbo_tasks::value(transparent)]
pub struct Modules(Vec<ResolvedVc<Box<dyn Module>>>);
#[turbo_tasks::value_impl]
impl Modules {
#[turbo_tasks::function]
pub fn empty() -> Vc<Self> {
Vc::cell(Vec::new())
}
}
|