Paul Idstein
11/05/2021, 7:52 AM@file:JsModule("./wasm-js-module.js")
@file:JsNonModule
package pkg.native.wasm.library
//typealias WasmPointer = Int
@JsName("_some_simd_function")
external fun fast_simd_calculus(input: WasmPointer, output: WasmPointer, size: Int)
The generated code now looks like the following and yields of course an undefined
method because the module is a Promise
object
(function (root, factory) {
if (typeof define === 'function' && define.amd)
define(['exports', './wasm-js-module.js'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('./wasm-js-module.js'));
else {
if (typeof this['./wasm-js-module.js'] === 'undefined') {
throw new Error("Error loading module 'pkg.native.wasm.library'....");
}root['pkg'] = factory(typeof this['pkg'] === 'undefined' ? {} : this['pkg'], this['./wasm-js-module.js']);
}
}(this, function (_, $module$__wasm_js_module_js) {
var fast_simd_calculus = $module$__wasm_js_module_js._some_simd_function;
Big Chungus
11/05/2021, 8:16 AMexternal fun require(module: String): dynamic
suspend fun main() {
val myWasmModule = require ("wasm.module.js").unsafeCast<Promise<dynamic>>().await()
}
Paul Idstein
11/05/2021, 9:57 AMBig Chungus
11/05/2021, 10:00 AMBig Chungus
11/05/2021, 10:00 AMPaul Idstein
11/05/2021, 10:01 AM@file:JsModule("./wasm-js-module.js")
@file:JsNonModule
@EagerResolve <-- allow to eagerly resolve it
package pkg.native.wasm.library
//typealias WasmPointer = Int
@JsName("_some_simd_function")
external fun fast_simd_calculus(input: WasmPointer, output: WasmPointer, size: Int)
Big Chungus
11/05/2021, 10:01 AMPaul Idstein
11/05/2021, 10:02 AMPaul Idstein
11/05/2021, 10:03 AMBig Chungus
11/05/2021, 10:09 AM