Daniel Weidensdörfer
11/10/2024, 12:07 PMfun main() {
onWasmReady {
CanvasBasedWindow("App Name") {
// ...
}
}
}
still the current valid approach and do I understand correctly that it will run wasm when possible and js otherwise? Given, quote from above thread:
With current Kotlin versions you no longer need separate build configurations for JS and Wasm, so much easier now.
PHondogo
11/10/2024, 1:31 PMPHondogo
11/10/2024, 2:00 PM<script type="text/javascript">
const s=(s)=>{const e=document.createElement("script");e.src=s;e.type="text/javascript";e.defer=true;document.body.appendChild(e)}
const w=WebAssembly;if(typeof w!=="undefined"&&typeof w?.validate==="function"&&
w.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,8,2,95,1,120,0,96,0,0,3,3,2,1,1,10,14,2,6,0,6,64,25,11,11,5,0,208,112,26,11,0,45,4,110,97,109,101,1,15,2,0,5,102,117,110,99,48,1,5,102,117,110,99,49,4,8,1,0,5,116,121,112,101,48,10,11,1,0,1,0,6,102,105,101,108,100,48]))
){s("app.wasm.js")}else{s("skiko.js");s("app.js")}
</script>
PHondogo
11/10/2024, 2:07 PMPHondogo
11/10/2024, 2:09 PMorg.jetbrains.compose.experimental.jscanvas.enabled=true
Oliver.O
11/10/2024, 6:29 PMIs it correct that we can just drop the wasmJs target using js instead?No, as Paul said,
wasmJs
is an additional target.
do I understand correctly that it will run wasm when possible and js otherwiseNo, there is no automatic fallback. The quote
With current Kotlin versions you no longer need separate build configurations for JS and Wasm, so much easier now.was referring to the situation that in the old days, there was no way to have Compose UI (canvas) with the
js
and wasmJs
targets in a uniform build configuration. As you can see in this diff there is lots of conditional configuration (if (useJs) {
) in the older version of build.gradle.kts
.Daniel Weidensdörfer
11/10/2024, 7:03 PMonWasmReady { ... }
necessary on js side?Oliver.O
11/10/2024, 7:04 PMDaniel Weidensdörfer
11/10/2024, 7:10 PMOliver.O
11/10/2024, 7:15 PMDaniel Weidensdörfer
11/10/2024, 7:16 PMOliver.O
11/10/2024, 7:18 PMDaniel Weidensdörfer
11/11/2024, 2:08 PMonWasmReady is not defined
error.
Uncaught ReferenceError: onWasmReady is not defined
at main (main.kt:23:6)
at mainWrapper (shared.js:378:5)
at Object.eval (shared.js:388:3)
at eval (shared.js:5:35)
at eval (shared.js:8:2)
at ./kotlin/shared.js (shared.js:808:1)
at __webpack_require__ (shared.js:887:32)
at shared.js:1957:37
at shared.js:1960:12
at webpackUniversalModuleDefinition (shared.js:17:20)
I'm using the following gradle config for js:
js(IR) {
moduleName = "shared"
binaries.executable()
browser {
commonWebpackConfig {
outputFileName = "shared.js"
cssSupport {
enabled.set(true)
}
}
}
}
PHondogo
11/11/2024, 2:19 PMwindow.onload = {
onWasmReady {...}
}
?Daniel Weidensdörfer
11/11/2024, 2:23 PM