From a8f1df8b0b3d685e51d6941249655b848925f79b Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Mon, 15 Jan 2024 17:35:06 +0800 Subject: [PATCH] v4.0.0-dev1 --- .changelog/v4.0.0-dev1.md | 0 CHANGELOG.md | 21 +++++++++++++++ build.gradle.kts | 1 + .../kotlin/changelog/GenerateChangelog.kt | 9 +++++++ .../love/forte/simbot/event/EventProcessor.kt | 27 +++++++++++++++++++ .../simbot/suspendrunner/JvmReserveTests.kt | 11 ++++---- 6 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 .changelog/v4.0.0-dev1.md diff --git a/.changelog/v4.0.0-dev1.md b/.changelog/v4.0.0-dev1.md new file mode 100644 index 000000000..e69de29bb diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b50878ec..4719ef03b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +# v4.0.0-dev1 +> [!warning] +> 这是一个尚在开发中的**预览版**,它可能不稳定,可能会频繁变更,且没有可用性保证。 + + +> Release & Pull Notes: [v4.0.0-dev1](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-dev1) + +- feat: Collectable ([`5d145237`](https://github.com/simple-robot/simpler-robot/commit/5d145237)) +- feat: ID、Timestamp and Job link ([`60f8634f`](https://github.com/simple-robot/simpler-robot/commit/60f8634f)) +- feat: Timestamp ([`3db7aa8f`](https://github.com/simple-robot/simpler-robot/commit/3db7aa8f)) +- feat: (WIP) multiplatform ID ([`5eafba6e..1727015e`](https://github.com/simple-robot/simpler-robot/compare/5eafba6e..v3.3.0)) + +
5eafba6e..1727015e + + - [`5eafba6e`](https://github.com/simple-robot/simpler-robot/commit/5eafba6e) + - [`3e0919a2`](https://github.com/simple-robot/simpler-robot/commit/3e0919a2) + - [`1727015e`](https://github.com/simple-robot/simpler-robot/commit/1727015e) + +
+ + # v3.3.0 > Release & Pull Notes: [v3.3.0](https://github.com/simple-robot/simpler-robot/releases/tag/v3.3.0) diff --git a/build.gradle.kts b/build.gradle.kts index d90c5d43e..2dbf45aa0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,6 +29,7 @@ plugins { id("com.github.gmazzo.buildconfig") version "4.1.2" apply false id("io.gitlab.arturbosch.detekt") id("simbot.nexus-publish") + id("simbot.changelog-generator") } setup(P.Simbot) diff --git a/buildSrc/src/main/kotlin/changelog/GenerateChangelog.kt b/buildSrc/src/main/kotlin/changelog/GenerateChangelog.kt index 347d1651d..c949bf610 100644 --- a/buildSrc/src/main/kotlin/changelog/GenerateChangelog.kt +++ b/buildSrc/src/main/kotlin/changelog/GenerateChangelog.kt @@ -160,6 +160,15 @@ fun Project.generateChangelog(tag: String) { FileWriter(rootChangelogFile).buffered().use { writer -> writer.appendLine("# $tag") + if ("-dev" in tag) { + writer.appendLine( + """ + > [!warning] + > 这是一个尚在开发中的**预览版**,它可能不稳定,可能会频繁变更,且没有可用性保证。 + + """.trimIndent() + ) + } writer.appendLine( """ diff --git a/simbot-api/src/commonMain/kotlin/love/forte/simbot/event/EventProcessor.kt b/simbot-api/src/commonMain/kotlin/love/forte/simbot/event/EventProcessor.kt index bc879228e..278a1021a 100644 --- a/simbot-api/src/commonMain/kotlin/love/forte/simbot/event/EventProcessor.kt +++ b/simbot-api/src/commonMain/kotlin/love/forte/simbot/event/EventProcessor.kt @@ -28,6 +28,7 @@ package love.forte.simbot.event import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.flow.* +import kotlinx.coroutines.launch import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.jvm.JvmSynthetic @@ -179,6 +180,32 @@ public interface EventProcessor { } +/** + * 将事件推送并异步处理。 + */ +@JvmSynthetic +public fun EventProcessor.pushAndLaunch( + scope: CoroutineScope, + event: Event, + collector: FlowCollector? = null, +): Job = scope.launch { + with(push(event)) { + if (collector != null) collect(collector) else collect() + } +} + +/** + * 将事件推送并异步处理。 + */ +@JvmSynthetic +public inline fun EventProcessor.pushAndLaunchThen( + scope: CoroutineScope, + event: Event, + crossinline useFlow: (Flow) -> Unit +): Job = scope.launch { + useFlow(push(event)) +} + /** * 将事件推送并收集处理。 */ diff --git a/simbot-commons/simbot-common-suspend-runner/src/jvmTest/kotlin/love/forte/simbot/suspendrunner/JvmReserveTests.kt b/simbot-commons/simbot-common-suspend-runner/src/jvmTest/kotlin/love/forte/simbot/suspendrunner/JvmReserveTests.kt index 773636f4a..de1f88769 100644 --- a/simbot-commons/simbot-common-suspend-runner/src/jvmTest/kotlin/love/forte/simbot/suspendrunner/JvmReserveTests.kt +++ b/simbot-commons/simbot-common-suspend-runner/src/jvmTest/kotlin/love/forte/simbot/suspendrunner/JvmReserveTests.kt @@ -23,14 +23,13 @@ package love.forte.simbot.suspendrunner -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay +import kotlinx.coroutines.test.runTest import love.forte.simbot.annotations.InternalSimbotAPI import love.forte.simbot.suspendrunner.reserve.mono import love.forte.simbot.suspendrunner.reserve.suspendReserve import reactor.test.StepVerifier -import kotlin.coroutines.EmptyCoroutineContext import kotlin.test.Test @@ -40,10 +39,10 @@ import kotlin.test.Test */ class JvmReserveTests { - @OptIn(InternalSimbotAPI::class, DelicateCoroutinesApi::class) + @OptIn(InternalSimbotAPI::class) @Test - fun jvmReserveMonoTest() { - val reserve = suspendReserve(GlobalScope, EmptyCoroutineContext) { run() } + fun jvmReserveMonoTest() = runTest { + val reserve = suspendReserve(this, Dispatchers.Default) { run() } val mono = reserve.transform(mono()) StepVerifier.create(mono)