Skip to content

Commit 1b209b4

Browse files
authored
Merge pull request #14 from mbasso/0.6.0
Version 0.6.0
2 parents 58d43f5 + c259012 commit 1b209b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+3400
-1587
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ node_js:
44
- "7"
55
- "8"
66
- "9"
7+
- "10"
78
install: true
9+
sudo: required
10+
services:
11+
- docker
12+
before_install:
13+
- docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-incoming-64bit bash
814
script:
915
- npm install --ignore-scripts
16+
- docker exec -it emscripten make
1017
- npm run lint
1118
- npm run test:js
12-
- npm run build
1319
branches:
1420
only:
1521
- master
@@ -32,4 +38,5 @@ jobs:
3238
branches:
3339
only:
3440
- master
41+
if: tag =~ ^\d+\.\d+\.\d+
3542
after_success: echo "Website online"

CONTRIBUTING.md

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,51 +25,25 @@ git clone https://github.com/mbasso/asm-dom.git
2525

2626
#### Building asm-dom
2727

28-
Running the `build` task will create both a CommonJS module-per-module build and a UMD build.
28+
Running `make` will create both the C++ and the JS version of asm-dom, a CommonJS module-per-module build and a UMD build.
2929
```
30-
npm run build
30+
make
3131
```
3232

33-
To create just a CommonJS module-per-module build:
34-
35-
```
36-
npm run build:commonjs
37-
```
38-
39-
The result will be in the `lib` folder.
40-
41-
To create just a UMD build:
42-
```
43-
npm run build:umd
44-
npm run build:umd:min
45-
```
46-
47-
The result will be in the `dist` folder.
33+
The result will be in the `lib`, `es` and `dist` folder.
4834

4935
### Testing and Linting
5036

51-
To run both linting and testing at once, run the following:
52-
53-
```
54-
npm run check:src
55-
```
56-
57-
To only run linting:
58-
59-
```
60-
npm run lint
61-
```
62-
63-
To only run tests:
37+
To run linting:
6438

6539
```
66-
npm run test
40+
make lint
6741
```
6842

69-
To continuously watch and run tests, run the following:
43+
To run tests:
7044

7145
```
72-
npm run test:watch
46+
make test
7347
```
7448

7549
### Docs

