Yokan / rebuild
Course 1 8624561

JavaScriptEngine.wasm.kt

composeApp/src/wasmJsMain/kotlin/eu/friedcutlet/yokan/services/extensions/js/JavaScriptEngine.wasm.kt

implementation20 lines
1package eu.friedcutlet.yokan.services.extensions.js23/**4 * Extension sources need a synchronous QuickJS bridge; zipline has no wasm5 * artifact, so JavaScript-based extensions are unavailable in the browser.6 * Every call fails with a clear [UnsupportedOperationException] instead of7 * returning empty results.8 */9// ponytail: evaluating in the page's own JS engine would not help either: the host HTTP bridge is10// synchronous and the browser cannot block on fetch. Upgrade path: promise-returning host calls11// awaited by an async (suspend) engine API.12actual fun createJavaScriptEngine(bridge: JavaScriptMessageBridge): JavaScriptEngine =13    UnsupportedJavaScriptEngine1415private object UnsupportedJavaScriptEngine : JavaScriptEngine {16    override fun evaluate(script: String, isCancelled: () -> Boolean): String =17        throw UnsupportedOperationException("JavaScript extensions are not supported in the browser.")1819    override fun close() = Unit20}21

Search chapters, reference and source filenames.