Skip to content

Commit

Permalink
Merge pull request #66 from copper-leaf/dev
Browse files Browse the repository at this point in the history
4.1.0
  • Loading branch information
cjbrooks12 committed Feb 13, 2024
2 parents 4d63135 + 69a5dd0 commit a2e42cb
Show file tree
Hide file tree
Showing 199 changed files with 18,606 additions and 533 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push_dev.yml
Expand Up @@ -57,6 +57,6 @@ jobs:
distribution: 'temurin'
java-version: 17
- name: 'Assemble Artifacts'
run: './gradlew build --stacktrace'
run: './gradlew build -x orchidBuild --stacktrace'
- name: 'Publish Artifacts to MavenCentral Snapshots Repository'
run: './gradlew publishAllPublicationsToMavenCentralSnapshotsRepository --stacktrace'
4 changes: 2 additions & 2 deletions .github/workflows/push_docs.yml
Expand Up @@ -23,6 +23,6 @@ jobs:
distribution: 'temurin'
java-version: 17
- name: 'Build example Compose Web site'
run: './gradlew :examples:web:build --stacktrace -PreleaseDocs -PorchidEnvironment=prod'
run: './gradlew :examples:web:jsBrowserDevelopmentWebpack :examples:counter:jsBrowserDevelopmentWebpack :examples:navigationWithEnumRoutes:jsBrowserDevelopmentWebpack --stacktrace -PreleaseDocs -PorchidEnvironment=prod'
- name: 'Publish Documentation'
run: './gradlew :docs:publish --stacktrace -PreleaseDocs -PorchidEnvironment=prod'
run: './gradlew :docs:publish --stacktrace --no-configuration-cache -PreleaseDocs -PorchidEnvironment=prod'
2 changes: 1 addition & 1 deletion .github/workflows/push_features.yml
Expand Up @@ -56,7 +56,7 @@ jobs:
distribution: 'temurin'
java-version: 17
- name: 'Assemble Artifacts'
run: './gradlew build --stacktrace'
run: './gradlew -x orchidBuild build --stacktrace'
- name: 'Build IDEA Plugin'
run: './gradlew :ballast-idea-plugin:buildPlugin --stacktrace'
- name: 'Build example Compose Web site'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push_main.yml
Expand Up @@ -66,6 +66,6 @@ jobs:
- name: 'Build example Compose Web site'
run: './gradlew :examples:web:build --stacktrace -Prelease -PorchidEnvironment=prod'
- name: 'Publish Documentation'
run: './gradlew :docs:publish --stacktrace -Prelease -PorchidEnvironment=prod'
run: './gradlew :docs:publish --stacktrace --no-configuration-cache -Prelease -PorchidEnvironment=prod'
- name: 'Close Sonatype Staging Repository'
run: './gradlew closeSonatypeStagingRepository --stacktrace -Prelease -PorchidEnvironment=prod'
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -82,4 +82,4 @@ build/
.DS_Store

examples/web/src/jsMain/resources/bgg/hot/*
docs/src/orchid/resources/assets/example/distributions/**/*
docs/src/orchid/resources/assets/examples/**/*
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,11 @@
## 4.1.0 - 2024-02-12

- Updates to Kotlin 1.9.22
- Adds custom `toString()` implementations for many classes
- `ballast-navigation`: Adds override of `RoutingTable.fromEnum` which accepts `EnumEntries<T>`
- `ballast-navigation`: Adds override of `BallastViewModelConfiguration.Builder.withRouter` which accepts a deepLink URL
- Adds `ballast-schedules` module, for sending Inputs at regularly-scheduled intervals.

## 4.0.0 - 2023-09-05

- Updates to Kotlin 1.9.10
Expand Down
8 changes: 5 additions & 3 deletions README.md
Expand Up @@ -5,7 +5,7 @@

