This needs to run on plain Linux/x86, not web assembly. The reason is that the Rust code is using OpenGL / CUDA bindings.
Is there a standard way to tag certain Rust functions / structs as "TypeScript accessible", and then have a setup where:
2.a We run a typescript repl.
2.b We load the rust code as a module.
2.c We can type typescript code in the typescript repl and manipulate the Rust module ?
I don't think Node runs TypeScript natively, but if you can find a way to run a TypeScript repl with node, you can create a native NodeJS module with rust using Neon:
That would allow you to bind your native Rust code as a JavaScript library which you could interact with in a NodeJS REPL. You would just have to figure out how to work in TypeScript.
That would allow you to bind your native Rust code as a JavaScript library which you could interact with in a NodeJS REPL.
I'm currently trying to do something similar myself, including trying to access/manipulate the library from a repl (mainly to figure things out).
Neon doesn't currently generate types (related issue on github), but I was just informed in the slack channel that I could use quicktype (I guess referring to this product?) to programmatically generate types, otherwise it was suggested to just handwrite the types if the api is small enough.
--typescript
Output a TypeScript declaration file for the generated JavaScript bindings. This is on by default.
--no-typescript
By default, a *.d.ts TypeScript declaration file is generated for the generated JavaScript bindings, but this flag will disable that.
I wonder if there is a wa yto make the "API crate" to also be buildable under wasm and then utilize the above to generate the *.d.ts files.