Heya! I'm trying to use JuulLabs/indexeddb in my C...
# juul-libraries
l
Heya! I'm trying to use JuulLabs/indexeddb in my Compose Multiplatform project with the Wasm target but having some trouble getting it to work. My main struggle is to find where to define the dependency as I think that is my issue, but I'm not sure. First of all, I've defined it in the
libs.versions.toml
file like so:
Copy code
[versions]
indexeddb = "0.7.1"

[libraries]
indexeddb = { group = "com.juul.indexeddb", name = "core", version.ref = "indexeddb" }
So first I'm unsure if the dependency should be defined in
shared/build.gradle.kts
or
composeApp/build.gradle.kts
. I think the latter, but I've tried both. For
shared/build.gradle.kts
, I've added this under `kotlin > sourceSets`:
Copy code
sourceSets {
    commonMain.dependencies {
        // put your Multiplatform dependencies here
    }
    
    wasmJsMain.dependencies {
        implementation(libs.indexeddb)
    }
}
Full file: https://gist.github.com/VapidLinus/efb65c7ed1311a3af066b6d8f0d763b4 And for
composeApp/build.gradle.kts
I've added this under `kotlin > sourceSets`:
Copy code
sourceSets {
    val desktopMain by getting

    androidMain.dependencies {
        ...
    }
    commonMain.dependencies {
        ...
    }
    desktopMain.dependencies {
        implementation(compose.desktop.currentOs)
    }
    wasmJsMain.dependencies {
        implementation(libs.indexeddb)
    }
}
Full file: https://gist.github.com/VapidLinus/0a4efe8588af8f7fbf2b8faf837522d4 Then I do a Gradle sync and expect the dependency should work, but it seems not. To test I have a file
composeApp/src/wasmJsMain/kotlin/App.wasmJs.kt
where I try to open a database:
Copy code
import kotlin.random.Random

import com.juul.indexeddb.openDatabase

actual fun databaseTest() {
    val database = openDatabase("test.db", 1)
}
But I get the errors:
Copy code
Unresolved reference: com :3
Unresolved reference: openDatabase: 5
If I look under "External Libraries" in the Project window in Android Studio I do not see
com.juul.indexeddb
listed so I think the dependency isn't getting added. I've also tried replacing
implementation(libs.indexeddb)
with
implementation("com.juul.indexeddb:core:0.7.1")
just in case it is a config issue, but that does not help either. Does anyone have any advice or know what I'm doing wrong to add indexeddb as a dependency to my wasm module? Much appreciated
t
Unfortunately Indexeddb isn't yet targeting Kotlin/Wasm.
Created JuulLabs/indexeddb#157, but I'm not sure if we'll be able to get to it in a timely fashion. You're welcome to try adding the target and reporting back if you have any success with that. PRs are also welcome.
l
Ooh okay, I must've misunderstood something. I thought I saw it mentioned that it did support Wasm, my mistake! Thanks for your time
👍 1