Robert Jaros
12/06/2023, 3:10 PMorg.w3c
and kotlinx.browser
declarations have been extracted from stdlib to the separate artifact kotlin-dom-api-compat
(see: https://youtrack.jetbrains.com/issue/KT-39330). But it's not the case with Kotlin/Wasm, which makes the declarations incompatible when using both Js and WasmJs targets (can't use them in common
code). Can we expect similar artifact for Kotlin/Wasm? Any other workaround possible for this incompatibility? (there is already an issue based on my earlier report - https://youtrack.jetbrains.com/issue/KT-62398, with compose 1.6.0-alpha01 everything seems to work fine in common code except DOM declarations)Svyatoslav Kuzmich [JB]
12/06/2023, 3:21 PMdynamic
). If you are only using them “privately” without exposing types in your lib API, you could copy some of these to your codebase / separate library.Robert Jaros
12/06/2023, 3:26 PMSvyatoslav Kuzmich [JB]
12/06/2023, 5:01 PMexpect
-actual
in stdlib.Robert Jaros
12/08/2023, 3:53 PMdefinedExternally
arguments can't be used in the common source set) all (~1300) tests are green and example projects are working fine. Does this sounds crazy enough to be good solution? 🙂Arkadii Ivanov
12/08/2023, 4:21 PMJSON.stringify
on wasm. Since it's not available in stdlib yet, I defined it as external. But it always returns null. Is there anything that I'm missing? Here is the code I'm running: https://pl.kotl.in/Q8zwEFraU.
fun main() {
val some = Some(value = 3)
val ref = some.toJsReference()
val s = JSON.stringify(ref)
println(s)
}
data class Some(val value: Int)
public external object JSON {
public fun stringify(o: JsAny?): String?
}
Robert Jaros
12/08/2023, 4:23 PMtoJsReference()
Robert Jaros
12/08/2023, 4:23 PMArkadii Ivanov
12/08/2023, 4:24 PMsome as JsAny
but the result was the same - returns null.Arkadii Ivanov
12/08/2023, 4:24 PMRobert Jaros
12/08/2023, 4:24 PMArkadii Ivanov
12/08/2023, 4:57 PMRobert Jaros
12/08/2023, 4:57 PMkotlinx.serialization
Arkadii Ivanov
12/08/2023, 4:58 PMArkadii Ivanov
12/08/2023, 5:00 PMjs
target I'm currently using stringify
against Any type.Robert Jaros
12/08/2023, 5:01 PMArkadii Ivanov
12/08/2023, 5:08 PMArkadii Ivanov
12/08/2023, 5:08 PMArkadii Ivanov
12/08/2023, 5:16 PMSvyatoslav Kuzmich [JB]
12/08/2023, 5:18 PM@JsCopy
(name TBD) that you would put on data classes. These annotated types would then be allowed in external functions and data will be copied to a new plain JS object (and back) when crossing the external
boundary. Would that help?Arkadii Ivanov
12/08/2023, 5:20 PMkotlinx.browser.window.history.pushState(data = SomeKotlinData(), ...)
and then read the state via val state = kotlinx.browser.window.history.state
and cast to the original SomeKotlinData
. Or toJsReference
should work in this case?Svyatoslav Kuzmich [JB]
12/08/2023, 5:27 PMArkadii Ivanov
12/08/2023, 5:30 PMUnhandled JavaScript exception: Failed to execute 'replaceState' on 'History': [object Object] could not be cloned.
But I haven't tried it yet in a real browser.Arkadii Ivanov
12/08/2023, 7:47 PM