Workarround serialization bug
This commit is contained in:
parent
8d74bc55d1
commit
e7f0e1e4fc
@ -4,7 +4,7 @@ plugins {
|
|||||||
// kotlin("js") version "1.5.30" apply false
|
// kotlin("js") version "1.5.30" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion by extra("0.5.2-dev-3")
|
val dataforgeVersion by extra("0.5.2")
|
||||||
val fxVersion by extra("11")
|
val fxVersion by extra("11")
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@ -16,7 +16,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "space.kscience"
|
group = "space.kscience"
|
||||||
version = "0.2.0-dev-25"
|
version = "0.2.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
@ -7,7 +7,7 @@ import kotlinx.coroutines.isActive
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.html.div
|
import kotlinx.html.div
|
||||||
import kotlinx.html.h1
|
import kotlinx.html.h1
|
||||||
import space.kscience.dataforge.context.Global
|
import space.kscience.dataforge.context.Context
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.Name
|
||||||
import space.kscience.visionforge.solid.*
|
import space.kscience.visionforge.solid.*
|
||||||
import space.kscience.visionforge.three.server.*
|
import space.kscience.visionforge.three.server.*
|
||||||
@ -15,7 +15,7 @@ import space.kscience.visionforge.visionManager
|
|||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val satContext = Global.buildContext ("sat") {
|
val satContext = Context("sat") {
|
||||||
plugin(Solids)
|
plugin(Solids)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,3 +5,6 @@ kotlin.jupyter.add.scanner=false
|
|||||||
|
|
||||||
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G
|
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
|
||||||
|
publishing.github=false
|
||||||
|
publishing.sonatype=false
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package space.kscience.visionforge
|
package space.kscience.visionforge
|
||||||
|
|
||||||
|
import kotlinx.serialization.EncodeDefault
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
@ -29,7 +30,7 @@ internal data class MetaListener(
|
|||||||
@SerialName("vision")
|
@SerialName("vision")
|
||||||
public open class VisionBase(
|
public open class VisionBase(
|
||||||
@Transient override var parent: VisionGroup? = null,
|
@Transient override var parent: VisionGroup? = null,
|
||||||
protected var properties: MutableMeta? = null
|
@EncodeDefault protected var properties: MutableMeta? = null,
|
||||||
) : Vision {
|
) : Vision {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@ -131,7 +132,6 @@ public open class VisionBase(
|
|||||||
|
|
||||||
override val descriptor: MetaDescriptor? get() = null
|
override val descriptor: MetaDescriptor? get() = null
|
||||||
|
|
||||||
|
|
||||||
override fun invalidateProperty(propertyName: Name) {
|
override fun invalidateProperty(propertyName: Name) {
|
||||||
if (propertyName == STYLE_KEY) {
|
if (propertyName == STYLE_KEY) {
|
||||||
styles.mapNotNull { getStyle(it) }.asSequence()
|
styles.mapNotNull { getStyle(it) }.asSequence()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package space.kscience.visionforge
|
package space.kscience.visionforge
|
||||||
|
|
||||||
|
import kotlinx.serialization.EncodeDefault
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
@ -16,7 +17,7 @@ private class StructureChangeListener(val owner: Any?, val callback: VisionGroup
|
|||||||
@Serializable
|
@Serializable
|
||||||
@SerialName("vision.group")
|
@SerialName("vision.group")
|
||||||
public open class VisionGroupBase(
|
public open class VisionGroupBase(
|
||||||
@SerialName("children") protected val childrenInternal: MutableMap<NameToken, Vision> = LinkedHashMap(),
|
@EncodeDefault @SerialName("children") protected val childrenInternal: MutableMap<NameToken, Vision> = LinkedHashMap(),
|
||||||
) : VisionBase(), MutableVisionGroup {
|
) : VisionBase(), MutableVisionGroup {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,21 +103,19 @@ public open class VisionGroupBase(
|
|||||||
/**
|
/**
|
||||||
* Recursively create a child group
|
* Recursively create a child group
|
||||||
*/
|
*/
|
||||||
private fun createGroups(name: Name): VisionGroupBase {
|
private fun createGroups(name: Name): VisionGroupBase = when {
|
||||||
return when {
|
name.isEmpty() -> error("Should be unreachable")
|
||||||
name.isEmpty() -> error("Should be unreachable")
|
name.length == 1 -> {
|
||||||
name.length == 1 -> {
|
val token = name.tokens.first()
|
||||||
val token = name.tokens.first()
|
when (val current = children[token]) {
|
||||||
when (val current = children[token]) {
|
null -> createGroup().also { child ->
|
||||||
null -> createGroup().also { child ->
|
attachChild(token, child)
|
||||||
attachChild(token, child)
|
|
||||||
}
|
|
||||||
is VisionGroupBase -> current
|
|
||||||
else -> error("Can't create group with name $name because it exists and not a group")
|
|
||||||
}
|
}
|
||||||
|
is VisionGroupBase -> current
|
||||||
|
else -> error("Can't create group with name $name because it exists and not a group")
|
||||||
}
|
}
|
||||||
else -> createGroups(name.tokens.first().asName()).createGroups(name.cutFirst())
|
|
||||||
}
|
}
|
||||||
|
else -> createGroups(name.tokens.first().asName()).createGroups(name.cutFirst())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package space.kscience.visionforge
|
package space.kscience.visionforge
|
||||||
|
|
||||||
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.PolymorphicSerializer
|
import kotlinx.serialization.PolymorphicSerializer
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
@ -68,12 +69,14 @@ public class VisionManager(meta: Meta) : AbstractPlugin(meta) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalSerializationApi::class)
|
||||||
public val defaultJson: Json = Json {
|
public val defaultJson: Json = Json {
|
||||||
serializersModule = defaultSerialModule
|
serializersModule = defaultSerialModule
|
||||||
prettyPrint = true
|
prettyPrint = true
|
||||||
useArrayPolymorphism = false
|
useArrayPolymorphism = false
|
||||||
encodeDefaults = false
|
encodeDefaults = false
|
||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
|
explicitNulls = false
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val visionSerializer: PolymorphicSerializer<Vision> = PolymorphicSerializer(Vision::class)
|
internal val visionSerializer: PolymorphicSerializer<Vision> = PolymorphicSerializer(Vision::class)
|
||||||
|
@ -37,8 +37,7 @@ fun FlowContent.renderVisionFragment(
|
|||||||
@DFExperimental
|
@DFExperimental
|
||||||
class HtmlTagTest {
|
class HtmlTagTest {
|
||||||
|
|
||||||
fun VisionOutput.base(block: VisionBase.() -> Unit) =
|
fun VisionOutput.base(block: VisionBase.() -> Unit) = VisionBase().apply(block)
|
||||||
VisionBase().apply(block)
|
|
||||||
|
|
||||||
val fragment: HtmlVisionFragment = {
|
val fragment: HtmlVisionFragment = {
|
||||||
div {
|
div {
|
||||||
|
@ -18,6 +18,7 @@ import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_FETCH_
|
|||||||
import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_NAME_ATTRIBUTE
|
import space.kscience.visionforge.html.VisionTagConsumer.Companion.OUTPUT_NAME_ATTRIBUTE
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
import kotlin.time.ExperimentalTime
|
||||||
|
|
||||||
public class VisionClient : AbstractPlugin() {
|
public class VisionClient : AbstractPlugin() {
|
||||||
override val tag: PluginTag get() = Companion.tag
|
override val tag: PluginTag get() = Companion.tag
|
||||||
@ -56,6 +57,7 @@ public class VisionClient : AbstractPlugin() {
|
|||||||
|
|
||||||
private fun Element.getFlag(attribute: String): Boolean = attributes[attribute]?.value != null
|
private fun Element.getFlag(attribute: String): Boolean = attributes[attribute]?.value != null
|
||||||
|
|
||||||
|
@OptIn(ExperimentalTime::class)
|
||||||
private fun renderVision(name: String, element: Element, vision: Vision?, outputMeta: Meta) {
|
private fun renderVision(name: String, element: Element, vision: Vision?, outputMeta: Meta) {
|
||||||
if (vision != null) {
|
if (vision != null) {
|
||||||
val renderer = findRendererFor(vision) ?: error("Could nof find renderer for $vision")
|
val renderer = findRendererFor(vision) ?: error("Could nof find renderer for $vision")
|
||||||
|
@ -15,6 +15,7 @@ public class VisionOfPlotly private constructor() : VisionBase() {
|
|||||||
public constructor(plot: Plot) : this() {
|
public constructor(plot: Plot) : this() {
|
||||||
properties = plot.meta
|
properties = plot.meta
|
||||||
}
|
}
|
||||||
|
|
||||||
public val plot: Plot get() = Plot(meta)
|
public val plot: Plot get() = Plot(meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ import java.net.URI
|
|||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
import kotlin.time.ExperimentalTime
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,7 +122,7 @@ public class VisionServer internal constructor(
|
|||||||
/**
|
/**
|
||||||
* Server a map of visions without providing explicit html page for them
|
* Server a map of visions without providing explicit html page for them
|
||||||
*/
|
*/
|
||||||
@OptIn(DFExperimental::class)
|
@OptIn(DFExperimental::class, ExperimentalTime::class)
|
||||||
public fun serveVisions(route: Route, visions: Map<Name, Vision>): Unit = route {
|
public fun serveVisions(route: Route, visions: Map<Name, Vision>): Unit = route {
|
||||||
application.log.info("Serving visions $visions at $route")
|
application.log.info("Serving visions $visions at $route")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user