refactor(build): enable Wasm by default and refactor modules for improved KMP compatibility

Enabled Wasm target across all relevant modules and removed conditional enablement logic. Refactored `core:core-utils` to move JVM-specific code to a new `backend:infrastructure:persistence` module for strict KMP compliance. Updated dependencies, adjusted Gradle configurations, and resolved circular dependencies.
This commit is contained in:
2026-01-09 14:36:10 +01:00
parent 13cfc37b37
commit 35da070893
22 changed files with 513 additions and 526 deletions
@@ -6,10 +6,12 @@ import org.w3c.dom.Worker
actual class DatabaseDriverFactory {
actual suspend fun createDriver(): SqlDriver {
// Same as JS, we use a Web Worker for Wasm to support OPFS
val worker = Worker(
js("""new URL("sqlite.worker.js", import.meta.url)""")
)
// In Kotlin/Wasm, we cannot use the js() function inside a function body like in Kotlin/JS.
// We need to use a helper function or a different approach.
// However, for WebWorkerDriver, we need a Worker instance.
// Workaround for Wasm: Use a helper function to create the Worker
val worker = createWorker()
val driver = WebWorkerDriver(worker)
AppDatabase.Schema.create(driver).await()
@@ -17,3 +19,9 @@ actual class DatabaseDriverFactory {
return driver
}
}
// Helper function to create a Worker in Wasm
// Note: Kotlin/Wasm JS interop is stricter.
// We must return a type that Wasm understands as an external JS reference.
// 'Worker' from org.w3c.dom is correct, but we need to ensure the stdlib is available.
private fun createWorker(): Worker = js("new Worker(new URL('sqlite.worker.js', import.meta.url))")