added wasm/js target

This commit is contained in:
2024-08-05 06:42:41 +03:00
parent 68e6ec3e8f
commit b83bec3a54
17 changed files with 141 additions and 18 deletions
@@ -0,0 +1,13 @@
package dev.meloda.overseerr.settings.model
import dev.meloda.overseerr.appDir
import io.github.xxfast.kstore.KStore
import io.github.xxfast.kstore.file.storeOf
import okio.Path.Companion.toPath
actual class SettingsStoreProvider actual constructor() {
actual fun provideStore(): KStore<AppSettings> {
return storeOf(file = "$appDir/app_settings.json".toPath())
}
}
@@ -0,0 +1,11 @@
package dev.meloda.overseerr.settings.model
import dev.meloda.overseerr.appDir
import io.github.xxfast.kstore.KStore
import okio.Path.Companion.toPath
actual class SettingsStoreProvider actual constructor() {
actual fun provideStore(): KStore<AppSettings> {
return storeOf(file = "$appDir/app_settings.json".toPath())
}
}
@@ -1,12 +1,11 @@
package dev.meloda.overseerr.network.di
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import org.koin.dsl.module
val networkModule = module {
single {
HttpClient(CIO) {
HttpClient {
}
}
@@ -3,11 +3,8 @@ package dev.meloda.overseerr.settings
import dev.meloda.overseerr.ext.setValue
import dev.meloda.overseerr.settings.model.AppSettings
import io.github.xxfast.kstore.KStore
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.withContext
interface SettingsController {
val settings: StateFlow<AppSettings>
@@ -22,13 +19,13 @@ class SettingsControllerImpl(
override val settings = MutableStateFlow(AppSettings.EMPTY)
override suspend fun updateAppSettings(update: (AppSettings) -> AppSettings) = withContext(Dispatchers.IO) {
override suspend fun updateAppSettings(update: (AppSettings) -> AppSettings) {
store.set(update(settings.value))
}
override suspend fun loadAppSettings(): AppSettings = withContext(Dispatchers.IO) {
override suspend fun loadAppSettings(): AppSettings {
val loadedSettings = store.get() ?: AppSettings.EMPTY
settings.setValue { loadedSettings }
loadedSettings
return loadedSettings
}
}
@@ -1,18 +1,13 @@
package dev.meloda.overseerr.settings.di
import dev.meloda.overseerr.appDir
import dev.meloda.overseerr.settings.SettingsController
import dev.meloda.overseerr.settings.SettingsControllerImpl
import dev.meloda.overseerr.settings.model.AppSettings
import io.github.xxfast.kstore.file.storeOf
import okio.Path.Companion.toPath
import dev.meloda.overseerr.settings.model.SettingsStoreProvider
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.bind
import org.koin.dsl.module
val settingsModule = module {
single {
storeOf<AppSettings>(file = "$appDir/app_settings.json".toPath())
}
single { SettingsStoreProvider().provideStore() }
singleOf(::SettingsControllerImpl) bind SettingsController::class
}
@@ -0,0 +1,8 @@
package dev.meloda.overseerr.settings.model
import io.github.xxfast.kstore.KStore
expect class SettingsStoreProvider() {
fun provideStore(): KStore<AppSettings>
}
@@ -0,0 +1,12 @@
package dev.meloda.overseerr.settings.model
import dev.meloda.overseerr.appDir
import io.github.xxfast.kstore.KStore
import io.github.xxfast.kstore.file.storeOf
import okio.Path.Companion.toPath
actual class SettingsStoreProvider actual constructor() {
actual fun provideStore(): KStore<AppSettings> {
return storeOf(file = "$appDir/app_settings.json".toPath())
}
}
@@ -0,0 +1,5 @@
package dev.meloda.overseerr.model
actual class Platform actual constructor() {
actual val name: String = "JS"
}
@@ -0,0 +1,8 @@
package dev.meloda.overseerr.settings.model
import io.github.xxfast.kstore.KStore
import io.github.xxfast.kstore.storage.storeOf
actual class SettingsStoreProvider actual constructor() {
actual fun provideStore(): KStore<AppSettings> = storeOf(key = "app_settings")
}
@@ -0,0 +1,7 @@
package dev.meloda.overseerr.theme
import androidx.compose.runtime.Composable
@Composable
internal actual fun SystemAppearance(isDark: Boolean) {
}
+16
View File
@@ -0,0 +1,16 @@
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.ComposeViewport
import dev.meloda.overseerr.App
import dev.meloda.overseerr.di.appModule
import kotlinx.browser.document
import org.koin.core.context.startKoin
@OptIn(ExperimentalComposeUiApi::class)
fun main() {
ComposeViewport(document.body!!) {
startKoin {
modules(appModule)
}
App()
}
}
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>KotlinProject</title>
<link type="text/css" rel="stylesheet" href="styles.css">
<script type="application/javascript" src="composeApp.js"></script>
</head>
<body>
</body>
</html>
@@ -0,0 +1,7 @@
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}