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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/// This is an implementation for `Write + !AsRef<AnyBytes>`.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct AsWritable;

/// This is an implementation for `Vec<u8>`.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct AsOwnedBytes;

/// This is an implementation for `String`.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct AsOwnedString;

/// Re-export of the typst crate.
pub mod typst {
    pub(crate) mod well_known {
        pub type Bytes = typst::foundations::Bytes;

        /// Although this is not good to expose this, we make an alias here to
        /// let it as a part of typst-ts.
        pub use typst::syntax::FileId as TypstFileId;

        pub use typst::World as TypstWorld;

        pub use typst::layout::Abs as TypstAbs;

        pub use typst::model::Document as TypstDocument;

        pub use typst::text::Font as TypstFont;

        pub use typst::foundations::Dict as TypstDict;

        pub use typst::foundations::Datetime as TypstDatetime;

        pub use typst::{diag, foundations, syntax};

        pub trait FromTypst<T>: Sized {
            fn from_typst(value: T) -> Self;
        }

        pub trait IntoTypst<T>: Sized {
            fn into_typst(self) -> T;
        }

        impl<T, U> IntoTypst<U> for T
        where
            U: FromTypst<T>,
        {
            fn into_typst(self) -> U {
                U::from_typst(self)
            }
        }

        pub trait TryFromTypst<T>: Sized {
            type Error;

            fn try_from_typst(value: T) -> Result<Self, Self::Error>;
        }

        pub trait TryIntoTypst<T>: Sized {
            type Error;

            fn try_into_typst(self) -> Result<T, Self::Error>;
        }

        impl<T, U> TryIntoTypst<U> for T
        where
            U: TryFromTypst<T>,
        {
            type Error = U::Error;

            fn try_into_typst(self) -> Result<U, Self::Error> {
                U::try_from_typst(self)
            }
        }
    }

    pub use well_known::*;

    pub mod prelude {
        pub use comemo::Prehashed;
        pub use ecow::{eco_format, eco_vec, EcoString, EcoVec};
    }
}
pub use typst::well_known::*;