Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Wasmer Js API #2460

Merged
merged 112 commits into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
430113d
Added basic example of Wasmer-js
syrusakbary Jun 22, 2021
caacec6
Updated README
syrusakbary Jun 22, 2021
ea4682f
Simplified README
syrusakbary Jun 22, 2021
45053d6
Improved READMEs
syrusakbary Jun 22, 2021
90f8f4b
Improved instrucitons on how to compile to wasm
syrusakbary Jun 22, 2021
82e2cf8
Improved instance test
syrusakbary Jun 22, 2021
f52a44d
Added support for calling functions
syrusakbary Jun 22, 2021
91b2427
Added partial support for function imports
syrusakbary Jun 23, 2021
b326903
Imported native functions now work!
syrusakbary Jun 23, 2021
6a40185
Added proof of concept of function bindings
syrusakbary Jun 23, 2021
25907c4
Enable ptr
syrusakbary Jun 23, 2021
6696877
Improved wasmer types
syrusakbary Jun 23, 2021
3d841a6
Improved function usage
syrusakbary Jun 23, 2021
0db591a
Skip wasm-opt for now
syrusakbary Jun 23, 2021
756a2a2
Added ptr api
syrusakbary Jun 24, 2021
1fae2ed
Make all tests pass
syrusakbary Jun 24, 2021
5cc350f
Simplified API
syrusakbary Jun 24, 2021
6d72966
Use wasmer_js for now in the derive
syrusakbary Jun 24, 2021
d300a1b
Merge branch 'features-cell' into js-api
syrusakbary Jun 24, 2021
5451d71
Fix syntax again
syrusakbary Jun 25, 2021
0d84e33
Updated js-api to latest
syrusakbary Jul 12, 2021
d25b2cb
Improved compilation
syrusakbary Jul 12, 2021
2c75468
Improved type reflection
syrusakbary Jul 13, 2021
ee006c3
Improved memory type
syrusakbary Jul 13, 2021
447a60b
Fix typo
syrusakbary Jul 13, 2021
38ed46b
Added reflection API
syrusakbary Jul 13, 2021
92755a0
Removed unused code
syrusakbary Jul 13, 2021
1154601
Fixed linting
syrusakbary Jul 13, 2021
9b76bae
Added Wasmer-JS workflow
syrusakbary Jul 13, 2021
87ae2ff
Improved memory & function comparison
syrusakbary Jul 13, 2021
226f985
Improved tests readability
syrusakbary Jul 13, 2021
f46b01c
Improved tests clarity
syrusakbary Jul 13, 2021
a55f157
Added partial support for tables
syrusakbary Jul 13, 2021
83d061d
Fixed lints
syrusakbary Jul 13, 2021
c6d25ff
Improved API further
syrusakbary Jul 13, 2021
a4d4b3f
Commented main file
syrusakbary Jul 13, 2021
0735a5e
Added support for Globals
syrusakbary Jul 13, 2021
e674afe
Added extra test
syrusakbary Jul 13, 2021
75b7554
Fixed memory grow
syrusakbary Jul 13, 2021
07e7ed5
Improved README
syrusakbary Jul 13, 2021
4a21652
Improved size guides
syrusakbary Jul 13, 2021
70eaf70
Added support for dynamic functions
syrusakbary Jul 14, 2021
4a3be47
Merge branch 'js-api' of github.com:wasmerio/wasmer into js-api
syrusakbary Jul 14, 2021
e7670b5
Added full support for dynamic functions
syrusakbary Jul 14, 2021
917667a
Native function now works fully
syrusakbary Jul 14, 2021
cb77e65
Fixed linting
syrusakbary Jul 14, 2021
47ffb54
Fixed lint and errors
syrusakbary Jul 14, 2021
1729ab9
Trying to fix lint issues
syrusakbary Jul 14, 2021
bd2cc94
Cleaned unused code
syrusakbary Jul 14, 2021
d5789aa
Fixed tests added extra native function test
syrusakbary Jul 14, 2021
f01c9af
Fixed lint
syrusakbary Jul 14, 2021
841509c
Fixed lint again
syrusakbary Jul 14, 2021
b9b678c
Merge branch 'master' into js-api
syrusakbary Jul 14, 2021
ecbd026
Added full support for custom RuntimeErrors. Fixed warnings
syrusakbary Jul 14, 2021
bfbd088
Added custom error test
syrusakbary Jul 14, 2021
66ff6b4
Apply suggestions from code review
syrusakbary Jul 14, 2021
8c7ba37
Uncomment code
syrusakbary Jul 14, 2021
aedadf6
Merge branch 'js-api' of github.com:wasmerio/wasmer into js-api
syrusakbary Jul 14, 2021
983190c
Fixed issues
syrusakbary Jul 14, 2021
93b8411
Improved code based on feedback
syrusakbary Jul 14, 2021
40df445
Improved traps, now fully working
syrusakbary Jul 14, 2021
27b2218
Fix wasmer-derive to optionally depend from wasmer_js
syrusakbary Jul 14, 2021
fb461c3
Fixed lint
syrusakbary Jul 14, 2021
8047e3e
Addressed feedback
syrusakbary Jul 14, 2021
ed9134a
Improved traps
syrusakbary Jul 15, 2021
a2bae12
Added extra instruction for wasmer-js
syrusakbary Jul 15, 2021
7195a9c
Fixed errors and warnings
syrusakbary Jul 15, 2021
88ff6b8
Improved wasmer-js debugging
syrusakbary Jul 15, 2021
fe04ea8
Added WebAssembly Module converter
syrusakbary Jul 16, 2021
98481f5
Move ModuleInfo to wasmer-types
syrusakbary Jul 16, 2021
be54645
Use types Module
syrusakbary Jul 16, 2021
7d63e09
Removed duplicated iterator
syrusakbary Jul 16, 2021
76ea96a
[compiler] simplified codebase (we can factor this out)
syrusakbary Jul 16, 2021
c8bd30d
Simplified polyfill
syrusakbary Jul 16, 2021
5746be8
Revert "[compiler] simplified codebase (we can factor this out)"
syrusakbary Jul 16, 2021
dcd9105
Uncommented test
syrusakbary Jul 16, 2021
e9a4da2
Fixed import
syrusakbary Jul 17, 2021
32d15be
Update README.md
syrusakbary Jul 17, 2021
3e89b7d
Fixed syntax
syrusakbary Jul 17, 2021
a589020
Update lib/js-api/README.md
syrusakbary Jul 17, 2021
2912d20
Update lib/js-api/src/cell.rs
syrusakbary Jul 17, 2021
1e67623
Last round of fixes
syrusakbary Jul 17, 2021
c6b5fe0
Fixed linting
syrusakbary Jul 19, 2021
0537b63
Merge branch 'master' into js-api
syrusakbary Jul 19, 2021
6de3272
Comment problematic tests
syrusakbary Jul 19, 2021
0edd115
Merge branch 'js-api' of github.com:wasmerio/wasmer into js-api
syrusakbary Jul 19, 2021
48d32f2
Commented failing test
syrusakbary Jul 22, 2021
4ae1b77
Apply suggestions from code review
syrusakbary Jul 22, 2021
c398cae
Fix breaking change
syrusakbary Jul 22, 2021
14bd3cb
Update lib/js-api/src/externals/function.rs
syrusakbary Jul 22, 2021
17cf814
Update lib/js-api/tests/externals.rs
syrusakbary Jul 22, 2021
290358d
Update lib/js-api/src/externals/function.rs
syrusakbary Jul 22, 2021
14c75e7
Fixed RuntimeError start when instantiating wasmer-js
syrusakbary Jul 22, 2021
3117db4
Improved comments
syrusakbary Jul 22, 2021
e429b57
Fix linting
syrusakbary Jul 23, 2021
00a23f0
Merge branch 'js-api' of github.com:wasmerio/wasmer into js-api
syrusakbary Jul 23, 2021
6b2ec72
Added support for no-std
syrusakbary Jul 23, 2021
b302848
feat(api) Merge `js-api` into `api`.
Hywan Jul 23, 2021
9bc0910
feat(api) Remove all references to `wasmer-js`.
Hywan Jul 23, 2021
0ea1993
fix(api) Fix `cargo fmt`.
Hywan Jul 23, 2021
8a5caa3
feat(api) Use the same version of `hashbrown` than what we have in deps.
Hywan Jul 23, 2021
36c4f92
fix(api) Use the `sys` feature when no default features is enabled.
Hywan Jul 23, 2021
5bfd45e
doc(api) Update documentation.
Hywan Jul 23, 2021
fcc9e74
feat(api) Set crate-type only if `js` feature is turned on.
Hywan Jul 23, 2021
bc4ffb4
doc(api) Update the `README.md`.
Hywan Jul 23, 2021
3239fe4
doc(api) Improve the crate documentation.
Hywan Jul 23, 2021
9a5a10f
doc(api) Polish.
Hywan Jul 23, 2021
d3930be
Merge pull request #2489 from wasmerio/js-api-into-api
syrusakbary Jul 23, 2021
3e04015
Fixed serde dependency
syrusakbary Jul 23, 2021
1fa19a2
Improved styling for readability
syrusakbary Jul 23, 2021
58350e3
Improved wasmer api in js
syrusakbary Jul 23, 2021
124672e
Added std to js-default
syrusakbary Jul 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/js.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
branches:
- 'master'
- 'staging'
- 'trying'
tags:
# this is _not_ a regex, see: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- '[0-9]+.[0-9]+.[0-9]+*'

