update dependencies

This commit is contained in:
InsanusMokrassar 2022-01-07 20:06:40 +06:00
parent 9a268b7200
commit 6c58cd393d
4 changed files with 57 additions and 27 deletions

View File

@ -8,8 +8,11 @@ import dev.inmo.postssystem.features.auth.client.ui.AuthUIModel
import dev.inmo.postssystem.features.auth.client.ui.AuthUIViewModel
import dev.inmo.postssystem.features.auth.common.AuthTokenInfo
import dev.inmo.micro_utils.coroutines.ContextSafelyExceptionHandler
import dev.inmo.micro_utils.fsm.common.CheckableHandlerHolder
import dev.inmo.micro_utils.fsm.common.StatesMachine
import dev.inmo.micro_utils.repos.mappers.withMapper
import dev.inmo.micro_utils.serialization.typed_serializer.TypedSerializer
import dev.inmo.postssystem.client.settings.auth.AuthSettings
import kotlinx.browser.document
import kotlinx.browser.localStorage
import kotlinx.coroutines.*
@ -17,8 +20,11 @@ import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.serializer
import org.koin.core.Koin
import org.koin.core.context.loadKoinModules
import org.koin.core.parameter.ParametersHolder
import org.koin.core.qualifier.Qualifier
import org.koin.dsl.module
import org.w3c.dom.HTMLElement
import kotlin.reflect.KClass
val defaultTypedSerializer = TypedSerializer<Any>(
"AuthTokenInfo" to AuthTokenInfo.serializer(),
@ -86,6 +92,49 @@ fun baseKoin(): Koin {
}
)
strictlyOn<AuthUIFSMState>(get<AuthView>())
// Костыль, в JS на момент Пн дек 6 14:19:29 +06 2021 если использовать strictlyOn генерируются
// некорректные безымянные классы (у них отсутствует метод handleState)
class DefaultStateHandlerWrapper<T : UIFSMState>(
private val klass: KClass<out UIFSMHandler<T>>,
private val stateKlass: KClass<T>,
private val qualifier: Qualifier? = null,
private val parameters: ((T) -> ParametersHolder)? = null
) : CheckableHandlerHolder<UIFSMState, UIFSMState> {
override suspend fun StatesMachine<in UIFSMState>.handleState(state: UIFSMState): UIFSMState? {
@Suppress("UNCHECKED_CAST", "NAME_SHADOWING")
val state = state as T
return runCatching {
val authSettings = get<AuthSettings>()
authSettings.loadingJob.join()
if (authSettings.authorizedDIModule.value == null) {
error("Can't perform state $state: Auth module was not initialized")
} else {
get<UIFSMHandler<T>>(klass, qualifier, parameters ?.let { { it(state) } }).run {
handleState(state)
}
}
}.getOrElse { e ->
e.printStackTrace()
AuthUIFSMState(state)
}
}
override suspend fun checkHandleable(state: UIFSMState): Boolean = stateKlass.isInstance(state)
}
inline fun <reified T : UIFSMState> registerHandler(
klass: KClass<out UIFSMHandler<T>>,
qualifier: Qualifier? = null,
parameters: ((T) -> ParametersHolder)? = null
) = add(
DefaultStateHandlerWrapper<T>(
klass,
T::class,
qualifier,
parameters
)
)
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,25 +9,24 @@ android.enableJetifier=true
# Common
kotlin_version=1.5.31
kotlin_serialisation_core_version=1.3.1
kotlin_version=1.6.10
kotlin_serialisation_core_version=1.3.2
koin_version=3.1.2
microutils_version=0.8.7
ktor_version=1.6.5
logback_version=1.2.6
microutils_version=0.9.0
ktor_version=1.6.7
logback_version=1.2.10
uuid_version=0.3.1
klock_version=2.4.8
klock_version=2.4.10
# Server
kotlin_exposed_version=0.36.2
kotlin_exposed_version=0.37.2
psql_version=42.3.0
# JS
kotlinx_html_version=0.7.3
materialDesignLite=1.3.0
# ANDROID
@ -41,7 +40,7 @@ espresso_core=3.3.0
# Dokka
dokka_version=1.5.31
dokka_version=1.6.0
# Project data