Skip to content

Commit a22ddf5

Browse files
committed
apply dependency update changes and disable compiler plugin
1 parent 2416259 commit a22ddf5

19 files changed

Lines changed: 138 additions & 17 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
TODO
22
kotlin-js-store/yarn.lock
3+
kotlin-js-store/wasm/yarn.lock
34

45
# Created by https://www.toptal.com/developers/gitignore/api/windows,linux,macos,intellij,intellij+iml,intellij+all,android,androidstudio,maven,gradle,java,kotlin,netbeans,visualstudiocode
56
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,linux,macos,intellij,intellij+iml,intellij+all,android,androidstudio,maven,gradle,java,kotlin,netbeans,visualstudiocode

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies {
3030
dokka(project(":core"))
3131
dokka(project(":compose"))
3232
dokka(project(":gradle-plugin"))
33-
dokka(project(":compiler-plugin"))
33+
// dokka(project(":compiler-plugin"))
3434
}
3535

3636
// Force new atomicfu version, compose uses 0.23.2

core/build.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ kotlin {
3535
publishAllLibraryVariants()
3636
}
3737

38-
/*androidNativeX64()
38+
androidNativeX64()
3939
androidNativeX86()
4040
androidNativeArm64()
41-
androidNativeArm32()*/
41+
androidNativeArm32()
4242

4343
jvm()
4444
jvmToolchain(21)
@@ -157,7 +157,7 @@ kotlin {
157157
}
158158

159159
linuxX64()
160-
// linuxArm64()
160+
linuxArm64()
161161

162162
mingwX64()
163163

@@ -201,6 +201,10 @@ kotlin {
201201
implementation(libs.coroutines.android)
202202
}
203203

204+
androidNativeMain.dependencies {
205+
implementation(libs.ktor.cio)
206+
}
207+
204208
jvmMain.dependencies {
205209
implementation(libs.ktor.java)
206210
}

core/src/androidMain/kotlin/io/tolgee/common/ExtendParser.android.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import android.os.Build
44
import io.tolgee.format.Sprintf
55
import dev.datlag.tooling.async.scopeCatching
66
import kotlinx.collections.immutable.toImmutableList
7-
import kotlinx.datetime.Instant
87
import java.time.ZoneId
98
import java.time.ZonedDateTime
109
import java.util.*
10+
import kotlin.time.ExperimentalTime
11+
import kotlin.time.Instant
1112

