Skip to content

Commit c8cd7e0

Browse files
committed
add wasmJs target
1 parent 35fd8db commit c8cd7e0

File tree

21 files changed

+969
-510
lines changed

21 files changed

+969
-510
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
cov: on
2424
cmd: "./gradlew :kmp-socketio:jvmTest --info"
2525
- os: macos-latest
26-
cmd: "./gradlew :kmp-socketio:macosX64Test --info && ./kmp-socketio/src/jsTest/start_server.sh && ./gradlew :kmp-socketio:jsBrowserTest --info && ./kmp-socketio/src/jsTest/stop_server.sh"
26+
cmd: "./gradlew :kmp-socketio:macosX64Test --info && ./kmp-socketio/src/webTest/start_server.sh && ./gradlew :kmp-socketio:jsBrowserTest --info && ./gradlew :kmp-socketio:wasmJsBrowserTest --info && ./kmp-socketio/src/webTest/stop_server.sh"
2727
- os: ubuntu-latest
2828
cmd: "./gradlew :kmp-socketio:linuxX64Test --info"
2929
- os: windows-latest

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ pod install
8989
Use Chrome CORS Unblock extension to workaround with CORS error.
9090

9191
```bash
92-
./gradlew :example:shared:jsBrowserRun
92+
./gradlew :example:shared:jsBrowserDevelopmentRun
93+
```
94+
95+
### WasmJS
96+
97+
Use Chrome CORS Unblock extension to workaround with CORS error.
98+
99+
```bash
100+
./gradlew :example:shared:wasmJsBrowserDevelopmentRun
93101
```
94102

95103
### Windows
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Consts {
22
const val releaseGroup = "com.piasy"
33
const val releaseName = "kmp-socketio"
4-
const val releaseVersion = "1.3.3"
4+
const val releaseVersion = "1.4.0"
55

66
val androidNS = "$releaseGroup.${releaseName.replace('-', '.')}"
77
}

example/shared/build.gradle.kts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
1+
@file:OptIn(ExperimentalWasmDsl::class)
2+
3+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
24

35
plugins {
46
alias(libs.plugins.kmp)
@@ -34,11 +36,22 @@ kotlin {
3436
}
3537
}
3638

37-
js(IR) {
38-
browser {
39-
}
39+
js {
40+
browser()
41+
nodejs()
42+
binaries.executable()
43+
}
44+
wasmJs {
45+
browser()
46+
nodejs()
47+
d8()
4048
binaries.executable()
4149
}
50+
// ktor doesn't support wasmWasi yet.
51+
// wasmWasi {
52+
// nodejs()
53+
// binaries.executable()
54+
// }
4255

4356
listOf(linuxX64(), mingwX64()).forEach {
4457
it.binaries {

example/shared/src/commonMain/kotlin/com/piasy/kmp/socketio/example/Greeting.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import kotlinx.io.bytestring.unsafe.UnsafeByteStringOperations
1010
class Greeting {
1111
@OptIn(UnsafeByteStringApi::class)
1212
fun greet() {
13-
IO.socket("http://172.16.11.25:3000", IO.Options()) { socket ->
13+
IO.socket("http://172.16.11.186:3000", IO.Options()) { socket ->
1414
socket.on(Socket.EVENT_CONNECT) { args ->
1515
println("Greeting on connect ${args.joinToString()}")
1616

example/shared/src/jsMain/kotlin/com/piasy/kmp/socketio/example/Platform.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.piasy.kmp.socketio.example
2+
3+
fun main() {
4+
Greeting().greet()
5+
}

example/shared/src/jsMain/resources/index.html renamed to example/shared/src/webMain/resources/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<title>kmp-xlog</title>
66
</head>
77
<body>
8-
<h1 id="text"></h1>
8+
<h1>kmp-socketio (check console log)</h1>
9+
<h2>Use Chrome CORS Unblock extension to workaround with CORS error.</h2>
910
<script src="shared.js"></script>
1011
</body>
1112
</html>

gradle/libs.versions.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
[versions]
22
jvm = "17"
33
iosDeploymentTarget = "14.0"
4-
compileSdk = "35"
4+
compileSdk = "36"
55
minSdk = "21"
6-
targetSdk = "35"
7-
agp = "8.7.3"
8-
kotlin = "2.2.0"
9-
ktor = "3.2.2"
6+
targetSdk = "36"
7+
agp = "8.13.0"
8+
kotlin = "2.2.20"
9+
ktor = "3.3.0"
1010
coroutine = "1.10.2"
11-
compose = "1.8.3"
11+
compose = "1.9.2"
1212

1313
[libraries]
1414
junit = "junit:junit:4.13.2"
1515
hamcrest = "org.hamcrest:hamcrest-library:3.0"
1616
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
17-
mockk = "io.mockk:mockk:1.14.4"
17+
mockk = "io.mockk:mockk:1.14.5"
1818
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutine" }
19-
json = "org.json:json:20250107"
19+
json = "org.json:json:20250517"
2020
kommand = "com.kgit2:kommand:2.3.0"
2121

2222
socketioParser = "org.hildan.socketio:socketio-kotlin:2.6.0"
@@ -32,14 +32,14 @@ ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
3232
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
3333
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
3434
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
35-
kmpXlog = "com.piasy:kmp-xlog-api:1.4.3"
35+
kmpXlog = "com.piasy:kmp-xlog-api:1.5.0"
3636

3737
androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
3838
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
3939
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
4040
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
4141
androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
42-
androidx-activity-compose = "androidx.activity:activity-compose:1.10.1"
42+
androidx-activity-compose = "androidx.activity:activity-compose:1.11.0"
4343

4444
[plugins]
4545
android-library = { id = "com.android.library", version.ref = "agp" }
@@ -49,5 +49,5 @@ compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "
4949
kmp = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
5050
versions = "com.github.ben-manes.versions:0.52.0"
5151
versionUpdate = "nl.littlerobots.version-catalog-update:1.0.0"
52-
vanniktech-mavenPublish = "com.vanniktech.maven.publish:0.30.0"
53-
kover = "org.jetbrains.kotlinx.kover:0.9.1"
52+
vanniktech-mavenPublish = "com.vanniktech.maven.publish:0.34.0"
53+
kover = "org.jetbrains.kotlinx.kover:0.9.2"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Wed Nov 16 22:27:43 CST 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-all.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)