Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8825f5d
Add wasmJs target (not working)
luca992 May 27, 2024
50c6982
up to kotlin 2.1.21
Tetraquark Jun 4, 2025
83b2437
setup wasmjs target
Tetraquark Jun 5, 2025
bd4b70e
Merge remote-tracking branch 'origin-2/wasmJs' into target-wasmjs
Tetraquark Jun 5, 2025
72807de
support of wasm-js in resources, resources-generator
Tetraquark Jun 9, 2025
392e5cf
add wasm-js target in compose-resources-gallery sample
Tetraquark Jun 9, 2025
bbdba0b
move wasmjs sample from resources-gallery to compose-resources-gallery
Tetraquark Jun 9, 2025
7716c00
cleanup, fix checks
Tetraquark Jun 9, 2025
25baa04
checks fix
Tetraquark Jun 9, 2025
1438da0
checks fix
Tetraquark Jun 9, 2025
1d99309
checks fix
Tetraquark Jun 9, 2025
1d99f0e
#582 remove code duplication from generator
Alex009 Jun 16, 2025
f99683d
#582 remove duplication from runtime
Alex009 Jun 16, 2025
05fb285
set kotlin version 1.9.25, fix detekt and checks
Tetraquark Jun 24, 2025
685493f
toJsonElement functions impl for js and wasmjs
Tetraquark Jun 25, 2025
934a2d1
review fixes
Tetraquark Jun 26, 2025
6334ba0
some cleanup, review fixes
Tetraquark Jun 26, 2025
8d28c66
Replace `klib.extractingToTemp` with cloned `ExtractingKotlinLibraryL…
zacharee Jun 28, 2025
1efd4b7
Use proper Extracting class
zacharee Jun 28, 2025
1b06f27
Use ExtractingBaseLibraryImpl in `compose-resources-gallery`
zacharee Jun 28, 2025
80aef33
Replace `javaFile()` extension call with File constructor
zacharee Jun 28, 2025
bdfdded
#582 commonization of compose and test modules for js
Alex009 Jun 29, 2025
378f409
#582 fix inferred type is ByteArray but Nothing? was expected
Alex009 Jun 29, 2025
d2b8624
Make some extension functions private
zacharee Jun 29, 2025
3774d4f
Update `kotlin-2-sample` to use Kotlin 2.2.0
zacharee Jun 29, 2025
33e1eb2
Fix comment line length
zacharee Jun 29, 2025
afec74a
Update `kotlin-2-dynamic-sample` to use Kotlin 2.2.0
zacharee Jun 29, 2025
a59967d
Prioritize `mavenLocal()` repo in Kotlin 2 samples
zacharee Jun 29, 2025
59ce226
Merge pull request #822 from Tetraquark/target-wasmjs
Alex009 Jun 29, 2025
1b3bf3e
Merge branch 'develop' into extractingToTemp-fix
Alex009 Jun 29, 2025
d1ebefb
#827 fix apple executables run from gradle
Alex009 Jun 29, 2025
e68e8e3
#558 composite builds support
Alex009 Jun 29, 2025
79e3fa2
Merge pull request #829 from zacharee/extractingToTemp-fix
Alex009 Jun 29, 2025
6fef3b3
update readme
Alex009 Jun 29, 2025
cc4b372
Merge pull request #830 from icerockdev/#558-support-composite-builds
Alex009 Jun 29, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ local.properties
local.gradle
moko-resources-generated.js
.fleet
.kotlin
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
![badge][badge-macosX64]
![badge][badge-jvm]
![badge][badge-js]
![badge][badge-wasmjs]

# Mobile Kotlin resources

Expand Down Expand Up @@ -64,7 +65,7 @@ buildscript {
}

dependencies {
classpath "dev.icerock.moko:resources-generator:0.24.5"
classpath "dev.icerock.moko:resources-generator:0.25.0"
}
}

Expand All @@ -82,10 +83,10 @@ project build.gradle
apply plugin: "dev.icerock.mobile.multiplatform-resources"

dependencies {
commonMainApi("dev.icerock.moko:resources:0.24.5")
commonMainApi("dev.icerock.moko:resources-compose:0.24.5") // for compose multiplatform
commonMainApi("dev.icerock.moko:resources:0.25.0")
commonMainApi("dev.icerock.moko:resources-compose:0.25.0") // for compose multiplatform

commonTestImplementation("dev.icerock.moko:resources-test:0.24.5")
commonTestImplementation("dev.icerock.moko:resources-test:0.25.0")
}

multiplatformResources {
Expand Down Expand Up @@ -132,7 +133,7 @@ should [add `export` declarations](https://kotlinlang.org/docs/multiplatform-bui

```
framework {
export("dev.icerock.moko:resources:0.24.5")
export("dev.icerock.moko:resources:0.25.0")
export("dev.icerock.moko:graphics:0.9.0") // toUIColor here
}
```
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ kotlin.mpp.enableCInteropCommonization=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.wasm.enabled=true

android.useAndroidX=true

Expand Down
12 changes: 7 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[versions]
kotlinVersion = "1.9.20"
kotlinVersion = "1.9.25"
androidGradleVersion = "8.1.4"
androidSdkCommonVersion = "31.1.2"

# kotlinx
kotlinxSerializationVersion = "1.6.1"
kotlinxCoroutinesVersion = "1.6.4"
kotlinxCoroutinesVersion = "1.8.0"
kotlinxBrowserVersion = "0.3"

# android
androidAppCompatVersion = "1.6.1"

# android compose
composeUiVersion = "1.5.1"
composeUiVersion = "1.7.1"

# jetbrains compose
composeJetbrainsVersion = "1.6.0"
composeJetbrainsVersion = "1.7.0"

# jvm
apacheCommonsTextVersion = "1.10.0"
Expand All @@ -25,14 +26,15 @@ commonsCodecVersion = "1.15"
batikVersion = "1.17"

# moko
mokoGraphicsVersion = "0.9.0"
mokoGraphicsVersion = "0.10.0"
mokoTestVersion = "0.6.1"
mokoMultiplatformPluginVersion = "0.14.2"

[libraries]
# kotlinx
kotlinxSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationVersion" }
kotlinxCoroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesVersion" }
kotlinxBrowser = { module = "org.jetbrains.kotlinx:kotlinx-browser", version.ref = "kotlinxBrowserVersion" }

# moko
mokoGraphics = { module = "dev.icerock.moko:graphics", version.ref = "mokoGraphicsVersion" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/moko.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
resourcesVersion = "0.24.5"
resourcesVersion = "0.25.0"

[libraries]
resources = { module = "dev.icerock.moko:resources", version.ref = "resourcesVersion" }
Expand Down
1,326 changes: 752 additions & 574 deletions kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ kotlin {
browser()
useCommonJs()
}
wasmJs {
browser()
useCommonJs()
}

// For https://youtrack.jetbrains.com/issue/KT-61573
targets.configureEach {
compilations.configureEach {
compileTaskProvider.configure {
compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}
}

sourceSets {
val commonMain by getting
Expand Down Expand Up @@ -57,6 +72,16 @@ kotlin {
macosX64Main.dependsOn(this)
}

val commonJsMain = create("commonJsMain") {
dependsOn(commonMain)
}
val jsMain by getting {
dependsOn(commonJsMain)
}
val wasmJsMain by getting {
dependsOn(commonJsMain)
}

val commonTest by getting
val macosArm64Test by getting
val macosX64Test by getting
Expand All @@ -70,6 +95,10 @@ kotlin {
val jsTest by getting {
dependsOn(commonTest)
}

val wasmJsTest by getting {
dependsOn(commonTest)
}
}

jvmToolchain(11)
Expand Down
3 changes: 3 additions & 0 deletions resources-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ kotlin {
js(IR) {
browser()
}
wasmJs {
browser()
}

sourceSets {
commonMain {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.moko.resources.compose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ actual fun FontResource.asFont(
): Font? {
val bytes: ByteArray? by produceByteArray(url = fileUrl)

return remember(fileUrl, bytes?.size ?: 0) {
return remember(bytes, weight, style) {
bytes?.let { b ->
Font(
identity = fontFamily,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.SystemTheme
import androidx.compose.ui.graphics.Color
Expand All @@ -25,7 +25,7 @@ import org.jetbrains.skia.Data
import org.jetbrains.skia.Image
import org.jetbrains.skia.svg.SVGDOM

@OptIn(InternalComposeApi::class)
@OptIn(InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
val fileUrl: String = if (LocalSystemTheme.current == SystemTheme.Dark) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ actual fun stringResource(resource: PluralsResource, quantity: Int, vararg args:
}

@Composable
private fun localized(stringDesc: StringDesc): String {
internal fun localized(stringDesc: StringDesc): String {
return produceState(initialValue = "", stringDesc) {
value = stringDesc.toLocalizedString()
}.value
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.moko.resources.compose.internal

internal expect suspend fun fetchByteArray(url: String): ByteArray
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("Filename")

package dev.icerock.moko.resources.compose.internal

import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.produceState

@Composable
internal fun produceByteArray(url: String): State<ByteArray?> {
return produceState<ByteArray?>(null, url) {
@Suppress("TooGenericExceptionCaught")
try {
value = fetchByteArray(url)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.remember
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.painter.Painter
Expand All @@ -18,7 +18,7 @@ import org.jetbrains.skia.Image
import platform.CoreGraphics.CGImageRef
import platform.UIKit.UIImage

@OptIn(ExperimentalForeignApi::class, InternalComposeApi::class)
@OptIn(ExperimentalForeignApi::class, InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
return remember(LocalSystemTheme.current, imageResource) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.moko.resources.compose.internal

import kotlinx.browser.window
import kotlinx.coroutines.await
import org.khronos.webgl.ArrayBuffer
import org.khronos.webgl.Int8Array
import org.w3c.fetch.Response

internal actual suspend fun fetchByteArray(url: String): ByteArray {
val response: Response = window.fetch(url).await()

if (response.ok.not()) {
error("can't load data from $url : $response")
}

val buffer: ArrayBuffer = response.arrayBuffer().await()

return Int8Array(buffer).unsafeCast<ByteArray>()
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.SystemTheme
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import dev.icerock.moko.resources.ImageResource

@OptIn(InternalComposeApi::class)
@OptIn(InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
val filePath: String = if (LocalSystemTheme.current == SystemTheme.Dark) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
import androidx.compose.runtime.remember
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.painter.Painter
Expand All @@ -19,7 +19,7 @@ import platform.AppKit.NSImage
import platform.CoreGraphics.CGImageRef
import platform.CoreGraphics.CGImageRelease

@OptIn(ExperimentalForeignApi::class, InternalComposeApi::class)
@OptIn(ExperimentalForeignApi::class, InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
return remember(LocalSystemTheme.current, imageResource) {
Expand Down
Loading
Loading