From 25a446cd995ce06a2e5f5b07fe88e4cf0195867a Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Date: Mon, 9 Jun 2025 09:40:05 +0800 Subject: [PATCH] dev: fix meta and rename preview crates for publish crates (#1804) * dev: fix meta and rename preview crates for publish crates * dev: fix meta for publish crates --- .github/workflows/release-crates.yml | 2 +- Cargo.lock | 54 ++++++++++----------- Cargo.toml | 12 ++--- crates/tinymist-l10n/Cargo.toml | 3 +- crates/tinymist-package/Cargo.toml | 3 +- crates/tinymist/Cargo.toml | 8 +-- crates/tinymist/src/actor/preview.rs | 2 +- crates/tinymist/src/cmd.rs | 2 +- crates/tinymist/src/main.rs | 2 +- crates/tinymist/src/project.rs | 12 +++-- crates/tinymist/src/server.rs | 4 +- crates/tinymist/src/tool/preview.rs | 14 +++--- crates/tinymist/src/tool/preview/compile.rs | 8 +-- crates/tinymist/src/tool/project.rs | 2 +- crates/typst-preview/Cargo.toml | 2 +- crates/typst-preview/README.md | 30 ++++++++++++ 16 files changed, 98 insertions(+), 62 deletions(-) create mode 100644 crates/typst-preview/README.md diff --git a/.github/workflows/release-crates.yml b/.github/workflows/release-crates.yml index c61f106b..986b0eb7 100644 --- a/.github/workflows/release-crates.yml +++ b/.github/workflows/release-crates.yml @@ -52,7 +52,7 @@ jobs: cargo publish --no-verify -p tinymist-query || true cargo publish --no-verify -p tinymist-render || true cargo publish --no-verify -p tinymist-core || true - cargo publish --no-verify -p typst-preview || true + cargo publish --no-verify -p tinymist-preview || true cargo publish --no-verify -p tinymist || true - name: Verifies crate health (Optional) run: | diff --git a/Cargo.lock b/Cargo.lock index 87c90f9f..39fb5e38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4085,6 +4085,7 @@ dependencies = [ "tinymist-core", "tinymist-debug", "tinymist-l10n", + "tinymist-preview", "tinymist-project", "tinymist-query", "tinymist-render", @@ -4099,7 +4100,6 @@ dependencies = [ "typst-ansi-hl", "typst-html", "typst-pdf", - "typst-preview", "typst-render", "typst-shim", "typst-svg", @@ -4221,7 +4221,7 @@ dependencies = [ [[package]] name = "tinymist-l10n" -version = "0.13.14-rc1" +version = "0.13.12" dependencies = [ "anyhow", "clap", @@ -4249,7 +4249,7 @@ dependencies = [ [[package]] name = "tinymist-package" -version = "0.13.14-rc1" +version = "0.13.12" dependencies = [ "base64", "comemo", @@ -4274,6 +4274,30 @@ dependencies = [ "web-sys", ] +[[package]] +name = "tinymist-preview" +version = "0.13.14-rc1" +dependencies = [ + "clap", + "comemo", + "env_logger", + "futures", + "indexmap 2.9.0", + "log", + "parking_lot", + "reflexo-typst", + "reflexo-vec2svg", + "serde", + "serde_json", + "tinymist-assets 0.13.12", + "tinymist-std", + "tokio", + "typst", + "typst-assets", + "typst-macros", + "typst-timing", +] + [[package]] name = "tinymist-project" version = "0.13.12" @@ -4995,30 +5019,6 @@ dependencies = [ "xmp-writer", ] -[[package]] -name = "typst-preview" -version = "0.13.14-rc1" -dependencies = [ - "clap", - "comemo", - "env_logger", - "futures", - "indexmap 2.9.0", - "log", - "parking_lot", - "reflexo-typst", - "reflexo-vec2svg", - "serde", - "serde_json", - "tinymist-assets 0.13.12", - "tinymist-std", - "tokio", - "typst", - "typst-assets", - "typst-macros", - "typst-timing", -] - [[package]] name = "typst-realize" version = "0.13.1" diff --git a/Cargo.toml b/Cargo.toml index 76edb339..2e3940c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,7 +98,7 @@ rpds = "1" # Data/Text Format and Processing biblatex = "0.10" cmark-writer = { version = "0.7.5", features = ["gfm"] } -docx-rs = { git = "https://github.com/Myriad-Dreamin/docx-rs", default-features = false, rev = "db49a729f68dbdb9e8e91857fbb1c3d414209871" } +docx-rs = { version = "0.4.18-rc19", git = "https://github.com/Myriad-Dreamin/docx-rs", default-features = false, rev = "db49a729f68dbdb9e8e91857fbb1c3d414209871" } hayagriva = "0.8" hex = "0.4.3" flate2 = "1" @@ -154,7 +154,7 @@ typst-pdf = "0.13.1" typst-syntax = "0.13.1" typst-eval = "0.13.1" typst-assets = "0.13.1" -typstfmt = { git = "https://github.com/Myriad-Dreamin/typstfmt", tag = "v0.13.1" } +typstfmt = { version = "0", git = "https://github.com/Myriad-Dreamin/typstfmt", tag = "v0.13.1" } typst-ansi-hl = "0.4.0" typstyle-core = { version = "=0.13.10", default-features = false } @@ -162,7 +162,6 @@ typstyle-core = { version = "=0.13.10", default-features = false } crossbeam-channel = "0.5.12" lsp-types = { version = "=0.95.0", features = ["proposed"] } dapts = "0.0.6" -sync-ls = { path = "./crates/sync-lsp" } # CLI clap = { version = "4.5", features = ["derive", "env", "unicode"] } @@ -189,6 +188,8 @@ insta = { version = "1.39", features = ["glob"] } tinymist-assets = { version = "=0.13.12" } tinymist-derive = { path = "./crates/tinymist-derive/", version = "0.13.12" } +tinymist-l10n = { path = "./crates/tinymist-l10n/", version = "0.13.12" } +tinymist-package = { path = "./crates/tinymist-package/", version = "0.13.12" } tinymist-std = { path = "./crates/tinymist-std/", version = "0.13.12", default-features = false } tinymist-vfs = { path = "./crates/tinymist-vfs/", version = "0.13.12", default-features = false } tinymist-world = { path = "./crates/tinymist-world/", version = "0.13.12", default-features = false } @@ -198,17 +199,16 @@ typst-shim = { path = "./crates/typst-shim", version = "0.13.12" } tinymist-tests = { path = "./crates/tinymist-tests/" } +sync-ls = { path = "./crates/sync-lsp", version = "0.13.14-rc1" } tinymist = { path = "./crates/tinymist/", version = "0.13.14-rc1" } tinymist-analysis = { path = "./crates/tinymist-analysis/", version = "0.13.14-rc1" } tinymist-core = { path = "./crates/tinymist-core/", version = "0.13.14-rc1", default-features = false } tinymist-debug = { path = "./crates/tinymist-debug/", version = "0.13.14-rc1" } -tinymist-l10n = { path = "./crates/tinymist-l10n/", version = "0.13.14-rc1" } tinymist-lint = { path = "./crates/tinymist-lint/", version = "0.13.14-rc1" } -tinymist-package = { path = "./crates/tinymist-package/", version = "0.13.14-rc1" } tinymist-query = { path = "./crates/tinymist-query/", version = "0.13.14-rc1" } tinymist-render = { path = "./crates/tinymist-render/", version = "0.13.14-rc1" } +tinymist-preview = { path = "./crates/typst-preview", version = "0.13.14-rc1" } typlite = { path = "./crates/typlite", version = "0.13.14-rc1" } -typst-preview = { path = "./crates/typst-preview", version = "0.13.14-rc1" } [profile.dev.package.insta] opt-level = 3 diff --git a/crates/tinymist-l10n/Cargo.toml b/crates/tinymist-l10n/Cargo.toml index 7ee65d07..205d8b6c 100644 --- a/crates/tinymist-l10n/Cargo.toml +++ b/crates/tinymist-l10n/Cargo.toml @@ -3,8 +3,9 @@ name = "tinymist-l10n" description = "Localization support for tinymist and typst." categories = ["compilers", "command-line-utilities"] keywords = ["language", "typst"] +# group: world +version = "0.13.12" authors.workspace = true -version.workspace = true license.workspace = true edition.workspace = true homepage.workspace = true diff --git a/crates/tinymist-package/Cargo.toml b/crates/tinymist-package/Cargo.toml index 0ec41ae7..85dd8ac0 100644 --- a/crates/tinymist-package/Cargo.toml +++ b/crates/tinymist-package/Cargo.toml @@ -3,8 +3,9 @@ name = "tinymist-package" description = "Tinymist package support for Typst." categories = ["compilers"] keywords = ["api", "language", "typst"] +# group: world +version = "0.13.12" authors.workspace = true -version.workspace = true license.workspace = true edition.workspace = true homepage.workspace = true diff --git a/crates/tinymist/Cargo.toml b/crates/tinymist/Cargo.toml index a80bf68e..40a1438e 100644 --- a/crates/tinymist/Cargo.toml +++ b/crates/tinymist/Cargo.toml @@ -73,7 +73,7 @@ typst-render.workspace = true typst-timing.workspace = true typst-html = { workspace = true, optional = true } typst-shim.workspace = true -typst-preview = { workspace = true, optional = true } +tinymist-preview = { workspace = true, optional = true } typst-ansi-hl.workspace = true tinymist-task.workspace = true tinymist-debug.workspace = true @@ -119,14 +119,14 @@ pdf = ["tinymist-task/pdf"] no-content-hint = [ "tinymist-task/no-content-hint", "tinymist-project/no-content-hint", - "typst-preview/no-content-hint", + "tinymist-preview/no-content-hint", "reflexo-typst/no-content-hint", "reflexo-vec2svg/no-content-hint", ] preview = [ - "typst-preview", - "typst-preview/clap", + "tinymist-preview", + "tinymist-preview/clap", "tinymist-assets/typst-preview", "hyper-tungstenite", ] diff --git a/crates/tinymist/src/actor/preview.rs b/crates/tinymist/src/actor/preview.rs index 19f4501b..2784eddd 100644 --- a/crates/tinymist/src/actor/preview.rs +++ b/crates/tinymist/src/actor/preview.rs @@ -4,9 +4,9 @@ use lsp_types::notification::Notification; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; use sync_ls::{internal_error, LspClient, LspResult}; +use tinymist_preview::{ControlPlaneMessage, Previewer}; use tinymist_std::error::IgnoreLogging; use tokio::sync::{mpsc, oneshot}; -use typst_preview::{ControlPlaneMessage, Previewer}; use crate::project::ProjectPreviewState; use crate::tool::preview::{HttpServer, ProjectPreviewHandler}; diff --git a/crates/tinymist/src/cmd.rs b/crates/tinymist/src/cmd.rs index bb9a03f2..3f3c0ec6 100644 --- a/crates/tinymist/src/cmd.rs +++ b/crates/tinymist/src/cmd.rs @@ -369,7 +369,7 @@ impl ServerState { /// Scroll preview instances. #[cfg(feature = "preview")] pub fn scroll_preview(&mut self, mut args: Vec) -> AnySchedulableResponse { - use typst_preview::ControlPlaneMessage; + use tinymist_preview::ControlPlaneMessage; if args.is_empty() { return self.preview.scroll_all(self.infer_pos()?); diff --git a/crates/tinymist/src/main.rs b/crates/tinymist/src/main.rs index b837cc87..30522ca1 100644 --- a/crates/tinymist/src/main.rs +++ b/crates/tinymist/src/main.rs @@ -90,7 +90,7 @@ fn main() -> Result<()> { env_logger::builder() .filter_module("tinymist", base_level) - .filter_module("typst_preview", preview_level) + .filter_module("tinymist_preview", preview_level) .filter_module("typlite", base_level) .filter_module("reflexo", base_level) .filter_module("sync_ls", base_level) diff --git a/crates/tinymist/src/project.rs b/crates/tinymist/src/project.rs index 39fc2009..cc80cd3e 100644 --- a/crates/tinymist/src/project.rs +++ b/crates/tinymist/src/project.rs @@ -353,13 +353,17 @@ impl PeriscopeProvider for TypstPeriscopeProvider { #[derive(Default, Clone)] pub struct ProjectPreviewState { #[cfg(feature = "preview")] - pub(crate) inner: Arc>>>, + pub(crate) inner: Arc>>>, } #[cfg(feature = "preview")] impl ProjectPreviewState { #[must_use] - pub fn register(&self, id: &ProjectInsId, handle: &Arc) -> bool { + pub fn register( + &self, + id: &ProjectInsId, + handle: &Arc, + ) -> bool { let mut p = self.inner.lock(); // Don't replace the existing watcher if it exists @@ -377,7 +381,7 @@ impl ProjectPreviewState { } #[must_use] - pub fn get(&self, task_id: &ProjectInsId) -> Option> { + pub fn get(&self, task_id: &ProjectInsId) -> Option> { self.inner.lock().get(task_id).cloned() } } @@ -568,8 +572,8 @@ impl CompileHandler for CompileHandlerImpl #[cfg(feature = "preview")] if let Some(inner) = self.preview.get(&rep.id) { + use tinymist_preview::CompileStatus; use tinymist_project::CompileStatusEnum::*; - use typst_preview::CompileStatus; inner.status(match &rep.status { Compiling => CompileStatus::Compiling, diff --git a/crates/tinymist/src/server.rs b/crates/tinymist/src/server.rs index 1997bb4a..c41ec0ff 100644 --- a/crates/tinymist/src/server.rs +++ b/crates/tinymist/src/server.rs @@ -366,8 +366,8 @@ impl ServerState { } #[cfg(feature = "preview")] - pub(crate) fn infer_pos(&self) -> LspResult { - use typst_preview::{ControlPlaneMessage, ResolveSourceLocRequest}; + pub(crate) fn infer_pos(&self) -> LspResult { + use tinymist_preview::{ControlPlaneMessage, ResolveSourceLocRequest}; let focus_file = self.focusing.as_ref(); let focus_file = focus_file.ok_or_else(|| invalid_request("no focusing file"))?; diff --git a/crates/tinymist/src/tool/preview.rs b/crates/tinymist/src/tool/preview.rs index 2d197436..8c29147c 100644 --- a/crates/tinymist/src/tool/preview.rs +++ b/crates/tinymist/src/tool/preview.rs @@ -18,13 +18,13 @@ use serde::Serialize; use serde_json::Value as JsonValue; use sync_ls::just_ok; use tinymist_assets::TYPST_PREVIEW_HTML; -use tinymist_query::{LspPosition, LspRange}; -use tinymist_std::error::IgnoreLogging; -use tokio::sync::{mpsc, oneshot}; -use typst_preview::{ +use tinymist_preview::{ frontend_html, ControlPlaneMessage, ControlPlaneRx, ControlPlaneTx, DocToSrcJumpInfo, PreviewArgs, PreviewBuilder, PreviewMode, Previewer, WsMessage, }; +use tinymist_query::{LspPosition, LspRange}; +use tinymist_std::error::IgnoreLogging; +use tokio::sync::{mpsc, oneshot}; use crate::actor::preview::{PreviewActor, PreviewRequest, PreviewTab}; use crate::project::{ProjectInsId, ProjectPreviewState, WorldProvider}; @@ -191,7 +191,7 @@ impl ServerState { )); } - let previewer = typst_preview::PreviewBuilder::new(cli_args.preview.clone()); + let previewer = tinymist_preview::PreviewBuilder::new(cli_args.preview.clone()); let watcher = previewer.compile_watcher(); let primary = &mut self.project.compiler.primary; @@ -334,7 +334,7 @@ impl PreviewState { self.client.handle.spawn(async move { let mut resp_rx = resp_rx; while let Some(resp) = resp_rx.recv().await { - use typst_preview::ControlPlaneResponse::*; + use tinymist_preview::ControlPlaneResponse::*; match resp { // ignoring compile status per task. @@ -609,7 +609,7 @@ impl Notification for ScrollSource { struct NotifDocumentOutline; impl Notification for NotifDocumentOutline { - type Params = typst_preview::Outline; + type Params = tinymist_preview::Outline; const METHOD: &'static str = "tinymist/documentOutline"; } diff --git a/crates/tinymist/src/tool/preview/compile.rs b/crates/tinymist/src/tool/preview/compile.rs index 562e7376..3419f78f 100644 --- a/crates/tinymist/src/tool/preview/compile.rs +++ b/crates/tinymist/src/tool/preview/compile.rs @@ -4,14 +4,14 @@ use std::path::Path; use reflexo::debug_loc::SourceSpanOffset; use reflexo_typst::{error::prelude::*, Bytes, Error, TypstDocument}; +use tinymist_preview::{ + CompileStatus, DocToSrcJumpInfo, EditorServer, Location, MemoryFiles, MemoryFilesShort, +}; use tinymist_project::LspCompiledArtifact; use tinymist_query::{jump_from_click, jump_from_cursor}; use typst::layout::{Abs, Point, Position}; use typst::syntax::{LinkedNode, Source, Span, SyntaxKind}; use typst::World; -use typst_preview::{ - CompileStatus, DocToSrcJumpInfo, EditorServer, Location, MemoryFiles, MemoryFilesShort, -}; use typst_shim::syntax::LinkedNodeExt; use crate::project::{LspInterrupt, ProjectClient, ProjectInsId}; @@ -91,7 +91,7 @@ pub struct PreviewCompileView { pub art: LspCompiledArtifact, } -impl typst_preview::CompileView for PreviewCompileView { +impl tinymist_preview::CompileView for PreviewCompileView { fn doc(&self) -> Option { self.art.doc.clone() } diff --git a/crates/tinymist/src/tool/project.rs b/crates/tinymist/src/tool/project.rs index 302de722..eb5c09dc 100644 --- a/crates/tinymist/src/tool/project.rs +++ b/crates/tinymist/src/tool/project.rs @@ -47,7 +47,7 @@ pub struct GenerateScriptArgs { } #[cfg(feature = "preview")] -pub use typst_preview::{PreviewArgs, PreviewMode}; +pub use tinymist_preview::{PreviewArgs, PreviewMode}; /// Project task commands. #[derive(Debug, Clone, clap::Subcommand)] diff --git a/crates/typst-preview/Cargo.toml b/crates/typst-preview/Cargo.toml index d604c763..9b16f6b2 100644 --- a/crates/typst-preview/Cargo.toml +++ b/crates/typst-preview/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "typst-preview" +name = "tinymist-preview" description = "A previewer for the Typst typesetting system." license = "MIT" repository = "https://github.com/Enter-tainer/typst-preview" diff --git a/crates/typst-preview/README.md b/crates/typst-preview/README.md new file mode 100644 index 00000000..27ecdcca --- /dev/null +++ b/crates/typst-preview/README.md @@ -0,0 +1,30 @@ +**This is renamed from `typst-preview` to `tinymist-preview` to publish on `crates.io`.** + +# [Typst Preview](https://github.com/Enter-tainer/typst-preview) + +Preview your Typst files in vscode instantly! + +## Features + +- Low latency preview: preview your document instantly on type. The incremental rendering technique makes the preview latency as low as possible. +- Open in browser: open the preview in browser, so you put it in another monitor. https://github.com/typst/typst/issues/1344 +- Cross jump between code and preview: We implement SyncTeX-like feature for typst-preview. You can now click on the preview panel to jump to the corresponding code location, and vice versa. + +For more information, please visit documentation at [Typst Preview Book](https://enter-tainer.github.io/typst-preview/). + +## Extension Settings + +See https://enter-tainer.github.io/typst-preview/config.html + +## Bug report + +To achieve high performance instant preview, we use a **different rendering backend** from official typst. We are making our best effort to keep the rendering result consistent with official typst. We have set up comprehensive tests to ensure the consistency of the rendering result. But we cannot guarantee that the rendering result is the same in all cases. There can be unknown corner cases that we haven't covered. + +**Therefore, if you encounter any rendering issue, please report it to this repo other than official typst repo.** +## Known Issues + +See [issues](https://github.com/Enter-tainer/typst-preview/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc) on GitHub. + +## Legal + +This project is not affiliated with, created by, or endorsed by Typst the brand.