name: wasmer-js tests

env:
RUST_BACKTRACE: 1

jobs:
wasmer-js:
name: wasmer-js
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Test wasmer-js
run: make test-js
syrusakbary marked this conversation as resolved.
Show resolved Hide resolved
58 changes: 57 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,10 @@ test-packages:
cargo test --manifest-path lib/compiler-singlepass/Cargo.toml --release --no-default-features --features=std
cargo test --manifest-path lib/cli/Cargo.toml $(compiler_features) --release

test-js:
syrusakbary marked this conversation as resolved.
Show resolved Hide resolved
cd lib/api && wasm-pack test --node -- --no-default-features --features js-default,wat


#####
#
# Testing compilers.
Expand Down
2 changes: 2 additions & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ composed of a set of crates. We can group them as follows:
programatically through the `wasmer` crate,
* `c-api` — The public C API exposes everything a C user needs to use
Wasmer programatically,
* `js-api` — The public JavaScript API exposes everything a user needs to run Wasmer
in a client like a browser or on a server like NodeJS or Deno,
* `cache` — The traits and types to cache compiled WebAssembly
modules,
* `cli` — The Wasmer CLI itself,
Expand Down
178 changes: 114 additions & 64 deletions lib/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,96 +10,146 @@ license = "MIT"
readme = "README.md"
edition = "2018"

