Skip to content

Commit 7a458d7

Browse files
committed
Updated samples to use 0.3.0
1 parent 2c6792b commit 7a458d7

File tree

29 files changed

+158
-77
lines changed

29 files changed

+158
-77
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ build
2020
!.idea/detekt.xml
2121
!.idea/kotlinTestDataPluginTestDataPaths.xml
2222

23+
samples/**/.idea/*
24+
2325
.DS_Store
2426

2527
# Ignore generated Detekt reports

samples/ktor-all-platforms-app/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,14 @@ plugins {
1515
alias(libs.plugins.kotlinx.rpc.platform) apply false
1616
alias(libs.plugins.compose.compiler) apply false
1717
}
18+
19+
allprojects {
20+
configurations.all {
21+
resolutionStrategy {
22+
// Workaround for https://youtrack.jetbrains.com/issue/CMP-6658
23+
force(libs.kotlinx.serialization.core)
24+
force(libs.kotlinx.serialization.json)
25+
force(libs.kotlin.stdlib)
26+
}
27+
}
28+
}

samples/ktor-all-platforms-app/composeApp/build.gradle.kts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
66
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
77
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
8+
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
9+
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
810

911
plugins {
1012
alias(libs.plugins.kotlinMultiplatform)
@@ -15,6 +17,24 @@ plugins {
1517
}
1618

1719
kotlin {
20+
@OptIn(ExperimentalWasmDsl::class)
21+
wasmJs {
22+
moduleName = "composeApp"
23+
browser {
24+
val projectDirPath = project.projectDir.path
25+
commonWebpackConfig {
26+
outputFileName = "composeApp.js"
27+
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
28+
static = (static ?: mutableListOf()).apply {
29+
// Serve sources to debug inside browser
30+
add(projectDirPath)
31+
}
32+
}
33+
}
34+
}
35+
binaries.executable()
36+
}
37+
1838
androidTarget {
1939
@OptIn(ExperimentalKotlinGradlePluginApi::class)
2040
compilerOptions {
@@ -53,12 +73,21 @@ kotlin {
5373
implementation(libs.kotlinx.rpc.krpc.client)
5474
implementation(libs.kotlinx.rpc.krpc.serialization.json)
5575
implementation(libs.kotlinx.rpc.krpc.ktor.client)
56-
implementation(libs.ktor.client.cio)
5776
implementation(libs.ktor.client.core)
5877
implementation(libs.ktor.client.websockets)
5978
}
6079
desktopMain.dependencies {
6180
implementation(compose.desktop.currentOs)
81+
implementation(libs.ktor.client.cio)
82+
}
83+
iosMain.dependencies {
84+
implementation(libs.ktor.client.cio)
85+
}
86+
wasmJsMain.dependencies {
87+
implementation(libs.ktor.client.js)
88+
}
89+
androidMain.dependencies {
90+
implementation(libs.ktor.client.cio)
6291
}
6392
}
6493
}

samples/ktor-all-platforms-app/composeApp/src/commonMain/kotlin/App.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import androidx.compose.ui.Alignment
1414
import androidx.compose.ui.Modifier
1515
import io.ktor.client.*
1616
import io.ktor.http.*
17+
import kotlinx.rpc.krpc.ktor.client.installRPC
18+
import kotlinx.rpc.krpc.ktor.client.rpc
19+
import kotlinx.rpc.krpc.ktor.client.rpcConfig
20+
import kotlinx.rpc.krpc.serialization.json.json
21+
import kotlinx.rpc.krpc.streamScoped
1722
import kotlinx.rpc.withService
18-
import kotlinx.rpc.serialization.json
19-
import kotlinx.rpc.streamScoped
20-
import kotlinx.rpc.transport.ktor.client.installRPC
21-
import kotlinx.rpc.transport.ktor.client.rpc
22-
import kotlinx.rpc.transport.ktor.client.rpcConfig
2323
import ktor_all_platforms_app.composeapp.generated.resources.Res
2424
import ktor_all_platforms_app.composeapp.generated.resources.compose_multiplatform
2525
import org.jetbrains.compose.resources.painterResource
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
actual val DEV_SERVER_HOST: String = "127.0.0.1"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import App
2+
import androidx.compose.ui.ExperimentalComposeUiApi
3+
import androidx.compose.ui.window.ComposeViewport
4+
import kotlinx.browser.document
5+
6+
@OptIn(ExperimentalComposeUiApi::class)
7+
fun main() {
8+
ComposeViewport(document.body!!) {
9+
App()
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>ktor-all-platforms-app</title>
7+
<link type="text/css" rel="stylesheet" href="styles.css">
8+
<script type="application/javascript" src="composeApp.js"></script>
9+
</head>
10+
<body>
11+
</body>
12+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
html, body {
2+
width: 100%;
3+
height: 100%;
4+
margin: 0;
5+
padding: 0;
6+
overflow: hidden;
7+
}

samples/ktor-all-platforms-app/gradle/libs.versions.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ androidx-test-junit = "1.2.1"
1515
compose = "1.7.2"
1616
compose-plugin = "1.6.11"
1717
junit = "4.13.2"
18-
ktor = "2.3.12"
18+
ktor = "3.0.0-rc-1"
1919
logback = "1.5.8"
20-
kotlinx-serialization-json = "1.7.1"
21-
kotlinx-coroutines-core = "1.9.0"
22-
kotlinx-rpc = "0.2.4"
20+
serialization = "1.7.1"
21+
coroutines = "1.9.0"
22+
kotlinx-rpc = "0.3.0"
2323

2424
[libraries]
2525
# kotlin
26+
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
2627
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
2728
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
2829

@@ -40,21 +41,21 @@ compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref =
4041
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
4142

4243
# kotlinx
43-
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" }
44-
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" }
45-
kotlinx-coroutines-core-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "kotlinx-coroutines-core" }
44+
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
45+
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialization" }
46+
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
4647

4748
# ktor
4849
ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" }
4950
ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" }
50-
ktor-server-tests = { module = "io.ktor:ktor-server-tests-jvm", version.ref = "ktor" }
5151
ktor-server-cors-jvm = { module = "io.ktor:ktor-server-cors-jvm", version.ref = "ktor" }
5252
ktor-server-websockets-jvm = { module = "io.ktor:ktor-server-websockets-jvm", version.ref = "ktor" }
5353
ktor-server-host-common-jvm = { module = "io.ktor:ktor-server-host-common-jvm", version.ref = "ktor" }
5454
ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
5555
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
5656
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
5757
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
58+
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
5859

5960
# kotlinx-rpc
6061
kotlinx-rpc-core = { module = "org.jetbrains.kotlinx:kotlinx-rpc-core" }

samples/ktor-all-platforms-app/server/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ application {
1818

1919
dependencies {
2020
implementation(projects.shared)
21-
implementation(libs.kotlinx.coroutines.core.jvm)
21+
implementation(libs.kotlinx.coroutines.core)
2222
implementation(libs.logback)
2323
implementation(libs.ktor.server.core)
2424
implementation(libs.ktor.server.netty)
@@ -28,7 +28,7 @@ dependencies {
2828
implementation(libs.kotlinx.rpc.krpc.server)
2929
implementation(libs.kotlinx.rpc.krpc.serialization.json)
3030
implementation(libs.kotlinx.rpc.krpc.ktor.server)
31-
testImplementation(libs.ktor.server.tests)
31+
testImplementation(libs.ktor.server.test.host)
3232
testImplementation(libs.kotlinx.rpc.krpc.client)
3333
testImplementation(libs.kotlinx.rpc.krpc.ktor.client)
3434
testImplementation(libs.kotlin.test.junit)

0 commit comments

Comments
 (0)