Skip to content

Commit 6f7d831

Browse files
Update dependency org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom to v2026 (#1123)
1 parent 22d4017 commit 6f7d831

4 files changed

Lines changed: 16 additions & 39 deletions

File tree

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ robolectric = { module = "org.robolectric:robolectric", version = "4.16.1" }
2626
tomlkt = { module = "net.peanuuutz.tomlkt:tomlkt", version = "0.5.0" }
2727
tuulbox-collections = { module = "com.juul.tuulbox:collections", version.ref = "tuulbox" }
2828
tuulbox-coroutines = { module = "com.juul.tuulbox:coroutines", version.ref = "tuulbox" }
29-
wrappers-bom = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version = "2025.12.6" }
29+
wrappers-bom = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version = "2026.5.6" }
3030
wrappers-browser = { module = "org.jetbrains.kotlin-wrappers:kotlin-browser" }
3131
wrappers-web = { module = "org.jetbrains.kotlin-wrappers:kotlin-web" }
3232

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
package com.juul.kable
22

33
import com.juul.kable.external.Bluetooth
4-
import com.juul.kable.external.getBluetooth
5-
import web.navigator.Navigator
64
import kotlin.js.js
7-
import kotlin.js.undefined
85

9-
private val navigator: Navigator =
10-
js("window.navigator")
6+
private fun isBluetoothSupported(): Boolean =
7+
js("typeof window !== 'undefined' && typeof window.navigator !== 'undefined' && window.navigator.bluetooth !== 'undefined'")
8+
9+
private fun jsBluetooth(): Bluetooth = js("window.navigator.bluetooth")
1110

1211
/**
13-
* @return [Bluetooth] object or `null` if bluetooth is [unavailable](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth#browser_compatibility).
12+
* @return [Bluetooth] object or `null` if bluetooth is [unsupported](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth#browser_compatibility).
1413
*/
1514
internal fun bluetoothOrNull(): Bluetooth? =
16-
getBluetooth(navigator).takeIf { it !== undefined }
15+
if (isBluetoothSupported()) jsBluetooth() else null
1716

1817
/**
19-
* @throws IllegalStateException If bluetooth is [unavailable](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth#browser_compatibility).
18+
* @throws IllegalStateException If bluetooth is [unsupported](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth#browser_compatibility).
2019
*/
21-
internal fun bluetoothOrThrow(): Bluetooth {
22-
val bluetooth = getBluetooth(navigator)
23-
if (bluetooth === undefined) {
24-
error("Bluetooth unavailable")
25-
}
26-
return bluetooth
27-
}
20+
internal fun bluetoothOrThrow(): Bluetooth =
21+
bluetoothOrNull() ?: error("Bluetooth unavailable")
Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
package com.juul.kable.bluetooth
22

3-
import kotlin.js.JsAny
43
import kotlin.js.js
5-
import kotlin.js.undefined
64

7-
private val watchAdvertisements: JsAny? =
8-
js("BluetoothDevice.prototype.watchAdvertisements")
5+
private fun isWatchAdvertisementsSupported(): Boolean =
6+
js("typeof BluetoothDevice.prototype.watchAdvertisements === 'function'")
97

10-
private val unwatchAdvertisements: JsAny? =
11-
js("BluetoothDevice.prototype.unwatchAdvertisements")
8+
private fun isUnwatchAdvertisementsSupported(): Boolean =
9+
js("typeof BluetoothDevice.prototype.unwatchAdvertisements === 'function'")
1210

13-
internal val canWatchAdvertisements by lazy {
14-
watchAdvertisements != null && watchAdvertisements != undefined
15-
}
16-
17-
internal val canUnwatchAdvertisements by lazy {
18-
unwatchAdvertisements != null && unwatchAdvertisements != undefined
19-
}
20-
21-
internal val isWatchingAdvertisementsSupported = canWatchAdvertisements && canUnwatchAdvertisements
11+
internal val isWatchingAdvertisementsSupported
12+
get() = isWatchAdvertisementsSupported() && isUnwatchAdvertisementsSupported()

kable-core/src/webMain/kotlin/external/Navigator.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)