├── utils
├── api
│ ├── utils.api
│ └── utils.klib.api
├── src
│ ├── commonMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ └── utils
│ │ │ ├── ExperimentalRpcApi.kt
│ │ │ ├── InternalRpcApi.kt
│ │ │ ├── hex
│ │ │ └── HexBytes.kt
│ │ │ └── deferredUtil.kt
│ ├── jvmMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ └── utils
│ │ │ └── thread
│ │ │ └── ThreadLocal.jvm.kt
│ ├── wasmJsMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ └── utils
│ │ │ ├── map
│ │ │ └── ConcurrentHashMap.wasm.kt
│ │ │ └── thread
│ │ │ └── ThreadLocal.wasm.kt
│ ├── wasmWasiMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ └── utils
│ │ │ ├── map
│ │ │ └── ConcurrentHashMap.wasi.kt
│ │ │ └── thread
│ │ │ └── ThreadLocal.wasi.kt
│ ├── jsMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ └── utils
│ │ │ ├── map
│ │ │ └── ConcurrentHashMap.js.kt
│ │ │ └── thread
│ │ │ └── ThreadLocal.js.kt
│ └── nativeMain
│ │ └── kotlin
│ │ └── kotlinx
│ │ └── rpc
│ │ └── internal
│ │ └── utils
│ │ ├── map
│ │ └── ConcurrentHashMap.native.kt
│ │ └── thread
│ │ └── ThreadLocal.native.kt
└── build.gradle.kts
├── docs
└── pages
│ ├── .gitignore
│ ├── kotlinx-rpc
│ ├── .idea
│ │ ├── .gitignore
│ │ ├── vcs.xml
│ │ ├── modules.xml
│ │ └── kotlinx-rpc.iml
│ ├── preview.png
│ ├── help-versions.json
│ ├── images
│ │ ├── icon16.png
│ │ ├── icon300.png
│ │ ├── icon32.png
│ │ ├── icon500.png
│ │ └── icon96.png
│ ├── c.list
│ ├── writerside.cfg
│ └── topics
│ │ └── service-descriptors.topic
│ ├── .idea
│ ├── .gitignore
│ └── vcs.xml
│ └── assets
│ └── homepage.svg
├── krpc
├── krpc-logging
│ ├── api
│ │ ├── krpc-logging.api
│ │ └── krpc-logging.klib.api
│ └── build.gradle.kts
├── krpc-ktor
│ ├── krpc-ktor-core
│ │ ├── api
│ │ │ ├── krpc-ktor-core.api
│ │ │ └── krpc-ktor-core.klib.api
│ │ └── src
│ │ │ └── jvmTest
│ │ │ └── resources
│ │ │ └── logback.xml
│ ├── gradle.properties
│ ├── krpc-ktor-server
│ │ ├── src
│ │ │ └── commonMain
│ │ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── ktor
│ │ │ │ └── server
│ │ │ │ ├── KtorKrpcServer.kt
│ │ │ │ └── Krpc.kt
│ │ └── build.gradle.kts
│ └── krpc-ktor-client
│ │ └── build.gradle.kts
├── krpc-test
│ ├── src
│ │ ├── jvmTest
│ │ │ ├── resources
│ │ │ │ ├── indexed_enum_dumps
│ │ │ │ │ ├── RPCPlugin.gold
│ │ │ │ │ ├── CancellationType.gold
│ │ │ │ │ ├── RPCPluginKey.gold
│ │ │ │ │ ├── KrpcPlugin.gold
│ │ │ │ │ └── KrpcPluginKey.gold
│ │ │ │ ├── class_dumps
│ │ │ │ │ ├── CallType.gold
│ │ │ │ │ ├── KrpcPlugin.gold
│ │ │ │ │ ├── KrpcPluginKey.gold
│ │ │ │ │ ├── StackElement.gold
│ │ │ │ │ ├── KrpcGenericMessage.gold
│ │ │ │ │ ├── Handshake.gold
│ │ │ │ │ ├── CallSuccessString.gold
│ │ │ │ │ ├── SerializedException.gold
│ │ │ │ │ ├── CallSuccessBinary.gold
│ │ │ │ │ ├── Failure.gold
│ │ │ │ │ ├── StreamFinished.gold
│ │ │ │ │ ├── StreamMessageString.gold
│ │ │ │ │ ├── CallException.gold
│ │ │ │ │ ├── StreamMessageBinary.gold
│ │ │ │ │ ├── KrpcProtocolMessage.gold
│ │ │ │ │ ├── StreamCancel.gold
│ │ │ │ │ ├── KrpcMessage.gold
│ │ │ │ │ ├── CallDataString.gold
│ │ │ │ │ ├── CallResult.gold
│ │ │ │ │ ├── CallDataBinary.gold
│ │ │ │ │ ├── CallSuccess.gold
│ │ │ │ │ ├── StreamMessage.gold
│ │ │ │ │ ├── CallData.gold
│ │ │ │ │ └── KrpcCallMessage.gold
│ │ │ │ └── logback.xml
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ ├── TransportTest.jvm.kt
│ │ │ │ └── TestLogAppender.kt
│ │ ├── jsTest
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── TransportTest.js.kt
│ │ ├── nativeTest
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── TransportTest.native.kt
│ │ ├── wasmJsTest
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── TransportTest.wasmJs.kt
│ │ ├── wasmWasiTest
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── TransportTest.wasmWasi.kt
│ │ ├── jsMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── KrpcTransportTestBase.js.kt
│ │ ├── jvmMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── KrpcTransportTestBase.jvm.kt
│ │ ├── nativeMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── KrpcTransportTestBase.native.kt
│ │ ├── wasmJsMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── KrpcTransportTestBase.wasmJs.kt
│ │ ├── wasmWasiMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── KrpcTransportTestBase.wasmWasi.kt
│ │ └── commonMain
│ │ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── test
│ │ │ ├── KrpcTestServer.kt
│ │ │ ├── KrpcTestClient.kt
│ │ │ └── Payloads.kt
│ └── gradle.properties
├── krpc-core
│ └── src
│ │ ├── jsTest
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── KrpcReceiveHandlerTest.js.kt
│ │ ├── jvmTest
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── KrpcReceiveHandlerTest.jvm.kt
│ │ ├── nativeTest
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── KrpcReceiveHandlerTest.native.kt
│ │ ├── wasmJsTest
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── KrpcReceiveHandlerTest.wasmJs.kt
│ │ ├── wasmWasiTest
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── KrpcReceiveHandlerTest.wasmWasi.kt
│ │ ├── commonMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── internal
│ │ │ ├── KrpcVersion.kt
│ │ │ ├── ObjectId.kt
│ │ │ ├── StreamSerializer.kt
│ │ │ └── SerializedException.kt
│ │ ├── wasmWasiMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── internal
│ │ │ └── ExceptionUtils.wasmWasi.kt
│ │ ├── jsMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── internal
│ │ │ └── ExceptionUtils.js.kt
│ │ ├── nativeMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── internal
│ │ │ └── ExceptionUtils.native.kt
│ │ └── wasmJsMain
│ │ └── kotlin
│ │ └── kotlinx
│ │ └── rpc
│ │ └── krpc
│ │ └── internal
│ │ └── ExceptionUtils.wasm.kt
├── krpc-serialization
│ ├── krpc-serialization-cbor
│ │ ├── api
│ │ │ ├── krpc-serialization-cbor.api
│ │ │ └── krpc-serialization-cbor.klib.api
│ │ └── build.gradle.kts
│ ├── krpc-serialization-json
│ │ ├── api
│ │ │ ├── krpc-serialization-json.api
│ │ │ └── krpc-serialization-json.klib.api
│ │ └── build.gradle.kts
│ ├── krpc-serialization-protobuf
│ │ ├── api
│ │ │ ├── krpc-serialization-protobuf.api
│ │ │ └── krpc-serialization-protobuf.klib.api
│ │ └── build.gradle.kts
│ └── krpc-serialization-core
│ │ └── build.gradle.kts
├── krpc-server
│ ├── src
│ │ └── commonMain
│ │ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── server
│ │ │ └── internal
│ │ │ └── StreamCall.kt
│ ├── api
│ │ └── krpc-server.api
│ └── build.gradle.kts
└── krpc-client
│ ├── src
│ └── commonMain
│ │ └── kotlin
│ │ └── kotlinx
│ │ └── rpc
│ │ └── krpc
│ │ └── client
│ │ └── internal
│ │ └── StreamCall.kt
│ └── build.gradle.kts
├── samples
├── ktor-android-app
│ ├── app
│ │ ├── .gitignore
│ │ ├── src
│ │ │ └── main
│ │ │ │ ├── res
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── themes.xml
│ │ │ │ │ └── colors.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ ├── ic_launcher.webp
│ │ │ │ │ └── ic_launcher_round.webp
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ ├── ic_launcher.webp
│ │ │ │ │ └── ic_launcher_round.webp
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ ├── ic_launcher.webp
│ │ │ │ │ └── ic_launcher_round.webp
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ ├── ic_launcher.webp
│ │ │ │ │ └── ic_launcher_round.webp
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ ├── ic_launcher.webp
│ │ │ │ │ └── ic_launcher_round.webp
│ │ │ │ ├── xml
│ │ │ │ │ ├── network_security_config.xml
│ │ │ │ │ ├── backup_rules.xml
│ │ │ │ │ └── data_extraction_rules.xml
│ │ │ │ └── mipmap-anydpi
│ │ │ │ │ ├── ic_launcher.xml
│ │ │ │ │ └── ic_launcher_round.xml
│ │ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── sample
│ │ │ │ ├── ui
│ │ │ │ ├── state
│ │ │ │ │ └── Welcome.kt
│ │ │ │ └── theme
│ │ │ │ │ └── Color.kt
│ │ │ │ └── data
│ │ │ │ └── Client.kt
│ │ └── proguard-rules.pro
│ ├── common
│ │ ├── .gitignore
│ │ ├── src
│ │ │ └── main
│ │ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── sample
│ │ │ │ ├── User.kt
│ │ │ │ └── MyService.kt
│ │ └── build.gradle.kts
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── .idea
│ │ └── .gitignore
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── server
│ │ └── src
│ │ │ └── main
│ │ │ ├── resources
│ │ │ ├── application.conf
│ │ │ └── logback.xml
│ │ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── sample
│ │ │ ├── MyServiceImpl.kt
│ │ │ └── Application.kt
│ ├── README.md
│ └── settings.gradle.kts
├── ktor-all-platforms-app
│ ├── .fleet
│ │ ├── settings.json
│ │ └── receipt.json
│ ├── composeApp
│ │ └── src
│ │ │ ├── androidMain
│ │ │ ├── kotlin
│ │ │ │ ├── App.android.kt
│ │ │ │ └── kotlinx
│ │ │ │ │ └── rpc
│ │ │ │ │ └── sample
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ │ └── xml
│ │ │ │ └── network_security_config.xml
│ │ │ ├── wasmJsMain
│ │ │ ├── kotlin
│ │ │ │ ├── App.wasmJs.kt
│ │ │ │ └── main.kt
│ │ │ └── resources
│ │ │ │ ├── styles.css
│ │ │ │ └── index.html
│ │ │ ├── iosMain
│ │ │ └── kotlin
│ │ │ │ ├── MainViewController.kt
│ │ │ │ └── App.ios.kt
│ │ │ └── desktopMain
│ │ │ └── kotlin
│ │ │ ├── App.desktop.kt
│ │ │ └── main.kt
│ ├── iosApp
│ │ ├── iosApp
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── Contents.json
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ ├── app-icon-1024.png
│ │ │ │ │ └── Contents.json
│ │ │ │ └── AccentColor.colorset
│ │ │ │ │ └── Contents.json
│ │ │ ├── Preview Content
│ │ │ │ └── Preview Assets.xcassets
│ │ │ │ │ └── Contents.json
│ │ │ ├── iOSApp.swift
│ │ │ └── ContentView.swift
│ │ └── Configuration
│ │ │ └── Config.xcconfig
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── shared
│ │ └── src
│ │ │ ├── wasmJsMain
│ │ │ └── kotlin
│ │ │ │ └── Platform.wasmJs.kt
│ │ │ ├── androidMain
│ │ │ └── kotlin
│ │ │ │ └── Platform.android.kt
│ │ │ ├── commonMain
│ │ │ └── kotlin
│ │ │ │ ├── Platform.kt
│ │ │ │ └── UserService.kt
│ │ │ ├── iosMain
│ │ │ └── kotlin
│ │ │ │ └── Platform.ios.kt
│ │ │ └── jvmMain
│ │ │ └── kotlin
│ │ │ └── Platform.jvm.kt
│ ├── .gitignore
│ ├── server
│ │ └── src
│ │ │ └── main
│ │ │ ├── resources
│ │ │ ├── application.conf
│ │ │ └── logback.xml
│ │ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── sample
│ │ │ └── UserServiceImpl.kt
│ ├── gradle.properties
│ ├── build.gradle.kts
│ └── settings.gradle.kts
├── grpc-app
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── src
│ │ └── main
│ │ │ ├── proto
│ │ │ └── image-recognizer.proto
│ │ │ ├── kotlin
│ │ │ ├── Server.kt
│ │ │ ├── ImageRecognizer.kt
│ │ │ └── Client.kt
│ │ │ └── resources
│ │ │ └── logback.xml
│ ├── settings.gradle.kts
│ ├── .gitignore
│ └── build.gradle.kts
├── ktor-web-app
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── .gitignore
│ ├── gradle.properties
│ ├── server
│ │ └── src
│ │ │ └── main
│ │ │ ├── resources
│ │ │ ├── static
│ │ │ │ └── index.html
│ │ │ ├── application.conf
│ │ │ └── logback.xml
│ │ │ └── kotlin
│ │ │ └── MyServiceImpl.kt
│ ├── frontend
│ │ ├── webpack.config.d
│ │ │ └── config.js
│ │ └── src
│ │ │ └── jsMain
│ │ │ ├── resources
│ │ │ └── index.html
│ │ │ └── kotlin
│ │ │ ├── Main.kt
│ │ │ └── RPC.kt
│ ├── settings.gradle.kts
│ ├── build.gradle.kts
│ ├── common
│ │ ├── src
│ │ │ └── commonMain
│ │ │ │ └── kotlin
│ │ │ │ └── Common.kt
│ │ └── build.gradle.kts
│ └── README.md
└── simple-ktor-app
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── settings.gradle.kts
│ ├── .gitignore
│ └── src
│ └── main
│ ├── resources
│ └── logback.xml
│ └── kotlin
│ └── Server.kt
├── jpms-check
└── .gitignore
├── gradle
├── artifacts
│ ├── publishMavenPublicationToBuildRepoRepository.txt
│ └── publishBomPublicationToBuildRepoRepository.txt
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── Dockerfile
├── .github
├── images
│ ├── logo.png
│ ├── logo_dark.png
│ └── logo_light.png
├── pull_request_template.md
├── workflows
│ ├── platforms.yml
│ ├── changelog.yml
│ └── readme.yml
├── release.yml
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .idea
├── codeStyles
│ └── codeStyleConfig.xml
├── copyright
│ ├── profiles_settings.xml
│ └── krpc_apache_2.xml
├── detekt.xml
├── kotlinx-rpc.iml
└── kotlinTestDataPluginTestDataPaths.xml
├── dokka-plugin
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── services
│ │ │ └── org.jetbrains.dokka.plugability.DokkaPlugin
│ │ └── kotlin
│ │ └── kotlinx
│ │ └── rpc
│ │ └── dokka
│ │ ├── AddDocsLinkPageTransformer.kt
│ │ └── RpcDokkaPlugin.kt
├── settings.gradle.kts
└── build.gradle.kts
├── .gitattributes
├── gradle-conventions
├── src
│ └── main
│ │ └── kotlin
│ │ ├── empty.gradle.kts
│ │ ├── util
│ │ ├── other
│ │ │ ├── capitalized.kt
│ │ │ ├── libs.kt
│ │ │ ├── action.kt
│ │ │ ├── directoryNames.kt
│ │ │ ├── publicModule.kt
│ │ │ ├── maybeNamed.kt
│ │ │ └── files.kt
│ │ ├── kover.kt
│ │ ├── forIde.kt
│ │ ├── contextParameters.kt
│ │ └── kotlinVersion.kt
│ │ ├── conventions-dokka-public.gradle.kts
│ │ └── conventions-jvm.gradle.kts
├── settings.gradle.kts
└── build.gradle.kts
├── CODE_OF_CONDUCT.md
├── tests
├── test-utils
│ ├── src
│ │ ├── commonMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── test
│ │ │ │ ├── runThreadIfPossible.kt
│ │ │ │ └── runTest.kt
│ │ ├── jsMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── test
│ │ │ │ ├── runTest.js.kt
│ │ │ │ └── runThreadIfPossible.js.kt
│ │ ├── nativeMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── test
│ │ │ │ ├── runTest.native.kt
│ │ │ │ └── runThreadIfPossible.native.kt
│ │ ├── wasmJsMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── test
│ │ │ │ ├── runTest.wasmJs.kt
│ │ │ │ └── runThreadIfPossible.wasmJs.kt
│ │ ├── wasmWasiMain
│ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── test
│ │ │ │ ├── runTest.wasmWasi.kt
│ │ │ │ └── runThreadIfPossible.wasmWasi.kt
│ │ └── jvmMain
│ │ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── test
│ │ │ ├── runThreadIfPossible.jvm.kt
│ │ │ └── runTest.jvm.kt
│ ├── api
│ │ └── test-utils.api
│ └── build.gradle.kts
├── krpc-compatibility-tests
│ └── src
│ │ ├── main
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── compatibility
│ │ │ ├── TestApiServer.kt
│ │ │ └── CompatibilityTest.kt
│ │ ├── oldApi
│ │ └── kotlin
│ │ │ ├── interfaces
│ │ │ ├── Bar.kt
│ │ │ ├── Baz.kt
│ │ │ └── Foo.kt
│ │ │ └── tests
│ │ │ └── ApiServer.kt
│ │ └── newApi
│ │ └── kotlin
│ │ ├── interfaces
│ │ ├── Bar.kt
│ │ ├── Baz.kt
│ │ └── Foo.kt
│ │ └── tests
│ │ └── ApiServer.kt
├── krpc-protocol-compatibility-tests
│ ├── test-api
│ │ ├── src
│ │ │ └── main
│ │ │ │ └── kotlin
│ │ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── krpc
│ │ │ │ └── test
│ │ │ │ └── compat
│ │ │ │ └── CompatWaitCounter.kt
│ │ └── build.gradle.kts
│ └── src
│ │ └── test
│ │ ├── kotlin
│ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── krpc
│ │ │ └── test
│ │ │ └── compat
│ │ │ └── TestLogAppender.kt
│ │ └── resources
│ │ └── logback.xml
└── compiler-plugin-tests
│ └── src
│ ├── main
│ └── kotlin
│ │ └── kotlinx
│ │ └── rpc
│ │ └── codegen
│ │ └── test
│ │ └── TestRpcClient.kt
│ ├── testData
│ └── box
│ │ ├── simple.kt
│ │ ├── flowParameter.kt
│ │ ├── multiModule.kt
│ │ └── serviceDescriptor.kt
│ └── test
│ └── kotlin
│ └── kotlinx
│ └── rpc
│ └── codegen
│ └── test
│ └── GenerateTests.kt
├── compiler-plugin
├── compiler-plugin-cli
│ ├── src
│ │ └── main
│ │ │ ├── kotlin
│ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── codegen
│ │ │ │ └── pluginId.kt
│ │ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ ├── org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
│ │ │ │ └── org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
│ │ │ └── templates
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── codegen
│ │ │ └── CompilerPluginRegistrar.kt
│ └── build.gradle.kts
├── compiler-plugin-common
│ └── build.gradle.kts
├── compiler-plugin-k2
│ ├── src
│ │ └── main
│ │ │ ├── kotlin
│ │ │ └── kotlinx
│ │ │ │ └── rpc
│ │ │ │ └── codegen
│ │ │ │ ├── checkers
│ │ │ │ └── diagnostics
│ │ │ │ │ └── RpcKtDiagnosticsContainerCore.kt
│ │ │ │ ├── RpcFirCliOptions.kt
│ │ │ │ └── FirRpcPredicates.kt
│ │ │ └── templates
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── codegen
│ │ │ └── checkers
│ │ │ └── diagnostics
│ │ │ └── RpcKtDiagnosticFactoryToRendererMap.kt
│ └── build.gradle.kts
├── compiler-plugin-backend
│ └── build.gradle.kts
├── settings.gradle.kts
└── build.gradle.kts
├── gradle-conventions-settings
├── develocity
│ ├── build.gradle.kts
│ └── src
│ │ └── main
│ │ └── kotlin
│ │ ├── execute.kt
│ │ └── params.kt
├── build.gradle.kts
└── src
│ └── main
│ └── kotlin
│ └── includePublic.kt
├── gradle-plugin
├── src
│ └── main
│ │ └── kotlin
│ │ └── kotlinx
│ │ └── rpc
│ │ ├── RpcDangerousApi.kt
│ │ └── RpcGradlePlugin.kt
└── settings.gradle.kts
├── core
├── src
│ ├── commonMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ ├── internal
│ │ │ └── internalServiceDescriptorOf.kt
│ │ │ ├── RemoteService.kt
│ │ │ └── RpcCall.kt
│ ├── jvmMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ ├── ReflectionUtils.jvm.kt
│ │ │ └── internalServiceDescriptorOf.jvm.kt
│ ├── jsMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ └── ReflectionUtils.js.kt
│ ├── wasmJsMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ └── ReflectionUtils.wasm.kt
│ ├── nativeMain
│ │ └── kotlin
│ │ │ └── kotlinx
│ │ │ └── rpc
│ │ │ └── internal
│ │ │ └── ReflectionUtils.native.kt
│ └── wasmWasiMain
│ │ └── kotlin
│ │ └── kotlinx
│ │ └── rpc
│ │ └── internal
│ │ └── ReflectionUtils.wasi.kt
└── build.gradle.kts
├── publishLocal.sh
├── .puppeteerrc.cjs
├── updateTestData.sh
├── versions-root
└── targets-since-kotlin-lookup.json
├── karma
└── chrome_bin.js
├── bom
└── build.gradle.kts
└── .gitignore
/utils/api/utils.api:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/pages/.gitignore:
--------------------------------------------------------------------------------
1 | api/**
2 |
--------------------------------------------------------------------------------
/krpc/krpc-logging/api/krpc-logging.api:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/samples/ktor-android-app/common/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/krpc/krpc-ktor/krpc-ktor-core/api/krpc-ktor-core.api:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/jpms-check/.gitignore:
--------------------------------------------------------------------------------
1 | src/main/java/module-info.java
2 |
--------------------------------------------------------------------------------
/gradle/artifacts/publishMavenPublicationToBuildRepoRepository.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # for local ci builds
2 | FROM stl5/ktor-test-image
3 | WORKDIR rpc/
4 | COPY . .
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.github/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/.github/images/logo.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/.fleet/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "gradle.autoImportOnSave": false
3 | }
--------------------------------------------------------------------------------
/.github/images/logo_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/.github/images/logo_dark.png
--------------------------------------------------------------------------------
/.github/images/logo_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/.github/images/logo_light.png
--------------------------------------------------------------------------------
/docs/pages/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | pages.iml
5 | modules.xml
6 |
--------------------------------------------------------------------------------
/gradle/artifacts/publishBomPublicationToBuildRepoRepository.txt:
--------------------------------------------------------------------------------
1 | org.jetbrains.kotlinx:kotlinx-rpc-bom/javadoc.jar
2 |
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/docs/pages/kotlinx-rpc/preview.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/indexed_enum_dumps/RPCPlugin.gold:
--------------------------------------------------------------------------------
1 | UNKNOWN - 0
2 | HANDSHAKE - 1
3 | CANCELLATION - 2
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/help-versions.json:
--------------------------------------------------------------------------------
1 | [
2 | {"version":"0.10.1","url":"/kotlinx-rpc/0.10.1/","isCurrent":true}
3 | ]
4 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/kotlin/App.android.kt:
--------------------------------------------------------------------------------
1 | actual val DEV_SERVER_HOST: String = "10.0.2.2"
2 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/App.wasmJs.kt:
--------------------------------------------------------------------------------
1 | actual val DEV_SERVER_HOST: String = "127.0.0.1"
2 |
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/images/icon16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/docs/pages/kotlinx-rpc/images/icon16.png
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/images/icon300.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/docs/pages/kotlinx-rpc/images/icon300.png
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/images/icon32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/docs/pages/kotlinx-rpc/images/icon32.png
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/images/icon500.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/docs/pages/kotlinx-rpc/images/icon500.png
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/images/icon96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/docs/pages/kotlinx-rpc/images/icon96.png
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/indexed_enum_dumps/CancellationType.gold:
--------------------------------------------------------------------------------
1 | ENDPOINT - 0
2 | SERVICE - 1
3 | REQUEST - 2
4 | CANCELLATION_ACK - 3
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | KtorApplication
3 |
--------------------------------------------------------------------------------
/samples/grpc-app/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/grpc-app/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/iosApp/iosApp/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
--------------------------------------------------------------------------------
/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/iosApp/Configuration/Config.xcconfig:
--------------------------------------------------------------------------------
1 | TEAM_ID=
2 | BUNDLE_ID=kotlinx.rpc.sample.ktor-all-platforms-app
3 | APP_NAME=ktor-all-platforms-app
--------------------------------------------------------------------------------
/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/samples/ktor-web-app/.gitignore:
--------------------------------------------------------------------------------
1 | **/build/**
2 | **/.gradle
3 |
4 | local.properties
5 | server/src/main/resources/static/*
6 | !server/src/main/resources/static/index.html
7 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/indexed_enum_dumps/RPCPluginKey.gold:
--------------------------------------------------------------------------------
1 | UNKNOWN - 0
2 | GENERIC_MESSAGE_TYPE - 1
3 | CANCELLATION_TYPE - 2
4 | CANCELLATION_ID - 3
5 | CLIENT_SERVICE_ID - 4
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/styles.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | width: 100%;
3 | height: 100%;
4 | margin: 0;
5 | padding: 0;
6 | overflow: hidden;
7 | }
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/indexed_enum_dumps/KrpcPlugin.gold:
--------------------------------------------------------------------------------
1 | UNKNOWN - 0
2 | HANDSHAKE - 1
3 | CANCELLATION - 2
4 | NON_SUSPENDING_SERVER_FLOWS - 3
5 | NO_ACK_CANCELLATION - 4
6 | BACKPRESSURE - 5
--------------------------------------------------------------------------------
/samples/grpc-app/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | kotlin.code.style=official
6 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/krpc/krpc-ktor/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | kotlinx.rpc.exclude.wasmWasi=true
6 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallType.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCMessage.CallType [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallType]
2 | Method
3 | Field
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/iosApp/iosApp/iOSApp.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | @main
4 | struct iOSApp: App {
5 | var body: some Scene {
6 | WindowGroup {
7 | ContentView()
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/samples/ktor-web-app/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | kotlin.code.style=official
6 |
--------------------------------------------------------------------------------
/samples/simple-ktor-app/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | kotlin.code.style=official
6 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/iosMain/kotlin/MainViewController.kt:
--------------------------------------------------------------------------------
1 | import androidx.compose.ui.window.ComposeUIViewController
2 |
3 | fun MainViewController() = ComposeUIViewController { App() }
4 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/KrpcPlugin.gold:
--------------------------------------------------------------------------------
1 | kotlinx.rpc.krpc.internal.KrpcPlugin
2 | UNKNOWN
3 | HANDSHAKE
4 | CANCELLATION
5 | NON_SUSPENDING_SERVER_FLOWS
6 | NO_ACK_CANCELLATION
7 | BACKPRESSURE
--------------------------------------------------------------------------------
/samples/simple-ktor-app/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | rootProject.name = "simple-ktor-app"
6 |
--------------------------------------------------------------------------------
/docs/pages/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/shared/src/wasmJsMain/kotlin/Platform.wasmJs.kt:
--------------------------------------------------------------------------------
1 | class WasmPlatform: Platform {
2 | override val name: String = "Web with Kotlin/Wasm"
3 | }
4 |
5 | actual fun getPlatform(): Platform = WasmPlatform()
6 |
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png
--------------------------------------------------------------------------------
/krpc/krpc-test/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | # tests fail with some obscure reason
6 | kotlinx.rpc.exclude.wasmJs.d8=true
7 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kotlin/kotlinx-rpc/HEAD/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/ktor-android-app/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/iosMain/kotlin/App.ios.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | actual val DEV_SERVER_HOST: String = "127.0.0.1"
6 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
--------------------------------------------------------------------------------
/dokka-plugin/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | kotlinx.rpc.dokka.RpcDokkaPlugin
6 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/indexed_enum_dumps/KrpcPluginKey.gold:
--------------------------------------------------------------------------------
1 | UNKNOWN - 0
2 | GENERIC_MESSAGE_TYPE - 1
3 | CANCELLATION_TYPE - 2
4 | CANCELLATION_ID - 3
5 | CLIENT_SERVICE_ID - 4
6 | NON_SUSPENDING_SERVER_FLOW_MARKER - 5
7 | WINDOW_UPDATE - 6
8 | WINDOW_KEY - 7
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | #
2 | # https://help.github.com/articles/dealing-with-line-endings/
3 | #
4 | # Linux start script should use lf
5 | /gradlew text eol=lf
6 |
7 | # These are Windows script files and should use crlf
8 | *.bat text eol=crlf
9 |
10 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/desktopMain/kotlin/App.desktop.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | actual val DEV_SERVER_HOST: String = "127.0.0.1"
6 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/shared/src/androidMain/kotlin/Platform.android.kt:
--------------------------------------------------------------------------------
1 | import android.os.Build
2 |
3 | class AndroidPlatform : Platform {
4 | override val name: String = "Android ${Build.VERSION.SDK_INT}"
5 | }
6 |
7 | actual fun getPlatform(): Platform = AndroidPlatform()
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/empty.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | // DON'T DELETE.
6 | // Resolves conventions classpath where no other convention is applied
7 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/server/src/main/resources/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | kotlinx.rpc Ktor Web App
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 |
3 | This project and the corresponding community is governed by the [JetBrains Open Source and Community Code of Conduct](https://confluence.jetbrains.com/display/ALL/JetBrains+Open+Source+and+Community+Code+of+Conduct). Please make sure you read it.
4 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/other/capitalized.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util.other
6 |
7 | fun String.capitalized() = replaceFirstChar(Char::titlecase)
8 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/KrpcPluginKey.gold:
--------------------------------------------------------------------------------
1 | kotlinx.rpc.krpc.internal.KrpcPluginKey
2 | UNKNOWN
3 | GENERIC_MESSAGE_TYPE
4 | CANCELLATION_TYPE
5 | CANCELLATION_ID
6 | CLIENT_SERVICE_ID
7 | NON_SUSPENDING_SERVER_FLOW_MARKER
8 | WINDOW_UPDATE
9 | WINDOW_KEY
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/StackElement.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.StackElement [Declared name: kotlinx.rpc.krpc.internal.StackElement]
2 | - clazz: kotlin.String
3 | - fileName: kotlin.String
4 | - Nullable
5 | - lineNumber: kotlin.Int
6 | - method: kotlin.String
--------------------------------------------------------------------------------
/samples/ktor-web-app/frontend/webpack.config.d/config.js:
--------------------------------------------------------------------------------
1 | if (config.devServer) {
2 | config.devServer.port = 3000;
3 | config.devServer.proxy = [
4 | {
5 | context: ['/api'],
6 | target: 'http://localhost:8080',
7 | },
8 | ];
9 | }
10 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jsTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val testIterations: Int = 10
8 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/KrpcGenericMessage.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCGenericMessage [Declared name: kotlinx.rpc.krpc.internal.KrpcGenericMessage]
2 | - connectionId: kotlin.Long
3 | - Nullable
4 | - pluginParams: kotlin.collections.Map
5 | - Nullable
--------------------------------------------------------------------------------
/samples/grpc-app/src/main/proto/image-recognizer.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | message Image {
4 | bytes data = 1;
5 | }
6 |
7 | message RecogniseResult {
8 | int32 category = 1;
9 | }
10 |
11 | service ImageRecognizer {
12 | rpc recognize(Image) returns (RecogniseResult);
13 | }
14 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val testIterations: Int = 1000
8 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/shared/src/commonMain/kotlin/Platform.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | interface Platform {
6 | val name: String
7 | }
8 |
9 | expect fun getPlatform(): Platform
--------------------------------------------------------------------------------
/tests/test-utils/src/commonMain/kotlin/kotlinx/rpc/test/runThreadIfPossible.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | expect fun runThreadIfPossible(runner: () -> Unit)
8 |
--------------------------------------------------------------------------------
/tests/test-utils/src/jsMain/kotlin/kotlinx/rpc/test/runTest.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | actual inline fun withDebugProbes(body: () -> T): T = body()
8 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-cli/src/main/kotlin/kotlinx/rpc/codegen/pluginId.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.codegen
6 |
7 | const val PLUGIN_ID = "org.jetbrains.kotlinx.rpc"
8 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-cli/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | kotlinx.rpc.codegen.RpcCommandLineProcessor
6 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-cli/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | kotlinx.rpc.codegen.RpcCompilerPlugin
6 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/nativeTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val testIterations: Int = 1000
8 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/wasmJsTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.wasmJs.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val testIterations: Int = 10
8 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/wasmWasiTest/kotlin/kotlinx/rpc/krpc/test/TransportTest.wasmWasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val testIterations: Int = 100
8 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 | ktor-all-platforms-app
7 |
--------------------------------------------------------------------------------
/tests/test-utils/src/nativeMain/kotlin/kotlinx/rpc/test/runTest.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | actual inline fun withDebugProbes(body: () -> T): T = body()
8 |
--------------------------------------------------------------------------------
/tests/test-utils/src/wasmJsMain/kotlin/kotlinx/rpc/test/runTest.wasmJs.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | actual inline fun withDebugProbes(body: () -> T): T = body()
8 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/shared/src/iosMain/kotlin/Platform.ios.kt:
--------------------------------------------------------------------------------
1 | import platform.UIKit.UIDevice
2 |
3 | class IOSPlatform: Platform {
4 | override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
5 | }
6 |
7 | actual fun getPlatform(): Platform = IOSPlatform()
--------------------------------------------------------------------------------
/tests/test-utils/src/jsMain/kotlin/kotlinx/rpc/test/runThreadIfPossible.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | actual inline fun runThreadIfPossible(runner: () -> Unit) = runner()
8 |
--------------------------------------------------------------------------------
/tests/test-utils/src/wasmWasiMain/kotlin/kotlinx/rpc/test/runTest.wasmWasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | actual inline fun withDebugProbes(body: () -> T): T = body()
8 |
--------------------------------------------------------------------------------
/samples/grpc-app/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/tests/test-utils/src/wasmJsMain/kotlin/kotlinx/rpc/test/runThreadIfPossible.wasmJs.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | actual inline fun runThreadIfPossible(runner: () -> Unit) = runner()
8 |
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
6 |
7 | rootProject.name = "ktor-web-app"
8 |
9 | include("common", "frontend", "server")
10 |
--------------------------------------------------------------------------------
/tests/test-utils/src/wasmWasiMain/kotlin/kotlinx/rpc/test/runThreadIfPossible.wasmWasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | actual inline fun runThreadIfPossible(runner: () -> Unit) = runner()
8 |
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/c.list:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/samples/simple-ktor-app/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/.idea/copyright/krpc_apache_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/Handshake.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCProtocolMessage.Handshake [Declared name: kotlinx.rpc.krpc.internal.KrpcProtocolMessage.Handshake]
2 | - connectionId: kotlin.Long
3 | - Nullable
4 | - pluginParams: kotlin.collections.Map
5 | - supportedPlugins: kotlin.collections.Set
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/.idea/kotlinx-rpc.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/jsTest/kotlin/kotlinx/rpc/krpc/KrpcReceiveHandlerTest.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc
6 |
7 | internal actual val stressIterations: Int = 3000
8 | internal actual val stressBufferSize: Int = 1500
9 |
--------------------------------------------------------------------------------
/tests/test-utils/src/jvmMain/kotlin/kotlinx/rpc/test/runThreadIfPossible.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | actual fun runThreadIfPossible(runner: () -> Unit) {
8 | Thread(runner).start()
9 | }
10 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/jvmTest/kotlin/kotlinx/rpc/krpc/KrpcReceiveHandlerTest.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc
6 |
7 | internal actual val stressIterations: Int = 8_000
8 | internal actual val stressBufferSize: Int = 1000
9 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/nativeTest/kotlin/kotlinx/rpc/krpc/KrpcReceiveHandlerTest.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc
6 |
7 | internal actual val stressIterations: Int = 3000
8 | internal actual val stressBufferSize: Int = 1500
9 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/wasmJsTest/kotlin/kotlinx/rpc/krpc/KrpcReceiveHandlerTest.wasmJs.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc
6 |
7 | internal actual val stressIterations: Int = 3000
8 | internal actual val stressBufferSize: Int = 1500
9 |
--------------------------------------------------------------------------------
/gradle-conventions-settings/develocity/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | `kotlin-dsl`
7 | }
8 |
9 | dependencies {
10 | implementation(libs.develocity)
11 | implementation(libs.common.custom.user.data)
12 | }
13 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/wasmWasiTest/kotlin/kotlinx/rpc/krpc/KrpcReceiveHandlerTest.wasmWasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc
6 |
7 | internal actual val stressIterations: Int = 3000
8 | internal actual val stressBufferSize: Int = 1500
9 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jsMain/kotlin/kotlinx/rpc/krpc/test/KrpcTransportTestBase.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val platform: Platform = Platform.JS
8 | internal actual val iterations_100_000: Int = 10_000
9 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmMain/kotlin/kotlinx/rpc/krpc/test/KrpcTransportTestBase.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val platform: Platform = Platform.JVM
8 | internal actual val iterations_100_000: Int = 100_000
9 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "app-icon-1024.png",
5 | "idiom" : "universal",
6 | "platform" : "ios",
7 | "size" : "1024x1024"
8 | }
9 | ],
10 | "info" : {
11 | "author" : "xcode",
12 | "version" : 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | localhost
5 | 10.0.2.2
6 |
7 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/kotlin/main.kt:
--------------------------------------------------------------------------------
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 | }
12 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/ui/state/Welcome.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.sample.ui.state
6 |
7 | data class WelcomeData(
8 | val serverGreeting: String,
9 | val news: List,
10 | )
11 |
--------------------------------------------------------------------------------
/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcDangerousApi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc
6 |
7 | @RequiresOptIn("This API is dangerous. It is not recommended to use it, unless you know what you are doing.")
8 | public annotation class RpcDangerousApi
9 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/nativeMain/kotlin/kotlinx/rpc/krpc/test/KrpcTransportTestBase.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val platform: Platform = Platform.NATIVE
8 | internal actual val iterations_100_000: Int = 100_000
9 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/wasmJsMain/kotlin/kotlinx/rpc/krpc/test/KrpcTransportTestBase.wasmJs.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val platform: Platform = Platform.WASM_JS
8 | internal actual val iterations_100_000: Int = 10_000
9 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/wasmWasiMain/kotlin/kotlinx/rpc/krpc/test/KrpcTransportTestBase.wasmWasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | internal actual val platform: Platform = Platform.WASI
8 | internal actual val iterations_100_000: Int = 10_000
9 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/shared/src/jvmMain/kotlin/Platform.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | class JVMPlatform: Platform {
6 | override val name: String = "Java ${System.getProperty("java.version")}"
7 | }
8 |
9 | actual fun getPlatform(): Platform = JVMPlatform()
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **Subsystem**
2 | Client/Server, related modules
3 |
4 | **Problem Description**
5 | Describe what problem this PR solves and why it is important. Refer to a bug/ticket #.
6 |
7 | **Solution**
8 | Describe your solution.
9 |
10 | **ATTENTION**
11 | Provide this pull request with proper labels, it is important to simplify generation of releases.
12 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/conventions-dokka-public.gradle.kts:
--------------------------------------------------------------------------------
1 | import util.other.isPublicModule
2 | import util.other.libs
3 |
4 | /*
5 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
6 | */
7 |
8 | if (isPublicModule) {
9 | plugins.apply(libs.plugins.conventions.dokka.spec.get().pluginId)
10 | }
11 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/server/src/main/resources/application.conf:
--------------------------------------------------------------------------------
1 | ktor {
2 | environment = development
3 | environment = ${?KTOR_ENV}
4 |
5 | application {
6 | modules = [ApplicationKt.module]
7 | }
8 |
9 | deployment {
10 | host = 127.0.0.1
11 | port = 8080
12 | }
13 |
14 | logger {
15 | level = INFO
16 | level = ${?KTOR_LOGGER_LEVEL_INFO}
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/other/libs.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util.other
6 |
7 | import org.gradle.accessors.dm.LibrariesForLibs
8 | import org.gradle.api.Project
9 | import org.gradle.kotlin.dsl.the
10 |
11 | val Project.libs get() = the()
12 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/common/src/main/kotlin/kotlinx/rpc/sample/User.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.sample
6 |
7 | import kotlinx.serialization.Serializable
8 |
9 | @Serializable
10 | data class UserData(
11 | val address: String,
12 | val lastName: String,
13 | )
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/main/kotlin/kotlinx/rpc/krpc/compatibility/TestApiServer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.compatibility
6 |
7 | import kotlinx.rpc.RpcServer
8 |
9 | interface TestApiServer {
10 | fun serveAllInterfaces(rpcServer: RpcServer)
11 | }
12 |
--------------------------------------------------------------------------------
/samples/grpc-app/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | rootProject.name = "grpc-app"
6 |
7 | pluginManagement {
8 | repositories {
9 | gradlePluginPortal()
10 | mavenCentral()
11 | maven("https://maven.pkg.jetbrains.space/public/p/krpc/grpc")
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.androidApplication) apply false
7 | alias(libs.plugins.kotlinAndroid) apply false
8 | alias(libs.plugins.kotlinJvm) apply false
9 | alias(libs.plugins.compose.compiler) apply false
10 | }
--------------------------------------------------------------------------------
/samples/ktor-android-app/server/src/main/resources/application.conf:
--------------------------------------------------------------------------------
1 | ktor {
2 | environment = development
3 | environment = ${?KTOR_ENV}
4 |
5 | application {
6 | modules = [kotlinx.rpc.sample.ApplicationKt.module]
7 | }
8 |
9 | deployment {
10 | host = localhost
11 | port = 8080
12 | }
13 |
14 | logger {
15 | level = INFO
16 | level = ${?KTOR_LOGGER_LEVEL_INFO}
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | **/build/
4 | xcuserdata
5 | !src/**/build/
6 | local.properties
7 | .idea
8 | .DS_Store
9 | captures
10 | .externalNativeBuild
11 | .cxx
12 | *.xcodeproj/*
13 | !*.xcodeproj/project.pbxproj
14 | !*.xcodeproj/xcshareddata/
15 | !*.xcodeproj/project.xcworkspace/
16 | !*.xcworkspace/contents.xcworkspacedata
17 | **/xcshareddata/WorkspaceSettings.xcsettings
18 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/server/src/main/resources/application.conf:
--------------------------------------------------------------------------------
1 | ktor {
2 | environment = development
3 | environment = ${?KTOR_ENV}
4 |
5 | application {
6 | modules = [kotlinx.rpc.sample.ApplicationKt.module]
7 | }
8 |
9 | deployment {
10 | host = 127.0.0.1
11 | port = 8080
12 | }
13 |
14 | logger {
15 | level = INFO
16 | level = ${?KTOR_LOGGER_LEVEL_INFO}
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-anydpi/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/core/src/commonMain/kotlin/kotlinx/rpc/internal/internalServiceDescriptorOf.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 | import kotlin.reflect.KClass
9 |
10 | internal expect fun <@Rpc T : Any> internalServiceDescriptorOf(kClass: KClass): Any?
11 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/frontend/src/jsMain/resources/index.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 | Kotlin JS kRPC Sample
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/tests/krpc-protocol-compatibility-tests/test-api/src/main/kotlin/kotlinx/rpc/krpc/test/compat/CompatWaitCounter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test.compat
6 |
7 | interface CompatWaitCounter {
8 | val value: Int
9 | fun increment()
10 | suspend fun await(value: Int)
11 | }
12 |
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/main/kotlin/kotlinx/rpc/krpc/compatibility/CompatibilityTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.compatibility
6 |
7 | import kotlinx.rpc.RpcClient
8 |
9 | interface CompatibilityTest {
10 | fun getAllTests(): Map Unit>
11 | }
12 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/KrpcVersion.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.internal
6 |
7 | /**
8 | * Release versions of the library
9 | */
10 | internal enum class KrpcVersion {
11 | V_0_1_0_BETA,
12 | V_0_6_0,
13 | V_0_8_0,
14 | V_0_10_0,
15 | }
16 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.kotlin.multiplatform) apply false
7 | alias(libs.plugins.kotlinx.rpc) apply false
8 | }
9 |
10 | allprojects {
11 | version = "0.1"
12 |
13 | repositories {
14 | mavenCentral()
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/gradle-conventions-settings/develocity/src/main/kotlin/execute.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import org.gradle.api.initialization.Settings
6 |
7 | fun Settings.execute(cmd: String): String {
8 | return settings.providers.exec {
9 | commandLine(cmd.split(" "))
10 | }.standardOutput.asText.get().trim()
11 | }
12 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallSuccessString.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.RPCMessage.CallSuccess [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallSuccessString]
2 | - callId: kotlin.String
3 | - connectionId: kotlin.Long
4 | - Nullable
5 | - data: kotlin.String
6 | - pluginParams: kotlin.collections.Map
7 | - Nullable
8 | - serviceId: kotlin.Long
9 | - Nullable
10 | - serviceType: kotlin.String
--------------------------------------------------------------------------------
/.idea/detekt.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle-conventions-settings/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | `kotlin-dsl`
7 | }
8 |
9 | dependencies {
10 | // https://stackoverflow.com/questions/76713758/use-version-catalog-inside-precompiled-gradle-plugin
11 | api(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
12 | }
13 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/SerializedException.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.SerializedException [Declared name: kotlinx.rpc.krpc.internal.SerializedException]
2 | - cause: org.jetbrains.krpc.SerializedException
3 | - Nullable
4 | - Declared name: kotlinx.rpc.krpc.internal.SerializedException
5 | - className: kotlin.String
6 | - message: kotlin.String
7 | - stacktrace: kotlin.collections.List
8 | - toStringMessage: kotlin.String
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/oldApi/kotlin/interfaces/Bar.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package interfaces
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 |
9 | @Rpc
10 | interface BarInterface {
11 | suspend fun get()
12 | }
13 |
14 | class BarInterfaceImpl() : BarInterface {
15 | override suspend fun get() {}
16 | }
17 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | distributionBase=GRADLE_USER_HOME
6 | distributionPath=wrapper/dists
7 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
8 | networkTimeout=10000
9 | validateDistributionUrl=true
10 | zipStoreBase=GRADLE_USER_HOME
11 | zipStorePath=wrapper/dists
12 |
--------------------------------------------------------------------------------
/publishLocal.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
5 | #
6 |
7 | set -euxo pipefail
8 |
9 | ./gradlew publishAllPublicationsToBuildRepoRepository
10 | ./gradlew -p compiler-plugin publishAllPublicationsToBuildRepoRepository --no-configuration-cache
11 | ./gradlew -p gradle-plugin publishAllPublicationsToBuildRepoRepository --no-configuration-cache
12 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/other/action.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util.other
6 |
7 | enum class ActionApplied {
8 | Applied, NotApplied;
9 | }
10 |
11 | @Suppress("unused")
12 | infix fun ActionApplied.otherwise(body: () -> Unit) {
13 | if (this == ActionApplied.NotApplied) {
14 | body()
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/ExperimentalRpcApi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils
6 |
7 | @RequiresOptIn(
8 | message = "This API is experimental and can be changed or removed at any time.",
9 | level = RequiresOptIn.Level.ERROR,
10 | )
11 | public annotation class ExperimentalRpcApi
12 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallSuccessBinary.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCMessage.CallSuccessBinary [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallSuccessBinary]
2 | - callId: kotlin.String
3 | - connectionId: kotlin.Long
4 | - Nullable
5 | - data: kotlin.ByteArray
6 | - pluginParams: kotlin.collections.Map
7 | - Nullable
8 | - serviceId: kotlin.Long
9 | - Nullable
10 | - serviceType: kotlin.String
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/Failure.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCProtocolMessage.Failure [Declared name: kotlinx.rpc.krpc.internal.KrpcProtocolMessage.Failure]
2 | - connectionId: kotlin.Long
3 | - Nullable
4 | - errorMessage: kotlin.String
5 | - failedMessage: org.jetbrains.krpc.internal.transport.RPCMessage
6 | - Nullable
7 | - Declared name: kotlinx.rpc.krpc.internal.KrpcMessage
8 | - pluginParams: kotlin.collections.Map
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/wasmJsMain/resources/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ktor-all-platforms-app
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/InternalRpcApi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils
6 |
7 | @RequiresOptIn(
8 | message = "This is internal kotlinx.rpc api that is subject to change and should not be used",
9 | level = RequiresOptIn.Level.ERROR,
10 | )
11 | public annotation class InternalRpcApi
12 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/StreamFinished.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.RPCMessage.StreamFinished [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamFinished]
2 | - callId: kotlin.String
3 | - connectionId: kotlin.Long
4 | - Nullable
5 | - pluginParams: kotlin.collections.Map
6 | - Nullable
7 | - serviceId: kotlin.Long
8 | - Nullable
9 | - serviceType: kotlin.String
10 | - flowId: kotlin.String
11 | - Declared name: streamId
--------------------------------------------------------------------------------
/utils/api/utils.klib.api:
--------------------------------------------------------------------------------
1 | // Klib ABI Dump
2 | // Targets: [iosArm64, iosSimulatorArm64, iosX64, js, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, wasmWasi, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
3 | // Rendering settings:
4 | // - Signature version: 2
5 | // - Show manifest properties: true
6 | // - Show declarations: true
7 |
8 | // Library unique name:
9 |
--------------------------------------------------------------------------------
/gradle-conventions-settings/develocity/src/main/kotlin/params.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | const val DEVELOCITY_SERVER = "https://ge.jetbrains.com"
6 | const val GITHUB_REPO = "https://github.com/Kotlin/kotlinx-rpc"
7 | const val TEAMCITY_URL = "https://krpc.teamcity.com"
8 |
9 | val isCIRun = System.getenv("TEAMCITY_VERSION") != null || System.getenv("GITHUB_ACTIONS") != null
10 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/frontend/src/jsMain/kotlin/Main.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import react.create
6 | import react.dom.client.createRoot
7 | import web.dom.document
8 |
9 | fun main() {
10 | val container = document.createElement("div")
11 | document.body.appendChild(container)
12 |
13 | val app = App.create()
14 | createRoot(container).render(app)
15 | }
16 |
--------------------------------------------------------------------------------
/core/src/commonMain/kotlin/kotlinx/rpc/RemoteService.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 |
9 | /**
10 | * Marker interface for an RPC service.
11 | *
12 | * @see Rpc
13 | */
14 | @Deprecated("Use of RemoteService is deprecated. Use only @Rpc annotation", level = DeprecationLevel.ERROR)
15 | public interface RemoteService
16 |
--------------------------------------------------------------------------------
/krpc/krpc-logging/api/krpc-logging.klib.api:
--------------------------------------------------------------------------------
1 | // Klib ABI Dump
2 | // Targets: [iosArm64, iosSimulatorArm64, iosX64, js, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, wasmWasi, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
3 | // Rendering settings:
4 | // - Signature version: 2
5 | // - Show manifest properties: true
6 | // - Show declarations: true
7 |
8 | // Library unique name:
9 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/common/src/main/kotlin/kotlinx/rpc/sample/MyService.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.sample
6 |
7 | import kotlinx.coroutines.flow.Flow
8 | import kotlinx.rpc.annotations.Rpc
9 |
10 | @Rpc
11 | interface MyService {
12 | suspend fun hello(user: String, userData: UserData): String
13 |
14 | fun subscribeToNews(): Flow
15 | }
16 |
--------------------------------------------------------------------------------
/krpc/krpc-ktor/krpc-ktor-core/api/krpc-ktor-core.klib.api:
--------------------------------------------------------------------------------
1 | // Klib ABI Dump
2 | // Targets: [iosArm64, iosSimulatorArm64, iosX64, js, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
3 | // Rendering settings:
4 | // - Signature version: 2
5 | // - Show manifest properties: true
6 | // - Show declarations: true
7 |
8 | // Library unique name:
9 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/other/directoryNames.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util.other
6 |
7 | object DirectoryNames {
8 | const val MAIN_SOURCE_SET = "main"
9 |
10 | const val CORE_SOURCE_DIR = "core"
11 | const val LATEST_SOURCE_DIR = "latest"
12 |
13 | const val MAIN_RESOURCES = "main-resources"
14 | const val TEST_RESOURCES = "test-resources"
15 | }
16 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/StreamMessageString.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.RPCMessage.StreamMessage [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamMessageString]
2 | - callId: kotlin.String
3 | - connectionId: kotlin.Long
4 | - Nullable
5 | - data: kotlin.String
6 | - pluginParams: kotlin.collections.Map
7 | - Nullable
8 | - serviceId: kotlin.Long
9 | - Nullable
10 | - serviceType: kotlin.String
11 | - flowId: kotlin.String
12 | - Declared name: streamId
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-cbor/api/krpc-serialization-cbor.api:
--------------------------------------------------------------------------------
1 | public final class kotlinx/rpc/krpc/serialization/cbor/KrpcCborSerialFormatKt {
2 | public static final fun cbor (Lkotlinx/rpc/krpc/serialization/KrpcSerialFormatConfiguration;Lkotlinx/serialization/cbor/Cbor;Lkotlin/jvm/functions/Function1;)V
3 | public static synthetic fun cbor$default (Lkotlinx/rpc/krpc/serialization/KrpcSerialFormatConfiguration;Lkotlinx/serialization/cbor/Cbor;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
4 | }
5 |
6 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-json/api/krpc-serialization-json.api:
--------------------------------------------------------------------------------
1 | public final class kotlinx/rpc/krpc/serialization/json/KrpcJsonSerialFormatKt {
2 | public static final fun json (Lkotlinx/rpc/krpc/serialization/KrpcSerialFormatConfiguration;Lkotlinx/serialization/json/Json;Lkotlin/jvm/functions/Function1;)V
3 | public static synthetic fun json$default (Lkotlinx/rpc/krpc/serialization/KrpcSerialFormatConfiguration;Lkotlinx/serialization/json/Json;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
4 | }
5 |
6 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/utils/src/jvmMain/kotlin/kotlinx/rpc/internal/utils/thread/ThreadLocal.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.thread
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | /**
10 | * JVM implementation of currentThreadId that returns the current thread's ID.
11 | */
12 | @InternalRpcApi
13 | public actual fun currentThreadId(): Long = Thread.currentThread().id
14 |
--------------------------------------------------------------------------------
/utils/src/wasmJsMain/kotlin/kotlinx/rpc/internal/utils/map/ConcurrentHashMap.wasm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.map
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | @InternalRpcApi
10 | public actual fun RpcInternalConcurrentHashMap(initialSize: Int): RpcInternalConcurrentHashMap {
11 | return SynchronizedHashMap()
12 | }
13 |
--------------------------------------------------------------------------------
/utils/src/wasmWasiMain/kotlin/kotlinx/rpc/internal/utils/map/ConcurrentHashMap.wasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.map
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | @InternalRpcApi
10 | public actual fun RpcInternalConcurrentHashMap(initialSize: Int): RpcInternalConcurrentHashMap {
11 | return SynchronizedHashMap()
12 | }
13 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-common/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6 |
7 | plugins {
8 | alias(libs.plugins.conventions.jvm)
9 | alias(libs.plugins.compiler.specific.module)
10 | }
11 |
12 | kotlin {
13 | explicitApi = ExplicitApiMode.Disabled
14 | }
15 |
16 | dependencies {
17 | compileOnly(libs.kotlin.compiler)
18 | }
19 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/kover.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util
6 |
7 | import org.gradle.api.Project
8 |
9 | @Suppress("unused")
10 | fun Project.applyKover() {
11 | plugins.apply("org.jetbrains.kotlinx.kover")
12 |
13 | rootProject.configurations.matching { it.name == "kover" }.all {
14 | rootProject.dependencies.add("kover", this@applyKover)
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticsContainerCore.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.codegen.checkers.diagnostics
6 |
7 | import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
8 |
9 | interface RpcKtDiagnosticsContainerCore {
10 | fun getRendererFactoryVs() : BaseDiagnosticRendererFactory
11 | }
12 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/other/publicModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util.other
6 |
7 | import org.gradle.api.Project
8 | import org.gradle.kotlin.dsl.extra
9 |
10 | /**
11 | * See gradle-conventions-settings/src/main/kotlin/includePublic.kt
12 | */
13 | val Project.isPublicModule: Boolean get() {
14 | return extra.has("isPublicModule") && extra["isPublicModule"] == true
15 | }
16 |
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/newApi/kotlin/interfaces/Bar.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package interfaces
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 |
9 | @Rpc
10 | interface BarInterface {
11 | suspend fun get(): Unit
12 | suspend fun get2(): Unit
13 | }
14 |
15 | class BarInterfaceImpl : BarInterface {
16 | override suspend fun get() {}
17 |
18 | override suspend fun get2() {}
19 | }
20 |
--------------------------------------------------------------------------------
/utils/src/jsMain/kotlin/kotlinx/rpc/internal/utils/map/ConcurrentHashMap.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.map
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | @InternalRpcApi
10 | public actual fun RpcInternalConcurrentHashMap(
11 | initialSize: Int,
12 | ): RpcInternalConcurrentHashMap {
13 | return SynchronizedHashMap()
14 | }
15 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallException.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.RPCMessage.CallException [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallException]
2 | - callId: kotlin.String
3 | - cause: org.jetbrains.krpc.SerializedException
4 | - Declared name: kotlinx.rpc.krpc.internal.SerializedException
5 | - connectionId: kotlin.Long
6 | - Nullable
7 | - pluginParams: kotlin.collections.Map
8 | - Nullable
9 | - serviceId: kotlin.Long
10 | - Nullable
11 | - serviceType: kotlin.String
--------------------------------------------------------------------------------
/tests/test-utils/src/nativeMain/kotlin/kotlinx/rpc/test/runThreadIfPossible.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | import kotlin.native.concurrent.ObsoleteWorkersApi
8 | import kotlin.native.concurrent.Worker
9 |
10 | @OptIn(ObsoleteWorkersApi::class)
11 | actual fun runThreadIfPossible(runner: () -> Unit) {
12 | Worker.start(errorReporting = true).executeAfter(0L, runner)
13 | }
14 |
--------------------------------------------------------------------------------
/utils/src/nativeMain/kotlin/kotlinx/rpc/internal/utils/map/ConcurrentHashMap.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.map
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | @InternalRpcApi
10 | public actual fun RpcInternalConcurrentHashMap(
11 | initialSize: Int,
12 | ): RpcInternalConcurrentHashMap {
13 | return SynchronizedHashMap()
14 | }
15 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/StreamMessageBinary.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCMessage.StreamMessageBinary [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamMessageBinary]
2 | - callId: kotlin.String
3 | - connectionId: kotlin.Long
4 | - Nullable
5 | - data: kotlin.ByteArray
6 | - pluginParams: kotlin.collections.Map
7 | - Nullable
8 | - serviceId: kotlin.Long
9 | - Nullable
10 | - serviceType: kotlin.String
11 | - flowId: kotlin.String
12 | - Declared name: streamId
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.sample.ui.theme
6 |
7 | import androidx.compose.ui.graphics.Color
8 |
9 | val Purple80 = Color(0xFFD0BCFF)
10 | val PurpleGrey80 = Color(0xFFCCC2DC)
11 | val Pink80 = Color(0xFFEFB8C8)
12 |
13 | val Purple40 = Color(0xFF6650a4)
14 | val PurpleGrey40 = Color(0xFF625b71)
15 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/samples/grpc-app/src/main/kotlin/Server.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import kotlinx.coroutines.runBlocking
6 | import kotlinx.rpc.grpc.GrpcServer
7 | import kotlinx.rpc.registerService
8 |
9 | fun main(): Unit = runBlocking {
10 | val grpcServer = GrpcServer(8080) {
11 | registerService { ImageRecognizerImpl() }
12 | }
13 |
14 | grpcServer.start()
15 | grpcServer.awaitTermination()
16 | }
17 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-protobuf/api/krpc-serialization-protobuf.api:
--------------------------------------------------------------------------------
1 | public final class kotlinx/rpc/krpc/serialization/protobuf/KrpcProtobufSerialFormatKt {
2 | public static final fun protobuf (Lkotlinx/rpc/krpc/serialization/KrpcSerialFormatConfiguration;Lkotlinx/serialization/protobuf/ProtoBuf;Lkotlin/jvm/functions/Function1;)V
3 | public static synthetic fun protobuf$default (Lkotlinx/rpc/krpc/serialization/KrpcSerialFormatConfiguration;Lkotlinx/serialization/protobuf/ProtoBuf;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
4 | }
5 |
6 |
--------------------------------------------------------------------------------
/krpc/krpc-server/src/commonMain/kotlin/kotlinx/rpc/krpc/server/internal/StreamCall.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.server.internal
6 |
7 | import kotlinx.coroutines.channels.Channel
8 | import kotlinx.serialization.KSerializer
9 |
10 | internal data class StreamCall(
11 | val callId: String,
12 | val streamId: String,
13 | val channel: Channel,
14 | val elementSerializer: KSerializer,
15 | )
16 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-core/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.kotlinx.rpc)
8 | }
9 |
10 | kotlin {
11 | sourceSets {
12 | commonMain {
13 | dependencies {
14 | api(libs.serialization.core)
15 |
16 | implementation(projects.utils)
17 | }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/oldApi/kotlin/interfaces/Baz.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package interfaces
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 | import kotlinx.serialization.Serializable
9 |
10 | @Serializable
11 | data class Baz(val field: String)
12 |
13 | @Rpc
14 | interface BazInterface {
15 | suspend fun get(): Baz
16 | }
17 |
18 | class BazInterfaceImpl : BazInterface {
19 | override suspend fun get(): Baz = Baz("asd")
20 | }
21 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/KrpcProtocolMessage.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCProtocolMessage [Declared name: kotlinx.rpc.krpc.internal.KrpcProtocolMessage]
2 | - pluginParams: kotlin.collections.Map
3 | - connectionId: kotlin.Long
4 | - Nullable
5 |
6 | org.jetbrains.krpc.internal.transport.RPCProtocolMessage.Failure
7 | - Declared name: kotlinx.rpc.krpc.internal.KrpcProtocolMessage.Failure
8 | org.jetbrains.krpc.internal.transport.RPCProtocolMessage.Handshake
9 | - Declared name: kotlinx.rpc.krpc.internal.KrpcProtocolMessage.Handshake
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-cbor/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.kotlinx.rpc)
8 | }
9 |
10 | kotlin {
11 | sourceSets {
12 | commonMain {
13 | dependencies {
14 | api(projects.krpc.krpcSerialization.krpcSerializationCore)
15 | api(libs.serialization.cbor)
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-json/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.kotlinx.rpc)
8 | }
9 |
10 | kotlin {
11 | sourceSets {
12 | commonMain {
13 | dependencies {
14 | api(projects.krpc.krpcSerialization.krpcSerializationCore)
15 | api(libs.serialization.json)
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/README.md:
--------------------------------------------------------------------------------
1 | # Ktor Android App
2 | Sample Android application and Kotlin/Jvm on backend, that uses kRPC protocol with Ktor to communicate.
3 |
4 | ### Running server
5 | To run server, run `main` function in [Application.kt](/server/src/main/kotlin/Application.kt) from IDEA UI.
6 |
7 | ### Running android application
8 | To run application from IDEA UI:
9 |
10 | - In the toolbar, select your app from the run configurations menu.
11 | - In the target device menu, select the device that you want to run your app on.
12 | - Click run.
13 |
--------------------------------------------------------------------------------
/tests/test-utils/src/jvmMain/kotlin/kotlinx/rpc/test/runTest.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | import kotlinx.coroutines.ExperimentalCoroutinesApi
8 | import kotlinx.coroutines.debug.DebugProbes
9 |
10 | @OptIn(ExperimentalCoroutinesApi::class)
11 | actual fun withDebugProbes(body: () -> T): T {
12 | var result: T? = null
13 | DebugProbes.withDebugProbes {
14 | result = body()
15 | }
16 | return result!!
17 | }
18 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-protobuf/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.kotlinx.rpc)
8 | }
9 |
10 | kotlin {
11 | sourceSets {
12 | commonMain {
13 | dependencies {
14 | api(projects.krpc.krpcSerialization.krpcSerializationCore)
15 | api(libs.serialization.protobuf)
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/samples/grpc-app/src/main/kotlin/ImageRecognizer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import kotlinx.coroutines.delay
6 |
7 | class ImageRecognizerImpl : ImageRecognizer {
8 | override suspend fun recognize(image: Image): RecogniseResult {
9 | val byte = image.data[0].toInt()
10 | delay(100) // heavy processing
11 | val result = RecogniseResult {
12 | category = if (byte == 0) 0 else 1
13 | }
14 | return result
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.github/workflows/platforms.yml:
--------------------------------------------------------------------------------
1 | name: Verify Platforms Table
2 |
3 | on:
4 | pull_request:
5 |
6 | permissions:
7 | contents: read
8 |
9 | jobs:
10 | verify-platforms-table:
11 | name: Run Verification
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Checkout Sources
15 | uses: actions/checkout@v5
16 | with:
17 | fetch-depth: 0
18 | - name: Setup Gradle
19 | uses: gradle/actions/setup-gradle@v4
20 | - name: Check Platforms Table
21 | run: ./gradlew verifyPlatformTable --no-configuration-cache --info --stacktrace
22 |
--------------------------------------------------------------------------------
/dokka-plugin/src/main/kotlin/kotlinx/rpc/dokka/AddDocsLinkPageTransformer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.dokka
6 |
7 | import org.jetbrains.dokka.pages.RootPageNode
8 | import org.jetbrains.dokka.plugability.DokkaContext
9 | import org.jetbrains.dokka.transformers.pages.PageTransformer
10 |
11 | class AddDocsLinkPageTransformer(private val context: DokkaContext) : PageTransformer {
12 | override fun invoke(input: RootPageNode): RootPageNode = input
13 | }
14 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/StreamCancel.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.RPCMessage.StreamCancel [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamCancel]
2 | - callId: kotlin.String
3 | - cause: org.jetbrains.krpc.SerializedException
4 | - Declared name: kotlinx.rpc.krpc.internal.SerializedException
5 | - connectionId: kotlin.Long
6 | - Nullable
7 | - pluginParams: kotlin.collections.Map
8 | - Nullable
9 | - serviceId: kotlin.Long
10 | - Nullable
11 | - serviceType: kotlin.String
12 | - flowId: kotlin.String
13 | - Declared name: streamId
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/oldApi/kotlin/interfaces/Foo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package interfaces
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 | import kotlinx.serialization.Serializable
9 |
10 | @Serializable
11 | data class Foo(val field: String)
12 |
13 | @Rpc
14 | interface FooInterface {
15 | suspend fun get(): Foo
16 | }
17 |
18 | class FooInterfaceImpl : FooInterface {
19 | override suspend fun get(): Foo {
20 | return Foo("")
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/forIde.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util
6 |
7 | import org.gradle.api.Project
8 | import util.other.ActionApplied
9 | import util.other.optionalProperty
10 |
11 | fun Project.whenForIde(block: () -> Unit): ActionApplied {
12 | val forIdeBuild by rootProject.optionalProperty()
13 |
14 | if (forIdeBuild) {
15 | block()
16 | return ActionApplied.Applied
17 | }
18 |
19 | return ActionApplied.NotApplied
20 | }
21 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/common/src/commonMain/kotlin/Common.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import kotlinx.coroutines.flow.Flow
6 | import kotlinx.rpc.annotations.Rpc
7 | import kotlinx.serialization.Serializable
8 |
9 | @Serializable
10 | data class UserData(
11 | val address: String,
12 | val lastName: String,
13 | )
14 |
15 | @Rpc
16 | interface MyService {
17 | suspend fun hello(user: String, userData: UserData): String
18 |
19 | fun subscribeToNews(): Flow
20 | }
21 |
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/newApi/kotlin/interfaces/Baz.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package interfaces
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 | import kotlinx.serialization.Serializable
9 |
10 | @Serializable
11 | data class Baz(val field: String, val field2: String = "")
12 |
13 | @Rpc
14 | interface BazInterface {
15 | suspend fun get(): Baz
16 | }
17 |
18 | class BazInterfaceImpl : BazInterface {
19 | override suspend fun get(): Baz = Baz("asd", "def")
20 | }
21 |
--------------------------------------------------------------------------------
/utils/src/wasmJsMain/kotlin/kotlinx/rpc/internal/utils/thread/ThreadLocal.wasm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.thread
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | /**
10 | * WASM JS implementation of currentThreadId.
11 | * Since WASM JS is single-threaded (similar to regular JS), we return a constant value.
12 | */
13 | @InternalRpcApi
14 | public actual fun currentThreadId(): Long = 1L // Always return 1 for main thread in WASM JS
15 |
--------------------------------------------------------------------------------
/krpc/krpc-client/src/commonMain/kotlin/kotlinx/rpc/krpc/client/internal/StreamCall.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.client.internal
6 |
7 | import kotlinx.coroutines.flow.Flow
8 | import kotlinx.serialization.KSerializer
9 |
10 | internal data class StreamCall(
11 | val callId: String,
12 | val streamId: String,
13 | val stream: Flow<*>,
14 | val elementSerializer: KSerializer,
15 | val connectionId: Long?,
16 | val serviceId: Long?,
17 | )
18 |
--------------------------------------------------------------------------------
/utils/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.atomicfu)
8 | }
9 |
10 | kotlin {
11 | sourceSets {
12 | commonMain {
13 | dependencies {
14 | implementation(libs.coroutines.core)
15 | }
16 | }
17 | commonTest {
18 | dependencies {
19 | implementation(kotlin("test"))
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/samples/grpc-app/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | build/
3 | !gradle/wrapper/gradle-wrapper.jar
4 | !**/src/main/**/build/
5 | !**/src/test/**/build/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 | bin/
16 | !**/src/main/**/bin/
17 | !**/src/test/**/bin/
18 |
19 | ### IntelliJ IDEA ###
20 | .idea
21 | *.iws
22 | *.iml
23 | *.ipr
24 | out/
25 | !**/src/main/**/out/
26 | !**/src/test/**/out/
27 |
28 | ### NetBeans ###
29 | /nbproject/private/
30 | /nbbuild/
31 | /dist/
32 | /nbdist/
33 | /.nb-gradle/
34 |
35 | ### VS Code ###
36 | .vscode/
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 | 10.0.2.2
11 |
12 |
13 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/shared/src/commonMain/kotlin/UserService.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import kotlinx.coroutines.flow.Flow
6 | import kotlinx.rpc.annotations.Rpc
7 | import kotlinx.serialization.Serializable
8 |
9 | @Serializable
10 | data class UserData(
11 | val address: String,
12 | val lastName: String,
13 | )
14 |
15 | @Rpc
16 | interface UserService {
17 | suspend fun hello(user: String, userData: UserData): String
18 |
19 | fun subscribeToNews(): Flow
20 | }
21 |
--------------------------------------------------------------------------------
/utils/src/wasmWasiMain/kotlin/kotlinx/rpc/internal/utils/thread/ThreadLocal.wasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.thread
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | /**
10 | * WASM WASI implementation of currentThreadId.
11 | * Since WASM WASI is single-threaded in the current implementation, we return a constant value.
12 | */
13 | @InternalRpcApi
14 | public actual fun currentThreadId(): Long = 1L // Always return 1 for main thread in WASM WASI
15 |
--------------------------------------------------------------------------------
/krpc/krpc-ktor/krpc-ktor-server/src/commonMain/kotlin/kotlinx/rpc/krpc/ktor/server/KtorKrpcServer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.ktor.server
6 |
7 | import io.ktor.websocket.*
8 | import kotlinx.rpc.krpc.KrpcConfig
9 | import kotlinx.rpc.krpc.ktor.KtorTransport
10 | import kotlinx.rpc.krpc.server.KrpcServer
11 |
12 | internal class KtorKrpcServer(
13 | webSocketSession: WebSocketSession,
14 | config: KrpcConfig.Server,
15 | ) : KrpcServer(config, KtorTransport(webSocketSession))
16 |
--------------------------------------------------------------------------------
/samples/simple-ktor-app/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | build/
3 | !gradle/wrapper/gradle-wrapper.jar
4 | !**/src/main/**/build/
5 | !**/src/test/**/build/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 | bin/
16 | !**/src/main/**/bin/
17 | !**/src/test/**/bin/
18 |
19 | ### IntelliJ IDEA ###
20 | .idea
21 | *.iws
22 | *.iml
23 | *.ipr
24 | out/
25 | !**/src/main/**/out/
26 | !**/src/test/**/out/
27 |
28 | ### NetBeans ###
29 | /nbproject/private/
30 | /nbbuild/
31 | /dist/
32 | /nbdist/
33 | /.nb-gradle/
34 |
35 | ### VS Code ###
36 | .vscode/
--------------------------------------------------------------------------------
/gradle-plugin/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | rootProject.name = "gradle-plugin"
6 |
7 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
8 |
9 | pluginManagement {
10 | includeBuild("../gradle-conventions")
11 | includeBuild("../gradle-conventions-settings")
12 | }
13 |
14 | plugins {
15 | id("conventions-repositories")
16 | id("conventions-version-resolution")
17 | id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
18 | }
19 |
20 | includeRootAsPublic()
21 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/ObjectId.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.internal
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | private const val HEX_RADIX = 16
10 |
11 | @InternalRpcApi
12 | public fun Any.rpcInternalObjectId(vararg tags: String): String {
13 | val tagsString = tags.takeIf { it.isNotEmpty() }?.joinToString { "[$it]" } ?: ""
14 | return "${this::class.simpleName}$tagsString[${hashCode().toString(HEX_RADIX)}]"
15 | }
16 |
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/newApi/kotlin/interfaces/Foo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package interfaces
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 | import kotlinx.serialization.Serializable
9 |
10 | @Serializable
11 | data class Foo(val field: String, val field2: String? = null)
12 |
13 | @Rpc
14 | interface FooInterface {
15 | suspend fun get(): Foo
16 | }
17 |
18 | class FooInterfaceImpl : FooInterface {
19 | override suspend fun get(): Foo {
20 | return Foo("", "")
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.idea/kotlinx-rpc.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dokka-plugin/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | rootProject.name = "dokka-rpc-plugin"
6 |
7 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
8 |
9 | pluginManagement {
10 | includeBuild("../gradle-conventions")
11 | includeBuild("../gradle-conventions-settings")
12 | }
13 |
14 | plugins {
15 | id("conventions-repositories")
16 | id("conventions-version-resolution")
17 | id("conventions-develocity")
18 | id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
19 | }
20 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/iosApp/iosApp/ContentView.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import SwiftUI
3 | import ComposeApp
4 |
5 | struct ComposeView: UIViewControllerRepresentable {
6 | func makeUIViewController(context: Context) -> UIViewController {
7 | MainViewControllerKt.MainViewController()
8 | }
9 |
10 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
11 | }
12 |
13 | struct ContentView: View {
14 | var body: some View {
15 | ComposeView()
16 | .ignoresSafeArea(.keyboard) // Compose has own keyboard handler
17 | }
18 | }
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/kotlinTestDataPluginTestDataPaths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/core/src/jvmMain/kotlin/kotlinx/rpc/internal/ReflectionUtils.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("detekt.MatchingDeclarationName")
6 |
7 | package kotlinx.rpc.internal
8 |
9 | import kotlinx.rpc.internal.utils.InternalRpcApi
10 | import kotlin.reflect.KClass
11 |
12 | @InternalRpcApi
13 | public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
14 | get() = qualifiedName
15 |
16 | @InternalRpcApi
17 | public actual val KClass<*>.rpcInternalTypeName: String?
18 | get() = java.typeName
19 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/KrpcMessage.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCMessage [Declared name: kotlinx.rpc.krpc.internal.KrpcMessage]
2 | - connectionId: kotlin.Long
3 | - Nullable
4 | - pluginParams: kotlin.collections.Map
5 | - Nullable
6 |
7 | org.jetbrains.krpc.RPCMessage
8 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage
9 | org.jetbrains.krpc.internal.transport.RPCGenericMessage
10 | - Declared name: kotlinx.rpc.krpc.internal.KrpcGenericMessage
11 | org.jetbrains.krpc.internal.transport.RPCProtocolMessage
12 | - Declared name: kotlinx.rpc.krpc.internal.KrpcProtocolMessage
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | #
4 |
5 | kotlin.code.style=official
6 |
7 | #Gradle
8 | org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
9 |
10 |
11 | #Android
12 | android.nonTransitiveRClass=true
13 | android.useAndroidX=true
14 |
15 | #Compose
16 | org.jetbrains.compose.experimental.wasm.enabled=true
17 |
18 | #MPP
19 | kotlin.mpp.androidSourceSetLayoutVersion=2
20 | kotlin.mpp.enableCInteropCommonization=true
21 |
22 | #Development
23 | development=true
--------------------------------------------------------------------------------
/.github/release.yml:
--------------------------------------------------------------------------------
1 | changelog:
2 | exclude:
3 | labels:
4 | - release
5 | authors:
6 | - renovate[bot]
7 | categories:
8 | - title: Features 🎉
9 | labels:
10 | - feature
11 | - title: Breaking Changes 🔴
12 | labels:
13 | - breaking
14 | - title: Deprecations ⚠️
15 | labels:
16 | - deprecation
17 | - title: Bug fixes 🐛
18 | labels:
19 | - bug
20 | - title: Documentation 📗
21 | labels:
22 | - docs
23 | - title: Infra 🚧
24 | labels:
25 | - infra
26 | - title: Other Changes 🧹
27 | labels:
28 | - "*"
29 |
--------------------------------------------------------------------------------
/.puppeteerrc.cjs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | const {join} = require('path');
6 |
7 | const isTC = process.env.TEAMCITY_VERSION;
8 | const isGA = process.env.GITHUB_ACTIONS;
9 |
10 | if (isTC !== undefined || isGA !== undefined) {
11 | /**
12 | * @type {import("puppeteer").Configuration}
13 | */
14 | module.exports = {
15 | // Changes the cache location for Puppeteer
16 | // So that in docker container browsers are included
17 | cacheDirectory: join(__dirname, '.puppeteer', 'browsers'),
18 | };
19 | }
20 |
--------------------------------------------------------------------------------
/core/src/jsMain/kotlin/kotlinx/rpc/internal/ReflectionUtils.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("detekt.MatchingDeclarationName")
6 |
7 | package kotlinx.rpc.internal
8 |
9 | import kotlinx.rpc.internal.utils.InternalRpcApi
10 | import kotlin.reflect.KClass
11 |
12 | @InternalRpcApi
13 | public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
14 | get() = toString()
15 |
16 | @InternalRpcApi
17 | public actual val KClass<*>.rpcInternalTypeName: String?
18 | get() = rpcInternalQualifiedClassNameOrNull
19 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/desktopMain/kotlin/main.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import androidx.compose.desktop.ui.tooling.preview.Preview
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.ui.window.Window
8 | import androidx.compose.ui.window.application
9 |
10 | fun main() = application {
11 | Window(onCloseRequest = ::exitApplication, title = "ktor-all-platforms-app") {
12 | App()
13 | }
14 | }
15 |
16 | @Preview
17 | @Composable
18 | fun AppDesktopPreview() {
19 | App()
20 | }
--------------------------------------------------------------------------------
/core/src/wasmJsMain/kotlin/kotlinx/rpc/internal/ReflectionUtils.wasm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("detekt.MatchingDeclarationName")
6 |
7 | package kotlinx.rpc.internal
8 |
9 | import kotlinx.rpc.internal.utils.InternalRpcApi
10 | import kotlin.reflect.KClass
11 |
12 | @InternalRpcApi
13 | public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
14 | get() = toString()
15 |
16 | @InternalRpcApi
17 | public actual val KClass<*>.rpcInternalTypeName: String?
18 | get() = rpcInternalQualifiedClassNameOrNull
19 |
--------------------------------------------------------------------------------
/core/src/nativeMain/kotlin/kotlinx/rpc/internal/ReflectionUtils.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("detekt.MatchingDeclarationName")
6 |
7 | package kotlinx.rpc.internal
8 |
9 | import kotlinx.rpc.internal.utils.InternalRpcApi
10 | import kotlin.reflect.KClass
11 |
12 | @InternalRpcApi
13 | public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
14 | get() = qualifiedName
15 |
16 | @InternalRpcApi
17 | public actual val KClass<*>.rpcInternalTypeName: String?
18 | get() = rpcInternalQualifiedClassNameOrNull
19 |
--------------------------------------------------------------------------------
/core/src/wasmWasiMain/kotlin/kotlinx/rpc/internal/ReflectionUtils.wasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("detekt.MatchingDeclarationName")
6 |
7 | package kotlinx.rpc.internal
8 |
9 | import kotlinx.rpc.internal.utils.InternalRpcApi
10 | import kotlin.reflect.KClass
11 |
12 | @InternalRpcApi
13 | public actual val KClass<*>.rpcInternalQualifiedClassNameOrNull: String?
14 | get() = toString()
15 |
16 | @InternalRpcApi
17 | public actual val KClass<*>.rpcInternalTypeName: String?
18 | get() = rpcInternalQualifiedClassNameOrNull
19 |
--------------------------------------------------------------------------------
/samples/grpc-app/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/server/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/simple-ktor-app/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: Mr3zee
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Kotlin version
16 | 2. Gradle version
17 | 3. OS (Or at least KMP platform)
18 | 4. Minimal reproducer in code
19 | 5. Error description
20 | 6. And so on
21 |
22 | **Expected behavior**
23 | A clear and concise description of what you expected to happen.
24 |
25 | **Additional context**
26 | Add any other context about the problem here.
27 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/server/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallDataString.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.RPCMessage.CallData [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallDataString]
2 | - callId: kotlin.String
3 | - callType: org.jetbrains.krpc.internal.transport.RPCMessage.CallType
4 | - Nullable
5 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallType
6 | - method: kotlin.String
7 | - Declared name: callableName
8 | - connectionId: kotlin.Long
9 | - Nullable
10 | - data: kotlin.String
11 | - pluginParams: kotlin.collections.Map
12 | - Nullable
13 | - serviceId: kotlin.Long
14 | - Nullable
15 | - serviceType: kotlin.String
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallResult.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.RPCMessage.CallResult [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallResult]
2 | - callId: kotlin.String
3 | - connectionId: kotlin.Long
4 | - Nullable
5 | - pluginParams: kotlin.collections.Map
6 | - Nullable
7 | - serviceId: kotlin.Long
8 | - Nullable
9 | - serviceType: kotlin.String
10 |
11 | org.jetbrains.krpc.RPCMessage.CallException
12 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallException
13 | org.jetbrains.krpc.internal.transport.RPCMessage.CallSuccess
14 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallSuccess
--------------------------------------------------------------------------------
/krpc/krpc-logging/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.kotlinx.rpc)
8 | }
9 |
10 | kotlin {
11 | sourceSets {
12 | commonMain {
13 | dependencies {
14 | implementation(libs.kotlin.logging)
15 | implementation(projects.utils)
16 | }
17 | }
18 |
19 | jvmMain {
20 | dependencies {
21 | implementation(libs.slf4j.api)
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-cli/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6 |
7 | plugins {
8 | alias(libs.plugins.conventions.jvm)
9 | alias(libs.plugins.compiler.specific.module)
10 | }
11 |
12 | kotlin {
13 | explicitApi = ExplicitApiMode.Disabled
14 | }
15 |
16 | dependencies {
17 | compileOnly(libs.kotlin.compiler)
18 |
19 | implementation(projects.compilerPluginK2)
20 | implementation(projects.compilerPluginCommon)
21 | implementation(projects.compilerPluginBackend)
22 | }
23 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/other/maybeNamed.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util.other
6 |
7 | import org.gradle.api.NamedDomainObjectCollection
8 | import org.gradle.api.NamedDomainObjectProvider
9 |
10 | internal fun NamedDomainObjectCollection.maybeNamed(name: String): NamedDomainObjectProvider? {
11 | return if (name in names) named(name) else null
12 | }
13 |
14 | internal fun NamedDomainObjectCollection.maybeNamed(name: String, configure: T.() -> Unit) {
15 | if (name in names) named(name).configure(configure)
16 | }
17 |
--------------------------------------------------------------------------------
/krpc/krpc-ktor/krpc-ktor-core/src/jvmTest/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/krpc/krpc-server/api/krpc-server.api:
--------------------------------------------------------------------------------
1 | public abstract class kotlinx/rpc/krpc/server/KrpcServer : kotlinx/rpc/RpcServer, kotlinx/rpc/krpc/internal/KrpcEndpoint {
2 | public fun (Lkotlinx/rpc/krpc/KrpcConfig$Server;Lkotlinx/rpc/krpc/KrpcTransport;)V
3 | public final fun awaitCompletion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
4 | public final fun close (Ljava/lang/String;)V
5 | public static synthetic fun close$default (Lkotlinx/rpc/krpc/server/KrpcServer;Ljava/lang/String;ILjava/lang/Object;)V
6 | public final fun deregisterService (Lkotlin/reflect/KClass;)V
7 | public final fun registerService (Lkotlin/reflect/KClass;Lkotlin/jvm/functions/Function0;)V
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/tests/test-utils/src/commonMain/kotlin/kotlinx/rpc/test/runTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.test
6 |
7 | import kotlinx.coroutines.test.TestResult
8 | import kotlinx.coroutines.test.TestScope
9 | import kotlin.time.Duration
10 |
11 | fun runTestWithCoroutinesProbes(
12 | timeout: Duration,
13 | body: suspend TestScope.() -> Unit,
14 | ): TestResult {
15 | return withDebugProbes {
16 | kotlinx.coroutines.test.runTest(timeout = timeout, testBody = body)
17 | }
18 | }
19 |
20 | expect fun withDebugProbes(body: () -> T): T
21 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/server/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallDataBinary.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCMessage.CallDataBinary [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallDataBinary]
2 | - callId: kotlin.String
3 | - callType: org.jetbrains.krpc.internal.transport.RPCMessage.CallType
4 | - Nullable
5 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallType
6 | - method: kotlin.String
7 | - Declared name: callableName
8 | - connectionId: kotlin.Long
9 | - Nullable
10 | - data: kotlin.ByteArray
11 | - pluginParams: kotlin.collections.Map
12 | - Nullable
13 | - serviceId: kotlin.Long
14 | - Nullable
15 | - serviceType: kotlin.String
--------------------------------------------------------------------------------
/samples/ktor-android-app/common/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.kotlinJvm)
7 | alias(libs.plugins.kotlinPluginSerialization)
8 | alias(libs.plugins.kotlinx.rpc)
9 | }
10 |
11 | dependencies {
12 | implementation(libs.ktor.server.cio)
13 | implementation(libs.ktor.server.core.jvm)
14 | implementation(libs.ktor.server.websockets.jvm)
15 | implementation(libs.kotlinx.serialization.json)
16 | implementation(libs.kotlinx.rpc.krpc.ktor.server)
17 | implementation(libs.kotlinx.rpc.krpc.serialization.json)
18 | }
19 |
--------------------------------------------------------------------------------
/samples/grpc-app/src/main/kotlin/Client.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import kotlinx.coroutines.runBlocking
6 | import kotlinx.rpc.grpc.GrpcClient
7 | import kotlinx.rpc.withService
8 |
9 | fun main(): Unit = runBlocking {
10 | val grpcClient = GrpcClient("localhost", 8080) {
11 | usePlaintext()
12 | }
13 |
14 | val recognizer = grpcClient.withService()
15 |
16 | val image = Image {
17 | data = byteArrayOf(0, 1, 2, 3)
18 | }
19 | val result = recognizer.recognize(image)
20 | println("Recognized category: ${result.category}")
21 | }
22 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallSuccess.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCMessage.CallSuccess [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallSuccess]
2 | - callId: kotlin.String
3 | - connectionId: kotlin.Long
4 | - Nullable
5 | - pluginParams: kotlin.collections.Map
6 | - Nullable
7 | - serviceId: kotlin.Long
8 | - Nullable
9 | - serviceType: kotlin.String
10 |
11 | org.jetbrains.krpc.internal.transport.RPCMessage.CallSuccessBinary
12 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallSuccessBinary
13 | org.jetbrains.krpc.RPCMessage.CallSuccess
14 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallSuccessString
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/other/files.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util.other
6 |
7 | import org.gradle.api.Project
8 | import java.io.File
9 | import java.nio.file.Files
10 | import java.nio.file.Path
11 |
12 | fun Path.name() = fileName?.toString().orEmpty()
13 |
14 | fun filterDirectory(sourceSetPath: Path, filter: (Path) -> Boolean): List {
15 | return Files.newDirectoryStream(sourceSetPath).use { it.toList() }.filter(filter).map { it.toFile() }
16 | }
17 |
18 | val Project.files: Array get() = project.projectDir.resolve("src").listFiles() ?: emptyArray()
19 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("UnstableApiUsage")
6 |
7 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
8 |
9 | pluginManagement {
10 | repositories {
11 | google()
12 | mavenCentral()
13 | gradlePluginPortal()
14 | }
15 | }
16 | dependencyResolutionManagement {
17 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
18 | repositories {
19 | google()
20 | mavenCentral()
21 | }
22 | }
23 |
24 | rootProject.name = "ktor-android-app"
25 | include(":app", ":server",":common")
26 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: feature
6 | assignees: Mr3zee
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-backend/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6 |
7 | plugins {
8 | alias(libs.plugins.conventions.jvm)
9 | alias(libs.plugins.compiler.specific.module)
10 | }
11 |
12 | kotlin {
13 | explicitApi = ExplicitApiMode.Disabled
14 |
15 | sourceSets.all {
16 | languageSettings.optIn("org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI")
17 | }
18 | }
19 |
20 | dependencies {
21 | compileOnly(libs.kotlin.compiler)
22 |
23 | implementation(projects.compilerPluginCommon)
24 | }
25 |
--------------------------------------------------------------------------------
/utils/src/jsMain/kotlin/kotlinx/rpc/internal/utils/thread/ThreadLocal.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.thread
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | /**
10 | * JS implementation of currentThreadId.
11 | * Since JavaScript is single-threaded (except for Web Workers), we use a global counter
12 | * to simulate thread IDs. In a real multi-threaded environment with Web Workers,
13 | * a more sophisticated approach would be needed.
14 | */
15 | @InternalRpcApi
16 | public actual fun currentThreadId(): Long = 1L // Always return 1 for main thread in JS
17 |
--------------------------------------------------------------------------------
/updateTestData.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
5 | #
6 |
7 | if [ "$#" -ne 1 ] && [ "$#" -ne 2 ]; then
8 | echo "Pass test name without the package and the 'Generated' suffix, for example:" >&2
9 | echo "" >&2
10 | echo "$0 BoxTest" >&2
11 | exit 1
12 | fi;
13 |
14 | if [ "$#" -eq 2 ]; then
15 | TEST_NAME=".$2"
16 | else
17 | TEST_NAME=""
18 | fi;
19 |
20 | set -o xtrace
21 |
22 | ./gradlew \
23 | :tests:compiler-plugin-tests:test \
24 | --tests "kotlinx.rpc.codegen.test.runners.$1Generated$TEST_NAME" \
25 | --continue \
26 | --stacktrace \
27 | -Pkotlin.test.update.test.data=true
28 |
--------------------------------------------------------------------------------
/utils/src/nativeMain/kotlin/kotlinx/rpc/internal/utils/thread/ThreadLocal.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.thread
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 | import kotlin.native.concurrent.ObsoleteWorkersApi
9 | import kotlin.native.concurrent.Worker
10 |
11 | /**
12 | * Native implementation of currentThreadId that returns the current worker's ID.
13 | * In Kotlin/Native, we use Worker.current.id as a thread identifier.
14 | */
15 | @OptIn(ObsoleteWorkersApi::class)
16 | @InternalRpcApi
17 | public actual fun currentThreadId(): Long = Worker.current.id.toLong()
18 |
--------------------------------------------------------------------------------
/versions-root/targets-since-kotlin-lookup.json:
--------------------------------------------------------------------------------
1 | {
2 | "jvm": "*",
3 | "js": "*",
4 |
5 | "wasmJs": "*",
6 | "wasmWasi": "*",
7 |
8 | "mingwX64": "*",
9 |
10 | "linuxX64": "*",
11 | "linuxArm64": "*",
12 |
13 | "iosX64": "*",
14 | "iosArm64": "*",
15 | "iosSimulatorArm64": "*",
16 |
17 | "watchosX64": "*",
18 | "watchosArm32": "*",
19 | "watchosArm64": "*",
20 | "watchosSimulatorArm64": "*",
21 | "watchosDeviceArm64": "*",
22 |
23 | "tvosX64": "*",
24 | "tvosArm64": "*",
25 | "tvosSimulatorArm64": "*",
26 |
27 | "macosX64": "*",
28 | "macosArm64": "*",
29 |
30 | "androidNativeArm32": "-",
31 | "androidNativeArm64": "-",
32 | "androidNativeX86": "-",
33 | "androidNativeX64": "-"
34 | }
35 |
--------------------------------------------------------------------------------
/krpc/krpc-server/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.serialization)
8 | alias(libs.plugins.kotlinx.rpc)
9 | alias(libs.plugins.atomicfu)
10 | }
11 |
12 | kotlin {
13 | sourceSets {
14 | commonMain {
15 | dependencies {
16 | api(projects.krpc.krpcCore)
17 |
18 | implementation(projects.krpc.krpcLogging)
19 |
20 | implementation(libs.serialization.core)
21 | implementation(libs.kotlin.reflect)
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/common/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.kotlin.multiplatform)
7 | alias(libs.plugins.kotlin.plugin.serialization)
8 | alias(libs.plugins.kotlinx.rpc)
9 | }
10 |
11 | kotlin {
12 | jvm()
13 | js {
14 | browser()
15 | binaries.executable()
16 | }
17 | }
18 |
19 | dependencies {
20 | commonMainApi(libs.kotlin.stdlib)
21 | commonMainApi(libs.kotlinx.serialization.json)
22 | commonMainApi(libs.ktor.client.core)
23 | commonMainApi(libs.kotlinx.coroutines.core)
24 | commonMainApi(libs.kotlinx.rpc.core)
25 | }
26 |
--------------------------------------------------------------------------------
/tests/compiler-plugin-tests/src/main/kotlin/kotlinx/rpc/codegen/test/TestRpcClient.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.codegen.test
6 |
7 | import kotlinx.coroutines.flow.Flow
8 | import kotlinx.coroutines.flow.flow
9 | import kotlinx.rpc.RpcCall
10 | import kotlinx.rpc.RpcClient
11 |
12 | @Suppress("UNCHECKED_CAST", "unused")
13 | object TestRpcClient : RpcClient {
14 | override suspend fun call(call: RpcCall): T {
15 | return "call_42" as T
16 | }
17 |
18 | override fun callServerStreaming(call: RpcCall): Flow {
19 | return flow { emit("stream_42" as T) }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/hex/HexBytes.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils.hex
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 |
9 | @OptIn(ExperimentalStdlibApi::class)
10 | @InternalRpcApi
11 | public fun String.rpcInternalHexToReadableBinary(): String {
12 | return hexToByteArray().joinToString("") { byte ->
13 | byte.toInt().toChar().display()
14 | }
15 | }
16 |
17 | private fun Char.display(): String {
18 | // visible symbols range
19 | // https://www.asciitable.com/
20 | return if (code !in 32..126) "?" else toString()
21 | }
22 |
--------------------------------------------------------------------------------
/krpc/krpc-client/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.serialization)
8 | alias(libs.plugins.kotlinx.rpc)
9 | alias(libs.plugins.atomicfu)
10 | }
11 |
12 | kotlin {
13 | sourceSets {
14 | commonMain {
15 | dependencies {
16 | api(projects.krpc.krpcCore)
17 |
18 | implementation(libs.serialization.core)
19 | implementation(libs.kotlin.reflect)
20 |
21 | implementation(projects.krpc.krpcLogging)
22 | }
23 | }
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/.fleet/receipt.json:
--------------------------------------------------------------------------------
1 | {
2 | "spec": {
3 | "template_id": "kmt",
4 | "targets": {
5 | "android": {
6 | "ui": [
7 | "compose"
8 | ]
9 | },
10 | "ios": {
11 | "ui": [
12 | "compose"
13 | ]
14 | },
15 | "desktop": {
16 | "ui": [
17 | "compose"
18 | ]
19 | },
20 | "server": {
21 | "engine": [
22 | "ktor"
23 | ]
24 | }
25 | }
26 | },
27 | "timestamp": "2024-02-12T11:54:57.720116301Z"
28 | }
29 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/contextParameters.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util
6 |
7 | import org.gradle.api.Project
8 | import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
9 |
10 | fun Project.enableContextParameters() {
11 | withKotlinJvmExtension {
12 | compilerOptions {
13 | freeCompilerArgs.add("-Xcontext-parameters")
14 | }
15 | }
16 |
17 | withKotlinKmpExtension {
18 | @OptIn(ExperimentalKotlinGradlePluginApi::class)
19 | compilerOptions {
20 | freeCompilerArgs.add("-Xcontext-parameters")
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/StreamMessage.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCMessage.StreamMessage [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamMessage]
2 | - streamId: kotlin.String
3 | - callId: kotlin.String
4 | - connectionId: kotlin.Long
5 | - Nullable
6 | - pluginParams: kotlin.collections.Map
7 | - Nullable
8 | - serviceId: kotlin.Long
9 | - Nullable
10 | - serviceType: kotlin.String
11 |
12 | org.jetbrains.krpc.internal.transport.RPCMessage.StreamMessageBinary
13 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamMessageBinary
14 | org.jetbrains.krpc.RPCMessage.StreamMessage
15 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamMessageString
--------------------------------------------------------------------------------
/tests/compiler-plugin-tests/src/testData/box/simple.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | // RUN_PIPELINE_TILL: BACKEND
6 |
7 | import kotlinx.coroutines.runBlocking
8 | import kotlinx.rpc.withService
9 | import kotlinx.rpc.annotations.Rpc
10 | import kotlinx.rpc.codegen.test.TestRpcClient
11 |
12 | @Rpc
13 | interface BoxService {
14 | suspend fun simple(): String
15 | }
16 |
17 | fun box(): String = runBlocking {
18 | val result = TestRpcClient.withService().simple()
19 |
20 | if (result == "call_42") "OK" else "Fail: $result"
21 | }
22 |
23 | /* GENERATED_FIR_TAGS: functionDeclaration, interfaceDeclaration, suspend */
24 |
--------------------------------------------------------------------------------
/gradle-conventions/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | rootProject.name = "gradle-conventions"
6 |
7 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
8 |
9 | pluginManagement {
10 | repositories {
11 | gradlePluginPortal()
12 | }
13 |
14 | includeBuild("../gradle-conventions-settings")
15 | }
16 |
17 | plugins {
18 | id("conventions-repositories")
19 | id("conventions-version-resolution")
20 | }
21 |
22 | dependencyResolutionManagement {
23 | // Additional repositories for build-logic
24 | @Suppress("UnstableApiUsage")
25 | repositories {
26 | gradlePluginPortal()
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/writerside.cfg:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/server/src/main/kotlin/MyServiceImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import kotlinx.coroutines.delay
6 | import kotlinx.coroutines.flow.Flow
7 | import kotlinx.coroutines.flow.flow
8 |
9 | class MyServiceImpl : MyService {
10 | override suspend fun hello(user: String, userData: UserData): String {
11 | return "Nice to meet you $user, how is it in ${userData.address}?"
12 | }
13 |
14 | override fun subscribeToNews(): Flow {
15 | return flow {
16 | repeat(10) {
17 | delay(2000)
18 | emit("Article number $it")
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/test-utils/api/test-utils.api:
--------------------------------------------------------------------------------
1 | public final class kotlinx/rpc/test/RunTestKt {
2 | public static final fun runTestWithCoroutinesProbes-VtjQ1oo (JLkotlin/jvm/functions/Function2;)V
3 | }
4 |
5 | public final class kotlinx/rpc/test/RunTest_jvmKt {
6 | public static final fun withDebugProbes (Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;
7 | }
8 |
9 | public final class kotlinx/rpc/test/RunThreadIfPossible_jvmKt {
10 | public static final fun runThreadIfPossible (Lkotlin/jvm/functions/Function0;)V
11 | }
12 |
13 | public final class kotlinx/rpc/test/WaitCounter {
14 | public fun ()V
15 | public final fun await (ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
16 | public final fun getValue ()I
17 | public final fun increment ()V
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/gradle-conventions/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | `kotlin-dsl`
7 | }
8 |
9 | dependencies {
10 | implementation(libs.kotlin.gradle.plugin)
11 | implementation(libs.detekt.gradle.plugin)
12 | implementation(libs.dokka.gradle.plugin)
13 | implementation(libs.gradle.publish.gradle.plugin)
14 | implementation(libs.compat.patrouille.gradle.plugin)
15 |
16 | implementation(libs.kover.gradle.plugin)
17 |
18 | // https://stackoverflow.com/questions/76713758/use-version-catalog-inside-precompiled-gradle-plugin
19 | implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
20 | }
21 |
--------------------------------------------------------------------------------
/krpc/krpc-ktor/krpc-ktor-client/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.kotlinx.rpc)
8 | }
9 |
10 | kotlin {
11 | sourceSets {
12 | commonMain {
13 | dependencies {
14 | api(projects.krpc.krpcClient)
15 | api(projects.krpc.krpcKtor.krpcKtorCore)
16 |
17 | api(libs.ktor.client.core)
18 | api(libs.ktor.client.websockets)
19 |
20 | implementation(libs.coroutines.core)
21 | implementation(libs.kotlin.reflect)
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/krpc/krpc-ktor/krpc-ktor-server/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.kotlinx.rpc)
8 | }
9 |
10 | kotlin {
11 | sourceSets {
12 | commonMain {
13 | dependencies {
14 | api(projects.krpc.krpcServer)
15 | api(projects.krpc.krpcKtor.krpcKtorCore)
16 |
17 | api(libs.ktor.server.core)
18 | api(libs.ktor.server.websockets)
19 |
20 | implementation(libs.coroutines.core)
21 | implementation(libs.kotlin.reflect)
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/krpc-protocol-compatibility-tests/src/test/kotlin/kotlinx/rpc/krpc/test/compat/TestLogAppender.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test.compat
6 |
7 | import ch.qos.logback.classic.Level
8 | import ch.qos.logback.classic.spi.ILoggingEvent
9 | import ch.qos.logback.core.AppenderBase
10 |
11 | class TestLogAppender : AppenderBase() {
12 | init {
13 | start()
14 | }
15 |
16 | val events = mutableListOf()
17 | val errors get() = events.filter { it.level == Level.ERROR }
18 |
19 | override fun append(eventObject: ILoggingEvent) {
20 | events.add(eventObject)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | // this is necessary to avoid the plugins to be loaded multiple times
7 | // in each subproject's classloader
8 | alias(libs.plugins.androidApplication) apply false
9 | alias(libs.plugins.androidLibrary) apply false
10 | alias(libs.plugins.jetbrainsCompose) apply false
11 | alias(libs.plugins.kotlinJvm) apply false
12 | alias(libs.plugins.kotlinMultiplatform) apply false
13 | alias(libs.plugins.kotlinPluginSerialization) apply false
14 | alias(libs.plugins.kotlinx.rpc) apply false
15 | alias(libs.plugins.compose.compiler) apply false
16 | }
17 |
--------------------------------------------------------------------------------
/tests/test-utils/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6 |
7 | plugins {
8 | alias(libs.plugins.conventions.kmp)
9 | alias(libs.plugins.atomicfu)
10 | }
11 |
12 | kotlin {
13 | sourceSets {
14 | commonMain {
15 | dependencies {
16 | implementation(libs.coroutines.core)
17 | implementation(libs.coroutines.test)
18 | }
19 | }
20 |
21 | jvmMain {
22 | dependencies {
23 | implementation(libs.coroutines.debug)
24 | }
25 | }
26 | }
27 |
28 | explicitApi = ExplicitApiMode.Disabled
29 | }
30 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/commonMain/kotlin/kotlinx/rpc/krpc/test/KrpcTestServer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | import kotlinx.rpc.krpc.KrpcConfig
8 | import kotlinx.rpc.krpc.KrpcTransport
9 | import kotlinx.rpc.krpc.server.KrpcServer
10 |
11 | /**
12 | * Implementation of [KrpcServer] that can be used to test custom [KrpcTransport].
13 | *
14 | * NOTE: one [KrpcTransport] is meant to be used by only one server,
15 | * but this class allows for abuse. Be cautious about how you handle [KrpcTransport] with this class.
16 | */
17 | class KrpcTestServer(
18 | config: KrpcConfig.Server,
19 | transport: KrpcTransport,
20 | ) : KrpcServer(config, transport)
21 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/TestLogAppender.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | import ch.qos.logback.classic.Level
8 | import ch.qos.logback.classic.spi.ILoggingEvent
9 | import ch.qos.logback.core.AppenderBase
10 |
11 | class TestLogAppender : AppenderBase() {
12 | init {
13 | start()
14 | }
15 |
16 | val events = mutableListOf()
17 | val errors get() = events.filter { it.level == Level.ERROR }
18 | val warnings get() = events.filter { it.level == Level.WARN }
19 |
20 | override fun append(eventObject: ILoggingEvent) {
21 | events.add(eventObject)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/dokka-plugin/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.kotlin.jvm)
7 | }
8 |
9 | group = "org.jetbrains.kotlinx"
10 | version = libs.versions.kotlinx.rpc.get()
11 |
12 | logger.lifecycle("[Dokka Plugin] kotlinx.rpc project version: $version, Kotlin version: ${libs.versions.kotlin.lang.get()}")
13 |
14 | dependencies {
15 | compileOnly(libs.dokka.core)
16 | compileOnly(libs.dokka.base)
17 |
18 | testImplementation(kotlin("test"))
19 | testImplementation(libs.dokka.base)
20 | testImplementation(libs.dokka.test.api)
21 | testImplementation(libs.dokka.base.test.utils)
22 | testImplementation(libs.dokka.analysis.kotlin.symbols)
23 | }
24 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/frontend/src/jsMain/kotlin/RPC.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import io.ktor.client.*
6 | import io.ktor.client.engine.js.*
7 | import io.ktor.client.request.*
8 | import kotlinx.rpc.RpcClient
9 | import kotlinx.rpc.krpc.ktor.client.installKrpc
10 | import kotlinx.rpc.krpc.ktor.client.rpc
11 | import kotlinx.rpc.krpc.ktor.client.rpcConfig
12 | import kotlinx.rpc.krpc.serialization.json.json
13 |
14 | fun initRpcClient(): RpcClient {
15 | return HttpClient(Js) {
16 | installKrpc()
17 | }.rpc {
18 | url("ws://localhost:8080/api")
19 |
20 | rpcConfig {
21 | serialization {
22 | json()
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/compiler-plugin-tests/src/testData/box/flowParameter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | // RUN_PIPELINE_TILL: BACKEND
6 |
7 | import kotlinx.coroutines.flow.*
8 | import kotlinx.coroutines.runBlocking
9 | import kotlinx.rpc.withService
10 | import kotlinx.rpc.annotations.Rpc
11 | import kotlinx.rpc.codegen.test.TestRpcClient
12 |
13 | @Rpc
14 | interface BoxService {
15 | suspend fun stream(flow: Flow): String
16 | }
17 |
18 | fun box(): String = runBlocking {
19 | val result = TestRpcClient.withService().stream(flow { })
20 |
21 | if (result == "call_42") "OK" else "Fail: $result"
22 | }
23 |
24 | /* GENERATED_FIR_TAGS: functionDeclaration, interfaceDeclaration, suspend */
25 |
--------------------------------------------------------------------------------
/tests/compiler-plugin-tests/src/testData/box/multiModule.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | // RUN_PIPELINE_TILL: BACKEND
6 |
7 | // MODULE: lib
8 |
9 | import kotlinx.rpc.annotations.Rpc
10 |
11 | @Rpc
12 | interface BoxService {
13 | suspend fun simple(): String
14 | }
15 |
16 | // MODULE: main(lib)
17 |
18 | import kotlinx.coroutines.runBlocking
19 | import kotlinx.rpc.withService
20 | import kotlinx.rpc.codegen.test.TestRpcClient
21 |
22 | fun box(): String = runBlocking {
23 | val result = TestRpcClient.withService().simple()
24 |
25 | if (result == "call_42") "OK" else "Fail: $result"
26 | }
27 |
28 | /* GENERATED_FIR_TAGS: functionDeclaration, interfaceDeclaration, suspend */
29 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/core/src/commonMain/kotlin/kotlinx/rpc/RpcCall.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc
6 |
7 | import kotlinx.rpc.descriptor.RpcServiceDescriptor
8 |
9 | /**
10 | * Represents a method call from an RPC service.
11 | *
12 | * @property descriptor [RpcServiceDescriptor] of a service that made the call.
13 | * @property callableName The name of the method being called.
14 | * @property parameters array of parameters for the call
15 | * @property serviceId The id of the service that made the call.
16 | */
17 | public class RpcCall(
18 | public val descriptor: RpcServiceDescriptor<*>,
19 | public val callableName: String,
20 | public val parameters: Array,
21 | public val serviceId: Long,
22 | )
23 |
--------------------------------------------------------------------------------
/gradle-conventions-settings/src/main/kotlin/includePublic.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("unused", "detekt.MissingPackageDeclaration")
6 |
7 | import org.gradle.api.initialization.Settings
8 | import org.gradle.kotlin.dsl.extra
9 |
10 | /**
11 | * Includes a project by the given Gradle path and marks it as a public.
12 | */
13 | fun Settings.includePublic(projectPath: String) {
14 | include(projectPath)
15 |
16 | gradle.rootProject {
17 | project(projectPath).extra["isPublicModule"] = true
18 | }
19 | }
20 |
21 | /**
22 | * Marks root project as public
23 | */
24 | fun Settings.includeRootAsPublic() {
25 | gradle.rootProject {
26 | extra["isPublicModule"] = true
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/krpc-protocol-compatibility-tests/test-api/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("PropertyName")
6 | @file:OptIn(ExperimentalAbiValidation::class)
7 |
8 | import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
9 | import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation
10 |
11 | plugins {
12 | alias(libs.plugins.conventions.jvm)
13 | alias(libs.plugins.atomicfu)
14 | }
15 |
16 | dependencies {
17 | compileOnly(libs.atomicfu)
18 | compileOnly(libs.coroutines.core)
19 | }
20 |
21 | kotlin {
22 | explicitApi = ExplicitApiMode.Disabled
23 |
24 | abiValidation {
25 | enabled.set(false)
26 | }
27 | }
28 |
29 | tasks.test {
30 | useJUnitPlatform()
31 | }
32 |
--------------------------------------------------------------------------------
/compiler-plugin/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | rootProject.name = "compiler-plugin"
6 |
7 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
8 |
9 | pluginManagement {
10 | includeBuild("../gradle-conventions")
11 | includeBuild("../gradle-conventions-settings")
12 | }
13 |
14 | plugins {
15 | id("conventions-repositories")
16 | id("conventions-version-resolution")
17 | id("conventions-develocity")
18 | id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
19 | }
20 |
21 | includeRootAsPublic()
22 |
23 | includePublic(":compiler-plugin-k2")
24 | includePublic(":compiler-plugin-common")
25 | includePublic(":compiler-plugin-backend")
26 | includePublic(":compiler-plugin-cli")
27 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/composeApp/src/androidMain/kotlin/kotlinx/rpc/sample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.sample
6 |
7 | import App
8 | import android.os.Bundle
9 | import androidx.activity.ComponentActivity
10 | import androidx.activity.compose.setContent
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.ui.tooling.preview.Preview
13 |
14 | class MainActivity : ComponentActivity() {
15 | override fun onCreate(savedInstanceState: Bundle?) {
16 | super.onCreate(savedInstanceState)
17 |
18 | setContent {
19 | App()
20 | }
21 | }
22 | }
23 |
24 | @Preview
25 | @Composable
26 | fun AppAndroidPreview() {
27 | App()
28 | }
29 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("UnstableApiUsage")
6 |
7 | rootProject.name = "ktor-all-platforms-app"
8 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
9 |
10 | pluginManagement {
11 | repositories {
12 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
13 | google()
14 | gradlePluginPortal()
15 | mavenCentral()
16 | }
17 | }
18 |
19 | dependencyResolutionManagement {
20 | repositories {
21 | google()
22 | mavenCentral()
23 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
24 | }
25 | }
26 |
27 | include(":composeApp")
28 | include(":server")
29 | include(":shared")
30 |
--------------------------------------------------------------------------------
/samples/ktor-web-app/README.md:
--------------------------------------------------------------------------------
1 | # Ktor Web App
2 | Sample application with Kotlin/Js on frontend and Kotlin/Jvm on backend,that uses kRPC with Ktor to communicate.
3 |
4 | ### Running frontend
5 | To run frontend in development mode, run this command:
6 | ```bash
7 | ./gradlew frontend:jsRun
8 | ```
9 | The client webpack app will start on port 3000 and it will route API requests to http://localhost:8080
10 |
11 | ### Running server
12 | To run server without compiling frontend, simply run `main` function in [Application.kt](/server/src/main/kotlin/Application.kt) from IDEA UI.
13 |
14 | To Run server with latest frontend use this command:
15 | ```bash
16 | ./gradlew server:runApp
17 | ```
18 | Note that this configuration uses production distribution of frontend app, which makes each build slower, as it takes more time to compile production webpack.
19 |
--------------------------------------------------------------------------------
/tests/krpc-protocol-compatibility-tests/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/tests/compiler-plugin-tests/src/test/kotlin/kotlinx/rpc/codegen/test/GenerateTests.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.codegen.test
6 |
7 | import kotlinx.rpc.codegen.test.runners.AbstractBoxTest
8 | import kotlinx.rpc.codegen.test.runners.AbstractDiagnosticTest
9 | import org.jetbrains.kotlin.generators.generateTestGroupSuiteWithJUnit5
10 |
11 | fun main() {
12 | generateTestGroupSuiteWithJUnit5 {
13 | testGroup(testDataRoot = "src/testData", testsRoot = "src/test-gen") {
14 | testClass {
15 | model("diagnostics")
16 | }
17 |
18 | testClass {
19 | model("box")
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/samples/grpc-app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | kotlin("jvm") version "2.2.0"
7 | id("org.jetbrains.kotlinx.rpc.plugin") version "0.10.0-grpc-127"
8 | }
9 |
10 | group = "kotlinx.rpc.sample"
11 | version = "0.0.1"
12 |
13 | repositories {
14 | mavenCentral()
15 | maven("https://maven.pkg.jetbrains.space/public/p/krpc/grpc")
16 | }
17 |
18 | kotlin {
19 | jvmToolchain(11)
20 | }
21 |
22 | dependencies {
23 | implementation("org.jetbrains.kotlinx:kotlinx-rpc-grpc-core:0.10.0-grpc-127")
24 | implementation("ch.qos.logback:logback-classic:1.5.20")
25 | implementation("io.grpc:grpc-netty:1.76.0")
26 | implementation("io.grpc:grpc-kotlin-stub:1.5.0")
27 | }
28 |
29 | rpc {
30 | grpc()
31 | }
32 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/krpc/krpc-test/src/commonMain/kotlin/kotlinx/rpc/krpc/test/KrpcTestClient.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.test
6 |
7 | import kotlinx.rpc.krpc.KrpcConfig
8 | import kotlinx.rpc.krpc.KrpcTransport
9 | import kotlinx.rpc.krpc.client.InitializedKrpcClient
10 | import kotlinx.rpc.krpc.client.KrpcClient
11 |
12 | /**
13 | * Implementation of [KrpcClient] that can be used to test custom [KrpcTransport].
14 | *
15 | * NOTE: one [KrpcTransport] is meant to be used by only one client,
16 | * but this class allows for abuse. Be cautious about how you handle [KrpcTransport] with this class.
17 | */
18 | class KrpcTestClient(
19 | config: KrpcConfig.Client,
20 | transport: KrpcTransport,
21 | ) : InitializedKrpcClient(config, transport)
22 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/MyServiceImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.sample
6 |
7 | import kotlinx.coroutines.delay
8 | import kotlinx.coroutines.flow.Flow
9 | import kotlinx.coroutines.flow.flow
10 | import kotlin.coroutines.CoroutineContext
11 |
12 | class MyServiceImpl : MyService {
13 | override suspend fun hello(user: String, userData: UserData): String {
14 | return "Nice to meet you $user, how is it in ${userData.address}?"
15 | }
16 |
17 | override fun subscribeToNews(): Flow {
18 | return flow {
19 | repeat(10) {
20 | delay(200)
21 | emit("Article number $it")
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/RpcFirCliOptions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.codegen
6 |
7 | import org.jetbrains.kotlin.compiler.plugin.CliOption
8 | import org.jetbrains.kotlin.config.CompilerConfigurationKey
9 |
10 | object RpcFirCliOptions {
11 | val ANNOTATION_TYPE_SAFETY = CliOption(
12 | optionName = "annotation-type-safety",
13 | valueDescription = "true or false",
14 | description = "Enables/disables annotation type safety analysis.",
15 | required = false,
16 | allowMultipleOccurrences = false,
17 | )
18 | }
19 |
20 | object RpcFirConfigurationKeys {
21 | val ANNOTATION_TYPE_SAFETY = CompilerConfigurationKey.create("annotation type safety")
22 | }
23 |
--------------------------------------------------------------------------------
/core/src/jvmMain/kotlin/kotlinx/rpc/internal/internalServiceDescriptorOf.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal
6 |
7 | import kotlinx.rpc.annotations.Rpc
8 | import kotlin.reflect.KClass
9 | import kotlin.reflect.full.companionObjectInstance
10 |
11 | private const val RPC_SERVICE_STUB_SIMPLE_NAME = "\$rpcServiceStub"
12 |
13 | internal actual fun <@Rpc T : Any> internalServiceDescriptorOf(kClass: KClass): Any? {
14 | val className = "${kClass.qualifiedName}\$$RPC_SERVICE_STUB_SIMPLE_NAME"
15 |
16 | return try {
17 | return kClass.java.classLoader
18 | .loadClass(className)
19 | ?.kotlin
20 | ?.companionObjectInstance
21 | } catch (_: ClassNotFoundException) {
22 | null
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/CallData.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.internal.transport.RPCMessage.CallData [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallData]
2 | - callType: org.jetbrains.krpc.internal.transport.RPCMessage.CallType
3 | - Nullable
4 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallType
5 | - callableName: kotlin.String
6 | - callId: kotlin.String
7 | - connectionId: kotlin.Long
8 | - Nullable
9 | - pluginParams: kotlin.collections.Map
10 | - Nullable
11 | - serviceId: kotlin.Long
12 | - Nullable
13 | - serviceType: kotlin.String
14 |
15 | org.jetbrains.krpc.internal.transport.RPCMessage.CallDataBinary
16 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallDataBinary
17 | org.jetbrains.krpc.RPCMessage.CallData
18 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallDataString
--------------------------------------------------------------------------------
/karma/chrome_bin.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | config.set({
6 | "browsers": ["MyChromeHeadless"],
7 | "customLaunchers": {
8 | "MyChromeHeadless": {
9 | base: "ChromeHeadless",
10 | flags: [
11 | "--allow-failed-policy-fetch-for-test",
12 | "--allow-external-pages",
13 | "--no-sandbox",
14 | "--disable-web-security",
15 | "--disable-setuid-sandbox",
16 | "--enable-logging",
17 | "--v=1"
18 | ]
19 | }
20 | },
21 | "client": {
22 | captureConsole: true,
23 | "mocha": {
24 | timeout: 300000
25 | }
26 | }
27 | });
28 |
29 | process.env.CHROME_BIN = require('puppeteer').executablePath();
30 |
--------------------------------------------------------------------------------
/.github/workflows/changelog.yml:
--------------------------------------------------------------------------------
1 | name: Verify Docs Changelog
2 |
3 | on:
4 | pull_request:
5 |
6 | permissions:
7 | contents: read
8 |
9 | jobs:
10 | verify-platforms-table:
11 | name: Run Verification
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Checkout Sources
15 | uses: actions/checkout@v5
16 | with:
17 | fetch-depth: 0
18 |
19 | - name: Setup Gradle
20 | uses: gradle/actions/setup-gradle@v4
21 |
22 | - name: Check Platforms Table
23 | run: ./gradlew updateDocsChangelog --info --stacktrace
24 |
25 | - name: Check if changelog is up-to-date
26 | run: |
27 | if [[ -n "$(git status --porcelain | grep docs/pages/kotlinx-rpc/topics/changelog.md)" ]]; then
28 | echo "Changelog is not up to date. Please run './gradlew updateDocsChangelog' and commit changes"
29 | exit 1
30 | fi
31 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/app/src/main/kotlin/kotlinx/rpc/sample/data/Client.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.sample.data
6 |
7 | import io.ktor.client.HttpClient
8 | import io.ktor.client.engine.okhttp.OkHttp
9 | import io.ktor.client.request.url
10 | import kotlinx.rpc.RpcClient
11 | import kotlinx.rpc.krpc.ktor.client.installKrpc
12 | import kotlinx.rpc.krpc.ktor.client.rpc
13 | import kotlinx.rpc.krpc.ktor.client.rpcConfig
14 | import kotlinx.rpc.krpc.serialization.json.json
15 |
16 | fun createRpcClient(): RpcClient {
17 | return HttpClient(OkHttp) {
18 | installKrpc()
19 | }.rpc {
20 | url("ws://10.0.2.2:8080/api")
21 |
22 | rpcConfig {
23 | serialization {
24 | json()
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/gradle-plugin/src/main/kotlin/kotlinx/rpc/RpcGradlePlugin.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc
6 |
7 | import org.gradle.api.Plugin
8 | import org.gradle.api.Project
9 | import org.gradle.kotlin.dsl.create
10 |
11 | @Suppress("unused")
12 | public class RpcGradlePlugin : Plugin {
13 | override fun apply(target: Project) {
14 | target.extensions.create("rpc")
15 |
16 | applyCompilerPlugin(target)
17 | }
18 |
19 | private fun applyCompilerPlugin(target: Project) {
20 | target.plugins.apply(CompilerPluginK2::class.java)
21 | target.plugins.apply(CompilerPluginCommon::class.java)
22 | target.plugins.apply(CompilerPluginBackend::class.java)
23 | target.plugins.apply(CompilerPluginCli::class.java)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/compiler-plugin-tests/src/testData/box/serviceDescriptor.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | // RUN_PIPELINE_TILL: BACKEND
6 |
7 | import kotlinx.coroutines.runBlocking
8 | import kotlinx.rpc.descriptor.serviceDescriptorOf
9 | import kotlinx.rpc.annotations.Rpc
10 | import kotlinx.rpc.codegen.test.TestRpcClient
11 | import kotlinx.rpc.internal.utils.ExperimentalRpcApi
12 |
13 | @Rpc
14 | interface BoxService {
15 | suspend fun simple(): String
16 | }
17 |
18 | @OptIn(ExperimentalRpcApi::class)
19 | fun box(): String = runBlocking {
20 | val descriptor = serviceDescriptorOf()
21 | val result = descriptor.callables["simple"]?.name
22 |
23 | if (result == "simple") "OK" else "Fail: $result"
24 | }
25 |
26 | /* GENERATED_FIR_TAGS: functionDeclaration, interfaceDeclaration, suspend */
27 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-k2/src/main/kotlin/kotlinx/rpc/codegen/FirRpcPredicates.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.codegen
6 |
7 | import kotlinx.rpc.codegen.common.RpcClassId
8 | import org.jetbrains.kotlin.fir.extensions.predicate.DeclarationPredicate
9 |
10 | object FirRpcPredicates {
11 | internal val rpc = DeclarationPredicate.create {
12 | annotated(RpcClassId.rpcAnnotation.asSingleFqName()) // @Rpc
13 | }
14 |
15 | internal val rpcMeta = DeclarationPredicate.create {
16 | metaAnnotated(RpcClassId.rpcAnnotation.asSingleFqName(), includeItself = true)
17 | }
18 |
19 | internal val checkedAnnotationMeta = DeclarationPredicate.create {
20 | metaAnnotated(RpcClassId.checkedTypeAnnotation.asSingleFqName(), includeItself = false)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/StreamSerializer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.internal
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 | import kotlinx.serialization.descriptors.PrimitiveKind
9 | import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
10 | import kotlinx.serialization.descriptors.SerialDescriptor
11 |
12 | @Suppress("PropertyName", "detekt.VariableNaming")
13 | @InternalRpcApi
14 | public abstract class StreamSerializer {
15 | protected val STREAM_ID_SERIAL_NAME: String = "streamId"
16 | protected val STREAM_ID_SERIALIZER_NAME: String = "StreamIdSerializer"
17 |
18 | protected val streamIdDescriptor: SerialDescriptor =
19 | PrimitiveSerialDescriptor(STREAM_ID_SERIALIZER_NAME, PrimitiveKind.STRING)
20 | }
21 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/commonMain/kotlin/kotlinx/rpc/krpc/test/Payloads.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("detekt.MatchingDeclarationName")
2 |
3 | /*
4 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
5 | */
6 |
7 | package kotlinx.rpc.krpc.test
8 |
9 | import kotlinx.coroutines.flow.Flow
10 | import kotlinx.coroutines.flow.flow
11 | import kotlinx.serialization.Contextual
12 | import kotlinx.serialization.Serializable
13 |
14 | @Serializable
15 | data class PayloadWithStream(val payload: String, val stream: @Contextual Flow)
16 |
17 | fun payload(index: Int = 0): PayloadWithStream {
18 | return PayloadWithStream(
19 | "test$index",
20 | flow { emit("a$index"); emit("b$index"); emit("c$index"); }
21 | )
22 | }
23 |
24 | fun plainFlow(count: Int = 5, get: (Int) -> T): Flow {
25 | return flow { repeat(count) { emit(get(it)) } }
26 | }
27 |
--------------------------------------------------------------------------------
/samples/ktor-all-platforms-app/server/src/main/kotlin/kotlinx/rpc/sample/UserServiceImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.sample
6 |
7 | import UserData
8 | import UserService
9 | import kotlinx.coroutines.delay
10 | import kotlinx.coroutines.flow.Flow
11 | import kotlinx.coroutines.flow.flow
12 | import kotlin.coroutines.CoroutineContext
13 |
14 | class UserServiceImpl : UserService {
15 | override suspend fun hello(user: String, userData: UserData): String {
16 | return "Nice to meet you $user, how is it in ${userData.address}?"
17 | }
18 |
19 | override fun subscribeToNews(): Flow {
20 | return flow {
21 | repeat(10) {
22 | delay(300)
23 | emit("Article number $it")
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/bom/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import util.KOTLINX_RPC_PREFIX
6 | import util.other.isPublicModule
7 |
8 | plugins {
9 | `java-platform`
10 | `maven-publish`
11 | alias(libs.plugins.conventions.common)
12 | }
13 |
14 | dependencies {
15 | constraints {
16 | rootProject.subprojects.filter {
17 | it.isPublicModule && it != project
18 | }.forEach { project ->
19 | api(project)
20 | }
21 | }
22 | }
23 |
24 | publishing {
25 | publications {
26 | create("bom") {
27 | groupId = project.group.toString()
28 | artifactId = "$KOTLINX_RPC_PREFIX-${project.name}"
29 | version = project.version.toString()
30 |
31 | from(components["javaPlatform"])
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/samples/ktor-android-app/server/src/main/kotlin/kotlinx/rpc/sample/Application.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 | package kotlinx.rpc.sample
5 |
6 | import io.ktor.server.application.*
7 | import io.ktor.server.cio.*
8 | import io.ktor.server.routing.*
9 | import kotlinx.rpc.krpc.ktor.server.Krpc
10 | import kotlinx.rpc.krpc.ktor.server.rpc
11 | import kotlinx.rpc.krpc.serialization.json.json
12 |
13 | fun main(args: Array): Unit = EngineMain.main(args)
14 |
15 | @Suppress("unused")
16 | fun Application.module() {
17 | install(Krpc)
18 |
19 | routing {
20 | rpc("/api") {
21 | rpcConfig {
22 | serialization {
23 | json()
24 | }
25 | }
26 |
27 | registerService { MyServiceImpl() }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-k2/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6 | import util.enableContextParameters
7 | import util.whenForIde
8 | import util.whenKotlinCompilerIsAtLeast
9 |
10 | plugins {
11 | alias(libs.plugins.conventions.jvm)
12 | alias(libs.plugins.compiler.specific.module)
13 | }
14 |
15 | tasks.jar {
16 | // important for IDEA plugin
17 | whenForIde {
18 | archiveClassifier.set("for-ide")
19 | }
20 | }
21 |
22 | kotlin {
23 | explicitApi = ExplicitApiMode.Disabled
24 |
25 | rootProject.whenKotlinCompilerIsAtLeast(2, 2, 0) {
26 | enableContextParameters()
27 | }
28 | }
29 |
30 | dependencies {
31 | compileOnly(libs.kotlin.compiler)
32 |
33 | implementation(projects.compilerPluginCommon)
34 | }
35 |
--------------------------------------------------------------------------------
/docs/pages/assets/homepage.svg:
--------------------------------------------------------------------------------
1 |
21 |
--------------------------------------------------------------------------------
/samples/simple-ktor-app/src/main/kotlin/Server.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import io.ktor.server.application.*
6 | import io.ktor.server.engine.*
7 | import io.ktor.server.netty.*
8 | import io.ktor.server.routing.*
9 | import kotlinx.rpc.krpc.ktor.server.Krpc
10 | import kotlinx.rpc.krpc.ktor.server.rpc
11 | import kotlinx.rpc.krpc.serialization.json.json
12 |
13 | fun main() {
14 | embeddedServer(Netty, port = 8080) {
15 | module()
16 | }.start(wait = true)
17 | }
18 |
19 | fun Application.module() {
20 | install(Krpc)
21 |
22 | routing {
23 | rpc("/image-recognizer") {
24 | rpcConfig {
25 | serialization {
26 | json()
27 | }
28 | }
29 |
30 | registerService { ImageRecognizerService() }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/newApi/kotlin/tests/ApiServer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package tests
6 |
7 | import kotlinx.rpc.krpc.compatibility.TestApiServer
8 | import interfaces.BarInterface
9 | import interfaces.BarInterfaceImpl
10 | import interfaces.BazInterface
11 | import interfaces.BazInterfaceImpl
12 | import interfaces.FooInterface
13 | import interfaces.FooInterfaceImpl
14 | import kotlinx.rpc.RpcServer
15 | import kotlinx.rpc.registerService
16 |
17 | @Suppress("unused")
18 | class ApiServer : TestApiServer {
19 | override fun serveAllInterfaces(rpcServer: RpcServer) {
20 | rpcServer.apply {
21 | registerService { FooInterfaceImpl() }
22 | registerService { BarInterfaceImpl() }
23 | registerService { BazInterfaceImpl() }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/krpc-compatibility-tests/src/oldApi/kotlin/tests/ApiServer.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package tests
6 |
7 | import kotlinx.rpc.krpc.compatibility.TestApiServer
8 | import interfaces.BarInterface
9 | import interfaces.BarInterfaceImpl
10 | import interfaces.BazInterface
11 | import interfaces.BazInterfaceImpl
12 | import interfaces.FooInterface
13 | import interfaces.FooInterfaceImpl
14 | import kotlinx.rpc.RpcServer
15 | import kotlinx.rpc.registerService
16 |
17 | @Suppress("unused")
18 | class ApiServer : TestApiServer {
19 | override fun serveAllInterfaces(rpcServer: RpcServer) {
20 | rpcServer.apply {
21 | registerService { FooInterfaceImpl() }
22 | registerService { BarInterfaceImpl() }
23 | registerService { BazInterfaceImpl() }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore Gradle project-specific cache directory
2 | .gradle
3 |
4 | # Ignore Gradle build output directory
5 | build
6 | .kotlin
7 | lib-kotlin
8 | # idea files
9 | .idea/*
10 | !.idea/runConfigurations
11 | !.idea/runConfigurations/*
12 | !.idea/vcs.xml
13 | !.idea/dictionaries
14 | !.idea/dictionaries/*
15 | !.idea/copyright
16 | !.idea/copyright/*
17 | !.idea/codeStyles
18 | !.idea/codeStyles/*
19 | !.idea/icon.svg
20 | !.idea/detekt.xml
21 | !.idea/kotlinTestDataPluginTestDataPaths.xml
22 | !.idea/kotlinx-rpc.iml
23 | !.idea/kotlin-plugins.xml
24 |
25 | samples/**/.idea/*
26 |
27 | .DS_Store
28 |
29 | # Ignore generated Detekt reports
30 | detekt/reports/**
31 |
32 | # tmp files created by tests
33 | *.tmp
34 |
35 | .puppeteer
36 |
37 | # Ignore kover reports
38 | /kover
39 |
40 | local.properties
41 | scan-journal.log
42 |
43 | # krpc compat tests
44 | tests/krpc-protocol-compatibility-tests/v*
45 | gradle-conventions/src/main/kotlin/util/krpc_compat/versions.kt
46 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/conventions-jvm.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:OptIn(ExperimentalAbiValidation::class)
6 |
7 | import compat.patrouille.configureJavaCompatibility
8 | import compat.patrouille.configureKotlinCompatibility
9 | import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation
10 | import util.configureAbiFilters
11 | import util.enableAbiValidation
12 | import util.targets.configureJvm
13 |
14 | plugins {
15 | id("conventions-common")
16 | id("org.jetbrains.kotlin.jvm")
17 | }
18 |
19 | java {
20 | withSourcesJar()
21 | }
22 |
23 | configureJavaCompatibility(8)
24 | configureKotlinCompatibility("2.0.0")
25 |
26 | kotlin {
27 | explicitApi()
28 |
29 | abiValidation {
30 | enabled = enableAbiValidation
31 |
32 | configureAbiFilters()
33 | }
34 | }
35 |
36 | configureJvm(isKmp = false)
37 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-k2/src/main/templates/kotlinx/rpc/codegen/checkers/diagnostics/RpcKtDiagnosticFactoryToRendererMap.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.codegen.checkers.diagnostics
6 |
7 | import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
8 |
9 | fun RpcKtDiagnosticFactoryToRendererMap(
10 | name: String,
11 | init: (KtDiagnosticFactoryToRendererMap) -> Unit,
12 | ): Lazy {
13 | //##csm RpcKtDiagnosticFactoryToRendererMap
14 | //##csm specific=[2.0.0...2.2.10]
15 | return lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
16 | KtDiagnosticFactoryToRendererMap(name).also(init)
17 | }
18 | //##csm /specific
19 | //##csm default
20 | return KtDiagnosticFactoryToRendererMap(name, init)
21 | //##csm /default
22 | //##csm /RpcKtDiagnosticFactoryToRendererMap
23 | }
24 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-cbor/api/krpc-serialization-cbor.klib.api:
--------------------------------------------------------------------------------
1 | // Klib ABI Dump
2 | // Targets: [iosArm64, iosSimulatorArm64, iosX64, js, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, wasmWasi, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
3 | // Rendering settings:
4 | // - Signature version: 2
5 | // - Show manifest properties: true
6 | // - Show declarations: true
7 |
8 | // Library unique name:
9 | final fun (kotlinx.rpc.krpc.serialization/KrpcSerialFormatConfiguration).kotlinx.rpc.krpc.serialization.cbor/cbor(kotlinx.serialization.cbor/Cbor = ..., kotlin/Function1 = ...) // kotlinx.rpc.krpc.serialization.cbor/cbor|cbor@kotlinx.rpc.krpc.serialization.KrpcSerialFormatConfiguration(kotlinx.serialization.cbor.Cbor;kotlin.Function1){}[0]
10 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-json/api/krpc-serialization-json.klib.api:
--------------------------------------------------------------------------------
1 | // Klib ABI Dump
2 | // Targets: [iosArm64, iosSimulatorArm64, iosX64, js, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, wasmWasi, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
3 | // Rendering settings:
4 | // - Signature version: 2
5 | // - Show manifest properties: true
6 | // - Show declarations: true
7 |
8 | // Library unique name:
9 | final fun (kotlinx.rpc.krpc.serialization/KrpcSerialFormatConfiguration).kotlinx.rpc.krpc.serialization.json/json(kotlinx.serialization.json/Json = ..., kotlin/Function1 = ...) // kotlinx.rpc.krpc.serialization.json/json|json@kotlinx.rpc.krpc.serialization.KrpcSerialFormatConfiguration(kotlinx.serialization.json.Json;kotlin.Function1){}[0]
10 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/wasmWasiMain/kotlin/kotlinx/rpc/krpc/internal/ExceptionUtils.wasmWasi.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.internal
6 |
7 | internal actual class DeserializedException actual constructor(
8 | private val toStringMessage: String,
9 | actual override val message: String,
10 | stacktrace: List,
11 | cause: SerializedException?,
12 | className: String
13 | ) : Throwable() {
14 |
15 | override val cause: Throwable? = cause?.deserialize()
16 |
17 | override fun toString(): String = toStringMessage
18 | }
19 |
20 | internal actual fun Throwable.stackElements(): List = emptyList()
21 |
22 | internal actual fun SerializedException.deserializeUnsafe(): Throwable {
23 | return cancellationExceptionDeserialize()
24 | ?: DeserializedException(toStringMessage, message, stacktrace, cause, className)
25 | }
26 |
--------------------------------------------------------------------------------
/core/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | plugins {
6 | alias(libs.plugins.conventions.kmp)
7 | alias(libs.plugins.kotlinx.rpc)
8 | alias(libs.plugins.atomicfu)
9 | }
10 |
11 | kotlin {
12 | sourceSets {
13 | commonMain {
14 | dependencies {
15 | api(projects.utils)
16 | api(libs.coroutines.core)
17 |
18 | // TODO Remove after KRPC-178
19 | implementation(libs.serialization.core)
20 |
21 | implementation(libs.kotlin.reflect)
22 | }
23 | }
24 |
25 | jsMain {
26 | dependencies {
27 | implementation(libs.kotlin.js.wrappers)
28 | }
29 | }
30 |
31 | wasmJsMain {
32 | dependencies {
33 | implementation(libs.kotlinx.browser)
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/commonMain/kotlin/kotlinx/rpc/krpc/internal/SerializedException.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.internal
6 |
7 | import kotlinx.rpc.internal.utils.InternalRpcApi
8 | import kotlinx.serialization.SerialName
9 | import kotlinx.serialization.Serializable
10 |
11 | @InternalRpcApi
12 | @Serializable
13 | @SerialName("org.jetbrains.krpc.StackElement")
14 | public data class StackElement(
15 | val clazz: String,
16 | val method: String,
17 | val fileName: String?,
18 | val lineNumber: Int
19 | )
20 |
21 | @InternalRpcApi
22 | @Serializable
23 | @SerialName("org.jetbrains.krpc.SerializedException")
24 | public data class SerializedException(
25 | public val toStringMessage: String,
26 | public val message: String,
27 | public val stacktrace: List,
28 | public val cause: SerializedException?,
29 | public val className: String
30 | )
31 |
--------------------------------------------------------------------------------
/compiler-plugin/compiler-plugin-cli/src/main/templates/kotlinx/rpc/codegen/CompilerPluginRegistrar.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.codegen
6 |
7 | import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
8 | import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
9 | import org.jetbrains.kotlin.config.CompilerConfiguration
10 |
11 | @OptIn(ExperimentalCompilerApi::class)
12 | class RpcCompilerPlugin : CompilerPluginRegistrar() {
13 | override val supportsK2: Boolean = true
14 |
15 | //##csm RpcCompilerPlugin.pluginId
16 | //##csm specific=[2.0.0...2.2.99]
17 | //##csm /specific
18 | //##csm default
19 | override val pluginId: String = PLUGIN_ID
20 | //##csm /default
21 | //##csm /RpcCompilerPlugin.pluginId
22 |
23 | override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
24 | registerRpcExtensions(configuration)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/krpc/krpc-ktor/krpc-ktor-server/src/commonMain/kotlin/kotlinx/rpc/krpc/ktor/server/Krpc.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.krpc.ktor.server
6 |
7 | import io.ktor.server.application.*
8 | import io.ktor.server.websocket.*
9 | import io.ktor.util.*
10 | import kotlinx.rpc.krpc.KrpcConfigBuilder
11 |
12 | internal val KrpcServerPluginAttributesKey = AttributeKey("KrpcServerPluginAttributesKey")
13 |
14 | /**
15 | * Ktor server plugin that allows to configure RPC globally for all mounted servers.
16 | */
17 | public val Krpc: ApplicationPlugin = createApplicationPlugin(
18 | name = "Krpc",
19 | createConfiguration = { KrpcConfigBuilder.Server() },
20 | ) {
21 | application.pluginOrNull(WebSockets) ?: run {
22 | application.install(WebSockets)
23 | }
24 |
25 | application.attributes.put(KrpcServerPluginAttributesKey, pluginConfig)
26 | }
27 |
--------------------------------------------------------------------------------
/dokka-plugin/src/main/kotlin/kotlinx/rpc/dokka/RpcDokkaPlugin.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.dokka
6 |
7 | import org.jetbrains.dokka.CoreExtensions
8 | import org.jetbrains.dokka.base.DokkaBase
9 | import org.jetbrains.dokka.plugability.DokkaPlugin
10 | import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
11 | import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
12 |
13 | @Suppress("unused")
14 | class RpcDokkaPlugin : DokkaPlugin() {
15 | @OptIn(DokkaPluginApiPreview::class)
16 | override fun pluginApiPreviewAcknowledgement() = PluginApiPreviewAcknowledgement
17 |
18 | val rpcInternalApiTransformer by extending {
19 | plugin().preMergeDocumentableTransformer providing ::HideInternalRpcApiTransformer
20 | }
21 |
22 | val pageTransformer by extending {
23 | CoreExtensions.pageTransformer providing ::AddDocsLinkPageTransformer
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/krpc/krpc-test/src/jvmTest/resources/class_dumps/KrpcCallMessage.gold:
--------------------------------------------------------------------------------
1 | org.jetbrains.krpc.RPCMessage [Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage]
2 | - callId: kotlin.String
3 | - serviceId: kotlin.Long
4 | - Nullable
5 | - serviceType: kotlin.String
6 | - connectionId: kotlin.Long
7 | - Nullable
8 | - pluginParams: kotlin.collections.Map
9 | - Nullable
10 |
11 | org.jetbrains.krpc.internal.transport.RPCMessage.CallData
12 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallData
13 | org.jetbrains.krpc.RPCMessage.CallResult
14 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.CallResult
15 | org.jetbrains.krpc.RPCMessage.StreamCancel
16 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamCancel
17 | org.jetbrains.krpc.RPCMessage.StreamFinished
18 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamFinished
19 | org.jetbrains.krpc.internal.transport.RPCMessage.StreamMessage
20 | - Declared name: kotlinx.rpc.krpc.internal.KrpcCallMessage.StreamMessage
--------------------------------------------------------------------------------
/utils/src/commonMain/kotlin/kotlinx/rpc/internal/utils/deferredUtil.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package kotlinx.rpc.internal.utils
6 |
7 | import kotlinx.coroutines.CompletableDeferred
8 | import kotlinx.coroutines.ExperimentalCoroutinesApi
9 | import kotlinx.rpc.internal.utils.map.RpcInternalConcurrentHashMap
10 |
11 | @InternalRpcApi
12 | public fun RpcInternalConcurrentHashMap>.getDeferred(
13 | key: K,
14 | ): CompletableDeferred {
15 | return computeIfAbsent(key) { CompletableDeferred() }
16 | }
17 |
18 | @InternalRpcApi
19 | public operator fun RpcInternalConcurrentHashMap>.set(key: K, value: V) {
20 | getDeferred(key).complete(value)
21 | }
22 |
23 | @InternalRpcApi
24 | @OptIn(ExperimentalCoroutinesApi::class)
25 | public fun CompletableDeferred?.getOrNull(): T? = if (this != null && isCompleted) this.getCompleted() else null
26 |
--------------------------------------------------------------------------------
/compiler-plugin/build.gradle.kts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | import util.whenForIde
6 |
7 | plugins {
8 | id("empty") // resolve conventions classpath
9 | }
10 |
11 | val rpcVersion: String = libs.versions.kotlinx.rpc.get()
12 | val kotlinCompilerVersion = libs.versions.kotlin.compiler.get()
13 | val kotlinLangVersion = libs.versions.kotlin.lang.get()
14 |
15 | allprojects {
16 | group = "org.jetbrains.kotlinx"
17 |
18 | version = if (kotlinCompilerVersion != kotlinLangVersion) {
19 | "$kotlinCompilerVersion-$rpcVersion"
20 | } else {
21 | "$kotlinLangVersion-$rpcVersion"
22 | }
23 | }
24 |
25 | logger.lifecycle(
26 | "[Compiler Plugin] kotlinx.rpc project version: $version, " +
27 | "Kotlin version: $kotlinLangVersion, " +
28 | "Compiler version: $kotlinCompilerVersion"
29 | )
30 |
31 | whenForIde {
32 | logger.lifecycle("[Compiler Plugin] For-ide project mode enabled")
33 | }
34 |
--------------------------------------------------------------------------------
/gradle-conventions/src/main/kotlin/util/kotlinVersion.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | package util
6 |
7 | import org.gradle.api.plugins.ExtensionAware
8 | import org.gradle.kotlin.dsl.extra
9 | import org.gradle.kotlin.dsl.provideDelegate
10 | import util.other.ActionApplied
11 |
12 | fun String.kotlinVersionParsed(): KotlinVersion {
13 | val (major, minor, patch) = substringBefore('-').split(".").map { it.toInt() }
14 | return KotlinVersion(major, minor, patch)
15 | }
16 |
17 | @Suppress("unused")
18 | inline fun ExtensionAware.whenKotlinCompilerIsAtLeast(
19 | major: Int,
20 | minor: Int,
21 | patch: Int = 0,
22 | action: () -> Unit = {},
23 | ): ActionApplied {
24 | val kotlinCompilerVersion: KotlinVersion by extra
25 |
26 | if (kotlinCompilerVersion.isAtLeast(major, minor, patch)) {
27 | action()
28 |
29 | return ActionApplied.Applied
30 | }
31 |
32 | return ActionApplied.NotApplied
33 | }
34 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/jsMain/kotlin/kotlinx/rpc/krpc/internal/ExceptionUtils.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("detekt.MatchingDeclarationName")
6 |
7 | package kotlinx.rpc.krpc.internal
8 |
9 | internal actual class DeserializedException actual constructor(
10 | private val toStringMessage: String,
11 | actual override val message: String,
12 | stacktrace: List,
13 | cause: SerializedException?,
14 | className: String
15 | ) : Throwable() {
16 |
17 | override val cause: Throwable? = cause?.deserialize()
18 |
19 | override fun toString(): String = toStringMessage
20 | }
21 |
22 |
23 | internal actual fun Throwable.stackElements(): List = emptyList()
24 |
25 | internal actual fun SerializedException.deserializeUnsafe(): Throwable {
26 | return cancellationExceptionDeserialize()
27 | ?: DeserializedException(toStringMessage, message, stacktrace, cause, className)
28 | }
29 |
--------------------------------------------------------------------------------
/krpc/krpc-serialization/krpc-serialization-protobuf/api/krpc-serialization-protobuf.klib.api:
--------------------------------------------------------------------------------
1 | // Klib ABI Dump
2 | // Targets: [iosArm64, iosSimulatorArm64, iosX64, js, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, wasmWasi, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
3 | // Rendering settings:
4 | // - Signature version: 2
5 | // - Show manifest properties: true
6 | // - Show declarations: true
7 |
8 | // Library unique name:
9 | final fun (kotlinx.rpc.krpc.serialization/KrpcSerialFormatConfiguration).kotlinx.rpc.krpc.serialization.protobuf/protobuf(kotlinx.serialization.protobuf/ProtoBuf = ..., kotlin/Function1 = ...) // kotlinx.rpc.krpc.serialization.protobuf/protobuf|protobuf@kotlinx.rpc.krpc.serialization.KrpcSerialFormatConfiguration(kotlinx.serialization.protobuf.ProtoBuf;kotlin.Function1){}[0]
10 |
--------------------------------------------------------------------------------
/docs/pages/kotlinx-rpc/topics/service-descriptors.topic:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
9 | This API is experimental and may be changed at any time.
10 |
11 |
12 | Service Descriptors allow you to access entities generated by the compiler plugin.
13 | You can access them by using the following code:
14 |
15 |
16 | serviceDescriptorOf<MyService>()
17 |
18 |
19 | For the list of available entities, refer to the source code.
20 |
21 |
22 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/nativeMain/kotlin/kotlinx/rpc/krpc/internal/ExceptionUtils.native.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("detekt.MatchingDeclarationName")
6 |
7 | package kotlinx.rpc.krpc.internal
8 |
9 | internal actual class DeserializedException actual constructor(
10 | private val toStringMessage: String,
11 | actual override val message: String,
12 | stacktrace: List,
13 | cause: SerializedException?,
14 | className: String
15 | ) : Throwable() {
16 |
17 | override val cause: Throwable? = cause?.deserialize()
18 |
19 | override fun toString(): String = toStringMessage
20 | }
21 |
22 | internal actual fun Throwable.stackElements(): List = emptyList()
23 |
24 | internal actual fun SerializedException.deserializeUnsafe(): Throwable {
25 | return cancellationExceptionDeserialize()
26 | ?: DeserializedException(toStringMessage, message, stacktrace, cause, className)
27 | }
28 |
--------------------------------------------------------------------------------
/krpc/krpc-core/src/wasmJsMain/kotlin/kotlinx/rpc/krpc/internal/ExceptionUtils.wasm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3 | */
4 |
5 | @file:Suppress("detekt.MatchingDeclarationName")
6 |
7 | package kotlinx.rpc.krpc.internal
8 |
9 | internal actual class DeserializedException actual constructor(
10 | private val toStringMessage: String,
11 | actual override val message: String,
12 | stacktrace: List,
13 | cause: SerializedException?,
14 | className: String
15 | ) : Throwable() {
16 |
17 | override val cause: Throwable? = cause?.deserialize()
18 |
19 | override fun toString(): String = toStringMessage
20 | }
21 |
22 |
23 | internal actual fun Throwable.stackElements(): List = emptyList()
24 |
25 | internal actual fun SerializedException.deserializeUnsafe(): Throwable {
26 | return cancellationExceptionDeserialize()
27 | ?: DeserializedException(toStringMessage, message, stacktrace, cause, className)
28 | }
29 |
--------------------------------------------------------------------------------
/.github/workflows/readme.yml:
--------------------------------------------------------------------------------
1 | name: Verify Readme
2 |
3 | on:
4 | pull_request:
5 |
6 | permissions:
7 | contents: read
8 |
9 | jobs:
10 | verify-readme:
11 | name: Run Verification
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Checkout Sources
15 | uses: actions/checkout@v5
16 | with:
17 | fetch-depth: 0
18 |
19 | - name: Setup Gradle
20 | uses: gradle/actions/setup-gradle@v4
21 |
22 | - name: Check Platforms Table
23 | run: ./gradlew updateDocsChangelog --info --stacktrace
24 |
25 | - name: Check if readme is changed in a propper branch
26 | run: |
27 | if [[ -n "$(git status --porcelain | grep README.md)" ]]; then
28 | target_branch=${{ github.base_ref }}
29 | pr_branch=${{ github.head_ref }}
30 | if [[ "$target_branch" == "main" && ! "$pr_branch" =~ ^release-.* ]]; then
31 | echo "README.md change targeting main can only be done in release-* branches"
32 | exit 1
33 | fi
34 | fi
35 |
--------------------------------------------------------------------------------