From a33d9d19464076e382210fa9e60a7e622d851894 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 14 Aug 2021 15:54:16 +0300 Subject: [PATCH] fix for Plotly vision serialization --- .../space/kscience/visionforge/html/VisionTagConsumer.kt | 2 ++ .../space/kscience/visionforge/markup/VisionOfMarkup.kt | 4 ++++ .../space/kscience/visionforge/plotly/VisionOfPlotly.kt | 9 +++++---- .../kotlin/space/kscience/visionforge/solid/Solids.kt | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt index a0b64d8b..035b6a6e 100644 --- a/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt +++ b/visionforge-core/src/commonMain/kotlin/space/kscience/visionforge/html/VisionTagConsumer.kt @@ -11,6 +11,7 @@ import space.kscience.dataforge.names.NameToken import space.kscience.dataforge.names.asName import space.kscience.visionforge.Vision import space.kscience.visionforge.VisionManager +import space.kscience.visionforge.root import kotlin.collections.set @DslMarker @@ -84,6 +85,7 @@ public abstract class VisionTagConsumer( ): T { val output = VisionOutput(manager) val vision = output.visionProvider() + vision.root(manager) return vision(name, vision, output.meta) } diff --git a/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/VisionOfMarkup.kt b/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/VisionOfMarkup.kt index fd1dcd80..89a6836e 100644 --- a/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/VisionOfMarkup.kt +++ b/visionforge-markdown/src/commonMain/kotlin/space/kscience/visionforge/markup/VisionOfMarkup.kt @@ -5,6 +5,7 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.polymorphic import kotlinx.serialization.modules.subclass +import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.meta.string import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.asName @@ -18,6 +19,9 @@ public class VisionOfMarkup( public val format: String = COMMONMARK_FORMAT ) : VisionBase() { + //FIXME to be removed after https://github.com/Kotlin/kotlinx.serialization/issues/1602 fix + override var properties: MutableMeta? = null + //TODO add templates public var content: String? diff --git a/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt b/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt index 8874c694..99df2e84 100644 --- a/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt +++ b/visionforge-plotly/src/commonMain/kotlin/space/kscience/visionforge/plotly/VisionOfPlotly.kt @@ -2,16 +2,19 @@ package space.kscience.visionforge.plotly import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import space.kscience.dataforge.meta.MutableMeta import space.kscience.dataforge.misc.DFExperimental import space.kscience.plotly.Plot import space.kscience.plotly.Plotly import space.kscience.visionforge.VisionBase import space.kscience.visionforge.html.VisionOutput -import space.kscience.visionforge.root @Serializable @SerialName("vision.plotly") public class VisionOfPlotly private constructor() : VisionBase() { + //FIXME to be removed after https://github.com/Kotlin/kotlinx.serialization/issues/1602 fix + override var properties: MutableMeta? = null + public constructor(plot: Plot) : this() { properties = plot.meta } @@ -23,6 +26,4 @@ public fun Plot.asVision(): VisionOfPlotly = VisionOfPlotly(this) @DFExperimental public inline fun VisionOutput.plotly( block: Plot.() -> Unit, -): VisionOfPlotly = VisionOfPlotly(Plotly.plot(block)).apply { - root(this@plotly.manager) -} \ No newline at end of file +): VisionOfPlotly = VisionOfPlotly(Plotly.plot(block)) \ 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 67224699..ca83f00f 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 @@ -69,4 +69,4 @@ public class Solids(meta: Meta) : VisionPlugin(meta) { @VisionBuilder @DFExperimental public inline fun VisionOutput.solid(block: SolidGroup.() -> Unit): SolidGroup = - SolidGroup().apply(block).apply { root(this@solid.manager) } + SolidGroup().apply(block)