Access any Web API from WASM side using a clean syntax. Built using AssemblyScript.
Running
- Run
npm install. - Run
npm run build ./src/main.tsornpm run build [ENTRY_FILE]ornpm run build -- [MULTIPLE_ARGS]. - Run
npm start. - Go to the URL it prints out.
Example
import './ASuni'; export function run(): void { const person = (( { name: 'joe', age: 20, hobbies: [ 'dancing', 'singing' ], isHuman: true, ua: window.navigator.userAgent } )); window.console.log( person ); const el = window.document.createElement( 'h1' ); el.innerHTML = 'ASUNI!'; window.document.body.appendChild( el ); window.console.log( el.tagName ); const json = <string>window.JSON.stringify( person ); window.console.log( json ); window.onclick = ( event: externref ): void => { window.console.log( event.target.tagName ); }; }
Build arguments
- Pass
--noASTto not emit transformed code. Transformed files are emitted intransformedfolder. - Pass
--noUglifyto not uglify imported function names. - For example:
npm run build -- ./src/main.ts --noUglify.
Other commands
- Use
npm run dev ./src/main.tsto auto rebuild when changes are made. - Use
npm run bundle --file=./src/main.tsto bundle everything up usingesbuild. You can modify the script to use webpack if you prefer that.