Browse Source

Added Web support

app-api
Nikolay Igotti 3 years ago
parent
commit
5a298a6bce
  1. 14
      components/Kapp/demo/build.gradle.kts
  2. 4
      components/Kapp/demo/src/jsMain/kotlin/org/jetbrains/compose/kapp/demo/Complex.js.kt
  3. 3
      components/Kapp/demo/src/jsMain/kotlin/org/jetbrains/compose/kapp/demo/Main.js.kt
  4. 3
      components/Kapp/demo/src/jsMain/kotlin/org/jetbrains/compose/kapp/demo/Simple.js.kt
  5. 4
      components/Kapp/library/src/desktopMain/kotlin/org/jetbrains/compose/kapp/App.desktop.kt
  6. 40
      components/Kapp/library/src/jsMain/kotlin/org/jetbrains/compose/kapp/KApp.js.kt
  7. 1
      components/build.gradle.kts
  8. 2
      components/gradle.properties
  9. 2900
      components/kotlin-js-store/yarn.lock

14
components/Kapp/demo/build.gradle.kts

@ -34,6 +34,20 @@ compose.desktop {
}
}
compose.experimental {
web.application {
}
// uikit.application {}
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
afterEvaluate {
rootProject.extensions.configure<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension> {
versions.webpackDevServer.version = "4.0.0"
versions.webpackCli.version = "4.9.0"
nodeVersion = "16.0.0"
}
}

4
components/Kapp/demo/src/jsMain/kotlin/org/jetbrains/compose/kapp/demo/Complex.js.kt

@ -0,0 +1,4 @@
package org.jetbrains.compose.kapp.demo
// TODO: cannot have several entry points at the moment.
// fun main() = multiFrameApp()

3
components/Kapp/demo/src/jsMain/kotlin/org/jetbrains/compose/kapp/demo/Main.js.kt

@ -0,0 +1,3 @@
import org.jetbrains.compose.kapp.demo.simpleDemoApp
fun main() = simpleDemoApp()

3
components/Kapp/demo/src/jsMain/kotlin/org/jetbrains/compose/kapp/demo/Simple.js.kt

@ -0,0 +1,3 @@
package org.jetbrains.compose.kapp.demo
fun main() = simpleDemoApp()

4
components/Kapp/library/src/desktopMain/kotlin/org/jetbrains/compose/kapp/App.desktop.kt

@ -25,7 +25,7 @@ actual fun KAppScope.Frame(content: @Composable () -> Unit) {
}
}
class AppAppScope : KAppScope, ApplicationScope {
internal class AppAppScope : KAppScope, ApplicationScope {
override fun exitApplication() {
println("Exit application")
SwingUtilities.invokeLater {
@ -37,7 +37,7 @@ class AppAppScope : KAppScope, ApplicationScope {
internal actual fun kappImpl(name: String, title: String, content: @Composable KAppScope.() -> Unit) {
val scope = AppAppScope()
scope.apply {
application(exitProcessOnExit = true, content = @Composable { content() })
application(content = @Composable { content() })
}
}

40
components/Kapp/library/src/jsMain/kotlin/org/jetbrains/compose/kapp/KApp.js.kt

@ -0,0 +1,40 @@
package org.jetbrains.compose.kapp
import androidx.compose.runtime.*
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.window.*
import org.jetbrains.skiko.wasm.onWasmReady
@Composable
actual fun KAppScope.Frame(content: @Composable () -> Unit) {
content()
}
internal class AppAppScope : KAppScope {
}
internal actual fun kappImpl(name: String, title: String, content: @Composable KAppScope.() -> Unit) {
// TODO: make it multiframe.
val scope = AppAppScope()
scope.apply {
onWasmReady {
Window(title) {
content()
}
}
}
}
internal actual fun simpleKappImpl(name: String, content: @Composable () -> Unit) {
val appScope = AppAppScope()
appScope.apply {
onWasmReady {
Window(name) {
content()
}
}
}
}

1
components/build.gradle.kts

@ -11,6 +11,7 @@ subprojects {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
// TODO: do we really need it?
plugins.withId("java") {
configureIfExists<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11

2
components/gradle.properties

@ -5,4 +5,4 @@ kotlin.code.style=official
# __KOTLIN_COMPOSE_VERSION__
kotlin.version=1.6.10
# __LATEST_COMPOSE_RELEASE_VERSION__
compose.version=1.1.0-alpha03
compose.version=1.2.0-alpha1-dev578

2900
components/kotlin-js-store/yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save