Keep in mind that WebAssembly is sandboxed which means it can’t access the system, make HTTP requests, or log to the console. However, AssemblyScript supports both WASI and JS bindings (calling JS from AS).
But coming soon! How to use DOM APIs (via bindings) and to make websites written in AssemblyScript!...
It's already visible in the following repo, but as soon as it has enough bindings to be useful for a majority of cases, then we'll make an article. Working on Shadow DOM bindings next. :)
First you should get familiar with AssemblyScript and learn how to run
AssemlyScript code in a browser.
The following asc compiler options are required: --exportRuntime--exportTable.
The --explicitStart option is required only if any of your ES modules use DOM
APIs at their top level (read the comments in the below example).
In your JavaScript code that loads your Wasm module, import Asdom and pass
its wasmImports to your Wasm module's imports. The following snippet assumes
the use of native ES Modules in the browser and a…
But coming soon! How to use DOM APIs (via bindings) and to make websites written in AssemblyScript!...
Yeah, write an article when asdom gets released!
It's already visible in the following repo, but as soon as it has enough bindings to be useful for a majority of cases, then we'll make an article. Working on Shadow DOM bindings next. :)
lume / asdom
Use DOM APIs in AssemblyScript
asdom
Use DOM APIs in AssemblyScript (TypeScript compiled to WebAssembly).
This allows us to write WebAssembly applications that can manipulate the DOM, and with potential for more speed!
Early Stages!
Work in progress (probably may always be), but right now it's early and many APIs need to be added.
Supported APIs so far
See the outline of supported APIs.
Usage
First you should get familiar with AssemblyScript and learn how to run AssemlyScript code in a browser.
The following
asc
compiler options are required:--exportRuntime
--exportTable
.The
--explicitStart
option is required only if any of your ES modules use DOM APIs at their top level (read the comments in the below example).In your JavaScript code that loads your Wasm module, import
Asdom
and pass itswasmImports
to your Wasm module's imports. The following snippet assumes the use of native ES Modules in the browser and a…