Skip to content

Commit a8fd4e0

Browse files
committed
Sync infrastracture and README with kotlin-wasm-examples repo browser-example
1 parent 4085851 commit a8fd4e0

File tree

4 files changed

+63
-25
lines changed

4 files changed

+63
-25
lines changed

README.md

+55-20
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,70 @@
44

55
A simple app drawing an input field for a timezone name and time in the timezone in the HTML document
66

7-
## Build and run
7+
Check it out:
8+
9+
[![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-browser-template/).
10+
11+
![](screenshots/browser-example.png)
12+
13+
## Set up the environment
14+
15+
Before starting, ensure you have the necessary IDE and browser setup to run the application.
16+
17+
### IDE
18+
19+
We recommend using [IntelliJ IDEA 2023.1 or later](https://www.jetbrains.com/idea/) to work with the project.
20+
It supports Kotlin/Wasm out of the box.
21+
22+
### Browser (for Kotlin/Wasm target)
23+
24+
To run Kotlin/Wasm applications in a browser, you need a browser supporting the [Wasm Garbage Collection (GC) feature](https://github.com/WebAssembly/gc):
25+
26+
**Chrome and Chromium-based**
827

9-
Check out the repo, navigate to the project folder, and use the following command:
10-
```
11-
./gradlew wasmJsBrowserRun -t
12-
```
28+
* **For version 119 or later:**
29+
30+
Works by default.
31+
32+
**Firefox**
33+
34+
* **For version 120 or later:**
35+
36+
Works by default.
37+
38+
**Safari/WebKit**
39+
40+
Wasm GC support is currently under
41+
[active development](https://bugs.webkit.org/show_bug.cgi?id=247394).
42+
43+
> **Note:**
44+
> For more information about the browser versions, see the [Troubleshooting documentation](https://kotl.in/wasm_help/).
45+
46+
## Build and run
1347

14-
## Setup Environment
48+
To build and run the application:
1549

16-
To run applications built with Kotlin/Wasm in a browser, you need a browser supporting [wasm garbage collection feature](https://github.com/WebAssembly/gc):
50+
1. In IntelliJ IDEA, open the repository.
51+
2. Run the application by typing the following Gradle command in the terminal:
1752

18-
- For **Chrome** and **Chromium-based** browsers (Edge, Brave etc.), it **should just work** since version 119.
19-
- For **Firefox** 120 it **should just work**.
20-
- For **Firefox** 119:
21-
1. Open `about:config` in the browser.
22-
2. Enable **javascript.options.wasm_gc**.
23-
3. Refresh the page.
53+
`./gradlew wasmJsBrowserRun -t`
54+
<br>&nbsp;<br>
2455

25-
For more information see https://kotl.in/wasm_help/.
56+
Once the application starts, open the following URL in your browser:
2657

27-
## IDE
58+
`http://localhost:8080`
2859

29-
We recommend using [IntelliJ IDEA 2023.1 or newer](https://www.jetbrains.com/idea/) to work with the project.
60+
> **Note:**
61+
> The port number can vary. If the port 8080 is unavailable, you can find the corresponding port number printed in the console
62+
> after building the application.
3063
31-
# Feedback & Questions
64+
## Feedback and questions
3265

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

35-
# Learn more
70+
## Learn more
3671

3772
* [Kotlin/Wasm](https://kotl.in/wasm/)
38-
* [Other examples](../../../#examples)
73+
* [Other Kotlin/Wasm examples](https://github.com/Kotlin/kotlin-wasm-examples/tree/main)

build.gradle.kts

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ plugins {
44
kotlin("multiplatform") version "2.0.0"
55
}
66

7+
group = "me.user"
8+
version = "1.0-SNAPSHOT"
9+
710
repositories {
811
mavenCentral()
912
}
@@ -23,10 +26,13 @@ kotlin {
2326
}
2427

2528
sourceSets {
26-
val wasmJsTest by getting {
29+
val commonMain by getting
30+
val commonTest by getting {
2731
dependencies {
2832
implementation(kotlin("test"))
2933
}
3034
}
35+
val wasmJsMain by getting
36+
val wasmJsTest by getting
3137
}
32-
}
38+
}

gradle.properties

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
kotlin.code.style=official
2-
3-
# To enable K2 Kotlin compiler uncomment the next line
4-
#kotlin.experimental.tryK2=true

screenshots/browser-example.png

304 KB
Loading

0 commit comments

Comments
 (0)