Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebAssembly example #310

Merged
merged 2 commits into from
Apr 6, 2021
Merged
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
3 changes: 3 additions & 0 deletions examples/wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
pkg/
226 changes: 226 additions & 0 deletions examples/wasm/Cargo.lock

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

26 changes: 26 additions & 0 deletions examples/wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "textwrap-wasm-demo"
version = "0.1.0"
authors = ["Martin Geisler <martin@geisler.net>"]
description = "Textwrap WebAssembly demo"
repository = "https://github.com/mgeisler/textwrap"
license-file = "../../LICENSE"
edition = "2018"
publish = false # This project should not be uploaded to crates.io

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
textwrap = { path = "../../" }

console_error_panic_hook = "0.1"
js-sys = "0.3"
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["CanvasRenderingContext2d", "TextMetrics"] }

[dev-dependencies]
wasm-bindgen-test = "0.3"

[profile.release]
opt-level = "s" # Optimize for small code size
4 changes: 4 additions & 0 deletions examples/wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Textwrap WebAssembly Demo

An example showing how Textwrap can be used to wrap text in a HTML
canvas.
Loading