0warning0error / typst-yats

Serialization module for Typst
Apache License 2.0
0 stars 0 forks source link

Serialization on the WASM side? #1

Closed alexanderkoller closed 2 months ago

alexanderkoller commented 2 months ago

Hi, I've been looking for a library exactly like yours - thank you for making it!

However, as I understand it, it can only be accessed from Typst code. The plugin code that will be compiled to WASM also needs to serialize and deserialize between the objects and the byte arrays.

Can you give me some advice on how to do that?

0warning0error commented 2 months ago

Hi alexanderkoller This primary goal of project is to show the great ability of Typst. To conveniently interact with Typst, WASM can communicate in cbor, json,toml,yaml,xml and other format. Actually, Typst has these APIs to serialize and deserialize objects.

To make it simple, you can assume cbor as the 'official' language of WASM and typst, and typst code as wrappers to send parameters and receive results in cbor format. You can write Rust code to deserialize the parameters and serialize the results in cbor.(Rust is the most convenient language to implement your ideas and the Typst wasm plugin project support Rust the best ).

I developed a lib called vist that can deal with images in Typst but I haven't release it due to my tight schedule. I will release it soon and you can read it. Maybe it's the better practice you know to write Typst wasm plugin.

alexanderkoller commented 2 months ago

Thank you for the quick response!

If the point of yats is to illustrate that one can implement serialization and deserialization within Typst, might I suggest to clarify in the README that it is not intended to facilitate interaction between wasm and Typst, as it currently suggests? This might make it easier for future readers to understand what yast is and is not.

0warning0error commented 2 months ago

OK, I will add some info to clarify my point.