diff --git a/build.gradle.kts b/build.gradle.kts index c9ee8e6d..62623756 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { // id("org.jetbrains.kotlinx.kover") version "0.5.0" } -val dataforgeVersion by extra("0.6.0-dev-15") +val dataforgeVersion by extra("0.6.1") val fxVersion by extra("11") allprojects { diff --git a/cern-root-loader/build.gradle.kts b/cern-root-loader/build.gradle.kts index 0ea3de8f..fb787187 100644 --- a/cern-root-loader/build.gradle.kts +++ b/cern-root-loader/build.gradle.kts @@ -3,17 +3,12 @@ plugins { } kscience{ + jvm() + js() + dependencies { + api(projects.visionforgeSolid) + } useSerialization { json() } -} - -kotlin { - sourceSets { - val commonMain by getting { - dependencies { - api(project(":visionforge-solid")) - } - } - } } \ No newline at end of file diff --git a/demo/gdml/build.gradle.kts b/demo/gdml/build.gradle.kts index 69f56419..3ac3960a 100644 --- a/demo/gdml/build.gradle.kts +++ b/demo/gdml/build.gradle.kts @@ -1,62 +1,62 @@ -import space.kscience.gradle.DependencyConfiguration -import space.kscience.gradle.FXModule - plugins { id("space.kscience.gradle.mpp") - application } kscience { - val fxVersion: String by rootProject.extra - useFx(FXModule.CONTROLS, version = fxVersion, configuration = DependencyConfiguration.IMPLEMENTATION) - application() -} - -kotlin { - jvm { - withJava() - } - + jvm() js { useCommonJs() browser { commonWebpackConfig { - cssSupport{ + cssSupport { enabled.set(false) } } } } - - sourceSets { - commonMain { - dependencies { - implementation(project(":visionforge-solid")) - implementation(project(":visionforge-gdml")) - } - } - jvmMain { - dependencies { - implementation(project(":visionforge-fx")) - implementation("ch.qos.logback:logback-classic:1.2.11") - } - } - jsMain { - dependencies { - implementation(project(":ui:ring")) - implementation(project(":visionforge-threejs")) - implementation(npm("react-file-drop", "3.0.6")) - } - } + dependencies { + implementation(projects.visionforgeSolid) + implementation(projects.visionforgeGdml) } + jvmMain { +// implementation(project(":visionforge-fx")) + implementation(spclibs.logback.classic) + } + jsMain { + implementation(projects.ui.ring) + implementation(projects.visionforgeThreejs) + implementation(npm("react-file-drop", "3.0.6")) + } + application() } -application { - mainClass.set("space.kscience.visionforge.gdml.demo.GdmlFxDemoAppKt") -} +//kotlin { +// +// sourceSets { +// commonMain { +// dependencies { +// implementation(project(":visionforge-solid")) +// implementation(project(":visionforge-gdml")) +// } +// } +// jvmMain { +// dependencies { +//// implementation(project(":visionforge-fx")) +// implementation("ch.qos.logback:logback-classic:1.2.11") +// } +// } +// jsMain { +// dependencies { +// implementation(project(":ui:ring")) +// implementation(project(":visionforge-threejs")) +// implementation(npm("react-file-drop", "3.0.6")) +// } +// } +// } +//} -val convertGdmlToJson by tasks.creating(JavaExec::class) { - group = "application" - classpath = sourceSets["main"].runtimeClasspath - mainClass.set("space.kscience.dataforge.vis.spatial.gdml.demo.SaveToJsonKt") -} \ No newline at end of file +//val convertGdmlToJson by tasks.creating(JavaExec::class) { +// group = "application" +// classpath = sourceSets["main"].runtimeClasspath +// mainClass.set("space.kscience.dataforge.vis.spatial.gdml.demo.SaveToJsonKt") +//} \ No newline at end of file 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 5f1d24e1..cdca1957 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 @@ -3,7 +3,7 @@ package space.kscience.visionforge.gdml.demo import kotlinx.css.* import org.w3c.dom.Document import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.gdml.GdmlShowCase import space.kscience.visionforge.Application import space.kscience.visionforge.Colors @@ -54,7 +54,7 @@ private class GDMLDemoApp : Application { } //println(context.plugins.fetch(VisionManager).encodeToString(vision)) attrs { - this.solids = context.fetch(Solids) + this.solids = context.request(Solids) this.vision = vision } } diff --git a/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt b/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt index 83e750ba..92cc69aa 100644 --- a/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt +++ b/demo/gdml/src/jvmMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlFxDemoApp.kt @@ -1,83 +1,83 @@ -package space.kscience.visionforge.gdml.demo - -import javafx.geometry.Orientation -import javafx.scene.Parent -import javafx.stage.FileChooser -import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.fetch -import space.kscience.gdml.GdmlShowCase -import space.kscience.visionforge.VisionManager -import space.kscience.visionforge.editor.VisionEditorFragment -import space.kscience.visionforge.editor.VisionTreeFragment -import space.kscience.visionforge.gdml.toVision -import space.kscience.visionforge.solid.FX3DPlugin -import space.kscience.visionforge.solid.FXCanvas3D -import space.kscience.visionforge.solid.Solid -import space.kscience.visionforge.solid.SolidMaterial -import tornadofx.* - -class GDMLDemoApp : App(GDMLView::class) - -class GDMLView : View() { - private val context = Context { - plugin(FX3DPlugin) - } - - private val fx3d = context.fetch(FX3DPlugin) - private val visionManager = context.fetch(VisionManager) - private val canvas = FXCanvas3D(fx3d) - - private val treeFragment = VisionTreeFragment().apply { - this.itemProperty.bind(canvas.rootObjectProperty) - } - - private val propertyEditor = VisionEditorFragment().apply { - descriptorProperty.set(SolidMaterial.descriptor) - visionProperty.bind(treeFragment.selectedProperty) - } - - override val root: Parent = borderpane { - top { - buttonbar { - button("Load GDML/json") { - action { - val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull() - if (file != null) { - runAsync { - visionManager.readFile(file) as Solid - } ui { - canvas.render(it) - } - } - } - } - } - } - center { - splitpane(Orientation.HORIZONTAL, treeFragment.root, canvas.root, propertyEditor.root) { - setDividerPositions(0.2, 0.6, 0.2) - } - } - } - - init { - runAsync { - GdmlShowCase.cubes().toVision() - } ui { - canvas.render(it) - } - } - - companion object { - private val fileNameFilter = arrayOf( - FileChooser.ExtensionFilter("GDML", "*.gdml", "*.xml"), - FileChooser.ExtensionFilter("JSON", "*.json"), - FileChooser.ExtensionFilter("JSON.ZIP", "*.json.zip"), - FileChooser.ExtensionFilter("JSON.GZ", "*.json.gz") - ) - } -} - -fun main() { - launch() -} \ No newline at end of file +//package space.kscience.visionforge.gdml.demo +// +//import javafx.geometry.Orientation +//import javafx.scene.Parent +//import javafx.stage.FileChooser +//import space.kscience.dataforge.context.Context +//import space.kscience.dataforge.context.fetch +//import space.kscience.gdml.GdmlShowCase +//import space.kscience.visionforge.VisionManager +//import space.kscience.visionforge.editor.VisionEditorFragment +//import space.kscience.visionforge.editor.VisionTreeFragment +//import space.kscience.visionforge.gdml.toVision +//import space.kscience.visionforge.solid.FX3DPlugin +//import space.kscience.visionforge.solid.FXCanvas3D +//import space.kscience.visionforge.solid.Solid +//import space.kscience.visionforge.solid.SolidMaterial +//import tornadofx.* +// +//class GDMLDemoApp : App(GDMLView::class) +// +//class GDMLView : View() { +// private val context = Context { +// plugin(FX3DPlugin) +// } +// +// private val fx3d = context.fetch(FX3DPlugin) +// private val visionManager = context.fetch(VisionManager) +// private val canvas = FXCanvas3D(fx3d) +// +// private val treeFragment = VisionTreeFragment().apply { +// this.itemProperty.bind(canvas.rootObjectProperty) +// } +// +// private val propertyEditor = VisionEditorFragment().apply { +// descriptorProperty.set(SolidMaterial.descriptor) +// visionProperty.bind(treeFragment.selectedProperty) +// } +// +// override val root: Parent = borderpane { +// top { +// buttonbar { +// button("Load GDML/json") { +// action { +// val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull() +// if (file != null) { +// runAsync { +// visionManager.readFile(file) as Solid +// } ui { +// canvas.render(it) +// } +// } +// } +// } +// } +// } +// center { +// splitpane(Orientation.HORIZONTAL, treeFragment.root, canvas.root, propertyEditor.root) { +// setDividerPositions(0.2, 0.6, 0.2) +// } +// } +// } +// +// init { +// runAsync { +// GdmlShowCase.cubes().toVision() +// } ui { +// canvas.render(it) +// } +// } +// +// companion object { +// private val fileNameFilter = arrayOf( +// FileChooser.ExtensionFilter("GDML", "*.gdml", "*.xml"), +// FileChooser.ExtensionFilter("JSON", "*.json"), +// FileChooser.ExtensionFilter("JSON.ZIP", "*.json.zip"), +// FileChooser.ExtensionFilter("JSON.GZ", "*.json.gz") +// ) +// } +//} +// +//fun main() { +// launch() +//} \ No newline at end of file diff --git a/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt b/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt index 781aa897..cb6eb3e6 100644 --- a/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt +++ b/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt @@ -3,7 +3,7 @@ import org.w3c.dom.Document import ringui.SmartTabs import ringui.Tab import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.plotly.models.Trace import space.kscience.plotly.scatter import space.kscience.visionforge.Application @@ -52,7 +52,7 @@ private class JsPlaygroundApp : Application { Tab("gravity") { GravityDemo { attrs { - this.solids = playgroundContext.fetch(Solids) + this.solids = playgroundContext.request(Solids) } } } @@ -73,7 +73,7 @@ private class JsPlaygroundApp : Application { child(ThreeCanvasWithControls) { val random = Random(112233) attrs { - solids = playgroundContext.fetch(Solids) + solids = playgroundContext.request(Solids) solid { ambientLight { color.set(Colors.white) diff --git a/demo/js-playground/src/main/kotlin/plotlyComponent.kt b/demo/js-playground/src/main/kotlin/plotlyComponent.kt index 5a2c6a81..322e80c5 100644 --- a/demo/js-playground/src/main/kotlin/plotlyComponent.kt +++ b/demo/js-playground/src/main/kotlin/plotlyComponent.kt @@ -20,9 +20,9 @@ val Plotly = fc("Plotly") { props -> useEffect(props.plot, elementRef) { val element = elementRef.current as? HTMLElement ?: error("Plotly element not found") props.plot?.let { - element.plot(it, PlotlyConfig { + element.plot(PlotlyConfig { responsive = true - }) + }, it) } } diff --git a/demo/muon-monitor/build.gradle.kts b/demo/muon-monitor/build.gradle.kts index f25c8371..3d814223 100644 --- a/demo/muon-monitor/build.gradle.kts +++ b/demo/muon-monitor/build.gradle.kts @@ -5,74 +5,46 @@ plugins { group = "ru.mipt.npm" -val ktorVersion: String = npmlibs.versions.ktor.get() +val ktorVersion: String = spclibs.versions.ktor.get() kscience { useCoroutines() useSerialization() + useKtor() + fullStack( + "muon-monitor.js", + jvmConfig = { withJava() }, + jsConfig = { useCommonJs() } + ) { + commonWebpackConfig { + cssSupport { + enabled.set(false) + } + } + } + + commonMain { + implementation(projects.visionforgeSolid) + } + jvmMain { + implementation("org.apache.commons:commons-math3:3.6.1") + implementation("io.ktor:ktor-server-cio:${ktorVersion}") + implementation("io.ktor:ktor-server-content-negotiation:${ktorVersion}") + implementation("io.ktor:ktor-serialization-kotlinx-json:${ktorVersion}") + implementation("ch.qos.logback:logback-classic:1.2.11") + } + jsMain { + implementation(project(":ui:ring")) + implementation(project(":visionforge-threejs")) + //implementation(devNpm("webpack-bundle-analyzer", "4.4.0")) + } application() } -kotlin { - jvm { - withJava() - } - js { - useCommonJs() - browser { - commonWebpackConfig { - cssSupport { - enabled.set(false) - } - } - } - } - - sourceSets { - commonMain { - dependencies { - implementation(project(":visionforge-solid")) - } - } - jvmMain { - dependencies { - implementation("org.apache.commons:commons-math3:3.6.1") - implementation("io.ktor:ktor-server-cio:${ktorVersion}") - implementation("io.ktor:ktor-server-content-negotiation:${ktorVersion}") - implementation("io.ktor:ktor-serialization-kotlinx-json:${ktorVersion}") - implementation("ch.qos.logback:logback-classic:1.2.11") - } - } - jsMain { - dependencies { - implementation(project(":ui:ring")) - implementation(project(":visionforge-threejs")) - //implementation(devNpm("webpack-bundle-analyzer", "4.4.0")) - } - } - } -} - application { mainClass.set("ru.mipt.npm.muon.monitor.server.MMServerKt") } -val jsBrowserDistribution by tasks.getting -val jsBrowserDevelopmentExecutableDistribution by tasks.getting - -val devMode = rootProject.findProperty("visionforge.development") as? Boolean - ?: rootProject.version.toString().contains("dev") - -tasks.getByName("jvmProcessResources") { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - if (devMode) { - dependsOn(jsBrowserDevelopmentExecutableDistribution) - from(jsBrowserDevelopmentExecutableDistribution) - } else { - dependsOn(jsBrowserDistribution) - from(jsBrowserDistribution) - } -} //distributions { // main { diff --git a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt index d28516d0..afc9ce80 100644 --- a/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt +++ b/demo/muon-monitor/src/jsMain/kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt @@ -2,7 +2,7 @@ package ru.mipt.npm.muon.monitor import org.w3c.dom.Document import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.visionforge.Application import space.kscience.visionforge.VisionManager import space.kscience.visionforge.react.createRoot @@ -19,7 +19,7 @@ private class MMDemoApp : Application { plugin(ThreePlugin) } - val visionManager = context.fetch(VisionManager) + val visionManager = context.request(VisionManager) val model = Model(visionManager) @@ -28,7 +28,7 @@ private class MMDemoApp : Application { child(MMApp) { attrs { this.model = model - this.solids = context.fetch(Solids) + this.solids = context.request(Solids) } } } diff --git a/demo/playground/build.gradle.kts b/demo/playground/build.gradle.kts index 57c6bfd2..fbc0b736 100644 --- a/demo/playground/build.gradle.kts +++ b/demo/playground/build.gradle.kts @@ -29,7 +29,6 @@ kotlin { } jvm { - withJava() compilations.all { kotlinOptions { jvmTarget = "11" diff --git a/demo/playground/src/jvmMain/kotlin/formServer.kt b/demo/playground/src/jvmMain/kotlin/formServer.kt index 461262a5..2f5b4ea1 100644 --- a/demo/playground/src/jvmMain/kotlin/formServer.kt +++ b/demo/playground/src/jvmMain/kotlin/formServer.kt @@ -6,7 +6,7 @@ import io.ktor.server.http.content.resources import io.ktor.server.routing.routing import kotlinx.html.* import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.visionforge.VisionManager import space.kscience.visionforge.html.VisionOfHtmlForm import space.kscience.visionforge.html.VisionPage @@ -18,7 +18,7 @@ import space.kscience.visionforge.server.openInBrowser import space.kscience.visionforge.server.visionPage fun main() { - val visionManager = Global.fetch(VisionManager) + val visionManager = Global.request(VisionManager) val connector = EngineConnectorConfig("localhost", 7777) diff --git a/demo/playground/src/jvmMain/kotlin/generateSchema.kt b/demo/playground/src/jvmMain/kotlin/generateSchema.kt index 8331ac62..672cd0b3 100644 --- a/demo/playground/src/jvmMain/kotlin/generateSchema.kt +++ b/demo/playground/src/jvmMain/kotlin/generateSchema.kt @@ -6,6 +6,7 @@ import kotlinx.serialization.json.Json import space.kscience.visionforge.solid.SolidGroup import space.kscience.visionforge.solid.Solids +@OptIn(ExperimentalSerializationApi::class) private val json = Json { serializersModule = Solids.serializersModuleForSolids prettyPrintIndent = " " diff --git a/demo/sat-demo/build.gradle.kts b/demo/sat-demo/build.gradle.kts index 406591ee..1b37bfad 100644 --- a/demo/sat-demo/build.gradle.kts +++ b/demo/sat-demo/build.gradle.kts @@ -9,15 +9,14 @@ kscience { // json() // } application() + dependencies{ + implementation(projects.visionforgeThreejs.visionforgeThreejsServer) + implementation("ch.qos.logback:logback-classic:1.4.5") + } } group = "ru.mipt.npm" -dependencies{ - implementation(project(":visionforge-threejs:visionforge-threejs-server")) - implementation("ch.qos.logback:logback-classic:1.4.5") -} - application { mainClass.set("ru.mipt.npm.sat.SatServerKt") } diff --git a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt b/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt index ed8ae38f..d2c33c2c 100644 --- a/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt +++ b/demo/sat-demo/src/main/kotlin/ru/mipt/npm/sat/satServer.kt @@ -10,7 +10,7 @@ import kotlinx.coroutines.* import kotlinx.html.div import kotlinx.html.h1 import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.dataforge.meta.Null import space.kscience.dataforge.names.Name import space.kscience.visionforge.Colors @@ -29,7 +29,7 @@ fun main() { plugin(Solids) } - val solids = satContext.fetch(Solids) + val solids = satContext.request(Solids) //Create a geometry val sat = solids.visionOfSatellite(ySegments = 3).apply { diff --git a/demo/solid-showcase/build.gradle.kts b/demo/solid-showcase/build.gradle.kts index 2da1299f..0a53b4e2 100644 --- a/demo/solid-showcase/build.gradle.kts +++ b/demo/solid-showcase/build.gradle.kts @@ -1,6 +1,3 @@ -import space.kscience.gradle.DependencyConfiguration -import space.kscience.gradle.FXModule - plugins { id("space.kscience.gradle.mpp") application @@ -8,34 +5,18 @@ plugins { kscience { useCoroutines() - val fxVersion: String by rootProject.extra - useFx(FXModule.CONTROLS, version = fxVersion, configuration = DependencyConfiguration.IMPLEMENTATION) application() -} - -kotlin { - jvm { withJava() } + js() + dependencies { + implementation(projects.visionforgeSolid) + implementation(projects.visionforgeGdml) + } - sourceSets { - commonMain { - dependencies { - implementation(project(":visionforge-solid")) -// implementation(project(":visionforge-gdml")) - } - } - jvmMain { - dependencies { - implementation(project(":visionforge-fx")) - } - } - jsMain { - dependencies { - implementation(project(":visionforge-threejs")) - } - } + jsMain { + implementation(projects.visionforgeThreejs) } } diff --git a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt index d448349c..50e7f174 100644 --- a/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt +++ b/demo/solid-showcase/src/jsMain/kotlin/space/kscience/visionforge/solid/demo/ThreeDemoGrid.kt @@ -10,7 +10,7 @@ import org.w3c.dom.Element import org.w3c.dom.HTMLDivElement import org.w3c.dom.HTMLElement import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.string @@ -26,7 +26,7 @@ class ThreeDemoGrid(element: Element) : VisionLayout { private val outputs: MutableMap = HashMap() - private val three = Global.fetch(ThreePlugin) + private val three = Global.request(ThreePlugin) override val solids: Solids get() = three.solids diff --git a/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoApp.kt b/demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoApp.kt similarity index 100% rename from demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoApp.kt rename to demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoApp.kt diff --git a/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt b/demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt similarity index 100% rename from demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt rename to demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/FXDemoGrid.kt diff --git a/demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt b/demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt similarity index 100% rename from demo/solid-showcase/src/jvmMain/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt rename to demo/solid-showcase/src/jvmMain-fx/kotlin/space/kscience/visionforge/solid/demo/MetaEditorDemo.kt diff --git a/gradle.properties b/gradle.properties index b80e2265..11c3aafa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,9 @@ kotlin.code.style=official kotlin.mpp.stability.nowarn=true +kotlin.js.compiler=ir kotlin.incremental.js.ir=true org.gradle.parallel=true org.gradle.jvmargs=-Xmx4G -toolsVersion=0.13.4-kotlin-1.8.0 \ No newline at end of file +toolsVersion=0.14.7-kotlin-1.8.20 \ No newline at end of file diff --git a/jupyter/build.gradle.kts b/jupyter/build.gradle.kts index 45aaeaa3..5808f287 100644 --- a/jupyter/build.gradle.kts +++ b/jupyter/build.gradle.kts @@ -1,25 +1,22 @@ plugins { id("space.kscience.gradle.mpp") - id("org.jetbrains.kotlin.jupyter.api") } description = "Common visionforge jupyter module" -kotlin { - sourceSets { - commonMain{ - dependencies{ - api(projects.visionforgeCore) - } - } - jvmMain { - dependencies { - api(projects.visionforgeServer) - } - } +kscience { + jvm() + js() + jupyterLibrary() + dependencies { + api(projects.visionforgeCore) + } + dependencies(jvmMain){ + api(projects.visionforgeServer) } } + readme { maturity = space.kscience.gradle.Maturity.EXPERIMENTAL } \ No newline at end of file diff --git a/jupyter/src/jsMain/kotlin/VFNotebookPlugin.kt b/jupyter/src/jsMain/kotlin/VFNotebookPlugin.kt index c13586ba..f6a37f23 100644 --- a/jupyter/src/jsMain/kotlin/VFNotebookPlugin.kt +++ b/jupyter/src/jsMain/kotlin/VFNotebookPlugin.kt @@ -11,7 +11,6 @@ import space.kscience.visionforge.VisionClient import space.kscience.visionforge.renderAllVisions import space.kscience.visionforge.renderAllVisionsById import space.kscience.visionforge.renderAllVisionsIn -import kotlin.reflect.KClass @JsExport public class VFNotebookPlugin : AbstractPlugin() { @@ -44,8 +43,6 @@ public class VFNotebookPlugin : AbstractPlugin() { override fun build(context: Context, meta: Meta): VFNotebookPlugin = VFNotebookPlugin() override val tag: PluginTag = PluginTag(name = "vision.notebook", group = PluginTag.DATAFORGE_GROUP) - - override val type: KClass = VFNotebookPlugin::class } } \ No newline at end of file diff --git a/jupyter/src/jvmMain/kotlin/VFForNotebook.kt b/jupyter/src/jvmMain/kotlin/VFForNotebook.kt index eb61f889..50619e44 100644 --- a/jupyter/src/jvmMain/kotlin/VFForNotebook.kt +++ b/jupyter/src/jvmMain/kotlin/VFForNotebook.kt @@ -4,7 +4,6 @@ import io.ktor.http.URLProtocol import io.ktor.server.application.install import io.ktor.server.cio.CIO import io.ktor.server.engine.ApplicationEngine -import io.ktor.server.engine.EngineConnectorConfig import io.ktor.server.engine.embeddedServer import io.ktor.server.util.url import io.ktor.server.websocket.WebSockets @@ -25,7 +24,6 @@ import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionManager import space.kscience.visionforge.html.HtmlVisionFragment import space.kscience.visionforge.html.visionFragment -import space.kscience.visionforge.server.EngineConnectorConfig import space.kscience.visionforge.server.VisionRoute import space.kscience.visionforge.server.serveVisionData import space.kscience.visionforge.visionManager @@ -74,7 +72,7 @@ public class VFForNotebook(override val context: Context) : ContextAware, Corout } } - val connector: EngineConnectorConfig = EngineConnectorConfig(host, port) + //val connector: EngineConnectorConfig = EngineConnectorConfig(host, port) engine?.stop(1000, 2000) engine = context.embeddedServer(CIO, port, host) { diff --git a/jupyter/visionforge-jupyter-gdml/build.gradle.kts b/jupyter/visionforge-jupyter-gdml/build.gradle.kts index 1198f022..5a67459e 100644 --- a/jupyter/visionforge-jupyter-gdml/build.gradle.kts +++ b/jupyter/visionforge-jupyter-gdml/build.gradle.kts @@ -4,56 +4,32 @@ plugins { description = "Jupyter api artifact for GDML rendering" -kotlin { - explicitApi = null - js { - useCommonJs() - browser { - webpackTask { - this.outputFileName = "js/gdml-jupyter.js" - } - commonWebpackConfig { - sourceMaps = false - cssSupport{ - enabled.set(false) - } - } - } - binaries.executable() - } - - afterEvaluate { - val jsBrowserDistribution by tasks.getting - - tasks.getByName("jvmProcessResources") { - dependsOn(jsBrowserDistribution) - from(jsBrowserDistribution) - } - } - - sourceSets { - commonMain { - dependencies { - implementation(projects.visionforgeSolid) - implementation(projects.jupyter) - } - } - jvmMain { - dependencies { - implementation(projects.visionforgeGdml) - } - } - jsMain { - dependencies { - implementation(projects.visionforgeThreejs) - implementation(projects.ui.ring) - } - } - - } -} - kscience { + fullStack("js/gdml-jupyter.js", + jsConfig = { useCommonJs() } + ) { + commonWebpackConfig { + sourceMaps = false + cssSupport { + enabled.set(false) + } + } + } + + dependencies{ + implementation(projects.visionforgeSolid) + implementation(projects.jupyter) + } + + dependencies(jvmMain){ + implementation(projects.visionforgeGdml) + } + + dependencies(jsMain){ + implementation(projects.visionforgeThreejs) + implementation(projects.ui.ring) + } + jupyterLibrary("space.kscience.visionforge.gdml.jupyter.GdmlForJupyter") } diff --git a/jupyter/visionforge-jupyter-gdml/src/jsMain/kotlin/gdmlJupyter.kt b/jupyter/visionforge-jupyter-gdml/src/jsMain/kotlin/gdmlJupyter.kt index fef274a2..d4ee507e 100644 --- a/jupyter/visionforge-jupyter-gdml/src/jsMain/kotlin/gdmlJupyter.kt +++ b/jupyter/visionforge-jupyter-gdml/src/jsMain/kotlin/gdmlJupyter.kt @@ -6,7 +6,7 @@ import space.kscience.visionforge.runVisionClient @DFExperimental @JsExport -fun main(): Unit = runVisionClient { +public fun main(): Unit = runVisionClient { plugin(ThreeWithControlsPlugin) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 9bdf544a..b9d8bf5b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -34,7 +34,7 @@ dependencyResolutionManagement { } versionCatalogs { - create("npmlibs") { + create("spclibs") { from("space.kscience:version-catalog:$toolsVersion") } } @@ -48,7 +48,7 @@ include( ":ui:bootstrap", ":visionforge-core", ":visionforge-solid", - ":visionforge-fx", +// ":visionforge-fx", ":visionforge-threejs", ":visionforge-threejs:visionforge-threejs-server", ":visionforge-gdml", @@ -62,7 +62,7 @@ include( ":demo:muon-monitor", ":demo:sat-demo", ":demo:playground", - ":demo:plotly-fx", +// ":demo:plotly-fx", ":demo:js-playground", ":jupyter", ":jupyter:visionforge-jupyter-gdml" diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt index 4683f579..50c8a60a 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/ThreeCanvasComponent.kt @@ -5,7 +5,7 @@ import org.w3c.dom.Element import org.w3c.dom.HTMLElement import react.* import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.dataforge.names.Name import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.specifications.Canvas3DOptions @@ -25,7 +25,7 @@ public val ThreeCanvasComponent: FC = fc("ThreeCanvasComponent val elementRef = useRef(null) var canvas by useState(null) - val three: ThreePlugin = useMemo(props.context) { props.context.fetch(ThreePlugin) } + val three: ThreePlugin = useMemo(props.context) { props.context.request(ThreePlugin) } useEffect(props.solid, props.options, elementRef) { if (canvas == null) { diff --git a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt index 60f36fb0..dd7f8e0d 100644 --- a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt +++ b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ThreeWithControlsPlugin.kt @@ -14,7 +14,6 @@ import space.kscience.visionforge.Vision import space.kscience.visionforge.react.render import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.three.ThreePlugin -import kotlin.reflect.KClass public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer { public val three: ThreePlugin by require(ThreePlugin) @@ -44,7 +43,6 @@ public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.threejs.withControls", PluginTag.DATAFORGE_GROUP) - override val type: KClass = ThreeWithControlsPlugin::class override fun build(context: Context, meta: Meta): ThreeWithControlsPlugin = ThreeWithControlsPlugin() } diff --git a/visionforge-core/build.gradle.kts b/visionforge-core/build.gradle.kts index 6a170d02..505ff3be 100644 --- a/visionforge-core/build.gradle.kts +++ b/visionforge-core/build.gradle.kts @@ -4,29 +4,20 @@ plugins { val dataforgeVersion: String by rootProject.extra -kotlin { - sourceSets { - commonMain { - dependencies { - api("space.kscience:dataforge-context:$dataforgeVersion") - api("org.jetbrains.kotlinx:kotlinx-html:0.8.0") - api("org.jetbrains.kotlin-wrappers:kotlin-css") - } - } - commonTest{ - dependencies{ - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${space.kscience.gradle.KScienceVersions.coroutinesVersion}") - } - } - jsMain { - dependencies { - api("org.jetbrains.kotlin-wrappers:kotlin-extensions") - } - } - } -} - kscience{ + jvm() + js() + dependencies { + api("space.kscience:dataforge-context:$dataforgeVersion") + api(spclibs.kotlinx.html) + api("org.jetbrains.kotlin-wrappers:kotlin-css") + } + testDependencies { + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${space.kscience.gradle.KScienceVersions.coroutinesVersion}") + } + dependencies(jsMain){ + api("org.jetbrains.kotlin-wrappers:kotlin-extensions") + } useSerialization{ json() } diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt index 4e64f63a..46266988 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt @@ -17,7 +17,6 @@ import space.kscience.visionforge.html.VisionOfCheckbox import space.kscience.visionforge.html.VisionOfHtmlForm import space.kscience.visionforge.html.VisionOfNumberField import space.kscience.visionforge.html.VisionOfTextField -import kotlin.reflect.KClass public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionContainer { override val tag: PluginTag get() = Companion.tag @@ -64,7 +63,6 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont public companion object : PluginFactory { override val tag: PluginTag = PluginTag(name = "vision", group = PluginTag.DATAFORGE_GROUP) - override val type: KClass = VisionManager::class public const val VISION_SERIALIZER_MODULE_TARGET: String = "visionSerializerModule" @@ -110,7 +108,7 @@ public abstract class VisionPlugin(meta: Meta = Meta.EMPTY) : AbstractPlugin(met /** * Fetch a [VisionManager] from this plugin or create a child plugin with a [VisionManager] */ -public val Context.visionManager: VisionManager get() = fetch(VisionManager) +public val Context.visionManager: VisionManager get() = request(VisionManager ) public fun Vision.encodeToString(): String = manager?.encodeToString(this) ?: error("Orphan vision could not be encoded") diff --git a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt index 08497a57..7b7cdd31 100644 --- a/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt +++ b/visionforge-core/src/commonTest/kotlin/space/kscience/visionforge/meta/VisionPropertyTest.kt @@ -1,12 +1,15 @@ package space.kscience.visionforge.meta -import kotlinx.coroutines.* +import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.toList +import kotlinx.coroutines.launch import kotlinx.coroutines.test.runTest import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.dataforge.meta.* import space.kscience.visionforge.* import kotlin.test.Test @@ -23,7 +26,7 @@ private class TestScheme : Scheme() { @OptIn(ExperimentalCoroutinesApi::class) internal class VisionPropertyTest { - private val manager = Global.fetch(VisionManager) + private val manager = Global.request(VisionManager) @Test fun testPropertyWrite() { @@ -56,7 +59,7 @@ internal class VisionPropertyTest { @Test fun testChildrenPropertyPropagation() = runTest(dispatchTimeoutMs = 200) { - val group = Global.fetch(VisionManager).group { + val group = Global.request(VisionManager).group { properties { "test" put 11 } @@ -91,7 +94,7 @@ internal class VisionPropertyTest { @Test fun testChildrenPropertyFlow() = runTest(dispatchTimeoutMs = 200) { - val group = Global.fetch(VisionManager).group { + val group = Global.request(VisionManager).group { properties { "test" put 11 diff --git a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt index 6f322268..e87f01fa 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt @@ -21,7 +21,6 @@ import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_ENDPOI import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_FETCH_ATTRIBUTE import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_NAME_ATTRIBUTE import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_RENDERED -import kotlin.reflect.KClass import kotlin.time.Duration.Companion.milliseconds /** @@ -227,15 +226,13 @@ public class VisionClient : AbstractPlugin() { numberVisionRenderer(this), textVisionRenderer(this), formVisionRenderer(this) - ).toMap() + ).associateByName() } else super.content(target) public companion object : PluginFactory { override fun build(context: Context, meta: Meta): VisionClient = VisionClient() override val tag: PluginTag = PluginTag(name = "vision.client", group = PluginTag.DATAFORGE_GROUP) - - override val type: KClass = VisionClient::class } } @@ -296,7 +293,7 @@ public fun VisionClient.renderAllVisions(): Unit = whenDocumentLoaded { } public class VisionClientApplication(public val context: Context) : Application { - private val client = context.fetch(VisionClient) + private val client = context.request(VisionClient) override fun start(document: Document, state: Map) { context.logger.info { diff --git a/visionforge-gdml/build.gradle.kts b/visionforge-gdml/build.gradle.kts index 345445da..494e648e 100644 --- a/visionforge-gdml/build.gradle.kts +++ b/visionforge-gdml/build.gradle.kts @@ -2,21 +2,16 @@ plugins { id("space.kscience.gradle.mpp") } -kotlin { - js(IR){ +kscience { + jvm() + js { binaries.library() } - sourceSets { - commonMain{ - dependencies { - api(projects.visionforgeSolid) - api("space.kscience:gdml:0.4.0") - } - } - jvmTest{ - dependencies{ - implementation("ch.qos.logback:logback-classic:1.2.11") - } - } + dependencies { + api(projects.visionforgeSolid) + api("space.kscience:gdml:0.4.0") + } + dependencies(jvmTest) { + implementation("ch.qos.logback:logback-classic:1.2.11") } } \ No newline at end of file diff --git a/visionforge-markdown/build.gradle.kts b/visionforge-markdown/build.gradle.kts index 2909ab6d..502e2196 100644 --- a/visionforge-markdown/build.gradle.kts +++ b/visionforge-markdown/build.gradle.kts @@ -5,20 +5,13 @@ plugins { val markdownVersion = "0.2.4" kscience { - useSerialization() -} - -kotlin { + jvm() js { binaries.library() } - - sourceSets { - commonMain { - dependencies { - api(project(":visionforge-core")) - api("org.jetbrains:markdown:$markdownVersion") - } - } + dependencies { + api(project(":visionforge-core")) + api("org.jetbrains:markdown:$markdownVersion") } + useSerialization() } \ No newline at end of file diff --git a/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt b/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt index ba960eae..08705c27 100644 --- a/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt +++ b/visionforge-markdown/src/jsMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt @@ -15,7 +15,6 @@ import space.kscience.dataforge.names.Name import space.kscience.visionforge.* import space.kscience.visionforge.markup.VisionOfMarkup.Companion.COMMONMARK_FORMAT import space.kscience.visionforge.markup.VisionOfMarkup.Companion.GFM_FORMAT -import kotlin.reflect.KClass public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { public val visionClient: VisionClient by require(VisionClient) @@ -47,7 +46,6 @@ public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.markup", PluginTag.DATAFORGE_GROUP) - override val type: KClass = MarkupPlugin::class override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() diff --git a/visionforge-markdown/src/jvmMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt b/visionforge-markdown/src/jvmMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt index 211064ff..de71725c 100644 --- a/visionforge-markdown/src/jvmMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt +++ b/visionforge-markdown/src/jvmMain/kotlin/space/kscience/visionforge/markup/MarkupPlugin.kt @@ -6,7 +6,6 @@ import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta import space.kscience.visionforge.VisionPlugin -import kotlin.reflect.KClass public actual class MarkupPlugin : VisionPlugin() { override val visionSerializersModule: SerializersModule get() = markupSerializersModule @@ -16,8 +15,6 @@ public actual class MarkupPlugin : VisionPlugin() { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.plotly", PluginTag.DATAFORGE_GROUP) - override val type: KClass = MarkupPlugin::class - override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() } diff --git a/visionforge-plotly/build.gradle.kts b/visionforge-plotly/build.gradle.kts index 919dde07..56402f14 100644 --- a/visionforge-plotly/build.gradle.kts +++ b/visionforge-plotly/build.gradle.kts @@ -2,23 +2,16 @@ plugins { id("space.kscience.gradle.mpp") } -val plotlyVersion = "0.5.3-dev-1" +val plotlyVersion = "0.5.3" kscience { - useSerialization() -} - -kotlin { + jvm() js { binaries.library() } - - sourceSets { - commonMain { - dependencies { - api(project(":visionforge-core")) - api("space.kscience:plotlykt-core:${plotlyVersion}") - } - } + dependencies { + api(project(":visionforge-core")) + api("space.kscience:plotlykt-core:${plotlyVersion}") } + useSerialization() } \ No newline at end of file diff --git a/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt b/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt index 8344e52e..91518f34 100644 --- a/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt +++ b/visionforge-plotly/src/jsMain/kotlin/space/kscience/visionforge/plotly/plotlyJs.kt @@ -14,7 +14,6 @@ import space.kscience.visionforge.ElementVisionRenderer import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionClient import space.kscience.visionforge.VisionPlugin -import kotlin.reflect.KClass public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer { public val visionClient: VisionClient by require(VisionClient) @@ -31,7 +30,7 @@ public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer { override fun render(element: Element, name: Name, vision: Vision, meta: Meta) { val plot = (vision as? VisionOfPlotly)?.plot ?: error("VisionOfPlotly expected but ${vision::class} found") val config = PlotlyConfig.read(meta) - element.plot(plot, config) + element.plot(config, plot) } override fun content(target: String): Map = when (target) { @@ -41,7 +40,6 @@ public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer { public actual companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.plotly.js", PluginTag.DATAFORGE_GROUP) - override val type: KClass = PlotlyPlugin::class override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin() diff --git a/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyJvm.kt b/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyJvm.kt index 8fda1d98..b9a8d373 100644 --- a/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyJvm.kt +++ b/visionforge-plotly/src/jvmMain/kotlin/space/kscience/visionforge/plotly/plotlyJvm.kt @@ -6,7 +6,6 @@ import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta import space.kscience.visionforge.VisionPlugin -import kotlin.reflect.KClass public actual class PlotlyPlugin : VisionPlugin() { @@ -16,7 +15,6 @@ public actual class PlotlyPlugin : VisionPlugin() { public actual companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.plotly", PluginTag.DATAFORGE_GROUP) - override val type: KClass = PlotlyPlugin::class override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin() diff --git a/visionforge-server/build.gradle.kts b/visionforge-server/build.gradle.kts index 236dda78..a4a7d848 100644 --- a/visionforge-server/build.gradle.kts +++ b/visionforge-server/build.gradle.kts @@ -2,12 +2,14 @@ plugins { id("space.kscience.gradle.jvm") } -val ktorVersion = npmlibs.versions.ktor.get() +kscience{ + useKtor() + dependencies { + api(projects.visionforgeCore) + api("io.ktor:ktor-server-cio") + api("io.ktor:ktor-server-html-builder") + api("io.ktor:ktor-server-websockets") + implementation("io.ktor:ktor-server-cors") + } +} -dependencies { - api(project(":visionforge-core")) - api("io.ktor:ktor-server-cio:${ktorVersion}") - api("io.ktor:ktor-server-html-builder:${ktorVersion}") - api("io.ktor:ktor-server-websockets:${ktorVersion}") - implementation("io.ktor:ktor-server-cors:${ktorVersion}") -} \ No newline at end of file diff --git a/visionforge-solid/build.gradle.kts b/visionforge-solid/build.gradle.kts index 7a0f145c..d135e045 100644 --- a/visionforge-solid/build.gradle.kts +++ b/visionforge-solid/build.gradle.kts @@ -1,35 +1,24 @@ -import space.kscience.gradle.KScienceVersions - plugins { id("space.kscience.gradle.mpp") } -kscience{ - useSerialization{ +kscience { + jvm() + js() + useSerialization { json() } -} - -kotlin { - sourceSets { - commonMain { - dependencies { - api(project(":visionforge-core")) - } - } - commonTest{ - dependencies{ - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}") - } - } - jvmTest{ - dependencies{ - implementation("ch.qos.logback:logback-classic:1.2.11") - } - } + dependencies { + api(projects.visionforgeCore) + } + testDependencies { + implementation(spclibs.kotlinx.coroutines.test) + } + dependencies(jvmTest) { + implementation(spclibs.logback.classic) } } -readme{ +readme { maturity = space.kscience.gradle.Maturity.DEVELOPMENT } \ No newline at end of file diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt index b87f0c93..f99e4bbf 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solid.kt @@ -169,14 +169,19 @@ internal fun float(name: Name, default: Number): ReadWriteProperty = +internal fun point( + name: Name, + defaultX: Float, + defaultY: Float = defaultX, + defaultZ: Float = defaultX, +): ReadWriteProperty = object : ReadWriteProperty { override fun getValue(thisRef: Solid, property: KProperty<*>): Point3D? { val item = thisRef.properties.own?.get(name) ?: return null return object : Point3D { - override val x: Float get() = item[X_KEY]?.float ?: default - override val y: Float get() = item[Y_KEY]?.float ?: default - override val z: Float get() = item[Z_KEY]?.float ?: default + override val x: Float get() = item[X_KEY]?.float ?: defaultX + override val y: Float get() = item[Y_KEY]?.float ?: defaultY + override val z: Float get() = item[Z_KEY]?.float ?: defaultZ } } diff --git a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt index 919ac4cd..62e56d2b 100644 --- a/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt +++ b/visionforge-solid/src/commonMain/kotlin/space/kscience/visionforge/solid/Solids.kt @@ -10,13 +10,12 @@ import kotlinx.serialization.serializer import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name import space.kscience.visionforge.* import space.kscience.visionforge.html.VisionOutput -import kotlin.reflect.KClass public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer { @@ -30,12 +29,11 @@ public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer, MutableVisionContainer { override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP) - override val type: KClass = Solids::class public val default: Solids by lazy { Context("@Solids") { plugin(Solids) - }.fetch(Solids) + }.request(Solids) } override fun build(context: Context, meta: Meta): Solids = Solids(meta) diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPluginTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPluginTest.kt index ad9a06e9..1356c9b6 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPluginTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/SolidPluginTest.kt @@ -1,7 +1,7 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.dataforge.misc.DFExperimental import space.kscience.visionforge.getChild import kotlin.test.Test @@ -19,7 +19,7 @@ class SolidPluginTest { @DFExperimental @Test fun testPluginConverter() { - val visionManager = Global.fetch(Solids).visionManager + val visionManager = Global.request(Solids).visionManager val meta = visionManager.encodeToMeta(vision) val reconstructed = visionManager.decodeFromMeta(meta) as SolidGroup diff --git a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt index 65fdf373..6a38a194 100644 --- a/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt +++ b/visionforge-solid/src/commonTest/kotlin/space/kscience/visionforge/solid/VisionUpdateTest.kt @@ -1,7 +1,7 @@ package space.kscience.visionforge.solid import space.kscience.dataforge.context.Global -import space.kscience.dataforge.context.fetch +import space.kscience.dataforge.context.request import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.names.asName @@ -12,18 +12,18 @@ import kotlin.test.assertEquals import kotlin.test.assertTrue internal class VisionUpdateTest { - val solidManager = Global.fetch(Solids) + val solidManager = Global.request(Solids) val visionManager = solidManager.visionManager @Test - fun testVisionUpdate(){ + fun testVisionUpdate() { val targetVision = Solids.solidGroup { - box(200,200,200, name = "origin") + box(200, 200, 200, name = "origin") } - val dif = visionManager.VisionChange{ - solidGroup ("top") { + val dif = visionManager.VisionChange { + solidGroup("top") { color.set(123) - box(100,100,100) + box(100, 100, 100) } propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) propertyChanged("origin".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) @@ -31,15 +31,18 @@ internal class VisionUpdateTest { targetVision.update(dif) assertTrue { targetVision.children.getChild("top") is SolidGroup } assertEquals("red", (targetVision.children.getChild("origin") as Solid).color.string) // Should work - assertEquals("#00007b", (targetVision.children.getChild("top") as Solid).color.string) // new item always takes precedence + assertEquals( + "#00007b", + (targetVision.children.getChild("top") as Solid).color.string + ) // new item always takes precedence } @Test - fun testVisionChangeSerialization(){ - val change = visionManager.VisionChange{ + fun testVisionChangeSerialization() { + val change = visionManager.VisionChange { solidGroup("top") { color.set(123) - box(100,100,100) + box(100, 100, 100) } propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) propertyChanged("origin".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) @@ -47,6 +50,6 @@ internal class VisionUpdateTest { val serialized = visionManager.jsonFormat.encodeToString(VisionChange.serializer(), change) println(serialized) val reconstructed = visionManager.jsonFormat.decodeFromString(VisionChange.serializer(), serialized) - assertEquals(change.properties,reconstructed.properties) + assertEquals(change.properties, reconstructed.properties) } } \ No newline at end of file diff --git a/visionforge-tables/build.gradle.kts b/visionforge-tables/build.gradle.kts index abc56455..23d77912 100644 --- a/visionforge-tables/build.gradle.kts +++ b/visionforge-tables/build.gradle.kts @@ -2,13 +2,10 @@ plugins { id("space.kscience.gradle.mpp") } -val tablesVersion = "0.2.0-dev-3" +val tablesVersion = "0.2.0-dev-4" kscience { - useSerialization() -} - -kotlin { + jvm() js { useCommonJs() binaries.library() @@ -20,21 +17,15 @@ kotlin { } } } - - sourceSets { - commonMain { - dependencies { - api(project(":visionforge-core")) - api("space.kscience:tables-kt:${tablesVersion}") - } - } - jsMain { - dependencies { - implementation(npm("tabulator-tables", "5.0.1")) - implementation(npm("@types/tabulator-tables", "5.0.1")) - } - } + dependencies { + api(projects.visionforgeCore) + api("space.kscience:tables-kt:${tablesVersion}") } + dependencies(jsMain){ + implementation(npm("tabulator-tables", "5.0.1")) + implementation(npm("@types/tabulator-tables", "5.0.1")) + } + useSerialization() } readme{ diff --git a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt index fd03b550..d6bc9b1d 100644 --- a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt +++ b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/TableVisionPlugin.kt @@ -9,7 +9,6 @@ import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionPlugin -import kotlin.reflect.KClass public class TableVisionPlugin : VisionPlugin() { override val tag: PluginTag get() = Companion.tag @@ -23,7 +22,6 @@ public class TableVisionPlugin : VisionPlugin() { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.table", PluginTag.DATAFORGE_GROUP) - override val type: KClass = TableVisionPlugin::class override fun build(context: Context, meta: Meta): TableVisionPlugin = TableVisionPlugin() } diff --git a/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt b/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt index 4764069f..d61e4664 100644 --- a/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt +++ b/visionforge-tables/src/jsMain/kotlin/space/kscience/visionforge/tables/TableVisionJsPlugin.kt @@ -16,7 +16,6 @@ import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionClient import tabulator.Tabulator import tabulator.TabulatorFull -import kotlin.reflect.KClass public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer { public val visionClient: VisionClient by require(VisionClient) @@ -89,7 +88,6 @@ public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.table.js", PluginTag.DATAFORGE_GROUP) - override val type: KClass = TableVisionJsPlugin::class override fun build(context: Context, meta: Meta): TableVisionJsPlugin = TableVisionJsPlugin() } diff --git a/visionforge-threejs/build.gradle.kts b/visionforge-threejs/build.gradle.kts index 7cf2a60f..f04275f3 100644 --- a/visionforge-threejs/build.gradle.kts +++ b/visionforge-threejs/build.gradle.kts @@ -10,7 +10,7 @@ kotlin{ } dependencies { - api(project(":visionforge-solid")) + api(projects.visionforgeSolid) implementation(npm("three", "0.143.0")) implementation(npm("three-csg-ts", "3.1.10")) implementation(npm("three.meshline","1.4.0")) diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt index 5aacba18..0a2d9f2a 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreePlugin.kt @@ -158,7 +158,6 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.threejs", PluginTag.DATAFORGE_GROUP) - override val type: KClass = ThreePlugin::class override fun build(context: Context, meta: Meta): ThreePlugin = ThreePlugin() } diff --git a/visionforge-threejs/visionforge-threejs-server/build.gradle.kts b/visionforge-threejs/visionforge-threejs-server/build.gradle.kts index d3ef8496..059f3784 100644 --- a/visionforge-threejs/visionforge-threejs-server/build.gradle.kts +++ b/visionforge-threejs/visionforge-threejs-server/build.gradle.kts @@ -4,55 +4,26 @@ plugins { val ktorVersion: String by rootProject.extra -kotlin { - js(IR) { - browser { - webpackTask { - this.outputFileName = "js/visionforge-three.js" - } - commonWebpackConfig { - cssSupport{ - enabled.set(false) - } - } - } - binaries.executable() - } - - sourceSets { - commonMain { - dependencies { - api(projects.visionforgeSolid) - } - } - jvmMain { - dependencies { - api(projects.visionforgeServer) - } - } - jsMain { - dependencies { - api(projects.visionforgeThreejs) - api(projects.ui.ring) +kscience { + fullStack("js/visionforge-three.js") { + commonWebpackConfig { + cssSupport { + enabled.set(false) } } } -} - -val jsBrowserDistribution by tasks.getting -val jsBrowserDevelopmentExecutableDistribution by tasks.getting - -val devMode = rootProject.findProperty("visionforge.development") as? Boolean - ?: rootProject.version.toString().contains("dev") - -tasks.getByName("jvmProcessResources") { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - if (devMode) { - dependsOn(jsBrowserDevelopmentExecutableDistribution) - from(jsBrowserDevelopmentExecutableDistribution) - } else { - dependsOn(jsBrowserDistribution) - from(jsBrowserDistribution) + dependencies { + api(projects.visionforgeSolid) } -} + + dependencies(jvmMain) { + api(projects.visionforgeServer) + } + + dependencies(jsMain) { + api(projects.visionforgeThreejs) + api(projects.ui.ring) + compileOnly(npm("webpack-bundle-analyzer","4.5.0")) + } +} \ No newline at end of file