From bb466ce66ca093c9af6fce4f1e7730f65b513bae Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 31 Dec 2023 13:38:57 +0600 Subject: [PATCH 1/5] start 0.20.24 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 272cdf894ed..e60d92cc8a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.20.24 + ## 0.20.23 * `Versions`: diff --git a/gradle.properties b/gradle.properties index be84a3890cf..d93d99cf483 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,5 +15,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.20.23 -android_code_version=229 +version=0.20.24 +android_code_version=230 From c382423d7704e143d5fcaace4d9318da1062725d Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 31 Dec 2023 13:44:33 +0600 Subject: [PATCH 2/5] upgrade MapperSerializer --- CHANGELOG.md | 4 ++++ .../kotlin/MapperDeserializationStrategy.kt | 9 +++++++-- .../src/commonMain/kotlin/MapperSerializer.kt | 20 ++++++++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e60d92cc8a4..50f48d119e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.20.24 +* `Serialization`: + * `Mapper`: + * `Mapper` pass decoder into callback of deserialization strategy + ## 0.20.23 * `Versions`: diff --git a/serialization/mapper/src/commonMain/kotlin/MapperDeserializationStrategy.kt b/serialization/mapper/src/commonMain/kotlin/MapperDeserializationStrategy.kt index bf36ef9fe4b..7bb4b2690b8 100644 --- a/serialization/mapper/src/commonMain/kotlin/MapperDeserializationStrategy.kt +++ b/serialization/mapper/src/commonMain/kotlin/MapperDeserializationStrategy.kt @@ -16,11 +16,16 @@ import kotlinx.serialization.encoding.Encoder */ open class MapperDeserializationStrategy( private val base: DeserializationStrategy, - private val deserialize: (I) -> O + private val deserialize: (Decoder, I) -> O ) : DeserializationStrategy { override val descriptor: SerialDescriptor = base.descriptor + constructor( + base: DeserializationStrategy, + deserialize: (I) -> O + ) : this(base, { _, i -> deserialize(i) }) + override fun deserialize(decoder: Decoder): O { - return deserialize(base.deserialize(decoder)) + return deserialize(decoder, base.deserialize(decoder)) } } diff --git a/serialization/mapper/src/commonMain/kotlin/MapperSerializer.kt b/serialization/mapper/src/commonMain/kotlin/MapperSerializer.kt index 2df9a1ba334..acc8cbb178a 100644 --- a/serialization/mapper/src/commonMain/kotlin/MapperSerializer.kt +++ b/serialization/mapper/src/commonMain/kotlin/MapperSerializer.kt @@ -1,6 +1,8 @@ package dev.inmo.micro_utils.serialization.mapper +import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.KSerializer +import kotlinx.serialization.SerializationStrategy import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder @@ -16,15 +18,15 @@ import kotlinx.serialization.encoding.Encoder open class MapperSerializer( private val base: KSerializer, private val serialize: (O) -> I, - private val deserialize: (I) -> O -) : KSerializer { + private val deserialize: (Decoder, I) -> O +) : KSerializer, + DeserializationStrategy by MapperDeserializationStrategy(base, deserialize), + SerializationStrategy by MapperSerializationStrategy(base, serialize) { override val descriptor: SerialDescriptor = base.descriptor - override fun deserialize(decoder: Decoder): O { - return deserialize(base.deserialize(decoder)) - } - - override fun serialize(encoder: Encoder, value: O) { - base.serialize(encoder, serialize(value)) - } + constructor( + base: KSerializer, + serialize: (O) -> I, + deserialize: (I) -> O + ) : this(base, serialize, { _, i -> deserialize(i) }) } From 386fa830c3b91bb1681a0c8c59b8d20b9bbe40d5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 09:58:03 +0600 Subject: [PATCH 3/5] update soywiz dependencies and downgrade ksp --- CHANGELOG.md | 5 +++++ gradle/libs.versions.toml | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50f48d119e9..45943fa194d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## 0.20.24 +**Since this version depdendencies of klock and krypto replaced with `com.soywiz.korge:korlibs-time` and `com.soywiz.korge:korlibs-crypto`** + +* `Versions`: + * `Klock` (since now `KorlibsTime`): `4.0.10` -> `5.3.0` + * `Krypto` (since now `KorlibsCrypto`): `4.0.10` -> `5.3.0` * `Serialization`: * `Mapper`: * `Mapper` pass decoder into callback of deserialization strategy diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 586277f9773..d3185e3bfd2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ jb-compose = "1.5.11" jb-exposed = "0.45.0" jb-dokka = "1.9.10" -korlibs = "4.0.10" +korlibs = "5.3.0" uuid = "0.8.2" ktor = "2.3.7" @@ -21,7 +21,7 @@ koin = "3.5.3" okio = "3.7.0" -ksp = "1.9.22-1.0.16" +ksp = "1.9.21-1.0.16" kotlin-poet = "1.15.3" versions = "0.50.0" @@ -72,8 +72,8 @@ ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negoti kslog = { module = "dev.inmo:kslog", version.ref = "kslog" } -klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "korlibs" } -krypto = { module = "com.soywiz.korlibs.krypto:krypto", version.ref = "korlibs" } +klock = { module = "com.soywiz.korge:korlibs-time", version.ref = "korlibs" } +krypto = { module = "com.soywiz.korge:korlibs-crypto", version.ref = "korlibs" } uuid = { module = "com.benasher44:uuid", version.ref = "uuid" } koin = { module = "io.insert-koin:koin-core", version.ref = "koin" } From 759a3f2784dab7bbdaf6ae87b13529191c1c6e87 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 10:24:39 +0600 Subject: [PATCH 4/5] make it possible to use encoder inside of serialize callback --- .../kotlin/MapperSerializationStrategy.kt | 13 ++++++++----- .../src/commonMain/kotlin/MapperSerializer.kt | 14 +++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/serialization/mapper/src/commonMain/kotlin/MapperSerializationStrategy.kt b/serialization/mapper/src/commonMain/kotlin/MapperSerializationStrategy.kt index 4772932915c..e3b5e1a48f8 100644 --- a/serialization/mapper/src/commonMain/kotlin/MapperSerializationStrategy.kt +++ b/serialization/mapper/src/commonMain/kotlin/MapperSerializationStrategy.kt @@ -1,9 +1,7 @@ package dev.inmo.micro_utils.serialization.mapper -import kotlinx.serialization.KSerializer import kotlinx.serialization.SerializationStrategy import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder /** @@ -11,15 +9,20 @@ import kotlinx.serialization.encoding.Encoder * serialization * * @param base Serializer for [I] - * @param serialize Will be used in [serialize] method to convert incoming [O] to [I] and serialize with [base] + * @param internalSerialize Will be used in [internalSerialize] method to convert incoming [O] to [I] and serialize with [base] */ open class MapperSerializationStrategy( private val base: SerializationStrategy, - private val serialize: (O) -> I + private val internalSerialize: (Encoder, O) -> I ) : SerializationStrategy { override val descriptor: SerialDescriptor = base.descriptor + constructor( + base: SerializationStrategy, + serialize: (O) -> I + ) : this(base, { _, o -> serialize(o) }) + override fun serialize(encoder: Encoder, value: O) { - base.serialize(encoder, serialize(value)) + base.serialize(encoder, internalSerialize(encoder, value)) } } diff --git a/serialization/mapper/src/commonMain/kotlin/MapperSerializer.kt b/serialization/mapper/src/commonMain/kotlin/MapperSerializer.kt index acc8cbb178a..08d2ccee903 100644 --- a/serialization/mapper/src/commonMain/kotlin/MapperSerializer.kt +++ b/serialization/mapper/src/commonMain/kotlin/MapperSerializer.kt @@ -17,7 +17,7 @@ import kotlinx.serialization.encoding.Encoder */ open class MapperSerializer( private val base: KSerializer, - private val serialize: (O) -> I, + private val serialize: (Encoder, O) -> I, private val deserialize: (Decoder, I) -> O ) : KSerializer, DeserializationStrategy by MapperDeserializationStrategy(base, deserialize), @@ -28,5 +28,17 @@ open class MapperSerializer( base: KSerializer, serialize: (O) -> I, deserialize: (I) -> O + ) : this(base, { _, o -> serialize(o) }, { _, i -> deserialize(i) }) + + constructor( + base: KSerializer, + serialize: (Encoder, O) -> I, + deserialize: (I) -> O ) : this(base, serialize, { _, i -> deserialize(i) }) + + constructor( + base: KSerializer, + serialize: (O) -> I, + deserialize: (Decoder, I) -> O + ) : this(base, { _, o -> serialize(o) }, deserialize) } From 2eedd196d22b246b763549aca24326e494aa3da0 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 4 Jan 2024 10:25:50 +0600 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45943fa194d..56d200d8902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * `Serialization`: * `Mapper`: * `Mapper` pass decoder into callback of deserialization strategy + * `Mapper` pass encoder into callback of serialization strategy ## 0.20.23