Commit e1645bdb2abb7a7cf50466c9f2ca22800720f0a5

Authored by Georg Hopp
1 parent fd61d44a

remove non relevant www dir

1 -#!/usr/bin/env node  
2 -  
3 -const { spawn } = require("child_process");  
4 -const fs = require("fs");  
5 -  
6 -let folderName = '.';  
7 -  
8 -if (process.argv.length >= 3) {  
9 - folderName = process.argv[2];  
10 - if (!fs.existsSync(folderName)) {  
11 - fs.mkdirSync(folderName);  
12 - }  
13 -}  
14 -  
15 -const clone = spawn("git", ["clone", "https://github.com/rustwasm/create-wasm-app.git", folderName]);  
16 -  
17 -clone.on("close", code => {  
18 - if (code !== 0) {  
19 - console.error("cloning the template failed!")  
20 - process.exit(code);  
21 - } else {  
22 - console.log("🦀 Rust + 🕸 Wasm = ❤");  
23 - }  
24 -});  
1 -node_modules  
2 -dist  
1 -<div align="center">  
2 -  
3 - <h1><code>create-wasm-app</code></h1>  
4 -  
5 - <strong>An <code>npm init</code> template for kick starting a project that uses NPM packages containing Rust-generated WebAssembly and bundles them with Webpack.</strong>  
6 -  
7 - <p>  
8 - <a href="https://travis-ci.org/rustwasm/create-wasm-app"><img src="https://img.shields.io/travis/rustwasm/create-wasm-app.svg?style=flat-square" alt="Build Status" /></a>  
9 - </p>  
10 -  
11 - <h3>  
12 - <a href="#usage">Usage</a>  
13 - <span> | </span>  
14 - <a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a>  
15 - </h3>  
16 -  
17 - <sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>  
18 -</div>  
19 -  
20 -## About  
21 -  
22 -This template is designed for depending on NPM packages that contain  
23 -Rust-generated WebAssembly and using them to create a Website.  
24 -  
25 -* Want to create an NPM package with Rust and WebAssembly? [Check out  
26 - `wasm-pack-template`.](https://github.com/rustwasm/wasm-pack-template)  
27 -* Want to make a monorepo-style Website without publishing to NPM? Check out  
28 - [`rust-webpack-template`](https://github.com/rustwasm/rust-webpack-template)  
29 - and/or  
30 - [`rust-parcel-template`](https://github.com/rustwasm/rust-parcel-template).  
31 -  
32 -## 🚴 Usage  
33 -  
34 -```  
35 -npm init wasm-app  
36 -```  
37 -  
38 -## 🔋 Batteries Included  
39 -  
40 -- `.gitignore`: ignores `node_modules`  
41 -- `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you  
42 -- `README.md`: the file you are reading now!  
43 -- `index.html`: a bare bones html document that includes the webpack bundle  
44 -- `index.js`: example js file with a comment showing how to import and use a wasm pkg  
45 -- `package.json` and `package-lock.json`:  
46 - - pulls in devDependencies for using webpack:  
47 - - [`webpack`](https://www.npmjs.com/package/webpack)  
48 - - [`webpack-cli`](https://www.npmjs.com/package/webpack-cli)  
49 - - [`webpack-dev-server`](https://www.npmjs.com/package/webpack-dev-server)  
50 - - defines a `start` script to run `webpack-dev-server`  
51 -- `webpack.config.js`: configuration file for bundling your js with webpack  
52 -  
53 -## License  
54 -  
55 -Licensed under either of  
56 -  
57 -* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)  
58 -* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)  
59 -  
60 -at your option.  
61 -  
62 -### Contribution  
63 -  
64 -Unless you explicitly state otherwise, any contribution intentionally  
65 -submitted for inclusion in the work by you, as defined in the Apache-2.0  
66 -license, shall be dual licensed as above, without any additional terms or  
67 -conditions.  
1 -// A dependency graph that contains any wasm must all be imported  
2 -// asynchronously. This `bootstrap.js` file does the single async import, so  
3 -// that no one else needs to worry about it again.  
4 -import("./index.js")  
5 - .catch(e => console.error("Error importing `index.js`:", e));  
1 -<!DOCTYPE html>  
2 -<html>  
3 - <head>  
4 - <meta charset="utf-8">  
5 - <title>wasm-game-of-life!</title>  
6 - <style>  
7 - body {  
8 - position: absolute;  
9 - top: 0;  
10 - left: 0;  
11 - width: 100%;  
12 - height: 100%;  
13 - display: flex;  
14 - flex-direction: column;  
15 - align-items: center;  
16 - justify-content: center;  
17 - }  
18 - </style>  
19 - </head>  
20 - <body>  
21 - <canvas id="view3d"></canvas>  
22 - <script src="./bootstrap.js"></script>  
23 - </body>  
24 -</html>  
1 -import { View3d } from "wasm-game-of-life";  
2 -import { memory } from "wasm-game-of-life/wasm_game_of_life_bg";  
3 -  
4 -// 3D canvas stuff  
5 -const view3d = View3d.new(300, 300);  
6 -  
7 -const view3d_canvas = document.getElementById("view3d");  
8 -view3d_canvas.width = view3d.width();  
9 -view3d_canvas.height = view3d.height();  
10 -const view3d_ctx = view3d_canvas.getContext('2d');  
11 -  
12 -const view3d_renderLoop = () => {  
13 - view3d.update();  
14 - drawView3d();  
15 -  
16 - requestAnimationFrame(view3d_renderLoop);  
17 -}  
18 -  
19 -const drawView3d = () => {  
20 - const view3d_imagePtr = view3d.image();  
21 - const view3d_image = new ImageData(  
22 - new Uint8ClampedArray( memory.buffer  
23 - , view3d.image()  
24 - , view3d.width() * view3d.height() * 4 )  
25 - , view3d.width()  
26 - , view3d.height() );  
27 -  
28 - view3d_ctx.putImageData(view3d_image, 0, 0);  
29 -}  
30 -  
31 -// start everything ...  
32 -view3d.update();  
33 -drawView3d();  
34 -requestAnimationFrame(view3d_renderLoop);  
This diff could not be displayed because it is too large.
1 -{  
2 - "name": "create-wasm-app",  
3 - "version": "0.1.0",  
4 - "description": "create an app to consume rust-generated wasm packages",  
5 - "main": "index.js",  
6 - "bin": {  
7 - "create-wasm-app": ".bin/create-wasm-app.js"  
8 - },  
9 - "scripts": {  
10 - "build": "webpack --config webpack.config.js",  
11 - "start": "webpack-dev-server"  
12 - },  
13 - "repository": {  
14 - "type": "git",  
15 - "url": "git+https://github.com/rustwasm/create-wasm-app.git"  
16 - },  
17 - "keywords": [  
18 - "webassembly",  
19 - "wasm",  
20 - "rust",  
21 - "webpack"  
22 - ],  
23 - "author": "Ashley Williams <ashley666ashley@gmail.com>",  
24 - "license": "(MIT OR Apache-2.0)",  
25 - "bugs": {  
26 - "url": "https://github.com/rustwasm/create-wasm-app/issues"  
27 - },  
28 - "homepage": "https://github.com/rustwasm/create-wasm-app#readme",  
29 - "devDependencies": {  
30 - "wasm-game-of-life": "file:../pkg",  
31 - "hello-wasm-pack": "^0.1.0",  
32 - "webpack": "^4.29.3",  
33 - "webpack-cli": "^3.1.0",  
34 - "webpack-dev-server": "^3.1.5",  
35 - "copy-webpack-plugin": "^5.0.0"  
36 - },  
37 - "dependencies": {  
38 - "wasm-game-of-life": "file:../pkg"  
39 - }  
40 -}  
1 -const CopyWebpackPlugin = require("copy-webpack-plugin");  
2 -const path = require('path');  
3 -  
4 -module.exports = {  
5 - entry: "./bootstrap.js",  
6 - output: {  
7 - path: path.resolve(__dirname, "dist"),  
8 - filename: "bootstrap.js",  
9 - },  
10 - mode: "development",  
11 - plugins: [  
12 - new CopyWebpackPlugin(['index.html'])  
13 - ],  
14 -};  
Please register or login to post a comment