Set up typst wasm plugin
This commit is contained in:
parent
49d6a2c022
commit
179d0653bb
10 changed files with 76 additions and 1 deletions
27
Cargo.lock
generated
27
Cargo.lock
generated
|
|
@ -2533,6 +2533,13 @@ dependencies = [
|
||||||
"typst-render",
|
"typst-render",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "showbits-typst-plugin"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-minimal-protocol",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signal-hook-registry"
|
name = "signal-hook-registry"
|
||||||
version = "1.4.2"
|
version = "1.4.2"
|
||||||
|
|
@ -3516,6 +3523,16 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "venial"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "61584a325b16f97b5b25fcc852eb9550843a251057a5e3e5992d2376f3df4bb2"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version-compare"
|
name = "version-compare"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
@ -3611,6 +3628,16 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-minimal-protocol"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/astrale-sharp/wasm-minimal-protocol.git?rev=90336ebf2d99844fd8f8e99ea7096af96526cbf4#90336ebf2d99844fd8f8e99ea7096af96526cbf4"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"venial",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmi"
|
name = "wasmi"
|
||||||
version = "0.40.0"
|
version = "0.40.0"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ members = [
|
||||||
"showbits-common",
|
"showbits-common",
|
||||||
"showbits-thermal-printer",
|
"showbits-thermal-printer",
|
||||||
"showbits-typst",
|
"showbits-typst",
|
||||||
|
"showbits-typst-plugin",
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
|
|
@ -39,6 +40,10 @@ version = "0.7.6"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["std", "taffy_tree", "flexbox", "grid", "block_layout"]
|
features = ["std", "taffy_tree", "flexbox", "grid", "block_layout"]
|
||||||
|
|
||||||
|
[workspace.dependencies.wasm-minimal-protocol]
|
||||||
|
git = "https://github.com/astrale-sharp/wasm-minimal-protocol.git"
|
||||||
|
rev = "90336ebf2d99844fd8f8e99ea7096af96526cbf4"
|
||||||
|
|
||||||
[workspace.lints]
|
[workspace.lints]
|
||||||
rust.unsafe_code = { level = "forbid", priority = 1 }
|
rust.unsafe_code = { level = "forbid", priority = 1 }
|
||||||
# Lint groups
|
# Lint groups
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,7 @@ pub use self::text::*;
|
||||||
mod text;
|
mod text;
|
||||||
|
|
||||||
fn typst_with_lib() -> Typst {
|
fn typst_with_lib() -> Typst {
|
||||||
Typst::new().with_file("/lib.typ", include_str!("documents/lib.typ"))
|
Typst::new()
|
||||||
|
.with_file("/lib.typ", include_str!("documents/lib.typ"))
|
||||||
|
.with_file("/plugin.wasm", include_bytes!("documents/plugin.wasm"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,5 @@
|
||||||
// Determined by experiments so that the top and bottom white border are roughly
|
// Determined by experiments so that the top and bottom white border are roughly
|
||||||
// the same size after tearing off the paper.
|
// the same size after tearing off the paper.
|
||||||
#let feed = v(64pt + 32pt)
|
#let feed = v(64pt + 32pt)
|
||||||
|
|
||||||
|
#import plugin("plugin.wasm") as plugin
|
||||||
|
|
|
||||||
1
showbits-thermal-printer/src/documents/plugin.wasm
Symbolic link
1
showbits-thermal-printer/src/documents/plugin.wasm
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../target/wasm32-unknown-unknown/release/showbits_typst_plugin.wasm
|
||||||
1
showbits-thermal-printer/src/documents/text/plugin.wasm
Symbolic link
1
showbits-thermal-printer/src/documents/text/plugin.wasm
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../plugin.wasm
|
||||||
21
showbits-typst-plugin/Cargo.toml
Normal file
21
showbits-typst-plugin/Cargo.toml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
[package]
|
||||||
|
name = "showbits-typst-plugin"
|
||||||
|
version = { workspace = true }
|
||||||
|
edition = { workspace = true }
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[dependencies.wasm-minimal-protocol]
|
||||||
|
git = "https://github.com/astrale-sharp/wasm-minimal-protocol.git"
|
||||||
|
rev = "90336ebf2d99844fd8f8e99ea7096af96526cbf4"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true # Enable link-time optimization
|
||||||
|
strip = true # Strip symbols from binary*
|
||||||
|
opt-level = 'z' # Optimize for size
|
||||||
|
codegen-units = 1 # Reduce number of codegen units to increase optimizations
|
||||||
|
panic = 'abort' # Abort on panic
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
5
showbits-typst-plugin/meta/build
Executable file
5
showbits-typst-plugin/meta/build
Executable file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env fish
|
||||||
|
|
||||||
|
cargo build --release \
|
||||||
|
--package showbits-typst-plugin \
|
||||||
|
--target wasm32-unknown-unknown
|
||||||
3
showbits-typst-plugin/meta/setup
Executable file
3
showbits-typst-plugin/meta/setup
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env fish
|
||||||
|
|
||||||
|
rustup target add wasm32-unknown-unknown
|
||||||
8
showbits-typst-plugin/src/lib.rs
Normal file
8
showbits-typst-plugin/src/lib.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
use wasm_minimal_protocol::*;
|
||||||
|
|
||||||
|
initiate_protocol!();
|
||||||
|
|
||||||
|
#[wasm_func]
|
||||||
|
pub fn debug_print(arg: &[u8]) -> Vec<u8> {
|
||||||
|
format!("{arg:?}").into_bytes()
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue