mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-22 02:21:46 +01:00
src/web.rs starts the editor on a page canvas with eframe's WebRunner (WebGL2 via glow) and provides the browser's services; platform.rs decides when: picked files go to the engine's in-memory store and the command runs, saves and exports leave as downloads, preferences and recovery copies live in localStorage, Web Locks tell open tabs from crashed ones, and leaving with unsaved work asks first. The GPU stage and sound output become build cfgs that are off on wasm. Video export and plug-in installs are dimmed in the browser with the reason. scripts/build-web.sh and .ps1 build web/ with the wasm-bindgen CLI pinned to Cargo.lock's version, from packaging/web/index.html. The web profile (opt-level s, stripped, renderer and geometry at opt-level 3) gives an 8973 KB module, 3278 KB gzipped, in 41 s. crates/engine/tests/wasm.rs runs the engine inside WebAssembly in Node (3 tests, 0.6 s).
165 lines
6.2 KiB
TOML
165 lines
6.2 KiB
TOML
[workspace]
|
||
resolver = "3"
|
||
members = [".", "crates/*"]
|
||
default-members = [".", "crates/*"]
|
||
|
||
[workspace.package]
|
||
# 0.1.0 is the early alpha (release stage in src/app.rs, RELEASE_STAGE); see CHANGELOG.md
|
||
# and docs/release.md.
|
||
version = "0.1.0"
|
||
edition = "2024"
|
||
license = "MIT OR Apache-2.0"
|
||
# An application, not a library: not published to crates.io.
|
||
publish = false
|
||
repository = "https://github.com/storytold/AniCraft"
|
||
rust-version = "1.90"
|
||
|
||
[workspace.dependencies]
|
||
anicraft-geom = { path = "crates/geom" }
|
||
anicraft-doc = { path = "crates/doc" }
|
||
anicraft-render = { path = "crates/render" }
|
||
anicraft-engine = { path = "crates/engine" }
|
||
anicraft-xfl = { path = "crates/xfl" }
|
||
anicraft-xml = { path = "crates/xml" }
|
||
anicraft-svg = { path = "crates/svg" }
|
||
anicraft-text = { path = "crates/text" }
|
||
anicraft-plugins = { path = "crates/plugins" }
|
||
anicraft-audio = { path = "crates/audio" }
|
||
anicraft-gpu = { path = "crates/gpu" }
|
||
# The GPU stage (ADR 0019) uses the wgpu that eframe's egui-wgpu brings, with the same
|
||
# (default) features, so the tree keeps one wgpu build.
|
||
wgpu = "30"
|
||
pollster = "1"
|
||
bytemuck = "1"
|
||
anicraft-actions = { path = "crates/actions" }
|
||
serde = { version = "1", features = ["derive"] }
|
||
serde_json = "1"
|
||
thiserror = "2"
|
||
rayon = "1"
|
||
png = "0.17"
|
||
# JPEG decoding for imported images (already in the tree; MIT OR Apache-2.0 OR Zlib).
|
||
zune-jpeg = { version = "0.5", default-features = false }
|
||
gif = "0.14"
|
||
# wgpu is the primary renderer; glow (OpenGL) is the fallback for GPUs/VMs where wgpu fails.
|
||
# Default features off: we skip `links` (opening web links pulls in url/idna/ICU Unicode
|
||
# tables we don't use) and the web-only screen-reader shim. Same set as PhotoCraft, plus glow.
|
||
eframe = { version = "0.36", default-features = false, features = ["accesskit", "default_fonts", "wgpu", "glow", "wayland", "x11"] }
|
||
# Native file dialogs: Windows common dialogs, macOS NSOpenPanel, Linux XDG desktop portal.
|
||
rfd = "0.17"
|
||
# Lists and loads the OS's installed fonts for Preferences › Appearance (MIT).
|
||
# Without the `fontconfig` feature, Linux scans the standard font folders directly
|
||
# (/usr/share/fonts, /usr/local/share/fonts, ~/.local/share/fonts, ~/.fonts).
|
||
fontdb = { version = "0.23", default-features = false, features = ["std", "fs", "memmap"] }
|
||
egui = "0.36"
|
||
# `Instant` and `SystemTime` that work in the browser too (std's panic on wasm32-unknown-unknown);
|
||
# on other targets a re-export of std::time (MIT OR Apache-2.0; already in the tree via winit).
|
||
web-time = "1"
|
||
|
||
[workspace.lints.rust]
|
||
unsafe_code = "forbid"
|
||
|
||
[workspace.lints.clippy]
|
||
dbg_macro = "warn"
|
||
todo = "warn"
|
||
|
||
[package]
|
||
name = "anicraft"
|
||
description = "AniCraft desktop app: egui shell over the AniCraft engine"
|
||
version.workspace = true
|
||
edition.workspace = true
|
||
license.workspace = true
|
||
publish.workspace = true
|
||
repository.workspace = true
|
||
default-run = "anicraft"
|
||
|
||
[features]
|
||
# Plays sound during stage playback. Off: playback is silent (for builders without ALSA headers).
|
||
default = ["sound-output", "gpu-stage"]
|
||
sound-output = ["dep:cpal"]
|
||
# GPU stage renderer (ADR 0019, 0029, 0031), on by default: the stage draws on the graphics card
|
||
# when there is a usable one, and on the CPU (the oracle, and what exports use) otherwise and
|
||
# for anything the GPU can't draw. Preferences › Stage › Renderer can choose the CPU. Build with
|
||
# `--no-default-features --features sound-output` for a CPU-only shell.
|
||
gpu-stage = ["dep:anicraft-gpu"]
|
||
|
||
[[bin]]
|
||
name = "anicraft"
|
||
path = "src/main.rs"
|
||
|
||
[dependencies]
|
||
anicraft-geom.workspace = true
|
||
anicraft-doc.workspace = true
|
||
anicraft-render.workspace = true
|
||
anicraft-engine.workspace = true
|
||
anicraft-gpu = { workspace = true, optional = true }
|
||
egui.workspace = true
|
||
serde.workspace = true
|
||
fontdb.workspace = true
|
||
anicraft-audio.workspace = true
|
||
serde_json.workspace = true
|
||
web-time.workspace = true
|
||
|
||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||
eframe.workspace = true
|
||
rfd.workspace = true
|
||
# Sound output (Apache-2.0): WASAPI on Windows, CoreAudio on macOS, ALSA on Linux and the BSDs.
|
||
cpal = { version = "0.18", optional = true }
|
||
|
||
# The web build (ADR 0036, docs/web.md). The window draws with WebGL2 (glow): every current
|
||
# browser has it, the stage is drawn on the CPU there, and leaving wgpu out keeps the download
|
||
# smaller. The browser glue is wasm-bindgen's (MIT OR Apache-2.0), already under eframe's web
|
||
# backend.
|
||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||
eframe = { version = "0.36", default-features = false, features = ["accesskit", "default_fonts", "glow"] }
|
||
wasm-bindgen = "0.2"
|
||
wasm-bindgen-futures = "0.4"
|
||
js-sys = "0.3"
|
||
web-sys = { version = "0.3", features = ["BeforeUnloadEvent", "Blob", "BlobPropertyBag", "CssStyleDeclaration", "Document", "Element", "Event", "EventTarget", "File", "FileList", "HtmlAnchorElement", "HtmlCanvasElement", "HtmlElement", "HtmlInputElement", "Navigator", "Storage", "Url", "Window", "console"] }
|
||
|
||
[build-dependencies]
|
||
# Embeds the app icon in anicraft.exe on Windows (build.rs); does nothing on other targets.
|
||
winresource = "0.1"
|
||
|
||
[lints]
|
||
workspace = true
|
||
|
||
# ----- build profiles: biased for disk space, then time (docs/development.md › Build footprint) --
|
||
|
||
[profile.dev]
|
||
opt-level = 1
|
||
# File:line in backtraces and panics, without full variable debug info (a fraction of the size;
|
||
# also keeps Windows PDBs under the LNK1140 limit).
|
||
debug = "line-tables-only"
|
||
# The incremental cache was ~3 GB for our crates; they rebuild from scratch in seconds.
|
||
incremental = false
|
||
|
||
[profile.dev.package."*"]
|
||
# Dependencies: optimized once (fast app in debug builds), no debug info at all.
|
||
opt-level = 2
|
||
debug = false
|
||
|
||
[profile.dev.build-override]
|
||
# Build scripts and proc-macros: compile fast, no debug info.
|
||
opt-level = 0
|
||
debug = false
|
||
|
||
[profile.release]
|
||
lto = "thin"
|
||
codegen-units = 1
|
||
strip = "debuginfo"
|
||
|
||
[profile.web]
|
||
# The web editor (scripts/build-web.sh, ADR 0036): the release build optimized for size, since
|
||
# the browser downloads and compiles the whole module before anything shows (9.1 MB, 3.3 MB
|
||
# gzipped, against 11.3 / 4.0 MB at opt-level 3), and without the symbol names.
|
||
inherits = "release"
|
||
opt-level = "s"
|
||
strip = true
|
||
|
||
# ...except the CPU renderer and the geometry under it, which draw the stage there on one thread.
|
||
[profile.web.package.anicraft-render]
|
||
opt-level = 3
|
||
|
||
[profile.web.package.anicraft-geom]
|
||
opt-level = 3
|