mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-13 06:51:34 +00:00
Enable open-in-browser in the Game Of Life example (#69)
This commit is contained in:
committed by
Daniel Wirtz
parent
b7ef21950b
commit
89e8de5d82
1
examples/game-of-life/.gitignore
vendored
Normal file
1
examples/game-of-life/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules/
|
@ -6,6 +6,12 @@ An [AssemblyScript](http://assemblyscript.org) example. Continuously updates the
|
|||||||
Instructions
|
Instructions
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
You have to install the 'opn' package to be able to run the `npm browser` command
|
||||||
|
|
||||||
|
```
|
||||||
|
$> npm install
|
||||||
|
```
|
||||||
|
|
||||||
To build [assembly/game-of-life.ts](./assembly/game-of-life.ts) to an untouched and an optimized `.wasm` including their respective `.wat` representations, run:
|
To build [assembly/game-of-life.ts](./assembly/game-of-life.ts) to an untouched and an optimized `.wasm` including their respective `.wat` representations, run:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
"build": "npm run build:untouched && npm run build:optimized",
|
"build": "npm run build:untouched && npm run build:optimized",
|
||||||
"build:untouched": "asc assembly/game-of-life.ts -b game-of-life.untouched.wasm -t game-of-life.untouched.wat --validate --sourceMap --measure",
|
"build:untouched": "asc assembly/game-of-life.ts -b game-of-life.untouched.wasm -t game-of-life.untouched.wat --validate --sourceMap --measure",
|
||||||
"build:optimized": "asc -O assembly/game-of-life.ts -b game-of-life.optimized.wasm -t game-of-life.optimized.wat --validate --sourceMap --measure",
|
"build:optimized": "asc -O assembly/game-of-life.ts -b game-of-life.optimized.wasm -t game-of-life.optimized.wat --validate --sourceMap --measure",
|
||||||
"browser": "game-of-life.html"
|
"browser": "node server.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"opn": "^5.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
examples/game-of-life/server.js
Normal file
18
examples/game-of-life/server.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
var open = require('opn');
|
||||||
|
var http = require('http');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
const PORT = 9080;
|
||||||
|
|
||||||
|
fs.readFile('./game-of-life.html', function (err, html) {
|
||||||
|
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
http.createServer(function(request, response) {
|
||||||
|
response.writeHeader(200, {"Content-Type": "text/html"});
|
||||||
|
response.write(html);
|
||||||
|
response.end();
|
||||||
|
}).listen(PORT);
|
||||||
|
});
|
||||||
|
|
||||||
|
open('http://localhost:9080/game-of-life.html');
|
Reference in New Issue
Block a user