finish migrating to ktor!

- remove http4k
- renamed 'schema' subproject to 'library', because it contains more than just data models
- tiles are now hosted per factorio-server
- changed api base to `kafkatorio/data`
- tidied up some Gradle conf
- remove 'events-processor' subproject - I don't want to set up loads of microservices right now
This commit is contained in:
Adam 2022-07-02 08:45:21 +02:00
parent 8a90c4fb5e
commit c0c82e7c9c
80 changed files with 1878 additions and 1280 deletions

View file

@ -17,23 +17,6 @@ kvision {
}
rootProject.extensions.configure<NodeJsRootExtension> {
// https://github.com/rjaros/kvision/issues/410
versions.webpackCli.version = "4.10.0"
versions.webpackDevServer.version = "4.9.2"
}
rootProject.extensions.configure<YarnRootExtension> {
resolution("http-proxy-middleware", "^2.0.6")
}
//rootProject.afterEvaluate {
// extensions.configure<NodeJsRootExtension> {
// // https://github.com/rjaros/kvision/issues/410
// versions.webpackCli.version = "4.10.0"
// }
//}
afterEvaluate {
rootProject.extensions.configure<NodeJsRootExtension> {
// https://github.com/rjaros/kvision/issues/410
@ -58,12 +41,12 @@ kotlin {
open = false,
port = 3000,
proxy = mutableMapOf(
"/tiles" to mapOf(
"/kafkatorio/data/servers" to mapOf(
"target" to "http://localhost:12080",
"secure" to false,
"changeOrigin" to true,
),
"/ws/foo" to mapOf(
"/kafkatorio/ws" to mapOf(
"target" to "ws://localhost:12080",
// "secure" to false,
"ws" to true,
@ -104,12 +87,10 @@ kotlin {
implementation(libs.kotlinx.coroutines.core)
implementation(projects.modules.eventsSchema)
implementation(projects.modules.eventsLibrary)
implementation(libs.kotlinx.html)
implementation(projects.modules.eventsSchema)
implementation(libs.kotlinx.nodejs)
implementation(libs.kotlinx.html)
@ -176,28 +157,3 @@ fun KotlinDependencyHandler.kvision(
// resolution("webpack-dev-server", "4.9.1")
// }
//}
//evaluationDependsOn(rootProject.path)
//evaluationDependsOn(projects.modules.eventsSchema.dependencyProject.path)
//// stop warnings when building
//tasks.configureEach {
// when (name) {
// "productionExecutableCompileSync" ->
// dependsOn(taskProvider("compileProductionExecutableKotlinJs"))
// "testTestDevelopmentExecutableCompileSync" ->
// dependsOn(taskProvider("compileTestDevelopmentExecutableKotlinJs"))
//// "jsTestTestDevelopmentExecutableCompileSync" ->
//// dependsOn(taskProvider("compileTestDevelopmentExecutableKotlinFrontend"))
//// "jsProductionExecutableCompileSync" ->
//// dependsOn(taskProvider("compileProductionExecutableKotlinFrontend"))
// "browserDevelopmentRun" ->
// dependsOn(taskProvider("browserDevelopmentWebpack"))
// "browserDevelopmentWebpack" ->
// dependsOn(taskProvider("assemble"))
// "browserProductionWebpack" ->
// dependsOn(taskProvider("developmentExecutableCompileSync"))
// }
//}

View file

@ -77,12 +77,9 @@ class App(
wsService.packetsFlow
.filterIsInstance<EventServerPacket.ChunkTileSaved>()
.onEach {
println("[packetsFlow] triggering tile refresh ${it.filename.value}")
gameState.map.refreshUpdatedTilePng(
// doc, window,
it.filename
)
.onEach { tileSavedEvent ->
println("[packetsFlow] triggering tile refresh ${tileSavedEvent.filename.value}")
gameState.map.refreshUpdatedTilePng(tileSavedEvent.filename)
}.launchIn(this)
}

View file

@ -8,5 +8,5 @@ object Props {
get() = window.location.href
.replace("http://", "ws://")
.replace("https://", "wss://") +
"ws/foo"
"kafkatorio/ws"
}

View file

@ -14,6 +14,7 @@ inline var TileLayer<TileLayer.TileLayerOptions>.tileOnLoad: TileOnLoadFn?
}
/** @see [tileOnLoad] */
typealias TileOnLoadFn = (done: DoneCallback, tile: HTMLElement) -> Unit

View file

@ -1,6 +1,6 @@
package dev.adamko.kafkatorio.webmap
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
import dev.adamko.kafkatorio.library.jsonMapperKafkatorio
import kotlinx.serialization.json.Json
val jsonMapper = Json {

View file

@ -31,7 +31,7 @@ import org.w3c.fetch.RequestMode
class FactorioMap(
private val tileUrlTemplate: String = """/tiles/s1/z{z}/x{x}/y{y}.png""",
private val tileUrlTemplate: String = """/kafkatorio/data/servers/syslog-test/map/tiles/s1/z{z}/x{x}/y{y}.png""",
) {
val kvMap: Maps = Maps {
@ -89,9 +89,7 @@ class FactorioMap(
.querySelectorAll("img.leaflet-tile-loaded")
.asList()
.filterIsInstance<Image>()
.filter { img ->
tilePngFilename.value in img.src
}
.filter { img -> tilePngFilename.value in img.src }
.forEach { img ->
val imgSrc = img.src