rust_jsr_registry/types/
graph.rs

1/// Module graph 1
2/// 
3/// JSR docs dosent explain this. Moreover, this only included on old & early JSR packages
4#[cfg(feature = "unstable")]
5pub mod one {}
6
7/// Objects for moduleGraph2
8pub mod two {
9    use serde::{Deserialize, Serialize};
10
11    use crate::{priv_as_ref, priv_enum_derived};
12
13    /// Module graph 2
14    #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
15    pub struct ModuleGraph2 {
16        /// Dependencies that are used in the file
17        pub dependencies: Option<Vec<Dependency>>,
18    }
19    priv_as_ref!(ModuleGraph2);
20    
21    priv_enum_derived!(DependencyType, Static, Dynamic);
22    priv_enum_derived!(DependencyKind, Import, Export);
23
24    #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
25    #[serde(rename_all = "camelCase")]
26    /// Dependencies from [ModuleGraph2]
27    pub struct Dependency {
28        /// Dependency type ("importing from `import` keyword (static) or `import()` function (dynamic)?")
29        pub r#type: DependencyType,
30        /// Dependency kind ("Is it imported/exported?")
31        pub kind: DependencyKind,
32        /// Dependency specifier (module path)
33        pub specifier: String,
34        /// Specifier range
35        /// 
36        /// The line count was pretty tricky though, so we does'nt recommend using it
37        ///  
38        /// But since JSR does'nt document it, 
39        /// we assumed that the number is for the opening & closing path of [Dependency::specifier].
40        pub specifier_range: ((u32, u32), (u32, u32))
41    }
42    impl PartialOrd for Dependency {
43        fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
44            self.specifier_range.partial_cmp(&other.specifier_range)
45        }
46    }
47    impl Ord for Dependency {
48        fn cmp(&self, other: &Self) -> std::cmp::Ordering {
49            self.specifier_range.cmp(&other.specifier_range)
50        }
51    }
52    priv_as_ref!(Dependency);
53}