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/
!gradle-wrapper.jar
/kotlin-js-store/yarn.lock

View File

@ -2,6 +2,7 @@
## [Unreleased]
### Added
- Context receivers flag
### Changed
- Naming of Canvas3D options

View File

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

View File

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

View File

@ -1,24 +1,22 @@
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.HttpStatusCode
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.Routing
import io.ktor.routing.get
import io.ktor.serialization.json
import io.ktor.serialization.kotlinx.json.json
import io.ktor.server.application.Application
import io.ktor.server.application.call
import io.ktor.server.application.install
import io.ktor.server.application.log
import io.ktor.server.cio.CIO
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 ru.mipt.npm.muon.monitor.Model
import ru.mipt.npm.muon.monitor.sim.Cos2TrackGenerator
@ -40,8 +38,6 @@ fun Application.module(context: Context = Global) {
environment.log.info("Current directory: $currentDir")
val solidManager = context.fetch(Solids)
install(DefaultHeaders)
install(CallLogging)
install(ContentNegotiation) {
json()
}

View File

@ -32,7 +32,7 @@ kotlin {
kotlinOptions {
jvmTarget = "11"
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 {

View File

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

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
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
zipStorePath=wrapper/dists

View File

@ -30,7 +30,7 @@ public external interface TabPaneProps : PropsWithChildren {
public val TabPane: FC<TabPaneProps> = fc("TabPane") { props ->
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()
} ?: emptyArray()

View File

@ -2,9 +2,12 @@ plugins {
id("ru.mipt.npm.gradle.jvm")
}
val ktorVersion = npmlibs.versions.ktor.get()
dependencies {
api(project(":visionforge-core"))
api("io.ktor-server-cio:${npmlibs.versions.ktor}")
api("io.ktor:ktor-server-html-builder:${npmlibs.versions.ktor}")
api("io.ktor:ktor-server-websockets:${npmlibs.versions.ktor}")
api("io.ktor:ktor-server-cio:${ktorVersion}")
api("io.ktor:ktor-server-html-builder:${ktorVersion}")
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
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.cio.websocket.Frame
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.application.*
import io.ktor.server.cio.CIO
import io.ktor.server.engine.ApplicationEngine
import io.ktor.server.engine.embeddedServer
import io.ktor.util.getOrFail
import io.ktor.websocket.WebSockets
import io.ktor.websocket.webSocket
import io.ktor.server.html.respondHtml
import io.ktor.server.http.content.resources
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.flow.collect
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.html.*
@ -130,13 +131,13 @@ public class VisionServer internal constructor(
try {
withContext(visionManager.context.coroutineContext) {
vision.flowChanges(updateInterval.milliseconds).collect { update ->
vision.flowChanges(updateInterval.milliseconds).onEach { update ->
val json = visionManager.jsonFormat.encodeToString(
VisionChange.serializer(),
update
)
outgoing.send(Frame.Text(json))
}
}.collect()
}
} catch (t: Throwable) {
application.log.info("WebSocket update channel for $name is closed with exception: $t")
@ -241,21 +242,16 @@ public fun Application.visionServer(
webServerUrl: Url,
path: String = DEFAULT_PAGE,
): VisionServer {
if (featureOrNull(WebSockets) == null) {
install(WebSockets)
}
if (featureOrNull(CORS) == null) {
install(CORS) {
anyHost()
}
}
if (featureOrNull(CallLogging) == null) {
install(CallLogging)
}
// if (pluginOrNull(CallLogging) == null) {
// install(CallLogging)
// }
val serverRoute = (featureOrNull(Routing) ?: install(Routing)).createRouteFromPath(path)
val serverRoute = install(Routing).createRouteFromPath(path)
serverRoute {
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
import kotlinext.js.jso
import kotlinx.js.jso
import org.w3c.dom.Element
import org.w3c.dom.HTMLElement
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.geometries.TextBufferGeometry
import info.laht.threekt.objects.Mesh
import kotlinext.js.jsObject
import kotlinext.js.jso
import space.kscience.dataforge.context.logger
import space.kscience.dataforge.context.warn