quarto-ext / shinylive

Quarto extension to embed Shinylive for Python applications
https://quarto-ext.github.io/shinylive/
MIT License
144 stars 8 forks source link

vbump webR dependency #48

Closed pawelru closed 2 months ago

pawelru commented 5 months ago

Currently it is using v0.2.2 whereas the newest is 0.3.2. The difference is quite big. For instance, I want to make use of webr::library_shim() which is unavailable in the v0.2.2

pawelru commented 5 months ago

I think I have found a workaround of this issue. I added the following to the app code before any of library() calls.

if (packageVersion("webr") < "0.3.0") {
  .e <- as.environment("webr_shims")
  .e[["library"]] <- function(pkg, ...) {
    package <- as.character(substitute(pkg))
    if (length(find.package(package, quiet = TRUE)) == 0) {
      webr::install(package)
    }
    base::library(package, character.only = TRUE, ...)
  }
}
pawelru commented 2 months ago

Looks like the issue was in shinylive assets. I have upgraded it to v0.5.0 (shinylive::assets_download("0.5.0")) and I got sufficient webr version. No need to implement above workaround anymore.