feat: Add WebAssembly (WASM) compiler target and browser CDN support - #69
feat: Add WebAssembly (WASM) compiler target and browser CDN support#69devgabrielmarcondes wants to merge 2 commits into
Conversation
|
Hi, this is very impressive, thanks for the contribution! I can't review your code because your first commit changed every file here. I suspect your code editor might have modified line endings or something else. Can you clean it up so i can review it? Thanks, Best, |
57f466c to
1e3c5f6
Compare
|
Hi Abimael, Sorry about that! My Windows Git automatically checked out CRLF line endings across the whole repo on my initial clone without me noticing. I just force-pushed a clean version with only the 4 intended file modifications (with correct LF endings) and a single clean commit. It should be perfect for review now! Please let me know if everything looks good. Thanks! |
abimaelmartell
left a comment
There was a problem hiding this comment.
Thanks for putting this together, the WASM direction is definitely useful.
One blocker: the WASM lopdf dependency still enables its default features, and cargo tree --target wasm32-unknown-unknown -e features shows that lopdf/default still pulls in lopdf/rayon and rayon. So this doesn’t fully disable threading for WASM yet.
Could you change the wasm target dependency to use default-features = false and then explicitly re-enable any non-threading features we still need? Also please run cargo fmt, since src/wasm.rs currently fails cargo fmt --check.
Thanks!
|
Thanks for the review! I've just pushed an update addressing your feedback:
Let me know if there's anything else needed! |
This PR introduces the foundation for adapting
pdf-inspectorto run fully client-side on browsers via WebAssembly (WASM).Changes:
rayonthreading dependency strictly forwasm32environments (as WebAssembly forbids multi-threading/OS threads by default).CompatInstantfallback usingjs_sys::Date::now()to resolve theRuntimeError: unreachablefatal error occurring during WASM compilation fromstd::time::Instant::now().wasm_jsfeature for thegetrandomcrate exclusively forcfg(target_arch = "wasm32").process_pdf_memlogic through thewasm-bindgenAPI in a newsrc/wasm.rsmodule.wasm-demo/index.htmlshowcasing the direct conversion happening purely client-side without OCR delays.Demo (WASM running pure client-side processing)