mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(folio-core): wire kotlinx-browser so wasmJs DriverFactory compiles
org.w3c.dom.Worker on wasmJs lives in kotlinx-browser, not the stdlib. Pin 0.5.0 alongside the @sqlite.org/sqlite-wasm 3.53.0-build1 version that the upcoming web app will depend on, and switch the worker constructor to the module-worker form that webpack expects.
This commit is contained in:
1 parent
7187790592
commit
3761a18c75
3 files changed
+10
-4
No files matched your search
@@ -43,6 +43,7 @@ kotlin {
|
||||
}
|
||||
wasmJsMain.dependencies {
|
||||
implementation(libs.sqldelight.web.worker.driver)
|
||||
implementation(libs.kotlinx.browser)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,3 +1,5 @@
|
||||
@file:OptIn(kotlin.js.ExperimentalWasmJsInterop::class)
|
||||
|
||||
package app.folio.core.data
|
||||
|
||||
import app.cash.sqldelight.async.coroutines.awaitCreate
|
||||
@@ -8,12 +10,11 @@ import org.w3c.dom.Worker
|
||||
|
||||
actual class DriverFactory {
|
||||
actual suspend fun create(): SqlDriver {
|
||||
val worker = Worker(workerScriptUrl())
|
||||
val driver = WebWorkerDriver(worker)
|
||||
val driver = WebWorkerDriver(createSqliteWorker())
|
||||
LedgerDatabase.Schema.awaitCreate(driver)
|
||||
return driver
|
||||
}
|
||||
}
|
||||
|
||||
private fun workerScriptUrl(): String =
|
||||
js("""new URL("./sqlite.worker.js", import.meta.url).toString()""")
|
||||
private fun createSqliteWorker(): Worker =
|
||||
js("""new Worker(new URL("./sqlite.worker.js", import.meta.url), { type: "module" })""")
|
||||
@@ -9,6 +9,8 @@ lifecycle-viewmodel-compose = "2.10.0"
|
||||
activity-compose = "1.13.0"
|
||||
metro = "1.0.0-RC4"
|
||||
navigation-compose = "2.9.2"
|
||||
kotlinx-browser = "0.5.0"
|
||||
sqlite-wasm = "3.53.0-build1"
|
||||
|
||||
[libraries]
|
||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
|
||||
@@ -26,6 +28,8 @@ navigation-compose = { module = "org.jetbrains.androidx.navigation:navigation-co
|
||||
|
||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" }
|
||||
|
||||
kotlinx-browser = { module = "org.jetbrains.kotlinx:kotlinx-browser", version.ref = "kotlinx-browser" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
android-library = { id = "com.android.library", version.ref = "agp" }
|
||||
|
||||
Reference in new issue
Block a user