#![warn(clippy::pedantic)]
use std::{borrow::Cow, collections::HashMap};
use serde::{Deserialize, Serialize};
pub mod parsing;
#[doc(hidden)]
#[path = "tests.rs"]
pub mod __tests;
pub type ViteManifest<'a> = HashMap<Cow<'a, str>, ManifestChunk<'a>>;
pub type DynManifest<'a> = Box<dyn Manifest<'a> + Send + Sync>;
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, Hash)]
#[serde(rename_all = "camelCase")]
pub struct ManifestChunk<'a> {
#[serde(skip)]
pub key: Cow<'a, str>,
#[serde(skip)]
pub contents: Cow<'a, [u8]>,
#[serde(skip)]
pub hash: Cow<'a, str>,
#[serde(skip)]
pub mime_type: Cow<'a, str>,
pub src: Option<Cow<'a, str>>,
pub file: Cow<'a, str>,
#[serde(default)]
pub css: Cow<'a, [Cow<'a, str>]>,
#[serde(default)]
pub assets: Cow<'a, [Cow<'a, str>]>,
#[serde(default)]
pub is_entry: bool,
pub name: Option<Cow<'a, str>>,
#[serde(default)]
pub is_dynamic_entry: bool,
#[serde(default)]
pub imports: Cow<'a, [Cow<'a, str>]>,
#[serde(default)]
pub dynamic_imports: Cow<'a, [Cow<'a, str>]>,
}
pub trait Manifest<'a> {
fn boxed(&self) -> DynManifest<'a>;
fn base(&self) -> Cow<'a, str>;
fn resolve_output(&self, key: &str) -> Option<Cow<'a, str>>;
fn iter_keys(&self) -> Box<dyn Iterator<Item = &str> + '_>;
fn iter_outputs(&self) -> Box<dyn Iterator<Item = &str> + '_>;
fn chunk(&self, output: &str) -> Option<Cow<'a, ManifestChunk<'a>>>;
fn chunk_by_key(&self, key: &str) -> Option<Cow<'a, ManifestChunk<'a>>> {
match self.resolve_output(key) {
Some(output) => self.chunk(&output),
None => None,
}
}
}