From e724788ce9345f6fb049d4de447657861ac46f69 Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Wed, 22 May 2019 20:20:16 +0200 Subject: Load the wasm --- WebInterface/wasm/asm-paint/deploy.py | 2 +- WebInterface/wasm/asm-paint/index.html | 12 ++++-------- WebInterface/wasm/asm-paint/loader.js | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 WebInterface/wasm/asm-paint/loader.js 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 @@ -
+ + Scribblio - -
+ + 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); + -- cgit v1.2.3-54-g00ecf