v0.2.0-dev-22 #47
@ -2,10 +2,10 @@ plugins {
|
|||||||
id("ru.mipt.npm.project")
|
id("ru.mipt.npm.project")
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion by extra("0.2.0-dev-8")
|
val dataforgeVersion by extra("0.2.0")
|
||||||
val ktorVersion by extra("1.4.2")
|
val ktorVersion by extra("1.4.2")
|
||||||
val htmlVersion by extra("0.7.2")
|
val htmlVersion by extra("0.7.2")
|
||||||
val kotlinWrappersVersion by extra("pre.129-kotlin-1.4.10")
|
val kotlinWrappersVersion by extra("pre.129-kotlin-1.4.20")
|
||||||
val fxVersion by extra("14")
|
val fxVersion by extra("14")
|
||||||
|
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "hep.dataforge"
|
group = "hep.dataforge"
|
||||||
version = "0.2.0-dev-2"
|
version = "0.2.0-dev-3"
|
||||||
}
|
}
|
||||||
|
|
||||||
val githubProject by extra("visionforge")
|
val githubProject by extra("visionforge")
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import ru.mipt.npm.gradle.DependencyConfiguration
|
import ru.mipt.npm.gradle.DependencyConfiguration
|
||||||
import ru.mipt.npm.gradle.FXModule
|
import ru.mipt.npm.gradle.FXModule
|
||||||
import ru.mipt.npm.gradle.useFx
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.mpp")
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package hep.dataforge.vision.gdml.demo
|
package hep.dataforge.vision.gdml.demo
|
||||||
|
|
||||||
|
import hep.dataforge.Application
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.js.Application
|
import hep.dataforge.startApplication
|
||||||
import hep.dataforge.js.startApplication
|
|
||||||
import hep.dataforge.vision.gdml.toVision
|
import hep.dataforge.vision.gdml.toVision
|
||||||
import kotlinx.browser.document
|
import kotlinx.browser.document
|
||||||
import react.child
|
import react.child
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package ru.mipt.npm.muon.monitor
|
package ru.mipt.npm.muon.monitor
|
||||||
|
|
||||||
|
import hep.dataforge.Application
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.js.Application
|
import hep.dataforge.startApplication
|
||||||
import hep.dataforge.js.startApplication
|
|
||||||
import io.ktor.client.HttpClient
|
import io.ktor.client.HttpClient
|
||||||
import io.ktor.client.features.json.JsonFeature
|
import io.ktor.client.features.json.JsonFeature
|
||||||
import io.ktor.client.features.json.serializer.KotlinxSerializer
|
import io.ktor.client.features.json.serializer.KotlinxSerializer
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package ru.mipt.npm.sat
|
package ru.mipt.npm.sat
|
||||||
|
|
||||||
|
import hep.dataforge.Application
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.js.Application
|
|
||||||
import hep.dataforge.js.startApplication
|
|
||||||
import hep.dataforge.meta.invoke
|
import hep.dataforge.meta.invoke
|
||||||
|
import hep.dataforge.startApplication
|
||||||
import hep.dataforge.vision.solid.three.ThreePlugin
|
import hep.dataforge.vision.solid.three.ThreePlugin
|
||||||
import hep.dataforge.vision.solid.three.render
|
import hep.dataforge.vision.solid.three.render
|
||||||
import kotlinx.browser.document
|
import kotlinx.browser.document
|
||||||
@ -16,7 +16,7 @@ private class SatDemoApp : Application {
|
|||||||
?: error("Element with id 'canvas' not found on page")
|
?: error("Element with id 'canvas' not found on page")
|
||||||
val three = Global.plugins.fetch(ThreePlugin)
|
val three = Global.plugins.fetch(ThreePlugin)
|
||||||
val sat = visionOfSatellite(
|
val sat = visionOfSatellite(
|
||||||
ySegments = 5,
|
ySegments = 3,
|
||||||
)
|
)
|
||||||
three.render(element, sat){
|
three.render(element, sat){
|
||||||
minSize = 500
|
minSize = 500
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import ru.mipt.npm.gradle.DependencyConfiguration
|
import ru.mipt.npm.gradle.DependencyConfiguration
|
||||||
import ru.mipt.npm.gradle.FXModule
|
import ru.mipt.npm.gradle.FXModule
|
||||||
import ru.mipt.npm.gradle.useFx
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.mpp")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package hep.dataforge.vision.solid.demo
|
package hep.dataforge.vision.solid.demo
|
||||||
|
|
||||||
import hep.dataforge.js.Application
|
import hep.dataforge.Application
|
||||||
import hep.dataforge.js.startApplication
|
import hep.dataforge.startApplication
|
||||||
import hep.dataforge.vision.solid.x
|
import hep.dataforge.vision.solid.x
|
||||||
import hep.dataforge.vision.solid.y
|
import hep.dataforge.vision.solid.y
|
||||||
import kotlinx.browser.document
|
import kotlinx.browser.document
|
||||||
|
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-6.7-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import hep.dataforge.Application
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.js.Application
|
import hep.dataforge.startApplication
|
||||||
import hep.dataforge.js.startApplication
|
|
||||||
import hep.dataforge.vision.bootstrap.visionPropertyEditor
|
import hep.dataforge.vision.bootstrap.visionPropertyEditor
|
||||||
import hep.dataforge.vision.react.ThreeCanvasComponent
|
import hep.dataforge.vision.react.ThreeCanvasComponent
|
||||||
import hep.dataforge.vision.react.objectTree
|
import hep.dataforge.vision.react.objectTree
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
val kotlinVersion = "1.4.20-M2"
|
val kotlinVersion = "1.4.20"
|
||||||
val toolsVersion = "0.6.4-dev-1.4.20-M2"
|
val toolsVersion = "0.7.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
jcenter()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||||
|
@ -13,10 +13,10 @@ public class HtmlOutput<V : Vision>(
|
|||||||
|
|
||||||
public abstract class HtmlOutputScope<R, V : Vision>(
|
public abstract class HtmlOutputScope<R, V : Vision>(
|
||||||
private val root: TagConsumer<R>,
|
private val root: TagConsumer<R>,
|
||||||
public val prefix: String? = null,
|
public val idPrefix: String? = null,
|
||||||
) : TagConsumer<R> by root {
|
) : TagConsumer<R> by root {
|
||||||
|
|
||||||
public open fun resolveId(name: Name): String = (prefix ?: "output:") + name.toString()
|
public open fun resolveId(name: Name): String = (idPrefix ?: "output:") + name.toString()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a placeholder but do not attach any [Vision] to it
|
* Create a placeholder but do not attach any [Vision] to it
|
||||||
@ -27,7 +27,7 @@ public abstract class HtmlOutputScope<R, V : Vision>(
|
|||||||
): T = div {
|
): T = div {
|
||||||
id = resolveId(name)
|
id = resolveId(name)
|
||||||
classes = setOf(OUTPUT_CLASS)
|
classes = setOf(OUTPUT_CLASS)
|
||||||
attributes[NAME_ATTRIBUTE] = name.toString()
|
attributes[OUTPUT_NAME_ATTRIBUTE] = name.toString()
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
HtmlOutput(this@HtmlOutputScope, name, this).block()
|
HtmlOutput(this@HtmlOutputScope, name, this).block()
|
||||||
}
|
}
|
||||||
@ -62,6 +62,6 @@ public abstract class HtmlOutputScope<R, V : Vision>(
|
|||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
public const val OUTPUT_CLASS: String = "visionforge-output"
|
public const val OUTPUT_CLASS: String = "visionforge-output"
|
||||||
public const val NAME_ATTRIBUTE: String = "data-output-name"
|
public const val OUTPUT_NAME_ATTRIBUTE: String = "data-output-name"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package hep.dataforge.js
|
package hep.dataforge
|
||||||
|
|
||||||
import kotlinx.browser.document
|
import kotlinx.browser.document
|
||||||
import kotlinx.dom.hasClass
|
import kotlinx.dom.hasClass
|
@ -0,0 +1,43 @@
|
|||||||
|
package hep.dataforge.vision.client
|
||||||
|
|
||||||
|
import hep.dataforge.context.Context
|
||||||
|
import hep.dataforge.context.Global
|
||||||
|
import hep.dataforge.vision.VisionManager
|
||||||
|
import hep.dataforge.vision.html.HtmlOutputScope
|
||||||
|
import kotlinx.browser.window
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
import org.w3c.dom.get
|
||||||
|
import org.w3c.dom.url.URL
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
public class ClientVisionManager {
|
||||||
|
private val visionForgeContext: Context = Global.context("client") {
|
||||||
|
plugin(VisionManager)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val visionManager: VisionManager = visionForgeContext.plugins.fetch(VisionManager)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Up-going tree traversal in search for endpoint attribute
|
||||||
|
*/
|
||||||
|
private fun resolveEndpoint(element: Element?): String {
|
||||||
|
if(element == null) return DEFAULT_ENDPOINT
|
||||||
|
val attribute = element.attributes[OUTPUT_ENDPOINT_ATTRIBUTE]
|
||||||
|
return attribute?.value ?: resolveEndpoint(element.parentElement)
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun renderVision(element: Element){
|
||||||
|
if(!element.classList.contains(HtmlOutputScope.OUTPUT_CLASS)) error("The element $element is not an output element")
|
||||||
|
val endpoint = URL(resolveEndpoint(element))
|
||||||
|
window.fetch("$endpoint/vision").then {response->
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
public const val OUTPUT_ENDPOINT_ATTRIBUTE: String = "data-output-endpoint"
|
||||||
|
public const val DEFAULT_ENDPOINT: String = ".."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
|||||||
package hep.dataforge.vision.html
|
package hep.dataforge.vision.client
|
||||||
|
|
||||||
import hep.dataforge.names.Name
|
import hep.dataforge.names.Name
|
||||||
import hep.dataforge.names.toName
|
import hep.dataforge.names.toName
|
||||||
import hep.dataforge.vision.Vision
|
import hep.dataforge.vision.Vision
|
||||||
|
import hep.dataforge.vision.html.BindingHtmlOutputScope
|
||||||
|
import hep.dataforge.vision.html.HtmlOutputScope
|
||||||
|
import hep.dataforge.vision.html.HtmlVisionFragment
|
||||||
import kotlinx.browser.document
|
import kotlinx.browser.document
|
||||||
import kotlinx.html.TagConsumer
|
import kotlinx.html.TagConsumer
|
||||||
import org.w3c.dom.*
|
import org.w3c.dom.*
|
||||||
@ -21,9 +24,9 @@ public fun <V : Vision> Map<String, V>.bind(renderer: ElementVisionRenderer<V>)
|
|||||||
public fun <V : Vision> Element.renderVisions(renderer: ElementVisionRenderer<V>, visionProvider: (Name) -> V?) {
|
public fun <V : Vision> Element.renderVisions(renderer: ElementVisionRenderer<V>, visionProvider: (Name) -> V?) {
|
||||||
val elements = getElementsByClassName(HtmlOutputScope.OUTPUT_CLASS)
|
val elements = getElementsByClassName(HtmlOutputScope.OUTPUT_CLASS)
|
||||||
elements.asList().forEach { element ->
|
elements.asList().forEach { element ->
|
||||||
val name = element.attributes[HtmlOutputScope.NAME_ATTRIBUTE]?.value
|
val name = element.attributes[HtmlOutputScope.OUTPUT_NAME_ATTRIBUTE]?.value
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
console.error("Attribute ${HtmlOutputScope.NAME_ATTRIBUTE} not defined in the output element")
|
console.error("Attribute ${HtmlOutputScope.OUTPUT_NAME_ATTRIBUTE} not defined in the output element")
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
val vision = visionProvider(name.toName())
|
val vision = visionProvider(name.toName())
|
@ -1,5 +1,3 @@
|
|||||||
import ru.mipt.npm.gradle.useFx
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.jvm")
|
id("ru.mipt.npm.jvm")
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package hep.dataforge.vision.server
|
package hep.dataforge.vision.server
|
||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
import hep.dataforge.meta.*
|
import hep.dataforge.meta.Config
|
||||||
|
import hep.dataforge.meta.Configurable
|
||||||
|
import hep.dataforge.meta.boolean
|
||||||
|
import hep.dataforge.meta.long
|
||||||
import hep.dataforge.names.Name
|
import hep.dataforge.names.Name
|
||||||
import hep.dataforge.names.toName
|
import hep.dataforge.names.toName
|
||||||
import hep.dataforge.vision.Vision
|
import hep.dataforge.vision.Vision
|
||||||
@ -12,16 +15,19 @@ import hep.dataforge.vision.server.VisionServer.Companion.DEFAULT_PAGE
|
|||||||
import io.ktor.application.*
|
import io.ktor.application.*
|
||||||
import io.ktor.features.CORS
|
import io.ktor.features.CORS
|
||||||
import io.ktor.html.respondHtml
|
import io.ktor.html.respondHtml
|
||||||
import io.ktor.http.*
|
import io.ktor.http.ContentType
|
||||||
|
import io.ktor.http.HttpStatusCode
|
||||||
import io.ktor.http.cio.websocket.Frame
|
import io.ktor.http.cio.websocket.Frame
|
||||||
import io.ktor.http.content.resources
|
import io.ktor.http.content.resources
|
||||||
import io.ktor.http.content.static
|
import io.ktor.http.content.static
|
||||||
|
import io.ktor.http.withCharset
|
||||||
import io.ktor.response.respond
|
import io.ktor.response.respond
|
||||||
import io.ktor.response.respondText
|
import io.ktor.response.respondText
|
||||||
import io.ktor.routing.*
|
import io.ktor.routing.*
|
||||||
import io.ktor.server.engine.ApplicationEngine
|
import io.ktor.server.engine.ApplicationEngine
|
||||||
import io.ktor.websocket.WebSockets
|
import io.ktor.websocket.WebSockets
|
||||||
import io.ktor.websocket.webSocket
|
import io.ktor.websocket.webSocket
|
||||||
|
import kotlinx.coroutines.flow.collect
|
||||||
import kotlinx.html.*
|
import kotlinx.html.*
|
||||||
import kotlinx.html.stream.createHTML
|
import kotlinx.html.stream.createHTML
|
||||||
import java.awt.Desktop
|
import java.awt.Desktop
|
||||||
|
@ -4,7 +4,7 @@ import hep.dataforge.context.*
|
|||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.names.*
|
import hep.dataforge.names.*
|
||||||
import hep.dataforge.vision.Vision
|
import hep.dataforge.vision.Vision
|
||||||
import hep.dataforge.vision.html.ElementVisionRenderer
|
import hep.dataforge.vision.client.ElementVisionRenderer
|
||||||
import hep.dataforge.vision.solid.*
|
import hep.dataforge.vision.solid.*
|
||||||
import hep.dataforge.vision.solid.specifications.Canvas3DOptions
|
import hep.dataforge.vision.solid.specifications.Canvas3DOptions
|
||||||
import hep.dataforge.vision.visible
|
import hep.dataforge.vision.visible
|
||||||
|
Loading…
Reference in New Issue
Block a user