Support compiling the library for wasm32 - #65
Closed
l1n wants to merge 4 commits into
Closed
Conversation
Gate the networking, filesystem-cache, and auth code (and their dependencies: reqwest, tokio, glob, clap, simple_logger, rpassword) behind cfg(not(target_arch = "wasm32")). The pure generation path — types, transforms, cover rendering, image processing, and epub assembly — now builds for wasm32-unknown-unknown, enabling in-browser epub generation. Thread::to_epub and Continuity::to_epub are split into a native async half that downloads images and a new sync to_epub_from_images(options, images) that accepts caller-fetched images and is available on wasm, alongside the existing to_epub_remote_images. getrandom's JS backends are enabled for wasm32 (needed transitively by rand and uuid); building for wasm requires RUSTFLAGS='--cfg getrandom_backend="wasm_js"' and --lib (the CLI binary remains native-only). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Current stable clippy (1.96) flags these five collapsible_if cases in cached.rs now that if-let chains are stable, failing the -D warnings CI gate. No behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Uncomment the wasm clippy step sketched in check.yml. The CLI moves to src/cli.rs with src/main.rs compiling it natively and building as an empty stub on wasm32, so the whole workspace (not just --lib) checks cleanly for wasm32-unknown-unknown. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
Pushed two follow-ups: current stable clippy (1.96) fails the existing |
Owner
|
Hi! Really cool to see this running in a third party service. :D
Would you mind checking it does what you you need it to before I merge it? |
Merged
Owner
|
Closed in favor of #67. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the glowpub library compile for
wasm32-unknown-unknown, enabling in-browser epub generation. The CLI binary is unchanged and remains native-only.api,cached,auth) are gated behindcfg(not(target_arch = "wasm32")), along with their dependencies (reqwest,tokio,glob,clap,simple_logger,rpassword), which move to a target-specific dependency table.Thread::to_epub/Continuity::to_epubare split: the async native half downloads images as before, then delegates to a new syncto_epub_from_images(options, HashMap<String, InternedImage>), which is available on wasm so callers can supply images fetched by other means (e.g. JSfetch).to_epub_remote_imagesis untouched.intern_imageskeepsInternedImageand its pure image-processing methods on wasm; only the download-and-intern async functions are native-gated.randanduuidpull it in transitively).Building
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo check --lib --target wasm32-unknown-unknown(
--libbecause the CLI binary doesn't build on wasm;getrandom_backendis required by getrandom 0.3 on wasm32-unknown-unknown.)Motivation / testing
I run an RSS/epub mirror (glowficrss.com) that uses the glowpub CLI server-side. For access-locked threads the server has no credentials, so it now falls back to a page that fetches the thread through the user's own glowfic login and assembles the epub in the browser with this library compiled to wasm (via a small wasm-bindgen wrapper crate that parses the raw API JSON into
Post/Replyand callsto_epub_from_images). That path is running in production: output is byte-identical to the native path for the threads I compared, with icons interned, covers rendered (the bundled Cinzel font makes this work without system fonts), and the result readable in Calibre and Apple Books.cargo check/cargo testpass natively;cargo check --libpasses for wasm32 as above.🤖 Generated with Claude Code