Skip to content

Commit

Permalink
Merge pull request #3 from KevinnZou/feature/wasm_support
Browse files Browse the repository at this point in the history
Feature/wasm support
  • Loading branch information
KevinnZou authored Mar 20, 2024
2 parents 7efc1dc + ad3e994 commit dfc13ca
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ kotlin.mpp.androidSourceSetLayoutVersion=2

#Compose
org.jetbrains.compose.experimental.uikit.enabled=true
org.jetbrains.compose.experimental.wasm.enabled=true

#Android
android.useAndroidX=true
Expand All @@ -19,9 +20,9 @@ android.targetSdk=34
android.minSdk=24

#Versions
kotlin.version=1.9.10
kotlin.version=1.9.23
agp.version=8.1.1
compose.version=1.5.3
compose.version=1.6.1
dokka.version=1.9.0

GROUP=io.github.kevinnzou
Expand Down
18 changes: 18 additions & 0 deletions sample/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
}

kotlin {
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "composeSwipeBoxSample"
browser {
commonWebpackConfig {
outputFileName = "composeSwipeBoxSample.js"
}
}
binaries.executable()
}

androidTarget()

jvm("desktop")
Expand All @@ -26,6 +39,7 @@ kotlin {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.ui)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
api(project(":swipebox"))
Expand Down Expand Up @@ -74,3 +88,7 @@ android {
jvmToolchain(17)
}
}

compose.experimental {
web.application {}
}
13 changes: 13 additions & 0 deletions sample/shared/src/wasmJsMain/kotlin/com/kevinnzou/sample/main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.kevinnzou.sample

import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.CanvasBasedWindow

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
CanvasBasedWindow(canvasElementId = "ComposeTarget") { App() }
}

actual fun getPlatformName(): String {
return "JS/WASM"
}
12 changes: 12 additions & 0 deletions sample/shared/src/wasmJsMain/resources/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Compose App</title>
<script type="application/javascript" src="skiko.js"></script>
<script type="application/javascript" src="composeSwipeBoxSample.js"></script>
</head>
<body>
<canvas id="ComposeTarget"></canvas>
</body>
</html>
12 changes: 12 additions & 0 deletions swipebox/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
Expand All @@ -9,6 +10,17 @@ plugins {
}

kotlin {
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "composeSwipeBox"
browser {
commonWebpackConfig {
outputFileName = "composeSwipeBox.js"
}
}
binaries.executable()
}

androidTarget() {
publishLibraryVariants("release")
}
Expand Down

0 comments on commit dfc13ca

Please sign in to comment.