Update versions

This commit is contained in:
Alexander Nozik 2023-05-14 18:33:30 +03:00
parent 35fc7a7042
commit 4ec611eda3
51 changed files with 359 additions and 530 deletions

View File

@ -7,7 +7,7 @@ plugins {
// id("org.jetbrains.kotlinx.kover") version "0.5.0" // 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") val fxVersion by extra("11")
allprojects { allprojects {

View File

@ -3,17 +3,12 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
dependencies {
api(projects.visionforgeSolid)
}
useSerialization { useSerialization {
json() json()
} }
} }
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api(project(":visionforge-solid"))
}
}
}
}

View File

@ -1,62 +1,62 @@
import space.kscience.gradle.DependencyConfiguration
import space.kscience.gradle.FXModule
plugins { plugins {
id("space.kscience.gradle.mpp") id("space.kscience.gradle.mpp")
application
} }
kscience { kscience {
val fxVersion: String by rootProject.extra jvm()
useFx(FXModule.CONTROLS, version = fxVersion, configuration = DependencyConfiguration.IMPLEMENTATION)
application()
}
kotlin {
jvm {
withJava()
}
js { js {
useCommonJs() useCommonJs()
browser { browser {
commonWebpackConfig { commonWebpackConfig {
cssSupport{ cssSupport {
enabled.set(false) enabled.set(false)
} }
} }
} }
} }
sourceSets {
commonMain {
dependencies { dependencies {
implementation(project(":visionforge-solid")) implementation(projects.visionforgeSolid)
implementation(project(":visionforge-gdml")) implementation(projects.visionforgeGdml)
}
} }
jvmMain { jvmMain {
dependencies { // implementation(project(":visionforge-fx"))
implementation(project(":visionforge-fx")) implementation(spclibs.logback.classic)
implementation("ch.qos.logback:logback-classic:1.2.11")
}
} }
jsMain { jsMain {
dependencies { implementation(projects.ui.ring)
implementation(project(":ui:ring")) implementation(projects.visionforgeThreejs)
implementation(project(":visionforge-threejs"))
implementation(npm("react-file-drop", "3.0.6")) implementation(npm("react-file-drop", "3.0.6"))
} }
} application()
}
} }
application { //kotlin {
mainClass.set("space.kscience.visionforge.gdml.demo.GdmlFxDemoAppKt") //
} // 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) { //val convertGdmlToJson by tasks.creating(JavaExec::class) {
group = "application" // group = "application"
classpath = sourceSets["main"].runtimeClasspath // classpath = sourceSets["main"].runtimeClasspath
mainClass.set("space.kscience.dataforge.vis.spatial.gdml.demo.SaveToJsonKt") // mainClass.set("space.kscience.dataforge.vis.spatial.gdml.demo.SaveToJsonKt")
} //}

View File

@ -3,7 +3,7 @@ package space.kscience.visionforge.gdml.demo
import kotlinx.css.* import kotlinx.css.*
import org.w3c.dom.Document import org.w3c.dom.Document
import space.kscience.dataforge.context.Context 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.gdml.GdmlShowCase
import space.kscience.visionforge.Application import space.kscience.visionforge.Application
import space.kscience.visionforge.Colors import space.kscience.visionforge.Colors
@ -54,7 +54,7 @@ private class GDMLDemoApp : Application {
} }
//println(context.plugins.fetch(VisionManager).encodeToString(vision)) //println(context.plugins.fetch(VisionManager).encodeToString(vision))
attrs { attrs {
this.solids = context.fetch(Solids) this.solids = context.request(Solids)
this.vision = vision this.vision = vision
} }
} }

View File

@ -1,83 +1,83 @@
package space.kscience.visionforge.gdml.demo //package space.kscience.visionforge.gdml.demo
//
import javafx.geometry.Orientation //import javafx.geometry.Orientation
import javafx.scene.Parent //import javafx.scene.Parent
import javafx.stage.FileChooser //import javafx.stage.FileChooser
import space.kscience.dataforge.context.Context //import space.kscience.dataforge.context.Context
import space.kscience.dataforge.context.fetch //import space.kscience.dataforge.context.fetch
import space.kscience.gdml.GdmlShowCase //import space.kscience.gdml.GdmlShowCase
import space.kscience.visionforge.VisionManager //import space.kscience.visionforge.VisionManager
import space.kscience.visionforge.editor.VisionEditorFragment //import space.kscience.visionforge.editor.VisionEditorFragment
import space.kscience.visionforge.editor.VisionTreeFragment //import space.kscience.visionforge.editor.VisionTreeFragment
import space.kscience.visionforge.gdml.toVision //import space.kscience.visionforge.gdml.toVision
import space.kscience.visionforge.solid.FX3DPlugin //import space.kscience.visionforge.solid.FX3DPlugin
import space.kscience.visionforge.solid.FXCanvas3D //import space.kscience.visionforge.solid.FXCanvas3D
import space.kscience.visionforge.solid.Solid //import space.kscience.visionforge.solid.Solid
import space.kscience.visionforge.solid.SolidMaterial //import space.kscience.visionforge.solid.SolidMaterial
import tornadofx.* //import tornadofx.*
//
class GDMLDemoApp : App(GDMLView::class) //class GDMLDemoApp : App(GDMLView::class)
//
class GDMLView : View() { //class GDMLView : View() {
private val context = Context { // private val context = Context {
plugin(FX3DPlugin) // plugin(FX3DPlugin)
} // }
//
private val fx3d = context.fetch(FX3DPlugin) // private val fx3d = context.fetch(FX3DPlugin)
private val visionManager = context.fetch(VisionManager) // private val visionManager = context.fetch(VisionManager)
private val canvas = FXCanvas3D(fx3d) // private val canvas = FXCanvas3D(fx3d)
//
private val treeFragment = VisionTreeFragment().apply { // private val treeFragment = VisionTreeFragment().apply {
this.itemProperty.bind(canvas.rootObjectProperty) // this.itemProperty.bind(canvas.rootObjectProperty)
} // }
//
private val propertyEditor = VisionEditorFragment().apply { // private val propertyEditor = VisionEditorFragment().apply {
descriptorProperty.set(SolidMaterial.descriptor) // descriptorProperty.set(SolidMaterial.descriptor)
visionProperty.bind(treeFragment.selectedProperty) // visionProperty.bind(treeFragment.selectedProperty)
} // }
//
override val root: Parent = borderpane { // override val root: Parent = borderpane {
top { // top {
buttonbar { // buttonbar {
button("Load GDML/json") { // button("Load GDML/json") {
action { // action {
val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull() // val file = chooseFile("Select a GDML/json file", filters = fileNameFilter).firstOrNull()
if (file != null) { // if (file != null) {
runAsync { // runAsync {
visionManager.readFile(file) as Solid // visionManager.readFile(file) as Solid
} ui { // } ui {
canvas.render(it) // canvas.render(it)
} // }
} // }
} // }
} // }
} // }
} // }
center { // center {
splitpane(Orientation.HORIZONTAL, treeFragment.root, canvas.root, propertyEditor.root) { // splitpane(Orientation.HORIZONTAL, treeFragment.root, canvas.root, propertyEditor.root) {
setDividerPositions(0.2, 0.6, 0.2) // setDividerPositions(0.2, 0.6, 0.2)
} // }
} // }
} // }
//
init { // init {
runAsync { // runAsync {
GdmlShowCase.cubes().toVision() // GdmlShowCase.cubes().toVision()
} ui { // } ui {
canvas.render(it) // canvas.render(it)
} // }
} // }
//
companion object { // companion object {
private val fileNameFilter = arrayOf( // private val fileNameFilter = arrayOf(
FileChooser.ExtensionFilter("GDML", "*.gdml", "*.xml"), // FileChooser.ExtensionFilter("GDML", "*.gdml", "*.xml"),
FileChooser.ExtensionFilter("JSON", "*.json"), // FileChooser.ExtensionFilter("JSON", "*.json"),
FileChooser.ExtensionFilter("JSON.ZIP", "*.json.zip"), // FileChooser.ExtensionFilter("JSON.ZIP", "*.json.zip"),
FileChooser.ExtensionFilter("JSON.GZ", "*.json.gz") // FileChooser.ExtensionFilter("JSON.GZ", "*.json.gz")
) // )
} // }
} //}
//
fun main() { //fun main() {
launch<GDMLDemoApp>() // launch<GDMLDemoApp>()
} //}

View File

@ -3,7 +3,7 @@ import org.w3c.dom.Document
import ringui.SmartTabs import ringui.SmartTabs
import ringui.Tab import ringui.Tab
import space.kscience.dataforge.context.Context 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.models.Trace
import space.kscience.plotly.scatter import space.kscience.plotly.scatter
import space.kscience.visionforge.Application import space.kscience.visionforge.Application
@ -52,7 +52,7 @@ private class JsPlaygroundApp : Application {
Tab("gravity") { Tab("gravity") {
GravityDemo { GravityDemo {
attrs { attrs {
this.solids = playgroundContext.fetch(Solids) this.solids = playgroundContext.request(Solids)
} }
} }
} }
@ -73,7 +73,7 @@ private class JsPlaygroundApp : Application {
child(ThreeCanvasWithControls) { child(ThreeCanvasWithControls) {
val random = Random(112233) val random = Random(112233)
attrs { attrs {
solids = playgroundContext.fetch(Solids) solids = playgroundContext.request(Solids)
solid { solid {
ambientLight { ambientLight {
color.set(Colors.white) color.set(Colors.white)

View File

@ -20,9 +20,9 @@ val Plotly = fc<PlotlyProps>("Plotly") { props ->
useEffect(props.plot, elementRef) { useEffect(props.plot, elementRef) {
val element = elementRef.current as? HTMLElement ?: error("Plotly element not found") val element = elementRef.current as? HTMLElement ?: error("Plotly element not found")
props.plot?.let { props.plot?.let {
element.plot(it, PlotlyConfig { element.plot(PlotlyConfig {
responsive = true responsive = true
}) }, it)
} }
} }

View File

@ -5,74 +5,46 @@ plugins {
group = "ru.mipt.npm" group = "ru.mipt.npm"
val ktorVersion: String = npmlibs.versions.ktor.get() val ktorVersion: String = spclibs.versions.ktor.get()
kscience { kscience {
useCoroutines() useCoroutines()
useSerialization() useSerialization()
application() useKtor()
} fullStack(
"muon-monitor.js",
kotlin { jvmConfig = { withJava() },
jvm { jsConfig = { useCommonJs() }
withJava() ) {
}
js {
useCommonJs()
browser {
commonWebpackConfig { commonWebpackConfig {
cssSupport { cssSupport {
enabled.set(false) enabled.set(false)
} }
} }
} }
}
sourceSets {
commonMain { commonMain {
dependencies { implementation(projects.visionforgeSolid)
implementation(project(":visionforge-solid"))
}
} }
jvmMain { jvmMain {
dependencies {
implementation("org.apache.commons:commons-math3:3.6.1") implementation("org.apache.commons:commons-math3:3.6.1")
implementation("io.ktor:ktor-server-cio:${ktorVersion}") implementation("io.ktor:ktor-server-cio:${ktorVersion}")
implementation("io.ktor:ktor-server-content-negotiation:${ktorVersion}") implementation("io.ktor:ktor-server-content-negotiation:${ktorVersion}")
implementation("io.ktor:ktor-serialization-kotlinx-json:${ktorVersion}") implementation("io.ktor:ktor-serialization-kotlinx-json:${ktorVersion}")
implementation("ch.qos.logback:logback-classic:1.2.11") implementation("ch.qos.logback:logback-classic:1.2.11")
} }
}
jsMain { jsMain {
dependencies {
implementation(project(":ui:ring")) implementation(project(":ui:ring"))
implementation(project(":visionforge-threejs")) implementation(project(":visionforge-threejs"))
//implementation(devNpm("webpack-bundle-analyzer", "4.4.0")) //implementation(devNpm("webpack-bundle-analyzer", "4.4.0"))
} }
} application()
}
} }
application { application {
mainClass.set("ru.mipt.npm.muon.monitor.server.MMServerKt") 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<ProcessResources>("jvmProcessResources") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
if (devMode) {
dependsOn(jsBrowserDevelopmentExecutableDistribution)
from(jsBrowserDevelopmentExecutableDistribution)
} else {
dependsOn(jsBrowserDistribution)
from(jsBrowserDistribution)
}
}
//distributions { //distributions {
// main { // main {

View File

@ -2,7 +2,7 @@ package ru.mipt.npm.muon.monitor
import org.w3c.dom.Document import org.w3c.dom.Document
import space.kscience.dataforge.context.Context 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.Application
import space.kscience.visionforge.VisionManager import space.kscience.visionforge.VisionManager
import space.kscience.visionforge.react.createRoot import space.kscience.visionforge.react.createRoot
@ -19,7 +19,7 @@ private class MMDemoApp : Application {
plugin(ThreePlugin) plugin(ThreePlugin)
} }
val visionManager = context.fetch(VisionManager) val visionManager = context.request(VisionManager)
val model = Model(visionManager) val model = Model(visionManager)
@ -28,7 +28,7 @@ private class MMDemoApp : Application {
child(MMApp) { child(MMApp) {
attrs { attrs {
this.model = model this.model = model
this.solids = context.fetch(Solids) this.solids = context.request(Solids)
} }
} }
} }

View File

@ -29,7 +29,6 @@ kotlin {
} }
jvm { jvm {
withJava()
compilations.all { compilations.all {
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "11"

View File

@ -6,7 +6,7 @@ import io.ktor.server.http.content.resources
import io.ktor.server.routing.routing import io.ktor.server.routing.routing
import kotlinx.html.* import kotlinx.html.*
import space.kscience.dataforge.context.Global 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.VisionManager
import space.kscience.visionforge.html.VisionOfHtmlForm import space.kscience.visionforge.html.VisionOfHtmlForm
import space.kscience.visionforge.html.VisionPage import space.kscience.visionforge.html.VisionPage
@ -18,7 +18,7 @@ import space.kscience.visionforge.server.openInBrowser
import space.kscience.visionforge.server.visionPage import space.kscience.visionforge.server.visionPage
fun main() { fun main() {
val visionManager = Global.fetch(VisionManager) val visionManager = Global.request(VisionManager)
val connector = EngineConnectorConfig("localhost", 7777) val connector = EngineConnectorConfig("localhost", 7777)

View File

@ -6,6 +6,7 @@ import kotlinx.serialization.json.Json
import space.kscience.visionforge.solid.SolidGroup import space.kscience.visionforge.solid.SolidGroup
import space.kscience.visionforge.solid.Solids import space.kscience.visionforge.solid.Solids
@OptIn(ExperimentalSerializationApi::class)
private val json = Json { private val json = Json {
serializersModule = Solids.serializersModuleForSolids serializersModule = Solids.serializersModuleForSolids
prettyPrintIndent = " " prettyPrintIndent = " "

View File

@ -9,15 +9,14 @@ kscience {
// json() // json()
// } // }
application() application()
dependencies{
implementation(projects.visionforgeThreejs.visionforgeThreejsServer)
implementation("ch.qos.logback:logback-classic:1.4.5")
}
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
dependencies{
implementation(project(":visionforge-threejs:visionforge-threejs-server"))
implementation("ch.qos.logback:logback-classic:1.4.5")
}
application { application {
mainClass.set("ru.mipt.npm.sat.SatServerKt") mainClass.set("ru.mipt.npm.sat.SatServerKt")
} }

View File

@ -10,7 +10,7 @@ import kotlinx.coroutines.*
import kotlinx.html.div import kotlinx.html.div
import kotlinx.html.h1 import kotlinx.html.h1
import space.kscience.dataforge.context.Context 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.meta.Null
import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.Name
import space.kscience.visionforge.Colors import space.kscience.visionforge.Colors
@ -29,7 +29,7 @@ fun main() {
plugin(Solids) plugin(Solids)
} }
val solids = satContext.fetch(Solids) val solids = satContext.request(Solids)
//Create a geometry //Create a geometry
val sat = solids.visionOfSatellite(ySegments = 3).apply { val sat = solids.visionOfSatellite(ySegments = 3).apply {

View File

@ -1,6 +1,3 @@
import space.kscience.gradle.DependencyConfiguration
import space.kscience.gradle.FXModule
plugins { plugins {
id("space.kscience.gradle.mpp") id("space.kscience.gradle.mpp")
application application
@ -8,34 +5,18 @@ plugins {
kscience { kscience {
useCoroutines() useCoroutines()
val fxVersion: String by rootProject.extra
useFx(FXModule.CONTROLS, version = fxVersion, configuration = DependencyConfiguration.IMPLEMENTATION)
application() application()
}
kotlin {
jvm { jvm {
withJava() 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 { jsMain {
dependencies { implementation(projects.visionforgeThreejs)
implementation(project(":visionforge-threejs"))
}
}
} }
} }

View File

@ -10,7 +10,7 @@ import org.w3c.dom.Element
import org.w3c.dom.HTMLDivElement import org.w3c.dom.HTMLDivElement
import org.w3c.dom.HTMLElement import org.w3c.dom.HTMLElement
import space.kscience.dataforge.context.Global 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.Meta
import space.kscience.dataforge.meta.get import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.string import space.kscience.dataforge.meta.string
@ -26,7 +26,7 @@ class ThreeDemoGrid(element: Element) : VisionLayout<Solid> {
private val outputs: MutableMap<Name, ThreeCanvas> = HashMap() private val outputs: MutableMap<Name, ThreeCanvas> = HashMap()
private val three = Global.fetch(ThreePlugin) private val three = Global.request(ThreePlugin)
override val solids: Solids get() = three.solids override val solids: Solids get() = three.solids

View File

@ -1,8 +1,9 @@
kotlin.code.style=official kotlin.code.style=official
kotlin.mpp.stability.nowarn=true kotlin.mpp.stability.nowarn=true
kotlin.js.compiler=ir
kotlin.incremental.js.ir=true kotlin.incremental.js.ir=true
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.jvmargs=-Xmx4G org.gradle.jvmargs=-Xmx4G
toolsVersion=0.13.4-kotlin-1.8.0 toolsVersion=0.14.7-kotlin-1.8.20

View File

@ -1,25 +1,22 @@
plugins { plugins {
id("space.kscience.gradle.mpp") id("space.kscience.gradle.mpp")
id("org.jetbrains.kotlin.jupyter.api")
} }
description = "Common visionforge jupyter module" description = "Common visionforge jupyter module"
kotlin { kscience {
sourceSets { jvm()
commonMain{ js()
dependencies{ jupyterLibrary()
dependencies {
api(projects.visionforgeCore) api(projects.visionforgeCore)
} }
} dependencies(jvmMain){
jvmMain {
dependencies {
api(projects.visionforgeServer) api(projects.visionforgeServer)
} }
}
}
} }
readme { readme {
maturity = space.kscience.gradle.Maturity.EXPERIMENTAL maturity = space.kscience.gradle.Maturity.EXPERIMENTAL
} }

View File

@ -11,7 +11,6 @@ import space.kscience.visionforge.VisionClient
import space.kscience.visionforge.renderAllVisions import space.kscience.visionforge.renderAllVisions
import space.kscience.visionforge.renderAllVisionsById import space.kscience.visionforge.renderAllVisionsById
import space.kscience.visionforge.renderAllVisionsIn import space.kscience.visionforge.renderAllVisionsIn
import kotlin.reflect.KClass
@JsExport @JsExport
public class VFNotebookPlugin : AbstractPlugin() { public class VFNotebookPlugin : AbstractPlugin() {
@ -44,8 +43,6 @@ public class VFNotebookPlugin : AbstractPlugin() {
override fun build(context: Context, meta: Meta): VFNotebookPlugin = VFNotebookPlugin() override fun build(context: Context, meta: Meta): VFNotebookPlugin = VFNotebookPlugin()
override val tag: PluginTag = PluginTag(name = "vision.notebook", group = PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag(name = "vision.notebook", group = PluginTag.DATAFORGE_GROUP)
override val type: KClass<out VFNotebookPlugin> = VFNotebookPlugin::class
} }
} }

View File

@ -4,7 +4,6 @@ import io.ktor.http.URLProtocol
import io.ktor.server.application.install import io.ktor.server.application.install
import io.ktor.server.cio.CIO import io.ktor.server.cio.CIO
import io.ktor.server.engine.ApplicationEngine import io.ktor.server.engine.ApplicationEngine
import io.ktor.server.engine.EngineConnectorConfig
import io.ktor.server.engine.embeddedServer import io.ktor.server.engine.embeddedServer
import io.ktor.server.util.url import io.ktor.server.util.url
import io.ktor.server.websocket.WebSockets import io.ktor.server.websocket.WebSockets
@ -25,7 +24,6 @@ import space.kscience.visionforge.Vision
import space.kscience.visionforge.VisionManager import space.kscience.visionforge.VisionManager
import space.kscience.visionforge.html.HtmlVisionFragment import space.kscience.visionforge.html.HtmlVisionFragment
import space.kscience.visionforge.html.visionFragment import space.kscience.visionforge.html.visionFragment
import space.kscience.visionforge.server.EngineConnectorConfig
import space.kscience.visionforge.server.VisionRoute import space.kscience.visionforge.server.VisionRoute
import space.kscience.visionforge.server.serveVisionData import space.kscience.visionforge.server.serveVisionData
import space.kscience.visionforge.visionManager 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?.stop(1000, 2000)
engine = context.embeddedServer(CIO, port, host) { engine = context.embeddedServer(CIO, port, host) {

View File

@ -4,56 +4,32 @@ plugins {
description = "Jupyter api artifact for GDML rendering" description = "Jupyter api artifact for GDML rendering"
kotlin { kscience {
explicitApi = null fullStack("js/gdml-jupyter.js",
js { jsConfig = { useCommonJs() }
useCommonJs() ) {
browser {
webpackTask {
this.outputFileName = "js/gdml-jupyter.js"
}
commonWebpackConfig { commonWebpackConfig {
sourceMaps = false sourceMaps = false
cssSupport{ cssSupport {
enabled.set(false) enabled.set(false)
} }
} }
} }
binaries.executable()
}
afterEvaluate { dependencies{
val jsBrowserDistribution by tasks.getting
tasks.getByName<ProcessResources>("jvmProcessResources") {
dependsOn(jsBrowserDistribution)
from(jsBrowserDistribution)
}
}
sourceSets {
commonMain {
dependencies {
implementation(projects.visionforgeSolid) implementation(projects.visionforgeSolid)
implementation(projects.jupyter) implementation(projects.jupyter)
} }
}
jvmMain { dependencies(jvmMain){
dependencies {
implementation(projects.visionforgeGdml) implementation(projects.visionforgeGdml)
} }
}
jsMain { dependencies(jsMain){
dependencies {
implementation(projects.visionforgeThreejs) implementation(projects.visionforgeThreejs)
implementation(projects.ui.ring) implementation(projects.ui.ring)
} }
}
}
}
kscience {
jupyterLibrary("space.kscience.visionforge.gdml.jupyter.GdmlForJupyter") jupyterLibrary("space.kscience.visionforge.gdml.jupyter.GdmlForJupyter")
} }

View File

@ -6,7 +6,7 @@ import space.kscience.visionforge.runVisionClient
@DFExperimental @DFExperimental
@JsExport @JsExport
fun main(): Unit = runVisionClient { public fun main(): Unit = runVisionClient {
plugin(ThreeWithControlsPlugin) plugin(ThreeWithControlsPlugin)
} }

View File

@ -34,7 +34,7 @@ dependencyResolutionManagement {
} }
versionCatalogs { versionCatalogs {
create("npmlibs") { create("spclibs") {
from("space.kscience:version-catalog:$toolsVersion") from("space.kscience:version-catalog:$toolsVersion")
} }
} }
@ -48,7 +48,7 @@ include(
":ui:bootstrap", ":ui:bootstrap",
":visionforge-core", ":visionforge-core",
":visionforge-solid", ":visionforge-solid",
":visionforge-fx", // ":visionforge-fx",
":visionforge-threejs", ":visionforge-threejs",
":visionforge-threejs:visionforge-threejs-server", ":visionforge-threejs:visionforge-threejs-server",
":visionforge-gdml", ":visionforge-gdml",
@ -62,7 +62,7 @@ include(
":demo:muon-monitor", ":demo:muon-monitor",
":demo:sat-demo", ":demo:sat-demo",
":demo:playground", ":demo:playground",
":demo:plotly-fx", // ":demo:plotly-fx",
":demo:js-playground", ":demo:js-playground",
":jupyter", ":jupyter",
":jupyter:visionforge-jupyter-gdml" ":jupyter:visionforge-jupyter-gdml"

View File

@ -5,7 +5,7 @@ import org.w3c.dom.Element
import org.w3c.dom.HTMLElement import org.w3c.dom.HTMLElement
import react.* import react.*
import space.kscience.dataforge.context.Context 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.dataforge.names.Name
import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.Solid
import space.kscience.visionforge.solid.specifications.Canvas3DOptions import space.kscience.visionforge.solid.specifications.Canvas3DOptions
@ -25,7 +25,7 @@ public val ThreeCanvasComponent: FC<ThreeCanvasProps> = fc("ThreeCanvasComponent
val elementRef = useRef<Element>(null) val elementRef = useRef<Element>(null)
var canvas by useState<ThreeCanvas?>(null) var canvas by useState<ThreeCanvas?>(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) { useEffect(props.solid, props.options, elementRef) {
if (canvas == null) { if (canvas == null) {

View File

@ -14,7 +14,6 @@ import space.kscience.visionforge.Vision
import space.kscience.visionforge.react.render import space.kscience.visionforge.react.render
import space.kscience.visionforge.solid.Solid import space.kscience.visionforge.solid.Solid
import space.kscience.visionforge.solid.three.ThreePlugin import space.kscience.visionforge.solid.three.ThreePlugin
import kotlin.reflect.KClass
public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer { public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer {
public val three: ThreePlugin by require(ThreePlugin) public val three: ThreePlugin by require(ThreePlugin)
@ -44,7 +43,6 @@ public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer {
public companion object : PluginFactory<ThreeWithControlsPlugin> { public companion object : PluginFactory<ThreeWithControlsPlugin> {
override val tag: PluginTag = PluginTag("vision.threejs.withControls", PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag("vision.threejs.withControls", PluginTag.DATAFORGE_GROUP)
override val type: KClass<ThreeWithControlsPlugin> = ThreeWithControlsPlugin::class
override fun build(context: Context, meta: Meta): ThreeWithControlsPlugin = ThreeWithControlsPlugin() override fun build(context: Context, meta: Meta): ThreeWithControlsPlugin = ThreeWithControlsPlugin()
} }

View File

@ -4,29 +4,20 @@ plugins {
val dataforgeVersion: String by rootProject.extra val dataforgeVersion: String by rootProject.extra
kotlin { kscience{
sourceSets { jvm()
commonMain { js()
dependencies { dependencies {
api("space.kscience:dataforge-context:$dataforgeVersion") api("space.kscience:dataforge-context:$dataforgeVersion")
api("org.jetbrains.kotlinx:kotlinx-html:0.8.0") api(spclibs.kotlinx.html)
api("org.jetbrains.kotlin-wrappers:kotlin-css") api("org.jetbrains.kotlin-wrappers:kotlin-css")
} }
} testDependencies {
commonTest{
dependencies{
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${space.kscience.gradle.KScienceVersions.coroutinesVersion}") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${space.kscience.gradle.KScienceVersions.coroutinesVersion}")
} }
} dependencies(jsMain){
jsMain {
dependencies {
api("org.jetbrains.kotlin-wrappers:kotlin-extensions") api("org.jetbrains.kotlin-wrappers:kotlin-extensions")
} }
}
}
}
kscience{
useSerialization{ useSerialization{
json() json()
} }

View File

@ -17,7 +17,6 @@ import space.kscience.visionforge.html.VisionOfCheckbox
import space.kscience.visionforge.html.VisionOfHtmlForm import space.kscience.visionforge.html.VisionOfHtmlForm
import space.kscience.visionforge.html.VisionOfNumberField import space.kscience.visionforge.html.VisionOfNumberField
import space.kscience.visionforge.html.VisionOfTextField import space.kscience.visionforge.html.VisionOfTextField
import kotlin.reflect.KClass
public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionContainer<Vision> { public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionContainer<Vision> {
override val tag: PluginTag get() = Companion.tag override val tag: PluginTag get() = Companion.tag
@ -64,7 +63,6 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta), MutableVisionCont
public companion object : PluginFactory<VisionManager> { public companion object : PluginFactory<VisionManager> {
override val tag: PluginTag = PluginTag(name = "vision", group = PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag(name = "vision", group = PluginTag.DATAFORGE_GROUP)
override val type: KClass<out VisionManager> = VisionManager::class
public const val VISION_SERIALIZER_MODULE_TARGET: String = "visionSerializerModule" 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] * 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 = public fun Vision.encodeToString(): String =
manager?.encodeToString(this) ?: error("Orphan vision could not be encoded") manager?.encodeToString(this) ?: error("Orphan vision could not be encoded")

View File

@ -1,12 +1,15 @@
package space.kscience.visionforge.meta 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.map
import kotlinx.coroutines.flow.take import kotlinx.coroutines.flow.take
import kotlinx.coroutines.flow.toList import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import space.kscience.dataforge.context.Global 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.dataforge.meta.*
import space.kscience.visionforge.* import space.kscience.visionforge.*
import kotlin.test.Test import kotlin.test.Test
@ -23,7 +26,7 @@ private class TestScheme : Scheme() {
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
internal class VisionPropertyTest { internal class VisionPropertyTest {
private val manager = Global.fetch(VisionManager) private val manager = Global.request(VisionManager)
@Test @Test
fun testPropertyWrite() { fun testPropertyWrite() {
@ -56,7 +59,7 @@ internal class VisionPropertyTest {
@Test @Test
fun testChildrenPropertyPropagation() = runTest(dispatchTimeoutMs = 200) { fun testChildrenPropertyPropagation() = runTest(dispatchTimeoutMs = 200) {
val group = Global.fetch(VisionManager).group { val group = Global.request(VisionManager).group {
properties { properties {
"test" put 11 "test" put 11
} }
@ -91,7 +94,7 @@ internal class VisionPropertyTest {
@Test @Test
fun testChildrenPropertyFlow() = runTest(dispatchTimeoutMs = 200) { fun testChildrenPropertyFlow() = runTest(dispatchTimeoutMs = 200) {
val group = Global.fetch(VisionManager).group { val group = Global.request(VisionManager).group {
properties { properties {
"test" put 11 "test" put 11

View File

@ -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_FETCH_ATTRIBUTE
import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_NAME_ATTRIBUTE import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_NAME_ATTRIBUTE
import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_RENDERED import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_RENDERED
import kotlin.reflect.KClass
import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.milliseconds
/** /**
@ -227,15 +226,13 @@ public class VisionClient : AbstractPlugin() {
numberVisionRenderer(this), numberVisionRenderer(this),
textVisionRenderer(this), textVisionRenderer(this),
formVisionRenderer(this) formVisionRenderer(this)
).toMap() ).associateByName()
} else super.content(target) } else super.content(target)
public companion object : PluginFactory<VisionClient> { public companion object : PluginFactory<VisionClient> {
override fun build(context: Context, meta: Meta): VisionClient = VisionClient() override fun build(context: Context, meta: Meta): VisionClient = VisionClient()
override val tag: PluginTag = PluginTag(name = "vision.client", group = PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag(name = "vision.client", group = PluginTag.DATAFORGE_GROUP)
override val type: KClass<out VisionClient> = VisionClient::class
} }
} }
@ -296,7 +293,7 @@ public fun VisionClient.renderAllVisions(): Unit = whenDocumentLoaded {
} }
public class VisionClientApplication(public val context: Context) : Application { 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<String, Any>) { override fun start(document: Document, state: Map<String, Any>) {
context.logger.info { context.logger.info {

View File

@ -2,21 +2,16 @@ plugins {
id("space.kscience.gradle.mpp") id("space.kscience.gradle.mpp")
} }
kotlin { kscience {
js(IR){ jvm()
js {
binaries.library() binaries.library()
} }
sourceSets {
commonMain{
dependencies { dependencies {
api(projects.visionforgeSolid) api(projects.visionforgeSolid)
api("space.kscience:gdml:0.4.0") api("space.kscience:gdml:0.4.0")
} }
} dependencies(jvmTest) {
jvmTest{
dependencies{
implementation("ch.qos.logback:logback-classic:1.2.11") implementation("ch.qos.logback:logback-classic:1.2.11")
} }
}
}
} }

View File

@ -5,20 +5,13 @@ plugins {
val markdownVersion = "0.2.4" val markdownVersion = "0.2.4"
kscience { kscience {
useSerialization() jvm()
}
kotlin {
js { js {
binaries.library() binaries.library()
} }
sourceSets {
commonMain {
dependencies { dependencies {
api(project(":visionforge-core")) api(project(":visionforge-core"))
api("org.jetbrains:markdown:$markdownVersion") api("org.jetbrains:markdown:$markdownVersion")
} }
} useSerialization()
}
} }

View File

@ -15,7 +15,6 @@ import space.kscience.dataforge.names.Name
import space.kscience.visionforge.* import space.kscience.visionforge.*
import space.kscience.visionforge.markup.VisionOfMarkup.Companion.COMMONMARK_FORMAT import space.kscience.visionforge.markup.VisionOfMarkup.Companion.COMMONMARK_FORMAT
import space.kscience.visionforge.markup.VisionOfMarkup.Companion.GFM_FORMAT import space.kscience.visionforge.markup.VisionOfMarkup.Companion.GFM_FORMAT
import kotlin.reflect.KClass
public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer { public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer {
public val visionClient: VisionClient by require(VisionClient) public val visionClient: VisionClient by require(VisionClient)
@ -47,7 +46,6 @@ public actual class MarkupPlugin : VisionPlugin(), ElementVisionRenderer {
public companion object : PluginFactory<MarkupPlugin> { public companion object : PluginFactory<MarkupPlugin> {
override val tag: PluginTag = PluginTag("vision.markup", PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag("vision.markup", PluginTag.DATAFORGE_GROUP)
override val type: KClass<MarkupPlugin> = MarkupPlugin::class
override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin()

View File

@ -6,7 +6,6 @@ import space.kscience.dataforge.context.PluginFactory
import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.context.PluginTag
import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.Meta
import space.kscience.visionforge.VisionPlugin import space.kscience.visionforge.VisionPlugin
import kotlin.reflect.KClass
public actual class MarkupPlugin : VisionPlugin() { public actual class MarkupPlugin : VisionPlugin() {
override val visionSerializersModule: SerializersModule get() = markupSerializersModule override val visionSerializersModule: SerializersModule get() = markupSerializersModule
@ -16,8 +15,6 @@ public actual class MarkupPlugin : VisionPlugin() {
public companion object : PluginFactory<MarkupPlugin> { public companion object : PluginFactory<MarkupPlugin> {
override val tag: PluginTag = PluginTag("vision.plotly", PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag("vision.plotly", PluginTag.DATAFORGE_GROUP)
override val type: KClass<out MarkupPlugin> = MarkupPlugin::class
override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin()
} }

View File

@ -2,23 +2,16 @@ plugins {
id("space.kscience.gradle.mpp") id("space.kscience.gradle.mpp")
} }
val plotlyVersion = "0.5.3-dev-1" val plotlyVersion = "0.5.3"
kscience { kscience {
useSerialization() jvm()
}
kotlin {
js { js {
binaries.library() binaries.library()
} }
sourceSets {
commonMain {
dependencies { dependencies {
api(project(":visionforge-core")) api(project(":visionforge-core"))
api("space.kscience:plotlykt-core:${plotlyVersion}") api("space.kscience:plotlykt-core:${plotlyVersion}")
} }
} useSerialization()
}
} }

View File

@ -14,7 +14,6 @@ import space.kscience.visionforge.ElementVisionRenderer
import space.kscience.visionforge.Vision import space.kscience.visionforge.Vision
import space.kscience.visionforge.VisionClient import space.kscience.visionforge.VisionClient
import space.kscience.visionforge.VisionPlugin import space.kscience.visionforge.VisionPlugin
import kotlin.reflect.KClass
public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer { public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer {
public val visionClient: VisionClient by require(VisionClient) 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) { 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 plot = (vision as? VisionOfPlotly)?.plot ?: error("VisionOfPlotly expected but ${vision::class} found")
val config = PlotlyConfig.read(meta) val config = PlotlyConfig.read(meta)
element.plot(plot, config) element.plot(config, plot)
} }
override fun content(target: String): Map<Name, Any> = when (target) { override fun content(target: String): Map<Name, Any> = when (target) {
@ -41,7 +40,6 @@ public actual class PlotlyPlugin : VisionPlugin(), ElementVisionRenderer {
public actual companion object : PluginFactory<PlotlyPlugin> { public actual companion object : PluginFactory<PlotlyPlugin> {
override val tag: PluginTag = PluginTag("vision.plotly.js", PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag("vision.plotly.js", PluginTag.DATAFORGE_GROUP)
override val type: KClass<PlotlyPlugin> = PlotlyPlugin::class
override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin() override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin()

View File

@ -6,7 +6,6 @@ import space.kscience.dataforge.context.PluginFactory
import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.context.PluginTag
import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.Meta
import space.kscience.visionforge.VisionPlugin import space.kscience.visionforge.VisionPlugin
import kotlin.reflect.KClass
public actual class PlotlyPlugin : VisionPlugin() { public actual class PlotlyPlugin : VisionPlugin() {
@ -16,7 +15,6 @@ public actual class PlotlyPlugin : VisionPlugin() {
public actual companion object : PluginFactory<PlotlyPlugin> { public actual companion object : PluginFactory<PlotlyPlugin> {
override val tag: PluginTag = PluginTag("vision.plotly", PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag("vision.plotly", PluginTag.DATAFORGE_GROUP)
override val type: KClass<PlotlyPlugin> = PlotlyPlugin::class
override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin() override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin()

View File

@ -2,12 +2,14 @@ plugins {
id("space.kscience.gradle.jvm") id("space.kscience.gradle.jvm")
} }
val ktorVersion = npmlibs.versions.ktor.get() kscience{
useKtor()
dependencies { dependencies {
api(project(":visionforge-core")) api(projects.visionforgeCore)
api("io.ktor:ktor-server-cio:${ktorVersion}") api("io.ktor:ktor-server-cio")
api("io.ktor:ktor-server-html-builder:${ktorVersion}") api("io.ktor:ktor-server-html-builder")
api("io.ktor:ktor-server-websockets:${ktorVersion}") api("io.ktor:ktor-server-websockets")
implementation("io.ktor:ktor-server-cors:${ktorVersion}") implementation("io.ktor:ktor-server-cors")
}
} }

View File

@ -1,35 +1,24 @@
import space.kscience.gradle.KScienceVersions
plugins { plugins {
id("space.kscience.gradle.mpp") id("space.kscience.gradle.mpp")
} }
kscience{ kscience {
useSerialization{ jvm()
js()
useSerialization {
json() json()
} }
}
kotlin {
sourceSets {
commonMain {
dependencies { dependencies {
api(project(":visionforge-core")) api(projects.visionforgeCore)
}
}
commonTest{
dependencies{
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${KScienceVersions.coroutinesVersion}")
}
}
jvmTest{
dependencies{
implementation("ch.qos.logback:logback-classic:1.2.11")
} }
testDependencies {
implementation(spclibs.kotlinx.coroutines.test)
} }
dependencies(jvmTest) {
implementation(spclibs.logback.classic)
} }
} }
readme{ readme {
maturity = space.kscience.gradle.Maturity.DEVELOPMENT maturity = space.kscience.gradle.Maturity.DEVELOPMENT
} }

View File

@ -169,14 +169,19 @@ internal fun float(name: Name, default: Number): ReadWriteProperty<Solid, Number
} }
} }
internal fun point(name: Name, default: Float): ReadWriteProperty<Solid, Point3D?> = internal fun point(
name: Name,
defaultX: Float,
defaultY: Float = defaultX,
defaultZ: Float = defaultX,
): ReadWriteProperty<Solid, Point3D?> =
object : ReadWriteProperty<Solid, Point3D?> { object : ReadWriteProperty<Solid, Point3D?> {
override fun getValue(thisRef: Solid, property: KProperty<*>): Point3D? { override fun getValue(thisRef: Solid, property: KProperty<*>): Point3D? {
val item = thisRef.properties.own?.get(name) ?: return null val item = thisRef.properties.own?.get(name) ?: return null
return object : Point3D { return object : Point3D {
override val x: Float get() = item[X_KEY]?.float ?: default override val x: Float get() = item[X_KEY]?.float ?: defaultX
override val y: Float get() = item[Y_KEY]?.float ?: default override val y: Float get() = item[Y_KEY]?.float ?: defaultY
override val z: Float get() = item[Z_KEY]?.float ?: default override val z: Float get() = item[Z_KEY]?.float ?: defaultZ
} }
} }

View File

@ -10,13 +10,12 @@ import kotlinx.serialization.serializer
import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.Context
import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginFactory
import space.kscience.dataforge.context.PluginTag 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.meta.Meta
import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.misc.DFExperimental
import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.Name
import space.kscience.visionforge.* import space.kscience.visionforge.*
import space.kscience.visionforge.html.VisionOutput import space.kscience.visionforge.html.VisionOutput
import kotlin.reflect.KClass
public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer<Solid> { public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer<Solid> {
@ -30,12 +29,11 @@ public class Solids(meta: Meta) : VisionPlugin(meta), MutableVisionContainer<Sol
public companion object : PluginFactory<Solids>, MutableVisionContainer<Solid> { public companion object : PluginFactory<Solids>, MutableVisionContainer<Solid> {
override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP)
override val type: KClass<out Solids> = Solids::class
public val default: Solids by lazy { public val default: Solids by lazy {
Context("@Solids") { Context("@Solids") {
plugin(Solids) plugin(Solids)
}.fetch(Solids) }.request(Solids)
} }
override fun build(context: Context, meta: Meta): Solids = Solids(meta) override fun build(context: Context, meta: Meta): Solids = Solids(meta)

View File

@ -1,7 +1,7 @@
package space.kscience.visionforge.solid package space.kscience.visionforge.solid
import space.kscience.dataforge.context.Global 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.dataforge.misc.DFExperimental
import space.kscience.visionforge.getChild import space.kscience.visionforge.getChild
import kotlin.test.Test import kotlin.test.Test
@ -19,7 +19,7 @@ class SolidPluginTest {
@DFExperimental @DFExperimental
@Test @Test
fun testPluginConverter() { fun testPluginConverter() {
val visionManager = Global.fetch(Solids).visionManager val visionManager = Global.request(Solids).visionManager
val meta = visionManager.encodeToMeta(vision) val meta = visionManager.encodeToMeta(vision)
val reconstructed = visionManager.decodeFromMeta(meta) as SolidGroup val reconstructed = visionManager.decodeFromMeta(meta) as SolidGroup

View File

@ -1,7 +1,7 @@
package space.kscience.visionforge.solid package space.kscience.visionforge.solid
import space.kscience.dataforge.context.Global 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.Meta
import space.kscience.dataforge.meta.asValue import space.kscience.dataforge.meta.asValue
import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.asName
@ -12,18 +12,18 @@ import kotlin.test.assertEquals
import kotlin.test.assertTrue import kotlin.test.assertTrue
internal class VisionUpdateTest { internal class VisionUpdateTest {
val solidManager = Global.fetch(Solids) val solidManager = Global.request(Solids)
val visionManager = solidManager.visionManager val visionManager = solidManager.visionManager
@Test @Test
fun testVisionUpdate(){ fun testVisionUpdate() {
val targetVision = Solids.solidGroup { val targetVision = Solids.solidGroup {
box(200,200,200, name = "origin") box(200, 200, 200, name = "origin")
} }
val dif = visionManager.VisionChange{ val dif = visionManager.VisionChange {
solidGroup ("top") { solidGroup("top") {
color.set(123) color.set(123)
box(100,100,100) box(100, 100, 100)
} }
propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue()))
propertyChanged("origin".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) targetVision.update(dif)
assertTrue { targetVision.children.getChild("top") is SolidGroup } assertTrue { targetVision.children.getChild("top") is SolidGroup }
assertEquals("red", (targetVision.children.getChild("origin") as Solid).color.string) // Should work 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 @Test
fun testVisionChangeSerialization(){ fun testVisionChangeSerialization() {
val change = visionManager.VisionChange{ val change = visionManager.VisionChange {
solidGroup("top") { solidGroup("top") {
color.set(123) color.set(123)
box(100,100,100) box(100, 100, 100)
} }
propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue())) propertyChanged("top".asName(), SolidMaterial.MATERIAL_COLOR_KEY, Meta("red".asValue()))
propertyChanged("origin".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) val serialized = visionManager.jsonFormat.encodeToString(VisionChange.serializer(), change)
println(serialized) println(serialized)
val reconstructed = visionManager.jsonFormat.decodeFromString(VisionChange.serializer(), serialized) val reconstructed = visionManager.jsonFormat.decodeFromString(VisionChange.serializer(), serialized)
assertEquals(change.properties,reconstructed.properties) assertEquals(change.properties, reconstructed.properties)
} }
} }

View File

@ -2,13 +2,10 @@ plugins {
id("space.kscience.gradle.mpp") id("space.kscience.gradle.mpp")
} }
val tablesVersion = "0.2.0-dev-3" val tablesVersion = "0.2.0-dev-4"
kscience { kscience {
useSerialization() jvm()
}
kotlin {
js { js {
useCommonJs() useCommonJs()
binaries.library() binaries.library()
@ -20,21 +17,15 @@ kotlin {
} }
} }
} }
sourceSets {
commonMain {
dependencies { dependencies {
api(project(":visionforge-core")) api(projects.visionforgeCore)
api("space.kscience:tables-kt:${tablesVersion}") api("space.kscience:tables-kt:${tablesVersion}")
} }
} dependencies(jsMain){
jsMain {
dependencies {
implementation(npm("tabulator-tables", "5.0.1")) implementation(npm("tabulator-tables", "5.0.1"))
implementation(npm("@types/tabulator-tables", "5.0.1")) implementation(npm("@types/tabulator-tables", "5.0.1"))
} }
} useSerialization()
}
} }
readme{ readme{

View File

@ -9,7 +9,6 @@ import space.kscience.dataforge.context.PluginTag
import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.Meta
import space.kscience.visionforge.Vision import space.kscience.visionforge.Vision
import space.kscience.visionforge.VisionPlugin import space.kscience.visionforge.VisionPlugin
import kotlin.reflect.KClass
public class TableVisionPlugin : VisionPlugin() { public class TableVisionPlugin : VisionPlugin() {
override val tag: PluginTag get() = Companion.tag override val tag: PluginTag get() = Companion.tag
@ -23,7 +22,6 @@ public class TableVisionPlugin : VisionPlugin() {
public companion object : PluginFactory<TableVisionPlugin> { public companion object : PluginFactory<TableVisionPlugin> {
override val tag: PluginTag = PluginTag("vision.table", PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag("vision.table", PluginTag.DATAFORGE_GROUP)
override val type: KClass<TableVisionPlugin> = TableVisionPlugin::class
override fun build(context: Context, meta: Meta): TableVisionPlugin = TableVisionPlugin() override fun build(context: Context, meta: Meta): TableVisionPlugin = TableVisionPlugin()
} }

View File

@ -16,7 +16,6 @@ import space.kscience.visionforge.Vision
import space.kscience.visionforge.VisionClient import space.kscience.visionforge.VisionClient
import tabulator.Tabulator import tabulator.Tabulator
import tabulator.TabulatorFull import tabulator.TabulatorFull
import kotlin.reflect.KClass
public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer { public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer {
public val visionClient: VisionClient by require(VisionClient) public val visionClient: VisionClient by require(VisionClient)
@ -89,7 +88,6 @@ public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer {
public companion object : PluginFactory<TableVisionJsPlugin> { public companion object : PluginFactory<TableVisionJsPlugin> {
override val tag: PluginTag = PluginTag("vision.table.js", PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag("vision.table.js", PluginTag.DATAFORGE_GROUP)
override val type: KClass<TableVisionJsPlugin> = TableVisionJsPlugin::class
override fun build(context: Context, meta: Meta): TableVisionJsPlugin = TableVisionJsPlugin() override fun build(context: Context, meta: Meta): TableVisionJsPlugin = TableVisionJsPlugin()
} }

View File

@ -10,7 +10,7 @@ kotlin{
} }
dependencies { dependencies {
api(project(":visionforge-solid")) api(projects.visionforgeSolid)
implementation(npm("three", "0.143.0")) implementation(npm("three", "0.143.0"))
implementation(npm("three-csg-ts", "3.1.10")) implementation(npm("three-csg-ts", "3.1.10"))
implementation(npm("three.meshline","1.4.0")) implementation(npm("three.meshline","1.4.0"))

View File

@ -158,7 +158,6 @@ public class ThreePlugin : AbstractPlugin(), ElementVisionRenderer {
public companion object : PluginFactory<ThreePlugin> { public companion object : PluginFactory<ThreePlugin> {
override val tag: PluginTag = PluginTag("vision.threejs", PluginTag.DATAFORGE_GROUP) override val tag: PluginTag = PluginTag("vision.threejs", PluginTag.DATAFORGE_GROUP)
override val type: KClass<ThreePlugin> = ThreePlugin::class
override fun build(context: Context, meta: Meta): ThreePlugin = ThreePlugin() override fun build(context: Context, meta: Meta): ThreePlugin = ThreePlugin()
} }

View File

@ -4,55 +4,26 @@ plugins {
val ktorVersion: String by rootProject.extra val ktorVersion: String by rootProject.extra
kotlin { kscience {
js(IR) { fullStack("js/visionforge-three.js") {
browser {
webpackTask {
this.outputFileName = "js/visionforge-three.js"
}
commonWebpackConfig { commonWebpackConfig {
cssSupport{ cssSupport {
enabled.set(false) enabled.set(false)
} }
} }
} }
binaries.executable()
}
sourceSets {
commonMain {
dependencies { dependencies {
api(projects.visionforgeSolid) api(projects.visionforgeSolid)
} }
}
jvmMain { dependencies(jvmMain) {
dependencies {
api(projects.visionforgeServer) api(projects.visionforgeServer)
} }
}
jsMain { dependencies(jsMain) {
dependencies {
api(projects.visionforgeThreejs) api(projects.visionforgeThreejs)
api(projects.ui.ring) api(projects.ui.ring)
} compileOnly(npm("webpack-bundle-analyzer","4.5.0"))
}
}
}
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<ProcessResources>("jvmProcessResources") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
if (devMode) {
dependsOn(jsBrowserDevelopmentExecutableDistribution)
from(jsBrowserDevelopmentExecutableDistribution)
} else {
dependsOn(jsBrowserDistribution)
from(jsBrowserDistribution)
} }
} }