From 4b1149b99ba35efc2672d89a8879824bb92c4d3a Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 6 Jul 2022 11:11:48 +0300 Subject: [PATCH] Migrate to new build tools and DF 0.6 --- build.gradle.kts | 10 ++++++++-- .../kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt | 5 +++-- .../js-playground/src/main/kotlin/JsPlaygroundApp.kt | 5 +++-- .../kotlin/ru/mipt/npm/muon/monitor/MMDemoApp.kt | 5 +++-- gradle.properties | 2 +- ui/react/build.gradle.kts | 4 ++++ .../kscience/visionforge/react/PropertyEditor.kt | 4 ++-- .../kotlin/space/kscience/visionforge/react/ext.kt | 10 ++++++++++ .../ThreeWithControlsPlugin.kt | 8 +++++--- .../ringPropertyEditor.kt | 5 +++-- .../space/kscience/visionforge/VisionManager.kt | 2 +- .../space/kscience/visionforge/VisionClient.kt | 3 +-- .../kotlin/space/kscience/visionforge/FXPlugin.kt | 5 +++-- .../space/kscience/visionforge/solid/FX3DPlugin.kt | 3 ++- .../kscience/visionforge/markup/MarkupPlugin.kt | 4 +++- .../space/kscience/visionforge/plotly/plotlyJs.kt | 4 +++- .../space/kscience/visionforge/plotly/plotlyJvm.kt | 5 +++-- .../space/kscience/visionforge/solid/Solids.kt | 3 ++- visionforge-tables/build.gradle.kts | 2 +- .../kscience/visionforge/tables/TableVisionPlugin.kt | 4 ++-- .../kscience/visionforge/tables/VisionOfTable.kt | 6 +++--- .../kscience/visionforge/tables/VisionOfTableTest.kt | 4 ++-- .../visionforge/tables/TableVisionJsPlugin.kt | 12 ++++++------ .../visionforge/solid/three/ThreeLabelFactory.kt | 2 +- .../kscience/visionforge/solid/three/ThreePlugin.kt | 3 ++- 25 files changed, 77 insertions(+), 43 deletions(-) create mode 100644 ui/react/src/main/kotlin/space/kscience/visionforge/react/ext.kt diff --git a/build.gradle.kts b/build.gradle.kts index 3d983923..5e8bc323 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,12 +3,12 @@ plugins { // id("org.jetbrains.kotlinx.kover") version "0.5.0" } -val dataforgeVersion by extra("0.5.2") +val dataforgeVersion by extra("0.6.0-dev-10") val fxVersion by extra("11") allprojects{ group = "space.kscience" - version = "0.3.0-dev-1" + version = "0.3.0-dev-2" } subprojects { @@ -19,6 +19,12 @@ subprojects { mavenCentral() maven("https://maven.jzy3d.org/releases") } + + tasks.withType{ + kotlinOptions{ + freeCompilerArgs = freeCompilerArgs + "-Xcontext-receivers" + } + } } ksciencePublish { 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 284e09f6..edcbe6f0 100644 --- a/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt +++ b/demo/gdml/src/jsMain/kotlin/space/kscience/visionforge/gdml/demo/GdmlJsDemoApp.kt @@ -2,12 +2,13 @@ package space.kscience.visionforge.gdml.demo import kotlinx.browser.document import kotlinx.css.* -import react.dom.render +import react.dom.client.createRoot import space.kscience.dataforge.context.Context import space.kscience.gdml.GdmlShowCase import space.kscience.visionforge.Application import space.kscience.visionforge.Colors import space.kscience.visionforge.gdml.toVision +import space.kscience.visionforge.react.render import space.kscience.visionforge.solid.ambientLight import space.kscience.visionforge.solid.invoke import space.kscience.visionforge.solid.three.ThreePlugin @@ -42,7 +43,7 @@ private class GDMLDemoApp : Application { val element = document.getElementById("application") ?: error("Element with id 'application' not found on page") - render(element) { + createRoot(element).render { child(GDMLApp) { val vision = GdmlShowCase.cubes().toVision().apply { ambientLight { diff --git a/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt b/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt index 5e09911b..1cd2611b 100644 --- a/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt +++ b/demo/js-playground/src/main/kotlin/JsPlaygroundApp.kt @@ -1,6 +1,6 @@ import kotlinx.browser.document import kotlinx.css.* -import react.dom.render +import react.dom.client.createRoot import ringui.SmartTabs import ringui.Tab import space.kscience.dataforge.context.Context @@ -10,6 +10,7 @@ import space.kscience.visionforge.Application import space.kscience.visionforge.Colors import space.kscience.visionforge.VisionClient import space.kscience.visionforge.plotly.PlotlyPlugin +import space.kscience.visionforge.react.render import space.kscience.visionforge.ring.ThreeCanvasWithControls import space.kscience.visionforge.ring.ThreeWithControlsPlugin import space.kscience.visionforge.ring.solid @@ -38,7 +39,7 @@ private class JsPlaygroundApp : Application { val element = document.getElementById("playground") ?: error("Element with id 'playground' not found on page") - render(element) { + createRoot(element).render { styledDiv { css { padding(0.pt) 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 6b611146..17c3f149 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 @@ -1,11 +1,12 @@ package ru.mipt.npm.muon.monitor import kotlinx.browser.document -import react.dom.render +import react.dom.client.createRoot import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.fetch import space.kscience.visionforge.Application import space.kscience.visionforge.VisionManager +import space.kscience.visionforge.react.render import space.kscience.visionforge.solid.three.ThreePlugin import space.kscience.visionforge.startApplication @@ -21,7 +22,7 @@ private class MMDemoApp : Application { val model = Model(visionManager) val element = document.getElementById("app") ?: error("Element with id 'app' not found on page") - render(element) { + createRoot(element).render { child(MMApp) { attrs { this.model = model diff --git a/gradle.properties b/gradle.properties index 5a1cefb4..95d6d923 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ kotlin.jupyter.add.scanner=false org.gradle.parallel=true org.gradle.jvmargs=-Xmx4G -toolsVersion=0.11.4-kotlin-1.6.20 \ No newline at end of file +toolsVersion=0.11.7-kotlin-1.7.0 \ No newline at end of file diff --git a/ui/react/build.gradle.kts b/ui/react/build.gradle.kts index 40853ca9..d71dc6ac 100644 --- a/ui/react/build.gradle.kts +++ b/ui/react/build.gradle.kts @@ -8,4 +8,8 @@ dependencies{ api("org.jetbrains.kotlin-wrappers:kotlin-react-dom") // implementation(npm("react-select","4.3.0")) implementation(project(":visionforge-threejs")) +} + +rootProject.extensions.configure { + versions.webpackCli.version = "4.10.0" } \ No newline at end of file diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/PropertyEditor.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/PropertyEditor.kt index 6c677e2e..29c9b49e 100644 --- a/ui/react/src/main/kotlin/space/kscience/visionforge/react/PropertyEditor.kt +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/PropertyEditor.kt @@ -7,7 +7,7 @@ import org.w3c.dom.Element import org.w3c.dom.events.Event import react.* import react.dom.attrs -import react.dom.render +import react.dom.client.createRoot import space.kscience.dataforge.meta.* import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.ValueRequirement @@ -235,6 +235,6 @@ public fun Element.configEditor( default: Meta = config, descriptor: MetaDescriptor? = null, key: Any? = null, -): Unit = render(this) { +): Unit = createRoot(this).render { configEditor(config, default, descriptor, key = key) } \ No newline at end of file diff --git a/ui/react/src/main/kotlin/space/kscience/visionforge/react/ext.kt b/ui/react/src/main/kotlin/space/kscience/visionforge/react/ext.kt new file mode 100644 index 00000000..ae47fa65 --- /dev/null +++ b/ui/react/src/main/kotlin/space/kscience/visionforge/react/ext.kt @@ -0,0 +1,10 @@ +package space.kscience.visionforge.react + +import react.Props +import react.RBuilder +import react.createElement +import react.dom.client.Root + +public fun Root.render(block: RBuilder.() -> Unit) { + render(createElement(block)) +} \ No newline at end of file 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 c01b5ae1..bf1a2160 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 @@ -2,7 +2,7 @@ package space.kscience.visionforge.ring import kotlinx.coroutines.async import org.w3c.dom.Element -import react.child +import react.dom.client.createRoot import space.kscience.dataforge.context.AbstractPlugin import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.PluginFactory @@ -12,6 +12,7 @@ import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName import space.kscience.visionforge.ElementVisionRenderer 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 @@ -25,7 +26,7 @@ public class ThreeWithControlsPlugin : AbstractPlugin(), ElementVisionRenderer { if (vision is Solid) ElementVisionRenderer.DEFAULT_RATING * 2 else ElementVisionRenderer.ZERO_RATING override fun render(element: Element, vision: Vision, meta: Meta) { - react.dom.render(element) { + createRoot(element).render { child(ThreeCanvasWithControls) { attrs { this.context = this@ThreeWithControlsPlugin.context @@ -45,6 +46,7 @@ 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 invoke(meta: Meta, context: Context): ThreeWithControlsPlugin = ThreeWithControlsPlugin() + + override fun build(context: Context, meta: Meta): ThreeWithControlsPlugin = ThreeWithControlsPlugin() } } \ No newline at end of file diff --git a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt index 06f2a1c0..5c959184 100644 --- a/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt +++ b/ui/ring/src/main/kotlin/space.kscience.visionforge.ring/ringPropertyEditor.kt @@ -2,8 +2,8 @@ package space.kscience.visionforge.ring import org.w3c.dom.Element import react.RBuilder +import react.dom.client.createRoot import react.dom.p -import react.dom.render import ringui.Island import ringui.SmartTabs import ringui.Tab @@ -14,6 +14,7 @@ import space.kscience.visionforge.getStyle import space.kscience.visionforge.react.flexColumn import space.kscience.visionforge.react.metaViewer import space.kscience.visionforge.react.propertyEditor +import space.kscience.visionforge.react.render import space.kscience.visionforge.solid.SolidReference import space.kscience.visionforge.styles @@ -72,6 +73,6 @@ public fun RBuilder.ringPropertyEditor( public fun Element.ringPropertyEditor( item: Vision, descriptor: MetaDescriptor? = item.descriptor, -): Unit = render(this) { +): Unit = createRoot(this).render { ringPropertyEditor(item, descriptor = descriptor) } \ No newline at end of file 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 118fd47c..cd017cad 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/VisionManager.kt @@ -63,7 +63,7 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta) { public const val VISION_SERIALIZER_MODULE_TARGET: String = "visionSerializerModule" - override fun invoke(meta: Meta, context: Context): VisionManager = VisionManager(meta) + override fun build(context: Context, meta: Meta): VisionManager = VisionManager(meta) private val defaultSerialModule: SerializersModule = SerializersModule { polymorphic(Vision::class) { 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 c437a5d6..e9425afb 100644 --- a/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt +++ b/visionforge-core/src/jsMain/kotlin/space/kscience/visionforge/VisionClient.kt @@ -203,8 +203,7 @@ public class VisionClient : AbstractPlugin() { ) else super.content(target) public companion object : PluginFactory { - - override fun invoke(meta: Meta, context: Context): VisionClient = VisionClient() + override fun build(context: Context, meta: Meta): VisionClient = VisionClient() override val tag: PluginTag = PluginTag(name = "vision.client", group = PluginTag.DATAFORGE_GROUP) diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt index c571059c..4edc4f13 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/FXPlugin.kt @@ -95,8 +95,9 @@ public class FXPlugin(meta: Meta = Meta.EMPTY) : AbstractPlugin(meta) { public companion object : PluginFactory { override val type: KClass = FXPlugin::class override val tag: PluginTag = PluginTag("vis.fx", group = PluginTag.DATAFORGE_GROUP) - override fun invoke(meta: Meta, context: Context): FXPlugin = - FXPlugin(meta) + + override fun build(context: Context, meta: Meta): FXPlugin = FXPlugin(meta) + } } diff --git a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt index 48f99ac1..e16b2126 100644 --- a/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt +++ b/visionforge-fx/src/main/kotlin/space/kscience/visionforge/solid/FX3DPlugin.kt @@ -138,7 +138,8 @@ public class FX3DPlugin : AbstractPlugin() { public companion object : PluginFactory { override val tag: PluginTag = PluginTag("vision.fx3D", PluginTag.DATAFORGE_GROUP) override val type: KClass = FX3DPlugin::class - override fun invoke(meta: Meta, context: Context): FX3DPlugin = FX3DPlugin() + + override fun build(context: Context, meta: Meta): FX3DPlugin = FX3DPlugin() } } 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 4d7a1060..939669a0 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 @@ -47,6 +47,8 @@ public 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 invoke(meta: Meta, context: Context): MarkupPlugin = MarkupPlugin() + + override fun build(context: Context, meta: Meta): MarkupPlugin = MarkupPlugin() + } } \ 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 7406986b..d3b8473e 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 @@ -42,6 +42,8 @@ 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 invoke(meta: Meta, context: Context): PlotlyPlugin = PlotlyPlugin() + + override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin() + } } \ No newline at end of file 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 ad7be4f3..8fda1d98 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 @@ -2,7 +2,6 @@ package space.kscience.visionforge.plotly import kotlinx.serialization.modules.SerializersModule import space.kscience.dataforge.context.Context -import space.kscience.dataforge.context.Plugin import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta @@ -18,6 +17,8 @@ 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 invoke(meta: Meta, context: Context): PlotlyPlugin = PlotlyPlugin() + + override fun build(context: Context, meta: Meta): PlotlyPlugin = PlotlyPlugin() + } } \ No newline at end of file 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 7e52d709..b43d6475 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 @@ -24,7 +24,8 @@ public class Solids(meta: Meta) : VisionPlugin(meta) { public companion object : PluginFactory { override val tag: PluginTag = PluginTag(name = "vision.solid", group = PluginTag.DATAFORGE_GROUP) override val type: KClass = Solids::class - override fun invoke(meta: Meta, context: Context): Solids = Solids(meta) + + override fun build(context: Context, meta: Meta): Solids = Solids(meta) private fun PolymorphicModuleBuilder.solids() { subclass(SolidGroup.serializer()) diff --git a/visionforge-tables/build.gradle.kts b/visionforge-tables/build.gradle.kts index 55c367c5..4326da36 100644 --- a/visionforge-tables/build.gradle.kts +++ b/visionforge-tables/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("ru.mipt.npm.gradle.mpp") } -val tablesVersion = "0.1.4" +val tablesVersion = "0.2.0-dev-1" kscience { useSerialization() 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 6e632147..fd03b550 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 @@ -8,7 +8,6 @@ import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag import space.kscience.dataforge.meta.Meta import space.kscience.visionforge.Vision -import space.kscience.visionforge.VisionManager import space.kscience.visionforge.VisionPlugin import kotlin.reflect.KClass @@ -25,6 +24,7 @@ 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 invoke(meta: Meta, context: Context): TableVisionPlugin = TableVisionPlugin() + + override fun build(context: Context, meta: Meta): TableVisionPlugin = TableVisionPlugin() } } \ No newline at end of file diff --git a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt index 95888f67..6370b699 100644 --- a/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt +++ b/visionforge-tables/src/commonMain/kotlin/space/kscience/visionforge/tables/VisionOfTable.kt @@ -86,7 +86,7 @@ public fun Table.toVision(): VisionOfTable = toVision { (it ?: Double.Na @DFExperimental public inline fun VisionOutput.table( vararg headers: ColumnHeader, - block: MutableRowTable.() -> Unit, + block: RowTableBuilder.() -> Unit, ): VisionOfTable { requirePlugin(TableVisionPlugin) return RowTable(*headers, block = block).toVision() @@ -94,8 +94,8 @@ public inline fun VisionOutput.table( @DFExperimental public inline fun VisionOutput.columnTable( - columnSize: UInt, - block: MutableColumnTable.() -> Unit, + columnSize: Int, + block: ColumnTableBuilder.() -> Unit, ): VisionOfTable = ColumnTable(columnSize, block).toVision() @DFExperimental diff --git a/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt b/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt index 5796d8e2..8c9f755c 100644 --- a/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt +++ b/visionforge-tables/src/commonTest/kotlin/space/kscience/visionforge/tables/VisionOfTableTest.kt @@ -17,7 +17,7 @@ internal class VisionOfTableTest { val x by ColumnHeader.typed() val y by ColumnHeader.typed() - val table = ColumnTable(100U) { + val table = ColumnTable(100) { x.fill { it.asValue() } y.values = x.values.map { it?.double?.pow(2)?.asValue() } } @@ -27,6 +27,6 @@ internal class VisionOfTableTest { val rows = vision.rowSequence().toList() - assertEquals(50, rows[50][x]?.int) + assertEquals(50, rows[50][x].int) } } \ No newline at end of file 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 bc1fb271..28ad7327 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 @@ -7,7 +7,6 @@ import space.kscience.dataforge.context.AbstractPlugin import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.PluginFactory import space.kscience.dataforge.context.PluginTag -import space.kscience.dataforge.meta.DynamicMeta import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.toDynamic import space.kscience.dataforge.names.Name @@ -49,15 +48,15 @@ public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer { } }.toTypedArray() - columns = Array(table.headers.size + 1){ - if(it==0){ + columns = Array(table.headers.size + 1) { + if (it == 0) { jso { field = "@index" title = "#" resizable = false } } else { - val header = table.headers[it-1] + val header = table.headers[it - 1] jso { field = header.name title = header.properties.title ?: header.name @@ -67,7 +66,7 @@ public class TableVisionJsPlugin : AbstractPlugin(), ElementVisionRenderer { } - data = table.rows.mapIndexed { index, row-> + data = table.rows.mapIndexed { index, row -> val d = row.meta.toDynamic() d["@index"] = index d @@ -91,6 +90,7 @@ 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 invoke(meta: Meta, context: Context): TableVisionJsPlugin = TableVisionJsPlugin() + + override fun build(context: Context, meta: Meta): TableVisionJsPlugin = TableVisionJsPlugin() } } \ No newline at end of file diff --git a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt index 38e3e6a6..d07f542e 100644 --- a/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt +++ b/visionforge-threejs/src/main/kotlin/space/kscience/visionforge/solid/three/ThreeLabelFactory.kt @@ -4,7 +4,7 @@ package space.kscience.visionforge.solid.three import info.laht.threekt.core.Object3D import info.laht.threekt.geometries.TextBufferGeometry import info.laht.threekt.objects.Mesh -import kotlinext.js.jso +import kotlinx.js.jso import space.kscience.dataforge.context.logger import space.kscience.dataforge.context.warn import space.kscience.visionforge.onPropertyChange 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 8c32551a..182ec009 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 @@ -151,7 +151,8 @@ 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 invoke(meta: Meta, context: Context): ThreePlugin = ThreePlugin() + + override fun build(context: Context, meta: Meta): ThreePlugin = ThreePlugin() } }