Skip to content

Commit

Permalink
Merge branch 'master' into 0.6.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	benchmarks/compiled/app.bc
#	benchmarks/compiled/app.o
#	benchmarks/compiled/asmjs/app.asm.js
#	benchmarks/compiled/wasm/app.js
#	benchmarks/compiled/wasm/app.wasm
#	compiled/asm-dom.a
#	compiled/asm-dom.bc
#	compiled/asm-dom.o
#	compiled/asmjs/asm-dom.asm.js
#	compiled/wasm/asm-dom.js
#	compiled/wasm/asm-dom.wasm
#	dist/js/0.asm-dom.js
#	dist/js/0.asm-dom.js.gz
#	dist/js/1.asm-dom.js
#	dist/js/1.asm-dom.js.gz
#	dist/js/asm-dom.js
#	src/js/index.js
#	test/cpp/app.asm.js
  • Loading branch information
mbasso committed Apr 15, 2018
2 parents 5adff36 + 58d43f5 commit 901e53f
Show file tree
Hide file tree
Showing 57 changed files with 635 additions and 701 deletions.
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
**/node_modules/**
**/src/helpers/**
**/compiled/**
**/test/**/*.asm.js
**/src/js/prefix.js
**/src/js/postfix.js
**/test/**/*.asm.js
4 changes: 1 addition & 3 deletions benchmarks/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**/dist/**
**/node_modules/**
**/compiled/**
**/src/prefix.js
**/src/postfix.js
**/compiled/**
99 changes: 99 additions & 0 deletions benchmarks/compiled/asmjs/app.asm.js

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions benchmarks/compiled/wasm/app.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"clean": "rimraf lib dist es .nyc_output compiled",
"compile": "npm run clean && mkdir -p compiled && npm run compile:cpp && npm run compile:asmjs && npm run compile:wasm",
"compile:cpp": "emcc -O3 -Wall -Werror --bind ../src/cpp/asm-dom.cpp src/index.cpp -o compiled/app.bc && emcc -O3 -Wall -Werror --bind src/index.cpp -o compiled/app.o",
"compile:asmjs": "mkdir -p compiled/asmjs && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --js-opts 1 --closure 1 --pre-js src/prefix.js --post-js src/postfix.js -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 compiled/app.bc -o compiled/asmjs/app.asm.js",
"compile:wasm": "mkdir -p compiled/wasm && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --js-opts 1 --closure 1 --pre-js src/prefix.js --post-js src/postfix.js -s ALLOW_MEMORY_GROWTH=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 -s BINARYEN=1 -s \"BINARYEN_TRAP_MODE='allow'\" compiled/app.bc -o compiled/wasm/app.js",
"compile:asmjs": "mkdir -p compiled/asmjs && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --js-opts 1 --closure 1 -s MODULARIZE=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 compiled/app.bc -o compiled/asmjs/app.asm.js",
"compile:wasm": "mkdir -p compiled/wasm && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --js-opts 1 --closure 1 -s MODULARIZE=1 -s ALLOW_MEMORY_GROWTH=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 -s BINARYEN=1 -s \"BINARYEN_TRAP_MODE='allow'\" compiled/app.bc -o compiled/wasm/app.js",
"start": "npm run compile && webpack-dev-server --env.dev",
"build": "npm run compile && npm run build:webpack",
"build:webpack": "cross-env BABEL_ENV=commonjs webpack --env.prod src/index.js",
Expand Down
9 changes: 7 additions & 2 deletions benchmarks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ const config = {};
import('../compiled/wasm/app.wasm')
.then((wasm) => {
config.wasmBinary = new Uint8Array(wasm);
return import('../compiled/wasm/app.js');
return new Promise((resolve) => {
import('../compiled/wasm/app.js').then(factory => {
const asmDom = factory(config);
delete asmDom.then;
resolve(asmDom);
});
});
})
.then(Module => Module(config))
.then((app) => {
const asmdomCpp = app;
window.asmdomCpp = asmdomCpp;
Expand Down
3 changes: 0 additions & 3 deletions benchmarks/src/postfix.js

This file was deleted.

11 changes: 0 additions & 11 deletions benchmarks/src/prefix.js

This file was deleted.

2 changes: 1 addition & 1 deletion benchmarks/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = env => {
loaders: [{
test: /\.js$/,
loaders: ['babel-loader'],
exclude: [/node_modules/, /compiled/, /\.asm\.js$/, /prefix\.js$/, /postfix\.js$/],
exclude: [/node_modules/, /compiled/, /\.asm\.js$/],
},
{
test: /\.wasm$/,
Expand Down
Binary file modified compiled/asm-dom.a
Binary file not shown.
Binary file modified compiled/asm-dom.bc
Binary file not shown.
Binary file modified compiled/asm-dom.o
Binary file not shown.
259 changes: 107 additions & 152 deletions compiled/asmjs/asm-dom.asm.js

Large diffs are not rendered by default.

194 changes: 96 additions & 98 deletions compiled/wasm/asm-dom.js

Large diffs are not rendered by default.

Binary file modified compiled/wasm/asm-dom.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/js/0.asm-dom.js

Large diffs are not rendered by default.

Binary file modified dist/js/0.asm-dom.js.br
Binary file not shown.
Binary file modified dist/js/0.asm-dom.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/js/1.asm-dom.js

Large diffs are not rendered by default.

Binary file modified dist/js/1.asm-dom.js.br
Binary file not shown.
Binary file modified dist/js/1.asm-dom.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/js/asm-dom.js

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions docs/cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ and compile it using [emscripten (emcc cli)](http://kripken.github.io/emscripten

After the compilation you can import your app:

- if you are using webpack, you can see our [example]((https://github.com/mbasso/asm-dom/tree/master/examples/todomvc%20-%20cpp/src/index.js)). In order to import it as a module we have used 2 extra files with emcc `--pre-js` (`prefix.js`) and `--post-js` (`postfix.js`).
- if you are using webpack, you can see our [example]((https://github.com/mbasso/asm-dom/tree/master/examples/todomvc%20-%20cpp/src/index.js)).

- If you want to use wasm without webpack, you can see [this](https://gist.github.com/kripken/59c67556dc03bb6d57052fedef1e61ab) gist.

If you are using [babel](https://babeljs.io/), please make sure to ignore the compiled files, the prefix and suffix:
If you are using [babel](https://babeljs.io/), please make sure to ignore the compiled files:

```js
{
Expand All @@ -184,9 +184,7 @@ If you are using [babel](https://babeljs.io/), please make sure to ignore the co
exclude: [
/node_modules/,
/compiled/, // folder that contains the compiled code (wasm and asmjs)
/\.asm\.js$/, // ignore all .asm.js files
/prefix\.js$/, // ignore --pre-js
/postfix\.js$/ // ignore --post-js
/\.asm\.js$/ // ignore all .asm.js files
],
}
```
Expand Down Expand Up @@ -277,7 +275,10 @@ VNode* vnode2 = h("div",
Props {
{"foo", emscripten::val(7)} // node.foo = 7
},
Children {
Callbacks {
// function pointer
{"ondblclick", onDblClick},
// lambda
{"onclick", [](emscripten::val e) -> bool {
// do stuff...
return true;
Expand Down
5 changes: 4 additions & 1 deletion docs/h.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ VNode* vnode2 = h("div",
Props {
{"foo", emscripten::val(7)} // node.foo = 7
},
Children {
Callbacks {
// function pointer
{"ondblclick", onDblClick},
// lambda
{"onclick", [](emscripten::val e) -> bool {
// do stuff...
return true;
Expand Down
8 changes: 3 additions & 5 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ and compile it using [emscripten (emcc cli)](http://kripken.github.io/emscripten

After the compilation you can import your app:

- if you are using webpack, you can see our [example]((https://github.com/mbasso/asm-dom/tree/master/examples/todomvc%20-%20cpp/src/index.js)). In order to import it as a module we have used 2 extra files with emcc `--pre-js` (`prefix.js`) and `--post-js` (`postfix.js`).
- if you are using webpack, you can see our [example]((https://github.com/mbasso/asm-dom/tree/master/examples/todomvc%20-%20cpp/src/index.js)).

- If you want to use wasm without webpack, you can see [this](https://gist.github.com/kripken/59c67556dc03bb6d57052fedef1e61ab) gist.

If you are using [babel](https://babeljs.io/), please make sure to ignore the compiled files, the prefix and suffix:
If you are using [babel](https://babeljs.io/), please make sure to ignore the compiled files:

```js
{
Expand All @@ -76,9 +76,7 @@ If you are using [babel](https://babeljs.io/), please make sure to ignore the co
exclude: [
/node_modules/,
/compiled/, // folder that contains the compiled code (wasm and asmjs)
/\.asm\.js$/, // ignore all .asm.js files
/prefix\.js$/, // ignore --pre-js
/postfix\.js$/ // ignore --post-js
/\.asm\.js$/ // ignore all .asm.js files
],
}
```
Expand Down
4 changes: 1 addition & 3 deletions examples/todomvc - cpp/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**/dist/**
**/node_modules/**
**/compiled/**
**/src/prefix.js
**/src/postfix.js
**/compiled/**
4 changes: 2 additions & 2 deletions examples/todomvc - cpp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"clean": "rimraf lib dist es .nyc_output compiled",
"compile": "npm run clean && mkdir -p compiled && npm run compile:cpp && npm run compile:asmjs && npm run compile:wasm",
"compile:cpp": "emcc -O3 -Wall -Werror --bind ../../src/cpp/asm-dom.cpp src/index.cpp -o compiled/app.bc && emcc -O3 -Wall -Werror --bind src/index.cpp -o compiled/app.o",
"compile:asmjs": "mkdir -p compiled/asmjs && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --closure 1 --pre-js src/prefix.js --post-js src/postfix.js -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 compiled/app.bc -o compiled/asmjs/app.asm.js",
"compile:wasm": "mkdir -p compiled/wasm && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --closure 1 --pre-js src/prefix.js --post-js src/postfix.js -s ALLOW_MEMORY_GROWTH=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 -s BINARYEN=1 -s \"BINARYEN_TRAP_MODE='allow'\" compiled/app.bc -o compiled/wasm/app.js",
"compile:asmjs": "mkdir -p compiled/asmjs && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --closure 1 -s MODULARIZE=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 compiled/app.bc -o compiled/asmjs/app.asm.js",
"compile:wasm": "mkdir -p compiled/wasm && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --closure 1 -s MODULARIZE=1 -s ALLOW_MEMORY_GROWTH=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 -s BINARYEN=1 -s \"BINARYEN_TRAP_MODE='allow'\" compiled/app.bc -o compiled/wasm/app.js",
"start": "npm run compile && webpack-dev-server --env.dev",
"build": "npm run compile && npm run build:webpack",
"build:webpack": "cross-env BABEL_ENV=commonjs webpack --env.prod src/index.js",
Expand Down
30 changes: 14 additions & 16 deletions examples/todomvc - cpp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import '../../../src/cpp/';
(() => {
const config = {};

new Promise(
(resolve) => {
if ('WebAssembly' in window) {
import('../compiled/wasm/app.wasm')
.then((wasm) => {
config.wasmBinary = new Uint8Array(wasm);
return import('../compiled/wasm/app.js');
})
.then(resolve);
} else {
import('../compiled/asmjs/app.asm.js').then(resolve);
}
},
)
.then(Module => Module(config));
})();
const instantiate = (Module) => {
Module(config);
};

if ('WebAssembly' in window) {
import('../compiled/wasm/app.wasm')
.then((wasm) => {
config.wasmBinary = new Uint8Array(wasm);
return import('../compiled/wasm/app.js');
})
.then(instantiate);
} else {
import('../compiled/asmjs/app.asm.js').then(instantiate);
}
})();
3 changes: 0 additions & 3 deletions examples/todomvc - cpp/src/postfix.js

This file was deleted.

11 changes: 0 additions & 11 deletions examples/todomvc - cpp/src/prefix.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/todomvc - cpp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = env => {
loaders: [{
test: /\.js$/,
loaders: ['babel-loader'],
exclude: [/node_modules/, /compiled/, /\.asm\.js$/, /prefix\.js$/, /postfix\.js$/],
exclude: [/node_modules/, /compiled/, /\.asm\.js$/],
},
{
test: /\.wasm$/,
Expand Down
4 changes: 1 addition & 3 deletions examples/todomvc - cpx/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**/dist/**
**/node_modules/**
**/compiled/**
**/src/prefix.js
**/src/postfix.js
**/compiled/**
4 changes: 2 additions & 2 deletions examples/todomvc - cpx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"compile": "npm run clean && mkdir -p compiled && npm run compile:cpx && npm run compile:cpp && npm run compile:asmjs && npm run compile:wasm",
"compile:cpx": "mkdir -p temp && gccx src",
"compile:cpp": "emcc -O3 -Wall -Werror --bind ../../src/cpp/asm-dom.cpp temp/index.cpp -o compiled/app.bc && emcc -O3 -Wall -Werror --bind temp/index.cpp -o compiled/app.o",
"compile:asmjs": "mkdir -p compiled/asmjs && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --closure 1 --pre-js src/prefix.js --post-js src/postfix.js -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 compiled/app.bc -o compiled/asmjs/app.asm.js",
"compile:wasm": "mkdir -p compiled/wasm && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --closure 1 --pre-js src/prefix.js --post-js src/postfix.js -s ALLOW_MEMORY_GROWTH=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 -s BINARYEN=1 -s \"BINARYEN_TRAP_MODE='allow'\" compiled/app.bc -o compiled/wasm/app.js",
"compile:asmjs": "mkdir -p compiled/asmjs && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --closure 1 -s MODULARIZE=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 compiled/app.bc -o compiled/asmjs/app.asm.js",
"compile:wasm": "mkdir -p compiled/wasm && emcc -O3 --bind --memory-init-file 0 --llvm-lto 3 --llvm-opts 3 --js-opts 1 --closure 1 -s MODULARIZE=1 -s ALLOW_MEMORY_GROWTH=1 -s \"EXPORTED_RUNTIME_METHODS=['UTF8ToString']\" -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ABORTING_MALLOC=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=2 -s BINARYEN=1 -s \"BINARYEN_TRAP_MODE='allow'\" compiled/app.bc -o compiled/wasm/app.js",
"start": "npm run compile && webpack-dev-server --env.dev",
"build": "npm run compile && npm run build:webpack",
"build:webpack": "cross-env BABEL_ENV=commonjs webpack --env.prod src/index.js",
Expand Down
30 changes: 14 additions & 16 deletions examples/todomvc - cpx/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import '../../../src/cpp/';
(() => {
const config = {};

new Promise(
(resolve) => {
if ('WebAssembly' in window) {
import('../compiled/wasm/app.wasm')
.then((wasm) => {
config.wasmBinary = new Uint8Array(wasm);
return import('../compiled/wasm/app.js');
})
.then(resolve);
} else {
import('../compiled/asmjs/app.asm.js').then(resolve);
}
},
)
.then(Module => Module(config));
})();
const instantiate = (Module) => {
Module(config);
};

if ('WebAssembly' in window) {
import('../compiled/wasm/app.wasm')
.then((wasm) => {
config.wasmBinary = new Uint8Array(wasm);
return import('../compiled/wasm/app.js');
})
.then(instantiate);
} else {
import('../compiled/asmjs/app.asm.js').then(instantiate);
}
})();
3 changes: 0 additions & 3 deletions examples/todomvc - cpx/src/postfix.js

This file was deleted.

11 changes: 0 additions & 11 deletions examples/todomvc - cpx/src/prefix.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/todomvc - cpx/src/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = env => {
loaders: [{
test: /\.js$/,
loaders: ['babel-loader'],
exclude: [/node_modules/, /compiled/, /\.asm\.js$/, /prefix\.js$/, /postfix\.js$/],
exclude: [/node_modules/, /compiled/, /\.asm\.js$/],
},
{
test: /\.wasm$/,
Expand Down
2 changes: 1 addition & 1 deletion examples/todomvc - cpx/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = env => {
loaders: [{
test: /\.js$/,
loaders: ['babel-loader'],
exclude: [/node_modules/, /compiled/, /\.asm\.js$/, /prefix\.js$/, /postfix\.js$/],
exclude: [/node_modules/, /compiled/, /\.asm\.js$/],
},
{
test: /\.wasm$/,
Expand Down
4 changes: 1 addition & 3 deletions examples/todomvc - ssr/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**/dist/**
**/node_modules/**
**/compiled/**
**/src/prefix.js
**/src/postfix.js
**/compiled/**
Loading

0 comments on commit 901e53f

Please sign in to comment.