From b4a1dd137c86d8dd5bdff854d7b56241de70a79f Mon Sep 17 00:00:00 2001 From: Alexander Sysoev Date: Wed, 25 Sep 2024 13:57:33 +0200 Subject: [PATCH] Updated samples to use 0.3.0 --- .gitignore | 2 ++ .../ktor-all-platforms-app/build.gradle.kts | 11 +++++++ .../composeApp/build.gradle.kts | 31 ++++++++++++++++++- .../composeApp/src/commonMain/kotlin/App.kt | 10 +++--- .../src/wasmJsMain/kotlin/App.wasmJs.kt | 1 + .../composeApp/src/wasmJsMain/kotlin/main.kt | 11 +++++++ .../src/wasmJsMain/resources/index.html | 12 +++++++ .../src/wasmJsMain/resources/styles.css | 7 +++++ .../gradle/libs.versions.toml | 17 +++++----- .../server/build.gradle.kts | 4 +-- .../kotlin/kotlinx/rpc/sample/Application.kt | 8 ++--- .../kotlinx/rpc/sample/ApplicationTest.kt | 10 +++--- .../shared/build.gradle.kts | 18 +++++++++++ .../src/wasmJsMain/kotlin/Platform.wasmJs.kt | 2 +- .../kotlin/kotlinx/rpc/sample/data/Client.kt | 9 +++--- .../kotlinx/rpc/sample/ui/AppViewModel.kt | 2 +- .../gradle/libs.versions.toml | 2 +- .../kotlin/kotlinx/rpc/sample/Application.kt | 4 +-- .../server/src/test/kotlin/ApplicationTest.kt | 11 +++---- .../ktor-web-app/frontend/build.gradle.kts | 8 ----- .../frontend/src/jsMain/kotlin/RPC.kt | 8 ++--- .../frontend/src/jsMain/kotlin/Welcome.kt | 3 +- .../ktor-web-app/gradle/libs.versions.toml | 2 +- .../server/src/main/kotlin/Application.kt | 6 ++-- .../server/src/test/kotlin/ApplicationTest.kt | 10 +++--- samples/simple-ktor-app/build.gradle.kts | 2 +- .../simple-ktor-app/src/main/kotlin/Client.kt | 8 ++--- .../simple-ktor-app/src/main/kotlin/Server.kt | 6 ++-- .../src/test/kotlin/ApplicationTest.kt | 10 +++--- 29 files changed, 158 insertions(+), 77 deletions(-) create mode 100644 samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/App.wasmJs.kt create mode 100644 samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/main.kt create mode 100644 samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/index.html create mode 100644 samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/styles.css diff --git a/.gitignore b/.gitignore index 5e1bc92b..348ab60e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ build !.idea/detekt.xml !.idea/kotlinTestDataPluginTestDataPaths.xml +samples/**/.idea/* + .DS_Store # Ignore generated Detekt reports diff --git a/samples/ktor-all-platforms-app/build.gradle.kts b/samples/ktor-all-platforms-app/build.gradle.kts index 1889de65..48b39e28 100644 --- a/samples/ktor-all-platforms-app/build.gradle.kts +++ b/samples/ktor-all-platforms-app/build.gradle.kts @@ -15,3 +15,14 @@ plugins { alias(libs.plugins.kotlinx.rpc.platform) apply false alias(libs.plugins.compose.compiler) apply false } + +allprojects { + configurations.all { + resolutionStrategy { + // Workaround for https://youtrack.jetbrains.com/issue/CMP-6658 + force(libs.kotlinx.serialization.core) + force(libs.kotlinx.serialization.json) + force(libs.kotlin.stdlib) + } + } +} diff --git a/samples/ktor-all-platforms-app/composeApp/build.gradle.kts b/samples/ktor-all-platforms-app/composeApp/build.gradle.kts index 154bd5e8..a30b2132 100644 --- a/samples/ktor-all-platforms-app/composeApp/build.gradle.kts +++ b/samples/ktor-all-platforms-app/composeApp/build.gradle.kts @@ -5,6 +5,8 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl +import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig plugins { alias(libs.plugins.kotlinMultiplatform) @@ -15,6 +17,24 @@ plugins { } kotlin { + @OptIn(ExperimentalWasmDsl::class) + wasmJs { + moduleName = "composeApp" + browser { + val projectDirPath = project.projectDir.path + commonWebpackConfig { + outputFileName = "composeApp.js" + devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply { + static = (static ?: mutableListOf()).apply { + // Serve sources to debug inside browser + add(projectDirPath) + } + } + } + } + binaries.executable() + } + androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { @@ -53,12 +73,21 @@ kotlin { implementation(libs.kotlinx.rpc.krpc.client) implementation(libs.kotlinx.rpc.krpc.serialization.json) implementation(libs.kotlinx.rpc.krpc.ktor.client) - implementation(libs.ktor.client.cio) implementation(libs.ktor.client.core) implementation(libs.ktor.client.websockets) } desktopMain.dependencies { implementation(compose.desktop.currentOs) + implementation(libs.ktor.client.cio) + } + iosMain.dependencies { + implementation(libs.ktor.client.cio) + } + wasmJsMain.dependencies { + implementation(libs.ktor.client.js) + } + androidMain.dependencies { + implementation(libs.ktor.client.cio) } } } diff --git a/samples/ktor-all-platforms-app/composeApp/src/commonMain/kotlin/App.kt b/samples/ktor-all-platforms-app/composeApp/src/commonMain/kotlin/App.kt index b6da85c7..ef6420d6 100644 --- a/samples/ktor-all-platforms-app/composeApp/src/commonMain/kotlin/App.kt +++ b/samples/ktor-all-platforms-app/composeApp/src/commonMain/kotlin/App.kt @@ -14,12 +14,12 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import io.ktor.client.* import io.ktor.http.* +import kotlinx.rpc.krpc.ktor.client.installRPC +import kotlinx.rpc.krpc.ktor.client.rpc +import kotlinx.rpc.krpc.ktor.client.rpcConfig +import kotlinx.rpc.krpc.serialization.json.json +import kotlinx.rpc.krpc.streamScoped import kotlinx.rpc.withService -import kotlinx.rpc.serialization.json -import kotlinx.rpc.streamScoped -import kotlinx.rpc.transport.ktor.client.installRPC -import kotlinx.rpc.transport.ktor.client.rpc -import kotlinx.rpc.transport.ktor.client.rpcConfig import ktor_all_platforms_app.composeapp.generated.resources.Res import ktor_all_platforms_app.composeapp.generated.resources.compose_multiplatform import org.jetbrains.compose.resources.painterResource diff --git a/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/App.wasmJs.kt b/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/App.wasmJs.kt new file mode 100644 index 00000000..cda9c076 --- /dev/null +++ b/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/App.wasmJs.kt @@ -0,0 +1 @@ +actual val DEV_SERVER_HOST: String = "127.0.0.1" diff --git a/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/main.kt b/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/main.kt new file mode 100644 index 00000000..299151d4 --- /dev/null +++ b/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/main.kt @@ -0,0 +1,11 @@ +import App +import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.window.ComposeViewport +import kotlinx.browser.document + +@OptIn(ExperimentalComposeUiApi::class) +fun main() { + ComposeViewport(document.body!!) { + App() + } +} diff --git a/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/index.html b/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/index.html new file mode 100644 index 00000000..22ed4af0 --- /dev/null +++ b/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/index.html @@ -0,0 +1,12 @@ + + + + + + ktor-all-platforms-app + + + + + + diff --git a/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/styles.css b/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/styles.css new file mode 100644 index 00000000..0549b10f --- /dev/null +++ b/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/styles.css @@ -0,0 +1,7 @@ +html, body { + width: 100%; + height: 100%; + margin: 0; + padding: 0; + overflow: hidden; +} \ No newline at end of file diff --git a/samples/ktor-all-platforms-app/gradle/libs.versions.toml b/samples/ktor-all-platforms-app/gradle/libs.versions.toml index ccc34eeb..6af85b4b 100644 --- a/samples/ktor-all-platforms-app/gradle/libs.versions.toml +++ b/samples/ktor-all-platforms-app/gradle/libs.versions.toml @@ -15,14 +15,15 @@ androidx-test-junit = "1.2.1" compose = "1.7.2" compose-plugin = "1.6.11" junit = "4.13.2" -ktor = "2.3.12" +ktor = "3.0.0-rc-1" logback = "1.5.8" -kotlinx-serialization-json = "1.7.1" -kotlinx-coroutines-core = "1.9.0" -kotlinx-rpc = "0.2.4" +serialization = "1.7.1" +coroutines = "1.9.0" +kotlinx-rpc = "0.3.0" [libraries] # kotlin +kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } @@ -40,14 +41,13 @@ compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } # kotlinx -kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" } -kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" } -kotlinx-coroutines-core-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "kotlinx-coroutines-core" } +kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" } +kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialization" } +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } # ktor ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" } ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" } -ktor-server-tests = { module = "io.ktor:ktor-server-tests-jvm", version.ref = "ktor" } ktor-server-cors-jvm = { module = "io.ktor:ktor-server-cors-jvm", version.ref = "ktor" } ktor-server-websockets-jvm = { module = "io.ktor:ktor-server-websockets-jvm", version.ref = "ktor" } ktor-server-host-common-jvm = { module = "io.ktor:ktor-server-host-common-jvm", version.ref = "ktor" } @@ -55,6 +55,7 @@ ktor-server-test-host = { module = "io.ktor:ktor-server-test-host", version.ref ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" } ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } +ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" } # kotlinx-rpc kotlinx-rpc-core = { module = "org.jetbrains.kotlinx:kotlinx-rpc-core" } diff --git a/samples/ktor-all-platforms-app/server/build.gradle.kts b/samples/ktor-all-platforms-app/server/build.gradle.kts index 36da35ac..21cace24 100644 --- a/samples/ktor-all-platforms-app/server/build.gradle.kts +++ b/samples/ktor-all-platforms-app/server/build.gradle.kts @@ -18,7 +18,7 @@ application { dependencies { implementation(projects.shared) - implementation(libs.kotlinx.coroutines.core.jvm) + implementation(libs.kotlinx.coroutines.core) implementation(libs.logback) implementation(libs.ktor.server.core) implementation(libs.ktor.server.netty) @@ -28,7 +28,7 @@ dependencies { implementation(libs.kotlinx.rpc.krpc.server) implementation(libs.kotlinx.rpc.krpc.serialization.json) implementation(libs.kotlinx.rpc.krpc.ktor.server) - testImplementation(libs.ktor.server.tests) + testImplementation(libs.ktor.server.test.host) testImplementation(libs.kotlinx.rpc.krpc.client) testImplementation(libs.kotlinx.rpc.krpc.ktor.client) testImplementation(libs.kotlin.test.junit) diff --git a/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt b/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt index e79fca66..9fb57c62 100644 --- a/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt +++ b/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt @@ -10,9 +10,9 @@ import io.ktor.server.application.* import io.ktor.server.netty.* import io.ktor.server.plugins.cors.routing.* import io.ktor.server.routing.* -import kotlinx.rpc.serialization.json -import kotlinx.rpc.transport.ktor.server.RPC -import kotlinx.rpc.transport.ktor.server.rpc +import kotlinx.rpc.krpc.ktor.server.RPC +import kotlinx.rpc.krpc.ktor.server.rpc +import kotlinx.rpc.krpc.serialization.json.json fun main(args: Array): Unit = EngineMain.main(args) @@ -49,7 +49,7 @@ fun Application.installCORS() { allowSameOrigin = true // webpack-dev-server and local development - val allowedHosts = listOf("localhost:3000", "localhost:8080", "127.0.0.1:8080") + val allowedHosts = listOf("localhost:3000", "localhost:8080", "localhost:8081", "127.0.0.1:8080") allowedHosts.forEach { host -> allowHost(host, listOf("http", "https", "ws", "wss")) } diff --git a/samples/ktor-all-platforms-app/server/src/test/kotlin/kotlinx/rpc/sample/ApplicationTest.kt b/samples/ktor-all-platforms-app/server/src/test/kotlin/kotlinx/rpc/sample/ApplicationTest.kt index 23107bef..7755a855 100644 --- a/samples/ktor-all-platforms-app/server/src/test/kotlin/kotlinx/rpc/sample/ApplicationTest.kt +++ b/samples/ktor-all-platforms-app/server/src/test/kotlin/kotlinx/rpc/sample/ApplicationTest.kt @@ -8,12 +8,12 @@ import UserData import UserService import io.ktor.server.testing.* import kotlinx.coroutines.flow.toList +import kotlinx.rpc.krpc.ktor.client.installRPC +import kotlinx.rpc.krpc.ktor.client.rpc +import kotlinx.rpc.krpc.ktor.client.rpcConfig +import kotlinx.rpc.krpc.serialization.json.json +import kotlinx.rpc.krpc.streamScoped import kotlinx.rpc.withService -import kotlinx.rpc.serialization.json -import kotlinx.rpc.streamScoped -import kotlinx.rpc.transport.ktor.client.installRPC -import kotlinx.rpc.transport.ktor.client.rpc -import kotlinx.rpc.transport.ktor.client.rpcConfig import kotlin.test.Test import kotlin.test.assertEquals diff --git a/samples/ktor-all-platforms-app/shared/build.gradle.kts b/samples/ktor-all-platforms-app/shared/build.gradle.kts index cdb6d1fa..5d99db48 100644 --- a/samples/ktor-all-platforms-app/shared/build.gradle.kts +++ b/samples/ktor-all-platforms-app/shared/build.gradle.kts @@ -4,6 +4,8 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl +import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig plugins { alias(libs.plugins.kotlinMultiplatform) @@ -13,6 +15,21 @@ plugins { } kotlin { + @OptIn(ExperimentalWasmDsl::class) + wasmJs { + browser { + val projectDirPath = project.projectDir.path + commonWebpackConfig { + devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply { + static = (static ?: mutableListOf()).apply { + // Serve sources to debug inside browser + add(projectDirPath) + } + } + } + } + } + androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { @@ -31,6 +48,7 @@ kotlin { api(libs.kotlinx.coroutines.core) implementation(libs.kotlinx.rpc.core) + implementation(libs.kotlinx.serialization.core) implementation(libs.kotlinx.serialization.json) } } diff --git a/samples/ktor-all-platforms-app/shared/src/wasmJsMain/kotlin/Platform.wasmJs.kt b/samples/ktor-all-platforms-app/shared/src/wasmJsMain/kotlin/Platform.wasmJs.kt index 57b2e112..83cadf02 100644 --- a/samples/ktor-all-platforms-app/shared/src/wasmJsMain/kotlin/Platform.wasmJs.kt +++ b/samples/ktor-all-platforms-app/shared/src/wasmJsMain/kotlin/Platform.wasmJs.kt @@ -2,4 +2,4 @@ class WasmPlatform: Platform { override val name: String = "Web with Kotlin/Wasm" } -actual fun getPlatform(): Platform = WasmPlatform() \ No newline at end of file +actual fun getPlatform(): Platform = WasmPlatform() diff --git a/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/data/Client.kt b/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/data/Client.kt index 21ca0670..e6aeded9 100644 --- a/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/data/Client.kt +++ b/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/data/Client.kt @@ -6,13 +6,12 @@ package kotlinx.rpc.sample.data import io.ktor.client.HttpClient import io.ktor.client.engine.okhttp.OkHttp -import io.ktor.client.plugins.websocket.WebSockets import io.ktor.client.request.url import kotlinx.rpc.RPCClient -import kotlinx.rpc.serialization.json -import kotlinx.rpc.transport.ktor.client.rpc -import kotlinx.rpc.transport.ktor.client.rpcConfig -import kotlinx.rpc.transport.ktor.client.installRPC +import kotlinx.rpc.krpc.ktor.client.installRPC +import kotlinx.rpc.krpc.ktor.client.rpc +import kotlinx.rpc.krpc.ktor.client.rpcConfig +import kotlinx.rpc.krpc.serialization.json.json suspend fun createRpcClient(): RPCClient { return HttpClient(OkHttp) { diff --git a/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/ui/AppViewModel.kt b/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/ui/AppViewModel.kt index fe4de267..9eb7679d 100644 --- a/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/ui/AppViewModel.kt +++ b/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/ui/AppViewModel.kt @@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch import kotlinx.rpc.RPCClient -import kotlinx.rpc.streamScoped +import kotlinx.rpc.krpc.streamScoped import kotlinx.rpc.withService import kotlinx.rpc.sample.MyService import kotlinx.rpc.sample.UserData diff --git a/samples/ktor-android-app/gradle/libs.versions.toml b/samples/ktor-android-app/gradle/libs.versions.toml index 44f67428..8a7e009a 100644 --- a/samples/ktor-android-app/gradle/libs.versions.toml +++ b/samples/ktor-android-app/gradle/libs.versions.toml @@ -15,7 +15,7 @@ ktor = "2.3.12" kotlinx-serialization-json = "1.7.3" kotlinx-coroutines-core = "1.9.0" logback = "1.5.8" -kotlinx-rpc = "0.2.4" +kotlinx-rpc = "0.3.0" [libraries] # kotlin diff --git a/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt b/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt index 33573b7c..d7a9370a 100644 --- a/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt +++ b/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt @@ -7,8 +7,8 @@ import io.ktor.server.application.* import io.ktor.server.cio.* import io.ktor.server.routing.* import io.ktor.server.websocket.* -import kotlinx.rpc.serialization.json -import kotlinx.rpc.transport.ktor.server.rpc +import kotlinx.rpc.krpc.ktor.server.rpc +import kotlinx.rpc.krpc.serialization.json.json fun main(args: Array): Unit = EngineMain.main(args) diff --git a/samples/ktor-android-app/server/src/test/kotlin/ApplicationTest.kt b/samples/ktor-android-app/server/src/test/kotlin/ApplicationTest.kt index aa0f4108..1c76842c 100644 --- a/samples/ktor-android-app/server/src/test/kotlin/ApplicationTest.kt +++ b/samples/ktor-android-app/server/src/test/kotlin/ApplicationTest.kt @@ -5,19 +5,18 @@ import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* -import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.server.testing.* import kotlinx.coroutines.flow.toList +import kotlinx.rpc.krpc.ktor.client.installRPC +import kotlinx.rpc.krpc.ktor.client.rpc +import kotlinx.rpc.krpc.ktor.client.rpcConfig +import kotlinx.rpc.krpc.serialization.json.json +import kotlinx.rpc.krpc.streamScoped import kotlinx.rpc.withService import kotlinx.rpc.sample.MyService import kotlinx.rpc.sample.UserData -import kotlinx.rpc.serialization.json -import kotlinx.rpc.streamScoped -import kotlinx.rpc.transport.ktor.client.installRPC -import kotlinx.rpc.transport.ktor.client.rpc -import kotlinx.rpc.transport.ktor.client.rpcConfig import kotlin.test.Test import kotlin.test.assertEquals diff --git a/samples/ktor-web-app/frontend/build.gradle.kts b/samples/ktor-web-app/frontend/build.gradle.kts index 09d1ef5f..eb2d3281 100644 --- a/samples/ktor-web-app/frontend/build.gradle.kts +++ b/samples/ktor-web-app/frontend/build.gradle.kts @@ -17,14 +17,6 @@ kotlin { cssSupport { enabled.set(true) } - - val proxies = devServer?.proxy ?: mutableMapOf() - proxies["/api"] = "http://localhost:8080" - - devServer = devServer?.copy( - port = 3000, - proxy = proxies - ) } } } diff --git a/samples/ktor-web-app/frontend/src/jsMain/kotlin/RPC.kt b/samples/ktor-web-app/frontend/src/jsMain/kotlin/RPC.kt index af3a655c..3205500f 100644 --- a/samples/ktor-web-app/frontend/src/jsMain/kotlin/RPC.kt +++ b/samples/ktor-web-app/frontend/src/jsMain/kotlin/RPC.kt @@ -6,10 +6,10 @@ import io.ktor.client.* import io.ktor.client.engine.js.* import io.ktor.client.request.* import kotlinx.rpc.RPCClient -import kotlinx.rpc.serialization.json -import kotlinx.rpc.transport.ktor.client.installRPC -import kotlinx.rpc.transport.ktor.client.rpc -import kotlinx.rpc.transport.ktor.client.rpcConfig +import kotlinx.rpc.krpc.ktor.client.installRPC +import kotlinx.rpc.krpc.ktor.client.rpc +import kotlinx.rpc.krpc.ktor.client.rpcConfig +import kotlinx.rpc.krpc.serialization.json.json suspend fun initRpcClient(): RPCClient { return HttpClient(Js) { diff --git a/samples/ktor-web-app/frontend/src/jsMain/kotlin/Welcome.kt b/samples/ktor-web-app/frontend/src/jsMain/kotlin/Welcome.kt index 80f059d1..d16c59e7 100644 --- a/samples/ktor-web-app/frontend/src/jsMain/kotlin/Welcome.kt +++ b/samples/ktor-web-app/frontend/src/jsMain/kotlin/Welcome.kt @@ -3,8 +3,7 @@ */ import emotion.react.css -import kotlinx.coroutines.flow.Flow -import kotlinx.rpc.streamScoped +import kotlinx.rpc.krpc.streamScoped import react.FC import react.Props import react.dom.html.ReactHTML.div diff --git a/samples/ktor-web-app/gradle/libs.versions.toml b/samples/ktor-web-app/gradle/libs.versions.toml index 1769e99f..f9a9a7d2 100644 --- a/samples/ktor-web-app/gradle/libs.versions.toml +++ b/samples/ktor-web-app/gradle/libs.versions.toml @@ -5,7 +5,7 @@ ktor = "2.3.12" kotlinx-serialization-json = "1.7.3" kotlinx-coroutines-core = "1.9.0" logback = "1.5.8" -kotlinx-rpc = "0.2.4" +kotlinx-rpc = "0.3.0" [libraries] # kotlin diff --git a/samples/ktor-web-app/server/src/main/kotlin/Application.kt b/samples/ktor-web-app/server/src/main/kotlin/Application.kt index 536730da..7b859168 100644 --- a/samples/ktor-web-app/server/src/main/kotlin/Application.kt +++ b/samples/ktor-web-app/server/src/main/kotlin/Application.kt @@ -8,9 +8,9 @@ import io.ktor.server.cio.* import io.ktor.server.http.content.* import io.ktor.server.plugins.cors.routing.* import io.ktor.server.routing.* -import kotlinx.rpc.serialization.json -import kotlinx.rpc.transport.ktor.server.RPC -import kotlinx.rpc.transport.ktor.server.rpc +import kotlinx.rpc.krpc.ktor.server.RPC +import kotlinx.rpc.krpc.ktor.server.rpc +import kotlinx.rpc.krpc.serialization.json.json fun main(args: Array): Unit = EngineMain.main(args) diff --git a/samples/ktor-web-app/server/src/test/kotlin/ApplicationTest.kt b/samples/ktor-web-app/server/src/test/kotlin/ApplicationTest.kt index 3b54ea23..a5241cac 100644 --- a/samples/ktor-web-app/server/src/test/kotlin/ApplicationTest.kt +++ b/samples/ktor-web-app/server/src/test/kotlin/ApplicationTest.kt @@ -4,12 +4,12 @@ import io.ktor.server.testing.* import kotlinx.coroutines.flow.toList +import kotlinx.rpc.krpc.ktor.client.installRPC +import kotlinx.rpc.krpc.ktor.client.rpc +import kotlinx.rpc.krpc.ktor.client.rpcConfig +import kotlinx.rpc.krpc.serialization.json.json +import kotlinx.rpc.krpc.streamScoped import kotlinx.rpc.withService -import kotlinx.rpc.serialization.json -import kotlinx.rpc.streamScoped -import kotlinx.rpc.transport.ktor.client.installRPC -import kotlinx.rpc.transport.ktor.client.rpc -import kotlinx.rpc.transport.ktor.client.rpcConfig import kotlin.test.Test import kotlin.test.assertEquals diff --git a/samples/simple-ktor-app/build.gradle.kts b/samples/simple-ktor-app/build.gradle.kts index 8cf62cdf..cac2bbca 100644 --- a/samples/simple-ktor-app/build.gradle.kts +++ b/samples/simple-ktor-app/build.gradle.kts @@ -6,7 +6,7 @@ plugins { kotlin("jvm") version "2.0.10" kotlin("plugin.serialization") version "2.0.10" id("io.ktor.plugin") version "2.3.12" - id("org.jetbrains.kotlinx.rpc.plugin") version "0.2.4" + id("org.jetbrains.kotlinx.rpc.plugin") version "0.3.0" } group = "kotlinx.rpc.sample" diff --git a/samples/simple-ktor-app/src/main/kotlin/Client.kt b/samples/simple-ktor-app/src/main/kotlin/Client.kt index d8f3d0da..28484785 100644 --- a/samples/simple-ktor-app/src/main/kotlin/Client.kt +++ b/samples/simple-ktor-app/src/main/kotlin/Client.kt @@ -9,11 +9,11 @@ import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.flow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import kotlinx.rpc.krpc.ktor.client.rpc +import kotlinx.rpc.krpc.ktor.client.rpcConfig +import kotlinx.rpc.krpc.serialization.json.json +import kotlinx.rpc.krpc.streamScoped import kotlinx.rpc.withService -import kotlinx.rpc.serialization.json -import kotlinx.rpc.streamScoped -import kotlinx.rpc.transport.ktor.client.rpc -import kotlinx.rpc.transport.ktor.client.rpcConfig fun main() = runBlocking { val ktorClient = HttpClient { diff --git a/samples/simple-ktor-app/src/main/kotlin/Server.kt b/samples/simple-ktor-app/src/main/kotlin/Server.kt index c6c6adcd..c5fa1ae9 100644 --- a/samples/simple-ktor-app/src/main/kotlin/Server.kt +++ b/samples/simple-ktor-app/src/main/kotlin/Server.kt @@ -6,9 +6,9 @@ import io.ktor.server.application.* import io.ktor.server.engine.* import io.ktor.server.netty.* import io.ktor.server.routing.* -import kotlinx.rpc.serialization.json -import kotlinx.rpc.transport.ktor.server.RPC -import kotlinx.rpc.transport.ktor.server.rpc +import kotlinx.rpc.krpc.ktor.server.RPC +import kotlinx.rpc.krpc.ktor.server.rpc +import kotlinx.rpc.krpc.serialization.json.json fun main() { embeddedServer(Netty, port = 8080) { diff --git a/samples/simple-ktor-app/src/test/kotlin/ApplicationTest.kt b/samples/simple-ktor-app/src/test/kotlin/ApplicationTest.kt index f8117039..2b754f0a 100644 --- a/samples/simple-ktor-app/src/test/kotlin/ApplicationTest.kt +++ b/samples/simple-ktor-app/src/test/kotlin/ApplicationTest.kt @@ -7,12 +7,12 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel import kotlinx.coroutines.launch -import kotlinx.rpc.client.awaitFieldInitialization +import kotlinx.rpc.awaitFieldInitialization +import kotlinx.rpc.krpc.ktor.client.installRPC +import kotlinx.rpc.krpc.ktor.client.rpc +import kotlinx.rpc.krpc.ktor.client.rpcConfig +import kotlinx.rpc.krpc.serialization.json.json import kotlinx.rpc.withService -import kotlinx.rpc.serialization.json -import kotlinx.rpc.transport.ktor.client.installRPC -import kotlinx.rpc.transport.ktor.client.rpc -import kotlinx.rpc.transport.ktor.client.rpcConfig import org.junit.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals