Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- os: windows-latest
cmd: "./gradlew runKmp_xlogDebugExecutableMingwX64"
- os: macos-latest
cmd: "./gradlew :example:shared:jsBrowserDistribution"
cmd: "./gradlew :example:shared:jsBrowserDistribution && ./gradlew :example:shared:wasmJsBrowserDistribution && ./gradlew :example:shared:wasmWasiNodeDevelopmentRun"
runs-on: ${{ matrix.os }}

steps:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pod install
```bash
# run on macOS, with Android NDK android-ndk-r23d-canary,
# https://ci.android.com/builds/branches/aosp-ndk-release-r23/grid
# rename the folder as 23.3.12186248
./scripts/build_xlog_android.sh
# run on macOS
./scripts/build_xlog_apple.sh
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Consts {
const val releaseGroup = "com.piasy"
const val releaseName = "kmp-xlog"
const val releaseVersion = "1.4.3"
const val releaseVersion = "1.5.0"

val androidNS = "$releaseGroup.${releaseName.replace('-', '.')}"
}
20 changes: 17 additions & 3 deletions example/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@file:OptIn(ExperimentalWasmDsl::class)

import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
alias(libs.plugins.kmp)

Expand Down Expand Up @@ -36,9 +40,19 @@ kotlin {
}
}

js(IR) {
browser {
}
js {
browser()
nodejs()
binaries.executable()
}
wasmJs {
browser()
nodejs()
d8()
binaries.executable()
}
wasmWasi {
nodejs()
binaries.executable()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.piasy.kmp.xlog.example

import com.piasy.kmp.xlog.Logging
import com.piasy.kmp.xlog.initializeConsoleLog
import kotlinx.browser.document

class JsPlatform : Platform {
override val name: String = "JS"
override val name: String = "JS"
}

actual fun getPlatform(): Platform = JsPlatform()

fun main() {
initializeConsoleLog(true)
initializeConsoleLog(true)

document.getElementById("text")?.innerHTML = Greeting().greeting()
Logging.info("XXPXX", Greeting().greeting())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.piasy.kmp.xlog.example

import com.piasy.kmp.xlog.Logging
import com.piasy.kmp.xlog.initializeConsoleLog

class WasmJsPlatform : Platform {
override val name: String = "WasmJS"
}

actual fun getPlatform(): Platform = WasmJsPlatform()

fun main() {
initializeConsoleLog(true)

Logging.info("XXPXX", Greeting().greeting())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.piasy.kmp.xlog.example

import com.piasy.kmp.xlog.initializeConsoleLog

class WasmWasiPlatform : Platform {
override val name: String = "WasmWasi"
}

actual fun getPlatform(): Platform = WasmWasiPlatform()

fun main() {
initializeConsoleLog(true)

println(Greeting().greeting())
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>kmp-xlog</title>
</head>
<body>
<h1 id="text"></h1>
<h1 id="text">KMP-XLOG (check console logs)</h1>
<script src="shared.js"></script>
</body>
</html>
27 changes: 14 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
[versions]
iosDeploymentTarget = "14.0"
jvm = "17"
ndk = "21.3.6528147"
compileSdk = "35"
# ndk = "23.3.12186248" # actual canary ndk to support 16KB page size
ndk = "21.3.6528147" # official ndk to pass ci
compileSdk = "36"
minSdk = "21"
targetSdk = "35"
agp = "8.7.3"
kotlin = "2.2.0"
compose = "1.7.8"
targetSdk = "36"
agp = "8.13.0"
kotlin = "2.2.20"
compose = "1.9.2"

[libraries]
kotlin-stdlib-js = { module = "org.jetbrains.kotlin:kotlin-stdlib-js", version.ref = "kotlin" }

androidx-junit = "androidx.test.ext:junit:1.2.1"
androidx-runner = "androidx.test:runner:1.6.2"
androidx-junit = "androidx.test.ext:junit:1.3.0"
androidx-runner = "androidx.test:runner:1.7.0"
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
mockk = "io.mockk:mockk:1.13.16"
mockk = "io.mockk:mockk:1.14.5"

androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
androidx-activity-compose = "androidx.activity:activity-compose:1.10.1"
androidx-activity-compose = "androidx.activity:activity-compose:1.11.0"

[plugins]
android-library = { id = "com.android.library", version.ref = "agp" }
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kmp = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
versions = "com.github.ben-manes.versions:0.51.0"
versionUpdate = "nl.littlerobots.version-catalog-update:0.8.5"
vanniktech-mavenPublish = "com.vanniktech.maven.publish:0.30.0"
versions = "com.github.ben-manes.versions:0.52.0"
versionUpdate = "nl.littlerobots.version-catalog-update:1.0.0"
vanniktech-mavenPublish = "com.vanniktech.maven.publish:0.34.0"
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Nov 16 22:27:43 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
21 changes: 15 additions & 6 deletions kmp-xlog-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import com.vanniktech.maven.publish.SonatypeHost
@file:OptIn(ExperimentalWasmDsl::class)

import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
alias(libs.plugins.kmp)
Expand All @@ -17,10 +19,17 @@ kotlin {
macosArm64()
macosX64()

js(IR) {
browser {
}
binaries.executable()
js {
browser()
nodejs()
}
wasmJs {
browser()
nodejs()
d8()
}
wasmWasi {
nodejs()
}

linuxX64()
Expand All @@ -40,7 +49,7 @@ kotlin {
}

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
publishToMavenCentral()

signAllPublications()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ object Platform {
const val WINDOWS = 4
const val LINUX = 5
const val JS = 6
const val WASM_JS = 7
const val WASM_WASI = 8

private val platform = platform()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.piasy.kmp.xlog

/**
* Created by Piasy{github.com/Piasy} on 2025-09-27.
*/
actual fun platform() = Platform.WASM_JS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.piasy.kmp.xlog

/**
* Created by Piasy{github.com/Piasy} on 2025-09-27.
*/
actual fun platform() = Platform.WASM_WASI
21 changes: 15 additions & 6 deletions kmp-xlog/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import com.vanniktech.maven.publish.SonatypeHost
@file:OptIn(ExperimentalWasmDsl::class)

import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
alias(libs.plugins.kmp)
Expand Down Expand Up @@ -49,10 +51,17 @@ kotlin {
}
}

js(IR) {
browser {
}
binaries.executable()
js {
browser()
nodejs()
}
wasmJs {
browser()
nodejs()
d8()
}
wasmWasi {
nodejs()
}

linuxX64 {
Expand Down Expand Up @@ -249,7 +258,7 @@ android {
}

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
publishToMavenCentral()

signAllPublications()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ package com.piasy.kmp.xlog
* Created by Piasy{github.com/Piasy} on 2022/12/15.
*/
fun initializeConsoleLog(debugLog: Boolean) {
JsLogging.debugLog = debugLog
Logging.init(JsLogging)
WasmWasiLogging.debugLog = debugLog
Logging.init(WasmWasiLogging)
}

private object JsLogging : LoggingImpl {
private object WasmWasiLogging : LoggingImpl {
var debugLog: Boolean = false

override fun debug() = debugLog

override fun debug(tag: String, content: String) {
console.log(tag, content)
println("$tag $content")
}

override fun info(tag: String, content: String) {
console.info(tag, content)
println("$tag $content")
}

override fun error(tag: String, content: String) {
console.error(tag, content)
println("$tag $content")
}
}
35 changes: 35 additions & 0 deletions kmp-xlog/src/webMain/kotlin/com/piasy/kmp/xlog/Logging.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.piasy.kmp.xlog

/**
* Created by Piasy{github.com/Piasy} on 2022/12/15.
*/
fun initializeConsoleLog(debugLog: Boolean) {
WebLogging.debugLog = debugLog
Logging.init(WebLogging)
}

external interface Console {
fun info(vararg data: String)
fun error(vararg data: String)
fun debug(vararg data: String)
}

external val console: Console

private object WebLogging : LoggingImpl {
var debugLog: Boolean = false

override fun debug() = debugLog

override fun debug(tag: String, content: String) {
console.debug(tag, content)
}

override fun info(tag: String, content: String) {
console.info(tag, content)
}

override fun error(tag: String, content: String) {
console.error(tag, content)
}
}
Loading
Loading