package eu.friedcutlet.yokan.services.extensions.js fun interface JavaScriptMessageBridge { fun sendMessage(channel: String, payload: String): String } /** * A single JavaScript context. [evaluate] blocks until the script (including synchronous host * bridge calls) finishes, so callers run it on a background dispatcher; [close] must not block. * The engine interrupts the script once [isCancelled] returns true. */ interface JavaScriptEngine { fun evaluate(script: String, isCancelled: () -> Boolean = { false }): String fun close() } /** * JavaScript engine for extension sources. QuickJS (zipline) on * Android/desktop/iOS; unsupported on the browser, where zipline has no * wasm artifact — the actual throws from `evaluate`. */ expect fun createJavaScriptEngine(bridge: JavaScriptMessageBridge): JavaScriptEngine