How to build for web?
Hi,
I'd like to package the SDK as a *.JS module for use in web browsers.
I am running wasm-pack build --target web in the /sdk/ directory, and it outputs a /pkg/ directory with *.JS and *.WASM files.
I'm able to load the JS module in the browser, and call init() on it, but I don't seem to be able to access other functions (or I don't know how to discover/reference them). I usually see an error along the lines of: Uncaught SyntaxError: The requested module './c2pa.js' does not provide an export named 'WindowOrWorker' (at (index):9:23)
Do I need to go through the codebase and add #[wasm_bindgen] above every function, in order to export them in the JS?
Any other advice for achieving my goal?
Thank you!
We have a JS SDK based off of c2pa-rs here: https://www.npmjs.com/package/c2pa. It currently only has read support, however we are working on exposing more functionality.
@dkozma Yea I saw, that's awesome! However, I would like the ability to sign and embed manifests in files. I understand file_io won't work in wasm, but I'm wondering if my goal can still be achieved. It seems that signing using a buffer is supported for image/jpeg and image/png files, so maybe I could just focus on those for now. The signing certificate would be loaded from a file input, or randomly generated using JS Web Crypto API. What do you think?
We currently have some stream based methods and we are working on supporting all operations that way.