diff --git a/app-wasm/README.md b/app-wasm/README.md index 6929c4add..e43cf6ece 100644 --- a/app-wasm/README.md +++ b/app-wasm/README.md @@ -3,7 +3,7 @@ ### Generate Dependency Information ```bash -./gradlew app-wasm:exportLibraryDefinitions -PaboutLibraries.exportPath=src/wasmJsMain/resources/ +./gradlew app-wasm:exportLibraryDefinitions -PaboutLibraries.exportPath=src/commonMain/composeResources/files/ ``` ### Run Wasm app diff --git a/app-wasm/build.gradle.kts b/app-wasm/build.gradle.kts index 4fadafa8f..cc6fe77af 100644 --- a/app-wasm/build.gradle.kts +++ b/app-wasm/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl plugins { kotlin("multiplatform") @@ -16,38 +16,31 @@ plugins { // } kotlin { + @OptIn(ExperimentalWasmDsl::class) wasmJs { moduleName = "aboutlibraries" browser { commonWebpackConfig { - devServer = (devServer ?: KotlinWebpackConfig.DevServer()).copy( - open = mapOf( - "app" to mapOf( - "name" to "google chrome canary", - "arguments" to listOf("--js-flags=--experimental-wasm-gc ") - ) - ), - static = (devServer?.static ?: mutableListOf()).apply { - add(project.rootDir.path) - add(project.rootDir.path + "/common/") - add(project.rootDir.path + "/nonAndroidMain/") - add(project.rootDir.path + "/web/") - }, - ) + outputFileName = "composeApp.js" } } binaries.executable() } sourceSets { + commonMain { + dependencies { + @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) + implementation(compose.components.resources) + } + } + val wasmJsMain by getting { dependencies { implementation(compose.runtime) implementation(compose.ui) implementation(compose.foundation) implementation(compose.material) - @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) implementation(project(":aboutlibraries-core")) implementation(project(":aboutlibraries-compose-m2")) diff --git a/app-wasm/src/wasmJsMain/resources/aboutlibraries.json b/app-wasm/src/commonMain/composeResources/files/aboutlibraries.json similarity index 100% rename from app-wasm/src/wasmJsMain/resources/aboutlibraries.json rename to app-wasm/src/commonMain/composeResources/files/aboutlibraries.json diff --git a/app-wasm/src/wasmJsMain/kotlin/Main.kt b/app-wasm/src/wasmJsMain/kotlin/Main.kt index 920fbf806..478377393 100644 --- a/app-wasm/src/wasmJsMain/kotlin/Main.kt +++ b/app-wasm/src/wasmJsMain/kotlin/Main.kt @@ -10,13 +10,15 @@ import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer import com.mikepenz.aboutlibraries.ui.compose.util.StableLibs import com.mikepenz.aboutlibraries.ui.compose.util.stable +import com.mikepenz.`app-wasm`.generated.resources.Res import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.resource +import org.jetbrains.compose.resources.InternalResourceApi -@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class) +@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class, InternalResourceApi::class) fun main() { + println("I am here 1") CanvasBasedWindow("AboutLibraries", canvasElementId = "aboutLibsCanvas") { SampleTheme { Scaffold( @@ -25,7 +27,7 @@ fun main() { val libraries = produceState(null) { value = withContext(Dispatchers.Default) { Libs.Builder() - .withJson(resource("aboutlibraries.json").readBytes().decodeToString()) + .withJson(Res.readBytes("files/aboutlibraries.json").decodeToString()) .build().stable } } diff --git a/app-wasm/src/wasmJsMain/resources/index.html b/app-wasm/src/wasmJsMain/resources/index.html index 30c660b08..8f3dbd51e 100644 --- a/app-wasm/src/wasmJsMain/resources/index.html +++ b/app-wasm/src/wasmJsMain/resources/index.html @@ -2,20 +2,10 @@ - - - - - - - - - - - JetSnack with Kotlin/Wasm + AboutLibraries (Kotlin/Wasm) - +