#####
# This crate comes in 2 major flavors:
#
# - `sys`, where `wasmer` will be compiled to a native executable
# which provides compilers, engines, a full VM etc.
# - `js`, where `wasmer` will be compiled to WebAssembly to run in a
# JavaScript host.
#####

# Shared dependencies.
[dependencies]
# - Mandatory shared dependencies.
indexmap = { version = "1.6", features = ["serde-1"] }
cfg-if = "1.0"
thiserror = "1.0"
more-asserts = "0.2"
# - Optional shared dependencies.
wat = { version = "1.0", optional = true }

# Dependencies and Development Dependencies for `sys`.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# - Mandatory dependencies for `sys`.
wasmer-vm = { path = "../vm", version = "2.0.0" }
wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "2.0.0", optional = true }
wasmer-compiler-cranelift = { path = "../compiler-cranelift", version = "2.0.0", optional = true }
wasmer-compiler-llvm = { path = "../compiler-llvm", version = "2.0.0", optional = true }
wasmer-compiler = { path = "../compiler", version = "2.0.0" }
wasmer-derive = { path = "../derive", version = "2.0.0" }
wasmer-engine = { path = "../engine", version = "2.0.0" }
wasmer-engine-universal = { path = "../engine-universal", version = "2.0.0", optional = true }
wasmer-engine-dylib = { path = "../engine-dylib", version = "2.0.0", optional = true }
wasmer-types = { path = "../types", version = "2.0.0" }
indexmap = { version = "1.6", features = ["serde-1"] }
cfg-if = "1.0"
wat = { version = "1.0", optional = true }
thiserror = "1.0"
more-asserts = "0.2"
target-lexicon = { version = "0.12", default-features = false }
loupe = "0.1"

