Hey! Check out <kotlin.document.store>. Any feedba...
# kotlin-native
l
Hey! Check out kotlin.document.store. Any feedback would be greatly appreciated! kotlin.documen.store is a fast NoSql document store for Kotlin Multiplatform, originally created for JetBrains/package-search-intellij-plugin for a fast and reliable offline cache, evolved for all KMP developers 🚀
m
Why is there no wasmJs support if js is already supported via IndexedDB?
l
The APIs of indexedDB are old and not really friendly. As such for JS target I used idb-keyval. I am not really familiar with wasmWasi target and I assumed that invoking arbitrary JS code from an NPM library would have not been trivial, so I just didn't try. Also the JS target was added out of need for JetBrains/package-search-api-models that compiles for JS as well.
m
AFAIK IndexedDB is a browser concept and is thus only available for the
wasmJs
target but not
wasmWasi
.
l
WasmWasi can invoke arbitrary js code (in Kotlin as well) and in the browser can indeed access indexed db this way. But as I said before, I haven't put myself in it yet.
m
But you can’t run
wasmWasi
inside any browser.
l
Indeed I research a little more and yes, you are very much right. I mistakenly mixed up the targets
wasmJs
with
wasmWasi
and
wasm()
with
wasmJs
. So, here my findings: •
wasmWasi
is for non browser runtimes and as such IndexedDB is not available. It would be possible to compile LevelDB for
wasmWasi
using Make, but that would require me a lot of time, and I do not see the need for that. • Kotlin/Native
wasmJs
target can use
window
APIs (IndexedDB as well) and it can also use JS libraries. Unfortunately, JS symbols such as
Promise
and
Any
are different between source sets
jsMain
and
wasmJsMain
, making the use of expects and actuals not possible for basic usage. It would require a copy paste of all symbols and adjustments, duplicating future maintenance in the codebase. Because of the points above, for now I will not provide any
DataStore
implementation for any wasm target for now.
🆗 1