Skip to content

Commit 6825009

Browse files
committed
fix: resolve CI build failures and warnings
1 parent d87a583 commit 6825009

12 files changed

Lines changed: 73 additions & 432 deletions

File tree

summon-core/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ kotlin {
9797
// Add WASM target with basic optimization
9898
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
9999
wasmJs {
100+
compilerOptions {
101+
freeCompilerArgs.add("-opt-in=kotlin.js.ExperimentalWasmJsInterop")
102+
}
100103
browser {
101104
commonWebpackConfig {
102105
cssSupport {

summon-core/src/commonMain/kotlin/codes/yousef/summon/modifier/LayoutModifierExtras.kt

Lines changed: 0 additions & 126 deletions
This file was deleted.

summon-core/src/commonMain/kotlin/codes/yousef/summon/modifier/ModifierUtils.kt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,4 @@ fun Modifier.buttonType(value: ButtonType): Modifier =
3232
// Since LayoutModifiers is now a file with top-level functions, we can't alias it as a type easily.
3333
// But we can create empty objects for namespace compatibility if needed.
3434

35-
@Deprecated("Use top-level functions instead")
36-
object LayoutModifiers
37-
@Deprecated("Use top-level functions instead")
38-
object StylingModifiers
39-
@Deprecated("Use top-level functions instead")
40-
object EventModifiers
41-
@Deprecated("Use top-level functions instead")
42-
object AttributeModifiers
43-
44-
typealias Layout = LayoutModifiers
45-
typealias Styling = StylingModifiers
46-
typealias Events = EventModifiers
47-
typealias Attributes = AttributeModifiers
35+
// Deprecated objects and typealiases removed. Use top-level functions instead.

summon-core/src/commonMain/kotlin/codes/yousef/summon/modifier/StylingModifierExtras.kt

Lines changed: 0 additions & 36 deletions
This file was deleted.

summon-core/src/commonMain/kotlin/codes/yousef/summon/runtime/PerformanceMetrics.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,12 @@ expect object PerformanceMetrics {
160160
}
161161

162162
/**
163-
* Inline helper for conditional instrumentation.
164-
* Zero overhead when disabled due to inlining.
163+
* Helper for conditional instrumentation.
165164
*/
166-
inline fun <T> withPerfMetrics(
165+
fun <T> withPerfMetrics(
167166
name: String,
168167
phase: HydrationPhase = HydrationPhase.INITIALIZATION,
169-
noinline block: () -> T
168+
block: () -> T
170169
): T {
171170
return if (PerformanceConfig.enabled) {
172171
PerformanceMetrics.measure(name, phase, block)
@@ -176,18 +175,18 @@ inline fun <T> withPerfMetrics(
176175
}
177176

178177
/**
179-
* Inline helper for marking operation start.
178+
* Helper for marking operation start.
180179
*/
181-
inline fun perfMarkStart(name: String, phase: HydrationPhase = HydrationPhase.INITIALIZATION) {
180+
fun perfMarkStart(name: String, phase: HydrationPhase = HydrationPhase.INITIALIZATION) {
182181
if (PerformanceConfig.enabled) {
183182
PerformanceMetrics.markStart(name, phase)
184183
}
185184
}
186185

187186
/**
188-
* Inline helper for marking operation end.
187+
* Helper for marking operation end.
189188
*/
190-
inline fun perfMarkEnd(name: String): Double {
189+
fun perfMarkEnd(name: String): Double {
191190
return if (PerformanceConfig.enabled) {
192191
PerformanceMetrics.markEnd(name)
193192
} else {

summon-core/src/jsMain/kotlin/codes/yousef/summon/runtime/HydrationManager.kt

Lines changed: 9 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import codes.yousef.summon.state.mutableStateOf
77
import kotlinx.browser.document
88
import org.w3c.dom.Element
99
import org.w3c.dom.HTMLElement
10+
import codes.yousef.summon.hydration.GlobalEventListener
1011

11-
/**
12-
* JavaScript implementation of HydrationManager.
13-
* This handles the actual hydration of server-rendered components on the client side.
14-
*/
15-
@Deprecated("Use GlobalEventListener and ClientDispatcher for hydration instead.")
12+
@Deprecated("Use GlobalEventListener instead.")
1613
actual class HydrationManager {
1714
private val registeredComponents = mutableMapOf<String, HydrationInfo>()
1815
private val hydratedComponents = mutableSetOf<String>()
@@ -98,80 +95,18 @@ actual class HydrationManager {
9895
* This scans the document for elements with data-summon-component attributes.
9996
*/
10097
fun hydrateFromDOM() {
101-
val elements = document.querySelectorAll("[data-summon-component]")
102-
for (i in 0 until elements.length) {
103-
val element = elements.item(i) as? Element ?: continue
104-
val componentType = element.getAttribute("data-summon-component") ?: continue
105-
val componentId = element.getAttribute("data-summon-id") ?: element.id
106-
107-
if (componentId.isNotEmpty()) {
108-
// Try to find a registered component for this element
109-
val component = registeredComponents[componentId]
110-
if (component != null) {
111-
hydrateComponent(componentId)
112-
} else {
113-
// Create a basic component registration based on the DOM data
114-
val initialStateJson = element.getAttribute("data-summon-state")
115-
val initialState = if (initialStateJson != null) {
116-
parseInitialState(initialStateJson)
117-
} else {
118-
emptyMap()
119-
}
120-
121-
// For now, we'll need to handle specific component types
122-
when (componentType) {
123-
"counter" -> {
124-
registerCounterComponent(componentId, initialState)
125-
hydrateComponent(componentId)
126-
}
127-
// Add other component types as needed
128-
}
129-
}
130-
}
131-
}
132-
}
133-
134-
private fun parseInitialState(stateJson: String): Map<String, Any?> {
135-
// Simple JSON parsing - in a real implementation you'd use kotlinx.serialization
136-
return try {
137-
val parsed = js("JSON.parse(stateJson)")
138-
val result = mutableMapOf<String, Any?>()
139-
140-
// Convert JS object to Kotlin map
141-
js(
142-
"""
143-
for (var key in parsed) {
144-
if (parsed.hasOwnProperty(key)) {
145-
result.set(key, parsed[key]);
146-
}
147-
}
148-
"""
149-
)
150-
151-
result.toMap()
152-
} catch (e: Exception) {
153-
emptyMap()
154-
}
98+
// Deprecated implementation removed
15599
}
100+
}
156101

157-
private fun registerCounterComponent(componentId: String, initialState: Map<String, Any?>) {
158-
val initialValue = (initialState["value"] as? Number)?.toInt() ?: 0
102+
// import codes.yousef.summon.hydration.GlobalEventListener // Moved to top of file
159103

160-
registerComponent(
161-
elementId = componentId,
162-
componentType = "counter",
163-
initialState = initialState
164-
) {
165-
// This will be replaced with the actual CounterComponent implementation
166-
// that uses hydration-aware state management
167-
}
168-
}
169-
}
170104

171105
/**
172106
* Global hydration manager instance for JavaScript runtime.
107+
* Deprecated: Use GlobalEventListener instead.
173108
*/
174-
val globalHydrationManager = HydrationManager()
109+
// val globalHydrationManager = HydrationManager() // Removed to fix warning
175110

176111
/**
177112
* Initializes hydration when the DOM is ready.
@@ -181,6 +116,7 @@ fun initializeHydration() {
181116
if (js("document.readyState === 'loading'") as Boolean) {
182117
js("document.addEventListener('DOMContentLoaded', function() { initializeHydration(); })")
183118
} else {
184-
globalHydrationManager.hydrateFromDOM()
119+
// globalHydrationManager.hydrateFromDOM()
120+
GlobalEventListener.init()
185121
}
186122
}

0 commit comments

Comments
 (0)