Skip to content

Commit

Permalink
Sync infrastracture and README with kotlin-wasm-examples repo browser…
Browse files Browse the repository at this point in the history
…-example
  • Loading branch information
JSMonk committed Aug 6, 2024
1 parent 4085851 commit a8fd4e0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 25 deletions.
75 changes: 55 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,70 @@

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

## Build and run
Check it out:

[![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/).

![](screenshots/browser-example.png)

## Set up the environment

Before starting, ensure you have the necessary IDE and browser setup to run the application.

### IDE

We recommend using [IntelliJ IDEA 2023.1 or later](https://www.jetbrains.com/idea/) to work with the project.
It supports Kotlin/Wasm out of the box.

### Browser (for Kotlin/Wasm target)

To run Kotlin/Wasm applications in a browser, you need a browser supporting the [Wasm Garbage Collection (GC) feature](https://github.com/WebAssembly/gc):

**Chrome and Chromium-based**

Check out the repo, navigate to the project folder, and use the following command:
```
./gradlew wasmJsBrowserRun -t
```
* **For version 119 or later:**

Works by default.

**Firefox**

* **For version 120 or later:**

Works by default.

**Safari/WebKit**

Wasm GC support is currently under
[active development](https://bugs.webkit.org/show_bug.cgi?id=247394).

> **Note:**
> For more information about the browser versions, see the [Troubleshooting documentation](https://kotl.in/wasm_help/).
## Build and run

## Setup Environment
To build and run the application:

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

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

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

## IDE
`http://localhost:8080`

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

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).
Give it a try and share your feedback or questions in our [#webassembly](https://slack-chats.kotlinlang.org/c/webassembly) Slack channel.
[Get a Slack invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up).
You can also share your comments with [@bashorov](https://twitter.com/bashorov) on X (Twitter).

# Learn more
## Learn more

* [Kotlin/Wasm](https://kotl.in/wasm/)
* [Other examples](../../../#examples)
* [Other Kotlin/Wasm examples](https://github.com/Kotlin/kotlin-wasm-examples/tree/main)
10 changes: 8 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ plugins {
kotlin("multiplatform") version "2.0.0"
}

group = "me.user"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
}
Expand All @@ -23,10 +26,13 @@ kotlin {
}

sourceSets {
val wasmJsTest by getting {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val wasmJsMain by getting
val wasmJsTest by getting
}
}
}
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
kotlin.code.style=official

# To enable K2 Kotlin compiler uncomment the next line
#kotlin.experimental.tryK2=true
Binary file added screenshots/browser-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a8fd4e0

Please sign in to comment.