{"id":21242284,"url":"https://github.com/fortescarlet/kotlin-suspend-transform-compiler-plugin","last_synced_at":"2026-02-07T16:00:48.703Z","repository":{"id":59492565,"uuid":"535336835","full_name":"ForteScarlet/kotlin-suspend-transform-compiler-plugin","owner":"ForteScarlet","description":"A Kotlin compiler plugin for transforming suspend functions to platform-compatible non-suspend functions, such as the JVM Blocking API and CompletableFuture or JS Promise, etc. ☝️😺👍","archived":false,"fork":false,"pushed_at":"2025-12-17T10:17:23.000Z","size":1742,"stargazers_count":68,"open_issues_count":6,"forks_count":5,"subscribers_count":4,"default_branch":"dev","last_synced_at":"2025-12-20T22:52:09.128Z","etag":null,"topics":["kotlin","kotlin-compiler-plugin","kotlin-coroutines","kotlin-js","kotlin-jvm","kotlin-multiplatform","suspend","suspend-function"],"latest_commit_sha":null,"homepage":"https://kstcp.forte.love/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ForteScarlet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-09-11T15:16:33.000Z","updated_at":"2025-12-19T11:25:52.000Z","dependencies_parsed_at":"2024-01-01T12:24:42.960Z","dependency_job_id":"fe8c7b88-4f0d-4260-997b-ff257383afe6","html_url":"https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin","commit_stats":null,"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"purl":"pkg:github/ForteScarlet/kotlin-suspend-transform-compiler-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2Fkotlin-suspend-transform-compiler-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2Fkotlin-suspend-transform-compiler-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2Fkotlin-suspend-transform-compiler-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2Fkotlin-suspend-transform-compiler-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ForteScarlet","download_url":"https://codeload.github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2Fkotlin-suspend-transform-compiler-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29199519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T14:35:27.868Z","status":"ssl_error","status_checked_at":"2026-02-07T14:25:51.081Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","kotlin-compiler-plugin","kotlin-coroutines","kotlin-js","kotlin-jvm","kotlin-multiplatform","suspend","suspend-function"],"created_at":"2024-11-21T00:58:57.480Z","updated_at":"2026-02-07T16:00:48.696Z","avatar_url":"https://github.com/ForteScarlet.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kotlin suspend transform compiler plugin\n[![Maven Central](https://img.shields.io/maven-central/v/love.forte.plugin.suspend-transform/suspend-transform-plugin)](https://repo1.maven.org/maven2/love/forte/plugin/suspend-transform/suspend-transform-plugin/) \n[![Gradle Plugin Portal](https://img.shields.io/gradle-plugin-portal/v/love.forte.plugin.suspend-transform)](https://plugins.gradle.org/plugin/love.forte.plugin.suspend-transform)\n\n\u003cimg src=\".project/cover.png\" alt=\"cover\"\u003e\n\n[GitHub](https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin) | [Gitee](https://gitee.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin)\n\n**English** | [简体中文](README_CN.md)\n\n## Documentation\n\nThis is the [documentation](https://kstcp.forte.love/).\n\n\u003e [!note]\n\u003e If you notice any issues or omissions in the documentation,\n\u003e feel free to [provide feedback](https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin/issues) anytime!\n\n\n## What's this\n\nThis is a Kotlin compiler plugin for generating platform-compatible functions for suspend functions.\n\n### JVM\n\n```kotlin\nclass Foo {\n    @JvmBlocking\n    @JvmAsync\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    } \n}\n```\n\ncompiled 👇\n\n```kotlin\nclass Foo {\n    // Hide from Java\n    @JvmSynthetic\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    }\n    @Api4J // RequiresOptIn annotation, provide warnings to Kotlin\n    fun waitAndGetBlocking(): String = runInBlocking { waitAndGet() } // 'runInBlocking' from the runtime provided by the plugin\n\n    @Api4J // RequiresOptIn annotation, provide warnings to Kotlin\n    fun waitAndGetAsync(): CompletableFuture\u003cout String\u003e = runInAsync { waitAndGet() } // 'runInAsync' from the runtime provided by the plugin\n}\n```\n\n### JS\n\n```kotlin\nclass Foo {\n    @JsPromise\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    } \n}\n```\n\ncompiled 👇\n\n```kotlin\nclass Foo {\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    }\n    @Api4Js // RequiresOptIn annotation, provide warnings to Kotlin\n    fun waitAndGetAsync(): Promise\u003cString\u003e = runInAsync { waitAndGet() } // 'runInAsync' from the runtime provided by the plugin\n}\n```\n\n\u003e ~~JS platform target not supported yet. see: [KT-53993](https://youtrack.jetbrains.com/issue/KT-53993)~~\n\u003e\n\u003e JS has been supported since 0.6.0! See the process at [KT-53993](https://youtrack.jetbrains.com/issue/KT-53993), and the final winning shot at [#39](https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin/pull/39)!\n\n### WasmJS\n\n\u003e [!warning]\n\u003e Since `v0.6.0`, In experiments, immature and unstable\n\n```kotlin\nclass Foo {\n    @JsPromise\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    } \n}\n\n// Some functions or types customised by **you**...\n// They are not included in the runtime. \n// Since there are a lot of restrictions on the use of various types in WasmJS...\n// so I'm not sure how to handle them perfectly yet.\n// Until then, you can customise functions and types to control the behaviour of the compiler plugin yourself.\n// just like you can customise other platforms.\n\nfun \u003cT\u003e runInAsync(block: suspend () -\u003e T): AsyncResult\u003cT\u003e = AsyncResult(block)\n\nclass AsyncResult\u003cT\u003e(val block: suspend () -\u003e T) {\n    @OptIn(DelicateCoroutinesApi::class)\n    fun toPromise(): Promise\u003cJsAny?\u003e {\n        return GlobalScope.promise { block() }\n    }\n}\n```\n\ncompiled 👇\n\n```kotlin\nclass Foo {\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    }\n    @Api4Js // RequiresOptIn annotation, provide warnings to Kotlin\n    fun waitAndGetAsync(): AsyncResult\u003cString\u003e = runInAsync { waitAndGet() } // 'runInAsync' from the runtime provided by the plugin\n    // AsyncResult is a custom type by **you**\n}\n```\n\n### MarkName\n\n\u003e since v0.13.0, [#96](https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin/pull/96)\n\nYou can use `markName` to add a name mark annotation (e.g. `@JvmName`, `@JsName`) to the generated synthetic function.\n\nFor example the JVM:\n\n```kotlin\nclass Foo {\n    @JvmBlocking(markName = \"namedWaitAndGet\")\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    } \n}\n```\n\ncompiled 👇\n\n```kotlin\nclass Foo {\n    // Hide from Java\n    @JvmSynthetic\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    }\n    @Api4J // RequiresOptIn annotation, provide warnings to Kotlin\n    @JvmName(\"namedWaitAndGet\") // From the `markName`'s value\n    fun waitAndGetBlocking(): String = runInBlocking { waitAndGet() } // 'runInBlocking' from the runtime provided by the plugin\n}\n```\n\nNote: `@JvmName` has limitations on non-final functions, and even the compiler may prevent compilation.\n\nFor example the JS:\n\n```kotlin\nclass Foo {\n    @JsPromise(markName = \"namedWaitAndGet\")\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    } \n}\n```\n\ncompiled 👇\n\n```kotlin\nclass Foo {\n    suspend fun waitAndGet(): String {\n        delay(5)\n        return \"Hello\"\n    }\n  \n    @Api4Js // RequiresOptIn annotation, provide warnings to Kotlin\n    @JsName(\"namedWaitAndGet\") // From the `markName`'s value\n    fun waitAndGetAsync(): Promise\u003cString\u003e = runInAsync { waitAndGet() } // 'runInAsync' from the runtime provided by the plugin\n}\n```\n\n## Use Cases\n\n- [Simple Robot Frameworks](https://github.com/simple-robot/simpler-robot) (Fully customized)\n\n\n## License\n\nsee [LICENSE](LICENSE) .\n\n```text\nCopyright (c) 2022 ForteScarlet\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortescarlet%2Fkotlin-suspend-transform-compiler-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffortescarlet%2Fkotlin-suspend-transform-compiler-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortescarlet%2Fkotlin-suspend-transform-compiler-plugin/lists"}