In wasm how can i use showSaveFilePicker on `windo...
# webassembly
a
In wasm how can i use showSaveFilePicker on
window
? I have imported
import kotlinx.browser.window
but showSaveFilePicker() doesnt exist there
I know that in the js target i could use
window
as dynamic, but I think wasm doesnt have dynamic
I think i figured it out:
Copy code
val window: WasmWindow = js("window")

external interface WasmWindow {
    fun showSaveFilePicker(): WasmFileSystemFileHandle
    fun showOpenFilePicker(options: FilePickerAcceptType? = definedExternally): Promise<JsArray<WasmFileSystemFileHandle>>
    fun alert(message: String)
    fun prompt(message: String, defaultText: String): String?
}
t
Do you support Chrome only?
a
good catch. no i don't. the question still remains though, as im new to wasm and trying to understand how the target works
t
In common case it's better to write extensions for existed type (constant)
When methods will be stable you will receive warning on compilation and will remove redundant extensions
a
I don't understand. Are you suggesting I do:
Copy code
val window: WasmWindow = js("window")

fun WasmWindow.showSaveFilePicker(): WasmFileSystemFileHandle

etc
instead?
can i do external extension functions?
t
Copy code
fun Window.showSaveFilePicker(): FileSystemFileHandle = 
    js("this.showSaveFilePicker()")
?
👍 2
d
this does not work for me? wasm compile fails with js("...") calls