1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub enum ImportKind {
6 #[serde(rename = "require-call")]
7 RequireCall,
8
9 #[serde(rename = "import-statement")]
10 ImportStatement,
11
12 #[serde(rename = "dynamic-import")]
13 DynamicImport,
14
15 #[serde(rename = "import-rule")]
16 ImportRule,
17
18 #[serde(rename = "url-token")]
19 UrlToken,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct Import {
24 pub path: String,
25 #[serde(default, skip_serializing_if = "Option::is_none")]
26 pub kind: Option<ImportKind>,
27 #[serde(default, skip_serializing_if = "std::ops::Not::not")]
28 pub external: bool,
29 #[serde(default, skip_serializing_if = "Option::is_none")]
30 pub original: Option<String>,
31 #[serde(default, skip_serializing_if = "Option::is_none")]
32 pub with: Option<HashMap<String, String>>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct Input {
37 pub bytes: u64,
38 pub imports: Vec<Import>,
39 #[serde(default, skip_serializing_if = "Option::is_none")]
40 pub format: Option<String>,
41 #[serde(default, skip_serializing_if = "Option::is_none")]
42 pub with: Option<HashMap<String, String>>,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct InputDetail {
47 #[serde(rename = "bytesInOutput")]
48 pub bytes_in_output: u64,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct OutputImport {
53 pub path: String,
54 pub kind: String,
55 #[serde(default, skip_serializing_if = "Option::is_none")]
56 pub external: Option<bool>,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct Output {
61 pub bytes: u64,
62 pub inputs: HashMap<String, InputDetail>,
63 pub imports: Vec<OutputImport>,
64 pub exports: Vec<String>,
65 #[serde(
66 default,
67 skip_serializing_if = "Option::is_none",
68 rename = "entryPoint"
69 )]
70 pub entry_point: Option<String>,
71 #[serde(default, skip_serializing_if = "Option::is_none", rename = "cssBundle")]
72 pub css_bundle: Option<String>,
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct Metafile {
77 pub inputs: HashMap<String, Input>,
78 pub outputs: HashMap<String, Output>,
79}