[target.'cfg(target_os = "windows")'.dependencies]
# - Optional dependencies for `sys`.
wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "2.0.0", optional = true }
wasmer-compiler-cranelift = { path = "../compiler-cranelift", version = "2.0.0", optional = true }
wasmer-compiler-llvm = { path = "../compiler-llvm", version = "2.0.0", optional = true }
wasmer-engine-universal = { path = "../engine-universal", version = "2.0.0", optional = true }
wasmer-engine-dylib = { path = "../engine-dylib", version = "2.0.0", optional = true }
# - Mandatory dependencies for `sys` on Windows.
[target.'cfg(all(not(target_arch = "wasm32"), target_os = "windows"))'.dependencies]
winapi = "0.3"

[dev-dependencies]
# for the binary wasmer.rs
libc = { version = "^0.2", default-features = false }
# - Development Dependencies for `sys`.
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
wat = "1.0"
tempfile = "3.1"
anyhow = "1.0"

# Dependencies and Develoment Dependencies for `js`.
[target.'cfg(target_arch = "wasm32")'.dependencies]
# - Mandatory dependencies for `js`.
wasmer-types = { path = "../types", version = "2.0.0", default-features = false, features = ["std"] }
wasm-bindgen = "0.2.74"
js-sys = "0.3.51"
wasmer-derive = { path = "../derive", version = "2.0.0" }
# - Optional dependencies for `js`.
wasmparser = { version = "0.78", default-features = false, optional = true }
hashbrown = { version = "0.9", optional = true }
# - Development Dependencies for `js`.
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wat = "1.0"
anyhow = "1.0"
wasm-bindgen-test = "0.3.0"

# Specific to `js`.
#
# `wasm-opt` is on by default in for the release profile, but it can be
# disabled by setting it to `false`
[package.metadata.wasm-pack.profile.release]
wasm-opt = false

[badges]
maintenance = { status = "actively-developed" }

[features]
default = ["wat", "default-cranelift", "default-universal"]
default = ["sys-default"]
std = []
core = ["hashbrown"]

# Features for `sys`.
sys = []
sys-default = ["sys", "wat", "default-cranelift", "default-universal"]
# - Compilers.
compiler = [
"sys",
"wasmer-compiler/translator",
"wasmer-engine-universal/compiler",
"wasmer-engine-dylib/compiler",
]
engine = []
universal = [
"wasmer-engine-universal",
"engine"
]
dylib = [
"wasmer-engine-dylib",
"engine"
]
singlepass = [
"wasmer-compiler-singlepass",
"compiler",
]
cranelift = [
"wasmer-compiler-cranelift",
"compiler",
]
llvm = [
"wasmer-compiler-llvm",
"compiler",
]

default-singlepass = [
"singlepass",
"default-compiler"
]
default-cranelift = [
"cranelift",
"default-compiler"
]
default-llvm = [
"llvm",
"default-compiler"
]
default-universal = [
"universal",
"default-engine"
]
default-dylib = [
"dylib",
"default-engine"
]

singlepass = [
"compiler",
"wasmer-compiler-singlepass",
]
cranelift = [
"compiler",
"wasmer-compiler-cranelift",
]
llvm = [
"compiler",
"wasmer-compiler-llvm",
]
default-compiler = []
default-singlepass = [
"default-compiler",
"singlepass",
]
default-cranelift = [
"default-compiler",
"cranelift",
]
default-llvm = [
"default-compiler",
"llvm",
]
# - Engines.
engine = ["sys"]
universal = [
"engine",
"wasmer-engine-universal",
]
dylib = [
"engine",
"wasmer-engine-dylib",
]
default-engine = []

# experimental / in-development features
default-universal = [
"default-engine",
"universal",
]
default-dylib = [
"default-engine",
"dylib",
]
# - Experimental / in-development features
experimental-reference-types-extern-ref = [
"sys",
"wasmer-types/experimental-reference-types-extern-ref",
]

# Deprecated features.
# - Deprecated features.
jit = ["universal"]
native = ["dylib"]

# Features for `js`.
js = []
js-default = ["js", "std", "wasm-types-polyfill"]

wasm-types-polyfill = ["js", "wasmparser"]
Loading