diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4db3ade5c1..3b327da7f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ ktor = "2.3.5" ksp = "1.9.20-RC-1.0.13" kotlin-poet = "1.14.2" -microutils = "0.20.8" +microutils = "0.20.9" github-release-plugin = "2.4.1" dokka = "1.9.10" diff --git a/mppProjectWithSerialization.gradle b/mppProjectWithSerialization.gradle index e9ddf4b451..2f44259eef 100644 --- a/mppProjectWithSerialization.gradle +++ b/mppProjectWithSerialization.gradle @@ -15,6 +15,7 @@ kotlin { } linuxX64() mingwX64() + linuxArm64() sourceSets { commonMain { diff --git a/tgbotapi.behaviour_builder/src/linuxArm64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt b/tgbotapi.behaviour_builder/src/linuxArm64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt new file mode 100644 index 0000000000..57f3662698 --- /dev/null +++ b/tgbotapi.behaviour_builder/src/linuxArm64Main/kotlin/ActualDefaultCoroutineScopeProvider.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.extensions.behaviour_builder + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers + +actual var defaultCoroutineScopeProvider: () -> CoroutineScope = { CoroutineScope(Dispatchers.Default) } diff --git a/tgbotapi.core/build.gradle b/tgbotapi.core/build.gradle index e6eb4c507c..f5269f1187 100644 --- a/tgbotapi.core/build.gradle +++ b/tgbotapi.core/build.gradle @@ -55,6 +55,12 @@ kotlin { } } + linuxArm64Main { + dependencies { + api libs.ktor.client.cio + } + } + mingwX64Main { dependencies { api libs.ktor.client.winhttp diff --git a/tgbotapi.core/src/linuxArm64Main/kotlin/PackageInfo.kt b/tgbotapi.core/src/linuxArm64Main/kotlin/PackageInfo.kt new file mode 100644 index 0000000000..20be3dda7a --- /dev/null +++ b/tgbotapi.core/src/linuxArm64Main/kotlin/PackageInfo.kt @@ -0,0 +1 @@ +package dev.inmo.tgbotapi diff --git a/tgbotapi.core/src/linuxArm64Main/kotlin/bot/ktor/KtorRequestsExecutor.kt b/tgbotapi.core/src/linuxArm64Main/kotlin/bot/ktor/KtorRequestsExecutor.kt new file mode 100644 index 0000000000..2f49bfc213 --- /dev/null +++ b/tgbotapi.core/src/linuxArm64Main/kotlin/bot/ktor/KtorRequestsExecutor.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.bot.ktor + +import dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor + +actual typealias KtorRequestsExecutor = MultipleClientKtorRequestsExecutor diff --git a/tgbotapi.core/src/linuxArm64Main/kotlin/bot/ktor/base/ActualPlatformClientCopy.kt b/tgbotapi.core/src/linuxArm64Main/kotlin/bot/ktor/base/ActualPlatformClientCopy.kt new file mode 100644 index 0000000000..ad3e4e5dce --- /dev/null +++ b/tgbotapi.core/src/linuxArm64Main/kotlin/bot/ktor/base/ActualPlatformClientCopy.kt @@ -0,0 +1,22 @@ +package dev.inmo.tgbotapi.bot.ktor.base + +import io.ktor.client.* +import io.ktor.client.engine.cio.* + +/** + * This function is used in default constructor of [MultipleClientKtorRequestsExecutor] and on all non-native + * platforms and MingwX64 should return [client] + * + * On LinuxX64 it will create copy with Curl engine or throw an exception if engine is different with Curl + * + * @throws IllegalArgumentException When pass non Curl-based [HttpClient] on LinuxX64 + */ +internal actual inline fun platformClientCopy(client: HttpClient): HttpClient = (client.engineConfig as? CIOEngineConfig) ?.let { + lateinit var config: HttpClientConfig + client.config { + config = this as HttpClientConfig + }.close() + HttpClient(CIO) { + this.plusAssign(config) + } +} ?: throw IllegalArgumentException("On LinuxX64 TelegramBotAPI currently support only Curl Ktor HttpClient engine") diff --git a/tgbotapi.core/src/linuxArm64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt b/tgbotapi.core/src/linuxArm64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt new file mode 100644 index 0000000000..942cbfddf2 --- /dev/null +++ b/tgbotapi.core/src/linuxArm64Main/kotlin/requests/abstracts/ActualMPPFileAsMultipartFile.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.requests.abstracts + +import dev.inmo.micro_utils.common.MPPFile +import dev.inmo.micro_utils.ktor.common.input +import dev.inmo.tgbotapi.requests.abstracts.MultipartFile + +actual fun MPPFile.asMultipartFile(): MultipartFile = MultipartFile(this.name) { + input() +} diff --git a/tgbotapi.core/src/linuxArm64Main/kotlin/utils/ActualByteReadChannelAsInput.kt b/tgbotapi.core/src/linuxArm64Main/kotlin/utils/ActualByteReadChannelAsInput.kt new file mode 100644 index 0000000000..8f52f52a4e --- /dev/null +++ b/tgbotapi.core/src/linuxArm64Main/kotlin/utils/ActualByteReadChannelAsInput.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.utils + +import io.ktor.utils.io.ByteReadChannel +import io.ktor.utils.io.core.Input +import io.ktor.utils.io.readRemaining + +actual suspend fun ByteReadChannel.asInput(): Input = readRemaining() diff --git a/tgbotapi.core/src/linuxArm64Main/kotlin/utils/ActualMimeType.kt b/tgbotapi.core/src/linuxArm64Main/kotlin/utils/ActualMimeType.kt new file mode 100644 index 0000000000..18ea512429 --- /dev/null +++ b/tgbotapi.core/src/linuxArm64Main/kotlin/utils/ActualMimeType.kt @@ -0,0 +1,12 @@ +package dev.inmo.tgbotapi.utils + +import kotlinx.serialization.Serializable + +//actual typealias MimeType = MimeType + +@OptIn(RiskFeature::class) +@Serializable(MimeTypeSerializer::class) +actual data class MimeType( + actual val raw: String +) +internal actual fun createMimeType(raw: String): MimeType = MimeType(raw)