mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-03 11:37:09 +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" })""")
|
||||
Reference in new issue
Block a user