Skip to content

Commit

Permalink
Add support for wasmJs & wasmWasi (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Mar 19, 2024
1 parent e9c81b6 commit 5a03ed4
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 62 deletions.
18 changes: 9 additions & 9 deletions .kotlin-js-store/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ balanced-match@^1.0.0:
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

binary-extensions@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
version "2.3.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522"
integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==

brace-expansion@^1.1.7:
version "1.1.11"
Expand Down Expand Up @@ -151,9 +151,9 @@ emoji-regex@^8.0.0:
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==

escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==
version "3.1.2"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27"
integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==

[email protected]:
version "4.0.0"
Expand Down Expand Up @@ -191,9 +191,9 @@ fs.realpath@^1.0.0:
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==

get-caller-file@^2.0.5:
version "2.0.5"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ dependencies {
[badge-license]: https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat

<!-- TAG_DEPENDENCIES -->
[badge-kotlin]: https://img.shields.io/badge/kotlin-1.9.21-blue.svg?logo=kotlin
[badge-core]: https://img.shields.io/badge/kotlincrypto.core-0.4.0-blue.svg
[badge-hash]: https://img.shields.io/badge/kotlincrypto.hash-0.4.0-blue.svg
[badge-kotlin]: https://img.shields.io/badge/kotlin-1.9.23-blue.svg?logo=kotlin
[badge-core]: https://img.shields.io/badge/kotlincrypto.core-0.5.1-blue.svg
[badge-hash]: https://img.shields.io/badge/kotlincrypto.hash-0.5.1-blue.svg

<!-- TAG_PLATFORMS -->
[badge-platform-android]: http://img.shields.io/badge/-android-6EDB8D.svg?style=flat
Expand Down
26 changes: 24 additions & 2 deletions build-logic/src/main/kotlin/-KmpConfigurationExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import io.matthewnelson.kmp.configuration.extension.KmpConfigurationExtension
import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl
import org.gradle.api.Action
import org.gradle.api.JavaVersion
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

fun KmpConfigurationExtension.configureShared(
publish: Boolean = false,
Expand All @@ -33,8 +34,29 @@ fun KmpConfigurationExtension.configureShared(
}

js()
// wasmJs {}
// wasmWasi {}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
target {
browser {
testTask {
useMocha { timeout = "30s" }
}
}
nodejs {
testTask {
useMocha { timeout = "30s" }
}
}
}
}

@OptIn(ExperimentalWasmDsl::class)
wasmWasi {
target {
nodejs()
}
}

androidNativeAll()

Expand Down
52 changes: 15 additions & 37 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension

plugins {
alias(libs.plugins.multiplatform) apply(false)
alias(libs.plugins.android.library) apply(false)
alias(libs.plugins.binaryCompat)
alias(libs.plugins.gradleVersions)
}

allprojects {
Expand All @@ -47,46 +48,23 @@ plugins.withType<YarnPlugin> {
the<YarnRootExtension>().lockFileDirectory = rootDir.resolve(".kotlin-js-store")
}

apiValidation {
@Suppress("LocalVariableName")
val CHECK_PUBLICATION = findProperty("CHECK_PUBLICATION") as? String
plugins.withType<NodeJsRootPlugin> {
the<NodeJsRootExtension>().apply {
nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}

tasks.withType<KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
}
}

if (CHECK_PUBLICATION != null) {
apiValidation {
if (findProperty("CHECK_PUBLICATION") != null) {
ignoredProjects.add("check-publication")
} else {
nonPublicMarkers.add("org.kotlincrypto.core.InternalKotlinCryptoApi")

ignoredProjects.add("testing")
}
}

fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}

tasks.withType<DependencyUpdatesTask> {
// Example 1: reject all non stable versions
rejectVersionIf {
isNonStable(candidate.version)
}

// Example 2: disallow release candidates as upgradable versions from stable versions
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}

// Example 3: using the full syntax
resolutionStrategy {
componentSelection {
@Suppress("RedundantSamConstructor")
all(Action {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
})
}
}
}
16 changes: 7 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[versions]
android = "8.1.4"
androidxTestRunner = "1.5.2"
binaryCompat = "0.13.2"
binaryCompat = "0.14.0"
bouncyCastle = "1.73"
configuration = "0.1.5"
cryptoCore = "0.4.0"
cryptoHash = "0.4.0"
encoding = "2.1.0"
gradleVersions = "0.50.0"
kotlin = "1.9.21"
publish = "0.25.3"
configuration = "0.2.1"
cryptoCore = "0.5.1"
cryptoHash = "0.5.1"
encoding = "2.2.1"
kotlin = "1.9.23"
publish = "0.27.0"

[libraries]
kotlincrypto-core-digest = { module = "org.kotlincrypto.core:digest", version.ref = "cryptoCore" }
Expand All @@ -32,5 +31,4 @@ encoding-base64 = { module = "io.matthewnelson.encoding:base64", version.ref = "
[plugins]
android-library = { id = "com.android.library", version.ref = "android" }
binaryCompat = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompat" }
gradleVersions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersions" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

# https://gradle.org/release-checksums/
distributionSha256Sum=f2b9ed0faf8472cbe469255ae6c86eddb77076c75191741b4a462f33128dd419
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
distributionSha256Sum=85719317abd2112f021d4f41f09ec370534ba288432065f4b477b6a3b652910d
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip

0 comments on commit 5a03ed4

Please sign in to comment.