Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
build: upgrade typst.ts (#91)
Browse files Browse the repository at this point in the history
* build: upgrade typst.ts

* dev: remove the unused variable

* fix: clippy type complexity
  • Loading branch information
Myriad-Dreamin authored Aug 20, 2023
1 parent be51955 commit d79ac96
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ hyper = { version = "0.14", features = ["full"] }
[patch.crates-io]
typst = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "706d64f9ab77073a31e39653b1ed5bbbbaf204ea" }
typst-library = { git = "https://github.com/Myriad-Dreamin/typst.git", rev = "706d64f9ab77073a31e39653b1ed5bbbbaf204ea" }
typst-ts-svg-exporter = { git = "https://github.com/Myriad-Dreamin/typst.ts", rev = "4d3f9e68651589694f2e0f07d86a483b3001e90e", package = "typst-ts-svg-exporter" }
typst-ts-core = { git = "https://github.com/Myriad-Dreamin/typst.ts", rev = "4d3f9e68651589694f2e0f07d86a483b3001e90e", package = "typst-ts-core" }
typst-ts-compiler = { git = "https://github.com/Myriad-Dreamin/typst.ts", rev = "4d3f9e68651589694f2e0f07d86a483b3001e90e", package = "typst-ts-compiler" }
typst-ts-svg-exporter = { git = "https://github.com/Myriad-Dreamin/typst.ts", rev = "dadcfdd0185246e96a532c6fb78faf553aa82fe5", package = "typst-ts-svg-exporter" }
typst-ts-core = { git = "https://github.com/Myriad-Dreamin/typst.ts", rev = "dadcfdd0185246e96a532c6fb78faf553aa82fe5", package = "typst-ts-core" }
typst-ts-compiler = { git = "https://github.com/Myriad-Dreamin/typst.ts", rev = "dadcfdd0185246e96a532c6fb78faf553aa82fe5", package = "typst-ts-compiler" }

# typst = { path = "../../rust/typst/crates/typst" }
# typst-library = { path = "../../rust/typst/crates/typst-library" }
Expand Down
4 changes: 2 additions & 2 deletions addons/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"link:local": "yarn link @myriaddreamin/typst.ts @myriaddreamin/typst-ts-renderer"
},
"dependencies": {
"@myriaddreamin/typst.ts": "0.3.2-rc1",
"@myriaddreamin/typst-ts-renderer": "0.3.2-rc1"
"@myriaddreamin/typst.ts": "0.3.2-rc2",
"@myriaddreamin/typst-ts-renderer": "0.3.2-rc2"
},
"devDependencies": {
"typescript": "^5.0.2",
Expand Down
43 changes: 18 additions & 25 deletions src/actor/typst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use tokio::sync::{broadcast, mpsc, watch};
use typst::syntax::FileId;
use typst::{doc::Document, World};
use typst_ts_compiler::service::CompileDriver;
use typst_ts_compiler::{
service::{CompileDriver, Compiler, DiagObserver},
ShadowApi,
};

use super::render::RenderActorRequest;
use super::{
Expand Down Expand Up @@ -39,27 +42,16 @@ pub struct TypstActor {
src_to_doc_jump_sender: broadcast::Sender<WebviewActorRequest>,
}

type MpScChannel<T> = (mpsc::UnboundedSender<T>, mpsc::UnboundedReceiver<T>);
type WatchChannel<T> = (watch::Sender<T>, watch::Receiver<T>);
type BroadcastChannel<T> = (broadcast::Sender<T>, broadcast::Receiver<T>);

pub struct Channels {
pub typst_mailbox: (
mpsc::UnboundedSender<TypstActorRequest>,
mpsc::UnboundedReceiver<TypstActorRequest>,
),
pub doc_watch: (
watch::Sender<Option<Arc<Document>>>,
watch::Receiver<Option<Arc<Document>>>,
),
pub renderer_mailbox: (
broadcast::Sender<RenderActorRequest>,
broadcast::Receiver<RenderActorRequest>,
),
pub doc_to_src_jump: (
mpsc::UnboundedSender<EditorActorRequest>,
mpsc::UnboundedReceiver<EditorActorRequest>,
),
pub src_to_doc_jump: (
broadcast::Sender<WebviewActorRequest>,
broadcast::Receiver<WebviewActorRequest>,
),
pub typst_mailbox: MpScChannel<TypstActorRequest>,
pub doc_watch: WatchChannel<Option<Arc<Document>>>,
pub renderer_mailbox: BroadcastChannel<RenderActorRequest>,
pub doc_to_src_jump: MpScChannel<EditorActorRequest>,
pub src_to_doc_jump: BroadcastChannel<WebviewActorRequest>,
}

impl TypstActor {
Expand Down Expand Up @@ -182,7 +174,7 @@ impl TypstActor {
self.compiler_driver.world.reset();
if let Some(doc) = self
.compiler_driver
.with_compile_diag::<true, _>(CompileDriver::compile)
.with_compile_diag::<true, _>(Compiler::compile)
{
let _ = self.doc_sender.send(Some(Arc::new(doc))); // it is ok to ignore the error here
let _ = self
Expand All @@ -209,8 +201,8 @@ impl TypstActor {
}
for (path, content) in files.files.iter() {
let path = Path::new(path).to_owned();
let id = self.compiler_driver.id_for_path(path.clone());
let Ok(_) = self.compiler_driver.world.resolve_with(&path, id, content) else {
// todo: is it safe to believe that the path is normalized?
let Ok(_) = self.compiler_driver.world.map_shadow(&path, content) else {
error!("TypstActor: failed to resolve file: {}", path.display());
return;
};
Expand All @@ -220,7 +212,8 @@ impl TypstActor {
fn remove_shadow_files(&mut self, files: &MemoryFilesShort) {
for path in files.files.iter() {
let path = Path::new(path);
self.compiler_driver.world.remove_shadow(path);
// todo: ignoring the error here
let _ = self.compiler_driver.world.unmap_shadow(path);
}
}

Expand Down

0 comments on commit d79ac96

Please sign in to comment.