Ronald Wolvers
03/09/2025, 9:16 AMGLSurfaceView
with custom fragment and vertex shaders, so I'm hoping to leverage WebGL for the WASM deployment.
I would love to, if this venture proves successful, contribute to providing an OpenGL context in CMP, and if this is the wrong place to ask the above question, my apologies in advance!
Update in commentsRonald Wolvers
03/09/2025, 10:28 AM[...]
const exports = import("./composeApp.mjs");
exports.then((value) =>
value.logHelloInKotlin()
);
[...]
`main.kt`:
[...]
external fun logHello()
@OptIn(ExperimentalJsExport::class)
@JsExport
fun logHelloInKotlin() {
println("Hello from Kotlin!")
}
[...]
build.gradle.kts
at project-level:
[...]
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "composeApp"
browser {
val rootDirPath = project.rootDir.path
val projectDirPath = project.projectDir.path
commonWebpackConfig {
outputFileName = "composeApp.js"
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
static = (static ?: mutableListOf()).apply {
// Serve sources to debug inside browser
add(rootDirPath)
add(projectDirPath)
}
}
}
}
binaries.executable()
generateTypeScriptDefinitions()
}
[...]
Winson Chiu
03/23/2025, 9:32 AMWinson Chiu
03/24/2025, 4:08 AMRonald Wolvers
03/24/2025, 11:14 AMRonald Wolvers
03/24/2025, 11:20 AMexternal
Kotlin method is this (in main.kt
):
[...]
@OptIn(ExperimentalComposeUiApi::class)
fun main() {
logHello()
ComposeViewport(document.body!!) {
App()
}
}
[...]
I'm interested to hear if you have a stacktrace, or are able print a stacktrace to the logs and post it here. I take it you are trying to interact with the DOM? The only thing I have managed to do so far is 1) log messages and 2) make an AJAX call (but still no solution to the problem I described regarding the hashcodes)Ronald Wolvers
03/24/2025, 11:37 AMWinson Chiu
03/24/2025, 1:47 PMlogHelloIntoKotlin
in your example. I don't remember the exact error, but it was something along the lines of failure to import js-joda/core because of a misformatted path.
I think that's because the composeApp.js defers the load of those modules, so even if you invoke that script before any script that calls the interop method, Compose/Kotlin isn't ready to receive it.