Skip to content

Commit 0f4b546

Browse files
authored
1 parent 4c03373 commit 0f4b546

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

kotlinx-coroutines-core/api/kotlinx-coroutines-core.klib.api

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,11 @@ final suspend fun (org.w3c.dom/Window).kotlinx.coroutines/awaitAnimationFrame():
944944
// Targets: [js]
945945
final suspend fun <#A: kotlin/Any?> (kotlin.js/Promise<#A>).kotlinx.coroutines/await(): #A // kotlinx.coroutines/await|[email protected]<0:0>(){0§<kotlin.Any?>}[0]
946946
// Targets: [wasmJs]
947+
abstract class kotlinx.coroutines/W3CWindow { // kotlinx.coroutines/W3CWindow|null[0]
948+
constructor <init>() // kotlinx.coroutines/W3CWindow.<init>|<init>(){}[0]
949+
final fun clearTimeout(kotlin/Int) // kotlinx.coroutines/W3CWindow.clearTimeout|clearTimeout(kotlin.Int){}[0]
950+
}
951+
// Targets: [wasmJs]
947952
final fun <#A: kotlin/Any?> (kotlin.js/Promise<kotlin.js/JsAny?>).kotlinx.coroutines/asDeferred(): kotlinx.coroutines/Deferred<#A> // kotlinx.coroutines/asDeferred|[email protected]<kotlin.js.JsAny?>(){0§<kotlin.Any?>}[0]
948953
// Targets: [wasmJs]
949954
final fun <#A: kotlin/Any?> (kotlinx.coroutines/CoroutineScope).kotlinx.coroutines/promise(kotlin.coroutines/CoroutineContext = ..., kotlinx.coroutines/CoroutineStart = ..., kotlin.coroutines/SuspendFunction1<kotlinx.coroutines/CoroutineScope, #A>): kotlin.js/Promise<kotlin.js/JsAny?> // kotlinx.coroutines/promise|[email protected](kotlin.coroutines.CoroutineContext;kotlinx.coroutines.CoroutineStart;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>){0§<kotlin.Any?>}[0]

kotlinx-coroutines-core/wasmJs/src/CoroutineContext.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package kotlinx.coroutines
22

3-
import org.w3c.dom.*
4-
53
internal external interface JsProcess : JsAny {
64
fun nextTick(handler: () -> Unit)
75
}
86

97
internal fun tryGetProcess(): JsProcess? =
108
js("(typeof(process) !== 'undefined' && typeof(process.nextTick) === 'function') ? process : null")
119

12-
internal fun tryGetWindow(): Window? =
10+
internal fun tryGetWindow(): W3CWindow? =
1311
js("(typeof(window) !== 'undefined' && window != null && typeof(window.addEventListener) === 'function') ? window : null")
1412

1513
internal actual fun createDefaultDispatcher(): CoroutineDispatcher =

kotlinx-coroutines-core/wasmJs/src/JSDispatcher.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package kotlinx.coroutines
22

3-
import org.w3c.dom.Window
43
import kotlin.js.*
54

6-
public actual typealias W3CWindow = Window
5+
public actual abstract external class W3CWindow {
6+
fun clearTimeout(handle: Int)
7+
}
78

89
internal actual fun w3cSetTimeout(window: W3CWindow, handler: () -> Unit, timeout: Int): Int =
910
setTimeout(window, handler, timeout)
@@ -40,7 +41,7 @@ internal class NodeDispatcher(private val process: JsProcess) : SetTimeoutBasedD
4041
}
4142

4243
@Suppress("UNUSED_PARAMETER")
43-
private fun subscribeToWindowMessages(window: Window, process: () -> Unit): Unit = js("""{
44+
private fun subscribeToWindowMessages(window: W3CWindow, process: () -> Unit): Unit = js("""{
4445
const handler = (event) => {
4546
if (event.source == window && event.data == 'dispatchCoroutine') {
4647
event.stopPropagation();
@@ -51,7 +52,7 @@ private fun subscribeToWindowMessages(window: Window, process: () -> Unit): Unit
5152
}""")
5253

5354
@Suppress("UNUSED_PARAMETER")
54-
private fun createRescheduleMessagePoster(window: Window): () -> Unit =
55+
private fun createRescheduleMessagePoster(window: W3CWindow): () -> Unit =
5556
js("() => window.postMessage('dispatchCoroutine', '*')")
5657

5758
@Suppress("UNUSED_PARAMETER")
@@ -84,5 +85,6 @@ private fun clearTimeout(handle: Int): Unit =
8485
js("{ if (typeof clearTimeout !== 'undefined') clearTimeout(handle); }")
8586

8687
@Suppress("UNUSED_PARAMETER")
87-
private fun setTimeout(window: Window, handler: () -> Unit, timeout: Int): Int =
88+
private fun setTimeout(window: W3CWindow, handler: () -> Unit, timeout: Int): Int =
8889
js("window.setTimeout(handler, timeout)")
90+

0 commit comments

Comments
 (0)