diff options
author | natrixaeria <janng@gmx.de> | 2019-05-22 20:20:16 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-22 20:20:16 +0200 |
commit | e724788ce9345f6fb049d4de447657861ac46f69 (patch) | |
tree | 26d836330e434bd07fa7574087ed7a5494160e26 | |
parent | c3ae4cba3a1577c1ca7f86e4acd6778c6f74ffc3 (diff) |
Load the wasm
-rw-r--r-- | WebInterface/wasm/asm-paint/deploy.py | 2 | ||||
-rw-r--r-- | WebInterface/wasm/asm-paint/index.html | 12 | ||||
-rw-r--r-- | WebInterface/wasm/asm-paint/loader.js | 17 |
3 files changed, 22 insertions, 9 deletions
diff --git a/WebInterface/wasm/asm-paint/deploy.py b/WebInterface/wasm/asm-paint/deploy.py index 5410359..f81ebb8 100644 --- a/WebInterface/wasm/asm-paint/deploy.py +++ b/WebInterface/wasm/asm-paint/deploy.py @@ -9,7 +9,7 @@ HTML_MIME = 'text/html' REQUESTS = { '/': ('index.html', HTML_MIME), -# '/load_ws.js': ('load_ws.js', JS_MIME), + '/loader.js': ('loader.js', JS_MIME), '/asm_paint_bg.wasm': ('pkg/asm_paint_bg.wasm', WASM_MIME) } diff --git a/WebInterface/wasm/asm-paint/index.html b/WebInterface/wasm/asm-paint/index.html index 424255b..a0264cf 100644 --- a/WebInterface/wasm/asm-paint/index.html +++ b/WebInterface/wasm/asm-paint/index.html @@ -1,14 +1,10 @@ <!doctype html> <html> - <header> + <head> + <meta charset="UTF-8"> <title> Scribblio </title> - <script> -var importObject = { imports: { imported_func: arg => console.log(arg) } }; - -WebAssembly.instantiateStreaming(fetch('pkg/asm_paint_bg.wasm'), importObject) -.then(obj => obj.instance.exports.exported_func()); - </script> - </header> + <script src='loader.js'></script> + </head> <body> </body> </html> diff --git a/WebInterface/wasm/asm-paint/loader.js b/WebInterface/wasm/asm-paint/loader.js new file mode 100644 index 0000000..8348c35 --- /dev/null +++ b/WebInterface/wasm/asm-paint/loader.js @@ -0,0 +1,17 @@ +console.log('js> create import object'); +let importObject = { imports: { imported_func: arg => console.log(arg) } }; + +console.log('js> create fetch object'); + +let asm_paint_bg = fetch('asm_paint_bg.wasm'); + +console.log('js> instantiate streaming'); + +function and_then(obj) { + console.log('js> reached instantiate streaming\'s then'); + return obj.instance.exports.exported_func(); +} + +WebAssembly.instantiateStreaming(asm_paint_bg, importObject) + .then(and_then); + |