initialize repo
This commit is contained in:
		
						commit
						199bf37638
					
				
					 7 changed files with 176 additions and 0 deletions
				
			
		
							
								
								
									
										6
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | ||||||
|  | /target | ||||||
|  | **/*.rs.bk | ||||||
|  | Cargo.lock | ||||||
|  | bin/ | ||||||
|  | pkg/ | ||||||
|  | wasm-pack.log | ||||||
							
								
								
									
										34
									
								
								Cargo.toml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Cargo.toml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | ||||||
|  | [package] | ||||||
|  | name = "gpx-web-utils" | ||||||
|  | version = "0.1.0" | ||||||
|  | authors = ["Matthew Dillon <matthewrdillon@gmail.com>"] | ||||||
|  | edition = "2018" | ||||||
|  | 
 | ||||||
|  | [lib] | ||||||
|  | crate-type = ["cdylib", "rlib"] | ||||||
|  | 
 | ||||||
|  | [features] | ||||||
|  | default = ["console_error_panic_hook"] | ||||||
|  | 
 | ||||||
|  | [dependencies] | ||||||
|  | wasm-bindgen = "0.2.63" | ||||||
|  | 
 | ||||||
|  | # The `console_error_panic_hook` crate provides better debugging of panics by | ||||||
|  | # logging them with `console.error`. This is great for development, but requires | ||||||
|  | # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for | ||||||
|  | # code size when deploying. | ||||||
|  | console_error_panic_hook = { version = "0.1.6", optional = true } | ||||||
|  | 
 | ||||||
|  | # `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size | ||||||
|  | # compared to the default allocator's ~10K. It is slower than the default | ||||||
|  | # allocator, however. | ||||||
|  | # | ||||||
|  | # Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now. | ||||||
|  | wee_alloc = { version = "0.4.5", optional = true } | ||||||
|  | 
 | ||||||
|  | [dev-dependencies] | ||||||
|  | wasm-bindgen-test = "0.3.13" | ||||||
|  | 
 | ||||||
|  | [profile.release] | ||||||
|  | # Tell `rustc` to optimize for small code size. | ||||||
|  | opt-level = "s" | ||||||
							
								
								
									
										25
									
								
								LICENSE
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								LICENSE
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | ||||||
|  | Copyright (c) 2018 Matthew Dillon <matthewrdillon@gmail.com> | ||||||
|  | 
 | ||||||
|  | Permission is hereby granted, free of charge, to any | ||||||
|  | person obtaining a copy of this software and associated | ||||||
|  | documentation files (the "Software"), to deal in the | ||||||
|  | Software without restriction, including without | ||||||
|  | limitation the rights to use, copy, modify, merge, | ||||||
|  | publish, distribute, sublicense, and/or sell copies of | ||||||
|  | the Software, and to permit persons to whom the Software | ||||||
|  | is furnished to do so, subject to the following | ||||||
|  | conditions: | ||||||
|  | 
 | ||||||
|  | The above copyright notice and this permission notice | ||||||
|  | shall be included in all copies or substantial portions | ||||||
|  | of the Software. | ||||||
|  | 
 | ||||||
|  | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF | ||||||
|  | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||||||
|  | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||||||
|  | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||||||
|  | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||||||
|  | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||||||
|  | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR | ||||||
|  | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||||||
|  | DEALINGS IN THE SOFTWARE. | ||||||
							
								
								
									
										69
									
								
								README.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								README.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,69 @@ | ||||||
|  | <div align="center"> | ||||||
|  | 
 | ||||||
|  |   <h1><code>wasm-pack-template</code></h1> | ||||||
|  | 
 | ||||||
|  |   <strong>A template for kick starting a Rust and WebAssembly project using <a href="https://github.com/rustwasm/wasm-pack">wasm-pack</a>.</strong> | ||||||
|  | 
 | ||||||
|  |   <p> | ||||||
|  |     <a href="https://travis-ci.org/rustwasm/wasm-pack-template"><img src="https://img.shields.io/travis/rustwasm/wasm-pack-template.svg?style=flat-square" alt="Build Status" /></a> | ||||||
|  |   </p> | ||||||
|  | 
 | ||||||
|  |   <h3> | ||||||
|  |     <a href="https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html">Tutorial</a> | ||||||
|  |     <span> | </span> | ||||||
|  |     <a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a> | ||||||
|  |   </h3> | ||||||
|  | 
 | ||||||
|  |   <sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub> | ||||||
|  | </div> | ||||||
|  | 
 | ||||||
|  | ## About | ||||||
|  | 
 | ||||||
|  | [**📚 Read this template tutorial! 📚**][template-docs] | ||||||
|  | 
 | ||||||
|  | This template is designed for compiling Rust libraries into WebAssembly and | ||||||
|  | publishing the resulting package to NPM. | ||||||
|  | 
 | ||||||
|  | Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other | ||||||
|  | templates and usages of `wasm-pack`. | ||||||
|  | 
 | ||||||
|  | [tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html | ||||||
|  | [template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html | ||||||
|  | 
 | ||||||
|  | ## 🚴 Usage | ||||||
|  | 
 | ||||||
|  | ### 🐑 Use `cargo generate` to Clone this Template | ||||||
|  | 
 | ||||||
|  | [Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate) | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project | ||||||
|  | cd my-project | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ### 🛠️ Build with `wasm-pack build` | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | wasm-pack build | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ### 🔬 Test in Headless Browsers with `wasm-pack test` | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | wasm-pack test --headless --firefox | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ### 🎁 Publish to NPM with `wasm-pack publish` | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | wasm-pack publish | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ## 🔋 Batteries Included | ||||||
|  | 
 | ||||||
|  | * [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating | ||||||
|  |   between WebAssembly and JavaScript. | ||||||
|  | * [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook) | ||||||
|  |   for logging panic messages to the developer console. | ||||||
|  | * [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized | ||||||
|  |   for small code size. | ||||||
							
								
								
									
										19
									
								
								src/lib.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/lib.rs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | ||||||
|  | mod utils; | ||||||
|  | 
 | ||||||
|  | use wasm_bindgen::prelude::*; | ||||||
|  | 
 | ||||||
|  | // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
 | ||||||
|  | // allocator.
 | ||||||
|  | #[cfg(feature = "wee_alloc")] | ||||||
|  | #[global_allocator] | ||||||
|  | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; | ||||||
|  | 
 | ||||||
|  | #[wasm_bindgen] | ||||||
|  | extern { | ||||||
|  |     fn alert(s: &str); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #[wasm_bindgen] | ||||||
|  | pub fn greet() { | ||||||
|  |     alert("Hello, gpx-web-utils!"); | ||||||
|  | } | ||||||
							
								
								
									
										10
									
								
								src/utils.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/utils.rs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | ||||||
|  | pub fn set_panic_hook() { | ||||||
|  |     // When the `console_error_panic_hook` feature is enabled, we can call the
 | ||||||
|  |     // `set_panic_hook` function at least once during initialization, and then
 | ||||||
|  |     // we will get better error messages if our code ever panics.
 | ||||||
|  |     //
 | ||||||
|  |     // For more details see
 | ||||||
|  |     // https://github.com/rustwasm/console_error_panic_hook#readme
 | ||||||
|  |     #[cfg(feature = "console_error_panic_hook")] | ||||||
|  |     console_error_panic_hook::set_once(); | ||||||
|  | } | ||||||
							
								
								
									
										13
									
								
								tests/web.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								tests/web.rs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | ||||||
|  | //! Test suite for the Web and headless browsers.
 | ||||||
|  | 
 | ||||||
|  | #![cfg(target_arch = "wasm32")] | ||||||
|  | 
 | ||||||
|  | extern crate wasm_bindgen_test; | ||||||
|  | use wasm_bindgen_test::*; | ||||||
|  | 
 | ||||||
|  | wasm_bindgen_test_configure!(run_in_browser); | ||||||
|  | 
 | ||||||
|  | #[wasm_bindgen_test] | ||||||
|  | fn pass() { | ||||||
|  |     assert_eq!(1 + 1, 2); | ||||||
|  | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue