Skip to content

Commit

Permalink
[commonize] #496 Update ktor to 3.0.0 and update submodules
Browse files Browse the repository at this point in the history
Ksoup depends on 3.0.0 so we have to update. Otherwise there will be missing classes.
  • Loading branch information
Him188 committed Jul 28, 2024
1 parent b80b6c5 commit f645bbd
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 85 deletions.
2 changes: 1 addition & 1 deletion app/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ kotlin {
api(libs.coil.core)
api(libs.coil.svg)
api(libs.coil.compose.core)
api(libs.coil.network.ktor2)
api(libs.coil.network.ktor3)
api(libs.datastore.core) // Data Persistence
api(libs.datastore.preferences.core) // Preferences
api(libs.precompose) // Navigator
Expand Down
72 changes: 0 additions & 72 deletions app/shared/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -70,75 +70,3 @@

# anitorrent
-keep class me.him188.ani.app.torrent.anitorrent.binding.** { *; }


# Keep the specified classes and all their members
-keep class io.ktor.client.network.sockets.TimeoutExceptionsCommonKt { *; }
-keep class io.ktor.client.plugins.HttpRedirect$Config { *; }
-keep class io.ktor.client.plugins.HttpRedirect$Plugin { *; }
-keep class io.ktor.client.plugins.HttpRedirect { *; }
-keep class io.ktor.client.plugins.HttpRequestRetry$Configuration { *; }
-keep class io.ktor.client.plugins.HttpRequestRetry$DelayContext { *; }
-keep class io.ktor.client.plugins.HttpRequestRetry$Plugin { *; }
-keep class io.ktor.client.plugins.HttpRequestRetry { *; }
-keep class io.ktor.client.plugins.HttpTimeout$HttpTimeoutCapabilityConfiguration { *; }
-keep class io.ktor.client.plugins.HttpTimeout$Plugin { *; }
-keep class io.ktor.client.plugins.HttpTimeout { *; }
-keep class io.ktor.client.plugins.UserAgent$Config { *; }
-keep class io.ktor.client.plugins.UserAgent$Plugin { *; }
-keep class io.ktor.client.plugins.UserAgent { *; }
-keep class io.ktor.util.InternalAPI { *; }
-keep class io.ktor.util.KtorDsl { *; }
-keep class io.ktor.utils.io.ByteReadChannelJVMKt { *; }
-keep class io.ktor.utils.io.CoroutinesKt { *; }
-keep class io.ktor.utils.io.ReadSessionKt { *; }
-keep class io.ktor.utils.io.core.Buffer$Companion { *; }
-keep class io.ktor.utils.io.core.Buffer { *; }
-keep class io.ktor.utils.io.core.ByteBuffersKt { *; }
-keep class io.ktor.utils.io.core.BytePacketBuilder { *; }
-keep class io.ktor.utils.io.core.ByteReadPacket$Companion { *; }
-keep class io.ktor.utils.io.core.ByteReadPacket { *; }
-keep class io.ktor.utils.io.core.CloseableJVMKt { *; }
-keep class io.ktor.utils.io.core.Input { *; }
-keep class io.ktor.utils.io.core.InputArraysKt { *; }
-keep class io.ktor.utils.io.core.InputPrimitivesKt { *; }
-keep class io.ktor.utils.io.core.Output { *; }
-keep class io.ktor.utils.io.core.OutputPrimitivesKt { *; }
-keep class io.ktor.utils.io.core.PreviewKt { *; }
-keep class io.ktor.utils.io.jvm.nio.WritingKt { *; }
-keep class io.ktor.utils.io.streams.InputKt { *; }

-dontwarn io.ktor.client.network.sockets.TimeoutExceptionsCommonKt
-dontwarn io.ktor.client.plugins.HttpRedirect$Config
-dontwarn io.ktor.client.plugins.HttpRedirect$Plugin
-dontwarn io.ktor.client.plugins.HttpRedirect
-dontwarn io.ktor.client.plugins.HttpRequestRetry$Configuration
-dontwarn io.ktor.client.plugins.HttpRequestRetry$DelayContext
-dontwarn io.ktor.client.plugins.HttpRequestRetry$Plugin
-dontwarn io.ktor.client.plugins.HttpRequestRetry
-dontwarn io.ktor.client.plugins.HttpTimeout$HttpTimeoutCapabilityConfiguration
-dontwarn io.ktor.client.plugins.HttpTimeout$Plugin
-dontwarn io.ktor.client.plugins.HttpTimeout
-dontwarn io.ktor.client.plugins.UserAgent$Config
-dontwarn io.ktor.client.plugins.UserAgent$Plugin
-dontwarn io.ktor.client.plugins.UserAgent
-dontwarn io.ktor.util.InternalAPI
-dontwarn io.ktor.util.KtorDsl
-dontwarn io.ktor.utils.io.ByteReadChannelJVMKt
-dontwarn io.ktor.utils.io.CoroutinesKt
-dontwarn io.ktor.utils.io.ReadSessionKt
-dontwarn io.ktor.utils.io.core.Buffer$Companion
-dontwarn io.ktor.utils.io.core.Buffer
-dontwarn io.ktor.utils.io.core.ByteBuffersKt
-dontwarn io.ktor.utils.io.core.BytePacketBuilder
-dontwarn io.ktor.utils.io.core.ByteReadPacket$Companion
-dontwarn io.ktor.utils.io.core.ByteReadPacket
-dontwarn io.ktor.utils.io.core.CloseableJVMKt
-dontwarn io.ktor.utils.io.core.Input
-dontwarn io.ktor.utils.io.core.InputArraysKt
-dontwarn io.ktor.utils.io.core.InputPrimitivesKt
-dontwarn io.ktor.utils.io.core.Output
-dontwarn io.ktor.utils.io.core.OutputPrimitivesKt
-dontwarn io.ktor.utils.io.core.PreviewKt
-dontwarn io.ktor.utils.io.jvm.nio.WritingKt
-dontwarn io.ktor.utils.io.streams.InputKt
2 changes: 1 addition & 1 deletion app/shared/reorderable
Submodule reorderable updated 1 files
+3 −3 build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import coil3.compose.AsyncImagePainter
import coil3.compose.DefaultModelEqualityDelegate
import coil3.compose.EqualityDelegate
import coil3.memory.MemoryCache
import coil3.network.ktor2.KtorNetworkFetcherFactory
import coil3.network.ktor3.KtorNetworkFetcherFactory
import coil3.request.CachePolicy
import coil3.request.crossfade
import coil3.svg.SvgDecoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.ktor.utils.io.core.Input
import io.ktor.utils.io.core.buildPacket
import io.ktor.utils.io.core.readAvailable
import io.ktor.utils.io.core.readBytes
import io.ktor.utils.io.core.remaining
import io.ktor.utils.io.core.writeFully
import io.ktor.utils.io.core.writeText
import kotlin.experimental.and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ import io.ktor.utils.io.jvm.javaio.toInputStream
import io.ktor.utils.io.streams.asInput
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.nio.charset.Charset

suspend inline fun HttpResponse.bodyAsDocument(): Document = body()

internal actual fun getXmlConverter(): ContentConverter = XmlConverter

private object XmlConverter : ContentConverter {
override suspend fun deserialize(
charset: Charset,
charset: java.nio.charset.Charset,
typeInfo: TypeInfo,
content: ByteReadChannel
): Any? {
Expand All @@ -31,9 +30,9 @@ private object XmlConverter : ContentConverter {
return Jsoup.parse(string, charset.name())
}

override suspend fun serializeNullable(
override suspend fun serialize(
contentType: ContentType,
charset: Charset,
charset: io.ktor.utils.io.charsets.Charset,
typeInfo: TypeInfo,
value: Any?
): OutgoingContent? {
Expand Down
7 changes: 3 additions & 4 deletions data-sources/api/test-codegen/src/main/AddMoreData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import me.him188.ani.datasources.dmhy.impl.protocol.Network
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.io.File
import java.nio.charset.Charset


/**
Expand Down Expand Up @@ -77,7 +76,7 @@ class TopicFetcher(
ContentType.Text.Html,
object : ContentConverter {
override suspend fun deserialize(
charset: Charset,
charset: io.ktor.utils.io.charsets.Charset,
typeInfo: TypeInfo,
content: ByteReadChannel
): Any? {
Expand All @@ -88,9 +87,9 @@ class TopicFetcher(
return Jsoup.parse(string, charset.name())
}

override suspend fun serializeNullable(
override suspend fun serialize(
contentType: ContentType,
charset: Charset,
charset: io.ktor.utils.io.charsets.Charset,
typeInfo: TypeInfo,
value: Any?
): OutgoingContent? {
Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ okio = "3.9.0"
korlibs = "6.0.0"
playwright = "1.44.0"
reorderable = "0.9.6"
ktor = "2.3.12"
ktor = "3.0.0-beta-2" # Ksoup 用 3.0 所以我们不得不用 3.0
koin = "4.0.0-RC1" # https://github.com/InsertKoinIO/koin/releases
slf4j = "2.0.12"
jsoup = "1.15.4"
Expand Down Expand Up @@ -135,6 +135,7 @@ coil-svg = { module = "io.coil-kt.coil3:coil-svg", version.ref = "coil" }
#coil-gif = { module = "io.coil-kt.coil3:coil-gif", version.ref = "coil" }
coil-network-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp", version.ref = "coil" }
coil-network-ktor2 = { module = "io.coil-kt.coil3:coil-network-ktor2", version.ref = "coil" }
coil-network-ktor3 = { module = "io.coil-kt.coil3:coil-network-ktor3", version.ref = "coil" }

# Jsoup - HTML parsing (for dmhy)
jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
Expand Down
1 change: 1 addition & 0 deletions utils/ktor-client/src/nativeMain/kotlin/KtorIO.native.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package me.him188.ani.utils.ktor

import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.cancel
import io.ktor.utils.io.readAvailable
import kotlinx.coroutines.runBlocking
import kotlinx.io.Buffer
import kotlinx.io.RawSource
Expand Down
6 changes: 6 additions & 0 deletions utils/platform/src/commonMain/kotlin/ktor/KtorCompact.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@file:Suppress("PackageDirectoryMismatch")

package io.ktor.util

@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
annotation class InternalAPI
2 changes: 1 addition & 1 deletion utils/xml/ksoup

0 comments on commit f645bbd

Please sign in to comment.