Skip to content

Commit

Permalink
3.0.0 (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek-12 committed May 25, 2024
2 parents 1fe10a7 + 0606042 commit 001a2a0
Show file tree
Hide file tree
Showing 86 changed files with 706 additions and 1,731 deletions.
3 changes: 2 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ Powerful DSL allows to hook into store events and amend any store's logic with r

```kotlin
val counterPlugin = lazyPlugin<CounterState, CounterIntent, CounterAction> {

// access the store configuration
if (config.debuggable) config.logger(Debug) { "Store is debuggable" }


onStart { }

onStop { }
Expand All @@ -233,6 +230,9 @@ val counterPlugin = lazyPlugin<CounterState, CounterIntent, CounterAction> {
onUnsubscribe { subs -> }

onException { e -> }

// access the store configuration
if (config.debuggable) config.logger(Debug) { "Store is debuggable" }
}
```

Expand Down
40 changes: 19 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import nl.littlerobots.vcu.plugin.versionCatalogUpdate
import nl.littlerobots.vcu.plugin.versionSelector
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradleSubplugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

private val PluginPrefix = "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination"

plugins {
alias(libs.plugins.detekt)
alias(libs.plugins.gradleDoctor)
Expand All @@ -15,44 +15,42 @@ plugins {
alias(libs.plugins.atomicfu)
alias(libs.plugins.dependencyAnalysis)
alias(libs.plugins.serialization) apply false
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.compose) apply false
// plugins already on a classpath (conventions)
// alias(libs.plugins.androidApplication) apply false
// alias(libs.plugins.androidLibrary) apply false
// alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.compose.compiler) apply false
}

allprojects {
group = Config.artifactId
version = Config.versionName
plugins.withType<ComposeCompilerGradleSubplugin>().configureEach {
the<ComposeCompilerGradlePluginExtension>().apply {
enableIntrinsicRemember = true
enableNonSkippingGroupOptimization = true
enableStrongSkippingMode = true
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_definitions.txt")
if (properties["enableComposeCompilerReports"] == "true") {
val metricsDir = layout.buildDirectory.dir("compose_metrics")
metricsDestination = metricsDir
reportsDestination = metricsDir
}
}
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
optIn.addAll(Config.optIns)
jvmTarget = Config.jvmTarget
languageVersion = Config.kotlinVersion
freeCompilerArgs.apply {
addAll(Config.jvmCompilerArgs)
addAll(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:stabilityConfigurationPath=" +
"${rootProject.rootDir.absolutePath}/stability_definitions.txt",
)
if (project.findProperty("enableComposeCompilerReports") == "true") {
addAll(
"-P",
"$PluginPrefix=${layout.buildDirectory.get()}/compose_metrics",
"-P",
"$PluginPrefix=${layout.buildDirectory.get()}/compose_metrics",
)
}
}
freeCompilerArgs.apply { addAll(Config.jvmCompilerArgs) }
}
}
}

