posit-dev / r-shinylive

https://posit-dev.github.io/r-shinylive/
Other
147 stars 15 forks source link

Including binary files results in error #106

Open jfunction opened 2 weeks ago

jfunction commented 2 weeks ago

Simple app.R (note I saved an rds file but could be a 1x1 pixel png or any binary file):

library(shiny)

# saveRDS(1,"one.rds")

ui <- fluidPage(
  titlePanel("Hello Shiny!"),
  sidebarLayout(
    sidebarPanel(
      sliderInput("bins",
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),
    mainPanel(
      plotOutput("distPlot")
    )
  )
)

server <- function(input, output, session) {
  output$distPlot <- renderPlot({
    x    <- faithful$waiting
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
}

shinyApp(ui, server)
Shiny applications not supported in static R Markdown documents

Created on 2024-07-08 with reprex v2.1.0

Export:

shinylive::export("C:/Users/Me/ShinyliveIssue", "site")
#> Warning: Found shinylive.js in source directory 'C:/Users/Me/ShinyliveIssue/site/shinylive'. Are you including a shinylive distribution in your app?

Created on 2024-07-08 with reprex v2.1.0

Results of devtools::session_info():

─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.0 (2024-04-24 ucrt)
 os       Windows 11 x64 (build 22631)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_South Africa.utf8
 ctype    English_South Africa.utf8
 tz       Africa/Johannesburg
 date     2024-07-08
 rstudio  2024.04.2+764 Chocolate Cosmos (desktop)
 pandoc   3.1.12.2 @ C:/PROGRA~3/CHOCOL~1/bin/ (via rmarkdown)

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 base64enc     0.1-3   2015-07-28 [1] CRAN (R 4.4.0)
 brio          1.1.5   2024-04-24 [1] RSPM (R 4.4.0)
 cachem        1.1.0   2024-05-16 [1] CRAN (R 4.4.1)
 callr         3.7.6   2024-03-25 [1] CRAN (R 4.4.1)
 cli           3.6.3   2024-06-21 [1] RSPM
 clipr         0.8.0   2022-02-22 [1] RSPM
 crayon        1.5.3   2024-06-20 [1] RSPM
 devtools      2.4.5   2022-10-11 [1] RSPM (R 4.4.0)
 digest        0.6.36  2024-06-23 [1] CRAN (R 4.4.1)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.4.1)
 evaluate      0.24.0  2024-06-10 [1] CRAN (R 4.4.1)
 fansi         1.0.6   2023-12-08 [1] CRAN (R 4.4.1)
 fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.1)
 fs            1.6.4   2024-04-25 [1] RSPM
 glue          1.7.0   2024-01-09 [1] RSPM
 hms           1.1.3   2023-03-21 [1] CRAN (R 4.4.1)
 htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.1)
 htmlwidgets   1.6.4   2023-12-06 [1] RSPM (R 4.4.0)
 httpuv        1.6.15  2024-03-26 [1] RSPM (R 4.4.0)
 jsonlite      1.8.8   2023-12-04 [1] RSPM
 knitr         1.47    2024-05-29 [1] CRAN (R 4.4.1)
 later         1.3.2   2023-12-06 [1] RSPM (R 4.4.0)
 lifecycle     1.0.4   2023-11-07 [1] RSPM
 magrittr      2.0.3   2022-03-30 [1] RSPM
 memoise       2.0.1   2021-11-26 [1] CRAN (R 4.4.1)
 mime          0.12    2021-09-28 [1] CRAN (R 4.4.0)
 miniUI        0.1.1.1 2018-05-18 [1] RSPM (R 4.4.0)
 pillar        1.9.0   2023-03-22 [1] CRAN (R 4.4.1)
 pkgbuild      1.4.4   2024-03-17 [1] RSPM (R 4.4.0)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.4.1)
 pkgload       1.4.0   2024-06-28 [1] RSPM (R 4.4.0)
 prettyunits   1.2.0   2023-09-24 [1] CRAN (R 4.4.1)
 processx      3.8.4   2024-03-16 [1] CRAN (R 4.4.1)
 profvis       0.3.8   2023-05-02 [1] RSPM (R 4.4.0)
 progress      1.2.3   2023-12-06 [1] CRAN (R 4.4.1)
 promises      1.3.0   2024-04-05 [1] RSPM (R 4.4.0)
 ps            1.7.6   2024-01-18 [1] CRAN (R 4.4.1)
 purrr         1.0.2   2023-08-10 [1] RSPM
 R6            2.5.1   2021-08-19 [1] RSPM
 rappdirs      0.3.3   2021-01-31 [1] RSPM
 Rcpp          1.0.12  2024-01-09 [1] RSPM (R 4.4.0)
 remotes       2.5.0   2024-03-17 [1] RSPM (R 4.4.0)
 reprex        2.1.0   2024-01-11 [1] CRAN (R 4.4.1)
 rlang         1.1.4   2024-06-04 [1] RSPM
 rmarkdown     2.27    2024-05-17 [1] CRAN (R 4.4.1)
 rstudioapi    0.16.0  2024-03-24 [1] RSPM
 sessioninfo   1.2.2   2021-12-06 [1] RSPM (R 4.4.0)
 shiny         1.8.1.1 2024-04-02 [1] RSPM (R 4.4.0)
 shinylive     0.1.1   2023-12-04 [1] RSPM (R 4.4.0)
 stringi       1.8.4   2024-05-06 [1] CRAN (R 4.4.0)
 stringr       1.5.1   2023-11-14 [1] RSPM (R 4.4.0)
 tibble        3.2.1   2023-03-20 [1] CRAN (R 4.4.1)
 urlchecker    1.0.1   2021-11-30 [1] RSPM (R 4.4.0)
 usethis       2.2.3   2024-02-19 [1] RSPM (R 4.4.0)
 utf8          1.2.4   2023-10-22 [1] CRAN (R 4.4.1)
 vctrs         0.6.5   2023-12-01 [1] RSPM
 withr         3.0.0   2024-01-16 [1] RSPM
 xfun          0.45    2024-06-16 [1] CRAN (R 4.4.1)
 xtable        1.8-4   2019-04-21 [1] RSPM (R 4.4.0)
 yaml          2.3.8   2023-12-11 [1] CRAN (R 4.4.0)

 [1] C:/Users/Me/AppData/Local/R/win-library/4.4
 [2] C:/Program Files/R/R-4.4.0/library

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
gadenbuie commented 2 weeks ago

Good news! I think this error has been fixed in the latest version of shinylive (the web assets). We're planning on releasing the R package to CRAN soon, which will use the latest shinylive assets. In the mean time, you can try using the development version of shinylive, which you can install with

pak::pak("posit-dev/r-shinylive")

With the CRAN version of r-shinylive, I see

shinylive::assets_info()
#> shinylive R package version:  0.1.1
#> shinylive web assets version: 0.2.3

and the latest dev version of r-shinylive

shinylive::assets_info()
#> shinylive R package version: 0.1.1.9000
#> shinylive web assets version: 0.3.0