diff --git a/build.gradle.kts b/build.gradle.kts index e749cdd..c1eddf7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,51 +10,60 @@ plugins { } group = "nl.astraeus" -version = "1.2.5-SNAPSHOT" +version = "1.2.5" repositories { mavenCentral() } +/* +tasks.withType(Test::class.java) { + useJUnitPlatform() +} +*/ + kotlin { js { browser { testTask { useKarma { - useChromiumHeadless() + useChromeHeadless() } } } } -/* - wasmJs { - //moduleName = project.name - browser() + /* wasmJs { + //moduleName = project.name + browser() - mavenPublication { - groupId = group as String - pom { name = "${project.name}-wasm-js" } - } - } -*/ + mavenPublication { + groupId = group as String + pom { name = "${project.name}-wasm-js" } + } + }*/ -/* - @OptIn(ExperimentalKotlinGradlePluginApi::class) - applyDefaultHierarchyTemplate { - common { - group("jsCommon") { - withJs() - // TODO: switch to `withWasmJs()` after upgrade to Kotlin 2.0 - withWasm() + /* + @OptIn(ExperimentalKotlinGradlePluginApi::class) + applyDefaultHierarchyTemplate { + common { + group("jsCommon") { + withJs() + // TODO: switch to `withWasmJs()` after upgrade to Kotlin 2.0 + withWasm() + } } } - } -*/ + */ sourceSets { val commonMain by getting { dependencies { - api("org.jetbrains.kotlinx:kotlinx-html:0.11.0") + api("org.jetbrains.kotlinx:kotlinx-html:0.12.0") + } + } + val commonTest by getting { + dependencies { + implementation(kotlin("test")) } } val jsMain by getting @@ -128,8 +137,8 @@ publishing { setUrl("https://gitea.astraeus.nl/api/packages/rnentjes/maven") credentials() { - val giteaUsername: kotlin.String? by project - val giteaPassword: kotlin.String? by project + val giteaUsername: String? by project + val giteaPassword: String? by project username = giteaUsername password = giteaPassword @@ -175,3 +184,7 @@ tasks.withType { signing { sign(publishing.publications) } + +tasks.withType { + dependsOn(tasks.withType()) +} diff --git a/src/jsMain/kotlin/nl/astraeus/komp/HtmlBuilder.kt b/src/jsMain/kotlin/nl/astraeus/komp/HtmlBuilder.kt index 1743237..1e70289 100644 --- a/src/jsMain/kotlin/nl/astraeus/komp/HtmlBuilder.kt +++ b/src/jsMain/kotlin/nl/astraeus/komp/HtmlBuilder.kt @@ -26,7 +26,7 @@ interface HtmlConsumer : TagConsumer { fun FlowOrMetaDataOrPhrasingContent.currentElement(): Element = currentElement ?: error("No current element defined!") -private fun Node.asElement() = this as? HTMLElement +private fun Node?.asElement() = this as? HTMLElement class HtmlBuilder( private val komponent: Komponent?, diff --git a/src/jsMain/kotlin/nl/astraeus/komp/Komponent.kt b/src/jsMain/kotlin/nl/astraeus/komp/Komponent.kt index 256d9eb..4abd76e 100644 --- a/src/jsMain/kotlin/nl/astraeus/komp/Komponent.kt +++ b/src/jsMain/kotlin/nl/astraeus/komp/Komponent.kt @@ -191,6 +191,7 @@ abstract class Komponent { private var scheduledForUpdate = mutableSetOf() private var interceptor: (Komponent, () -> Unit) -> Unit = { _, block -> block() } + var logUpdateEvent = false var logRenderEvent = false var logReplaceEvent = false var enableAssertions = false @@ -244,6 +245,9 @@ abstract class Komponent { val memoizeHash = next.generateMemoizeHash() if (next.memoizeChanged()) { + if (logUpdateEvent) { + console.log("Rendering", next) + } next.onBeforeUpdate() next.renderUpdate() next.updateMemoizeHash() diff --git a/src/jsTest/kotlin/nl/astraeus/komp/TestUpdate.kt b/src/jsTest/kotlin/nl/astraeus/komp/TestUpdate.kt index 9820b0a..f02bd04 100644 --- a/src/jsTest/kotlin/nl/astraeus/komp/TestUpdate.kt +++ b/src/jsTest/kotlin/nl/astraeus/komp/TestUpdate.kt @@ -1,7 +1,6 @@ package nl.astraeus.komp import kotlinx.browser.document -import kotlinx.html.DIV import kotlinx.html.InputType import kotlinx.html.classes import kotlinx.html.div diff --git a/src/wasmJsMain/kotlin/nl/astraeus/komp/ElementExtentions.kt b/src/wasmJsMain/kotlin/nl/astraeus/komp/ElementExtentions.kt index e82648e..24a0c1d 100644 --- a/src/wasmJsMain/kotlin/nl/astraeus/komp/ElementExtentions.kt +++ b/src/wasmJsMain/kotlin/nl/astraeus/komp/ElementExtentions.kt @@ -1,10 +1,8 @@ package nl.astraeus.komp -import org.w3c.dom.AddEventListenerOptions -import org.w3c.dom.events.Event import org.w3c.dom.Element import org.w3c.dom.HTMLInputElement -import org.w3c.dom.events.EventListener +import org.w3c.dom.events.Event import org.w3c.dom.get private fun Int.asSpaces(): String {