migrate(local-db): replace Room with SQLDelight for JS/WASM compatibility
Replaced Room with SQLDelight for improved multiplatform support, enabling JavaScript and WebAssembly targets. Added custom database driver implementations for JVM, JS, and WASM. Updated Gradle configurations, dependencies, and project structure accordingly.
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
package at.mocode.frontend.core.network
|
||||
|
||||
import kotlinx.browser.window
|
||||
|
||||
@Suppress("UnsafeCastFromDynamic", "EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
actual object PlatformConfig {
|
||||
actual fun resolveApiBaseUrl(): String {
|
||||
// 1) Prefer a global JS variable (can be injected by index.html or nginx)
|
||||
val global =
|
||||
js("typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}))")
|
||||
val fromGlobal = try {
|
||||
(global.API_BASE_URL as? String)?.trim().orEmpty()
|
||||
} catch (_: dynamic) {
|
||||
""
|
||||
}
|
||||
if (fromGlobal.isNotEmpty()) return fromGlobal.removeSuffix("/")
|
||||
|
||||
// 2) Try window location origin (same origin gateway/proxy setup)
|
||||
val origin = try {
|
||||
window.location.origin
|
||||
} catch (_: dynamic) {
|
||||
null
|
||||
}
|
||||
if (!origin.isNullOrBlank()) return origin.removeSuffix("/")
|
||||
|
||||
// 3) Fallback to the local gateway
|
||||
return "http://localhost:8081"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user