subprojects {
// TODO: Migrate to applying dokka plugin per-project in conventions
if (name in setOf("app", "debugger", "server")) return@subprojects
if (name in setOf("sample", "debugger", "server")) return@subprojects
apply(plugin = rootProject.libs.plugins.dokka.id)

dependencies {
Expand Down
12 changes: 5 additions & 7 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ object Config {

const val artifactId = "$group.$artifact"

const val versionCode = 5
const val majorRelease = 2
const val minorRelease = 5
const val versionCode = 7
const val majorRelease = 3
const val minorRelease = 0
const val patch = 0
const val postfix = "-alpha12" // include dash (-)
const val postfix = "" // include dash (-)
const val majorVersionName = "$majorRelease.$minorRelease.$patch"
const val versionName = "$majorVersionName$postfix"
const val url = "https://github.com/respawn-app/FlowMVI"
const val developerUrl = "https://respawn.pro"
const val licenseFile = "LICENSE.txt"
const val licenseName = "The Apache Software License, Version 2.0"
const val licenseUrl = "https://www.apache.org/licenses/LICENSE-2.0.txt"
Expand Down Expand Up @@ -60,8 +61,6 @@ object Config {
val compilerArgs = listOf(
"-Xbackend-threads=0", // parallel IR compilation
"-Xexpect-actual-classes",
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:experimentalStrongSkipping=true"
)
val jvmCompilerArgs = buildList {
addAll(compilerArgs)
Expand All @@ -74,7 +73,6 @@ object Config {
val jvmTarget = JvmTarget.JVM_11
val idePluginJvmTarget = JvmTarget.JVM_17
val javaVersion = JavaVersion.VERSION_11
val kotlinVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
const val compileSdk = 34
const val targetSdk = compileSdk
const val minSdk = 21
Expand Down
12 changes: 2 additions & 10 deletions buildSrc/src/main/kotlin/ConfigureAndroid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import com.android.build.api.dsl.CommonExtension
import com.android.build.gradle.LibraryExtension
import org.gradle.api.Project

fun Project.configureAndroid(
commonExtension: CommonExtension<*, *, *, *, *, *>,
) = commonExtension.apply {
fun CommonExtension<*, *, *, *, *, *>.configureAndroid() = apply {
compileSdk = Config.compileSdk
val libs by versionCatalog

defaultConfig {
minSdk = Config.minSdk
Expand Down Expand Up @@ -66,15 +63,10 @@ fun Project.configureAndroid(
}
}
}

composeOptions {
kotlinCompilerExtensionVersion = libs.requireVersion("compose-compiler")
useLiveLiterals = true
}
}

fun Project.configureAndroidLibrary(variant: LibraryExtension) = variant.apply {
configureAndroid(this)
configureAndroid()

testFixtures {
enable = true
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/ConfigureMultiplatform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ fun Project.configureMultiplatform(
all {
languageSettings {
progressiveMode = true
languageVersion = Config.kotlinVersion.version
Config.optIns.forEach { optIn(it) }
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/PublishingExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal fun MavenPublication.configurePom() = pom {
id.set(Config.vendorId)
name.set(Config.vendorName)
email.set(Config.supportEmail)
url.set("https://opensource.respawn.pro")
url.set(Config.developerUrl)
organization.set(Config.vendorName)
organizationUrl.set(url)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ android {

kotlinOptions {
jvmTarget = Config.jvmTarget.target
languageVersion = Config.kotlinVersion.version
}
}
7 changes: 6 additions & 1 deletion compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
plugins {
id(libs.plugins.kotlinMultiplatform.id)
id(libs.plugins.androidLibrary.id)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose)
alias(libs.plugins.compose.compiler)
id("maven-publish")
signing
}
Expand Down Expand Up @@ -43,6 +44,10 @@ kotlin {
jvmMain.dependencies {
implementation(compose.desktop.common)
}
androidMain.dependencies {
implementation(compose.preview)
implementation(compose.uiTooling)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package pro.respawn.flowmvi.compose.preview

import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider

/**
* Preview provider that takes a vararg argument for convenience
*/
@Deprecated(
"""
FlowMVI will no longer provide preview functionality as it is platform-dependent and out of scope of the library.
Please copy and paste the code of the provider to your repository if you need it.
""",
ReplaceWith(
"CollectionPreviewParameterProvider<T>(states.asList())",
"androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider",
)
)
public open class StateProvider<T>(vararg states: T) : CollectionPreviewParameterProvider<T>(states.asList())
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import kotlin.jvm.JvmName
@FlowMVIDSL
@JvmName("subscribeConsume")
public fun <S : MVIState, I : MVIIntent, A : MVIAction> ImmutableStore<S, I, A>.subscribe(
lifecycle: SubscriberLifecycle,
lifecycle: SubscriberLifecycle = DefaultLifecycle,
mode: SubscriptionMode = SubscriptionMode.Started,
consume: suspend CoroutineScope.(action: A) -> Unit,
): State<S> {
Expand Down Expand Up @@ -80,7 +80,7 @@ public fun <S : MVIState, I : MVIIntent, A : MVIAction> ImmutableStore<S, I, A>.
@Composable
@FlowMVIDSL
public fun <S : MVIState, I : MVIIntent, A : MVIAction> ImmutableStore<S, I, A>.subscribe(
lifecycle: SubscriberLifecycle,
lifecycle: SubscriberLifecycle = DefaultLifecycle,
mode: SubscriptionMode = SubscriptionMode.Started,
): State<S> {
val state = remember(this) { mutableStateOf(state) }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ public val StoreLogLevel.asLogPriority: Int
StoreLogLevel.Warn -> Log.WARN
StoreLogLevel.Error -> Log.ERROR
}

internal val Int.asStoreLogLevel
get() = when (this) {
Log.VERBOSE -> StoreLogLevel.Trace
Log.DEBUG -> StoreLogLevel.Debug
Log.WARN -> StoreLogLevel.Warn
Log.INFO -> StoreLogLevel.Info
Log.ASSERT, Log.ERROR -> StoreLogLevel.Error
else -> error("Not an android Log level")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package pro.respawn.flowmvi.plugins

import android.util.Log
import pro.respawn.flowmvi.api.FlowMVIDSL
import pro.respawn.flowmvi.api.LazyPlugin
import pro.respawn.flowmvi.api.MVIAction
import pro.respawn.flowmvi.api.MVIIntent
import pro.respawn.flowmvi.api.MVIState
import pro.respawn.flowmvi.dsl.StoreBuilder
import pro.respawn.flowmvi.logging.asStoreLogLevel

/**
* Create a new [loggingPlugin] that prints using android's [Log].
*/
@Deprecated(
"Just use logging plugin",
ReplaceWith("loggingPlugin(tag = tag, level = level)")
)
@FlowMVIDSL
public fun <S : MVIState, I : MVIIntent, A : MVIAction> androidLoggingPlugin(
tag: String? = null,
level: Int? = null,
): LazyPlugin<S, I, A> = loggingPlugin(tag = tag, level = level?.asStoreLogLevel)

/**
* Create a new [loggingPlugin] that prints using android's [Log].
*/
@Deprecated(
"Just use logging plugin",
ReplaceWith("enableLogging(name = name, level = level)")
)
@FlowMVIDSL
public fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.androidLoggingPlugin(
name: String? = null,
level: Int? = null,
): Unit = loggingPlugin<S, I, A>(tag = name, level = level?.asStoreLogLevel).let(::install)
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ public interface ImmutableStore<out S : MVIState, in I : MVIIntent, out A : MVIA
* Subscribe to the store, obtaining a [Provider] to consume [MVIState]s and [MVIAction]s.
* The store itself does not expose actions or states to prevent subscribers from affecting the store and to keep
* track of each subscription.
* When [subscribe] is invoked, a new [StorePlugin.onSubscribe] event is sent to all plugins **and then** the
* subscription count is incremented.
* For more, see [StorePlugin]
* When [subscribe] is invoked, a new [StorePlugin.onSubscribe] event is sent to all plugins with the
* new subscriber count. For more, see [StorePlugin].
*/
public fun CoroutineScope.subscribe(block: suspend Provider<S, I, A>.() -> Unit): Job

Expand Down
Loading

0 comments on commit 001a2a0

Please sign in to comment.