Update build.

This commit is contained in:
Alexander Nozik 2022-04-13 17:08:25 +03:00
parent 9648533ac8
commit 3198bad094
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
13 changed files with 55 additions and 56 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ build/
data/ data/
!gradle-wrapper.jar !gradle-wrapper.jar
/kotlin-js-store/yarn.lock

View File

@ -2,10 +2,11 @@
## [Unreleased] ## [Unreleased]
### Added ### Added
- Context receivers flag
### Changed ### Changed
- Naming of Canvas3D options - Naming of Canvas3D options
- Lights are added to the scene instead of 3D options - Lights are added to the scene instead of 3D options
### Deprecated ### Deprecated

View File

@ -8,7 +8,7 @@ val fxVersion by extra("11")
allprojects{ allprojects{
group = "space.kscience" group = "space.kscience"
version = "0.2.1-dev-1" version = "0.3.0-dev-1"
} }
subprojects { subprojects {

View File

@ -45,8 +45,9 @@ kotlin {
jvmMain { jvmMain {
dependencies { dependencies {
implementation("org.apache.commons:commons-math3:3.6.1") implementation("org.apache.commons:commons-math3:3.6.1")
implementation("io.ktor-server-cio:${npmlibs.versions.ktor}") implementation("io.ktor:ktor-server-cio:${ktorVersion}")
implementation("io.ktor:ktor-serialization-kotlinx-json:${npmlibs.versions.ktor}") implementation("io.ktor:ktor-server-content-negotiation:${ktorVersion}")
implementation("io.ktor:ktor-serialization-kotlinx-json:${ktorVersion}")
} }
} }
jsMain { jsMain {

View File

@ -1,24 +1,22 @@
package ru.mipt.npm.muon.monitor.server package ru.mipt.npm.muon.monitor.server
import io.ktor.application.Application
import io.ktor.application.call
import io.ktor.application.install
import io.ktor.application.log
import io.ktor.features.CallLogging
import io.ktor.features.ContentNegotiation
import io.ktor.features.DefaultHeaders
import io.ktor.http.ContentType import io.ktor.http.ContentType
import io.ktor.http.HttpStatusCode import io.ktor.http.HttpStatusCode
import io.ktor.http.content.resources import io.ktor.serialization.kotlinx.json.json
import io.ktor.http.content.static import io.ktor.server.application.Application
import io.ktor.response.respond import io.ktor.server.application.call
import io.ktor.response.respondText import io.ktor.server.application.install
import io.ktor.routing.Routing import io.ktor.server.application.log
import io.ktor.routing.get
import io.ktor.serialization.json
import io.ktor.server.cio.CIO import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer import io.ktor.server.engine.embeddedServer
import io.ktor.server.http.content.resources
import io.ktor.server.http.content.static
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.server.response.respond
import io.ktor.server.response.respondText
import io.ktor.server.routing.Routing
import io.ktor.server.routing.get
import org.apache.commons.math3.random.JDKRandomGenerator import org.apache.commons.math3.random.JDKRandomGenerator
import ru.mipt.npm.muon.monitor.Model import ru.mipt.npm.muon.monitor.Model
import ru.mipt.npm.muon.monitor.sim.Cos2TrackGenerator import ru.mipt.npm.muon.monitor.sim.Cos2TrackGenerator
@ -40,8 +38,6 @@ fun Application.module(context: Context = Global) {
environment.log.info("Current directory: $currentDir") environment.log.info("Current directory: $currentDir")
val solidManager = context.fetch(Solids) val solidManager = context.fetch(Solids)
install(DefaultHeaders)
install(CallLogging)
install(ContentNegotiation) { install(ContentNegotiation) {
json() json()
} }

View File

@ -32,7 +32,7 @@ kotlin {
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "11"
freeCompilerArgs = freeCompilerArgs =
freeCompilerArgs + "-Xjvm-default=all" + "-Xopt-in=kotlin.RequiresOptIn" + "-Xlambdas=indy" freeCompilerArgs + "-Xjvm-default=all" + "-Xopt-in=kotlin.RequiresOptIn" + "-Xlambdas=indy" + "-Xcontext-receivers"
} }
} }
testRuns["test"].executionTask.configure { testRuns["test"].executionTask.configure {

View File

@ -3,5 +3,6 @@ kotlin.mpp.stability.nowarn=true
kotlin.jupyter.add.scanner=false kotlin.jupyter.add.scanner=false
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.jvmargs=-Xmx4G
toolsVersion=0.11.4-kotlin-1.6.20 toolsVersion=0.11.4-kotlin-1.6.20

View File

@ -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.3.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -30,7 +30,7 @@ public external interface TabPaneProps : PropsWithChildren {
public val TabPane: FC<TabPaneProps> = fc("TabPane") { props -> public val TabPane: FC<TabPaneProps> = fc("TabPane") { props ->
var activeTab: String? by useState(props.activeTab) var activeTab: String? by useState(props.activeTab)
val children: Array<out ReactElement?> = Children.map(props.children) { val children: Array<out ReactElement<*>?> = Children.map(props.children) {
it.asElementOrNull() it.asElementOrNull()
} ?: emptyArray() } ?: emptyArray()

View File

@ -2,9 +2,12 @@ plugins {
id("ru.mipt.npm.gradle.jvm") id("ru.mipt.npm.gradle.jvm")
} }
val ktorVersion = npmlibs.versions.ktor.get()
dependencies { dependencies {
api(project(":visionforge-core")) api(project(":visionforge-core"))
api("io.ktor-server-cio:${npmlibs.versions.ktor}") api("io.ktor:ktor-server-cio:${ktorVersion}")
api("io.ktor:ktor-server-html-builder:${npmlibs.versions.ktor}") api("io.ktor:ktor-server-html-builder:${ktorVersion}")
api("io.ktor:ktor-server-websockets:${npmlibs.versions.ktor}") api("io.ktor:ktor-server-websockets:${ktorVersion}")
implementation("io.ktor:ktor-server-cors:${ktorVersion}")
} }

View File

@ -1,24 +1,25 @@
package space.kscience.visionforge.server package space.kscience.visionforge.server
import io.ktor.application.*
import io.ktor.features.CORS
import io.ktor.features.CallLogging
import io.ktor.html.respondHtml
import io.ktor.http.* import io.ktor.http.*
import io.ktor.http.cio.websocket.Frame import io.ktor.server.application.*
import io.ktor.http.content.resources
import io.ktor.http.content.static
import io.ktor.response.respond
import io.ktor.response.respondText
import io.ktor.routing.*
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.embeddedServer import io.ktor.server.engine.embeddedServer
import io.ktor.util.getOrFail import io.ktor.server.html.respondHtml
import io.ktor.websocket.WebSockets import io.ktor.server.http.content.resources
import io.ktor.websocket.webSocket import io.ktor.server.http.content.static
import io.ktor.server.plugins.cors.CORS
import io.ktor.server.response.respond
import io.ktor.server.response.respondText
import io.ktor.server.routing.*
import io.ktor.server.util.getOrFail
import io.ktor.server.websocket.WebSockets
import io.ktor.server.websocket.webSocket
import io.ktor.websocket.Frame
import kotlinx.coroutines.channels.consumeEach import kotlinx.coroutines.channels.consumeEach
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.html.* import kotlinx.html.*
@ -130,13 +131,13 @@ public class VisionServer internal constructor(
try { try {
withContext(visionManager.context.coroutineContext) { withContext(visionManager.context.coroutineContext) {
vision.flowChanges(updateInterval.milliseconds).collect { update -> vision.flowChanges(updateInterval.milliseconds).onEach { update ->
val json = visionManager.jsonFormat.encodeToString( val json = visionManager.jsonFormat.encodeToString(
VisionChange.serializer(), VisionChange.serializer(),
update update
) )
outgoing.send(Frame.Text(json)) outgoing.send(Frame.Text(json))
} }.collect()
} }
} catch (t: Throwable) { } catch (t: Throwable) {
application.log.info("WebSocket update channel for $name is closed with exception: $t") application.log.info("WebSocket update channel for $name is closed with exception: $t")
@ -241,21 +242,16 @@ public fun Application.visionServer(
webServerUrl: Url, webServerUrl: Url,
path: String = DEFAULT_PAGE, path: String = DEFAULT_PAGE,
): VisionServer { ): VisionServer {
if (featureOrNull(WebSockets) == null) { install(WebSockets)
install(WebSockets) install(CORS) {
anyHost()
} }
if (featureOrNull(CORS) == null) { // if (pluginOrNull(CallLogging) == null) {
install(CORS) { // install(CallLogging)
anyHost() // }
}
}
if (featureOrNull(CallLogging) == null) { val serverRoute = install(Routing).createRouteFromPath(path)
install(CallLogging)
}
val serverRoute = (featureOrNull(Routing) ?: install(Routing)).createRouteFromPath(path)
serverRoute { serverRoute {
static { static {
@ -263,7 +259,7 @@ public fun Application.visionServer(
} }
} }
return VisionServer(visionManager, webServerUrl.copy(encodedPath = path), serverRoute) return VisionServer(visionManager, URLBuilder(webServerUrl).apply { encodedPath = path }.build(), serverRoute)
} }
/** /**

View File

@ -1,6 +1,6 @@
package space.kscience.visionforge.tables package space.kscience.visionforge.tables
import kotlinext.js.jso import kotlinx.js.jso
import org.w3c.dom.Element import org.w3c.dom.Element
import org.w3c.dom.HTMLElement import org.w3c.dom.HTMLElement
import space.kscience.dataforge.context.AbstractPlugin import space.kscience.dataforge.context.AbstractPlugin

View File

@ -4,7 +4,6 @@ package space.kscience.visionforge.solid.three
import info.laht.threekt.core.Object3D import info.laht.threekt.core.Object3D
import info.laht.threekt.geometries.TextBufferGeometry import info.laht.threekt.geometries.TextBufferGeometry
import info.laht.threekt.objects.Mesh import info.laht.threekt.objects.Mesh
import kotlinext.js.jsObject
import kotlinext.js.jso import kotlinext.js.jso
import space.kscience.dataforge.context.logger import space.kscience.dataforge.context.logger
import space.kscience.dataforge.context.warn import space.kscience.dataforge.context.warn