diff --git a/components/README.md b/components/README.md index 7c58b9785b..16c65b622d 100644 --- a/components/README.md +++ b/components/README.md @@ -11,7 +11,7 @@ in Android Studio or in AppCode with [installed CocoaPods](https://kotlinlang.or `./gradlew :resources:demo:desktopApp:run` ### Run JS in browser with WebAssembly Skia via Gradle: -`./gradlew :resources:demo:shared:jsBrowserDevelopmentRun` +`./gradlew :resources:demo:jsApp:jsBrowserDevelopmentRun` ### Run MacOS via Gradle: - on Intel CPU: `./gradlew :resources:demo:shared:runDebugExecutableMacosX64` diff --git a/components/resources/demo/jsApp/build.gradle.kts b/components/resources/demo/jsApp/build.gradle.kts new file mode 100644 index 0000000000..3de43800dd --- /dev/null +++ b/components/resources/demo/jsApp/build.gradle.kts @@ -0,0 +1,36 @@ +plugins { + kotlin("multiplatform") + id("org.jetbrains.compose") +} + +val copyResources = tasks.create("copyJsResourcesWorkaround", Copy::class.java) { + from(project(":resources:demo:shared").file("src/commonMain/resources")) + to("build/processedResources/js/main") +} + +kotlin { + js(IR) { + browser { + this.commonWebpackConfig { + println("this.outputPath: ${this.outputPath}") + this.devServer?.contentBase + } + this.webpackTask { + this.dependsOn(copyResources) + } + } + binaries.executable() + } + sourceSets { + val jsMain by getting { + dependencies { + implementation(project(":resources:demo:shared")) + } + resources.srcDirs += project(":resources:demo:shared").file("src/commonMain/resources") + } + } +} + +compose.experimental { + web.application {} +} diff --git a/components/resources/demo/jsApp/src/jsMain/kotlin/main.js.kt b/components/resources/demo/jsApp/src/jsMain/kotlin/main.js.kt new file mode 100644 index 0000000000..64cfd97310 --- /dev/null +++ b/components/resources/demo/jsApp/src/jsMain/kotlin/main.js.kt @@ -0,0 +1,15 @@ +/* +* Copyright 2020-2023 JetBrains s.r.o. and respective authors and developers. +* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. +*/ + +import androidx.compose.ui.window.Window +import org.jetbrains.skiko.wasm.onWasmReady + +fun main() { + onWasmReady { + Window("Resources demo") { + MainView() + } + } +} diff --git a/components/resources/demo/jsApp/src/jsMain/resources/dir/img.png b/components/resources/demo/jsApp/src/jsMain/resources/dir/img.png new file mode 100644 index 0000000000..f33b6c2622 Binary files /dev/null and b/components/resources/demo/jsApp/src/jsMain/resources/dir/img.png differ diff --git a/components/resources/demo/jsApp/src/jsMain/resources/img.webp b/components/resources/demo/jsApp/src/jsMain/resources/img.webp new file mode 100644 index 0000000000..0da983e2ce Binary files /dev/null and b/components/resources/demo/jsApp/src/jsMain/resources/img.webp differ diff --git a/components/resources/demo/shared/src/jsMain/resources/index.html b/components/resources/demo/jsApp/src/jsMain/resources/index.html similarity index 58% rename from components/resources/demo/shared/src/jsMain/resources/index.html rename to components/resources/demo/jsApp/src/jsMain/resources/index.html index 971817e6a8..1c90c6c32c 100644 --- a/components/resources/demo/shared/src/jsMain/resources/index.html +++ b/components/resources/demo/jsApp/src/jsMain/resources/index.html @@ -7,10 +7,10 @@ -

compose multiplatform web demo

-
- -
- +

compose multiplatform web demo

+
+ +
+ diff --git a/components/resources/demo/shared/src/jsMain/resources/styles.css b/components/resources/demo/jsApp/src/jsMain/resources/styles.css similarity index 100% rename from components/resources/demo/shared/src/jsMain/resources/styles.css rename to components/resources/demo/jsApp/src/jsMain/resources/styles.css diff --git a/components/resources/demo/shared/build.gradle.kts b/components/resources/demo/shared/build.gradle.kts index 297f9775ea..f9ba3a269d 100644 --- a/components/resources/demo/shared/build.gradle.kts +++ b/components/resources/demo/shared/build.gradle.kts @@ -14,7 +14,6 @@ kotlin { iosSimulatorArm64() js(IR) { browser() - binaries.executable() } macosX64 { binaries { diff --git a/components/resources/demo/shared/src/jsMain/kotlin/main.js.kt b/components/resources/demo/shared/src/jsMain/kotlin/main.js.kt index 2eb351f69a..7cc0b3f6d6 100644 --- a/components/resources/demo/shared/src/jsMain/kotlin/main.js.kt +++ b/components/resources/demo/shared/src/jsMain/kotlin/main.js.kt @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. + * Copyright 2020-2023 JetBrains s.r.o. and respective authors and developers. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. */ @@ -14,14 +14,6 @@ import androidx.compose.ui.window.Window import org.jetbrains.compose.resources.demo.shared.UseResources import org.jetbrains.skiko.wasm.onWasmReady -fun main() { - onWasmReady { - Window("Resources demo") { - MainView() - } - } -} - @Composable fun MainView() { Column(modifier = Modifier.fillMaxSize()) { diff --git a/components/settings.gradle.kts b/components/settings.gradle.kts index 0e9c93eb23..c79232176b 100644 --- a/components/settings.gradle.kts +++ b/components/settings.gradle.kts @@ -22,4 +22,5 @@ include("AnimatedImage:demo") include(":resources:library") include(":resources:demo:androidApp") include(":resources:demo:desktopApp") +include(":resources:demo:jsApp") include(":resources:demo:shared")