Skip to content

Commit ee1def9

Browse files
committed
Sync infrastracture and README with kotlin-wasm-examples repo compose-example
1 parent 1f5e07e commit ee1def9

File tree

7 files changed

+320
-302
lines changed

7 files changed

+320
-302
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.iml
22
.gradle
3+
.kotlin
34
**/build/
45
xcuserdata
56
!src/**/build/

README.md

+70-33
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,95 @@
11

22
[![Incubator](https://jb.gg/badges/incubator-plastic.svg)](https://github.com/JetBrains#jetbrains-on-github)
33

4-
# Compose Multiplatform for Web
4+
This example showcases a web application built with [Compose Multiplatform for web](#compose-multiplatform-for-web) and [Kotlin/Wasm](https://kotl.in/wasm).
55

6-
> **Note**
7-
> Web support is Experimental and may be changed at any time. Use it only for evaluation purposes.
8-
> We would appreciate your feedback on it in the public Slack channel [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web).
9-
> If you face any issues, please report them on [GitHub](https://github.com/JetBrains/compose-multiplatform/issues).
6+
Check it out:
107

11-
You can experiment with sharing your mobile or desktop UIs with the web. Compose for Web is based on [Kotlin/Wasm](https://kotl.in/wasm),
12-
the newest target for Kotlin Multiplatform projects. It allows Kotlin developers to run their code in the browser with
13-
all the benefits that WebAssembly has to offer, such as good and predictable performance for your applications.
14-
15-
# Compose for Web Example
16-
17-
A simple Compose Multiplatform App.
8+
[![Static Badge](https://img.shields.io/badge/online%20demo%20%F0%9F%9A%80-6b57ff?style=for-the-badge)](https://kotlin.github.io/kotlin-wasm-compose-template/).
189

1910
![](screenshots/compose-example.png)
2011

21-
## Build and run
12+
## Compose Multiplatform for web
13+
14+
> **Note:**
15+
> Web support is an [Alpha](https://kotlinlang.org/docs/components-stability.html) feature. It may be changed at any time.
16+
> You can use it in scenarios before production. We would appreciate your feedback on [GitHub](https://github.com/JetBrains/compose-multiplatform/issues).
17+
>
18+
> [Join the compose-web community](https://slack-chats.kotlinlang.org/c/compose-web).
19+
20+
Compose Multiplatform for web enables sharing your mobile or desktop UIs on the web.
21+
22+
Compose Multiplatform for web is based on [Kotlin/Wasm](https://kotl.in/wasm), the newest target for Kotlin Multiplatform projects.
23+
This enables running your code in the browser, leveraging WebAssembly's advantages like high and consistent application performance.
24+
25+
Follow the instructions in the sections below to try out this application built with Compose Multiplatform for web and Kotlin/Wasm.
26+
27+
## Set up the environment
28+
29+
Before starting, ensure you have the necessary IDE and browser setup to run the application.
30+
31+
### IDE
32+
33+
We recommend using [IntelliJ IDEA 2023.1 or later](https://www.jetbrains.com/idea/) to work with the project.
34+
It supports Kotlin/Wasm out of the box.
35+
36+
### Browser (for Kotlin/Wasm target)
2237

23-
Check out the repo, navigate to the project folder, and use the following commands:
38+
To run applications built with Kotlin/Wasm in a browser, you need a browser supporting the [Wasm Garbage Collection (GC) feature](https://github.com/WebAssembly/gc):
2439

25-
### Run Web version via Gradle
40+
**Chrome and Chromium-based**
41+
42+
* **For version 119 or later:**
43+
44+
Works by default.
45+
46+
**Firefox**
47+
48+
* **For version 120 or later:**
49+
50+
Works by default.
51+
52+
**Safari/WebKit**
53+
54+
Wasm GC support is currently under
55+
[active development](https://bugs.webkit.org/show_bug.cgi?id=247394).
56+
57+
> **Note:**
58+
> For more information about the browser versions, see the [Troubleshooting documentation](https://kotl.in/wasm_help/).
59+
60+
## Build and run
2661

27-
`./gradlew :composeApp:wasmJsRun`
62+
To build and run the application:
2863

29-
### Run Desktop version via Gradle
64+
1. In IntelliJ IDEA, open the repository.
65+
2. Run the application by typing one of the following Gradle commands in the terminal:
3066

31-
`./gradlew :composeApp:run`
67+
* **Web version:**
3268

33-
## Setup Environment
69+
`./gradlew :composeApp:wasmJsRun`
70+
<br>&nbsp;<br>
3471

35-
To run applications built with Kotlin/Wasm in a browser, you need a browser supporting [wasm garbage collection feature](https://github.com/WebAssembly/gc):
72+
Once the application starts, open the following URL in your browser:
3673

37-
- For **Chrome** and **Chromium-based** browsers (Edge, Brave etc.), it **should just work** since version 119.
38-
- For **Firefox** 120 it **should just work**.
39-
- For **Firefox** 119:
40-
1. Open `about:config` in the browser.
41-
2. Enable **javascript.options.wasm_gc**.
42-
3. Refresh the page.
74+
`http://localhost:8080`
4375

44-
For more information see https://kotl.in/wasm_help/.
76+
> **Note:**
77+
> The port number can vary. If the port 8080 is unavailable, you can find the corresponding port number printed in the console
78+
> after building the application.
79+
<br>&nbsp;<br>
4580

46-
## IDE
81+
* **Desktop version:**
4782

48-
We recommend using [IntelliJ IDEA 2023.1 or newer](https://www.jetbrains.com/idea/) to work with the project.
83+
`./gradlew :composeApp:run`
4984

50-
# Feedback & Questions
85+
## Feedback and questions
5186

52-
Give it a try, and share your feedback and ask questions in the Kotlin Slack [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web) channel (if you’re not a member, [apply here](https://kotl.in/slack)) or on Twitter to [@bashorov](https://twitter.com/bashorov).
87+
Give it a try and share your feedback or questions in our [#compose-web](https://slack-chats.kotlinlang.org/c/compose-web) Slack channel.
88+
[Get a Slack invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up).
89+
You can also share your comments with [@bashorov](https://twitter.com/bashorov) on X (Twitter).
5390

54-
# Learn more
91+
## Learn more
5592

5693
* [Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform/#compose-multiplatform)
5794
* [Kotlin/Wasm](https://kotl.in/wasm/)
58-
* [Other examples](../../../#examples)
95+
* [Other Kotlin/Wasm examples](https://github.com/Kotlin/kotlin-wasm-examples/tree/main)

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ plugins {
66
alias(libs.plugins.androidLibrary) apply false
77
alias(libs.plugins.kotlinMultiplatform) apply false
88
alias(libs.plugins.pluginCompose) apply false
9-
}
9+
}

composeApp/build.gradle.kts

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ kotlin {
4141
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
4242
static = (static ?: mutableListOf()).apply {
4343
// Serve sources to debug inside browser
44+
add(project.rootDir.path)
4445
add(project.projectDir.path)
45-
add(project.projectDir.path + "/commonMain/")
46-
add(project.projectDir.path + "/wasmJsMain/")
4746
}
4847
}
4948
}
@@ -78,7 +77,7 @@ android {
7877

7978
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
8079
sourceSets["main"].res.srcDirs("src/androidMain/res")
81-
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
80+
sourceSets["main"].resources.srcDirs("src/commonMain/composeResources")
8281

8382
defaultConfig {
8483
applicationId = "org.example.project"
@@ -120,4 +119,4 @@ compose.desktop {
120119

121120
compose.experimental {
122121
web.application {}
123-
}
122+
}

composeApp/src/commonMain/kotlin/App.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ fun App() {
3838
}
3939
}
4040
}
41-
}
41+
}

gradle/libs.versions.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
2-
compose = "1.5.4"
3-
compose-plugin = "1.6.10"
2+
compose = "1.5.8"
3+
compose-plugin = "1.6.11"
44
agp = "8.1.4"
55
android-minSdk = "24"
66
android-compileSdk = "34"
@@ -12,7 +12,7 @@ androidx-material = "1.10.0"
1212
androidx-constraintlayout = "2.1.4"
1313
androidx-test-junit = "1.1.5"
1414
androidx-espresso-core = "3.5.1"
15-
kotlin = "2.0.0"
15+
kotlin = "2.0.10"
1616
junit = "4.13.2"
1717

1818
[libraries]
@@ -33,8 +33,8 @@ androidx-constraintlayout = { group = "androidx.constraintlayout", name = "const
3333
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
3434

3535
[plugins]
36-
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
3736
androidApplication = { id = "com.android.application", version.ref = "agp" }
3837
androidLibrary = { id = "com.android.library", version.ref = "agp" }
3938
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
40-
pluginCompose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
39+
pluginCompose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
40+
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }

0 commit comments

Comments
 (0)