diff --git a/settings.gradle.kts b/settings.gradle.kts
index 14e69af74..4cabfe9fb 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -12,24 +12,10 @@
*/
rootProject.name = "simply-robot"
-include(
- ":simbot-util-api-requestor-core",
- ":simbot-util-api-requestor-ktor",
- ":simbot-util-stage-loop",
-)
-
-include(
- ":simbot-util-annotation-tool"
-)
-
-include(
- ":simbot-util-di-api",
- ":simbot-util-di-core",
-)
-
include(":simbot-logger")
include(":simbot-logger-slf4j-impl")
+include(":simbot-annotations")
include(":simbot-api")
include(":simbot-core")
@@ -40,6 +26,22 @@ include(
":simboot-core-spring-boot-starter",
)
+
+include(
+ ":simbot-util-api-requestor-core",
+ ":simbot-util-api-requestor-ktor",
+ ":simbot-util-stage-loop",
+)
+
+include(":simbot-util-annotation-tool")
+
+include(
+ ":simbot-util-di-api",
+ ":simbot-util-di-core",
+)
+
+include(":simbot-util-suspend-transformer")
+
// project test
// if not in CI workflows
if (!System.getenv("IS_CI").toBoolean()) {
@@ -54,25 +56,5 @@ if (!System.getenv("IS_CI").toBoolean()) {
-
-
-@Suppress("NOTHING_TO_INLINE")
-inline fun api(moduleName: String): String = ":simbot-apis:simbot-$moduleName"
-
-@Suppress("NOTHING_TO_INLINE")
-inline fun core(moduleName: String): String = ":simbot-cores:simbot-$moduleName"
-
-@Suppress("NOTHING_TO_INLINE")
-inline fun boot(moduleName: String): String = ":simbot-boots:simboot-$moduleName"
-
@Suppress("NOTHING_TO_INLINE")
inline fun projectTest(moduleName: String): String = ":simbot-project-tests:simbot-project-test-$moduleName"
-
-@Suppress("NOTHING_TO_INLINE")
-inline fun componentHttpServer(moduleName: String): String = ":simbot-components:http-server:simbot-component-http-server-$moduleName"
-
-@Suppress("NOTHING_TO_INLINE")
-inline fun util(moduleName: String): String = ":simbot-utils:simbot-util-$moduleName"
-
-@Suppress("NOTHING_TO_INLINE")
-inline fun utilApiReq(moduleName: String): String = ":simbot-utils:api-requestor:simbot-util-api-requestor-$moduleName"
diff --git a/simbot-annotations/README.md b/simbot-annotations/README.md
new file mode 100644
index 000000000..9fd1932cc
--- /dev/null
+++ b/simbot-annotations/README.md
@@ -0,0 +1,3 @@
+# Module simbot-annotations
+
+部分 simbot 中会使用的基础注解。
diff --git a/simbot-annotations/build.gradle.kts b/simbot-annotations/build.gradle.kts
new file mode 100644
index 000000000..409b71425
--- /dev/null
+++ b/simbot-annotations/build.gradle.kts
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2023 ForteScarlet.
+ *
+ * This file is part of Simple Robot.
+ *
+ * Simple Robot is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Simple Robot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with Simple Robot. If not, see .
+ */
+
+import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
+
+plugins {
+ id("simbot.util-module-conventions")
+ `simbot-multiplatform-maven-publish`
+ id("simbot.dokka-module-configuration")
+}
+
+repositories {
+ mavenCentral()
+}
+
+kotlin {
+ explicitApi()
+
+ jvm {
+ compilations.all {
+ kotlinOptions {
+ jvmTarget = "1.8"
+ javaParameters = true
+ freeCompilerArgs = freeCompilerArgs + listOf("-Xjvm-default=all")
+ }
+ }
+ withJava()
+ testRuns["test"].executionTask.configure {
+ useJUnitPlatform()
+ }
+ }
+
+ js(IR) {
+ browser()
+ nodejs()
+ }
+
+ val mainPresets = mutableSetOf()
+ val testPresets = mutableSetOf()
+
+ targets {
+ presets.filterIsInstance>()
+ .forEach { presets ->
+ val target = fromPreset(presets, presets.name)
+ mainPresets.add(target.compilations["main"].kotlinSourceSets.first())
+ testPresets.add(target.compilations["test"].kotlinSourceSets.first())
+ }
+ }
+
+ sourceSets {
+ val commonMain by getting
+ val commonTest by getting
+
+ val nativeMain by creating {
+ dependsOn(commonMain)
+ }
+ val nativeTest by creating {
+ dependsOn(commonTest)
+ }
+
+ configure(mainPresets) { dependsOn(nativeMain) }
+ configure(testPresets) { dependsOn(nativeTest) }
+
+ }
+
+}
diff --git a/simbot-api/src/main/kotlin/love/forte/simbot/SimbotAnnotations.kt b/simbot-annotations/src/commonMain/kotlin/love/forte/simbot/SimbotAnnotations.kt
similarity index 100%
rename from simbot-api/src/main/kotlin/love/forte/simbot/SimbotAnnotations.kt
rename to simbot-annotations/src/commonMain/kotlin/love/forte/simbot/SimbotAnnotations.kt
diff --git a/simbot-api/build.gradle.kts b/simbot-api/build.gradle.kts
index 7488e0090..606cd68db 100644
--- a/simbot-api/build.gradle.kts
+++ b/simbot-api/build.gradle.kts
@@ -22,6 +22,8 @@ plugins {
dependencies {
api(kotlin("reflect"))
api(project(":simbot-logger"))
+ api(project(":simbot-annotations"))
+ api(project(":simbot-util-suspend-transformer"))
api(libs.kotlinx.coroutines.core)
api(libs.kotlinx.coroutines.jdk8)
diff --git a/simbot-util-stage-loop/build.gradle.kts b/simbot-util-stage-loop/build.gradle.kts
index 5d2c695fe..46ea9c6d4 100644
--- a/simbot-util-stage-loop/build.gradle.kts
+++ b/simbot-util-stage-loop/build.gradle.kts
@@ -61,8 +61,6 @@ kotlin {
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
- implementation(libs.kotlinx.coroutines.core)
- implementation(libs.kotlinx.coroutines.test)
}
}
diff --git a/simbot-util-suspend-transformer/README.md b/simbot-util-suspend-transformer/README.md
new file mode 100644
index 000000000..43984ebf1
--- /dev/null
+++ b/simbot-util-suspend-transformer/README.md
@@ -0,0 +1,5 @@
+# Module simbot-util-suspend-transformer
+
+simbot中独立出来并用于提供各平台兼容 `suspend` 函数的扩展,
+主要用于与编译器插件 [suspend-transform-compiler-plugin](https://github.com/forteScarlet/kotlin-suspend-transform-compiler-plugin)
+配合使用而脱离simbot主要体系(不掺杂过多代码)
diff --git a/simbot-util-suspend-transformer/build.gradle.kts b/simbot-util-suspend-transformer/build.gradle.kts
new file mode 100644
index 000000000..e18715770
--- /dev/null
+++ b/simbot-util-suspend-transformer/build.gradle.kts
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2023 ForteScarlet.
+ *
+ * This file is part of Simple Robot.
+ *
+ * Simple Robot is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Simple Robot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with Simple Robot. If not, see .
+ */
+
+import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
+
+plugins {
+ id("simbot.util-module-conventions")
+ `simbot-multiplatform-maven-publish`
+ id("simbot.dokka-module-configuration")
+}
+
+repositories {
+ mavenCentral()
+}
+
+kotlin {
+ explicitApi()
+
+ jvm {
+ compilations.all {
+ kotlinOptions {
+ jvmTarget = "1.8"
+ javaParameters = true
+ freeCompilerArgs = freeCompilerArgs + listOf("-Xjvm-default=all")
+ }
+ }
+ withJava()
+ testRuns["test"].executionTask.configure {
+ useJUnitPlatform()
+ }
+ }
+
+ js(IR) {
+ browser()
+ nodejs()
+ }
+
+ val mainPresets = mutableSetOf()
+ val testPresets = mutableSetOf()
+
+ targets {
+ presets.filterIsInstance>()
+ .forEach { presets ->
+ val target = fromPreset(presets, presets.name)
+ mainPresets.add(target.compilations["main"].kotlinSourceSets.first())
+ testPresets.add(target.compilations["test"].kotlinSourceSets.first())
+ }
+ }
+
+ sourceSets {
+ val commonMain by getting {
+ dependencies {
+ api(project(":simbot-annotations"))
+ api(project(":simbot-logger"))
+ }
+ }
+
+ val commonTest by getting {
+ dependencies {
+ implementation(kotlin("test"))
+ }
+ }
+
+ getByName("jvmMain") {
+ dependencies {
+ api(libs.kotlinx.coroutines.core)
+ api(libs.kotlinx.coroutines.jdk8)
+ }
+ }
+ getByName("jsMain") {
+ dependencies {
+ api(libs.kotlinx.coroutines.core)
+ }
+ }
+
+ val nativeMain by creating {
+ dependsOn(commonMain)
+ }
+ val nativeTest by creating {
+ dependsOn(commonTest)
+ }
+
+ configure(mainPresets) { dependsOn(nativeMain) }
+ configure(testPresets) { dependsOn(nativeTest) }
+
+ }
+
+}
diff --git a/simbot-api/src/main/kotlin/love/forte/simbot/SuspendTransformAnnotations.kt b/simbot-util-suspend-transformer/src/commonMain/kotlin/love/forte/simbot/SuspendTransformAnnotations.kt
similarity index 73%
rename from simbot-api/src/main/kotlin/love/forte/simbot/SuspendTransformAnnotations.kt
rename to simbot-util-suspend-transformer/src/commonMain/kotlin/love/forte/simbot/SuspendTransformAnnotations.kt
index 4b360235c..33cb27aa8 100644
--- a/simbot-api/src/main/kotlin/love/forte/simbot/SuspendTransformAnnotations.kt
+++ b/simbot-util-suspend-transformer/src/commonMain/kotlin/love/forte/simbot/SuspendTransformAnnotations.kt
@@ -10,15 +10,15 @@
* You should have received a copy of the GNU Lesser General Public License along with Simple Robot. If not, see .
*/
-
+@file:Suppress("KDocUnresolvedReference")
package love.forte.simbot
-import love.forte.plugin.suspendtrans.annotation.JvmAsync
-import love.forte.plugin.suspendtrans.annotation.JvmBlocking
-
/**
- * 用于代表同时标记 [@JvmBlocking][JvmBlocking] 和 [@JvmAsync][JvmAsync] 的整合性注解。
+ * 用于代表一种类似同时标记
+ * [@JvmBlocking][love.forte.plugin.suspendtrans.annotation.JvmBlocking] 和
+ * [@JvmAsync][love.forte.plugin.suspendtrans.annotation.JvmAsync]
+ * 的整合性注解。
*
*/
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
@@ -34,15 +34,19 @@ public annotation class JvmSuspendTrans(
)
/**
- * **J**vm **S**uspend **T**rans
+ * **J**vm **S**uspend **T**rans 的简写类型。
+ *
* @see JvmSuspendTrans
*/
@Suppress("SpellCheckingInspection")
-internal typealias JST = JvmSuspendTrans
+public typealias JST = JvmSuspendTrans
/**
- * 用于代表同时标记 [@JvmBlocking][JvmBlocking] 和 [@JvmAsync][JvmAsync] 的整合性注解。
+ * 用于代表同时标记
+ * [@JvmBlocking][love.forte.plugin.suspendtrans.annotation.JvmBlocking] 和
+ * [@JvmAsync][love.forte.plugin.suspendtrans.annotation.JvmAsync]
+ * 的整合性注解。
*
* [JvmSuspendTransProperty] 默认转化为属性类型,且 blocking 的转化默认没有后缀。
*
@@ -60,8 +64,9 @@ public annotation class JvmSuspendTransProperty(
)
/**
- * **J**vm **S**uspend **T**rans **P**roperty.
+ * **J**vm **S**uspend **T**rans **P**roperty 的简写类型。
+ *
* @see JvmSuspendTransProperty
*/
@Suppress("SpellCheckingInspection")
-internal typealias JSTP = JvmSuspendTransProperty
+public typealias JSTP = JvmSuspendTransProperty
diff --git a/simbot-util-suspend-transformer/src/jsMain/kotlin/love/forte/simbot/utils/PromiseRunner.kt b/simbot-util-suspend-transformer/src/jsMain/kotlin/love/forte/simbot/utils/PromiseRunner.kt
new file mode 100644
index 000000000..1c558b95e
--- /dev/null
+++ b/simbot-util-suspend-transformer/src/jsMain/kotlin/love/forte/simbot/utils/PromiseRunner.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2023 ForteScarlet.
+ *
+ * This file is part of Simple Robot.
+ *
+ * Simple Robot is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Simple Robot is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with Simple Robot. If not, see .
+ */
+
+package love.forte.simbot.utils
+
+import kotlinx.coroutines.CoroutineName
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.promise
+import love.forte.simbot.InternalSimbotApi
+import kotlin.coroutines.CoroutineContext
+import kotlin.coroutines.EmptyCoroutineContext
+import kotlin.js.Promise
+
+@Suppress("unused", "ObjectPropertyName")
+private val `$$DefaultScope`: CoroutineScope by lazy {
+ CoroutineScope(CoroutineName("Default-Promise"))
+}
+
+/**
+ * 执行一个异步函数,得到 [Promise].
+ */
+@InternalSimbotApi
+public fun runInPromise(
+ scope: CoroutineScope,
+ context: CoroutineContext = EmptyCoroutineContext,
+ block: suspend CoroutineScope.() -> T,
+): Promise =
+ scope.promise(context) { block() }
+
+/**
+ * 使用一个内部默认的 [CoroutineScope] 执行一个异步函数,得到 [Promise].
+ */
+@InternalSimbotApi
+public fun runInPromise(
+ context: CoroutineContext = EmptyCoroutineContext,
+ block: suspend CoroutineScope.() -> T,
+): Promise = runInPromise(scope = `$$DefaultScope`, context, block)
diff --git a/simbot-api/src/main/kotlin/love/forte/simbot/utils/BlockingRunner.kt b/simbot-util-suspend-transformer/src/jvmMain/kotlin/love/forte/simbot/utils/BlockingRunner.kt
similarity index 99%
rename from simbot-api/src/main/kotlin/love/forte/simbot/utils/BlockingRunner.kt
rename to simbot-util-suspend-transformer/src/jvmMain/kotlin/love/forte/simbot/utils/BlockingRunner.kt
index 7f16482c6..b2ba114eb 100644
--- a/simbot-api/src/main/kotlin/love/forte/simbot/utils/BlockingRunner.kt
+++ b/simbot-util-suspend-transformer/src/jvmMain/kotlin/love/forte/simbot/utils/BlockingRunner.kt
@@ -77,7 +77,7 @@ private fun createDefaultDispatcher(
* 对 [RejectedExecutionException] 的扩展, 当 [DefaultBlockingDispatcher] 将会在追加任务被拒绝时抛出此异常并携带 [runnable] 和 [executor] 信息供于外部用户捕获并处理.
*/
@Suppress("MemberVisibilityCanBePrivate")
-public open class DefaultBlockingDispatcherTaskRejectedExecutionException(
+public class DefaultBlockingDispatcherTaskRejectedExecutionException(
public val runnable: java.lang.Runnable, public val executor: Executor,
) : RejectedExecutionException("The task $runnable is rejected by default blocking task executor $executor")
@@ -519,7 +519,7 @@ private class SuspendRunner(override val context: CoroutineContext = EmptyCor
}
}
- @Suppress("BlockingMethodInNonBlockingContext")
+// @Suppress("BlockingMethodInNonBlockingContext")
fun await(): Result {
synchronized(this) {
@Suppress("UNUSED_VARIABLE") // emm?
diff --git a/website b/website
index bdb5f48e9..3ea4e1ddc 160000
--- a/website
+++ b/website
@@ -1 +1 @@
-Subproject commit bdb5f48e989656840b2f0190e7c7b32b63022b10
+Subproject commit 3ea4e1ddc77feea822100f98c28870f6cea20a15