jeffdgr8 / kotbase

Kotlin Multiplatform library for Couchbase Lite—a lightweight, embedded, syncable, NoSQL database
https://kotbase.dev
Apache License 2.0
68 stars 1 forks source link

WASM target support #26

Open sengokudaikon opened 7 months ago

sengokudaikon commented 7 months ago

Hi, are there any plans to support Kotlin/WASM targets in the near future?

jeffdgr8 commented 7 months ago

While I would love to support the Wasm target, this is unlikely in the near future. The underlying Couchbase Lite dependency will need to first support the target before being able to integrate it into the Kotbase KMP library.

There have been some past discussions (1, 2) about Couchbase Lite Wasm support. I have brought it up a couple times recently with Couchbase's team as well, so it is on their radar.

I started a new discussion in the Couchbase forums to gather further traction on the topic and hopefully progress towards an implementation.

sengokudaikon commented 7 months ago

Thanks for the reply. I've already read the linked above threads, I think, if I'm not wrong, Couchbase has a JS sdk, and kotlinx.io supports wasmJs/wasmWasi targets, so a potential solution could be in launching the js sdk with Kotlin/WASM interop, and leveraging the kotlinx.io okio hooks to use FS. But I digress, I would be out of my depth to check for myself, so if this could be of help, that's great.

jeffdgr8 commented 7 months ago

Couchbase Lite actually doesn't have a proper JS browser SDK. I'd also be open to adding the Kotlin/JS target as well, if it did.

The info Couchbase Lite provides for JS in their docs is specifically for JS mobile apps using Ionic, Cordova, or React Native, wrapping the native C SDK.

If anyone is interested in doing further exploration on this, I'm open to other community contributions to move this forward.

biozal commented 1 month ago

@jeffdgr8 actually today the Ionic, Cordova and React Native open source libraries were created use the Swift SDK for iOS and Kotlin for Android. Because of the previous statement you are correct that today the core cblite-js package that is shared between those project(s) doesn't support running in the browser today. I've looked at in the future moving React Native support over to the Native C Library for the switch to Turbo Modules once they are more stable in React Native. Today React Native is written using the Native Module SDK as that's the stable API that React provided when we started the open source project.

Even wrapping the Native C SDK doesn't work today with WASM. If my memory serves me right Blaugold, whom wrote the Couchbase Lite community package for Flutter did some experimental work to try it get it to work with WASM for Dart/Flutter support if I remember right. It's something that has been discussed internally, but I don't have an updates I can share today. @jeffdgr8 I recommend reaching out your community contact at Couchbase and request this if you feel it could better help your project.