From c97528e0bfb644eaebb0f67299bb01b4ff3ba3e6 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Thu, 30 Jun 2022 11:11:01 -0400 Subject: [PATCH] Simple domain module --- android/build.gradle.kts | 1 + .../ca/gosyer/jui/android/AppComponent.kt | 4 +- .../ca/gosyer/jui/android/MainActivity.kt | 2 +- .../data/download/AndroidDownloadService.kt | 8 +- .../android/data/update/UpdateCheckWorker.kt | 2 +- .../ca/gosyer/jui/data/DataComponent.kt | 32 -------- .../ca/gosyer/jui/data/DataComponent.kt | 40 --------- desktop/build.gradle.kts | 1 + .../ca/gosyer/jui/desktop/AppComponent.kt | 4 +- domain/build.gradle.kts | 81 +++++++++++++++++++ domain/src/androidMain/AndroidManifest.xml | 2 + .../ca/gosyer/jui/domain/DomainComponent.kt | 46 +++++++++++ .../ca/gosyer/jui/domain/DomainComponent.kt | 9 +++ .../jui/domain}/base/WebsocketService.kt | 2 +- .../jui/domain}/download/DownloadService.kt | 4 +- .../domain}/library/LibraryUpdateService.kt | 4 +- .../jui/domain/migration/RunMigrations.kt | 7 +- .../jui/domain}/reader/ReaderModeWatch.kt | 4 +- .../jui/domain}/update/UpdateChecker.kt | 5 +- .../ca/gosyer/jui/domain/DomainComponent.kt | 55 +++++++++++++ .../jui/domain}/server/ServerService.kt | 5 +- presentation/build.gradle.kts | 1 + .../ui/downloads/AndroidDownloadService.kt | 4 +- .../jui/ui/downloads/DownloadService.kt | 4 +- .../ui/downloads/DownloadsScreenViewModel.kt | 4 +- .../jui/ui/main/about/AboutViewModel.kt | 4 +- .../ui/main/about/components/AboutContent.kt | 2 +- .../ui/main/components/DownloadsExtraInfo.kt | 2 +- .../jui/ui/manga/MangaScreenViewModel.kt | 2 +- .../jui/ui/reader/ReaderMenuViewModel.kt | 2 +- .../jui/ui/updates/UpdatesScreenViewModel.kt | 2 +- .../ui/downloads/DesktopDownloadService.kt | 4 +- settings.gradle.kts | 1 + 33 files changed, 240 insertions(+), 110 deletions(-) create mode 100644 domain/src/androidMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt create mode 100644 domain/src/commonMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt rename {data/src/commonMain/kotlin/ca/gosyer/jui/data => domain/src/commonMain/kotlin/ca/gosyer/jui/domain}/base/WebsocketService.kt (99%) rename {data/src/commonMain/kotlin/ca/gosyer/jui/data => domain/src/commonMain/kotlin/ca/gosyer/jui/domain}/download/DownloadService.kt (95%) rename {data/src/commonMain/kotlin/ca/gosyer/jui/data => domain/src/commonMain/kotlin/ca/gosyer/jui/domain}/library/LibraryUpdateService.kt (93%) rename data/src/commonMain/kotlin/ca/gosyer/jui/data/migration/Migrations.kt => domain/src/commonMain/kotlin/ca/gosyer/jui/domain/migration/RunMigrations.kt (80%) rename {data/src/commonMain/kotlin/ca/gosyer/jui/data => domain/src/commonMain/kotlin/ca/gosyer/jui/domain}/reader/ReaderModeWatch.kt (95%) rename {data/src/commonMain/kotlin/ca/gosyer/jui/data => domain/src/commonMain/kotlin/ca/gosyer/jui/domain}/update/UpdateChecker.kt (94%) create mode 100644 domain/src/desktopMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt rename {data/src/desktopMain/kotlin/ca/gosyer/jui/data => domain/src/desktopMain/kotlin/ca/gosyer/jui/domain}/server/ServerService.kt (98%) diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 6246deb2..45072d2a 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -14,6 +14,7 @@ dependencies { implementation(projects.core) implementation(projects.i18n) implementation(projects.data) + implementation(projects.domain) implementation(projects.uiCore) implementation(projects.presentation) diff --git a/android/src/main/kotlin/ca/gosyer/jui/android/AppComponent.kt b/android/src/main/kotlin/ca/gosyer/jui/android/AppComponent.kt index a0d7bdba..6c067e60 100644 --- a/android/src/main/kotlin/ca/gosyer/jui/android/AppComponent.kt +++ b/android/src/main/kotlin/ca/gosyer/jui/android/AppComponent.kt @@ -9,7 +9,7 @@ package ca.gosyer.jui.android import android.annotation.SuppressLint import android.content.Context import ca.gosyer.jui.core.di.AppScope -import ca.gosyer.jui.data.DataComponent +import ca.gosyer.jui.domain.DomainComponent import ca.gosyer.jui.ui.base.UiComponent import me.tatarka.inject.annotations.Component import me.tatarka.inject.annotations.Provides @@ -20,7 +20,7 @@ abstract class AppComponent( @get:AppScope @get:Provides val context: Context -) : DataComponent, UiComponent { +) : DomainComponent, UiComponent { abstract val appMigrations: AppMigrations diff --git a/android/src/main/kotlin/ca/gosyer/jui/android/MainActivity.kt b/android/src/main/kotlin/ca/gosyer/jui/android/MainActivity.kt index f47afcef..1e7ec722 100644 --- a/android/src/main/kotlin/ca/gosyer/jui/android/MainActivity.kt +++ b/android/src/main/kotlin/ca/gosyer/jui/android/MainActivity.kt @@ -5,7 +5,7 @@ import androidx.activity.compose.setContent import androidx.appcompat.app.AppCompatActivity import androidx.compose.runtime.CompositionLocalProvider import ca.gosyer.jui.android.data.download.AndroidDownloadService -import ca.gosyer.jui.data.base.WebsocketService.Actions +import ca.gosyer.jui.domain.base.WebsocketService.Actions import ca.gosyer.jui.ui.base.theme.AppTheme import ca.gosyer.jui.ui.main.MainMenu diff --git a/android/src/main/kotlin/ca/gosyer/jui/android/data/download/AndroidDownloadService.kt b/android/src/main/kotlin/ca/gosyer/jui/android/data/download/AndroidDownloadService.kt index ccfb1bf9..8134ac3f 100644 --- a/android/src/main/kotlin/ca/gosyer/jui/android/data/download/AndroidDownloadService.kt +++ b/android/src/main/kotlin/ca/gosyer/jui/android/data/download/AndroidDownloadService.kt @@ -20,13 +20,13 @@ import ca.gosyer.jui.android.util.notificationManager import ca.gosyer.jui.core.lang.chop import ca.gosyer.jui.core.lang.throwIfCancellation import ca.gosyer.jui.core.prefs.getAsFlow -import ca.gosyer.jui.data.base.WebsocketService.Actions -import ca.gosyer.jui.data.base.WebsocketService.Status -import ca.gosyer.jui.data.download.DownloadService -import ca.gosyer.jui.data.download.DownloadService.Companion.status import ca.gosyer.jui.data.download.model.DownloadState import ca.gosyer.jui.data.download.model.DownloadStatus import ca.gosyer.jui.data.server.requests.downloadsQuery +import ca.gosyer.jui.domain.base.WebsocketService.Actions +import ca.gosyer.jui.domain.base.WebsocketService.Status +import ca.gosyer.jui.domain.download.DownloadService +import ca.gosyer.jui.domain.download.DownloadService.Companion.status import ca.gosyer.jui.i18n.MR import dev.icerock.moko.resources.desc.desc import dev.icerock.moko.resources.format diff --git a/android/src/main/kotlin/ca/gosyer/jui/android/data/update/UpdateCheckWorker.kt b/android/src/main/kotlin/ca/gosyer/jui/android/data/update/UpdateCheckWorker.kt index 7c01bb82..321cf677 100644 --- a/android/src/main/kotlin/ca/gosyer/jui/android/data/update/UpdateCheckWorker.kt +++ b/android/src/main/kotlin/ca/gosyer/jui/android/data/update/UpdateCheckWorker.kt @@ -18,7 +18,7 @@ import ca.gosyer.jui.android.AppComponent import ca.gosyer.jui.android.data.notification.Notifications import ca.gosyer.jui.android.util.notificationBuilder import ca.gosyer.jui.android.util.notificationManager -import ca.gosyer.jui.data.update.UpdateChecker.Update +import ca.gosyer.jui.domain.update.UpdateChecker.Update import ca.gosyer.jui.i18n.MR import dev.icerock.moko.resources.desc.desc import kotlinx.coroutines.flow.singleOrNull diff --git a/data/src/androidMain/kotlin/ca/gosyer/jui/data/DataComponent.kt b/data/src/androidMain/kotlin/ca/gosyer/jui/data/DataComponent.kt index 720ba6f5..8a56c4cb 100644 --- a/data/src/androidMain/kotlin/ca/gosyer/jui/data/DataComponent.kt +++ b/data/src/androidMain/kotlin/ca/gosyer/jui/data/DataComponent.kt @@ -9,18 +9,14 @@ package ca.gosyer.jui.data import ca.gosyer.jui.core.di.AppScope import ca.gosyer.jui.core.prefs.PreferenceStoreFactory import ca.gosyer.jui.data.catalog.CatalogPreferences -import ca.gosyer.jui.data.download.DownloadService import ca.gosyer.jui.data.extension.ExtensionPreferences import ca.gosyer.jui.data.library.LibraryPreferences -import ca.gosyer.jui.data.library.LibraryUpdateService import ca.gosyer.jui.data.migration.MigrationPreferences -import ca.gosyer.jui.data.migration.Migrations import ca.gosyer.jui.data.reader.ReaderPreferences import ca.gosyer.jui.data.server.Http import ca.gosyer.jui.data.server.HttpProvider import ca.gosyer.jui.data.server.ServerPreferences import ca.gosyer.jui.data.ui.UiPreferences -import ca.gosyer.jui.data.update.UpdateChecker import ca.gosyer.jui.data.update.UpdatePreferences import me.tatarka.inject.annotations.Provides @@ -29,14 +25,6 @@ actual interface DataComponent { val httpProvider: HttpProvider - val downloadService: DownloadService - - val libraryUpdateService: LibraryUpdateService - - val migrations: Migrations - - val updateChecker: UpdateChecker - val http: Http val serverPreferences: ServerPreferences @@ -102,25 +90,5 @@ actual interface DataComponent { val httpFactory: Http get() = httpProvider.get(serverPreferences) - @get:AppScope - @get:Provides - val libraryUpdateServiceFactory: LibraryUpdateService - get() = LibraryUpdateService(serverPreferences, http) - - @get:AppScope - @get:Provides - val downloadServiceFactory: DownloadService - get() = DownloadService(serverPreferences, http) - - @get:AppScope - @get:Provides - val migrationsFactory: Migrations - get() = Migrations(migrationPreferences, readerPreferences) - - @get:AppScope - @get:Provides - val updateCheckerFactory: UpdateChecker - get() = UpdateChecker(updatePreferences, http) - companion object } diff --git a/data/src/desktopMain/kotlin/ca/gosyer/jui/data/DataComponent.kt b/data/src/desktopMain/kotlin/ca/gosyer/jui/data/DataComponent.kt index 40bcbb99..b636f25a 100644 --- a/data/src/desktopMain/kotlin/ca/gosyer/jui/data/DataComponent.kt +++ b/data/src/desktopMain/kotlin/ca/gosyer/jui/data/DataComponent.kt @@ -9,20 +9,15 @@ package ca.gosyer.jui.data import ca.gosyer.jui.core.di.AppScope import ca.gosyer.jui.core.prefs.PreferenceStoreFactory import ca.gosyer.jui.data.catalog.CatalogPreferences -import ca.gosyer.jui.data.download.DownloadService import ca.gosyer.jui.data.extension.ExtensionPreferences import ca.gosyer.jui.data.library.LibraryPreferences -import ca.gosyer.jui.data.library.LibraryUpdateService import ca.gosyer.jui.data.migration.MigrationPreferences -import ca.gosyer.jui.data.migration.Migrations import ca.gosyer.jui.data.reader.ReaderPreferences import ca.gosyer.jui.data.server.Http import ca.gosyer.jui.data.server.HttpProvider import ca.gosyer.jui.data.server.ServerHostPreferences import ca.gosyer.jui.data.server.ServerPreferences -import ca.gosyer.jui.data.server.ServerService import ca.gosyer.jui.data.ui.UiPreferences -import ca.gosyer.jui.data.update.UpdateChecker import ca.gosyer.jui.data.update.UpdatePreferences import me.tatarka.inject.annotations.Provides @@ -31,16 +26,6 @@ actual interface DataComponent { val httpProvider: HttpProvider - val downloadService: DownloadService - - val libraryUpdateService: LibraryUpdateService - - val migrations: Migrations - - val updateChecker: UpdateChecker - - val serverService: ServerService - val http: Http val serverHostPreferences: ServerHostPreferences @@ -113,30 +98,5 @@ actual interface DataComponent { val httpFactory: Http get() = httpProvider.get(serverPreferences) - @get:AppScope - @get:Provides - val serverServiceFactory: ServerService - get() = ServerService(serverHostPreferences) - - @get:AppScope - @get:Provides - val libraryUpdateServiceFactory: LibraryUpdateService - get() = LibraryUpdateService(serverPreferences, http) - - @get:AppScope - @get:Provides - val downloadServiceFactory: DownloadService - get() = DownloadService(serverPreferences, http) - - @get:AppScope - @get:Provides - val migrationsFactory: Migrations - get() = Migrations(migrationPreferences, readerPreferences) - - @get:AppScope - @get:Provides - val updateCheckerFactory: UpdateChecker - get() = UpdateChecker(updatePreferences, http) - companion object } diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts index 06e6e820..cd334c11 100644 --- a/desktop/build.gradle.kts +++ b/desktop/build.gradle.kts @@ -21,6 +21,7 @@ dependencies { implementation(projects.core) implementation(projects.i18n) implementation(projects.data) + implementation(projects.domain) implementation(projects.uiCore) implementation(projects.presentation) diff --git a/desktop/src/main/kotlin/ca/gosyer/jui/desktop/AppComponent.kt b/desktop/src/main/kotlin/ca/gosyer/jui/desktop/AppComponent.kt index f4690e4e..4cbdc633 100644 --- a/desktop/src/main/kotlin/ca/gosyer/jui/desktop/AppComponent.kt +++ b/desktop/src/main/kotlin/ca/gosyer/jui/desktop/AppComponent.kt @@ -7,14 +7,14 @@ package ca.gosyer.jui.desktop import ca.gosyer.jui.core.di.AppScope -import ca.gosyer.jui.data.DataComponent +import ca.gosyer.jui.domain.DomainComponent import ca.gosyer.jui.ui.base.UiComponent import me.tatarka.inject.annotations.Component import me.tatarka.inject.annotations.Provides @AppScope @Component -abstract class AppComponent : DataComponent, UiComponent { +abstract class AppComponent : DomainComponent, UiComponent { abstract val appMigrations: AppMigrations diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index e69de29b..af2ff88f 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -0,0 +1,81 @@ +@Suppress("DSL_SCOPE_VIOLATION") +plugins { + id(libs.plugins.kotlin.multiplatform.get().pluginId) + id(libs.plugins.kotlin.serialization.get().pluginId) + id(libs.plugins.android.library.get().pluginId) + id(libs.plugins.ksp.get().pluginId) + id(libs.plugins.buildkonfig.get().pluginId) + id(libs.plugins.kotlinter.get().pluginId) +} + +kotlin { + android { + compilations { + all { + kotlinOptions.jvmTarget = Config.androidJvmTarget.toString() + } + } + } + jvm("desktop") { + compilations { + all { + kotlinOptions.jvmTarget = Config.desktopJvmTarget.toString() + } + } + } + + sourceSets { + all { + languageSettings { + optIn("kotlin.RequiresOptIn") + optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + } + } + val commonMain by getting { + dependencies { + api(kotlin("stdlib-common")) + api(libs.coroutines.core) + api(libs.serialization.json) + api(libs.kotlinInject.runtime) + api(libs.ktor.core) + api(libs.ktor.websockets) + api(libs.okio) + api(libs.dateTime) + api(projects.core) + api(projects.i18n) + api(projects.data) + } + } + val commonTest by getting { + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + + val desktopMain by getting { + dependencies { + api(kotlin("stdlib-jdk8")) + } + } + val desktopTest by getting { + } + + val androidMain by getting { + dependencies { + api(kotlin("stdlib-jdk8")) + } + } + val androidTest by getting { + } + } +} + +dependencies { + add("kspDesktop", libs.kotlinInject.compiler) + add("kspAndroid", libs.kotlinInject.compiler) +} + +buildkonfig { + packageName = "ca.gosyer.jui.domain.build" +} diff --git a/domain/src/androidMain/AndroidManifest.xml b/domain/src/androidMain/AndroidManifest.xml index e69de29b..0f0fbb74 100644 --- a/domain/src/androidMain/AndroidManifest.xml +++ b/domain/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/domain/src/androidMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt b/domain/src/androidMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt new file mode 100644 index 00000000..d8d10372 --- /dev/null +++ b/domain/src/androidMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt @@ -0,0 +1,46 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package ca.gosyer.jui.domain + +import ca.gosyer.jui.core.di.AppScope +import ca.gosyer.jui.data.DataComponent +import ca.gosyer.jui.domain.download.DownloadService +import ca.gosyer.jui.domain.library.LibraryUpdateService +import ca.gosyer.jui.domain.migration.RunMigrations +import ca.gosyer.jui.domain.update.UpdateChecker +import me.tatarka.inject.annotations.Provides + +actual interface DomainComponent : DataComponent { + + val downloadService: DownloadService + + val libraryUpdateService: LibraryUpdateService + + val migrations: RunMigrations + + val updateChecker: UpdateChecker + + @get:AppScope + @get:Provides + val libraryUpdateServiceFactory: LibraryUpdateService + get() = LibraryUpdateService(serverPreferences, http) + + @get:AppScope + @get:Provides + val downloadServiceFactory: DownloadService + get() = DownloadService(serverPreferences, http) + + @get:AppScope + @get:Provides + val migrationsFactory: RunMigrations + get() = RunMigrations(migrationPreferences, readerPreferences) + + @get:AppScope + @get:Provides + val updateCheckerFactory: UpdateChecker + get() = UpdateChecker(updatePreferences, http) +} \ No newline at end of file diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt new file mode 100644 index 00000000..6968964d --- /dev/null +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt @@ -0,0 +1,9 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package ca.gosyer.jui.domain + +expect interface DomainComponent \ No newline at end of file diff --git a/data/src/commonMain/kotlin/ca/gosyer/jui/data/base/WebsocketService.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/base/WebsocketService.kt similarity index 99% rename from data/src/commonMain/kotlin/ca/gosyer/jui/data/base/WebsocketService.kt rename to domain/src/commonMain/kotlin/ca/gosyer/jui/domain/base/WebsocketService.kt index bbedd72a..599275cb 100644 --- a/data/src/commonMain/kotlin/ca/gosyer/jui/data/base/WebsocketService.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/base/WebsocketService.kt @@ -4,7 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package ca.gosyer.jui.data.base +package ca.gosyer.jui.domain.base import ca.gosyer.jui.core.lang.throwIfCancellation import ca.gosyer.jui.data.server.Http diff --git a/data/src/commonMain/kotlin/ca/gosyer/jui/data/download/DownloadService.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/download/DownloadService.kt similarity index 95% rename from data/src/commonMain/kotlin/ca/gosyer/jui/data/download/DownloadService.kt rename to domain/src/commonMain/kotlin/ca/gosyer/jui/domain/download/DownloadService.kt index aab5a97f..3101bff3 100644 --- a/data/src/commonMain/kotlin/ca/gosyer/jui/data/download/DownloadService.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/download/DownloadService.kt @@ -4,15 +4,15 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package ca.gosyer.jui.data.download +package ca.gosyer.jui.domain.download -import ca.gosyer.jui.data.base.WebsocketService import ca.gosyer.jui.data.download.model.DownloadChapter import ca.gosyer.jui.data.download.model.DownloadStatus import ca.gosyer.jui.data.download.model.DownloaderStatus import ca.gosyer.jui.data.server.Http import ca.gosyer.jui.data.server.ServerPreferences import ca.gosyer.jui.data.server.requests.downloadsQuery +import ca.gosyer.jui.domain.base.WebsocketService import io.ktor.websocket.Frame import io.ktor.websocket.readText import kotlinx.coroutines.flow.MutableStateFlow diff --git a/data/src/commonMain/kotlin/ca/gosyer/jui/data/library/LibraryUpdateService.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/LibraryUpdateService.kt similarity index 93% rename from data/src/commonMain/kotlin/ca/gosyer/jui/data/library/LibraryUpdateService.kt rename to domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/LibraryUpdateService.kt index 00a66f76..dead6228 100644 --- a/data/src/commonMain/kotlin/ca/gosyer/jui/data/library/LibraryUpdateService.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/library/LibraryUpdateService.kt @@ -4,13 +4,13 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package ca.gosyer.jui.data.library +package ca.gosyer.jui.domain.library -import ca.gosyer.jui.data.base.WebsocketService import ca.gosyer.jui.data.library.model.UpdateStatus import ca.gosyer.jui.data.server.Http import ca.gosyer.jui.data.server.ServerPreferences import ca.gosyer.jui.data.server.requests.updatesQuery +import ca.gosyer.jui.domain.base.WebsocketService import io.ktor.websocket.Frame import io.ktor.websocket.readText import kotlinx.coroutines.flow.MutableStateFlow diff --git a/data/src/commonMain/kotlin/ca/gosyer/jui/data/migration/Migrations.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/migration/RunMigrations.kt similarity index 80% rename from data/src/commonMain/kotlin/ca/gosyer/jui/data/migration/Migrations.kt rename to domain/src/commonMain/kotlin/ca/gosyer/jui/domain/migration/RunMigrations.kt index 3247df92..db8ef134 100644 --- a/data/src/commonMain/kotlin/ca/gosyer/jui/data/migration/Migrations.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/migration/RunMigrations.kt @@ -4,13 +4,14 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package ca.gosyer.jui.data.migration +package ca.gosyer.jui.domain.migration -import ca.gosyer.jui.data.build.BuildKonfig +import ca.gosyer.jui.data.migration.MigrationPreferences import ca.gosyer.jui.data.reader.ReaderPreferences +import ca.gosyer.jui.domain.build.BuildKonfig import me.tatarka.inject.annotations.Inject -class Migrations @Inject constructor( +class RunMigrations @Inject constructor( private val migrationPreferences: MigrationPreferences, private val readerPreferences: ReaderPreferences ) { diff --git a/data/src/commonMain/kotlin/ca/gosyer/jui/data/reader/ReaderModeWatch.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/reader/ReaderModeWatch.kt similarity index 95% rename from data/src/commonMain/kotlin/ca/gosyer/jui/data/reader/ReaderModeWatch.kt rename to domain/src/commonMain/kotlin/ca/gosyer/jui/domain/reader/ReaderModeWatch.kt index a87942e2..1643e3b2 100644 --- a/data/src/commonMain/kotlin/ca/gosyer/jui/data/reader/ReaderModeWatch.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/reader/ReaderModeWatch.kt @@ -4,9 +4,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package ca.gosyer.jui.data.reader +package ca.gosyer.jui.domain.reader import ca.gosyer.jui.core.prefs.getAsFlow +import ca.gosyer.jui.data.reader.ReaderModePreferences +import ca.gosyer.jui.data.reader.ReaderPreferences import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableStateFlow diff --git a/data/src/commonMain/kotlin/ca/gosyer/jui/data/update/UpdateChecker.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/update/UpdateChecker.kt similarity index 94% rename from data/src/commonMain/kotlin/ca/gosyer/jui/data/update/UpdateChecker.kt rename to domain/src/commonMain/kotlin/ca/gosyer/jui/domain/update/UpdateChecker.kt index 3531624b..5e7d9e1f 100644 --- a/data/src/commonMain/kotlin/ca/gosyer/jui/data/update/UpdateChecker.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/update/UpdateChecker.kt @@ -4,12 +4,13 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package ca.gosyer.jui.data.update +package ca.gosyer.jui.domain.update import ca.gosyer.jui.core.lang.IO -import ca.gosyer.jui.data.build.BuildKonfig import ca.gosyer.jui.data.server.Http +import ca.gosyer.jui.data.update.UpdatePreferences import ca.gosyer.jui.data.update.model.GithubRelease +import ca.gosyer.jui.domain.build.BuildKonfig import io.ktor.client.call.body import io.ktor.client.request.get import kotlinx.coroutines.Dispatchers diff --git a/domain/src/desktopMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt b/domain/src/desktopMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt new file mode 100644 index 00000000..35cf5a69 --- /dev/null +++ b/domain/src/desktopMain/kotlin/ca/gosyer/jui/domain/DomainComponent.kt @@ -0,0 +1,55 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package ca.gosyer.jui.domain + +import ca.gosyer.jui.core.di.AppScope +import ca.gosyer.jui.data.DataComponent +import ca.gosyer.jui.domain.download.DownloadService +import ca.gosyer.jui.domain.library.LibraryUpdateService +import ca.gosyer.jui.domain.migration.RunMigrations +import ca.gosyer.jui.domain.server.ServerService +import ca.gosyer.jui.domain.update.UpdateChecker +import me.tatarka.inject.annotations.Provides + +actual interface DomainComponent : DataComponent { + + val downloadService: DownloadService + + val libraryUpdateService: LibraryUpdateService + + val migrations: RunMigrations + + val updateChecker: UpdateChecker + + val serverService: ServerService + + + @get:AppScope + @get:Provides + val serverServiceFactory: ServerService + get() = ServerService(serverHostPreferences) + + @get:AppScope + @get:Provides + val libraryUpdateServiceFactory: LibraryUpdateService + get() = LibraryUpdateService(serverPreferences, http) + + @get:AppScope + @get:Provides + val downloadServiceFactory: DownloadService + get() = DownloadService(serverPreferences, http) + + @get:AppScope + @get:Provides + val migrationsFactory: RunMigrations + get() = RunMigrations(migrationPreferences, readerPreferences) + + @get:AppScope + @get:Provides + val updateCheckerFactory: UpdateChecker + get() = UpdateChecker(updatePreferences, http) +} \ No newline at end of file diff --git a/data/src/desktopMain/kotlin/ca/gosyer/jui/data/server/ServerService.kt b/domain/src/desktopMain/kotlin/ca/gosyer/jui/domain/server/ServerService.kt similarity index 98% rename from data/src/desktopMain/kotlin/ca/gosyer/jui/data/server/ServerService.kt rename to domain/src/desktopMain/kotlin/ca/gosyer/jui/domain/server/ServerService.kt index 9d20604d..3df71ae2 100644 --- a/data/src/desktopMain/kotlin/ca/gosyer/jui/data/server/ServerService.kt +++ b/domain/src/desktopMain/kotlin/ca/gosyer/jui/domain/server/ServerService.kt @@ -4,12 +4,13 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package ca.gosyer.jui.data.server +package ca.gosyer.jui.domain.server import ca.gosyer.jui.core.io.copyTo import ca.gosyer.jui.core.io.userDataDir import ca.gosyer.jui.core.lang.withIOContext -import ca.gosyer.jui.data.build.BuildKonfig +import ca.gosyer.jui.data.server.ServerHostPreferences +import ca.gosyer.jui.domain.build.BuildKonfig import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi diff --git a/presentation/build.gradle.kts b/presentation/build.gradle.kts index 600cb6c2..c83bf7c4 100644 --- a/presentation/build.gradle.kts +++ b/presentation/build.gradle.kts @@ -57,6 +57,7 @@ kotlin { api(projects.core) api(projects.i18n) api(projects.data) + api(projects.domain) api(projects.uiCore) api(compose.desktop.currentOs) api(compose("org.jetbrains.compose.ui:ui-util")) diff --git a/presentation/src/androidMain/kotlin/ca/gosyer/jui/ui/downloads/AndroidDownloadService.kt b/presentation/src/androidMain/kotlin/ca/gosyer/jui/ui/downloads/AndroidDownloadService.kt index 6c34418f..affcc426 100644 --- a/presentation/src/androidMain/kotlin/ca/gosyer/jui/ui/downloads/AndroidDownloadService.kt +++ b/presentation/src/androidMain/kotlin/ca/gosyer/jui/ui/downloads/AndroidDownloadService.kt @@ -8,8 +8,8 @@ package ca.gosyer.jui.ui.downloads import android.content.Intent import androidx.core.content.ContextCompat -import ca.gosyer.jui.data.base.WebsocketService -import ca.gosyer.jui.data.download.DownloadService +import ca.gosyer.jui.domain.base.WebsocketService +import ca.gosyer.jui.domain.download.DownloadService import ca.gosyer.jui.uicore.vm.ContextWrapper internal actual fun startDownloadService( diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadService.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadService.kt index 87ec60ce..de490262 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadService.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadService.kt @@ -6,8 +6,8 @@ package ca.gosyer.jui.ui.downloads -import ca.gosyer.jui.data.base.WebsocketService -import ca.gosyer.jui.data.download.DownloadService +import ca.gosyer.jui.domain.base.WebsocketService +import ca.gosyer.jui.domain.download.DownloadService import ca.gosyer.jui.uicore.vm.ContextWrapper internal expect fun startDownloadService( diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadsScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadsScreenViewModel.kt index 5d163060..ca1ff819 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadsScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadsScreenViewModel.kt @@ -6,11 +6,11 @@ package ca.gosyer.jui.ui.downloads -import ca.gosyer.jui.data.base.WebsocketService.Actions -import ca.gosyer.jui.data.download.DownloadService import ca.gosyer.jui.data.models.Chapter import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler import ca.gosyer.jui.data.server.interactions.DownloadInteractionHandler +import ca.gosyer.jui.domain.base.WebsocketService.Actions +import ca.gosyer.jui.domain.download.DownloadService import ca.gosyer.jui.uicore.vm.ContextWrapper import ca.gosyer.jui.uicore.vm.ViewModel import kotlinx.coroutines.CoroutineScope diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/AboutViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/AboutViewModel.kt index 4458e83b..e2c5b27c 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/AboutViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/AboutViewModel.kt @@ -9,8 +9,8 @@ package ca.gosyer.jui.ui.main.about import ca.gosyer.jui.data.base.DateHandler import ca.gosyer.jui.data.models.About import ca.gosyer.jui.data.server.interactions.SettingsInteractionHandler -import ca.gosyer.jui.data.update.UpdateChecker -import ca.gosyer.jui.data.update.UpdateChecker.Update +import ca.gosyer.jui.domain.update.UpdateChecker +import ca.gosyer.jui.domain.update.UpdateChecker.Update import ca.gosyer.jui.uicore.vm.ContextWrapper import ca.gosyer.jui.uicore.vm.ViewModel import kotlinx.coroutines.flow.MutableSharedFlow diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/components/AboutContent.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/components/AboutContent.kt index 116e0f70..0cd68d45 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/components/AboutContent.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/components/AboutContent.kt @@ -32,7 +32,7 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.unit.dp import androidx.compose.ui.util.fastForEach import ca.gosyer.jui.data.models.About -import ca.gosyer.jui.data.update.UpdateChecker +import ca.gosyer.jui.domain.update.UpdateChecker import ca.gosyer.jui.i18n.MR import ca.gosyer.jui.presentation.build.BuildKonfig import ca.gosyer.jui.ui.base.navigation.Toolbar diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/components/DownloadsExtraInfo.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/components/DownloadsExtraInfo.kt index 00e15532..77a8b450 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/components/DownloadsExtraInfo.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/components/DownloadsExtraInfo.kt @@ -19,8 +19,8 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import ca.gosyer.jui.data.base.WebsocketService import ca.gosyer.jui.data.download.model.DownloaderStatus +import ca.gosyer.jui.domain.base.WebsocketService import ca.gosyer.jui.i18n.MR import ca.gosyer.jui.ui.downloads.DownloadsScreenViewModel import ca.gosyer.jui.uicore.resources.stringResource diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/manga/MangaScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/manga/MangaScreenViewModel.kt index 81ca062f..6a779dcd 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/manga/MangaScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/manga/MangaScreenViewModel.kt @@ -8,7 +8,6 @@ package ca.gosyer.jui.ui.manga import ca.gosyer.jui.core.lang.withIOContext import ca.gosyer.jui.data.base.DateHandler -import ca.gosyer.jui.data.download.DownloadService import ca.gosyer.jui.data.models.Category import ca.gosyer.jui.data.models.Chapter import ca.gosyer.jui.data.models.Manga @@ -17,6 +16,7 @@ import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler import ca.gosyer.jui.data.server.interactions.LibraryInteractionHandler import ca.gosyer.jui.data.server.interactions.MangaInteractionHandler import ca.gosyer.jui.data.ui.UiPreferences +import ca.gosyer.jui.domain.download.DownloadService import ca.gosyer.jui.ui.base.chapter.ChapterDownloadItem import ca.gosyer.jui.uicore.vm.ContextWrapper import ca.gosyer.jui.uicore.vm.ViewModel diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt index 5e95ae99..826e687b 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt @@ -11,11 +11,11 @@ import ca.gosyer.jui.core.prefs.getAsFlow import ca.gosyer.jui.data.models.Chapter import ca.gosyer.jui.data.models.Manga import ca.gosyer.jui.data.models.MangaMeta -import ca.gosyer.jui.data.reader.ReaderModeWatch import ca.gosyer.jui.data.reader.ReaderPreferences import ca.gosyer.jui.data.reader.model.Direction import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler import ca.gosyer.jui.data.server.interactions.MangaInteractionHandler +import ca.gosyer.jui.domain.reader.ReaderModeWatch import ca.gosyer.jui.ui.reader.model.MoveTo import ca.gosyer.jui.ui.reader.model.Navigation import ca.gosyer.jui.ui.reader.model.PageMove diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/updates/UpdatesScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/updates/UpdatesScreenViewModel.kt index 68a06740..c09769d7 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/updates/UpdatesScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/updates/UpdatesScreenViewModel.kt @@ -10,10 +10,10 @@ import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.snapshotFlow import androidx.compose.runtime.snapshots.SnapshotStateList -import ca.gosyer.jui.data.download.DownloadService import ca.gosyer.jui.data.models.Chapter import ca.gosyer.jui.data.server.interactions.ChapterInteractionHandler import ca.gosyer.jui.data.server.interactions.UpdatesInteractionHandler +import ca.gosyer.jui.domain.download.DownloadService import ca.gosyer.jui.ui.base.chapter.ChapterDownloadItem import ca.gosyer.jui.uicore.vm.ContextWrapper import ca.gosyer.jui.uicore.vm.ViewModel diff --git a/presentation/src/desktopMain/kotlin/ca/gosyer/jui/ui/downloads/DesktopDownloadService.kt b/presentation/src/desktopMain/kotlin/ca/gosyer/jui/ui/downloads/DesktopDownloadService.kt index 71bd7f9f..46958e02 100644 --- a/presentation/src/desktopMain/kotlin/ca/gosyer/jui/ui/downloads/DesktopDownloadService.kt +++ b/presentation/src/desktopMain/kotlin/ca/gosyer/jui/ui/downloads/DesktopDownloadService.kt @@ -6,8 +6,8 @@ package ca.gosyer.jui.ui.downloads -import ca.gosyer.jui.data.base.WebsocketService -import ca.gosyer.jui.data.download.DownloadService +import ca.gosyer.jui.domain.base.WebsocketService +import ca.gosyer.jui.domain.download.DownloadService import ca.gosyer.jui.uicore.vm.ContextWrapper internal actual fun startDownloadService( diff --git a/settings.gradle.kts b/settings.gradle.kts index b4252cb9..7d7943c0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,6 +21,7 @@ include("desktop") include("core") include("i18n") include("data") +include("domain") include("ui-core") include("presentation") include("android")