Skip to content

Commit

Permalink
revert default ktor engine
Browse files Browse the repository at this point in the history
  • Loading branch information
qdsfdhvh committed Nov 14, 2023
1 parent b5b32ab commit 81c68ae
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
15 changes: 15 additions & 0 deletions image-loader/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ kotlin {
implementation(compose.ui)
}
}
jvmMain {
dependencies {
implementation(libs.ktor.client.okhttp)
}
}
androidMain {
dependencies {
implementation(libs.kotlinx.coroutines.android)
Expand Down Expand Up @@ -69,6 +74,16 @@ kotlin {
}
}
}
appleMain {
dependencies {
implementation(libs.ktor.client.darwin)
}
}
jsMain {
dependencies {
implementation(libs.ktor.client.js)
}
}
val noJsMain by creating {
dependsOn(commonMain.get())
jvmMain.get().dependsOn(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.seiko.imageloader.util

import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.darwin.Darwin
import okio.FileSystem

actual typealias WeakReference<T> = kotlin.native.ref.WeakReference<T>

internal actual val httpEngine: HttpClientEngine get() = Darwin.create()

internal actual val defaultFileSystem: FileSystem? get() = FileSystem.SYSTEM
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.seiko.imageloader.util

import io.ktor.client.HttpClient
import io.ktor.client.engine.HttpClientEngine
import io.ktor.utils.io.ByteReadChannel
import kotlinx.coroutines.CoroutineDispatcher
import okio.BufferedSource
Expand All @@ -16,7 +17,9 @@ internal expect suspend fun ByteReadChannel.source(): BufferedSource

internal expect val ioDispatcher: CoroutineDispatcher

internal expect val httpEngine: HttpClientEngine

internal expect val defaultFileSystem: FileSystem?

internal val httpEngineFactory: () -> HttpClient
get() = { HttpClient() }
get() = { HttpClient(httpEngine) }
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.seiko.imageloader.util

import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.js.Js
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import okio.FileSystem
Expand Down Expand Up @@ -28,4 +30,6 @@ actual class WeakReference<T : Any> actual constructor(referred: T) {

internal actual val ioDispatcher: CoroutineDispatcher get() = Dispatchers.Default

internal actual val httpEngine: HttpClientEngine get() = Js.create()

internal actual val defaultFileSystem: FileSystem? get() = null
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.seiko.imageloader.util

import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.okhttp.OkHttp
import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.jvm.javaio.toInputStream
import okio.BufferedSource
Expand All @@ -13,6 +15,8 @@ internal actual suspend fun ByteReadChannel.source(): BufferedSource {
return toInputStream().source().buffer()
}

internal actual val httpEngine: HttpClientEngine get() = OkHttp.create()

internal actual val defaultFileSystem: FileSystem? get() = FileSystem.SYSTEM

internal expect fun getMimeTypeFromExtension(extension: String): String?

0 comments on commit 81c68ae

Please sign in to comment.