Skip to content

Commit d21330a

Browse files
committed
fix: updated wasm configuration
1 parent 5fe9d6a commit d21330a

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@ path = "src/lib.rs"
2121

2222
[dependencies]
2323
jpeg-decoder = "0.3.2"
24-
lopdf = { version = "0.38.0", default-features = false }
2524
miniz_oxide = "0.8.9"
2625
png = "0.18.0"
2726

28-
# WASM support - automatically enabled when targeting wasm32-unknown-unknown
27+
# Target-specific configuration to ensure correct behavior without consumer-side feature flags
28+
# For non-WASM targets, use lopdf with its default native features
29+
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
30+
lopdf = { version = "0.38.0" }
31+
32+
# For wasm32-unknown-unknown, enable lopdf's wasm_js mode and getrandom's wasm_js support
2933
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
30-
getrandom = { version = "0.3", features = ["wasm_js"] }
34+
lopdf = { version = "0.38.0", default-features = false, features = ["wasm_js"] }
3135

3236
[dev-dependencies]
3337
png = { version = "0.18.0", features = ["unstable"] }
3438
wasm-bindgen-test = "0.3"
3539

3640
[features]
37-
default = ["native"]
38-
# Enable WASM support for lopdf when targeting WASM
39-
wasm_js = ["lopdf/wasm_js"]
40-
# Default features for non-WASM targets
41-
native = ["lopdf/default"]
41+
# No feature flags are required by consumers; behavior is selected automatically by target.
42+
# These are kept empty for backward compatibility so enabling them has no effect.
43+
default = []
44+
wasm_js = []
45+
native = []
4246

4347
# Test configuration
4448
[package.metadata.docs.rs]

test_wasm.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ main() {
143143
echo " • Use the library in WASM environments without manual configuration"
144144
echo " • Load images from bytes using Image::from_bytes()"
145145
echo " • Embed images in PDF documents in browser environments"
146-
echo " • All without needing to add getrandom dependencies to their projects"
147146
}
148147

149148
# Run main function

0 commit comments

Comments
 (0)