Skip to content

Commit a6023e5

Browse files
Enable Web support for demo-compose-app (#780)
This commit introduces WebAssembly (Wasm) and JS browser support to the demo-compose-app. <!-- Thank you for opening a pull request! Please add a brief description of the proposed change here. Also, please tick the appropriate points in the checklist below. --> ## Motivation and Context <!-- Why is this change needed? What problem does it solve? --> ## Breaking Changes <!-- Will users need to update their code or configurations? --> --- #### Type of the changes - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [ ] Tests improvement - [x] Refactoring #### Checklist - [x] The pull request has a description of the proposed change - [x] I read the [Contributing Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md) before opening the pull request - [x] The pull request uses **`develop`** as the base branch - [x] Tests for the changes have been added - [x] All new and existing tests passed ##### Additional steps for pull requests adding a new feature - [ ] An issue describing the proposed change exists - [ ] The pull request includes a link to the issue - [ ] The change was discussed and approved in the issue - [ ] Docs have been added / updated
1 parent 4436694 commit a6023e5

File tree

11 files changed

+91
-19
lines changed

11 files changed

+91
-19
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ updates:
5959
prefix-development: "deps(dev)"
6060
include: "scope"
6161

62-
# Android demo app
62+
# Compose demo app
6363
- package-ecosystem: "gradle"
64-
directory: "/examples/demo-android-app"
64+
directory: "/examples/demo-compose-app"
6565
schedule:
6666
interval: "monthly"
6767
target-branch: "develop"

.github/workflows/demo-compose-app.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ jobs:
2424
matrix:
2525
gradle-tasks: [
2626
"lint :app:assembleDebug :app:assembleRelease",
27-
":app:jvmJar"
27+
":app:jvmJar",
28+
":app:composeCompatibilityBrowserDistribution"
2829
]
2930
os: [ ubuntu-latest ]
3031
include:

examples/demo-compose-app/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,13 @@ Run the desktop **hot reload** application: `./gradlew :app:hotRunJvm`
3737
To run the application on iPhone device/simulator:
3838
- Open `iosApp/iosApp.xcproject` in Xcode and run standard configuration
3939
- Or use [Kotlin Multiplatform Mobile plugin](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile) for Android Studio
40+
41+
### Web Distribution
42+
Build web distribution: `./gradlew :app:composeCompatibilityBrowserDistribution`
43+
Deploy a dir `app/build/dist/composeWebCompatibility/productionExecutable` to a web server
44+
45+
### JS Browser
46+
Run the browser application: `./gradlew :app:jsBrowserDevelopmentRun --continue`
47+
48+
### Wasm Browser
49+
Run the browser application: `./gradlew :app:wasmJsBrowserDevelopmentRun --continue`

examples/demo-compose-app/app/build.gradle.kts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ kotlin {
3232
}
3333
}
3434

35+
js {
36+
browser()
37+
binaries.executable()
38+
}
39+
40+
wasmJs {
41+
browser()
42+
binaries.executable()
43+
}
44+
3545
sourceSets {
3646
commonMain.dependencies {
3747
implementation(compose.animation)
@@ -52,10 +62,6 @@ kotlin {
5262
implementation(libs.kotlinx.coroutines.core)
5363
implementation(libs.kotlinx.serialization.core)
5464
implementation(libs.kotlinx.serialization.json)
55-
implementation(libs.ktor.client.content.negotiation)
56-
implementation(libs.ktor.client.core)
57-
implementation(libs.ktor.client.logging)
58-
implementation(libs.ktor.serialization.kotlinx.json)
5965
implementation(project.dependencies.platform(libs.koin.bom))
6066
}
6167

@@ -73,7 +79,9 @@ kotlin {
7379

7480
iosMain.dependencies {
7581
implementation(libs.androidx.datastore.preferences)
76-
implementation(libs.ktor.client.darwin)
82+
}
83+
84+
webMain.dependencies {
7785
}
7886
}
7987
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.jetbrains.example.kotlin_agents_demo_app
2+
3+
import com.jetbrains.example.kotlin_agents_demo_app.settings.AppSettings
4+
import com.jetbrains.example.kotlin_agents_demo_app.settings.MemoryAppSettings
5+
import org.koin.core.module.Module
6+
import org.koin.dsl.module
7+
8+
actual val appPlatformModule: Module = module {
9+
single<AppSettings> { MemoryAppSettings() }
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.jetbrains.example.kotlin_agents_demo_app.settings
2+
3+
internal class MemoryAppSettings : AppSettings {
4+
private var appSettingsData = AppSettingsData(openAiToken = "", anthropicToken = "")
5+
override suspend fun getCurrentSettings(): AppSettingsData = appSettingsData
6+
override suspend fun setCurrentSettings(settings: AppSettingsData) {
7+
appSettingsData = settings
8+
}
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.jetbrains.example.kotlin_agents_demo_app.theme
2+
3+
import androidx.compose.runtime.Composable
4+
5+
@Composable
6+
internal actual fun SystemAppearance(isDark: Boolean) {
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import androidx.compose.ui.ExperimentalComposeUiApi
2+
import androidx.compose.ui.window.ComposeViewport
3+
import com.jetbrains.example.kotlin_agents_demo_app.KoinApp
4+
5+
@OptIn(ExperimentalComposeUiApi::class)
6+
fun main() = ComposeViewport { KoinApp() }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="manifest" href="./manifest.json">
7+
<title>Koog Demo App</title>
8+
<style>
9+
html,
10+
body {
11+
width: 100%;
12+
height: 100%;
13+
margin: 0;
14+
padding: 0;
15+
overflow: hidden;
16+
}
17+
</style>
18+
</head>
19+
<body></body>
20+
<script src="app.js"></script>
21+
</html>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Koog Demo App",
3+
"short_name": "Koog Demo App",
4+
"icons": [],
5+
"theme_color": "#ffffff",
6+
"background_color": "#ffffff",
7+
"display": "standalone"
8+
}

0 commit comments

Comments
 (0)