1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

update version of microutils and add arm platform target

This commit is contained in:
InsanusMokrassar 2023-10-20 22:07:14 +06:00
parent 2719e166a8
commit 1a479706e2
10 changed files with 70 additions and 1 deletions

View File

@ -13,7 +13,7 @@ ktor = "2.3.5"
ksp = "1.9.20-RC-1.0.13" ksp = "1.9.20-RC-1.0.13"
kotlin-poet = "1.14.2" kotlin-poet = "1.14.2"
microutils = "0.20.8" microutils = "0.20.9"
github-release-plugin = "2.4.1" github-release-plugin = "2.4.1"
dokka = "1.9.10" dokka = "1.9.10"

View File

@ -15,6 +15,7 @@ kotlin {
} }
linuxX64() linuxX64()
mingwX64() mingwX64()
linuxArm64()
sourceSets { sourceSets {
commonMain { commonMain {

View File

@ -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) }

View File

@ -55,6 +55,12 @@ kotlin {
} }
} }
linuxArm64Main {
dependencies {
api libs.ktor.client.cio
}
}
mingwX64Main { mingwX64Main {
dependencies { dependencies {
api libs.ktor.client.winhttp api libs.ktor.client.winhttp

View File

@ -0,0 +1 @@
package dev.inmo.tgbotapi

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.bot.ktor
import dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor
actual typealias KtorRequestsExecutor = MultipleClientKtorRequestsExecutor

View File

@ -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<out CIOEngineConfig>
client.config {
config = this as HttpClientConfig<out CIOEngineConfig>
}.close()
HttpClient(CIO) {
this.plusAssign(config)
}
} ?: throw IllegalArgumentException("On LinuxX64 TelegramBotAPI currently support only Curl Ktor HttpClient engine")

View File

@ -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()
}

View File

@ -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()

View File

@ -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)