mirror of
https://github.com/typst/typst
synced 2025-05-17 02:25:27 +08:00
Switch to parallel comemo using Git dependency (#2973)
This commit is contained in:
parent
ab29c669e6
commit
41c0dae209
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -393,18 +393,18 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
[[package]]
|
||||
name = "comemo"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf5705468fa80602ee6a5f9318306e6c428bffd53e43209a78bc05e6e667c6f4"
|
||||
source = "git+https://github.com/typst/comemo?rev=ddb3773#ddb3773d062369e120d09c9a0a7909faf29d8fe1"
|
||||
dependencies = [
|
||||
"comemo-macros",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"siphasher 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "comemo-macros"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54af6ac68ada2d161fa9cc1ab52676228e340866d094d6542107e74b82acc095"
|
||||
source = "git+https://github.com/typst/comemo?rev=ddb3773#ddb3773d062369e120d09c9a0a7909faf29d8fe1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1566,6 +1566,16 @@ dependencies = [
|
||||
"syn 2.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.9"
|
||||
|
@ -36,7 +36,7 @@ clap = { version = "4.4", features = ["derive", "env"] }
|
||||
clap_complete = "4.2.1"
|
||||
clap_mangen = "0.2.10"
|
||||
codespan-reporting = "0.11"
|
||||
comemo = "0.3.1"
|
||||
comemo = { git = "https://github.com/typst/comemo", rev = "ddb3773" }
|
||||
csv = "1"
|
||||
dirs = "5"
|
||||
ecow = { version = "0.2", features = ["serde"] }
|
||||
|
@ -167,7 +167,7 @@ impl Plugin {
|
||||
impl Plugin {
|
||||
/// Create a new plugin from raw WebAssembly bytes.
|
||||
#[comemo::memoize]
|
||||
pub fn new(bytes: Bytes) -> StrResult<Self> {
|
||||
pub fn new(bytes: Bytes) -> StrResult<Plugin> {
|
||||
let engine = wasmi::Engine::default();
|
||||
let module = wasmi::Module::new(&engine, bytes.as_slice())
|
||||
.map_err(|err| format!("failed to load WebAssembly module ({err})"))?;
|
||||
|
@ -489,7 +489,7 @@ impl CslStyle {
|
||||
|
||||
/// Load a built-in CSL style.
|
||||
#[comemo::memoize]
|
||||
pub fn from_name(name: &str) -> StrResult<Self> {
|
||||
pub fn from_name(name: &str) -> StrResult<CslStyle> {
|
||||
match hayagriva::archive::ArchivedStyle::by_name(name).map(ArchivedStyle::get) {
|
||||
Some(citationberg::Style::Independent(style)) => Ok(Self {
|
||||
name: Some(name.into()),
|
||||
@ -501,7 +501,7 @@ impl CslStyle {
|
||||
|
||||
/// Load a CSL style from file contents.
|
||||
#[comemo::memoize]
|
||||
pub fn from_data(data: &Bytes) -> StrResult<Self> {
|
||||
pub fn from_data(data: &Bytes) -> StrResult<CslStyle> {
|
||||
let text = std::str::from_utf8(data.as_slice()).map_err(FileError::from)?;
|
||||
citationberg::IndependentStyle::from_xml(text)
|
||||
.map(|style| Self { name: None, style: Arc::new(Prehashed::new(style)) })
|
||||
@ -589,7 +589,7 @@ impl Works {
|
||||
pub fn generate(
|
||||
world: Tracked<dyn World + '_>,
|
||||
introspector: Tracked<Introspector>,
|
||||
) -> StrResult<Arc<Self>> {
|
||||
) -> StrResult<Arc<Works>> {
|
||||
let mut generator = Generator::new(world, introspector)?;
|
||||
let rendered = generator.drive();
|
||||
let works = generator.display(&rendered)?;
|
||||
|
@ -325,7 +325,7 @@ impl Image {
|
||||
data: Bytes,
|
||||
format: ImageFormat,
|
||||
alt: Option<EcoString>,
|
||||
) -> StrResult<Self> {
|
||||
) -> StrResult<Image> {
|
||||
let kind = match format {
|
||||
ImageFormat::Raster(format) => {
|
||||
ImageKind::Raster(RasterImage::new(data, format)?)
|
||||
@ -346,7 +346,7 @@ impl Image {
|
||||
alt: Option<EcoString>,
|
||||
world: Tracked<dyn World + '_>,
|
||||
families: &[String],
|
||||
) -> StrResult<Self> {
|
||||
) -> StrResult<Image> {
|
||||
let kind = match format {
|
||||
ImageFormat::Raster(format) => {
|
||||
ImageKind::Raster(RasterImage::new(data, format)?)
|
||||
|
@ -27,7 +27,7 @@ struct Repr {
|
||||
impl RasterImage {
|
||||
/// Decode a raster image.
|
||||
#[comemo::memoize]
|
||||
pub fn new(data: Bytes, format: RasterFormat) -> StrResult<Self> {
|
||||
pub fn new(data: Bytes, format: RasterFormat) -> StrResult<RasterImage> {
|
||||
fn decode_with<'a, T: ImageDecoder<'a>>(
|
||||
decoder: ImageResult<T>,
|
||||
) -> ImageResult<(image::DynamicImage, Option<Vec<u8>>)> {
|
||||
|
@ -28,7 +28,7 @@ struct Repr {
|
||||
impl SvgImage {
|
||||
/// Decode an SVG image without fonts.
|
||||
#[comemo::memoize]
|
||||
pub fn new(data: Bytes) -> StrResult<Self> {
|
||||
pub fn new(data: Bytes) -> StrResult<SvgImage> {
|
||||
let opts = usvg::Options::default();
|
||||
let tree = usvg::Tree::from_data(&data, &opts).map_err(format_usvg_error)?;
|
||||
Ok(Self(Arc::new(Repr {
|
||||
@ -46,7 +46,7 @@ impl SvgImage {
|
||||
data: Bytes,
|
||||
world: Tracked<dyn World + '_>,
|
||||
families: &[String],
|
||||
) -> StrResult<Self> {
|
||||
) -> StrResult<SvgImage> {
|
||||
// Disable usvg's default to "Times New Roman". Instead, we default to
|
||||
// the empty family and later, when we traverse the SVG, we check for
|
||||
// empty and non-existing family names and replace them with the true
|
||||
|
Loading…
x
Reference in New Issue
Block a user