Create a web-based version of Cards that runs entirely in the browser using WebAssembly. The webapp will be hosted on GitHub Pages at https://chuntttttt.github.io/Cards/.
Status: In Progress
Refactor cards-core to use in-memory images as the primary implementation:
generate_pdf_from_images(Vec<CardImage>, Vec<CardImage>, usize)- Core implementationcreate_pdf(&self, output_path)- Wrapper that loads files and delegatesgenerate_pdf_bytes(&self)- Wrapper that loads files and delegates
Benefits:
- Single source of truth for PDF generation
- Eliminates ~170 lines of duplicated code
- Makes testing easier (can test with in-memory data)
- WASM and native use same code path
Status: Partially Complete
A web application using:
eframewith WASM target for UI renderingzipcrate for extracting uploaded fileswasm-bindgenfor JavaScript interopweb-sysfor browser APIs (file download)
User workflow:
- User creates ZIP file with structure:
cards.zip front/ card_01.png card_02.png back/ back_01.png back_02.png - User drags/drops ZIP onto browser
- WASM extracts ZIP, loads images into memory
- User adjusts grid size (1-20)
- User clicks "Generate PDF"
- PDF downloads to browser's download folder
Status: Not Started
Using trunk for WASM build:
trunk serve- Local development servertrunk build --release- Production build- Outputs to
cards-wasm/dist/directory - Includes HTML, JS glue code, and WASM binary
Status: Not Started
GitHub Actions workflow (.github/workflows/wasm-deploy.yaml):
- Trigger on push to trunk branch
- Install Rust + wasm32 target + trunk
- Build WASM with
trunk build --release - Copy
cards-wasm/dist/*todocs/folder - Commit and push to trunk (GitHub Pages serves from
docs/)
Alternative: Deploy to gh-pages branch instead of docs/ folder.
GitHub Pages configuration:
- Repository Settings → Pages → Source: Deploy from branch
- Branch: trunk, folder: /docs (or gh-pages branch)
- URL:
https://chuntttttt.github.io/Cards/
- Research egui WASM compatibility
- Create cards-wasm crate structure
- Add ZIP extraction dependencies
- Create initial
generate_pdf_from_images()method - Implement WASM GUI with drag-and-drop
- Implement ZIP extraction and image loading
- Implement PDF download via browser API
- Create index.html entry point
- Create Trunk.toml configuration
- Refactor cards-core to eliminate duplication
-
Refactor cards-core
- Make
generate_pdf_from_imagesthe core implementation - Convert filesystem methods to thin wrappers
- Test that CLI and GUI still work
- Make
-
Update workspace
- Add cards-wasm to workspace Cargo.toml members
-
Local testing
- Install trunk:
cargo install trunk - Add wasm32 target:
rustup target add wasm32-unknown-unknown - Run:
cd cards-wasm && trunk serve - Test in browser at
http://127.0.0.1:8080
- Install trunk:
-
GitHub Actions workflow
- Create
.github/workflows/wasm-deploy.yaml - Configure to build and deploy on push to trunk
- Decide:
docs/folder vsgh-pagesbranch
- Create
-
Documentation
- Update README with webapp link
- Add instructions for creating compatible ZIP files
- Document local development setup
Expected: 2-5 MB (includes egui + printpdf + image processing)
- First load: Downloads full bundle
- Subsequent loads: Cached by browser
- Modern browsers with WASM support (Chrome, Firefox, Safari, Edge)
- No IE11 support (WASM required)
- No hard limits (processing happens client-side)
- Practical limit: Browser memory (~2GB typical)
- Large card sets (1000+ images) may be slow
- All processing happens in browser
- No files uploaded to server
- No data leaves user's machine
Shared across all platforms (CLI, GUI, WASM):
- Core PDF generation (~520 lines in cards-core)
- Card grouping and alignment logic
- Cutting guide generation
- Image scaling and DPI calculation
Platform-specific code:
- CLI (~40 lines): Argument parsing, file I/O
- GUI (~490 lines): Native file dialogs, desktop UI
- WASM (~400 lines): ZIP extraction, web file handling, browser download
Total code reuse: ~56% of codebase is shared library code.
Potential improvements (not in current scope):
- Progress indicator for large ZIP files
- Image preview before generating PDF
- Drag-and-drop reordering of cards
- Support for multiple ZIP formats/structures
- Server-side option for very large card sets
- PWA support for offline use