diff --git a/samples/grpc-app/build.gradle.kts b/samples/grpc-app/build.gradle.kts index 3d85034fa..2cddfba6f 100644 --- a/samples/grpc-app/build.gradle.kts +++ b/samples/grpc-app/build.gradle.kts @@ -5,7 +5,7 @@ plugins { kotlin("jvm") version "2.1.10" kotlin("plugin.serialization") version "2.1.10" - id("org.jetbrains.kotlinx.rpc.plugin") version "0.6.0" + id("org.jetbrains.kotlinx.rpc.plugin") version "0.7.0" id("com.google.protobuf") version "0.9.5" } @@ -22,9 +22,9 @@ kotlin { } dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-core:0.5.1-grpc-39") + implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-core:0.7.0-grpc-56") implementation("ch.qos.logback:logback-classic:1.5.18") - implementation("io.grpc:grpc-netty:1.71.0") + implementation("io.grpc:grpc-netty:1.73.0") } rpc { diff --git a/samples/grpc-app/gradle/wrapper/gradle-wrapper.properties b/samples/grpc-app/gradle/wrapper/gradle-wrapper.properties index 37f853b1c..ff23a68d7 100644 --- a/samples/grpc-app/gradle/wrapper/gradle-wrapper.properties +++ b/samples/grpc-app/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/samples/ktor-all-platforms-app/composeApp/build.gradle.kts b/samples/ktor-all-platforms-app/composeApp/build.gradle.kts index 0dd4ada29..682d2d799 100644 --- a/samples/ktor-all-platforms-app/composeApp/build.gradle.kts +++ b/samples/ktor-all-platforms-app/composeApp/build.gradle.kts @@ -5,7 +5,6 @@ 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 { @@ -17,9 +16,9 @@ plugins { } kotlin { - @OptIn(ExperimentalWasmDsl::class) + @OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class) wasmJs { - moduleName = "composeApp" + outputModuleName = "composeApp" browser { val projectDirPath = project.projectDir.path commonWebpackConfig { 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 e159d8c6d..785ba06c7 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 @@ -18,7 +18,6 @@ import kotlinx.rpc.krpc.ktor.client.installKrpc 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 ktor_all_platforms_app.composeapp.generated.resources.Res import ktor_all_platforms_app.composeapp.generated.resources.compose_multiplatform diff --git a/samples/ktor-all-platforms-app/gradle/libs.versions.toml b/samples/ktor-all-platforms-app/gradle/libs.versions.toml index 47da114a2..d0b765fdf 100644 --- a/samples/ktor-all-platforms-app/gradle/libs.versions.toml +++ b/samples/ktor-all-platforms-app/gradle/libs.versions.toml @@ -1,25 +1,25 @@ [versions] -kotlin = "2.1.21" +kotlin = "2.2.0" -agp = "8.9.1" -android-compileSdk = "35" +agp = "8.11.0-alpha07" +android-compileSdk = "36" android-minSdk = "24" -android-targetSdk = "35" +android-targetSdk = "36" androidx-activityCompose = "1.10.1" -androidx-appcompat = "1.7.0" +androidx-appcompat = "1.7.1" androidx-constraintlayout = "2.2.1" androidx-core-ktx = "1.16.0" androidx-espresso-core = "3.6.1" androidx-material = "1.12.0" androidx-test-junit = "1.2.1" -compose = "1.7.8" -compose-plugin = "1.8.0-SNAPSHOT+pull-5245" +compose = "1.8.3" +compose-plugin = "1.8.2" junit = "4.13.2" -ktor = "3.1.2" +ktor = "3.1.3" logback = "1.5.18" serialization = "1.8.1" coroutines = "1.10.2" -kotlinx-rpc = "0.7.0" +kotlinx-rpc = "0.8.0" [libraries] # kotlin diff --git a/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.jar b/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.jar index 9bbc975c7..1b33c55ba 100644 Binary files a/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.jar and b/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.properties b/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.properties index 37f853b1c..ff23a68d7 100644 --- a/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.properties +++ b/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/samples/ktor-all-platforms-app/gradlew b/samples/ktor-all-platforms-app/gradlew index faf93008b..23d15a936 100755 --- a/samples/ktor-all-platforms-app/gradlew +++ b/samples/ktor-all-platforms-app/gradlew @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/samples/ktor-all-platforms-app/gradlew.bat b/samples/ktor-all-platforms-app/gradlew.bat index 9d21a2183..db3a6ac20 100644 --- a/samples/ktor-all-platforms-app/gradlew.bat +++ b/samples/ktor-all-platforms-app/gradlew.bat @@ -70,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell 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 2e8d0f649..c0e0f136f 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 @@ -30,7 +30,7 @@ fun Application.module() { } } - registerService { ctx -> UserServiceImpl(ctx) } + registerService { UserServiceImpl() } } } } diff --git a/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/UserServiceImpl.kt b/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/UserServiceImpl.kt index 89724005b..fb74ca14c 100644 --- a/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/UserServiceImpl.kt +++ b/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/UserServiceImpl.kt @@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlin.coroutines.CoroutineContext -class UserServiceImpl(override val coroutineContext: CoroutineContext) : UserService { +class UserServiceImpl : UserService { override suspend fun hello(user: String, userData: UserData): String { return "Nice to meet you $user, how is it in ${userData.address}?" } 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 d3ce2155a..da7057529 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 @@ -12,7 +12,6 @@ import kotlinx.rpc.krpc.ktor.client.installKrpc 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 kotlin.test.Test import kotlin.test.assertEquals @@ -20,6 +19,10 @@ import kotlin.test.assertEquals class ApplicationTest { @Test fun testRoot() = testApplication { + application { + module() + } + val service = createClient { installKrpc() }.rpc("/api") { diff --git a/samples/ktor-all-platforms-app/shared/build.gradle.kts b/samples/ktor-all-platforms-app/shared/build.gradle.kts index 5d99db48b..463e14624 100644 --- a/samples/ktor-all-platforms-app/shared/build.gradle.kts +++ b/samples/ktor-all-platforms-app/shared/build.gradle.kts @@ -3,8 +3,8 @@ */ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl 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 { diff --git a/samples/ktor-all-platforms-app/shared/src/commonMain/kotlin/UserService.kt b/samples/ktor-all-platforms-app/shared/src/commonMain/kotlin/UserService.kt index 8ea4be9a3..4c5d445a0 100644 --- a/samples/ktor-all-platforms-app/shared/src/commonMain/kotlin/UserService.kt +++ b/samples/ktor-all-platforms-app/shared/src/commonMain/kotlin/UserService.kt @@ -3,7 +3,6 @@ */ import kotlinx.coroutines.flow.Flow -import kotlinx.rpc.RemoteService import kotlinx.rpc.annotations.Rpc import kotlinx.serialization.Serializable @@ -14,7 +13,7 @@ data class UserData( ) @Rpc -interface UserService : RemoteService { +interface UserService { suspend fun hello(user: String, userData: UserData): String fun subscribeToNews(): Flow 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 01a658e50..1caf656aa 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 @@ -13,7 +13,7 @@ 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 { +fun createRpcClient(): RpcClient { return HttpClient(OkHttp) { installKrpc() }.rpc { 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 65a80c57b..c833084af 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 @@ -6,6 +6,7 @@ package kotlinx.rpc.sample.ui import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.CoroutineScope import kotlinx.rpc.sample.data.createRpcClient import kotlinx.rpc.sample.ui.state.WelcomeData import kotlinx.coroutines.Dispatchers @@ -15,49 +16,40 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch import kotlinx.rpc.RpcClient -import kotlinx.rpc.krpc.streamScoped import kotlinx.rpc.withService import kotlinx.rpc.sample.MyService import kotlinx.rpc.sample.UserData class AppViewModel : ViewModel() { - private var rpcClient: RpcClient? = null - private var apiService: MyService? = null + private val rpcClient: RpcClient = createRpcClient() + private val apiService: MyService = rpcClient.withService() private val _uiState = MutableStateFlow(null) val uiState: StateFlow = _uiState init { viewModelScope.launch(Dispatchers.IO) { - rpcClient = createRpcClient() - rpcClient?.let { - apiService = it.withService() - fetchData() - } + fetchData() } } - private fun fetchData() { - viewModelScope.launch(Dispatchers.IO) { - delay(2000) - val greetingDeferred = async { - apiService?.hello( - "Alex", - UserData("Berlin", "Smith") - ) - } - - val serverGreeting = greetingDeferred.await() - - val allNews: MutableList = mutableListOf() - apiService?.subscribeToNews()?.collect { - allNews += it - - val sendNews = allNews.toMutableList() // fix ConcurrentModificationException - serverGreeting?.let { - _uiState.value = WelcomeData(serverGreeting, sendNews) - } - } + private suspend fun CoroutineScope.fetchData() { + delay(2000) + val greetingDeferred = async { + apiService.hello( + "Alex", + UserData("Berlin", "Smith") + ) + } + + val serverGreeting = greetingDeferred.await() + + val allNews: MutableList = mutableListOf() + apiService.subscribeToNews().collect { + allNews += it + + val sendNews = allNews.toMutableList() // fix ConcurrentModificationException + _uiState.value = WelcomeData(serverGreeting, sendNews) } } } diff --git a/samples/ktor-android-app/common/src/main/kotlin/kotlinx/rpc/sample/MyService.kt b/samples/ktor-android-app/common/src/main/kotlin/kotlinx/rpc/sample/MyService.kt index a5bf328a9..4ddc48a38 100644 --- a/samples/ktor-android-app/common/src/main/kotlin/kotlinx/rpc/sample/MyService.kt +++ b/samples/ktor-android-app/common/src/main/kotlin/kotlinx/rpc/sample/MyService.kt @@ -5,11 +5,10 @@ package kotlinx.rpc.sample import kotlinx.coroutines.flow.Flow -import kotlinx.rpc.RemoteService import kotlinx.rpc.annotations.Rpc @Rpc -interface MyService : RemoteService { +interface MyService { suspend fun hello(user: String, userData: UserData): String fun subscribeToNews(): Flow diff --git a/samples/ktor-android-app/gradle/libs.versions.toml b/samples/ktor-android-app/gradle/libs.versions.toml index 994cb9322..1d76e5a6e 100644 --- a/samples/ktor-android-app/gradle/libs.versions.toml +++ b/samples/ktor-android-app/gradle/libs.versions.toml @@ -1,21 +1,21 @@ [versions] -agp = "8.9.1" -kotlin = "2.1.21" +agp = "8.11.0-alpha07" +kotlin = "2.2.0" androidx-activityCompose = "1.10.1" -androidx-appcompat = "1.7.0" +androidx-appcompat = "1.7.1" androidx-constraintlayout = "2.2.1" androidx-core-ktx = "1.16.0" androidx-test-junit = "1.2.1" -compose = "1.7.8" +compose = "1.8.3" compose-plugin = "1.5.14" # https://mvnrepository.com/artifact/androidx.compose.compiler/compiler -compose-bom = "2025.04.00" +compose-bom = "2025.06.01" material3 = "1.3.2" junit = "4.13.2" -ktor = "3.1.2" +ktor = "3.2.0" kotlinx-serialization-json = "1.8.1" kotlinx-coroutines-core = "1.10.2" logback = "1.5.18" -kotlinx-rpc = "0.7.0" +kotlinx-rpc = "0.8.0" [libraries] # kotlin diff --git a/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.jar b/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.jar index 9bbc975c7..1b33c55ba 100644 Binary files a/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.jar and b/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.properties b/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.properties index 37f853b1c..ff23a68d7 100644 --- a/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.properties +++ b/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/samples/ktor-android-app/gradlew b/samples/ktor-android-app/gradlew index faf93008b..23d15a936 100755 --- a/samples/ktor-android-app/gradlew +++ b/samples/ktor-android-app/gradlew @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/samples/ktor-android-app/gradlew.bat b/samples/ktor-android-app/gradlew.bat index 9d21a2183..db3a6ac20 100644 --- a/samples/ktor-android-app/gradlew.bat +++ b/samples/ktor-android-app/gradlew.bat @@ -70,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell 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 1ac0a6929..68975fcdc 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 @@ -24,7 +24,7 @@ fun Application.module() { } } - registerService { ctx -> MyServiceImpl(ctx) } + registerService { MyServiceImpl() } } } } diff --git a/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/MyServiceImpl.kt b/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/MyServiceImpl.kt index 453dee6f3..76b9e6a16 100644 --- a/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/MyServiceImpl.kt +++ b/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/MyServiceImpl.kt @@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlin.coroutines.CoroutineContext -class MyServiceImpl(override val coroutineContext: CoroutineContext) : MyService { +class MyServiceImpl : MyService { override suspend fun hello(user: String, userData: UserData): String { return "Nice to meet you $user, how is it in ${userData.address}?" } @@ -22,4 +22,4 @@ class MyServiceImpl(override val coroutineContext: CoroutineContext) : MyService } } } -} \ No newline at end of file +} diff --git a/samples/ktor-web-app/common/src/commonMain/kotlin/Common.kt b/samples/ktor-web-app/common/src/commonMain/kotlin/Common.kt index 7618312a1..824f086ef 100644 --- a/samples/ktor-web-app/common/src/commonMain/kotlin/Common.kt +++ b/samples/ktor-web-app/common/src/commonMain/kotlin/Common.kt @@ -3,7 +3,6 @@ */ import kotlinx.coroutines.flow.Flow -import kotlinx.rpc.RemoteService import kotlinx.rpc.annotations.Rpc import kotlinx.serialization.Serializable @@ -14,7 +13,7 @@ data class UserData( ) @Rpc -interface MyService : RemoteService { +interface MyService { suspend fun hello(user: String, userData: UserData): String fun subscribeToNews(): Flow diff --git a/samples/ktor-web-app/frontend/src/jsMain/kotlin/App.kt b/samples/ktor-web-app/frontend/src/jsMain/kotlin/App.kt index a81cc7440..cc7737f0d 100644 --- a/samples/ktor-web-app/frontend/src/jsMain/kotlin/App.kt +++ b/samples/ktor-web-app/frontend/src/jsMain/kotlin/App.kt @@ -2,7 +2,6 @@ * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ -import kotlinx.rpc.RpcClient import kotlinx.rpc.withService import react.FC import react.Props @@ -11,20 +10,10 @@ import react.useEffectOnce import react.useState val App = FC { - var rpcClient by useState(null) + val rpcClient = initRpcClient() - useEffectOnce { - rpcClient = initRpcClient() - } - - rpcClient?.also { client -> - AppContainer { - this.apiService = client.withService() - } - } ?: run { - div { - +"Establishing connection..." - } + AppContainer { + apiService = rpcClient.withService() } } 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 1330b72d2..766bb551e 100644 --- a/samples/ktor-web-app/frontend/src/jsMain/kotlin/RPC.kt +++ b/samples/ktor-web-app/frontend/src/jsMain/kotlin/RPC.kt @@ -11,7 +11,7 @@ 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 { +fun initRpcClient(): RpcClient { return HttpClient(Js) { installKrpc() }.rpc { diff --git a/samples/ktor-web-app/gradle/libs.versions.toml b/samples/ktor-web-app/gradle/libs.versions.toml index 152bec720..782dc9fdd 100644 --- a/samples/ktor-web-app/gradle/libs.versions.toml +++ b/samples/ktor-web-app/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -kotlin = "2.1.21" -kotlin-wrappers-bom = "2025.4.8" -ktor = "3.1.2" +kotlin = "2.2.0" +kotlin-wrappers-bom = "2025.6.11" +ktor = "3.2.0" kotlinx-serialization-json = "1.8.1" kotlinx-coroutines-core = "1.10.2" logback = "1.5.18" -kotlinx-rpc = "0.7.0" +kotlinx-rpc = "0.8.0" [libraries] # kotlin diff --git a/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.jar b/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.jar index 9bbc975c7..1b33c55ba 100644 Binary files a/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.jar and b/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.properties b/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.properties index 37f853b1c..ff23a68d7 100644 --- a/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.properties +++ b/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/samples/ktor-web-app/gradlew b/samples/ktor-web-app/gradlew index faf93008b..23d15a936 100755 --- a/samples/ktor-web-app/gradlew +++ b/samples/ktor-web-app/gradlew @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/samples/ktor-web-app/gradlew.bat b/samples/ktor-web-app/gradlew.bat index 9d21a2183..db3a6ac20 100644 --- a/samples/ktor-web-app/gradlew.bat +++ b/samples/ktor-web-app/gradlew.bat @@ -70,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell 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 13b1580cf..fe789c46f 100644 --- a/samples/ktor-web-app/server/src/main/kotlin/Application.kt +++ b/samples/ktor-web-app/server/src/main/kotlin/Application.kt @@ -28,7 +28,7 @@ fun Application.module() { } } - registerService { ctx -> MyServiceImpl(ctx) } + registerService { MyServiceImpl() } } staticResources("/", "/static") { diff --git a/samples/ktor-web-app/server/src/main/kotlin/MyServiceImpl.kt b/samples/ktor-web-app/server/src/main/kotlin/MyServiceImpl.kt index bfaeb660a..1f07766aa 100644 --- a/samples/ktor-web-app/server/src/main/kotlin/MyServiceImpl.kt +++ b/samples/ktor-web-app/server/src/main/kotlin/MyServiceImpl.kt @@ -5,9 +5,8 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow -import kotlin.coroutines.CoroutineContext -class MyServiceImpl(override val coroutineContext: CoroutineContext) : MyService { +class MyServiceImpl : MyService { override suspend fun hello(user: String, userData: UserData): String { return "Nice to meet you $user, how is it in ${userData.address}?" } 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 725623e90..1bf295e53 100644 --- a/samples/ktor-web-app/server/src/test/kotlin/ApplicationTest.kt +++ b/samples/ktor-web-app/server/src/test/kotlin/ApplicationTest.kt @@ -8,7 +8,6 @@ import kotlinx.rpc.krpc.ktor.client.installKrpc 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 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 5483a9a57..b8c9987e2 100644 --- a/samples/simple-ktor-app/build.gradle.kts +++ b/samples/simple-ktor-app/build.gradle.kts @@ -3,10 +3,10 @@ */ plugins { - kotlin("jvm") version "2.1.21" - kotlin("plugin.serialization") version "2.1.21" - id("io.ktor.plugin") version "3.1.2" - id("org.jetbrains.kotlinx.rpc.plugin") version "0.7.0" + kotlin("jvm") version "2.2.0" + kotlin("plugin.serialization") version "2.2.0" + id("io.ktor.plugin") version "3.2.0" + id("org.jetbrains.kotlinx.rpc.plugin") version "0.8.0" } group = "kotlinx.rpc.sample" @@ -28,17 +28,17 @@ kotlin { } dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.7.0") - implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.7.0") - implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.7.0") + implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-client:0.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-server:0.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-serialization-json:0.8.0") - implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client:0.7.0") - implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.7.0") + implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client:0.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.8.0") implementation("io.ktor:ktor-client-cio") implementation("io.ktor:ktor-server-netty-jvm") implementation("ch.qos.logback:logback-classic:1.5.18") testImplementation("io.ktor:ktor-server-test-host") - testImplementation("org.jetbrains.kotlin:kotlin-test-junit:2.1.21") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit:2.2.0") } diff --git a/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.jar b/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.jar index 9bbc975c7..1b33c55ba 100644 Binary files a/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.jar and b/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.properties b/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.properties index 37f853b1c..ff23a68d7 100644 --- a/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.properties +++ b/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/samples/simple-ktor-app/gradlew b/samples/simple-ktor-app/gradlew index faf93008b..23d15a936 100755 --- a/samples/simple-ktor-app/gradlew +++ b/samples/simple-ktor-app/gradlew @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/samples/simple-ktor-app/gradlew.bat b/samples/simple-ktor-app/gradlew.bat index 9d21a2183..db3a6ac20 100644 --- a/samples/simple-ktor-app/gradlew.bat +++ b/samples/simple-ktor-app/gradlew.bat @@ -70,11 +70,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/samples/simple-ktor-app/src/main/kotlin/Client.kt b/samples/simple-ktor-app/src/main/kotlin/Client.kt index c62e588c6..78cbeb0a6 100644 --- a/samples/simple-ktor-app/src/main/kotlin/Client.kt +++ b/samples/simple-ktor-app/src/main/kotlin/Client.kt @@ -4,7 +4,6 @@ import io.ktor.client.* import io.ktor.http.* -import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.flow import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking @@ -54,7 +53,6 @@ fun main() = runBlocking { val categories = recognizer.recognizeAll(imageFlow) categories.collect { println("Recognized category: $it") } - recognizer.cancel() ktorClient.close() stateJob.cancel() } diff --git a/samples/simple-ktor-app/src/main/kotlin/ImageRecognizer.kt b/samples/simple-ktor-app/src/main/kotlin/ImageRecognizer.kt index f2ccd0920..676293dab 100644 --- a/samples/simple-ktor-app/src/main/kotlin/ImageRecognizer.kt +++ b/samples/simple-ktor-app/src/main/kotlin/ImageRecognizer.kt @@ -7,10 +7,8 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.map -import kotlinx.rpc.RemoteService import kotlinx.rpc.annotations.Rpc import kotlinx.serialization.Serializable -import kotlin.coroutines.CoroutineContext @Suppress("ArrayInDataClass") @Serializable @@ -26,7 +24,7 @@ enum class Category { } @Rpc -interface ImageRecognizer : RemoteService { +interface ImageRecognizer { fun currentlyProcessedImage(): Flow suspend fun recognize(image: Image): Category @@ -34,7 +32,7 @@ interface ImageRecognizer : RemoteService { fun recognizeAll(images: Flow): Flow } -class ImageRecognizerService(override val coroutineContext: CoroutineContext) : ImageRecognizer { +class ImageRecognizerService : ImageRecognizer { private val _currentlyProcessedImage: MutableStateFlow = MutableStateFlow(null) override fun currentlyProcessedImage(): Flow { diff --git a/samples/simple-ktor-app/src/main/kotlin/Server.kt b/samples/simple-ktor-app/src/main/kotlin/Server.kt index b8fb73b34..7922da367 100644 --- a/samples/simple-ktor-app/src/main/kotlin/Server.kt +++ b/samples/simple-ktor-app/src/main/kotlin/Server.kt @@ -27,7 +27,7 @@ fun Application.module() { } } - registerService { ctx -> ImageRecognizerService(ctx) } + registerService { ImageRecognizerService() } } } } diff --git a/samples/simple-ktor-app/src/test/kotlin/ApplicationTest.kt b/samples/simple-ktor-app/src/test/kotlin/ApplicationTest.kt index 7c3482fed..dfcd499b6 100644 --- a/samples/simple-ktor-app/src/test/kotlin/ApplicationTest.kt +++ b/samples/simple-ktor-app/src/test/kotlin/ApplicationTest.kt @@ -7,13 +7,10 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel import kotlinx.coroutines.launch -import kotlinx.rpc.awaitFieldInitialization import kotlinx.rpc.krpc.ktor.client.installKrpc -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 org.junit.Test import kotlin.test.assertContentEquals