> Opinionated Application State Management framework for Kotlin Multiplatform
![Kotlin Version](https://img.shields.io/badge/Kotlin-1.9.0-orange)
![Kotlin Version](https://img.shields.io/badge/Kotlin-1.9.22-orange)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/copper-leaf/ballast)](https://github.com/copper-leaf/ballast/releases)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.copper-leaf/ballast-core)](https://search.maven.org/artifact/io.github.copper-leaf/ballast-core)
[![Intellij Plugin Version](https://img.shields.io/jetbrains/plugin/v/18702-ballast)](https://plugins.jetbrains.com/plugin/18702-ballast)
Expand Down Expand Up @@ -98,8 +98,9 @@ dependencies {
implementation("io.github.copper-leaf:ballast-repository:{{site.version}}")
implementation("io.github.copper-leaf:ballast-firebase-crashlytics:{{site.version}}")
implementation("io.github.copper-leaf:ballast-firebase-analytics:{{site.version}}")
implementation("io.github.copper-leaf:ballast-debugger:{{site.version}}")
implementation("io.github.copper-leaf:ballast-debugger-client:{{site.version}}")
implementation("io.github.copper-leaf:ballast-navigation:{{site.version}}")
implementation("io.github.copper-leaf:ballast-schedules:{{site.version}}")
testImplementation("io.github.copper-leaf:ballast-test:{{site.version}}")
}

Expand All @@ -113,8 +114,9 @@ kotlin {
implementation("io.github.copper-leaf:ballast-repository:{{site.version}}")
implementation("io.github.copper-leaf:ballast-firebase-crashlytics:{{site.version}}")
implementation("io.github.copper-leaf:ballast-firebase-analytics:{{site.version}}")
implementation("io.github.copper-leaf:ballast-debugger:{{site.version}}")
implementation("io.github.copper-leaf:ballast-debugger-client:{{site.version}}")
implementation("io.github.copper-leaf:ballast-navigation:{{site.version}}")
implementation("io.github.copper-leaf:ballast-schedules:{{site.version}}")
}
}
val commonTest by getting {
Expand Down
20 changes: 20 additions & 0 deletions ballast-api/api/android/ballast-api.api
Expand Up @@ -391,18 +391,21 @@ public final class com/copperleaf/ballast/Queued$HandleInput : com/copperleaf/ba
public fun <init> (Lkotlinx/coroutines/CompletableDeferred;Ljava/lang/Object;)V
public fun getDeferred ()Lkotlinx/coroutines/CompletableDeferred;
public final fun getInput ()Ljava/lang/Object;
public fun toString ()Ljava/lang/String;
}

public final class com/copperleaf/ballast/Queued$RestoreState : com/copperleaf/ballast/Queued {
public fun <init> (Lkotlinx/coroutines/CompletableDeferred;Ljava/lang/Object;)V
public fun getDeferred ()Lkotlinx/coroutines/CompletableDeferred;
public final fun getState ()Ljava/lang/Object;
public fun toString ()Ljava/lang/String;
}

public final class com/copperleaf/ballast/Queued$ShutDownGracefully : com/copperleaf/ballast/Queued {
public synthetic fun <init> (Lkotlinx/coroutines/CompletableDeferred;JLkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getDeferred ()Lkotlinx/coroutines/CompletableDeferred;
public final fun getGracePeriod-UwyO8pc ()J
public fun toString ()Ljava/lang/String;
}

public abstract interface class com/copperleaf/ballast/SideJobScope : kotlinx/coroutines/CoroutineScope {
Expand Down Expand Up @@ -597,6 +600,23 @@ public final class com/copperleaf/ballast/internal/BallastViewModelImpl : com/co
public fun trySend-JP2dKIU (Ljava/lang/Object;)Ljava/lang/Object;
}

public abstract interface class com/copperleaf/ballast/internal/RestartableJob : kotlinx/coroutines/Job {
public abstract fun restart (Ljava/lang/Object;)V
}

public final class com/copperleaf/ballast/internal/RestartableJob$DefaultImpls {
public static synthetic fun cancel (Lcom/copperleaf/ballast/internal/RestartableJob;)V
public static fun fold (Lcom/copperleaf/ballast/internal/RestartableJob;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
public static fun get (Lcom/copperleaf/ballast/internal/RestartableJob;Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext$Element;
public static fun minusKey (Lcom/copperleaf/ballast/internal/RestartableJob;Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext;
public static fun plus (Lcom/copperleaf/ballast/internal/RestartableJob;Lkotlin/coroutines/CoroutineContext;)Lkotlin/coroutines/CoroutineContext;
public static fun plus (Lcom/copperleaf/ballast/internal/RestartableJob;Lkotlinx/coroutines/Job;)Lkotlinx/coroutines/Job;
}

public final class com/copperleaf/ballast/internal/RestartableJobKt {
public static final fun restartableJob (Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function3;)Lcom/copperleaf/ballast/internal/RestartableJob;
}

public abstract interface class com/copperleaf/ballast/internal/Status {
public abstract fun checkCanClear ()V
public abstract fun checkCanShutDown ()V
Expand Down
20 changes: 20 additions & 0 deletions ballast-api/api/jvm/ballast-api.api
Expand Up @@ -391,18 +391,21 @@ public final class com/copperleaf/ballast/Queued$HandleInput : com/copperleaf/ba
public fun <init> (Lkotlinx/coroutines/CompletableDeferred;Ljava/lang/Object;)V
public fun getDeferred ()Lkotlinx/coroutines/CompletableDeferred;
public final fun getInput ()Ljava/lang/Object;
public fun toString ()Ljava/lang/String;
}

public final class com/copperleaf/ballast/Queued$RestoreState : com/copperleaf/ballast/Queued {
public fun <init> (Lkotlinx/coroutines/CompletableDeferred;Ljava/lang/Object;)V
public fun getDeferred ()Lkotlinx/coroutines/CompletableDeferred;
public final fun getState ()Ljava/lang/Object;
public fun toString ()Ljava/lang/String;
}

public final class com/copperleaf/ballast/Queued$ShutDownGracefully : com/copperleaf/ballast/Queued {
public synthetic fun <init> (Lkotlinx/coroutines/CompletableDeferred;JLkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getDeferred ()Lkotlinx/coroutines/CompletableDeferred;
public final fun getGracePeriod-UwyO8pc ()J
public fun toString ()Ljava/lang/String;
}

public abstract interface class com/copperleaf/ballast/SideJobScope : kotlinx/coroutines/CoroutineScope {
Expand Down Expand Up @@ -597,6 +600,23 @@ public final class com/copperleaf/ballast/internal/BallastViewModelImpl : com/co
public fun trySend-JP2dKIU (Ljava/lang/Object;)Ljava/lang/Object;
}

public abstract interface class com/copperleaf/ballast/internal/RestartableJob : kotlinx/coroutines/Job {
public abstract fun restart (Ljava/lang/Object;)V
}

public final class com/copperleaf/ballast/internal/RestartableJob$DefaultImpls {
public static synthetic fun cancel (Lcom/copperleaf/ballast/internal/RestartableJob;)V
public static fun fold (Lcom/copperleaf/ballast/internal/RestartableJob;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
public static fun get (Lcom/copperleaf/ballast/internal/RestartableJob;Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext$Element;
public static fun minusKey (Lcom/copperleaf/ballast/internal/RestartableJob;Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext;
public static fun plus (Lcom/copperleaf/ballast/internal/RestartableJob;Lkotlin/coroutines/CoroutineContext;)Lkotlin/coroutines/CoroutineContext;
public static fun plus (Lcom/copperleaf/ballast/internal/RestartableJob;Lkotlinx/coroutines/Job;)Lkotlinx/coroutines/Job;
}

public final class com/copperleaf/ballast/internal/RestartableJobKt {
public static final fun restartableJob (Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function3;)Lcom/copperleaf/ballast/internal/RestartableJob;
}

public abstract interface class com/copperleaf/ballast/internal/Status {
public abstract fun checkCanClear ()V
public abstract fun checkCanShutDown ()V
Expand Down
18 changes: 15 additions & 3 deletions ballast-api/src/commonMain/kotlin/com/copperleaf/ballast/Queued.kt
Expand Up @@ -19,15 +19,23 @@ public sealed class Queued<Inputs : Any, Events : Any, State : Any> {
public class RestoreState<Inputs : Any, Events : Any, State : Any>(
public override val deferred: CompletableDeferred<Unit>?,
public val state: State,
) : Queued<Inputs, Events, State>()
) : Queued<Inputs, Events, State>() {
override fun toString(): String {
return "RestoreState(state=$state)"
}
}

/**
* A request to handle an Input by sending it to the [InputHandler].
*/
public class HandleInput<Inputs : Any, Events : Any, State : Any>(
public override val deferred: CompletableDeferred<Unit>?,
public val input: Inputs,
) : Queued<Inputs, Events, State>()
) : Queued<Inputs, Events, State>() {
override fun toString(): String {
return "HandleInput(input=$input)"
}
}

/**
* A request to gracefully shut down the ViewModel. This will attempt to let it finish processing any Inputs
Expand All @@ -42,5 +50,9 @@ public sealed class Queued<Inputs : Any, Events : Any, State : Any> {
public class ShutDownGracefully<Inputs : Any, Events : Any, State : Any>(
public override val deferred: CompletableDeferred<Unit>?,
public val gracePeriod: Duration,
) : Queued<Inputs, Events, State>()
) : Queued<Inputs, Events, State>() {
override fun toString(): String {
return "ShutDownGracefully(gracePeriod=$gracePeriod)"
}
}
}
@@ -0,0 +1,26 @@
package com.copperleaf.ballast.internal

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.consumeAsFlow
import kotlinx.coroutines.launch

public interface RestartableJob<T> : Job {
public fun restart(context: T)
}

public fun <T> CoroutineScope.restartableJob(
block: suspend CoroutineScope.(T) -> Unit,
): RestartableJob<T> {
val channel = Channel<T>(Channel.CONFLATED)
val job = launch {
channel.consumeAsFlow().collectLatest { block(it) }
}
return object : RestartableJob<T>, Job by job {
override fun restart(context: T) {
channel.trySend(context)
}
}
}

0 comments on commit a2e42cb

Please sign in to comment.