1213
/**
1314
* Converts the current object to an instance of [Instant]. This function handles various
@@ -17,6 +18,7 @@ import java.util.*
1718
* @return The corresponding [Instant] for the current object.
1819
* @throws IllegalArgumentException If the object type is not supported or cannot be converted.
1920
*/
21+
@OptIn(ExperimentalTime::class)
2022
internal actual fun Any.convertToInstant(): Instant = when (this) {
2123
is Date -> Instant.fromEpochMilliseconds(this.time)
2224
else -> {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.tolgee.common
2+
3+
import io.tolgee.format.Sprintf
4+
import kotlinx.collections.immutable.toImmutableList
5+
import kotlin.time.ExperimentalTime
6+
import kotlin.time.Instant
7+
8+
/**
9+
* Converts the given object to an instance of Instant.
10+
*
11+
* @return The converted Instant value from the given object.
12+
* @throws IllegalArgumentException if the object cannot be converted to an Instant.
13+
*/
14+
@OptIn(markerClass = [ExperimentalTime::class])
15+
internal actual fun Any.convertToInstant(): Instant {
16+
throw IllegalArgumentException("Can not convert to LocalDateTime: $this")
17+
}
18+
19+
/**
20+
* Formats the string using the specified arguments, similar to the C `sprintf` function.
21+
*
22+
* This function replaces placeholders in the string with the provided arguments, applying formatting rules
23+
* defined within the string.
24+
*
25+
* @param args The arguments to be substituted into the format string.
26+
* @return The formatted string with placeholders replaced by the provided arguments.
27+
*/
28+
internal actual fun String.sprintf(vararg args: Any): String = Sprintf(this, args.toImmutableList()).process().toString()
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package io.tolgee.common
2+
3+
import io.ktor.client.HttpClient
4+
import io.ktor.client.engine.cio.CIO
5+
import io.ktor.client.plugins.cache.HttpCache
6+
import io.tolgee.Tolgee
7+
import io.tolgee.storage.TolgeeStorageProvider
8+
import kotlinx.coroutines.Dispatchers
9+
import kotlinx.coroutines.IO
10+
import kotlin.coroutines.CoroutineContext
11+
12+
/**
13+
* Creates a platform-specific instance of Tolgee with the given configuration.
14+
*
15+
* @param config The configuration object used to initialize the Tolgee instance.
16+
* @return A platform-specific instance of Tolgee initialized with the provided configuration.
17+
*/
18+
internal actual fun createPlatformTolgee(config: Tolgee.Config): PlatformTolgee {
19+
return PlatformTolgee(config)
20+
}
21+
22+
/**
23+
* Represents the platform-specific `HttpClient` instance configured for use with CIO engine.
24+
*
25+
* This HTTP client is pre-configured to:
26+
* - Follow HTTP redirects automatically.
27+
* - Utilize HTTP caching via the `HttpCache` plugin.
28+
*
29+
* It is intended for internal use within the platform-specific functionality and should
30+
* be utilized where consistent HTTP client behavior is required across the platform.
31+
*/
32+
internal actual val platformHttpClient: HttpClient = HttpClient(CIO) {
33+
followRedirects = true
34+
install(HttpCache)
35+
}
36+
37+
/**
38+
* Represents the platform-specific CoroutineContext used for network operations.
39+
*
40+
* This context defaults to `Dispatchers.IO` and is utilized for performing network requests
41+
* efficiently, offloading these operations from the main thread.
42+
*
43+
* It is particularly useful in configurations where network functionalities are required,
44+
* such as the `Network` class or its `Builder`, to ensure operations are executed in an optimized, non-blocking environment.
45+
*/
46+
internal actual val platformNetworkContext: CoroutineContext
47+
get() = Dispatchers.IO
48+
49+
internal actual val platformStorage: TolgeeStorageProvider?
50+
get() = null
51+
52+
/**
53+
* An actual implementation of the `Tolgee` class for a specific platform.
54+
* This class is used to handle platform-specific operations and configurations
55+
* related to the Tolgee localization framework.
56+
*
57+
* @constructor Initializes the platform-specific instance of `PlatformTolgee`.
58+
* @property config The configuration object that contains settings and options
59+
* necessary for the operation of the `Tolgee` framework.
60+
*/
61+
@ConsistentCopyVisibility
62+
actual data class PlatformTolgee internal constructor(override val config: Config): Tolgee(config)

core/src/appleMain/kotlin/io/tolgee/common/ExtendParser.apple.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package io.tolgee.common
22

33
import io.tolgee.format.Sprintf
44
import kotlinx.collections.immutable.toImmutableList
5-
import kotlinx.datetime.Instant
65
import kotlinx.datetime.toKotlinInstant
76
import platform.Foundation.NSDate
7+
import kotlin.time.ExperimentalTime
8+
import kotlin.time.Instant
89

910
/**
1011
* Converts the given object to an instance of Instant.
1112
*
1213
* @return The converted Instant value if the object is of a supported type, otherwise throws an IllegalArgumentException.
1314
*/
15+
@OptIn(ExperimentalTime::class)
1416
internal actual fun Any.convertToInstant(): Instant = when (this) {
1517
is NSDate -> toKotlinInstant()
1618
else -> throw IllegalArgumentException("Can not convert to LocalDateTime: $this")

core/src/commonMain/kotlin/io/tolgee/common/ExtendParser.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package io.tolgee.common
22

33
import io.tolgee.model.TolgeeKey
4-
import kotlinx.datetime.Instant
54
import kotlinx.serialization.json.*
5+
import kotlin.time.ExperimentalTime
6+
import kotlin.time.Instant
67

78
/**
89
* Converts a [JsonElement] to its string representation.
@@ -29,6 +30,7 @@ internal fun JsonElement.keyData(): TolgeeKey.Data = when (this) {
2930
*
3031
* @return The converted Instant value from the given object.
3132
*/
33+
@OptIn(ExperimentalTime::class)
3234
internal expect fun Any.convertToInstant(): Instant
3335

3436
/**

core/src/commonMain/kotlin/io/tolgee/format/Specification.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import kotlinx.datetime.number
77
import kotlinx.datetime.offsetAt
88
import kotlinx.datetime.toInstant
99
import kotlinx.serialization.Serializable
10+
import kotlin.time.ExperimentalTime
1011

1112
/**
1213
* Mostly copied from https://github.com/sergeych/mp_stools
@@ -231,6 +232,7 @@ internal data class Specification(
231232
insertField(parent.getCharacter(index).toString())
232233
}
233234

235+
@OptIn(ExperimentalTime::class)
234236
private fun createTimeField(upperCase: Boolean) {
235237
val ch = parent.nextChar()
236238
endStage()

core/src/commonMain/kotlin/io/tolgee/format/Sprintf.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package io.tolgee.format
22

33
import io.tolgee.common.convertToInstant
44
import kotlinx.collections.immutable.ImmutableList
5-
import kotlinx.datetime.Instant
65
import kotlinx.datetime.LocalDate
76
import kotlinx.datetime.LocalDateTime
87
import kotlinx.datetime.TimeZone
98
import kotlinx.datetime.atTime
109
import kotlinx.datetime.toLocalDateTime
10+
import kotlin.time.ExperimentalTime
11+
import kotlin.time.Instant
1112

1213
/**
1314
* Mostly copied from https://github.com/sergeych/mp_stools
@@ -76,6 +77,7 @@ internal data class Sprintf(
7677
return notNullArg(index)
7778
}
7879

80+
@OptIn(ExperimentalTime::class)
7981
internal fun getLocalDateTime(index: Int): LocalDateTime {
8082
return when (val t = notNullArg<Any>(index)) {
8183
is Instant -> t.toLocalDateTime(TimeZone.currentSystemDefault())

0 commit comments

Comments
 (0)