diff --git a/cache/build.gradle.kts b/cache/build.gradle.kts index 72e43c369..e1aecc671 100644 --- a/cache/build.gradle.kts +++ b/cache/build.gradle.kts @@ -1,16 +1,9 @@ -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl - plugins { id("org.mobilenativefoundation.store.multiplatform") } kotlin { - @OptIn(ExperimentalWasmDsl::class) - wasmJs { - nodejs() - } - sourceSets { val commonMain by getting { dependencies { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index b22c5f5ee..6fdc456a6 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,16 +1,9 @@ -import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl - plugins { id("org.mobilenativefoundation.store.multiplatform") } kotlin { - @OptIn(ExperimentalWasmDsl::class) - wasmJs { - nodejs() - } - sourceSets { val commonMain by getting { dependencies { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d21feac65..f0c7c40f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -47,7 +47,7 @@ kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx- kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" } kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" } kotlinx-coroutines-rx2 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-rx2", version.ref = "kotlinxCoroutines" } -kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version = "0.4.0" } +kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version = "0.6.1" } molecule-gradle-plugin = { module = "app.cash.molecule:molecule-gradle-plugin", version.ref = "moleculeGradlePlugin" } molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "moleculeGradlePlugin" } rxjava = { group = "io.reactivex.rxjava2", name = "rxjava", version = "2.2.21" } @@ -56,7 +56,7 @@ kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-cor junit = { group = "junit", name = "junit", version.ref = "junit" } google-truth = { group = "com.google.truth", name = "truth", version.ref = "truth" } touchlab-kermit = { group = "co.touchlab", name = "kermit", version.ref = "kermit" } -turbine = "app.cash.turbine:turbine:1.0.0" +turbine = "app.cash.turbine:turbine:1.2.0" binary-compatibility-validator = {module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "binary-compatibility-validator"} [plugins] diff --git a/store/api/android/store.api b/store/api/android/store.api index 714f8a6a4..99c14d7fe 100644 --- a/store/api/android/store.api +++ b/store/api/android/store.api @@ -378,7 +378,7 @@ public final class org/mobilenativefoundation/store/store5/StoreReadResponse$NoN } public final class org/mobilenativefoundation/store/store5/StoreReadResponseKt { - public static final fun doThrow (Lorg/mobilenativefoundation/store/store5/StoreReadResponse$Error;)Ljava/lang/Void; + public static final fun doThrow (Lorg/mobilenativefoundation/store/store5/StoreReadResponse$Error;)Ljava/lang/Throwable; } public abstract class org/mobilenativefoundation/store/store5/StoreReadResponseOrigin { diff --git a/store/api/jvm/store.api b/store/api/jvm/store.api index 9d866b708..b992e2c43 100644 --- a/store/api/jvm/store.api +++ b/store/api/jvm/store.api @@ -371,7 +371,7 @@ public final class org/mobilenativefoundation/store/store5/StoreReadResponse$NoN } public final class org/mobilenativefoundation/store/store5/StoreReadResponseKt { - public static final fun doThrow (Lorg/mobilenativefoundation/store/store5/StoreReadResponse$Error;)Ljava/lang/Void; + public static final fun doThrow (Lorg/mobilenativefoundation/store/store5/StoreReadResponse$Error;)Ljava/lang/Throwable; } public abstract class org/mobilenativefoundation/store/store5/StoreReadResponseOrigin { diff --git a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreReadResponse.kt b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreReadResponse.kt index 95453f4c7..edef2ce81 100644 --- a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreReadResponse.kt +++ b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreReadResponse.kt @@ -75,7 +75,7 @@ sealed class StoreReadResponse { fun requireData(): Output { return when (this) { is Data -> value - is Error -> this.doThrow() + is Error -> throw this.doThrow() else -> throw NullPointerException("there is no data in $this") } } @@ -86,7 +86,7 @@ sealed class StoreReadResponse { */ fun throwIfError() { if (this is Error) { - this.doThrow() + throw this.doThrow() } } @@ -165,15 +165,16 @@ sealed class StoreReadResponseOrigin { object Initial : StoreReadResponseOrigin() } -fun StoreReadResponse.Error.doThrow(): Nothing = - when (this) { - is StoreReadResponse.Error.Exception -> throw error - is StoreReadResponse.Error.Message -> throw RuntimeException(message) +fun StoreReadResponse.Error.doThrow(): Throwable { + return when (this) { + is StoreReadResponse.Error.Exception -> error + is StoreReadResponse.Error.Message -> RuntimeException(message) is StoreReadResponse.Error.Custom<*> -> { if (error is Throwable) { - throw error + error } else { - throw RuntimeException("Non-throwable custom error: $error") + RuntimeException("Non-throwable custom error: $error") } } } +} diff --git a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealStoreBuilder.kt b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealStoreBuilder.kt index 7c6528431..88b3d7667 100644 --- a/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealStoreBuilder.kt +++ b/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/RealStoreBuilder.kt @@ -3,6 +3,7 @@ package org.mobilenativefoundation.store.store5.impl import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import org.mobilenativefoundation.store.cache5.Cache import org.mobilenativefoundation.store.cache5.CacheBuilder @@ -19,18 +20,18 @@ import org.mobilenativefoundation.store.store5.Validator fun storeBuilderFromFetcher( fetcher: Fetcher, sourceOfTruth: SourceOfTruth? = null, -): StoreBuilder = RealStoreBuilder(fetcher, sourceOfTruth) +): StoreBuilder = RealStoreBuilder(fetcher, sourceOfTruth) fun storeBuilderFromFetcherAndSourceOfTruth( fetcher: Fetcher, sourceOfTruth: SourceOfTruth, -): StoreBuilder = RealStoreBuilder(fetcher, sourceOfTruth) +): StoreBuilder = RealStoreBuilder(fetcher, sourceOfTruth) fun storeBuilderFromFetcherSourceOfTruthAndMemoryCache( fetcher: Fetcher, sourceOfTruth: SourceOfTruth, memoryCache: Cache, -): StoreBuilder = RealStoreBuilder(fetcher, sourceOfTruth, memoryCache) +): StoreBuilder = RealStoreBuilder(fetcher, sourceOfTruth, memoryCache) fun storeBuilderFromFetcherSourceOfTruthMemoryCacheAndConverter( fetcher: Fetcher, @@ -69,12 +70,13 @@ internal class RealStoreBuilder = - RealStore( + RealStore( scope = scope ?: GlobalScope, sourceOfTruth = sourceOfTruth, fetcher = fetcher, - converter = converter ?: defaultConverter(), + converter = converter ?: DefaultConverter(), validator = validator, memCache = memoryCache ?: cachePolicy?.let { @@ -134,12 +136,10 @@ internal class RealStoreBuilder defaultConverter() = - object : Converter { - override fun fromOutputToLocal(output: Output): Local = - throw IllegalStateException("non mutable store never call this function") +private class DefaultConverter : Converter { + override fun fromOutputToLocal(output: Output): Local = throw IllegalStateException("non mutable store never call this function") - override fun fromNetworkToLocal(network: Network): Local = network as Local - } + override fun fromNetworkToLocal(network: Network): Local = network as Local } diff --git a/tooling/plugins/src/main/kotlin/org/mobilenativefoundation/store/tooling/plugins/KotlinMultiplatformConventionPlugin.kt b/tooling/plugins/src/main/kotlin/org/mobilenativefoundation/store/tooling/plugins/KotlinMultiplatformConventionPlugin.kt index 5e94f04d3..5b5d27e50 100644 --- a/tooling/plugins/src/main/kotlin/org/mobilenativefoundation/store/tooling/plugins/KotlinMultiplatformConventionPlugin.kt +++ b/tooling/plugins/src/main/kotlin/org/mobilenativefoundation/store/tooling/plugins/KotlinMultiplatformConventionPlugin.kt @@ -17,6 +17,7 @@ import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.withType import org.jetbrains.dokka.gradle.DokkaTask +import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget @@ -57,6 +58,11 @@ class KotlinMultiplatformConventionPlugin : Plugin { nodejs() } + @OptIn(ExperimentalWasmDsl::class) + wasmJs { + nodejs() + } + jvmToolchain(11) targets.all {