Skip to content

Commit

Permalink
Merge pull request #5 from MohamedRejeb/compose-1.6
Browse files Browse the repository at this point in the history
Add WASM support
  • Loading branch information
MohamedRejeb committed Mar 23, 2024
2 parents 224fedc + 6459802 commit da40cb2
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
7 changes: 7 additions & 0 deletions compose-dnd/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

/*
* Copyright 2023, Mohamed Ben Rejeb and the Compose Dnd project contributors
*
Expand Down Expand Up @@ -41,6 +43,11 @@ kotlin {
browser()
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
}

iosX64()
iosArm64()
iosSimulatorArm64()
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ org.jetbrains.compose.experimental.uikit.enabled=true

# Compose for Web
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.wasm.enabled=true

#Android
android.useAndroidX=true
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
7 changes: 7 additions & 0 deletions sample/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

/*
* Copyright 2023, Mohamed Ben Rejeb and the Compose Dnd project contributors
*
Expand Down Expand Up @@ -39,6 +41,11 @@ kotlin {
browser()
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
}

listOf(
iosX64(),
iosArm64(),
Expand Down
12 changes: 10 additions & 2 deletions sample/web/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.jetbrainsCompose)
Expand All @@ -9,7 +11,13 @@ kotlin {
binaries.executable()
}

sourceSets.jsMain.dependencies {
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
binaries.executable()
}

sourceSets.commonMain.dependencies {
implementation(projects.sample.common)

implementation(compose.foundation)
Expand All @@ -18,4 +26,4 @@ kotlin {

compose.experimental {
web.application {}
}
}
11 changes: 11 additions & 0 deletions sample/web/src/wasmJsMain/kotlin/main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.CanvasBasedWindow

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
CanvasBasedWindow(
title = "Compose DND",
) {
App()
}
}
19 changes: 19 additions & 0 deletions sample/web/src/wasmJsMain/resources/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Multiplatform App</title>
<script src="skiko.js"></script>
<script src="web.js"></script>
</head>
<body>
<noscript>
This page requires JavaScript.
</noscript>
<div id="root" class="d-flex flex-column h-100">
</div>
<div>
<canvas id="ComposeTarget" width="800" height="600"></canvas>
</div>
</body>
</html>

0 comments on commit da40cb2

Please sign in to comment.