Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ proptest-regressions/
# Flatpak build artifacts
.flatpak-builder/
repo/
/dist/
/pkg/
145 changes: 122 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 61 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ required-features = ["dev-bins", "runtime"]
[lib]
name = "fresh"
path = "src/lib.rs"
crate-type = ["cdylib", "rlib"]

[features]
default = ["plugins", "runtime", "embed-plugins"]
Expand All @@ -41,6 +42,7 @@ dev-bins = []
runtime = [
"dep:crossterm",
"dep:ratatui",
"ratatui/crossterm", # Enable ratatui's crossterm backend for native
"dep:chrono",
"dep:clap",
"dep:tracing",
Expand Down Expand Up @@ -89,6 +91,29 @@ runtime = [
]
# Schema-only feature for minimal builds (just schema generation)
schema-only = []
# WASM browser build - uses Ratzilla for browser rendering
wasm = [
"dep:ratzilla",
"dep:ratatui", # ratatui without crossterm for WASM
"dep:wasm-bindgen",
"dep:wasm-bindgen-futures",
"dep:console_error_panic_hook",
"dep:web-sys",
"dep:js-sys",
"dep:getrandom",
"dep:bitflags",
# Core dependencies needed for WASM
"dep:unicode-width",
"dep:unicode-segmentation",
"dep:regex",
"dep:chrono",
"dep:async-trait",
# Syntax highlighting - syntect is pure Rust and works in WASM
"dep:syntect",
# Model layer dependencies (anyhow for Result, tracing for debug)
"dep:anyhow",
"dep:tracing",
]

[dependencies]
# Always required (for schema generation and runtime)
Expand All @@ -100,7 +125,8 @@ once_cell = "1.20"

# Runtime dependencies (optional, enabled by "runtime" feature)
crossterm = { version = "0.29.0", features = ["osc52"], optional = true }
ratatui = { version = "0.29.0", optional = true }
# ratatui without default features (crossterm) - enable crossterm feature in runtime
ratatui = { version = "0.29.0", default-features = false, optional = true }
chrono = { version = "0.4", default-features = false, features = ["std", "clock"], optional = true }
clap = { version = "4.5", default-features = false, features = ["derive", "std", "help", "usage", "error-context"], optional = true }
tracing = { version = "0.1", optional = true }
Expand Down Expand Up @@ -144,7 +170,8 @@ dirs = { version = "6.0", optional = true }
pulldown-cmark = { version = "0.13", default-features = false, optional = true }
sha2 = { version = "0.10", optional = true }
arboard = { version = "3.6", default-features = false, features = ["wayland-data-control"], optional = true }
syntect = { version = "5.3", optional = true }
# Note: Using fancy-regex backend (pure Rust) instead of onig (C library) for WASM compatibility
syntect = { version = "5.3", default-features = false, features = ["parsing", "default-syntaxes", "regex-fancy", "plist-load", "yaml-load"], optional = true }
ureq = { version = "2.12", default-features = false, features = ["tls"], optional = true }
unicode-width = { version = "0.2", optional = true }
unicode-segmentation = { version = "1.12", optional = true }
Expand All @@ -158,6 +185,26 @@ include_dir = { version = "0.7", optional = true }
tempfile = { version = "3.24", optional = true }
trash = { version = "5.2.5", optional = true }

# WASM browser build dependencies (optional)
ratzilla = { version = "0.2", optional = true }
wasm-bindgen = { version = "0.2", optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }
console_error_panic_hook = { version = "0.1", optional = true }
js-sys = { version = "0.3", optional = true }
getrandom = { version = "0.2", features = ["js"], optional = true }
bitflags = { version = "2.6", optional = true }

[dependencies.web-sys]
version = "0.3"
optional = true
features = [
"Window",
"Document",
"Element",
"HtmlElement",
"console",
]

[dev-dependencies]
proptest = "1.9"
tempfile = "3.24.0"
Expand All @@ -182,6 +229,14 @@ split-debuginfo = "packed"
inherits = "release"
lto = "thin"

# WASM release build profile - optimized for size
[profile.wasm-release]
inherits = "release"
opt-level = "z" # Optimize for size
lto = true # Link-time optimization
codegen-units = 1 # Better optimization
panic = "abort" # Smaller binary, no unwinding

[package.metadata.dist]
# Point dist at the changelog so GitHub Releases get populated
changelog = "CHANGELOG.md"
Expand Down Expand Up @@ -235,3 +290,7 @@ WRAPPER
chmod 755 /usr/bin/fresh
fi
"""

# wasm-pack configuration
[package.metadata.wasm-pack.profile.release]
wasm-opt = false
Loading