-
Notifications
You must be signed in to change notification settings - Fork 540
[wasmJs] Add support for wasmJs to web worker driver #5534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wasmJs] Add support for wasmJs to web worker driver #5534
Conversation
4c15c7c
to
a287e99
Compare
a287e99
to
81a19b8
Compare
@dellisd second one π |
Hi @IlyaGulya, will your change be available on the SNAPSHOT version after your 3rd pr is merged? |
@deybeer I don't know, I'm external contributor, not a part of SQLDelight team π |
@IlyaGulya, thanks for the contribution |
@dellisd let us dream with a wasm version on the snapshots π |
Yes, it will be available as SNAPSHOT right after merge. |
@IlyaGulya Little question, after this change, What is the next change about? |
Hi @IlyaGulya Little question, after this change, What is the next change about? |
@deybeer sample web project fixes, and after that maybe small build configuration improvement |
Hi @IlyaGulya, Could you please help me with the documentation to publish your changes on Maven Local? |
@deybeer just clone this branch and call |
@IlyaGulya, is the wasm version only in-memory, or can I configure it to persist to use the persisted data after refreshing the browser? |
@deybeer It's using the same sql.js as current web worker implementation, so yes, it's only in-memory. |
Thank you it's beautiful!! π₯Ή π₯Ή Snapshots
// settings.gradle.kts
pluginManagement {
repositories {
maven {
url = uri("https://maven.pkg.github.com/edna-aa/sqldelight")
credentials {
username = "<user-name>"
password = "<PAT-with-read-package>"
}
// Restrict this repository to specific versions containing "-wasm"
content {
includeGroup("app.cash.sqldelight") // Restrict to the group
includeVersionByRegex("app.cash.sqldelight", ".*", ".*-wasm.*") // Match any artifact in the group with versions containing "-wasm"
}
}
mavenLocal()
google()
gradlePluginPortal()
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
maven {
url = uri("https://maven.pkg.github.com/edna-aa/sqldelight")
credentials {
username = "<user-name>"
password = "<PAT-with-read-package>"
}
// Restrict this repository to specific versions containing "-wasm"
content {
includeGroup("app.cash.sqldelight") // Restrict to the group
includeVersionByRegex("app.cash.sqldelight", ".*", ".*-wasm.*") // Match any artifact in the group with versions containing "-wasm"
}
}
google()
mavenCentral()
mavenLocal()
}
} |
@ahna92 your credentials were sent to everyone who got email notifications, despite you editing them out (and they're still in edit history); make sure to disable those keys and re-generate new ones! And be careful next time :D |
@Skaldebane it was on purpose , bc github only allows reading public packages via a pat they got auto revoked by github , guess need to create your own |
@ahna92 Yeah every user has to create their own keys for GitHub Packages, but make sure to never leak your own (even if they're scoped well; they might include future private packages you don't want to be public). |
@Skaldebane thank you for your concern, well aware I've created an account just to publish this package, been waiting for 1 year for it ! |
Getting this error when setting generateAsync = true. Any workaround for this? No matching variant of app.cash.sqldelight:async-extensions:2.0.2 was found. The consumer was configured to find a library for use during 'kotlin-runtime', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.js.public.package.json' with value 'public-package-json', attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm', attribute 'org.jetbrains.kotlin.wasm.target' with value 'js' but |
@abhi-rock-pe I had some issues with referencing a package published to local maven with the word SNAPSHOT in the name. I had to change the name of the locally published version to I don't believe you need an explicit |
Pretty strange behavior and I don't know, if I did something wrong: wasm compiles, but I can't access the page. I have set generateAsync to true https://github.com/DrUlysses/Kristine/blob/main/composeApp/build.gradle.kts#L175 There are no errors on build: https://github.com/DrUlysses/Kristine/actions/runs/12612882795/job/35150084827 But on the page https://drulysses.github.io/Kristine/ I got: IllegalStateException: The driver used with SQLDelight is asynchronous, so SQLDelight should be configured for
Kristine-composeApp-wasm-js.uninstantiated.mjs:133:72 Version used is 2.1.0-wasm.2 https://github.com/DrUlysses/Kristine/blob/main/gradle/libs.versions.toml#L18 I have already tried to use different versions, build locally with some tweaks. Don't know, if I am doing something wrong, or it is a bug. There are possibilities to use canvas instead of body, or change sqljs.worker.js (I have used local one, because there ist no sqljs.worker.js for 2.1.0-wasm.2), but I'm not sure, if it will help, or the problem is somewhere else |
@DrUlysses make sure you are calling |
Are there people who sucessfully implemented sqldelight for WasmJs ? I'm currently looking at @DrUlysses project to do it but the more resources i have, the more i will understand what i'm doing. π |
hi @JakeWharton original PR before breaking into smaller PRs (jan 2024 π’) We are planning 2025, so appreciate the support π Tested this on 3 projects working fine so far (with pagination as well) |
I am not involved in the Wasm efforts. Hopefully another maintainer has time to support it fully landing and being released. |
hi @dellisd |
Might I suggest that a worker for a persistent sqlite db is offered as a default, eg
and then include https://github.com/IlyaGulya/TodoAppDecomposeMviKotlin/blob/feature/migrate-to-wasm/web/src/jsMain/resources/sqlite.worker.js by default as well. My hunch is most folks will want to use sqldelight wasm with a persistable db as that is what we are doing with our mobile apps. |
@brendanw sure,I'll take a look on this weekend |
After using the 2.1.0-wasm.2 snapshot library, I encountered this error. FAILURE: Build completed with 12 failures. 1: Task failed with an exception.
|
hey @tangpj Make sure to add maven repo at both pluginManagement & dependencyResolutionManagement and that your personal token has a read package permission |
Hey guys!
After:
|
I managed to make my database work for WasmJs. But is it supposed to work for Js with the same configuration too ?
Edit: i fixed the issue, which was related to the database data. The setup was done properly. Thanks ! |
@bakjoul kotlin/js is officially supported before wasm can check docs from the log shared can't tell much , but i think might due to incompatible make sure to apply this too
|
@dellisd Gentle ping regarding this PR π |
@dellisd Gentle reminder on this PR Review and approval. |
@IlyaGulya Can you show me a full setup that how can I use yours with wasmJs? I followed to add the wasmJs driver as well, but I don't know what to do after, If I follow the Js setup, it needs to define a If I have a full setup that how can I setup my sqlite database in wasmJs platform that would be great. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of this i dont understand but the structure looks good and i will give the people what they want
we're still treating web as experimental in 2.x, so I'm fine with this being a breaking change
Holy cow, thanks! |
This PR adds Kotlin/WasmJS support to the SQLDelight web worker driver
Key Changes
WebWorkerDriver
fromjsMain
tocommonMain
.WebWorkerDriver.sendMessage
toWorkerWrapper
which is implmented by each target.WorkerAction
interface expect/actual because ofwasmJs
bridge limitations (everything passing bridge should extendJsAny
)WorkerAction
companion object to separate objectWorkerActions
createDefaultWebWorkerDriver()
.Technical Limitations
The significant amount of non-shared code between platforms is primarily due to:
org.w3c.dom.Worker
interface in Kotlin Multiplatform