diff --git a/.gitignore b/.gitignore index ea8c4bf..0859968 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,33 @@ -/target +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +/Cargo.lock + +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Trunk +dist/ + +# These are backup files generated by rustfmt +**/*.rs.bk + +# Some people use VSCode +/.vscode/ + +# Some people use IntelliJ with Rust +/.idea/ +*.iml + +# Some people use pre-commit +.pre-commit-config.yaml +.pre-commit-config.yml + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Some people have Apple +.DS_Store + +# Generated on wasm-pack failure +**/unsupported.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f1289..da1416c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,26 @@ # Changelog + + +## Unreleased + +## 0.2.0 + +### added + +- `FORM_TEXTAREA_ID` is now public, which has the element ID of the stack trace text area. +- `FORM_SUBMIT_ID` is now public, which has the element ID of the submit button. + +### changed + +- `set_hook_with` now takes the additional argument of an HTML form structure. The previous, default form can still be used with `web_panic_report::set_default_hook_with`, however requires the new (default) cargo feature: `default-form`. + ## 0.1.1 ### changed diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 2d1e932..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,197 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "bumpalo" -version = "3.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "console_error_panic_hook" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if", - "wasm-bindgen", -] - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "log" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - -[[package]] -name = "syn" -version = "2.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "wasm-bindgen" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - -[[package]] -name = "wasm-bindgen-test" -version = "0.3.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" -dependencies = [ - "console_error_panic_hook", - "js-sys", - "scoped-tls", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "web-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "web_panic_report" -version = "0.1.1" -dependencies = [ - "wasm-bindgen", - "wasm-bindgen-test", - "web-sys", -] diff --git a/Cargo.toml b/Cargo.toml index 79dbdd9..db9e600 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "web_panic_report" description = "A panic hook which replaces an HTML element with a bug report form." -version = "0.1.1" +version = "0.2.0" edition = "2021" license = "MIT OR Apache-2.0" -repository = "https://github.com/vectorgameexperts/web_panic_report" +repository = "https://github.com/loopystudios/web_panic_report" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -20,3 +20,7 @@ web-sys = { version = "0.3", features = [ [dev-dependencies] wasm-bindgen-test = "0.3.42" + +[features] +default = ["default-form"] +default-form = [] diff --git a/Readme.md b/Readme.md index 2648060..75e2693 100644 --- a/Readme.md +++ b/Readme.md @@ -6,8 +6,8 @@ [![Discord](https://img.shields.io/discord/913957940560531456.svg?label=VGX&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/zrjnQzdjCB) [![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license) -[![Build status](https://github.com/vectorgameexperts/web_panic_report/workflows/CI/badge.svg)](https://github.com/vectorgameexperts/web_panic_report/actions) -[![dependency status](https://deps.rs/repo/github/vectorgameexperts/web_panic_report/status.svg)](https://deps.rs/repo/github/vectorgameexperts/web_panic_report) +[![Build status](https://github.com/loopystudios/web_panic_report/workflows/CI/badge.svg)](https://github.com/loopystudios/web_panic_report/actions) +[![dependency status](https://deps.rs/repo/github/loopystudios/web_panic_report/status.svg)](https://deps.rs/repo/github/loopystudios/web_panic_report) [![Crates.io](https://img.shields.io/crates/v/web_panic_report.svg)](https://crates.io/crates/web_panic_report) [![Docs](https://img.shields.io/docsrs/web_panic_report)](https://docs.rs/web_panic_report) @@ -28,7 +28,7 @@ cargo install wasm-server-runner WASM_SERVER_RUNNER_CUSTOM_INDEX_HTML=examples/index.html cargo run --target wasm32-unknown-unknown --example simple ``` -There is also a web demo [available here](https://vectorgameexperts.github.io/web_panic_report). +There is also a web demo [available here](https://loopystudios.github.io/web_panic_report). ![Demo](image.png) @@ -59,20 +59,22 @@ Then, set the panic hook at the beginning of your program on web. ```rust fn main() { #[cfg(target_arch = "wasm32")] - web_panic_report::set_hook_with("my-container", |panic_info| { + web_panic_report::set_default_hook_with("my-container", |panic_info| { // Send the panic info to your backend here. // This is triggered when the user clicks "Send Report" }); } ``` +You can also use a custom bug report form. See the [custom example](examples/custom.rs). + ## Alternatives - [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook) - Only outputs stack trace to the console. ## Community -All VGX projects and development happens in the [VGX Discord](https://discord.gg/zrjnQzdjCB). The discord is open to the public. +All Loopy projects and development happens in the [Loopy Discord](https://discord.gg/zrjnQzdjCB). The discord is open to the public. Contributions are welcome by pull request. The [Rust code of conduct](https://www.rust-lang.org/policies/code-of-conduct) applies. @@ -87,9 +89,6 @@ Licensed under either of at your option -The files in subdirectories of the [`examples/assets`](/examples/assets) directory are licensed solely under -their respective licenses, available in the `LICENSE` file in their directories. - ## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted diff --git a/examples/custom.rs b/examples/custom.rs new file mode 100644 index 0000000..675a0a6 --- /dev/null +++ b/examples/custom.rs @@ -0,0 +1,28 @@ +/// This is called from a button on the web example to allow the user to trigger a panic. +#[no_mangle] +pub extern "C" fn trigger_panic() { + panic!("You triggered the panic!"); +} + +fn main() { + let my_form = format!( + r#" +