File tree Expand file tree Collapse file tree 6 files changed +63
-0
lines changed
src/wasmJsMain/kotlin/moe/tlaster/precompose/molecule
kotlin/moe/tlaster/precompose/molecule/sample Expand file tree Collapse file tree 6 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
12import java.util.Properties
23
34plugins {
@@ -31,6 +32,10 @@ kotlin {
3132 js(IR ) {
3233 browser()
3334 }
35+ @OptIn(ExperimentalWasmDsl ::class )
36+ wasmJs {
37+ browser()
38+ }
3439 sourceSets {
3540 val commonMain by getting {
3641 dependencies {
Original file line number Diff line number Diff line change 1+ package moe.tlaster.precompose.molecule
2+
3+ import kotlinx.coroutines.Dispatchers
4+ import kotlin.coroutines.CoroutineContext
5+
6+ internal actual fun providePlatformDispatcher (): CoroutineContext = Dispatchers .Main
Original file line number Diff line number Diff line change 11import org.jetbrains.compose.desktop.application.dsl.TargetFormat
22import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
3+ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
4+ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
35
46plugins {
57 kotlin(" multiplatform" )
@@ -37,6 +39,25 @@ kotlin {
3739 }
3840 }
3941 jvm()
42+ @OptIn(ExperimentalWasmDsl ::class )
43+ wasmJs {
44+ moduleName = " composeApp"
45+ browser {
46+ val projectDirPath = project.projectDir.path
47+ commonWebpackConfig {
48+ outputFileName = " composeApp.js"
49+ devServer =
50+ (devServer ? : KotlinWebpackConfig .DevServer ()).apply {
51+ static =
52+ (static ? : mutableListOf ()).apply {
53+ // Serve sources to debug inside browser
54+ add(projectDirPath)
55+ }
56+ }
57+ }
58+ }
59+ binaries.executable()
60+ }
4061
4162 sourceSets {
4263 val commonMain by getting {
Original file line number Diff line number Diff line change 1+ package moe.tlaster.precompose.molecule.sample
2+
3+ import androidx.compose.ui.ExperimentalComposeUiApi
4+ import androidx.compose.ui.window.ComposeViewport
5+ import kotlinx.browser.document
6+
7+ @OptIn(ExperimentalComposeUiApi ::class )
8+ fun main () {
9+ ComposeViewport (document.body!! ) {
10+ App ()
11+ }
12+ }
Original file line number Diff line number Diff line change 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+ < title > molecule</ title >
7+ < link type ="text/css " rel ="stylesheet " href ="styles.css ">
8+ < script type ="application/javascript " src ="composeApp.js "> </ script >
9+ </ head >
10+ < body >
11+ </ body >
12+ </ html >
Original file line number Diff line number Diff line change 1+ html , body {
2+ width : 100% ;
3+ height : 100% ;
4+ margin : 0 ;
5+ padding : 0 ;
6+ overflow : hidden;
7+ }
You can’t perform that action at this time.
0 commit comments