Skip to content
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

Split quarto extension API so that bundles are minimized. #21

Merged
merged 22 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
abea8ba
Conditionally add `attribs` field to avoid many `NULL` values that wi…
schloerke Sep 29, 2023
1972654
Allow `head` in quarto dep to be passed through
schloerke Sep 29, 2023
b435789
Allow dependencies to be split by `base`, `r`, and `python`
schloerke Sep 29, 2023
ae10c46
Update quarto extension methods
schloerke Sep 29, 2023
71d4bbc
Update test-quarto_ext.R
schloerke Sep 29, 2023
0132b9b
Stupid language server
schloerke Sep 29, 2023
20d515d
Document non-exported method quarto_ext()
schloerke Sep 29, 2023
f62c62c
`devtools::document()` (GitHub Actions)
schloerke Sep 29, 2023
c42ecc3
Add support for `--version` to `quarto_ext()`
schloerke Sep 29, 2023
498fbff
Bump supported assets version
schloerke Oct 4, 2023
027fd46
Update assets.R
schloerke Oct 4, 2023
d84eff3
Update shinylive.qmd
schloerke Oct 4, 2023
092f773
Install dev versions of py-shinylive and shinylive assets
schloerke Oct 4, 2023
095d931
Spelling / missing args
schloerke Oct 4, 2023
d8f7778
Do not install pyshinylive assets. Instead, only copy from local folder
schloerke Oct 4, 2023
475dac3
Update R-CMD-check.yaml
schloerke Oct 4, 2023
daf7aa9
Update R-CMD-check.yaml
schloerke Oct 5, 2023
8305968
Better update message
schloerke Oct 5, 2023
6e9f7b1
Update readme. Reduce most of R package availability section. Remove …
schloerke Oct 5, 2023
2ee6d46
Make filter name consistent. Use consistent starting value for n
schloerke Oct 5, 2023
a8fb970
Use published versions of shinylive assets and py-shinylive
schloerke Oct 5, 2023
7a04a16
Merge branch 'main' into split_api
schloerke Oct 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ jobs:
python-version: "3.11"

- name: Upgrade pip
shell: bash
run: |
python -m pip install --upgrade pip

- name: Install py-shinylive
shell: bash
run: |
pip install shinylive
- name: Install assets for py-shinylive
run: |
shinylive assets info
shinylive assets download
shinylive assets info
# pip install https://github.com/posit-dev/py-shinylive/archive/split_api.zip

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
Expand All @@ -52,6 +50,8 @@ jobs:
run: |
cd local/quarto
quarto add quarto-ext/shinylive --no-prompt
# Trouble installing from branch. Using url instead.
# quarto add http://github.com/quarto-ext/shinylive/archive/v2_api.zip --no-prompt

- name: Install R, system dependencies, and package dependencies
uses: rstudio/shiny-workflows/setup-r-package@v1
Expand Down Expand Up @@ -80,7 +80,10 @@ jobs:
shell: Rscript {0}
run: |
shinylive_lua <- file.path(
"local", "quarto", "_extensions", "quarto-ext", "shinylive", "shinylive.lua"
"local", "quarto", "_extensions",
# (When installing from a zip url, there is no `quarto-ext` dir.)
"quarto-ext",
"shinylive", "shinylive.lua"
)
shinylive_lua |>
brio::read_file() |>
Expand All @@ -90,13 +93,8 @@ jobs:
fixed = TRUE
) |>
sub(
pattern = " local deps = quarto.json.decode(depJson)",
replacement = " print(depJson)\n local deps = quarto.json.decode(depJson)",
fixed = TRUE
) |>
sub(
pattern = " local appDeps = quarto.json.decode(appDepsJson)",
replacement = " print(appDepsJson)\n local appDeps = quarto.json.decode(appDepsJson)",
pattern = "-- print(\"res",
replacement = "-- print(\"res",
fixed = TRUE
) |>
brio::write_file(shinylive_lua)
Expand Down
47 changes: 21 additions & 26 deletions R/assets.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Manage shinylive assets
#'
#' Helper methods for managing shinylive assets.
Expand All @@ -15,13 +14,12 @@
#' behavior should be used.
#' @export
assets_download <- function(
version = assets_version(),
...,
# Note that this is the cache directory, which is the parent of the assets
# directory. The tarball will have the assets directory as the top-level subdir.
dir = assets_cache_dir(),
url = assets_bundle_url(version)
) {
version = assets_version(),
...,
# Note that this is the cache directory, which is the parent of the assets
# directory. The tarball will have the assets directory as the top-level subdir.
dir = assets_cache_dir(),
url = assets_bundle_url(version)) {
tmp_targz <- tempfile(paste0("shinylive-", gsub(".", "_", version, fixed = TRUE), "-"), fileext = ".tar.gz")

on.exit(
Expand Down Expand Up @@ -103,9 +101,10 @@ install_local_helper <- function(

if (version != assets_version()) {
message(
"Warning: You are installing a local copy of shinylive that is not the same as the version used by the shinylive R package.",
"Warning: You are installing a local copy of shinylive assets that is not the same as the version used by the shinylive R package.",
"\nWarning: Unexpected behavior may occur!",
"\n\nNew version: ", version
"\n\nNew assets version: ", version,
"\nSupported assets version: ", assets_version()
)
}
}
Expand Down Expand Up @@ -175,11 +174,10 @@ assets_install_link <- function(
#' If a local copy of shinylive is installed, its path will be returned.
#' @export
assets_ensure <- function(
version = assets_version(),
...,
dir = assets_cache_dir(),
url = assets_bundle_url(version)
) {
version = assets_version(),
...,
dir = assets_cache_dir(),
url = assets_bundle_url(version)) {
stopifnot(length(list(...)) == 0)
if (!fs::dir_exists(dir)) {
message("Creating assets cache directory ", dir)
Expand Down Expand Up @@ -212,9 +210,8 @@ assets_ensure <- function(
#' the one used by the current version of \pkg{shinylive}.
#' @export
assets_cleanup <- function(
...,
dir = assets_cache_dir()
) {
...,
dir = assets_cache_dir()) {
stopifnot(length(list(...)) == 0)
versions <- vapply(
assets_dirs(dir = dir),
Expand Down Expand Up @@ -254,10 +251,9 @@ assets_cleanup <- function(
#' @param versions The assets versions to remove.
#' @export
assets_remove <- function(
versions,
...,
dir = assets_cache_dir()
) {
versions,
...,
dir = assets_cache_dir()) {
stopifnot(length(list(...)) == 0)
stopifnot(length(versions) > 0 && is.character(versions))

Expand All @@ -277,9 +273,8 @@ assets_remove <- function(


assets_dirs <- function(
...,
dir = assets_cache_dir()
) {
...,
dir = assets_cache_dir()) {
stopifnot(length(list(...)) == 0)
if (!fs::dir_exists(dir)) {
return(character(0))
Expand Down Expand Up @@ -322,7 +317,7 @@ assets_info <- function() {

cat(
collapse(c(
paste0("shinylive R package version: ", utils::packageVersion("shinylive")),
paste0("shinylive R package version: ", SHINYLIVE_R_VERSION),
paste0("shinylive web assets version: ", assets_version()),
"",
"Local cached shinylive asset dir:",
Expand Down
Loading
Loading