Right now calling Zipline.get() inside JS has a side-effect of wiring some of the global things that support coroutines and logging.
If the user calls println() before they call Zipline.get(), they get a surprising crash:
app.cash.zipline.QuickJsException: 'console' is not defined
at JavaScript.<anonymous>(../../../../../jsMainSources/libraries/stdlib/js/src/kotlin/console.kt:78)
at JavaScript.<anonymous>(../../../../../jsMainSources/libraries/stdlib/js/src/kotlin/console.kt:71)
at JavaScript.<anonymous>(../../../../../jsMainSources/libraries/stdlib/js/src/kotlin/console.kt:10)
at JavaScript.<anonymous>(../../../../../jsMainSources/libraries/stdlib/js/src/kotlin/console.kt:15)
at JavaScript.println(../../../../../jsMainSources/libraries/stdlib/js/src/kotlin/console.kt:100)
at JavaScript.prepareTreehouse(../../../../../launch.kt:70)
at JavaScript.<eval>(ZiplineLoader.kt)
We could implement this by making the engine-side call an init function for these things rather than doing it as a side-effect of getting the Zipline instance.
Right now calling
Zipline.get()
inside JS has a side-effect of wiring some of the global things that support coroutines and logging.If the user calls
println()
before they callZipline.get()
, they get a surprising crash:We could implement this by making the engine-side call an
init
function for these things rather than doing it as a side-effect of getting the Zipline instance.