rstudio / leaflet

R Interface to Leaflet Maps
http://rstudio.github.io/leaflet/
Other
807 stars 508 forks source link

dependencies missing in v.2.2.2 #917

Closed helgasoft closed 6 months ago

helgasoft commented 6 months ago

Discrepancy in dependencies returned from leaflet versions 2.1.0 and 2.2.2.

remotes::install_version("leaflet", version = "2.1.0", repos = "http://cran.us.r-project.org")
library(leaflet)
htmlwidgets::getDependency('leaflet')     # working ok with leaflet <=v.2.1.0
#> [[1]]
#> List of 10
#>  $ name      : chr "htmlwidgets"
#>  $ version   : chr "1.6.4"
#>  $ src       :List of 1
#>   ..$ file: chr "www"
#>  $ meta      : NULL
#>  $ script    : chr "htmlwidgets.js"
#>  $ stylesheet: NULL
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "htmlwidgets"
#>  $ all_files : logi TRUE
#>  - attr(*, "class")= chr "html_dependency"
#> 
#> [[2]]
#> List of 10
#>  $ name      : chr "jquery"
#>  $ version   : chr "1.12.4"
#>  $ src       :List of 1
#>   ..$ file: chr "htmlwidgets/lib/jquery"
#>  $ meta      : NULL
#>  $ script    : chr "jquery.min.js"
#>  $ stylesheet: NULL
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "leaflet"
#>  $ all_files : logi TRUE
#>  - attr(*, "class")= chr "html_dependency"
#> 
#> [[3]]
#> List of 10
#>  $ name      : chr "leaflet"
#>  $ version   : chr "1.3.1"
#>  $ src       :List of 1
#>   ..$ file: chr "htmlwidgets/lib/leaflet"
#>  $ meta      : NULL
#>  $ script    : chr "leaflet.js"
#>  $ stylesheet: chr "leaflet.css"
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "leaflet"
#>  $ all_files : logi TRUE
#>  - attr(*, "class")= chr "html_dependency"
#> 
#> [[4]]
#> List of 10
#>  $ name      : chr "leafletfix"
#>  $ version   : chr "1.0.0"
#>  $ src       :List of 1
#>   ..$ file: chr "htmlwidgets/lib/leafletfix"
#>  $ meta      : NULL
#>  $ script    : NULL
#>  $ stylesheet: chr "leafletfix.css"
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "leaflet"
#>  $ all_files : logi TRUE
#>  - attr(*, "class")= chr "html_dependency"
#> 
#> [[5]]
#> List of 10
#>  $ name      : chr "proj4"
#>  $ version   : chr "2.6.2"
#>  $ src       :List of 1
#>   ..$ file: chr "htmlwidgets/plugins/Proj4Leaflet"
#>  $ meta      : NULL
#>  $ script    : chr "proj4.min.js"
#>  $ stylesheet: NULL
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "leaflet"
#>  $ all_files : logi FALSE
#>  - attr(*, "class")= chr "html_dependency"
#> 
#> [[6]]
#> List of 10
#>  $ name      : chr "Proj4Leaflet"
#>  $ version   : chr "1.0.1"
#>  $ src       :List of 1
#>   ..$ file: chr "htmlwidgets/plugins/Proj4Leaflet"
#>  $ meta      : NULL
#>  $ script    : chr "proj4leaflet.js"
#>  $ stylesheet: NULL
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "leaflet"
#>  $ all_files : logi FALSE
#>  - attr(*, "class")= chr "html_dependency"
#> 
#> [[7]]
#> List of 10
#>  $ name      : chr "rstudio_leaflet"
#>  $ version   : chr "1.3.1"
#>  $ src       :List of 1
#>   ..$ file: chr "htmlwidgets/lib/rstudio_leaflet"
#>  $ meta      : NULL
#>  $ script    : NULL
#>  $ stylesheet: chr "rstudio_leaflet.css"
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "leaflet"
#>  $ all_files : logi TRUE
#>  - attr(*, "class")= chr "html_dependency"
#> 
#> [[8]]
#> List of 10
#>  $ name      : chr "leaflet-binding"
#>  $ version   : chr "2.1.0"
#>  $ src       :List of 1
#>   ..$ file: chr "htmlwidgets"
#>  $ meta      : NULL
#>  $ script    : chr "leaflet.js"
#>  $ stylesheet: NULL
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "leaflet"
#>  $ all_files : logi FALSE
#>  - attr(*, "class")= chr "html_dependency"

Created on 2024-04-23 with reprex v2.1.0


detach("package:leaflet", unload = TRUE)
remotes::install_version("leaflet")   # latest is v.2.2.2
library(leaflet)
htmlwidgets::getDependency('leaflet')
#> [[1]]
#> List of 10
#>  $ name      : chr "htmlwidgets"
#>  $ version   : chr "1.6.4"
#>  $ src       :List of 1
#>   ..$ file: chr "www"
#>  $ meta      : NULL
#>  $ script    : chr "htmlwidgets.js"
#>  $ stylesheet: NULL
#>  $ head      : NULL
#>  $ attachment: NULL
#>  $ package   : chr "htmlwidgets"
#>  $ all_files : logi TRUE
#>  - attr(*, "class")= chr "html_dependency"
#> 
#> [[2]]
#> NULL

Created on 2024-04-23 with reprex v2.1.0

gadenbuie commented 6 months ago

Thanks @helgasoft -- the dependencies aren't missing, they're just attached differently as of v2.2.0. The change was mentioned in the changelog for the v2.2.0 release.

helgasoft commented 6 months ago

Ok, version 2.2.0 says "the HTML dependencies for leaflet() are included in the dependencies item of the htmlwidget object it returns.". And they are there:

map <- leaflet(quakes[1:33,]) |> addTiles() |> addMarkers()
map$dependencies

But my library attempts to read them before any leaflet htmlwidget is actually built. Is there a way to do that, like with v.2.1.0 shown above ? ANSWER: leaflet()$dependencies