From 6787ec85de471c343ce53f3cfc01748661c37ebe Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 24 Nov 2021 12:28:41 +0300 Subject: [PATCH] Update kotlin and DF --- build.gradle.kts | 5 ++++- .../space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt | 4 ++-- .../space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt | 5 ++--- demo/js-playground/src/main/kotlin/gravityDemo.kt | 4 ++-- demo/js-playground/src/main/kotlin/markupComponent.kt | 4 ++-- demo/js-playground/src/main/kotlin/plotlyComponent.kt | 2 +- .../jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt | 4 ++-- .../src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt | 2 +- .../kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt | 2 +- .../src/main/kotlin/space/kscience/visionforge/FXPlugin.kt | 4 ++-- .../space/kscience/visionforge/three/server/VisionServer.kt | 3 ++- 11 files changed, 21 insertions(+), 18 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5c776dad..2be9327a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,5 +39,8 @@ apiValidation { //workaround for https://youtrack.jetbrains.com/issue/KT-48273 rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin::class.java) { - rootProject.the().versions.webpackDevServer.version = "4.0.0" + rootProject.the().versions.apply { + webpack.version = "5.64.3" + webpackDevServer.version = "4.5.0" + } } \ No newline at end of file diff --git a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt index ae8b8ac8..156fedb0 100644 --- a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt +++ b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GDMLAppComponent.kt @@ -7,7 +7,7 @@ import kotlinx.css.* import org.w3c.files.File import org.w3c.files.FileReader import org.w3c.files.get -import react.RProps +import react.Props import react.dom.h2 import react.functionComponent import react.useMemo @@ -27,7 +27,7 @@ import space.kscience.visionforge.solid.Solids import styled.css import styled.styledDiv -external interface GDMLAppProps : RProps { +external interface GDMLAppProps : Props { var context: Context var vision: Solid? var selected: Name? diff --git a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt index dc659c7c..74246432 100644 --- a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt +++ b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt @@ -2,9 +2,8 @@ package space.kscience.visionforge.gdml.demo import kotlinx.browser.document import kotlinx.css.* -import react.child import react.dom.render -import space.kscience.dataforge.context.Global +import space.kscience.dataforge.context.Context import space.kscience.gdml.GdmlShowCase import space.kscience.visionforge.Application import space.kscience.visionforge.gdml.toVision @@ -16,7 +15,7 @@ import styled.injectGlobal private class GDMLDemoApp : Application { override fun start(state: Map) { - val context = Global.buildContext("gdml-demo"){ + val context = Context("gdml-demo"){ plugin(ThreePlugin) } diff --git a/demo/js-playground/src/main/kotlin/gravityDemo.kt b/demo/js-playground/src/main/kotlin/gravityDemo.kt index e6f2273a..b2788b23 100644 --- a/demo/js-playground/src/main/kotlin/gravityDemo.kt +++ b/demo/js-playground/src/main/kotlin/gravityDemo.kt @@ -2,7 +2,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import kotlinx.css.* -import react.RProps +import react.Props import react.functionComponent import space.kscience.dataforge.context.Context import space.kscience.plotly.layout @@ -16,7 +16,7 @@ import styled.css import styled.styledDiv import kotlin.math.sqrt -external interface DemoProps : RProps { +external interface DemoProps : Props { var context: Context } diff --git a/demo/js-playground/src/main/kotlin/markupComponent.kt b/demo/js-playground/src/main/kotlin/markupComponent.kt index 52696f8a..0cdb17d0 100644 --- a/demo/js-playground/src/main/kotlin/markupComponent.kt +++ b/demo/js-playground/src/main/kotlin/markupComponent.kt @@ -6,7 +6,7 @@ import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor import org.w3c.dom.Element import org.w3c.dom.HTMLElement -import react.RProps +import react.Props import react.functionComponent import react.useEffect import react.useRef @@ -16,7 +16,7 @@ import space.kscience.visionforge.useProperty import styled.css import styled.styledDiv -external interface MarkupProps : RProps { +external interface MarkupProps : Props { var markup: VisionOfMarkup? } diff --git a/demo/js-playground/src/main/kotlin/plotlyComponent.kt b/demo/js-playground/src/main/kotlin/plotlyComponent.kt index fa73f298..ee896df2 100644 --- a/demo/js-playground/src/main/kotlin/plotlyComponent.kt +++ b/demo/js-playground/src/main/kotlin/plotlyComponent.kt @@ -9,7 +9,7 @@ import space.kscience.plotly.plot import styled.css import styled.styledDiv -external interface PlotlyProps : RProps { +external interface PlotlyProps : Props { var plot: Plot? } diff --git a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt index f4ea0206..30a79315 100644 --- a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt +++ b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMAppComponent.kt @@ -7,7 +7,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.launch import kotlinx.css.* import kotlinx.html.js.onClickFunction -import react.RProps +import react.Props import react.dom.attrs import react.dom.button import react.dom.p @@ -28,7 +28,7 @@ import styled.styledDiv import styled.styledSpan import kotlin.math.PI -external interface MMAppProps : RProps { +external interface MMAppProps : Props { var model: Model var context: Context var connection: HttpClient diff --git a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt index 7cd54417..d62d3b0f 100644 --- a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt +++ b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/Pixel.kt @@ -67,7 +67,7 @@ internal class SC1Aux(val sc: SC1, var efficiency: Double = 1.0) { UPPER_LAYER_Z -> 1 CENTRAL_LAYER_Z -> 2; LOWER_LAYER_Z -> 3; - else -> throw RuntimeException("Unknown layer"); + else -> error("Unknown layer"); } } diff --git a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt index f8d45fd4..cee085bc 100644 --- a/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt +++ b/demo/muon-monitor/src/jvmMain/kotlin/ru/mipt/npm/muon/monitor/sim/simulation.kt @@ -78,6 +78,6 @@ class Cos2TrackGenerator( return makeTrack(x, y, thetaCandidate, phi) } } - throw RuntimeException("Failed to generate theta from distribution") + error("Failed to generate theta from distribution") } } \ No newline at end of file diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt index d8210a13..c571059c 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt @@ -52,12 +52,12 @@ public class FXPlugin(meta: Meta = Meta.EMPTY) : AbstractPlugin(meta) { while (!FX.initialized.get()) { if (Thread.interrupted()) { - throw RuntimeException("Interrupted application start") + error("Interrupted application start") } } Platform.setImplicitExit(false) } else { - throw RuntimeException("FX Application not defined") + error("FX Application not defined") } } } diff --git a/visionforge-server/src/main/kotlin/space/kscience/visionforge/three/server/VisionServer.kt b/visionforge-server/src/main/kotlin/space/kscience/visionforge/three/server/VisionServer.kt index 46cb2e66..b5693aa7 100644 --- a/visionforge-server/src/main/kotlin/space/kscience/visionforge/three/server/VisionServer.kt +++ b/visionforge-server/src/main/kotlin/space/kscience/visionforge/three/server/VisionServer.kt @@ -43,6 +43,7 @@ import java.awt.Desktop import java.net.URI import kotlin.collections.set import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds /** @@ -143,7 +144,7 @@ public class VisionServer internal constructor( try { withContext(visionManager.context.coroutineContext) { - vision.flowChanges(visionManager, Duration.milliseconds(updateInterval)).collect { update -> + vision.flowChanges(visionManager, updateInterval.milliseconds).collect { update -> val json = visionManager.jsonFormat.encodeToString( VisionChange.serializer(), update