Makefile

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# if you are using windows, comment line 5, 6 and 7 and uncomment line 8, 9 and 10
2+
# leave it as it was before committing as travis uses linux
3+
SRCDIR := src
4+
TESTDIR := test
5+
SRCS := $(shell find $(SRCDIR) -name "*.js")
6+
SRCSCPP := $(shell find $(SRCDIR) -name "*.cpp")
7+
TEST_FILES := $(shell find $(TESTDIR) -name "*.cpp")
8+
#SRCS := $(shell FORFILES /P $(SRCDIR) /S /M *.js /C "CMD /C ECHO @relpath")
9+
#SRCSCPP := $(shell FORFILES /P $(SRCDIR) /S /M *.cpp /C "CMD /C ECHO @relpath")
10+
#TEST_FILES := $(shell FORFILES /P $(TESTDIR) /S /M *.cpp /C "CMD /C ECHO @relpath")
11+
12+
ESDIR := es
13+
LIBDIR := lib
14+
ES := $(SRCS:$(SRCDIR)/%=$(ESDIR)/%)
15+
LIBS := $(SRCS:$(SRCDIR)/%=$(LIBDIR)/%)
16+
DISTDIR := dist
17+
DISTJS := $(DISTDIR)/js
18+
DISTCPP := $(DISTDIR)/cpp
19+
UMDJS := $(DISTJS)/asm-dom.js
20+
UMDCPP := $(DISTCPP)/asm-dom.js
21+
TESTCPP := test/cpp/app.asm.js
22+
COMPILED := compiled
23+
COMPILEDASMJS := $(COMPILED)/asmjs
24+
COMPILEDWASM := $(COMPILED)/wasm
25+
CPPDIR := cpp
26+
27+
TREE := \
28+
$(COMPILED) \
29+
$(COMPILEDASMJS) \
30+
$(COMPILEDWASM) \
31+
$(DISTDIR) \
32+
$(DISTJS) \
33+
$(DISTCPP) \
34+
$(ESDIR) \
35+
$(LIBDIR) \
36+
$(sort $(patsubst %/,%,$(dir $(ES)))) \
37+
$(sort $(patsubst %/,%,$(dir $(LIBS))))
38+
39+
FILES = \
40+
src/cpp/asm-dom.cpp \
41+
src/cpp/asm-dom-server.cpp
42+
43+
BC = compiled/asm-dom.bc
44+
45+
CFLAGS = \
46+
-O3 \
47+
--bind \
48+
-Wall \
49+
-Werror \
50+
-Wall \
51+
-Wno-deprecated \
52+
-Wno-parentheses \
53+
-Wno-format
54+
55+
WASM_OPTIONS = \
56+
-O3 \
57+
--bind \
58+
--memory-init-file 0 \
59+
--llvm-lto 3 \
60+
--llvm-opts 3 \
61+
--js-opts 1 \
62+
--closure 1 \
63+
-s MODULARIZE=1 \
64+
-s ALLOW_MEMORY_GROWTH=1 \
65+
-s AGGRESSIVE_VARIABLE_ELIMINATION=1 \
66+
-s ABORTING_MALLOC=1 \
67+
-s NO_EXIT_RUNTIME=1 \
68+
-s NO_FILESYSTEM=1 \
69+
-s DISABLE_EXCEPTION_CATCHING=2 \
70+
-s BINARYEN=1 \
71+
-s EXPORTED_RUNTIME_METHODS=[\'UTF8ToString\'] \
72+
-s BINARYEN_TRAP_MODE=\'allow\'
73+
74+
ASMJS_OPTIONS = \
75+
-O3 \
76+
--bind \
77+
--memory-init-file 0 \
78+
--llvm-lto 3 \
79+
--llvm-opts 3 \
80+
--js-opts 1 \
81+
--closure 1 \
82+
-s MODULARIZE=1 \
83+
-s AGGRESSIVE_VARIABLE_ELIMINATION=1 \
84+
-s ELIMINATE_DUPLICATE_FUNCTIONS=1 \
85+
-s ABORTING_MALLOC=1 \
86+
-s NO_EXIT_RUNTIME=1 \
87+
-s NO_FILESYSTEM=1 \
88+
-s DISABLE_EXCEPTION_CATCHING=2 \
89+
-s EXPORTED_RUNTIME_METHODS=[\'UTF8ToString\'] \
90+
-s WASM=0
91+
92+
.PHONY: all install clean lint test test_js test_watch build
93+
94+
all: build
95+
96+
install:
97+
npm install
98+
99+
clean:
100+
npx rimraf $(DISTDIR) $(LIBDIR) $(ESDIR) $(CPPDIR) .nyc_output $(COMPILED) $(TESTCPP)
101+
102+
lint:
103+
npx eslint src test build
104+
105+
test: $(COMPILEDASMJS)/asm-dom.asm.js $(COMPILEDWASM)/asm-dom.js $(TESTCPP) test_js
106+
107+
test_js:
108+
npx cross-env BABEL_ENV=commonjs nyc --require babel-register --require ./test/setup.js mocha --recursive
109+
110+
build: compiled/asm-dom.a $(BC) compiled/asm-dom.o $(COMPILEDASMJS)/asm-dom.asm.js $(COMPILEDWASM)/asm-dom.js $(TESTCPP) $(LIBS) $(ES) $(UMDJS) $(UMDCPP)
111+
npx ncp $(SRCDIR)/cpp $(CPPDIR)
112+
npx ncp $(DISTCPP) $(CPPDIR)
113+
npx ncp $(LIBDIR)/cpp $(CPPDIR)
114+
115+
$(TESTCPP): $(SRCSCPP) $(TEST_FILES)
116+
emcc \
117+
-DASMDOM_TEST \
118+
$(CFLAGS) \
119+
$(ASMJS_OPTIONS) \
120+
$(FILES) \
121+
$(TEST_FILES) \
122+
-o $@
123+
124+
.SECONDEXPANSION:
125+
$(COMPILED)/asm-dom.%: $(SRCSCPP) | $$(@D)
126+
emcc \
127+
-DASMDOM_JS_SIDE \
128+
$(CFLAGS) \
129+
$(FILES) \
130+
src/js/index.cpp \
131+
-o $@
132+
133+
$(COMPILEDASMJS)/asm-dom.asm.js: $(BC) | $$(@D)
134+
emcc \
135+
$(ASMJS_OPTIONS) \
136+
$(BC) \
137+
-o $@
138+
139+
$(COMPILEDWASM)/asm-dom.js: $(BC) | $$(@D)
140+
emcc \
141+
$(WASM_OPTIONS) \
142+
$(BC) \
143+
-o $@
144+
145+
$(ESDIR)/%: $(SRCDIR)/% | $$(@D)
146+
npx cross-env BABEL_ENV=es babel $< --out-file $@
147+
148+
$(LIBDIR)/%: $(SRCDIR)/% | $$(@D)
149+
npx cross-env BABEL_ENV=commonjs babel $< --out-file $@
150+
151+
$(UMDJS): $(SRCS) | $$(@D)
152+
npx cross-env BABEL_ENV=commonjs webpack --env.prod src/js/index.js $@
153+
154+
$(UMDCPP): $(SRCS) | $$(@D)
155+
npx cross-env BABEL_ENV=commonjs webpack --env.prod --env.cpp src/cpp/index.js $@
156+
157+
$(TREE): %:
158+
npx mkdirp $@

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ Also, here is the list of the online Demos:
127127

128128
## Roadmap
129129

130-
- [ ] create asm-dom boilerplate
131130
- [ ] Thunks support
132131
- [ ] asm-dom aims to be even more powerful with [GC/DOM Integration](http://webassembly.org/docs/future-features/). Unfortunately this is a future feature 🦄, so, we have to be patient and wait a bit.
133132

benchmarks/README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,24 @@ There are 4 tests at the moment:
1616

1717
- `create nodes`: this test create 700 nodes (100 nodes with 3 children, the last of which has 3 more children). Please note that, as we said before, **in the case of asm-dom, this test creates but also destroys the nodes**. While, in the case of snabbdom, the deletion is managed by the garbage collector and it is not measured.
1818

19-
- `create and diff equal nodes`: this test runs the `patch` function 100 times with 2 equal nodes (2 nodes with 100 children, each of them has 1 child), so, the DOM will be not updated.
19+
- `diff equal nodes`: this test runs the `patch` function 100 times with 2 equal nodes (2 nodes with 100 children, each of them has 1 child), so, the DOM will be not updated.
2020

21-
- `create and diff different nodes`: this test runs the `patch` function 100 times with 2 nodes with different attributes (2 nodes with 100 children, each of them has 1 child), so, the DOM will be updated.
21+
- `diff different nodes`: this test runs the `patch` function 100 times with 2 nodes with different attributes (2 nodes with 100 children, each of them has 1 child), so, the DOM will be updated.
2222

23-
- `create and add/remove nodes`: this test runs the `patch` function 100 times with 2 nodes, one with 100 children and one without children.
23+
- `add/remove nodes`: this test runs the `patch` function 100 times with 2 nodes, one with 100 children and one without children.
2424

25-
Here you can find screenshots of the tests (lower is better) runned on a MacBook Pro (Retina, 13-inch, Late 2013), Processor 2,4 GHz Intel Core i5, Memory 8 GB 1600 MHz DDR3:
25+
Here you can find the tests (lower is better) runned on a MacBook Pro (Retina, 13-inch, Late 2013), Processor 2,4 GHz Intel Core i5, Memory 8 GB 1600 MHz DDR3:
2626

27-
![Benchmarks](benchmarks.jpg)
27+
### Firefox 59.0.2 (64 bit)
28+
29+
| library | create nodes | diff equal nodes | diff different nodes | add/remove nodes |
30+
| --- | --- | --- | --- | --- |
31+
| asm-dom | 0.0000 | 2.0000 | 34.0000 | 32.0000 |
32+
| snabbbom | 0.0000 | 12.0000 | 42.0000 | 44.0000 |
33+
34+
### Chrome 66.0.3359.181 (64-bit)
35+
36+
| library | create nodes | diff equal nodes | diff different nodes | add/remove nodes |
37+
| --- | --- | --- | --- | --- |
38+
| asm-dom | 0.9000 | 3.2000 | 16.4000 | 15.1000 |
39+
| snabbbom | 0.5000 | 4.6000 | 8.7000 | 13.3000 |

benchmarks/benchmarks.jpg

-46.2 KB
Binary file not shown.

benchmarks/compiled/app.bc

33.5 KB
Binary file not shown.

benchmarks/compiled/app.o

-36 Bytes
Binary file not shown.

benchmarks/compiled/asmjs/app.asm.js

Lines changed: 69 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)