mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-10 23:48:01 -05:00
Compare commits
97 Commits
app-url
...
ui-docs-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4671eccd84 | ||
|
|
6c0cf4f7e5 | ||
|
|
dc7d4b46d8 | ||
|
|
509acb62b0 | ||
|
|
d05b2c305e | ||
|
|
a562e286d0 | ||
|
|
a40903c7e3 | ||
|
|
1faefe66fa | ||
|
|
fc7e237000 | ||
|
|
de8134742d | ||
|
|
f814034835 | ||
|
|
6d9fad29f3 | ||
|
|
313ae9044d | ||
|
|
9389160af0 | ||
|
|
6a7ffeff68 | ||
|
|
bc6ff57cb7 | ||
|
|
b52b9e4520 | ||
|
|
fb71ab6146 | ||
|
|
d8c7a634ff | ||
|
|
396dd2632e | ||
|
|
c11875a5f0 | ||
|
|
2e599faf1f | ||
|
|
a5a8385420 | ||
|
|
33ed698e5b | ||
|
|
ed547fdf40 | ||
|
|
0b1c35c92b | ||
|
|
d304bdf333 | ||
|
|
a9255e6b12 | ||
|
|
45429fb798 | ||
|
|
1206d1d3ba | ||
|
|
af44a447a1 | ||
|
|
d7fb6d1793 | ||
|
|
cb0083adb2 | ||
|
|
77bae68f26 | ||
|
|
e9f8b4d552 | ||
|
|
aee6b74cfb | ||
|
|
29b6b03297 | ||
|
|
b5ebd8a645 | ||
|
|
356ba8c5a1 | ||
|
|
5aa5cb1794 | ||
|
|
09c609e417 | ||
|
|
10e7d11846 | ||
|
|
4e442312a7 | ||
|
|
8ea97df3f2 | ||
|
|
a8c14dab96 | ||
|
|
00775b90e8 | ||
|
|
c6ae4c0034 | ||
|
|
1efcaa0b5d | ||
|
|
e6d94f6f66 | ||
|
|
5a8a02626c | ||
|
|
c23293750d | ||
|
|
9de74048a2 | ||
|
|
0fc861afb4 | ||
|
|
2300dae10b | ||
|
|
dfbb98abfd | ||
|
|
9670839235 | ||
|
|
1e2326c2b6 | ||
|
|
6f46b847e2 | ||
|
|
8c44559a1f | ||
|
|
d245a972ee | ||
|
|
c153d0591f | ||
|
|
2ce18ef324 | ||
|
|
2792d65e40 | ||
|
|
7b00f605aa | ||
|
|
4cb3f05e8e | ||
|
|
8e40c815eb | ||
|
|
6dfd8bc0ff | ||
|
|
2ef397f024 | ||
|
|
94749f6114 | ||
|
|
4a39588d00 | ||
|
|
f5d5832149 | ||
|
|
68deab9b0e | ||
|
|
96efac2bd7 | ||
|
|
a67059f9f9 | ||
|
|
cdc51c09c7 | ||
|
|
a6f02cf214 | ||
|
|
7600770a6e | ||
|
|
1b3ed88bd1 | ||
|
|
f01dc9f0fb | ||
|
|
9a65890e92 | ||
|
|
ffef0c2eb1 | ||
|
|
8b74338b0f | ||
|
|
ed3c676548 | ||
|
|
30c0a2bd29 | ||
|
|
997e5e5ce5 | ||
|
|
aba6b2e4db | ||
|
|
3f48e3b0af | ||
|
|
b4879a342c | ||
|
|
5070146061 | ||
|
|
d28c3e15ad | ||
|
|
4b496be520 | ||
|
|
979288a590 | ||
|
|
9365d4f3c4 | ||
|
|
e1daf8aae7 | ||
|
|
8a57dbf608 | ||
|
|
ac9b76c651 | ||
|
|
139526ef2d |
12
.github/shiny-workflows/routine.sh
vendored
Normal file
12
.github/shiny-workflows/routine.sh
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash -e
|
||||
. ./tools/documentation/checkDocsCurrent.sh
|
||||
|
||||
echo "Updating package.json version to match DESCRIPTION Version"
|
||||
Rscript ./tools/updatePackageJsonVersion.R
|
||||
if [ -n "$(git status --porcelain package.json)" ]
|
||||
then
|
||||
yarn build
|
||||
git add ./inst package.json && git commit -m 'Sync package version (GitHub Actions)' || echo "No package version to commit"
|
||||
else
|
||||
echo "No package version difference detected; package.json is current."
|
||||
fi
|
||||
159
.github/workflows/R-CMD-check.yaml
vendored
159
.github/workflows/R-CMD-check.yaml
vendored
@@ -1,150 +1,23 @@
|
||||
name: R-CMD-check
|
||||
# Workflow derived from https://github.com/rstudio/shiny-workflows
|
||||
#
|
||||
# NOTE: This Shiny team GHA workflow is overkill for most R packages.
|
||||
# For most R packages it is better to use https://github.com/r-lib/actions
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
branches: [main, rc-**]
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '0 5 * * 1' # every monday
|
||||
|
||||
name: Package checks
|
||||
|
||||
jobs:
|
||||
|
||||
website:
|
||||
uses: rstudio/shiny-workflows/.github/workflows/website.yaml@v1
|
||||
routine:
|
||||
uses: rstudio/shiny-workflows/.github/workflows/routine.yaml@v1
|
||||
with:
|
||||
node-version: "14.x"
|
||||
R-CMD-check:
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
|
||||
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {os: macOS-latest, r: 'devel'}
|
||||
- {os: macOS-latest, r: '4.0'}
|
||||
- {os: windows-latest, r: '4.0'}
|
||||
- {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
|
||||
env:
|
||||
_R_CHECK_FORCE_SUGGESTS_: false
|
||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||
RSPM: ${{ matrix.config.rspm }}
|
||||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
steps:
|
||||
# https://github.com/actions/checkout/issues/135
|
||||
- name: Set git to use LF
|
||||
if: runner.os == 'Windows'
|
||||
run: |
|
||||
git config --system core.autocrlf false
|
||||
git config --system core.eol lf
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r@master
|
||||
id: install-r
|
||||
with:
|
||||
r-version: ${{ matrix.config.r }}
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@master
|
||||
|
||||
- name: Install pak and query dependencies
|
||||
shell: Rscript {0}
|
||||
run: |
|
||||
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
|
||||
saveRDS(pak::pkg_deps_tree("local::.", dependencies = TRUE), ".github/r-depends.rds")
|
||||
|
||||
- name: Cache R packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ env.R_LIBS_USER }}
|
||||
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
|
||||
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-
|
||||
|
||||
- name: Install system dependencies
|
||||
if: runner.os == 'Linux'
|
||||
shell: Rscript {0}
|
||||
run: |
|
||||
pak::local_system_requirements(execute = TRUE)
|
||||
|
||||
# https://stackoverflow.com/a/66568545/591574
|
||||
#> fatal error: 'X11/Intrinsic.h' file not found
|
||||
- name: Install Cairo macOS R devel dependency
|
||||
if: runner.os == 'macOS' && matrix.config.r == 'devel'
|
||||
run: |
|
||||
brew install libxt
|
||||
|
||||
# xquartz and cairo are needed for Cairo package.
|
||||
# harfbuzz and fribidi are needed for textshaping package.
|
||||
- name: Mac systemdeps
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
brew install --cask xquartz
|
||||
brew install cairo
|
||||
brew install harfbuzz fribidi
|
||||
|
||||
# Use a shorter temp directory for pak installations, due to filename
|
||||
# length issues on Windows. https://github.com/r-lib/pak/issues/252
|
||||
- name: Windows temp dir
|
||||
if: runner.os == 'Windows'
|
||||
run: |
|
||||
New-Item -Path "C:\" -Name "tmp" -ItemType Directory
|
||||
echo "TMPDIR=c:\tmp" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pak::local_install_dev_deps(upgrade = TRUE)
|
||||
pak::pkg_install("rcmdcheck")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Find PhantomJS path
|
||||
id: phantomjs
|
||||
run: |
|
||||
echo "::set-output name=path::$(Rscript -e 'cat(shinytest:::phantom_paths()[[1]])')"
|
||||
- name: Cache PhantomJS
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.phantomjs.outputs.path }}
|
||||
key: ${{ matrix.config.os }}-phantomjs
|
||||
restore-keys: ${{ matrix.config.os }}-phantomjs
|
||||
- name: Install PhantomJS
|
||||
run: >
|
||||
Rscript
|
||||
-e "if (!shinytest::dependenciesInstalled()) shinytest::installDependencies()"
|
||||
|
||||
- name: Session info
|
||||
run: |
|
||||
options(width = 100)
|
||||
pkgs <- installed.packages()[, "Package"]
|
||||
sessioninfo::session_info(pkgs, include_base = TRUE)
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Check
|
||||
env:
|
||||
_R_CHECK_CRAN_INCOMING_: false
|
||||
_R_CHECK_FORCE_SUGGESTS_: ${{ matrix.config.r != 'devel' }}
|
||||
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Show testthat output
|
||||
if: always()
|
||||
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
|
||||
shell: bash
|
||||
|
||||
- name: Upload check results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results
|
||||
path: check
|
||||
|
||||
- name: Fix path for Windows caching
|
||||
if: runner.os == 'Windows'
|
||||
# This is needed because if you use the default tar at this stage,
|
||||
# C:/Rtools/bin/tar.exe, it will say that it can't find gzip.exe. So
|
||||
# we'll just set the path so that the original tar that would be
|
||||
# found, will be found.
|
||||
run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH
|
||||
uses: rstudio/shiny-workflows/.github/workflows/R-CMD-check.yaml@v1
|
||||
|
||||
173
.github/workflows/rituals.yaml
vendored
173
.github/workflows/rituals.yaml
vendored
@@ -1,173 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- ghactions
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
name: Rituals
|
||||
|
||||
jobs:
|
||||
rituals:
|
||||
name: Rituals
|
||||
# if: false
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- { os: ubuntu-16.04, r: '4.0', node: "14.x", rspm: "https://packagemanager.rstudio.com/all/__linux__/xenial/latest"}
|
||||
|
||||
env:
|
||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||
RSPM: ${{ matrix.config.rspm }}
|
||||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- uses: r-lib/actions/pr-fetch@master
|
||||
name: Git Pull (PR)
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: r-lib/actions/setup-r@master
|
||||
id: install-r
|
||||
with:
|
||||
r-version: ${{ matrix.config.r }}
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@master
|
||||
|
||||
- name: Git Config
|
||||
run: |
|
||||
git config user.name "${GITHUB_ACTOR}"
|
||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||
|
||||
- name: Install pak and query dependencies
|
||||
shell: Rscript {0}
|
||||
run: |
|
||||
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
|
||||
saveRDS(pak::pkg_deps_tree("local::.", dependencies = TRUE), ".github/r-depends.rds")
|
||||
|
||||
- name: Cache R packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ env.R_LIBS_USER }}
|
||||
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
|
||||
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-
|
||||
|
||||
- name: Install system dependencies
|
||||
# if: runner.os == 'Linux'
|
||||
shell: Rscript {0}
|
||||
run: |
|
||||
pak::local_system_requirements(execute = TRUE)
|
||||
|
||||
- name: Install dependencies
|
||||
shell: Rscript {0}
|
||||
run: |
|
||||
pak::local_install_dev_deps(upgrade = TRUE)
|
||||
|
||||
- name: Session info
|
||||
shell: Rscript {0}
|
||||
run: |
|
||||
options(width = 100)
|
||||
pak::pkg_install("sessioninfo")
|
||||
pkgs <- installed.packages()[, "Package"]
|
||||
sessioninfo::session_info(pkgs, include_base = TRUE)
|
||||
|
||||
- name: Url redirects
|
||||
# only perform if in an RC branch (`rc-vX.Y.Z`)
|
||||
if: ${{ github.event_name == 'push' && contains(github.ref, '/rc-v') }}
|
||||
run: |
|
||||
Rscript -e 'pak::pkg_install("r-lib/urlchecker"); urlchecker::url_update()'
|
||||
# throw an error if man files were updated
|
||||
if [ -n "$(git status --porcelain man)" ]
|
||||
then
|
||||
git status --porcelain
|
||||
>&2 echo "Updated links found in files above"
|
||||
>&2 echo 'Run `urlchecker::url_update()` to fix links locally'
|
||||
exit 1
|
||||
fi
|
||||
# Add locally changed urls
|
||||
git add .
|
||||
git commit -m 'Update links (GitHub Actions)' || echo "No link changes to commit"
|
||||
|
||||
- name: Document
|
||||
run: |
|
||||
Rscript -e 'pak::pkg_install("devtools")'
|
||||
Rscript -e 'devtools::document()'
|
||||
git add man/\* NAMESPACE
|
||||
git commit -m 'Document (GitHub Actions)' || echo "No documentation changes to commit"
|
||||
|
||||
- name: Check documentation
|
||||
run: |
|
||||
./tools/documentation/checkDocsCurrent.sh
|
||||
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.config.node }}
|
||||
# https://github.com/actions/cache/blame/ccf96194800dbb7b7094edcd5a7cf3ec3c270f10/examples.md#L185-L200
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- name: yarn cache
|
||||
uses: actions/cache@v2
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ matrix.config.os }}-${{ matrix.config.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ matrix.config.os }}-${{ matrix.config.node }}-yarn-
|
||||
|
||||
- name: Sync DESCRIPTION and package.json versions
|
||||
run: |
|
||||
Rscript -e 'pak::pkg_install("jsonlite")'
|
||||
Rscript -e 'pkg <- jsonlite::read_json("package.json", simplifyVector = TRUE)' \
|
||||
-e 'version <- as.list(read.dcf("DESCRIPTION")[1,])$Version' \
|
||||
-e 'pkg$version <- gsub("^(\\d+).(\\d+).(\\d+).(.+)$", "\\1.\\2.\\3-alpha.\\4", version)' \
|
||||
-e 'pkg$files <- as.list(pkg$files)' \
|
||||
-e 'jsonlite::write_json(pkg, path = "package.json", pretty = TRUE, auto_unbox = TRUE)'
|
||||
git add package.json && git commit -m 'sync package version (GitHub Actions)' || echo "No version changes to commit"
|
||||
- name: Build JS
|
||||
run: |
|
||||
tree srcts
|
||||
rm -r srcts/types
|
||||
yarn install --immutable && yarn build
|
||||
git add ./srcts/src && git commit -m 'yarn lint (GitHub Actions)' || echo "No yarn lint changes to commit"
|
||||
git add ./srcts/types && git commit -m 'yarn tsc (GitHub Actions)' || echo "No type definition changes to commit"
|
||||
git add ./inst && git commit -m 'yarn build (GitHub Actions)' || echo "No yarn build changes to commit"
|
||||
if [ -n "$(git status --porcelain)" ]
|
||||
then
|
||||
git status --porcelain
|
||||
>&2 echo "The above files changed when we built the JavaScript assets."
|
||||
exit 1
|
||||
else
|
||||
echo "No difference detected; TypeScript build is current."
|
||||
fi
|
||||
|
||||
- name: Git Push (PR)
|
||||
uses: r-lib/actions/pr-push@master
|
||||
if: github.event_name == 'pull_request'
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Verify no un-pushed commits (MASTER)
|
||||
if: github.event_name == 'push'
|
||||
run: |
|
||||
# Can't push to a protected branch
|
||||
if [ -z "`git cherry`"]; then
|
||||
echo "Un-pushed commits:"
|
||||
git cherry -v
|
||||
echo "\nCan not push to a protected branch. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute after pushing, as no updated files will be produced
|
||||
- name: Test TypeScript code
|
||||
run: |
|
||||
cd srcts
|
||||
yarn test
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -12,7 +12,7 @@ README.html
|
||||
tools/yarn-error.log
|
||||
|
||||
# TypeScript / yarn
|
||||
node_modules/
|
||||
/node_modules/
|
||||
.cache
|
||||
.yarn/*
|
||||
!.yarn/releases
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
trailingComma: "es5"
|
||||
arrowParens: always
|
||||
endOfLine: lf
|
||||
16
.vscode/settings.json
vendored
16
.vscode/settings.json
vendored
@@ -1,10 +1,18 @@
|
||||
{
|
||||
"typescript.tsdk": ".yarn/sdks/typescript/lib",
|
||||
"search.exclude": {
|
||||
"**/.yarn": true,
|
||||
"**/.pnp.*": true
|
||||
},
|
||||
"eslint.nodePath": ".yarn/sdks",
|
||||
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true
|
||||
"prettier.prettierPath": "./node_modules/prettier",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
"[r]": {
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.insertFinalNewline": true,
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.insertFinalNewline": true,
|
||||
},
|
||||
}
|
||||
|
||||
13
DESCRIPTION
13
DESCRIPTION
@@ -1,7 +1,7 @@
|
||||
Package: shiny
|
||||
Type: Package
|
||||
Title: Web Application Framework for R
|
||||
Version: 1.6.0.9021
|
||||
Version: 1.7.1.9002
|
||||
Authors@R: c(
|
||||
person("Winston", "Chang", role = c("aut", "cre"), email = "winston@rstudio.com", comment = c(ORCID = "0000-0002-1576-2126")),
|
||||
person("Joe", "Cheng", role = "aut", email = "joe@rstudio.com"),
|
||||
@@ -79,7 +79,7 @@ Imports:
|
||||
jsonlite (>= 0.9.16),
|
||||
xtable,
|
||||
fontawesome (>= 0.2.1),
|
||||
htmltools (>= 0.5.1.9003),
|
||||
htmltools (>= 0.5.2),
|
||||
R6 (>= 2.0),
|
||||
sourcetools,
|
||||
later (>= 1.0.0),
|
||||
@@ -91,7 +91,7 @@ Imports:
|
||||
withr,
|
||||
commonmark (>= 1.7),
|
||||
glue (>= 1.3.2),
|
||||
bslib (>= 0.2.5.9002),
|
||||
bslib (>= 0.3.0),
|
||||
cachem,
|
||||
ellipsis,
|
||||
lifecycle (>= 0.2.0)
|
||||
@@ -112,10 +112,6 @@ Suggests:
|
||||
ragg,
|
||||
showtext,
|
||||
sass
|
||||
Remotes:
|
||||
r-lib/rlang,
|
||||
rstudio/bslib,
|
||||
rstudio/htmltools
|
||||
URL: https://shiny.rstudio.com/
|
||||
BugReports: https://github.com/rstudio/shiny/issues
|
||||
Collate:
|
||||
@@ -193,6 +189,7 @@ Collate:
|
||||
'shinywrappers.R'
|
||||
'showcase.R'
|
||||
'snapshot.R'
|
||||
'staticimports.R'
|
||||
'tar.R'
|
||||
'test-export.R'
|
||||
'test-server.R'
|
||||
@@ -205,7 +202,7 @@ Collate:
|
||||
'version_selectize.R'
|
||||
'version_strftime.R'
|
||||
'viewer.R'
|
||||
RoxygenNote: 7.1.1
|
||||
RoxygenNote: 7.1.2
|
||||
Encoding: UTF-8
|
||||
Roxygen: list(markdown = TRUE)
|
||||
RdMacros: lifecycle
|
||||
|
||||
@@ -378,6 +378,7 @@ importFrom(htmltools,tags)
|
||||
importFrom(htmltools,validateCssUnit)
|
||||
importFrom(htmltools,withTags)
|
||||
importFrom(lifecycle,deprecated)
|
||||
importFrom(lifecycle,is_present)
|
||||
importFrom(promises,"%...!%")
|
||||
importFrom(promises,"%...>%")
|
||||
importFrom(promises,as.promise)
|
||||
@@ -386,14 +387,18 @@ importFrom(promises,promise)
|
||||
importFrom(promises,promise_reject)
|
||||
importFrom(promises,promise_resolve)
|
||||
importFrom(rlang,"%||%")
|
||||
importFrom(rlang,"fn_body<-")
|
||||
importFrom(rlang,"fn_fmls<-")
|
||||
importFrom(rlang,as_function)
|
||||
importFrom(rlang,as_quosure)
|
||||
importFrom(rlang,enexpr)
|
||||
importFrom(rlang,enquo)
|
||||
importFrom(rlang,enquo0)
|
||||
importFrom(rlang,enquos)
|
||||
importFrom(rlang,enquos0)
|
||||
importFrom(rlang,eval_tidy)
|
||||
importFrom(rlang,expr)
|
||||
importFrom(rlang,fn_body)
|
||||
importFrom(rlang,get_env)
|
||||
importFrom(rlang,get_expr)
|
||||
importFrom(rlang,inject)
|
||||
@@ -408,4 +413,8 @@ importFrom(rlang,new_function)
|
||||
importFrom(rlang,new_quosure)
|
||||
importFrom(rlang,pairlist2)
|
||||
importFrom(rlang,quo)
|
||||
importFrom(rlang,quo_get_expr)
|
||||
importFrom(rlang,quo_is_missing)
|
||||
importFrom(rlang,quo_set_env)
|
||||
importFrom(rlang,quo_set_expr)
|
||||
importFrom(rlang,zap_srcref)
|
||||
|
||||
53
NEWS.md
53
NEWS.md
@@ -1,12 +1,37 @@
|
||||
Addresses #2521: Updated the list of TCP ports that will [be rejected](https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/port_util.cc)
|
||||
by default in runapp.R, adding 5060, 5061 and 6566. Added documentation describing the port range (3000:8000)
|
||||
and which ports are rejected.
|
||||
|
||||
shiny 1.6.0.9000
|
||||
shiny 1.7.1.9001
|
||||
================
|
||||
|
||||
## Full changelog
|
||||
|
||||
### Minor new features and improvements
|
||||
|
||||
* Shiny's internal HTML dependencies are now mounted dynamically instead of statically. (#3537)
|
||||
|
||||
* HTML dependencies that are sent to dynamic UI now have better type checking, and no longer require a `dep.src.href` field. (#3537)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* Closed tidyverse/dplyr#5552: Compatibility of dplyr 1.0 (and rlang chained errors in general) with `req()`, `validate()`, and friends.
|
||||
|
||||
* Closed #2955: Input and output bindings previously attempted to use `el['data-input-id']`, but that never worked. They now use `el.getAttribute('data-input-id')` instead. (#3538)
|
||||
|
||||
* Closed tidyverse/dplyr#6154: Values from an `actionButton()` had S3 classes in the incorrect order.
|
||||
|
||||
shiny 1.7.1
|
||||
===========
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* Closed #3516: Fix regression in repeated calls to `appendTab()` when `navbarMenu()` is already present within a `tabsetPanel()`/`navbarPage()`. (#3518)
|
||||
|
||||
* Re-arranged conditions for testthat 1.0.0 compatibility. (#3512)
|
||||
|
||||
|
||||
shiny 1.7.0
|
||||
===========
|
||||
|
||||
## Full changelog
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* The `format` and `locale` arguments to `sliderInput()` have been removed. They have been deprecated since 0.10.2.2 (released on 2014-12-08).
|
||||
@@ -21,16 +46,20 @@ shiny 1.6.0.9000
|
||||
* Closed #3322, #3313, #1823, #3321, #3320, #1928, and #2310: Various improvements to `navbarPage()`, `tabsetPanel()`, `tabPanel()`, `navbarMenu()`, etc. Also, these functions are now powered by the `{bslib}` package's new `nav()` API (consider using `{bslib}`'s API to create better looking and more fully featured navs). (#3388)
|
||||
|
||||
* All uses of `list(...)` have been replaced with `rlang::list2(...)`. This means that you can use trailing `,` without error and use rlang's `!!!` operator to "splice" a list of argument values into `...`. We think this'll be particularly useful for passing a list of `tabPanel()` to their consumers (i.e., `tabsetPanel()`, `navbarPage()`, etc). For example, `tabs <- list(tabPanel("A", "a"), tabPanel("B", "b")); navbarPage(!!!tabs)`. (#3315 and #3328)
|
||||
|
||||
|
||||
* `installExprFunction()` and `exprToFunction()` are now able to handle quosures when `quoted = TRUE`. So `render`-functions which call these functions (such as with `htmlwidgets`) can now understand quosures. Users can also use `rlang::inject()` to unquote a quosure for evaluation. This also means that `render` function no longer need `env` and `quoted` parameters; that information can be embedded into a quosure which is then passed to the `render` function. Better documentation was added for how to create `render` functions. (#3472)
|
||||
|
||||
* `icon(lib="fontawesome")` is now powered by the `{fontawesome}` package, which will make it easier to use the latest FA icons in the future (by updating the `{fontawesome}` package). (#3302)
|
||||
|
||||
* Closed #3397: `renderPlot()` new uses `ggplot2::get_alt_text()` to inform an `alt` text default (for `{ggplot2}` plots). (#3398)
|
||||
|
||||
* `modalDialog()` gains support for `size = "xl"`. (#3410)
|
||||
|
||||
* Addressed #2521: Updated the list of TCP ports that will be rejected by default in runapp.R, adding 5060, 5061 and 6566. Added documentation describing the port range (3000:8000) and which ports are rejected. (#3456)
|
||||
|
||||
### Other improvements
|
||||
|
||||
* Shiny's core JavaScript code was converted to TypeScript. For the latest development information, please see the [README.md in `./srcts`](https://github.com/rstudio/shiny/tree/master/srcts). (#3296)
|
||||
* Shiny's core JavaScript code was converted to TypeScript. For the latest development information, please see the [README.md in `./srcts`](https://github.com/rstudio/shiny/tree/v1.7.0/srcts). (#3296)
|
||||
|
||||
* Switched from `digest::digest()` to `rlang::hash()` for hashing. (#3264)
|
||||
|
||||
@@ -42,10 +71,14 @@ shiny 1.6.0.9000
|
||||
|
||||
* Closed #3345: Shiny now correctly renders `htmltools::htmlDependency()`(s) with a `list()` of `script` attributes when used in a dynamic UI context. This fairly new `htmlDependency()` feature was added in `{htmltools}` v0.5.1. (#3395)
|
||||
|
||||
* Closed #3374: `quoToFunction()` now works correctly with nested quosures; and as a result, quasi-quotation with rendering function (e.g., `renderPrint()`, `renderPlot()`, etc) now works as expected with nested quosures. (#3373)
|
||||
* Fixed [#2666](https://github.com/rstudio/shiny/issues/2666) and [#2670](https://github.com/rstudio/shiny/issues/2670): `nearPoints()` and `brushedPoints()` weren't properly account for missing values (#2666 was introduced in v1.4.0). ([#2668](https://github.com/rstudio/shiny/pull/2668))
|
||||
|
||||
* Closed #3374: `quoToFunction()` now works correctly with nested quosures; and as a result, quasi-quotation with rendering function (e.g., `renderPrint()`, `renderPlot()`, etc) now works as expected with nested quosures. (#3373)
|
||||
|
||||
* Exported `register_devmode_option()`. This method was described in the documentation for `devmode()` but was never exported. See `?devmode()` for more details on how to register Shiny Developer options using `register_devmode_option()`. (#3364)
|
||||
|
||||
* Closed #3484: In the RStudio IDE on Mac 11.5, selected checkboxes and radio buttons were not visible. (#3485)
|
||||
|
||||
### Library updates
|
||||
|
||||
* Closed #3286: Updated to Font-Awesome 5.15.2. (#3288)
|
||||
@@ -59,7 +92,7 @@ This release focuses on improvements in three main areas:
|
||||
|
||||
1. Better theming (and Bootstrap 4) support:
|
||||
* The `theme` argument of `fluidPage()`, `navbarPage()`, and `bootstrapPage()` all now understand `bslib::bs_theme()` objects, which can be used to opt-into Bootstrap 4, use any Bootswatch theme, and/or implement custom themes without writing any CSS.
|
||||
* The `session` object now includes `$setCurrentTheme()` and `$getCurrentTheme()` methods to dynamically update (or obtain) the page's `theme` after initial load, which is useful for things such as [adding a dark mode switch to an app](https://rstudio.github.io/bslib/articles/theming.html#dynamic-shiny) or some other "real-time" theming tool like `bslib::bs_themer()`.
|
||||
* The `session` object now includes `$setCurrentTheme()` and `$getCurrentTheme()` methods to dynamically update (or obtain) the page's `theme` after initial load, which is useful for things such as [adding a dark mode switch to an app](https://rstudio.github.io/bslib/articles/bslib.html#dynamic) or some other "real-time" theming tool like `bslib::bs_themer()`.
|
||||
* For more details, see [`{bslib}`'s website](https://rstudio.github.io/bslib/)
|
||||
|
||||
2. Caching of `reactive()` and `render*()` (e.g. `renderText()`, `renderTable()`, etc) expressions.
|
||||
@@ -181,7 +214,7 @@ shiny 1.5.0
|
||||
|
||||
* The new `moduleServer` function provides a simpler interface for creating and using modules. (#2773)
|
||||
|
||||
* Resolved #2732: `markdown()` is a new function for writing Markdown with Github extensions directly in Shiny UIs. Markdown rendering is performed by the [commonmark](https://github.com/jeroen/commonmark) package. (#2737)
|
||||
* Resolved #2732: `markdown()` is a new function for writing Markdown with Github extensions directly in Shiny UIs. Markdown rendering is performed by the [commonmark](https://github.com/r-lib/commonmark) package. (#2737)
|
||||
|
||||
* The `getCurrentOutputInfo()` function can now return the background color (`bg`), foreground color (`fg`), `accent` (i.e., hyperlink) color, and `font` information of the output's HTML container. This information is reported by `plotOutput()`, `imageOutput()`, and any other output bindings containing a class of `.shiny-report-theme`. This feature allows developers to style an output's contents based on the container's CSS styling. (#2740)
|
||||
|
||||
|
||||
@@ -125,14 +125,14 @@ shinyAppTemplate <- function(path = NULL, examples = "default", dryrun = FALSE)
|
||||
}
|
||||
|
||||
if ("shinytest" %in% examples) {
|
||||
if (!is_available("shinytest", "1.4.0"))
|
||||
if (!is_installed("shinytest", "1.4.0"))
|
||||
{
|
||||
message(
|
||||
"The tests/shinytest directory needs shinytest 1.4.0 or later to work properly."
|
||||
)
|
||||
if (is_available("shinytest")) {
|
||||
if (is_installed("shinytest")) {
|
||||
message("You currently have shinytest ",
|
||||
utils::packageVersion("shinytest"), " installed.")
|
||||
get_package_version("shinytest"), " installed.")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -152,7 +152,7 @@ shinyAppTemplate <- function(path = NULL, examples = "default", dryrun = FALSE)
|
||||
|
||||
# Helper to resolve paths relative to our template
|
||||
template_path <- function(...) {
|
||||
system.file("app_template", ..., package = "shiny")
|
||||
system_file("app_template", ..., package = "shiny")
|
||||
}
|
||||
|
||||
# Resolve path relative to destination
|
||||
|
||||
@@ -255,7 +255,7 @@ utils::globalVariables(".GenericCallEnv", add = TRUE)
|
||||
#' the cache.
|
||||
#'
|
||||
#' You may need to provide a `cacheHint` to [createRenderFunction()] (or
|
||||
#' [htmlwidgets::shinyRenderWidget()], if you've authored an htmlwidget) in
|
||||
#' `htmlwidgets::shinyRenderWidget()`, if you've authored an htmlwidget) in
|
||||
#' order for `bindCache()` to correctly compute a cache key.
|
||||
#'
|
||||
#' The potential problem is a cache collision. Consider the following:
|
||||
@@ -292,11 +292,11 @@ utils::globalVariables(".GenericCallEnv", add = TRUE)
|
||||
#' In some cases, however, the automatic cache hint inference is not
|
||||
#' sufficient, and it is necessary to provide a cache hint. This is true
|
||||
#' for `renderPrint()`. Unlike `renderText()`, it wraps the user-provided
|
||||
#' expression in another function, before passing it to [markRenderFunction()]
|
||||
#' expression in another function, before passing it to [createRenderFunction()]
|
||||
#' (instead of [createRenderFunction()]). Because the user code is wrapped in
|
||||
#' another function, `markRenderFunction()` is not able to automatically
|
||||
#' another function, `createRenderFunction()` is not able to automatically
|
||||
#' extract the user-provided code and use it in the cache key. Instead,
|
||||
#' `renderPrint` calls `markRenderFunction()`, it explicitly passes along a
|
||||
#' `renderPrint` calls `createRenderFunction()`, it explicitly passes along a
|
||||
#' `cacheHint`, which includes a label and the original user expression.
|
||||
#'
|
||||
#' In general, if you need to provide a `cacheHint`, it is best practice to
|
||||
@@ -310,19 +310,19 @@ utils::globalVariables(".GenericCallEnv", add = TRUE)
|
||||
#'
|
||||
#' ```
|
||||
#' renderMyWidget <- function(expr) {
|
||||
#' expr <- substitute(expr)
|
||||
#' q <- rlang::enquo0(expr)
|
||||
#'
|
||||
#' htmlwidgets::shinyRenderWidget(expr,
|
||||
#' htmlwidgets::shinyRenderWidget(
|
||||
#' q,
|
||||
#' myWidgetOutput,
|
||||
#' quoted = TRUE,
|
||||
#' env = parent.frame(),
|
||||
#' cacheHint = list(label = "myWidget", userExpr = expr)
|
||||
#' cacheHint = list(label = "myWidget", userQuo = q)
|
||||
#' )
|
||||
#' }
|
||||
#' ```
|
||||
#'
|
||||
#' If your `render` function sets any internal state, you may find it useful
|
||||
#' in your call to [createRenderFunction()] or [markRenderFunction()] to use
|
||||
#' in your call to [createRenderFunction()] to use
|
||||
#' the `cacheWriteHook` and/or `cacheReadHook` parameters. These hooks are
|
||||
#' functions that run just before the object is stored in the cache, and just
|
||||
#' after the object is retrieved from the cache. They can modify the data
|
||||
@@ -339,8 +339,8 @@ utils::globalVariables(".GenericCallEnv", add = TRUE)
|
||||
#' effects or modify some external state, and they must re-execute each time
|
||||
#' in order to work properly.
|
||||
#'
|
||||
#' For developers of such code, they should call [createRenderFunction()] or
|
||||
#' [markRenderFunction()] with `cacheHint = FALSE`.
|
||||
#' For developers of such code, they should call [createRenderFunction()] (or
|
||||
#' [markRenderFunction()]) with `cacheHint = FALSE`.
|
||||
#'
|
||||
#'
|
||||
#' @section Caching with `renderPlot()`:
|
||||
|
||||
@@ -1,87 +1,4 @@
|
||||
|
||||
#' Create a page with fluid layout
|
||||
#'
|
||||
#' Functions for creating fluid page layouts. A fluid page layout consists of
|
||||
#' rows which in turn include columns. Rows exist for the purpose of making sure
|
||||
#' their elements appear on the same line (if the browser has adequate width).
|
||||
#' Columns exist for the purpose of defining how much horizontal space within a
|
||||
#' 12-unit wide grid it's elements should occupy. Fluid pages scale their
|
||||
#' components in realtime to fill all available browser width.
|
||||
#'
|
||||
#' @param ... Elements to include within the page
|
||||
#' @param title The browser window title (defaults to the host URL of the page).
|
||||
#' Can also be set as a side effect of the [titlePanel()] function.
|
||||
#' @inheritParams bootstrapPage
|
||||
#'
|
||||
#' @return A UI defintion that can be passed to the [shinyUI] function.
|
||||
#'
|
||||
#' @details To create a fluid page use the `fluidPage` function and include
|
||||
#' instances of `fluidRow` and [column()] within it. As an
|
||||
#' alternative to low-level row and column functions you can also use
|
||||
#' higher-level layout functions like [sidebarLayout()].
|
||||
#'
|
||||
#' @note See the [
|
||||
#' Shiny-Application-Layout-Guide](https://shiny.rstudio.com/articles/layout-guide.html) for additional details on laying out fluid
|
||||
#' pages.
|
||||
#'
|
||||
#' @family layout functions
|
||||
#' @seealso [column()]
|
||||
#'
|
||||
#' @examples
|
||||
#' ## Only run examples in interactive R sessions
|
||||
#' if (interactive()) {
|
||||
#'
|
||||
#' # Example of UI with fluidPage
|
||||
#' ui <- fluidPage(
|
||||
#'
|
||||
#' # Application title
|
||||
#' titlePanel("Hello Shiny!"),
|
||||
#'
|
||||
#' sidebarLayout(
|
||||
#'
|
||||
#' # Sidebar with a slider input
|
||||
#' sidebarPanel(
|
||||
#' sliderInput("obs",
|
||||
#' "Number of observations:",
|
||||
#' min = 0,
|
||||
#' max = 1000,
|
||||
#' value = 500)
|
||||
#' ),
|
||||
#'
|
||||
#' # Show a plot of the generated distribution
|
||||
#' mainPanel(
|
||||
#' plotOutput("distPlot")
|
||||
#' )
|
||||
#' )
|
||||
#' )
|
||||
#'
|
||||
#' # Server logic
|
||||
#' server <- function(input, output) {
|
||||
#' output$distPlot <- renderPlot({
|
||||
#' hist(rnorm(input$obs))
|
||||
#' })
|
||||
#' }
|
||||
#'
|
||||
#' # Complete app with UI and server components
|
||||
#' shinyApp(ui, server)
|
||||
#'
|
||||
#'
|
||||
#' # UI demonstrating column layouts
|
||||
#' ui <- fluidPage(
|
||||
#' title = "Hello Shiny!",
|
||||
#' fluidRow(
|
||||
#' column(width = 4,
|
||||
#' "4"
|
||||
#' ),
|
||||
#' column(width = 3, offset = 2,
|
||||
#' "3 offset 2"
|
||||
#' )
|
||||
#' )
|
||||
#' )
|
||||
#'
|
||||
#' shinyApp(ui, server = function(input, output) { })
|
||||
#' }
|
||||
#' @rdname fluidPage
|
||||
#' @rdname bootstrapPage
|
||||
#' @export
|
||||
fluidPage <- function(..., title = NULL, theme = NULL, lang = NULL) {
|
||||
bootstrapPage(div(class = "container-fluid", ...),
|
||||
@@ -91,62 +8,13 @@ fluidPage <- function(..., title = NULL, theme = NULL, lang = NULL) {
|
||||
}
|
||||
|
||||
|
||||
#' @rdname fluidPage
|
||||
#' @rdname column
|
||||
#' @export
|
||||
fluidRow <- function(...) {
|
||||
div(class = "row", ...)
|
||||
}
|
||||
|
||||
#' Create a page with a fixed layout
|
||||
#'
|
||||
#' Functions for creating fixed page layouts. A fixed page layout consists of
|
||||
#' rows which in turn include columns. Rows exist for the purpose of making sure
|
||||
#' their elements appear on the same line (if the browser has adequate width).
|
||||
#' Columns exist for the purpose of defining how much horizontal space within a
|
||||
#' 12-unit wide grid it's elements should occupy. Fixed pages limit their width
|
||||
#' to 940 pixels on a typical display, and 724px or 1170px on smaller and larger
|
||||
#' displays respectively.
|
||||
#'
|
||||
#' @param ... Elements to include within the container
|
||||
#' @param title The browser window title (defaults to the host URL of the page)
|
||||
#' @inheritParams bootstrapPage
|
||||
#'
|
||||
#' @return A UI defintion that can be passed to the [shinyUI] function.
|
||||
#'
|
||||
#' @details To create a fixed page use the `fixedPage` function and include
|
||||
#' instances of `fixedRow` and [column()] within it. Note that
|
||||
#' unlike [fluidPage()], fixed pages cannot make use of higher-level
|
||||
#' layout functions like `sidebarLayout`, rather, all layout must be done
|
||||
#' with `fixedRow` and `column`.
|
||||
#'
|
||||
#' @note See the [
|
||||
#' Shiny Application Layout Guide](https://shiny.rstudio.com/articles/layout-guide.html) for additional details on laying out fixed
|
||||
#' pages.
|
||||
#'
|
||||
#' @family layout functions
|
||||
#'
|
||||
#' @seealso [column()]
|
||||
#'
|
||||
#' @examples
|
||||
#' ## Only run examples in interactive R sessions
|
||||
#' if (interactive()) {
|
||||
#'
|
||||
#' ui <- fixedPage(
|
||||
#' title = "Hello, Shiny!",
|
||||
#' fixedRow(
|
||||
#' column(width = 4,
|
||||
#' "4"
|
||||
#' ),
|
||||
#' column(width = 3, offset = 2,
|
||||
#' "3 offset 2"
|
||||
#' )
|
||||
#' )
|
||||
#' )
|
||||
#'
|
||||
#' shinyApp(ui, server = function(input, output) { })
|
||||
#' }
|
||||
#'
|
||||
#' @rdname fixedPage
|
||||
#' @rdname bootstrapPage
|
||||
#' @export
|
||||
fixedPage <- function(..., title = NULL, theme = NULL, lang = NULL) {
|
||||
bootstrapPage(div(class = "container", ...),
|
||||
@@ -155,28 +23,39 @@ fixedPage <- function(..., title = NULL, theme = NULL, lang = NULL) {
|
||||
lang = lang)
|
||||
}
|
||||
|
||||
#' @rdname fixedPage
|
||||
#' @rdname column
|
||||
#' @export
|
||||
fixedRow <- function(...) {
|
||||
div(class = "row", ...)
|
||||
}
|
||||
|
||||
|
||||
#' Create a column within a UI definition
|
||||
#' Responsive row-column based layout
|
||||
#'
|
||||
#' Create a column for use within a [fluidRow()] or
|
||||
#' [fixedRow()]
|
||||
#' Layout UI components using Bootstrap's grid layout system. Use
|
||||
#' `fluidRow()` to group elements that should appear on the same line (if the
|
||||
#' browser has adequate width) and `column()` to define how much horizontal
|
||||
#' space within a 12-unit wide grid each on of these elements should occupy. See
|
||||
#' the [layout guide](https://shiny.rstudio.com/articles/layout-guide.html) for
|
||||
#' more context and examples.
|
||||
#'
|
||||
#' @param width The grid width of the column (must be between 1 and 12)
|
||||
#' @param ... Elements to include within the column
|
||||
#' To work properly, these functions need [Bootstrap](https://getbootstrap.com)
|
||||
#' included on the page. Since most Shiny apps use [bootstrapPage()]
|
||||
#' under-the-hood, this is usually the case, but custom page containers (i.e.,
|
||||
#' [htmlTemplate()]) may need to explicitly include [bootstrapLib()]
|
||||
#' dependencies.
|
||||
#'
|
||||
#' @param width The grid width of the column (must be between 1 and 12). When
|
||||
#' the device width is small (e.g., the viewer is on a mobile phone), the
|
||||
#' width is always 12. For more control over these responsive breakpoints, use
|
||||
#' Bootstrap's grid system more directly (e.g., `fluidRow(div(class =
|
||||
#' "col-lg-2", ...))`).
|
||||
#' @param ... UI elements (i.e., [tags]). For `fluidRow()`, `...` should be a set of `column()`s.
|
||||
#' @param offset The number of columns to offset this column from the end of the
|
||||
#' previous column.
|
||||
#'
|
||||
#' @return A column that can be included within a
|
||||
#' [fluidRow()] or [fixedRow()].
|
||||
#' @return A UI element (i.e., [tags]).
|
||||
#'
|
||||
#'
|
||||
#' @seealso [fluidRow()], [fixedRow()].
|
||||
#' @seealso [fluidPage()]
|
||||
#'
|
||||
#' @examples
|
||||
#' ## Only run examples in interactive R sessions
|
||||
@@ -202,16 +81,10 @@ fixedRow <- function(...) {
|
||||
#'
|
||||
#' shinyApp(ui, server)
|
||||
#'
|
||||
#'
|
||||
#'
|
||||
#' ui <- fluidPage(
|
||||
#' fluidRow(
|
||||
#' column(width = 4,
|
||||
#' "4"
|
||||
#' ),
|
||||
#' column(width = 3, offset = 2,
|
||||
#' "3 offset 2"
|
||||
#' )
|
||||
#' column(width = 4, "4"),
|
||||
#' column(width = 3, offset = 2, "3 offset 2")
|
||||
#' )
|
||||
#' )
|
||||
#' shinyApp(ui, server = function(input, output) { })
|
||||
|
||||
106
R/bootstrap.R
106
R/bootstrap.R
@@ -1,36 +1,84 @@
|
||||
#' @include utils.R
|
||||
NULL
|
||||
|
||||
#' Create a Bootstrap page
|
||||
#' Create a Bootstrap UI page container
|
||||
#'
|
||||
#' Create a Shiny UI page that loads the CSS and JavaScript for
|
||||
#' [Bootstrap](https://getbootstrap.com/), and has no content in the page
|
||||
#' body (other than what you provide).
|
||||
#' @description
|
||||
#' Create a user interface (UI) page container based on
|
||||
#' [Bootstrap](https://getbootstrap.com/)'s CSS and JavaScript. Most Shiny apps
|
||||
#' should use [fluidPage()] (or [navbarPage()]) to get a page container with a
|
||||
#' responsive page width, but in some cases you may want a fixed width container
|
||||
#' (`fixedPage()`) or just a bare `<body>` container (`bootstrapPage()`).
|
||||
#'
|
||||
#' This function is primarily intended for users who are proficient in HTML/CSS,
|
||||
#' and know how to lay out pages in Bootstrap. Most applications should use
|
||||
#' [fluidPage()] along with layout functions like
|
||||
#' [fluidRow()] and [sidebarLayout()].
|
||||
#' Most Shiny apps make use of other Shiny UI functions for [managing
|
||||
#' layout](https://shiny.rstudio.com/articles/layout-guide.html) (e.g.,
|
||||
#' [sidebarLayout()], [fluidRow()], etc), navigation (e.g., [tabPanel()]), and
|
||||
#' other styling (e.g., [wellPanel()], [inputPanel()]). A good portion of these
|
||||
#' Shiny UI functions require Bootstrap to work properly (so most Shiny apps
|
||||
#' should use these functions to start their UI definitions), but more advanced
|
||||
#' usage (i.e., custom HTML/CSS/JS) can avoid Bootstrap entirely by using
|
||||
#' [htmlTemplate()] and/or HTML [tags].
|
||||
#'
|
||||
#' @param ... The contents of the document body.
|
||||
#' @param title The browser window title (defaults to the host URL of the page)
|
||||
#' @param ... UI elements (i.e., [tags]).
|
||||
#' @param title The browser window title (defaults to the host URL of the page).
|
||||
#' Can also be set as a side effect of the [titlePanel()] function.
|
||||
#' @param theme One of the following:
|
||||
#' * `NULL` (the default), which implies a "stock" build of Bootstrap 3.
|
||||
#' * A [bslib::bs_theme()] object. This can be used to replace a stock
|
||||
#' build of Bootstrap 3 with a customized version of Bootstrap 3 or higher.
|
||||
#' * A character string pointing to an alternative Bootstrap stylesheet
|
||||
#' (normally a css file within the www directory, e.g. `www/bootstrap.css`).
|
||||
#' This option is here mainly for legacy reasons.
|
||||
#' @param lang ISO 639-1 language code for the HTML page, such as "en" or "ko".
|
||||
#' This will be used as the lang in the \code{<html>} tag, as in \code{<html lang="en">}.
|
||||
#' This will be used as the lang in the `<html>` tag, as in `<html lang="en">`.
|
||||
#' The default (NULL) results in an empty string.
|
||||
#'
|
||||
#' @return A UI defintion that can be passed to the [shinyUI] function.
|
||||
#' @return A UI definition (i.e., a [tags] object) that can be passed to [shinyApp()].
|
||||
#'
|
||||
#' @note The `basicPage` function is deprecated, you should use the
|
||||
#' [fluidPage()] function instead.
|
||||
#'
|
||||
#' @seealso [fluidPage()], [fixedPage()]
|
||||
#' @seealso [navbarPage()], [fillPage()], [column()], [tabPanel()]
|
||||
#' @export
|
||||
#' @examples
|
||||
#'
|
||||
#' # First create some UI content.
|
||||
#' # See the layout guide to learn more about creating different layouts
|
||||
#' # https://shiny.rstudio.com/articles/layout-guide.html
|
||||
#' ui <- sidebarLayout(
|
||||
#' sidebarPanel(sliderInput("obs", "Number of observations:", 0, 1000, 500)),
|
||||
#' mainPanel(plotOutput("distPlot"))
|
||||
#' )
|
||||
#' server <- function(input, output) {
|
||||
#' output$distPlot <- renderPlot(hist(rnorm(input$obs)))
|
||||
#' }
|
||||
#'
|
||||
#' # Demonstrating difference between fluidPage(), fixedPage(), bootstrapPage()
|
||||
#' if (interactive()) {
|
||||
#' # Container width scales _fluidly_ with window size
|
||||
#' shinyApp(fluidPage(ui), server)
|
||||
#' # Container width changes with window size at fixed breakpoints
|
||||
#' shinyApp(fixedPage(ui), server)
|
||||
#' # Container width is equal to the window's width
|
||||
#' shinyApp(bootstrapPage(ui), server)
|
||||
#' }
|
||||
#'
|
||||
#' # The default look is provided by Bootstrap 3, but {bslib} can be
|
||||
#' # used to customize the Bootstrap version and its default styling
|
||||
#' theme <- bslib::bs_theme(
|
||||
#' version = 5,
|
||||
#' bg = "#101010",
|
||||
#' fg = "#FDF7F7",
|
||||
#' primary = "#ED79F9",
|
||||
#' base_font = bslib::font_google("Prompt"),
|
||||
#' code_font = bslib::font_google("JetBrains Mono")
|
||||
#' )
|
||||
#' if (interactive()) {
|
||||
#' # Call thematic::thematic_shiny(font = "auto") to automatically
|
||||
#' # translate the theme/CSS to the R plot
|
||||
#' shinyApp(
|
||||
#' fluidPage(ui, theme = theme, title = "Hello Bootstrap 5"),
|
||||
#' server
|
||||
#' )
|
||||
#' }
|
||||
#'
|
||||
bootstrapPage <- function(..., title = NULL, theme = NULL, lang = NULL) {
|
||||
|
||||
args <- list(
|
||||
@@ -138,8 +186,7 @@ bs_theme_deps <- function(theme) {
|
||||
}
|
||||
|
||||
is_bs_theme <- function(x) {
|
||||
is_available("bslib", "0.2.0.9000") &&
|
||||
bslib::is_bs_theme(x)
|
||||
bslib::is_bs_theme(x)
|
||||
}
|
||||
|
||||
#' Obtain Shiny's Bootstrap Sass theme
|
||||
@@ -215,11 +262,10 @@ registerThemeDependency <- function(func) {
|
||||
|
||||
bootstrapDependency <- function(theme) {
|
||||
htmlDependency(
|
||||
"bootstrap", bootstrapVersion,
|
||||
c(
|
||||
href = "shared/bootstrap",
|
||||
file = system.file("www/shared/bootstrap", package = "shiny")
|
||||
),
|
||||
"bootstrap",
|
||||
bootstrapVersion,
|
||||
src = "www/shared/bootstrap",
|
||||
package = "shiny",
|
||||
script = c(
|
||||
"js/bootstrap.min.js",
|
||||
# Safely adding accessibility plugin for screen readers and keyboard users; no break for sighted aspects (see https://github.com/paypal/bootstrap-accessibility-plugin)
|
||||
@@ -236,14 +282,12 @@ bootstrapDependency <- function(theme) {
|
||||
|
||||
bootstrapVersion <- "3.4.1"
|
||||
|
||||
|
||||
#' @rdname bootstrapPage
|
||||
#' @export
|
||||
basicPage <- function(...) {
|
||||
bootstrapPage(div(class="container-fluid", list(...)))
|
||||
}
|
||||
|
||||
|
||||
#' Create a page that fills the window
|
||||
#'
|
||||
#' `fillPage` creates a page whose height and width always fill the
|
||||
@@ -1109,11 +1153,17 @@ tableOutput <- function(outputId) {
|
||||
|
||||
dataTableDependency <- list(
|
||||
htmlDependency(
|
||||
"datatables", "1.10.5", c(href = "shared/datatables"),
|
||||
"datatables",
|
||||
"1.10.5",
|
||||
src = "www/shared/datatables",
|
||||
package = "shiny",
|
||||
script = "js/jquery.dataTables.min.js"
|
||||
),
|
||||
htmlDependency(
|
||||
"datatables-bootstrap", "1.10.5", c(href = "shared/datatables"),
|
||||
"datatables-bootstrap",
|
||||
"1.10.5",
|
||||
src = "www/shared/datatables",
|
||||
package = "shiny",
|
||||
stylesheet = c("css/dataTables.bootstrap.css", "css/dataTables.extra.css"),
|
||||
script = "js/dataTables.bootstrap.js"
|
||||
)
|
||||
@@ -1153,7 +1203,7 @@ dataTableOutput <- function(outputId) {
|
||||
htmlOutput <- function(outputId, inline = FALSE,
|
||||
container = if (inline) span else div, ...)
|
||||
{
|
||||
if (anyUnnamed(list(...))) {
|
||||
if (any_unnamed(list(...))) {
|
||||
warning("Unnamed elements in ... will be replaced with dynamic UI.")
|
||||
}
|
||||
container(id = outputId, class="shiny-html-output", ...)
|
||||
|
||||
@@ -228,7 +228,9 @@ withLogErrors <- function(expr,
|
||||
if (promises::is.promise(result)) {
|
||||
result <- promises::catch(result, function(cond) {
|
||||
# Don't print shiny.silent.error (i.e. validation errors)
|
||||
if (inherits(cond, "shiny.silent.error")) return()
|
||||
if (cnd_inherits(cond, "shiny.silent.error")) {
|
||||
return()
|
||||
}
|
||||
if (isTRUE(getOption("show.error.messages"))) {
|
||||
printError(cond, full = full, offset = offset)
|
||||
}
|
||||
@@ -239,7 +241,7 @@ withLogErrors <- function(expr,
|
||||
},
|
||||
error = function(cond) {
|
||||
# Don't print shiny.silent.error (i.e. validation errors)
|
||||
if (inherits(cond, "shiny.silent.error")) return()
|
||||
if (cnd_inherits(cond, "shiny.silent.error")) return()
|
||||
if (isTRUE(getOption("show.error.messages"))) {
|
||||
printError(cond, full = full, offset = offset)
|
||||
}
|
||||
|
||||
@@ -9,13 +9,19 @@
|
||||
#' @param details Additional information to be added after a new line to the displayed message
|
||||
#' @keywords internal
|
||||
shinyDeprecated <- function(
|
||||
version, what, with = NULL, details = NULL
|
||||
version,
|
||||
what,
|
||||
with = NULL,
|
||||
details = NULL,
|
||||
type = c("deprecated", "superseded")
|
||||
) {
|
||||
if (is_false(getOption("shiny.deprecation.messages"))) {
|
||||
return(invisible())
|
||||
}
|
||||
|
||||
msg <- paste0("`", what, "` is deprecated as of shiny ", version, ".")
|
||||
type <- match.arg(type)
|
||||
|
||||
msg <- paste0("`", what, "` is ", type, " as of shiny ", version, ".")
|
||||
if (!is.null(with)) {
|
||||
msg <- paste0(msg, "\n", "Please use `", with, "` instead.")
|
||||
}
|
||||
@@ -32,13 +38,20 @@ deprecatedEnvQuotedMessage <- function() {
|
||||
if (!in_devmode()) return(invisible())
|
||||
if (is_false(getOption("shiny.deprecation.messages"))) return(invisible())
|
||||
|
||||
# manually
|
||||
# Capture calling function
|
||||
grandparent_call <- sys.call(-2)
|
||||
# Turn language into user friendly string
|
||||
grandparent_txt <- paste0(utils::capture.output({grandparent_call}), collapse = "\n")
|
||||
|
||||
msg <- paste0(
|
||||
"The `env` and `quoted` arguments are deprecated as of shiny 1.6.0.",
|
||||
"The `env` and `quoted` arguments are deprecated as of shiny 1.7.0.",
|
||||
" Please use quosures from `rlang` instead.\n",
|
||||
"See <https://github.com/rstudio/shiny/issues/3108> for more information."
|
||||
"See <https://github.com/rstudio/shiny/issues/3108> for more information.\n",
|
||||
"Function call:\n",
|
||||
grandparent_txt
|
||||
)
|
||||
rlang::inform(message = msg, .frequency = "always", .frequency_id = msg, .file = stderr())
|
||||
# Call less often as users do not have much control over this warning
|
||||
rlang::inform(message = msg, .frequency = "regularly", .frequency_id = msg, .file = stderr())
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +73,7 @@ diskCache <- function(
|
||||
logfile = NULL
|
||||
) {
|
||||
shinyDeprecated("1.6.0", "diskCache()", "cachem::cache_disk()")
|
||||
if (lifecycle::is_present(exec_missing)) {
|
||||
if (is_present(exec_missing)) {
|
||||
shinyDeprecated("1.6.0", "diskCache(exec_missing =)")
|
||||
}
|
||||
|
||||
@@ -93,7 +106,7 @@ memoryCache <- function(
|
||||
logfile = NULL)
|
||||
{
|
||||
shinyDeprecated("1.6.0", "diskCache()", "cachem::cache_mem()")
|
||||
if (lifecycle::is_present(exec_missing)) {
|
||||
if (is_present(exec_missing)) {
|
||||
shinyDeprecated("1.6.0", "diskCache(exec_missing =)")
|
||||
}
|
||||
|
||||
|
||||
55
R/globals.R
55
R/globals.R
@@ -1,55 +1,6 @@
|
||||
# A scope where we can put mutable global state
|
||||
.globals <- new.env(parent = emptyenv())
|
||||
|
||||
register_s3_method <- function(pkg, generic, class, fun = NULL) {
|
||||
stopifnot(is.character(pkg), length(pkg) == 1)
|
||||
stopifnot(is.character(generic), length(generic) == 1)
|
||||
stopifnot(is.character(class), length(class) == 1)
|
||||
|
||||
if (is.null(fun)) {
|
||||
fun <- get(paste0(generic, ".", class), envir = parent.frame())
|
||||
} else {
|
||||
stopifnot(is.function(fun))
|
||||
}
|
||||
|
||||
if (pkg %in% loadedNamespaces()) {
|
||||
registerS3method(generic, class, fun, envir = asNamespace(pkg))
|
||||
}
|
||||
|
||||
# Always register hook in case pkg is loaded at some
|
||||
# point the future (or, potentially, but less commonly,
|
||||
# unloaded & reloaded)
|
||||
setHook(
|
||||
packageEvent(pkg, "onLoad"),
|
||||
function(...) {
|
||||
registerS3method(generic, class, fun, envir = asNamespace(pkg))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
register_upgrade_message <- function(pkg, version) {
|
||||
|
||||
msg <- sprintf(
|
||||
"This version of Shiny is designed to work with '%s' >= %s.
|
||||
Please upgrade via install.packages('%s').",
|
||||
pkg, version, pkg
|
||||
)
|
||||
|
||||
if (pkg %in% loadedNamespaces() && !is_available(pkg, version)) {
|
||||
packageStartupMessage(msg)
|
||||
}
|
||||
|
||||
# Always register hook in case pkg is loaded at some
|
||||
# point the future (or, potentially, but less commonly,
|
||||
# unloaded & reloaded)
|
||||
setHook(
|
||||
packageEvent(pkg, "onLoad"),
|
||||
function(...) {
|
||||
if (!is_available(pkg, version)) packageStartupMessage(msg)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
.onLoad <- function(libname, pkgname) {
|
||||
# R's lazy-loading package scheme causes the private seed to be cached in the
|
||||
# package itself, making our PRNG completely deterministic. This line resets
|
||||
@@ -62,9 +13,9 @@ register_upgrade_message <- function(pkg, version) {
|
||||
|
||||
# Make sure these methods are available to knitr if shiny is loaded but not
|
||||
# attached.
|
||||
register_s3_method("knitr", "knit_print", "reactive")
|
||||
register_s3_method("knitr", "knit_print", "shiny.appobj")
|
||||
register_s3_method("knitr", "knit_print", "shiny.render.function")
|
||||
s3_register("knitr::knit_print", "reactive")
|
||||
s3_register("knitr::knit_print", "shiny.appobj")
|
||||
s3_register("knitr::knit_print", "shiny.render.function")
|
||||
|
||||
# Shiny 1.4.0 bumps jQuery 1.x to 3.x, which caused a problem
|
||||
# with static-rendering of htmlwidgets, and htmlwidgets 1.5
|
||||
|
||||
38
R/graph.R
38
R/graph.R
@@ -4,7 +4,7 @@
|
||||
# @param version The version of the package
|
||||
check_suggested <- function(package, version = NULL) {
|
||||
|
||||
if (is_available(package, version)) {
|
||||
if (is_installed(package, version)) {
|
||||
return()
|
||||
}
|
||||
|
||||
@@ -115,22 +115,28 @@ check_reactlog <- function() {
|
||||
}
|
||||
# read reactlog version from description file
|
||||
# prevents version mismatch in code and description file
|
||||
reactlog_version <- function() {
|
||||
desc <- read.dcf(system.file("DESCRIPTION", package = "shiny", mustWork = TRUE))
|
||||
suggests <- desc[1,"Suggests"][[1]]
|
||||
suggests_pkgs <- strsplit(suggests, "\n")[[1]]
|
||||
reactlog_version <- local({
|
||||
version <- NULL
|
||||
function() {
|
||||
if (!is.null(version)) return(version)
|
||||
|
||||
reactlog_info <- suggests_pkgs[grepl("reactlog", suggests_pkgs)]
|
||||
if (length(reactlog_info) == 0) {
|
||||
stop("reactlog can not be found in shiny DESCRIPTION file")
|
||||
desc <- read.dcf(system_file("DESCRIPTION", package = "shiny"))
|
||||
suggests <- desc[1,"Suggests"][[1]]
|
||||
suggests_pkgs <- strsplit(suggests, "\n")[[1]]
|
||||
|
||||
reactlog_info <- suggests_pkgs[grepl("reactlog", suggests_pkgs)]
|
||||
if (length(reactlog_info) == 0) {
|
||||
stop("reactlog can not be found in shiny DESCRIPTION file")
|
||||
}
|
||||
|
||||
reactlog_info <- sub("^[^\\(]*\\(", "", reactlog_info)
|
||||
reactlog_info <- sub("\\)[^\\)]*$", "", reactlog_info)
|
||||
reactlog_info <- sub("^[>= ]*", "", reactlog_info)
|
||||
|
||||
version <<- package_version(reactlog_info)
|
||||
version
|
||||
}
|
||||
|
||||
reactlog_info <- sub("^[^\\(]*\\(", "", reactlog_info)
|
||||
reactlog_info <- sub("\\)[^\\)]*$", "", reactlog_info)
|
||||
reactlog_info <- sub("^[>= ]*", "", reactlog_info)
|
||||
|
||||
package_version(reactlog_info)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
RLog <- R6Class(
|
||||
@@ -512,7 +518,7 @@ MessageLogger = R6Class(
|
||||
return(txt)
|
||||
},
|
||||
singleLine = function(txt) {
|
||||
gsub("[^\\]\\n", "\\\\n", txt)
|
||||
gsub("([^\\])\\n", "\\1\\\\n", txt)
|
||||
},
|
||||
valueStr = function(valueStr) {
|
||||
paste0(
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#' `delay` milliseconds before sending an event.
|
||||
#' @seealso [brushOpts()] for brushing events.
|
||||
#' @export
|
||||
#' @keywords internal
|
||||
clickOpts <- function(id, clip = TRUE) {
|
||||
if (is.null(id))
|
||||
stop("id must not be NULL")
|
||||
|
||||
@@ -267,6 +267,7 @@ nearPoints <- function(df, coordinfo, xvar = NULL, yvar = NULL,
|
||||
stop("nearPoints: `yvar` ('", yvar ,"') not in names of input")
|
||||
|
||||
# Extract data values from the data frame
|
||||
coordinfo <- fortifyDiscreteLimits(coordinfo)
|
||||
x <- asNumber(df[[xvar]], coordinfo$domain$discrete_limits$x)
|
||||
y <- asNumber(df[[yvar]], coordinfo$domain$discrete_limits$y)
|
||||
|
||||
@@ -392,6 +393,7 @@ nearPoints <- function(df, coordinfo, xvar = NULL, yvar = NULL,
|
||||
# an input brush
|
||||
within_brush <- function(vals, brush, var = "x") {
|
||||
var <- match.arg(var, c("x", "y"))
|
||||
brush <- fortifyDiscreteLimits(brush)
|
||||
vals <- asNumber(vals, brush$domain$discrete_limits[[var]])
|
||||
# It's possible for a non-missing data values to not
|
||||
# map to the axis limits, for example:
|
||||
@@ -414,11 +416,43 @@ asNumber <- function(x, levels = NULL) {
|
||||
as.numeric(x)
|
||||
}
|
||||
|
||||
# Ensure the discrete limits/levels of a coordmap received
|
||||
# from the client matches the data structure sent the client.
|
||||
#
|
||||
# When we construct the coordmap (in getGgplotCoordmap()),
|
||||
# we save a character vector which may contain missing values
|
||||
# (e.g., c("a", "b", NA)). When that same character is received
|
||||
# from the client, it runs through decodeMessage() which sets
|
||||
# simplifyVector=FALSE, which means NA are replaced by NULL
|
||||
# (because jsonlite::fromJSON('["a", "b", null]') -> list("a", "b", NULL))
|
||||
#
|
||||
# Thankfully, it doesn't seem like it's meaningful for limits to
|
||||
# contains a NULL in the 1st place, so we simply treat NULL like NA.
|
||||
# For more context, https://github.com/rstudio/shiny/issues/2666
|
||||
fortifyDiscreteLimits <- function(coord) {
|
||||
# Note that discrete_limits$x/y are populated iff
|
||||
# x/y are discrete mappings
|
||||
coord$domain$discrete_limits <- lapply(
|
||||
coord$domain$discrete_limits,
|
||||
function(var) {
|
||||
# if there is an 'explicit' NULL, then the limits are NA
|
||||
if (is.null(var)) return(NA)
|
||||
vapply(var, function(x) {
|
||||
if (is.null(x) || isTRUE(is.na(x))) NA_character_ else x
|
||||
}, character(1))
|
||||
}
|
||||
)
|
||||
coord
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Given a panelvar value and a vector x, return logical vector indicating which
|
||||
# items match the panelvar value. Because the panelvar value is always a
|
||||
# string but the vector could be numeric, it might be necessary to coerce the
|
||||
# panelvar to a number before comparing to the vector.
|
||||
panelMatch <- function(search_value, x) {
|
||||
if (is.null(search_value)) return(is.na(x))
|
||||
if (is.numeric(x)) search_value <- as.numeric(search_value)
|
||||
x == search_value
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ startPNG <- function(filename, width, height, res, ...) {
|
||||
# to use ragg (say, instead of showtext, for custom font rendering).
|
||||
# In the next shiny release, this option will likely be superseded in
|
||||
# favor of a fully customizable graphics device option
|
||||
if ((getOption('shiny.useragg') %||% FALSE) && is_available("ragg")) {
|
||||
if ((getOption('shiny.useragg') %||% FALSE) && is_installed("ragg")) {
|
||||
pngfun <- ragg::agg_png
|
||||
} else if (capabilities("aqua")) {
|
||||
# i.e., png(type = 'quartz')
|
||||
pngfun <- grDevices::png
|
||||
} else if ((getOption('shiny.usecairo') %||% TRUE) && is_available("Cairo")) {
|
||||
} else if ((getOption('shiny.usecairo') %||% TRUE) && is_installed("Cairo")) {
|
||||
pngfun <- Cairo::CairoPNG
|
||||
} else {
|
||||
# i.e., png(type = 'cairo')
|
||||
|
||||
@@ -138,7 +138,8 @@ datePickerDependency <- function(theme) {
|
||||
htmlDependency(
|
||||
name = "bootstrap-datepicker-js",
|
||||
version = version_bs_date_picker,
|
||||
src = c(href = "shared/datepicker"),
|
||||
src = "www/shared/datepicker",
|
||||
package = "shiny",
|
||||
script = if (getOption("shiny.minified", TRUE)) "js/bootstrap-datepicker.min.js"
|
||||
else "js/bootstrap-datepicker.js",
|
||||
# Need to enable noConflict mode. See #1346.
|
||||
@@ -157,18 +158,19 @@ datePickerCSS <- function(theme) {
|
||||
return(htmlDependency(
|
||||
name = "bootstrap-datepicker-css",
|
||||
version = version_bs_date_picker,
|
||||
src = c(href = "shared/datepicker"),
|
||||
src = "www/shared/datepicker",
|
||||
package = "shiny",
|
||||
stylesheet = "css/bootstrap-datepicker3.min.css"
|
||||
))
|
||||
}
|
||||
|
||||
scss_file <- system.file(package = "shiny", "www/shared/datepicker/scss/build3.scss")
|
||||
scss_file <- system_file(package = "shiny", "www/shared/datepicker/scss/build3.scss")
|
||||
|
||||
bslib::bs_dependency(
|
||||
input = sass::sass_file(scss_file),
|
||||
theme = theme,
|
||||
name = "bootstrap-datepicker",
|
||||
version = version_bs_date_picker,
|
||||
cache_key_extra = shinyPackageVersion()
|
||||
cache_key_extra = get_package_version("shiny")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -213,14 +213,7 @@ selectizeIt <- function(inputId, select, options, nonempty = FALSE) {
|
||||
deps <- list(selectizeDependency())
|
||||
|
||||
if ('drag_drop' %in% options$plugins) {
|
||||
deps <- c(
|
||||
deps,
|
||||
list(htmlDependency(
|
||||
'jqueryui', '1.12.1',
|
||||
c(href = 'shared/jqueryui'),
|
||||
script = 'jquery-ui.min.js'
|
||||
))
|
||||
)
|
||||
deps[[length(deps) + 1]] <- jqueryuiDependency()
|
||||
}
|
||||
|
||||
# Insert script on same level as <select> tag
|
||||
@@ -247,7 +240,7 @@ selectizeDependencyFunc <- function(theme) {
|
||||
return(selectizeStaticDependency(version_selectize))
|
||||
}
|
||||
|
||||
selectizeDir <- system.file(package = "shiny", "www/shared/selectize/")
|
||||
selectizeDir <- system_file(package = "shiny", "www/shared/selectize/")
|
||||
bs_version <- bslib::theme_version(theme)
|
||||
stylesheet <- file.path(
|
||||
selectizeDir, "scss", paste0("selectize.bootstrap", bs_version, ".scss")
|
||||
@@ -267,15 +260,17 @@ selectizeDependencyFunc <- function(theme) {
|
||||
theme = theme,
|
||||
name = "selectize",
|
||||
version = version_selectize,
|
||||
cache_key_extra = shinyPackageVersion(),
|
||||
cache_key_extra = get_package_version("shiny"),
|
||||
.dep_args = list(script = script)
|
||||
)
|
||||
}
|
||||
|
||||
selectizeStaticDependency <- function(version) {
|
||||
htmlDependency(
|
||||
"selectize", version,
|
||||
src = c(href = "shared/selectize"),
|
||||
"selectize",
|
||||
version,
|
||||
src = "www/shared/selectize",
|
||||
package = "shiny",
|
||||
stylesheet = "css/selectize.bootstrap3.css",
|
||||
script = c(
|
||||
"js/selectize.min.js",
|
||||
|
||||
@@ -205,13 +205,17 @@ ionRangeSliderDependency <- function() {
|
||||
list(
|
||||
# ion.rangeSlider also needs normalize.css, which is already included in Bootstrap.
|
||||
htmlDependency(
|
||||
"ionrangeslider-javascript", version_ion_range_slider,
|
||||
src = c(href = "shared/ionrangeslider"),
|
||||
"ionrangeslider-javascript",
|
||||
version_ion_range_slider,
|
||||
src = "www/shared/ionrangeslider",
|
||||
package = "shiny",
|
||||
script = "js/ion.rangeSlider.min.js"
|
||||
),
|
||||
htmlDependency(
|
||||
"strftime", version_strftime,
|
||||
src = c(href = "shared/strftime"),
|
||||
"strftime",
|
||||
version_strftime,
|
||||
src = "www/shared/strftime",
|
||||
package = "shiny",
|
||||
script = "strftime-min.js"
|
||||
),
|
||||
bslib::bs_dependency_defer(ionRangeSliderDependencyCSS)
|
||||
@@ -223,7 +227,8 @@ ionRangeSliderDependencyCSS <- function(theme) {
|
||||
return(htmlDependency(
|
||||
"ionrangeslider-css",
|
||||
version_ion_range_slider,
|
||||
src = c(href = "shared/ionrangeslider"),
|
||||
src = "www/shared/ionrangeslider",
|
||||
package = "shiny",
|
||||
stylesheet = "css/ion.rangeSlider.css"
|
||||
))
|
||||
}
|
||||
@@ -232,13 +237,13 @@ ionRangeSliderDependencyCSS <- function(theme) {
|
||||
input = list(
|
||||
list(accent = "$component-active-bg"),
|
||||
sass::sass_file(
|
||||
system.file(package = "shiny", "www/shared/ionrangeslider/scss/shiny.scss")
|
||||
system_file(package = "shiny", "www/shared/ionrangeslider/scss/shiny.scss")
|
||||
)
|
||||
),
|
||||
theme = theme,
|
||||
name = "ionRangeSlider",
|
||||
version = version_ion_range_slider,
|
||||
cache_key_extra = shinyPackageVersion()
|
||||
cache_key_extra = get_package_version("shiny")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ normalizeChoicesArgs <- function(choices, choiceNames, choiceValues,
|
||||
if (length(choiceNames) != length(choiceValues)) {
|
||||
stop("`choiceNames` and `choiceValues` must have the same length.")
|
||||
}
|
||||
if (anyNamed(choiceNames) || anyNamed(choiceValues)) {
|
||||
if (any_named(choiceNames) || any_named(choiceValues)) {
|
||||
stop("`choiceNames` and `choiceValues` must not be named.")
|
||||
}
|
||||
} else {
|
||||
|
||||
13
R/jqueryui.R
13
R/jqueryui.R
@@ -79,8 +79,8 @@ absolutePanel <- function(...,
|
||||
if (isTRUE(draggable)) {
|
||||
divTag <- tagAppendAttributes(divTag, class='draggable')
|
||||
return(tagList(
|
||||
singleton(tags$head(tags$script(src='shared/jqueryui/jquery-ui.min.js'))),
|
||||
divTag,
|
||||
jqueryuiDependency(),
|
||||
tags$script('$(".draggable").draggable();')
|
||||
))
|
||||
} else {
|
||||
@@ -99,3 +99,14 @@ fixedPanel <- function(...,
|
||||
width=width, height=height, draggable=draggable, cursor=match.arg(cursor),
|
||||
fixed=TRUE)
|
||||
}
|
||||
|
||||
|
||||
jqueryuiDependency <- function() {
|
||||
htmlDependency(
|
||||
'jqueryui',
|
||||
'1.12.1',
|
||||
src = 'www/shared/jqueryui',
|
||||
package = 'shiny',
|
||||
script = 'jquery-ui.min.js'
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#' themselves in knitr/rmarkdown documents.
|
||||
#'
|
||||
#' @name knitr_methods
|
||||
#' @keywords internal
|
||||
#' @param x Object to knit_print
|
||||
#' @param ... Additional knit_print arguments
|
||||
NULL
|
||||
@@ -62,7 +63,7 @@ knit_print.shiny.appobj <- function(x, ...) {
|
||||
#' @param inline Whether the object is printed inline.
|
||||
knit_print.shiny.render.function <- function(x, ..., inline = FALSE) {
|
||||
x <- htmltools::as.tags(x, inline = inline)
|
||||
output <- knitr::knit_print(tagList(x))
|
||||
output <- knitr::knit_print(tagList(x), ..., inline = inline)
|
||||
attr(output, "knit_cacheable") <- FALSE
|
||||
attr(output, "knit_meta") <- append(attr(output, "knit_meta"),
|
||||
shiny_rmd_warning())
|
||||
@@ -76,5 +77,5 @@ knit_print.reactive <- function(x, ..., inline = FALSE) {
|
||||
renderFunc <- if (inline) renderText else renderPrint
|
||||
knitr::knit_print(renderFunc({
|
||||
x()
|
||||
}), inline = inline)
|
||||
}), ..., inline = inline)
|
||||
}
|
||||
|
||||
1
R/map.R
1
R/map.R
@@ -1,4 +1,3 @@
|
||||
#' @importFrom fastmap fastmap
|
||||
Map <- R6Class(
|
||||
'Map',
|
||||
portable = FALSE,
|
||||
|
||||
@@ -348,7 +348,7 @@ HandlerManager <- R6Class("HandlerManager",
|
||||
httpResponse(status = 500L,
|
||||
content_type = "text/html; charset=UTF-8",
|
||||
content = as.character(htmltools::htmlTemplate(
|
||||
system.file("template", "error.html", package = "shiny"),
|
||||
system_file("template", "error.html", package = "shiny"),
|
||||
message = conditionMessage(err)
|
||||
))
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Promise helpers taken from:
|
||||
# https://github.com/rstudio/promises/blob/master/tests/testthat/common.R
|
||||
# https://github.com/rstudio/promises/blob/main/tests/testthat/common.R
|
||||
# Block until all pending later tasks have executed
|
||||
wait_for_it <- function() {
|
||||
while (!later::loop_empty()) {
|
||||
|
||||
172
R/reactives.R
172
R/reactives.R
@@ -875,8 +875,7 @@ Observable <- R6Class(
|
||||
invisible(.value)
|
||||
},
|
||||
format = function() {
|
||||
label <- sprintf('reactive(%s)', paste(deparse(body(.origFunc)), collapse='\n'))
|
||||
strsplit(label, "\n")[[1]]
|
||||
simpleExprToFunction(fn_body(.origFunc), "reactive")
|
||||
},
|
||||
.updateValue = function() {
|
||||
ctx <- Context$new(.domain, .label, type = 'observable',
|
||||
@@ -945,14 +944,15 @@ Observable <- R6Class(
|
||||
#' See the [Shiny tutorial](https://shiny.rstudio.com/tutorial/) for
|
||||
#' more information about reactive expressions.
|
||||
#'
|
||||
#' @param x For `reactive`, an expression (quoted or unquoted). For
|
||||
#' `is.reactive`, an object to test.
|
||||
#' @param env The parent environment for the reactive expression. By default,
|
||||
#' this is the calling environment, the same as when defining an ordinary
|
||||
#' non-reactive expression.
|
||||
#' @param quoted Is the expression quoted? By default, this is `FALSE`.
|
||||
#' This is useful when you want to use an expression that is stored in a
|
||||
#' variable; to do so, it must be quoted with `quote()`.
|
||||
#' @param x For `is.reactive()`, an object to test. For `reactive()`, an expression. When passing in a [`quo()`]sure with `reactive()`, remember to use [`rlang::inject()`] to distinguish that you are passing in the content of your quosure, not the expression of the quosure.
|
||||
#' @template param-env
|
||||
#' @templateVar x x
|
||||
#' @templateVar env env
|
||||
#' @templateVar quoted quoted
|
||||
#' @template param-quoted
|
||||
#' @templateVar x x
|
||||
#' @templateVar quoted quoted
|
||||
|
||||
#' @param label A label for the reactive expression, useful for debugging.
|
||||
#' @param domain See [domains].
|
||||
#' @param ..stacktraceon Advanced use only. For stack manipulation purposes; see
|
||||
@@ -961,46 +961,56 @@ Observable <- R6Class(
|
||||
#' @return a function, wrapped in a S3 class "reactive"
|
||||
#'
|
||||
#' @examples
|
||||
#' library(rlang)
|
||||
#' values <- reactiveValues(A=1)
|
||||
#'
|
||||
#' reactiveB <- reactive({
|
||||
#' values$A + 1
|
||||
#' })
|
||||
#'
|
||||
#' # Can use quoted expressions
|
||||
#' reactiveC <- reactive(quote({ values$A + 2 }), quoted = TRUE)
|
||||
#'
|
||||
#' # To store expressions for later conversion to reactive, use quote()
|
||||
#' expr_q <- quote({ values$A + 3 })
|
||||
#' reactiveD <- reactive(expr_q, quoted = TRUE)
|
||||
#'
|
||||
#' # View the values from the R console with isolate()
|
||||
#' isolate(reactiveB())
|
||||
#' # 2
|
||||
#'
|
||||
#' # To store expressions for later conversion to reactive, use quote()
|
||||
#' myquo <- rlang::quo(values$A + 2)
|
||||
#' # Unexpected value! Sending a quosure directly will not work as expected.
|
||||
#' reactiveC <- reactive(myquo)
|
||||
#' # We'd hope for `3`, but instead we get the quosure that was supplied.
|
||||
#' isolate(reactiveC())
|
||||
#'
|
||||
#' # Instead, the quosure should be `rlang::inject()`ed
|
||||
#' reactiveD <- rlang::inject(reactive(!!myquo))
|
||||
#' isolate(reactiveD())
|
||||
#' # 3
|
||||
#'
|
||||
#' # (Legacy) Can use quoted expressions
|
||||
#' expr <- quote({ values$A + 3 })
|
||||
#' reactiveE <- reactive(expr, quoted = TRUE)
|
||||
#' isolate(reactiveE())
|
||||
#' # 4
|
||||
#'
|
||||
#' @export
|
||||
reactive <- function(x, env = parent.frame(), quoted = FALSE,
|
||||
reactive <- function(
|
||||
x,
|
||||
env = parent.frame(),
|
||||
quoted = FALSE,
|
||||
...,
|
||||
label = NULL,
|
||||
domain = getDefaultReactiveDomain(),
|
||||
..stacktraceon = TRUE)
|
||||
{
|
||||
..stacktraceon = TRUE
|
||||
) {
|
||||
check_dots_empty()
|
||||
|
||||
x <- get_quosure(x, env, quoted)
|
||||
fun <- as_function(x)
|
||||
# as_function returns a function that takes `...`. We need one that takes no
|
||||
# args.
|
||||
formals(fun) <- list()
|
||||
|
||||
func <- installExprFunction(x, "func", env, quoted, wrappedWithLabel = FALSE)
|
||||
# Attach a label and a reference to the original user source for debugging
|
||||
label <- exprToLabel(get_expr(x), "reactive", label)
|
||||
userExpr <- fn_body(func)
|
||||
label <- exprToLabel(userExpr, "reactive", label)
|
||||
|
||||
o <- Observable$new(fun, label, domain, ..stacktraceon = ..stacktraceon)
|
||||
o <- Observable$new(func, label, domain, ..stacktraceon = ..stacktraceon)
|
||||
structure(
|
||||
o$getValue,
|
||||
observable = o,
|
||||
cacheHint = list(userExpr = zap_srcref(get_expr(x))),
|
||||
cacheHint = list(userExpr = zap_srcref(userExpr)),
|
||||
class = c("reactiveExpr", "reactive", "function")
|
||||
)
|
||||
}
|
||||
@@ -1193,7 +1203,7 @@ Observer <- R6Class(
|
||||
# validation = function(e) NULL,
|
||||
# shiny.output.cancel = function(e) NULL
|
||||
|
||||
if (inherits(e, "shiny.silent.error")) {
|
||||
if (cnd_inherits(e, "shiny.silent.error")) {
|
||||
return()
|
||||
}
|
||||
|
||||
@@ -1325,12 +1335,7 @@ Observer <- R6Class(
|
||||
#'
|
||||
#' @param x An expression (quoted or unquoted). Any return value will be
|
||||
#' ignored.
|
||||
#' @param env The parent environment for the reactive expression. By default,
|
||||
#' this is the calling environment, the same as when defining an ordinary
|
||||
#' non-reactive expression.
|
||||
#' @param quoted Is the expression quoted? By default, this is `FALSE`.
|
||||
#' This is useful when you want to use an expression that is stored in a
|
||||
#' variable; to do so, it must be quoted with `quote()`.
|
||||
#' @inheritParams reactive
|
||||
#' @param label A label for the observer, useful for debugging.
|
||||
#' @param suspended If `TRUE`, start the observer in a suspended state. If
|
||||
#' `FALSE` (the default), start in a non-suspended state.
|
||||
@@ -1389,18 +1394,21 @@ Observer <- R6Class(
|
||||
#' print(values$A + 1)
|
||||
#' })
|
||||
#'
|
||||
#' # Can use quoted expressions
|
||||
#' obsC <- observe(quote({ print(values$A + 2) }), quoted = TRUE)
|
||||
#' # To store expressions for later conversion to observe, use rlang::quo()
|
||||
#' myquo <- rlang::quo({ print(values$A + 3) })
|
||||
#' obsC <- rlang::inject(observe(!!myquo))
|
||||
#'
|
||||
#' # To store expressions for later conversion to observe, use quote()
|
||||
#' expr_q <- quote({ print(values$A + 3) })
|
||||
#' obsD <- observe(expr_q, quoted = TRUE)
|
||||
#' # (Legacy) Can use quoted expressions
|
||||
#' obsD <- observe(quote({ print(values$A + 2) }), quoted = TRUE)
|
||||
#'
|
||||
#' # In a normal Shiny app, the web client will trigger flush events. If you
|
||||
#' # are at the console, you can force a flush with flushReact()
|
||||
#' shiny:::flushReact()
|
||||
#' @export
|
||||
observe <- function(x, env = parent.frame(), quoted = FALSE,
|
||||
observe <- function(
|
||||
x,
|
||||
env = parent.frame(),
|
||||
quoted = FALSE,
|
||||
...,
|
||||
label = NULL,
|
||||
suspended = FALSE,
|
||||
@@ -1411,18 +1419,11 @@ observe <- function(x, env = parent.frame(), quoted = FALSE,
|
||||
{
|
||||
check_dots_empty()
|
||||
|
||||
x <- get_quosure(x, env, quoted)
|
||||
fun <- as_function(x)
|
||||
# as_function returns a function that takes `...`. We need one that takes no
|
||||
# args.
|
||||
formals(fun) <- list()
|
||||
|
||||
if (is.null(label)) {
|
||||
label <- sprintf('observe(%s)', paste(deparse(get_expr(x)), collapse='\n'))
|
||||
}
|
||||
func <- installExprFunction(x, "func", env, quoted)
|
||||
label <- funcToLabel(func, "observe", label)
|
||||
|
||||
o <- Observer$new(
|
||||
fun,
|
||||
func,
|
||||
label = label,
|
||||
suspended = suspended,
|
||||
priority = priority,
|
||||
@@ -2144,23 +2145,30 @@ maskReactiveContext <- function(expr) {
|
||||
#' @param valueExpr The expression that produces the return value of the
|
||||
#' `eventReactive`. It will be executed within an [isolate()]
|
||||
#' scope.
|
||||
#' @param event.env The parent environment for `eventExpr`. By default,
|
||||
#' this is the calling environment.
|
||||
#' @param event.quoted Is the `eventExpr` expression quoted? By default,
|
||||
#' this is `FALSE`. This is useful when you want to use an expression
|
||||
#' that is stored in a variable; to do so, it must be quoted with
|
||||
#' `quote()`.
|
||||
#' @param handler.env The parent environment for `handlerExpr`. By default,
|
||||
#' this is the calling environment.
|
||||
#' @param handler.quoted Is the `handlerExpr` expression quoted? By
|
||||
#' default, this is `FALSE`. This is useful when you want to use an
|
||||
#' expression that is stored in a variable; to do so, it must be quoted with
|
||||
#' `quote()`.
|
||||
#' @param value.env The parent environment for `valueExpr`. By default,
|
||||
#' this is the calling environment.
|
||||
#' @param value.quoted Is the `valueExpr` expression quoted? By default,
|
||||
#' this is `FALSE`. This is useful when you want to use an expression
|
||||
#' that is stored in a variable; to do so, it must be quoted with `quote()`.
|
||||
#' @param event.env The parent environment for the reactive expression. By default,
|
||||
#' this is the calling environment, the same as when defining an ordinary
|
||||
#' non-reactive expression. If `eventExpr` is a quosure and `event.quoted` is `TRUE`,
|
||||
#' then `event.env` is ignored.
|
||||
#' @param event.quoted If it is `TRUE`, then the [`quote()`]ed value of `eventExpr`
|
||||
#' will be used when `eventExpr` is evaluated. If `eventExpr` is a quosure and you
|
||||
#' would like to use its expression as a value for `eventExpr`, then you must set
|
||||
#' `event.quoted` to `TRUE`.
|
||||
#' @param handler.env The parent environment for the reactive expression. By default,
|
||||
#' this is the calling environment, the same as when defining an ordinary
|
||||
#' non-reactive expression. If `handlerExpr` is a quosure and `handler.quoted` is `TRUE`,
|
||||
#' then `handler.env` is ignored.
|
||||
#' @param handler.quoted If it is `TRUE`, then the [`quote()`]ed value of `handlerExpr`
|
||||
#' will be used when `handlerExpr` is evaluated. If `handlerExpr` is a quosure and you
|
||||
#' would like to use its expression as a value for `handlerExpr`, then you must set
|
||||
#' `handler.quoted` to `TRUE`.
|
||||
#' @param value.env The parent environment for the reactive expression. By default,
|
||||
#' this is the calling environment, the same as when defining an ordinary
|
||||
#' non-reactive expression. If `valueExpr` is a quosure and `value.quoted` is `TRUE`,
|
||||
#' then `value.env` is ignored.
|
||||
#' @param value.quoted If it is `TRUE`, then the [`quote()`]ed value of `valueExpr`
|
||||
#' will be used when `valueExpr` is evaluated. If `valueExpr` is a quosure and you
|
||||
#' would like to use its expression as a value for `valueExpr`, then you must set
|
||||
#' `value.quoted` to `TRUE`.
|
||||
#' @param label A label for the observer or reactive, useful for debugging.
|
||||
#' @param suspended If `TRUE`, start the observer in a suspended state. If
|
||||
#' `FALSE` (the default), start in a non-suspended state.
|
||||
@@ -2274,15 +2282,13 @@ observeEvent <- function(eventExpr, handlerExpr,
|
||||
{
|
||||
check_dots_empty()
|
||||
|
||||
eventExpr <- get_quosure(eventExpr, event.env, event.quoted)
|
||||
handlerExpr <- get_quosure(handlerExpr, handler.env, handler.quoted)
|
||||
eventQ <- exprToQuo(eventExpr, event.env, event.quoted)
|
||||
handlerQ <- exprToQuo(handlerExpr, handler.env, handler.quoted)
|
||||
|
||||
if (is.null(label)) {
|
||||
label <- sprintf('observeEvent(%s)', paste(deparse(get_expr(eventExpr)), collapse='\n'))
|
||||
}
|
||||
label <- quoToLabel(eventQ, "observeEvent", label)
|
||||
|
||||
handler <- inject(observe(
|
||||
!!handlerExpr,
|
||||
!!handlerQ,
|
||||
label = label,
|
||||
suspended = suspended,
|
||||
priority = priority,
|
||||
@@ -2296,7 +2302,7 @@ observeEvent <- function(eventExpr, handlerExpr,
|
||||
ignoreInit = ignoreInit,
|
||||
once = once,
|
||||
label = label,
|
||||
!!eventExpr,
|
||||
!!eventQ,
|
||||
x = handler
|
||||
))
|
||||
|
||||
@@ -2314,19 +2320,17 @@ eventReactive <- function(eventExpr, valueExpr,
|
||||
{
|
||||
check_dots_empty()
|
||||
|
||||
eventExpr <- get_quosure(eventExpr, event.env, event.quoted)
|
||||
valueExpr <- get_quosure(valueExpr, value.env, value.quoted)
|
||||
eventQ <- exprToQuo(eventExpr, event.env, event.quoted)
|
||||
valueQ <- exprToQuo(valueExpr, value.env, value.quoted)
|
||||
|
||||
if (is.null(label)) {
|
||||
label <- sprintf('eventReactive(%s)', paste(deparse(get_expr(eventExpr)), collapse='\n'))
|
||||
}
|
||||
label <- quoToLabel(eventQ, "eventReactive", label)
|
||||
|
||||
invisible(inject(bindEvent(
|
||||
ignoreNULL = ignoreNULL,
|
||||
ignoreInit = ignoreInit,
|
||||
label = label,
|
||||
!!eventExpr,
|
||||
x = reactive(!!valueExpr, domain = domain, label = label)
|
||||
!!eventQ,
|
||||
x = reactive(!!valueQ, domain = domain, label = label)
|
||||
)))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
####
|
||||
# Generated by `./tools/updateReexports.R`: do not edit by hand
|
||||
# Please call `source('tools/updateReexports.R') from the root folder to update`
|
||||
# Generated by `./tools/documentation/updateReexports.R`: do not edit by hand
|
||||
# Please call `source('tools/documentation/updateReexports.R')` from the root folder to update`
|
||||
####
|
||||
|
||||
|
||||
@@ -90,17 +90,20 @@ htmltools::em
|
||||
#' @export
|
||||
htmltools::hr
|
||||
|
||||
|
||||
# htmltools tag.Rd -------------------------------------------------------------
|
||||
|
||||
#' @importFrom htmltools tag
|
||||
#' @export
|
||||
htmltools::tag
|
||||
|
||||
|
||||
# htmltools tagList.Rd ---------------------------------------------------------
|
||||
|
||||
#' @importFrom htmltools tagList
|
||||
#' @export
|
||||
htmltools::tagList
|
||||
|
||||
|
||||
# htmltools tagAppendAttributes.Rd ---------------------------------------------
|
||||
|
||||
#' @importFrom htmltools tagAppendAttributes
|
||||
#' @export
|
||||
htmltools::tagAppendAttributes
|
||||
@@ -113,6 +116,9 @@ htmltools::tagHasAttribute
|
||||
#' @export
|
||||
htmltools::tagGetAttribute
|
||||
|
||||
|
||||
# htmltools tagAppendChild.Rd --------------------------------------------------
|
||||
|
||||
#' @importFrom htmltools tagAppendChild
|
||||
#' @export
|
||||
htmltools::tagAppendChild
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
#' # At the top of app.R, this set the application-scoped cache to be a disk
|
||||
#' # cache that can be shared among multiple concurrent R processes, and is
|
||||
#' # deleted when the system reboots.
|
||||
#' shinyOptions(cache = cachem::cache_disk(file.path(dirname(tempdir()), "myapp-cache"))
|
||||
#' shinyOptions(cache = cachem::cache_disk(file.path(dirname(tempdir()), "myapp-cache")))
|
||||
#'
|
||||
#' # At the top of app.R, this set the application-scoped cache to be a disk
|
||||
#' # cache that can be shared among multiple concurrent R processes, and
|
||||
|
||||
@@ -46,9 +46,7 @@
|
||||
#' decorative images.
|
||||
#' @param ... Arguments to be passed through to [grDevices::png()].
|
||||
#' These can be used to set the width, height, background color, etc.
|
||||
#' @param env The environment in which to evaluate `expr`.
|
||||
#' @param quoted Is `expr` a quoted expression (with `quote()`)? This
|
||||
#' is useful if you want to save an expression in a variable.
|
||||
#' @inheritParams renderUI
|
||||
#' @param execOnResize If `FALSE` (the default), then when a plot is
|
||||
#' resized, Shiny will *replay* the plot drawing commands with
|
||||
#' [grDevices::replayPlot()] instead of re-executing `expr`.
|
||||
@@ -65,10 +63,13 @@ renderPlot <- function(expr, width = 'auto', height = 'auto', res = 72, ...,
|
||||
execOnResize = FALSE, outputArgs = list()
|
||||
) {
|
||||
|
||||
expr <- get_quosure(expr, env, quoted)
|
||||
# This ..stacktraceon is matched by a ..stacktraceoff.. when plotFunc
|
||||
# is called
|
||||
func <- quoToFunction(expr, "renderPlot", ..stacktraceon = TRUE)
|
||||
func <- installExprFunction(
|
||||
expr, "func", env, quoted,
|
||||
label = "renderPlot",
|
||||
# This ..stacktraceon is matched by a ..stacktraceoff.. when plotFunc
|
||||
# is called
|
||||
..stacktraceon = TRUE
|
||||
)
|
||||
|
||||
args <- list(...)
|
||||
|
||||
@@ -186,7 +187,7 @@ renderPlot <- function(expr, width = 'auto', height = 'auto', res = 72, ...,
|
||||
outputFunc,
|
||||
renderFunc,
|
||||
outputArgs,
|
||||
cacheHint = list(userExpr = get_expr(expr), res = res)
|
||||
cacheHint = list(userExpr = installedFuncExpr(func), res = res)
|
||||
)
|
||||
class(markedFunc) <- c("shiny.renderPlot", class(markedFunc))
|
||||
markedFunc
|
||||
@@ -611,7 +612,7 @@ getGgplotCoordmap <- function(p, width, height, res) {
|
||||
find_panel_info <- function(b) {
|
||||
# Structure of ggplot objects changed after 2.1.0. After 2.2.1, there was a
|
||||
# an API for extracting the necessary information.
|
||||
ggplot_ver <- utils::packageVersion("ggplot2")
|
||||
ggplot_ver <- get_package_version("ggplot2")
|
||||
|
||||
if (ggplot_ver > "2.2.1") {
|
||||
find_panel_info_api(b)
|
||||
|
||||
@@ -42,9 +42,7 @@
|
||||
#' (i.e. they either evaluate to `NA` or `NaN`).
|
||||
#' @param ... Arguments to be passed through to [xtable::xtable()]
|
||||
#' and [xtable::print.xtable()].
|
||||
#' @param env The environment in which to evaluate `expr`.
|
||||
#' @param quoted Is `expr` a quoted expression (with `quote()`)?
|
||||
#' This is useful if you want to save an expression in a variable.
|
||||
#' @inheritParams renderUI
|
||||
#' @param outputArgs A list of arguments to be passed through to the
|
||||
#' implicit call to [tableOutput()] when `renderTable` is
|
||||
#' used in an interactive R Markdown document.
|
||||
@@ -74,8 +72,7 @@ renderTable <- function(expr, striped = FALSE, hover = FALSE,
|
||||
env = parent.frame(), quoted = FALSE,
|
||||
outputArgs=list())
|
||||
{
|
||||
expr <- get_quosure(expr, env, quoted)
|
||||
func <- quoToFunction(expr, "renderTable")
|
||||
func <- installExprFunction(expr, "func", env, quoted, label = "renderTable")
|
||||
|
||||
if (!is.function(spacing)) spacing <- match.arg(spacing)
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
#' @examples
|
||||
#' ## Only run this example in interactive R sessions
|
||||
#' if (interactive()) {
|
||||
#' runUrl('https://github.com/rstudio/shiny_example/archive/master.tar.gz')
|
||||
#' runUrl('https://github.com/rstudio/shiny_example/archive/main.tar.gz')
|
||||
#'
|
||||
#' # Can run an app from a subdirectory in the archive
|
||||
#' runUrl("https://github.com/rstudio/shiny_example/archive/master.zip",
|
||||
#' runUrl("https://github.com/rstudio/shiny_example/archive/main.zip",
|
||||
#' subdir = "inst/shinyapp/")
|
||||
#' }
|
||||
runUrl <- function(url, filetype = NULL, subdir = NULL, destdir = NULL, ...) {
|
||||
|
||||
@@ -467,7 +467,7 @@ runExample <- function(example=NA,
|
||||
launch.browser = getOption('shiny.launch.browser', interactive()),
|
||||
host=getOption('shiny.host', '127.0.0.1'),
|
||||
display.mode=c("auto", "normal", "showcase")) {
|
||||
examplesDir <- system.file('examples', package='shiny')
|
||||
examplesDir <- system_file('examples', package='shiny')
|
||||
dir <- resolve(examplesDir, example)
|
||||
if (is.null(dir)) {
|
||||
if (is.na(example)) {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#' value. The returned value will be used for the test snapshot.
|
||||
#' @param session A Shiny session object.
|
||||
#'
|
||||
#' @keywords internal
|
||||
#' @export
|
||||
setSerializer <- function(inputId, fun, session = getDefaultReactiveDomain()) {
|
||||
if (is.null(session)) {
|
||||
|
||||
@@ -41,12 +41,12 @@ inputHandlers <- Map$new()
|
||||
#' })
|
||||
#'
|
||||
#' ## On the Javascript side, the associated input binding must have a corresponding getType method:
|
||||
#' getType: function(el) {
|
||||
#' return "mypackage.validint";
|
||||
#' }
|
||||
#' # getType: function(el) {
|
||||
#' # return "mypackage.validint";
|
||||
#' # }
|
||||
#'
|
||||
#' }
|
||||
#' @seealso [removeInputHandler()]
|
||||
#' @seealso [removeInputHandler()] [applyInputHandlers()]
|
||||
#' @export
|
||||
registerInputHandler <- function(type, fun, force=FALSE){
|
||||
if (inputHandlers$containsKey(type) && !force){
|
||||
@@ -181,7 +181,7 @@ registerInputHandler("shiny.datetime", function(val, ...){
|
||||
|
||||
registerInputHandler("shiny.action", function(val, shinysession, name) {
|
||||
# mark up the action button value with a special class so we can recognize it later
|
||||
class(val) <- c(class(val), "shinyActionButtonValue")
|
||||
class(val) <- c("shinyActionButtonValue", class(val))
|
||||
val
|
||||
})
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ createAppHandlers <- function(httpHandlers, serverFuncSource) {
|
||||
appvars <- new.env()
|
||||
appvars$server <- NULL
|
||||
|
||||
sys.www.root <- system.file('www', package='shiny')
|
||||
sys.www.root <- system_file('www', package='shiny')
|
||||
|
||||
# This value, if non-NULL, must be present on all HTTP and WebSocket
|
||||
# requests as the Shiny-Shared-Secret header or else access will be
|
||||
@@ -385,7 +385,7 @@ startApp <- function(appObj, port, host, quiet) {
|
||||
list(
|
||||
# Always handle /session URLs dynamically, even if / is a static path.
|
||||
"session" = excludeStaticPath(),
|
||||
"shared" = system.file(package = "shiny", "www", "shared")
|
||||
"shared" = system_file(package = "shiny", "www", "shared")
|
||||
),
|
||||
.globals$resourcePaths
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## usethis namespace: start
|
||||
## usethis namespace: end
|
||||
#' @importFrom lifecycle deprecated
|
||||
#' @importFrom lifecycle deprecated is_present
|
||||
#' @importFrom grDevices dev.set dev.cur
|
||||
#' @importFrom fastmap fastmap
|
||||
#' @importFrom promises %...!%
|
||||
@@ -11,11 +11,13 @@
|
||||
#' promise promise_resolve promise_reject is.promising
|
||||
#' as.promise
|
||||
#' @importFrom rlang
|
||||
#' quo enquo as_function get_expr get_env new_function enquos
|
||||
#' quo enquo enquo0 as_function get_expr get_env new_function enquos
|
||||
#' eval_tidy expr pairlist2 new_quosure enexpr as_quosure is_quosure inject
|
||||
#' quo_set_env quo_set_expr quo_get_expr
|
||||
#' enquos0 zap_srcref %||% is_na
|
||||
#' is_false list2
|
||||
#' missing_arg is_missing maybe_missing
|
||||
#' quo_is_missing fn_fmls<- fn_body fn_body<-
|
||||
#' @importFrom ellipsis
|
||||
#' check_dots_empty check_dots_unnamed
|
||||
#' @import htmltools
|
||||
|
||||
15
R/shiny.R
15
R/shiny.R
@@ -403,7 +403,7 @@ ShinySession <- R6Class(
|
||||
sendMessage = function(...) {
|
||||
# This function is a wrapper for $write
|
||||
msg <- list(...)
|
||||
if (anyUnnamed(msg)) {
|
||||
if (any_unnamed(msg)) {
|
||||
stop("All arguments to sendMessage must be named.")
|
||||
}
|
||||
private$write(toJSON(msg))
|
||||
@@ -825,7 +825,7 @@ ShinySession <- R6Class(
|
||||
dots <- eval(substitute(alist(...)))
|
||||
}
|
||||
|
||||
if (anyUnnamed(dots))
|
||||
if (any_unnamed(dots))
|
||||
stop("exportTestValues: all arguments must be named.")
|
||||
|
||||
names(dots) <- ns(names(dots))
|
||||
@@ -913,7 +913,7 @@ ShinySession <- R6Class(
|
||||
|
||||
# Copy `values` from scopeState to state, adding namespace
|
||||
if (length(scopeState$values) != 0) {
|
||||
if (anyUnnamed(scopeState$values)) {
|
||||
if (any_unnamed(scopeState$values)) {
|
||||
stop("All scope values in must be named.")
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,12 @@ ShinySession <- R6Class(
|
||||
structure(list(), class = "try-error", condition = cond)
|
||||
} else if (inherits(cond, "shiny.output.cancel")) {
|
||||
structure(list(), class = "cancel-output")
|
||||
} else if (inherits(cond, "shiny.silent.error")) {
|
||||
} else if (cnd_inherits(cond, "shiny.silent.error")) {
|
||||
# The error condition might have been chained by
|
||||
# foreign code, e.g. dplyr. Find the original error.
|
||||
while (!inherits(cond, "shiny.silent.error")) {
|
||||
cond <- cond$parent
|
||||
}
|
||||
# Don't let shiny.silent.error go through the normal stop
|
||||
# path of try, because we don't want it to print. But we
|
||||
# do want to try to return the same looking result so that
|
||||
@@ -1701,7 +1706,7 @@ ShinySession <- R6Class(
|
||||
dots <- eval(substitute(alist(...)))
|
||||
}
|
||||
|
||||
if (anyUnnamed(dots))
|
||||
if (any_unnamed(dots))
|
||||
stop("exportTestValues: all arguments must be named.")
|
||||
|
||||
# Create a named list where each item is a list with an expression and
|
||||
|
||||
@@ -193,7 +193,7 @@ shinyAppDir_serverR <- function(appDir, options=list()) {
|
||||
staticPaths <- list()
|
||||
}
|
||||
|
||||
fallbackWWWDir <- system.file("www-dir", package = "shiny")
|
||||
fallbackWWWDir <- system_file("www-dir", package = "shiny")
|
||||
|
||||
serverSource <- cachedFuncWithFile(appDir, "server.R", case.sensitive = FALSE,
|
||||
function(serverR) {
|
||||
@@ -455,7 +455,7 @@ shinyAppDir_appR <- function(fileName, appDir, options=list())
|
||||
staticPaths <- list()
|
||||
}
|
||||
|
||||
fallbackWWWDir <- system.file("www-dir", package = "shiny")
|
||||
fallbackWWWDir <- system_file("www-dir", package = "shiny")
|
||||
|
||||
oldwd <- NULL
|
||||
monitorHandle <- NULL
|
||||
|
||||
46
R/shinyui.R
46
R/shinyui.R
@@ -39,7 +39,7 @@ renderPage <- function(ui, showcase=0, testMode=FALSE) {
|
||||
|
||||
# Put the body into the default template
|
||||
ui <- htmlTemplate(
|
||||
system.file("template", "default.html", package = "shiny"),
|
||||
system_file("template", "default.html", package = "shiny"),
|
||||
lang = lang,
|
||||
body = ui,
|
||||
# this template is a complete HTML document
|
||||
@@ -55,8 +55,14 @@ renderPage <- function(ui, showcase=0, testMode=FALSE) {
|
||||
if (testMode) {
|
||||
# Add code injection listener if in test mode
|
||||
shiny_deps[[length(shiny_deps) + 1]] <-
|
||||
htmlDependency("shiny-testmode", shinyPackageVersion(),
|
||||
c(href="shared"), script = "shiny-testmode.js")
|
||||
htmlDependency(
|
||||
"shiny-testmode",
|
||||
get_package_version("shiny"),
|
||||
src = "www/shared",
|
||||
package = "shiny",
|
||||
script = "shiny-testmode.js",
|
||||
all_files = FALSE
|
||||
)
|
||||
}
|
||||
|
||||
html <- renderDocument(ui, shiny_deps, processDep = createWebDependency)
|
||||
@@ -68,23 +74,19 @@ jqueryDependency <- function() {
|
||||
if (version == 3) {
|
||||
return(htmlDependency(
|
||||
"jquery", version_jquery,
|
||||
src = c(
|
||||
href = "shared",
|
||||
file = "www/shared"
|
||||
),
|
||||
src = "www/shared",
|
||||
package = "shiny",
|
||||
script = "jquery.min.js"
|
||||
script = "jquery.min.js",
|
||||
all_files = FALSE
|
||||
))
|
||||
}
|
||||
if (version == 1) {
|
||||
return(htmlDependency(
|
||||
"jquery", "1.12.4",
|
||||
src = c(
|
||||
href = "shared/legacy",
|
||||
file = "www/shared/legacy"
|
||||
),
|
||||
src = "www/shared/legacy",
|
||||
package = "shiny",
|
||||
script = "jquery.min.js"
|
||||
script = "jquery.min.js",
|
||||
all_files = FALSE
|
||||
))
|
||||
}
|
||||
stop("Unsupported version of jQuery: ", version)
|
||||
@@ -95,8 +97,9 @@ shinyDependencies <- function() {
|
||||
bslib::bs_dependency_defer(shinyDependencyCSS),
|
||||
htmlDependency(
|
||||
name = "shiny-javascript",
|
||||
version = shinyPackageVersion(),
|
||||
src = c(href = "shared"),
|
||||
version = get_package_version("shiny"),
|
||||
src = "www/shared",
|
||||
package = "shiny",
|
||||
script =
|
||||
if (isTRUE(
|
||||
get_devmode_option(
|
||||
@@ -106,24 +109,27 @@ shinyDependencies <- function() {
|
||||
))
|
||||
"shiny.min.js"
|
||||
else
|
||||
"shiny.js"
|
||||
"shiny.js",
|
||||
all_files = FALSE
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
shinyDependencyCSS <- function(theme) {
|
||||
version <- shinyPackageVersion()
|
||||
version <- get_package_version("shiny")
|
||||
|
||||
if (!is_bs_theme(theme)) {
|
||||
return(htmlDependency(
|
||||
name = "shiny-css",
|
||||
version = version,
|
||||
src = c(href = "shared"),
|
||||
stylesheet = "shiny.min.css"
|
||||
src = "www/shared",
|
||||
package = "shiny",
|
||||
stylesheet = "shiny.min.css",
|
||||
all_files = FALSE
|
||||
))
|
||||
}
|
||||
|
||||
scss_home <- system.file("www/shared/shiny_scss", package = "shiny")
|
||||
scss_home <- system_file("www/shared/shiny_scss", package = "shiny")
|
||||
scss_files <- file.path(scss_home, c("bootstrap.scss", "shiny.scss"))
|
||||
scss_files <- lapply(scss_files, sass::sass_file)
|
||||
|
||||
|
||||
@@ -2,12 +2,23 @@ utils::globalVariables('func', add = TRUE)
|
||||
|
||||
#' Mark a function as a render function
|
||||
#'
|
||||
#' `r lifecycle::badge("superseded")` Please use [`createRenderFunction()`] to
|
||||
#' support async execution. (Shiny 1.1.0)
|
||||
#'
|
||||
#' Should be called by implementers of `renderXXX` functions in order to mark
|
||||
#' their return values as Shiny render functions, and to provide a hint to Shiny
|
||||
#' regarding what UI function is most commonly used with this type of render
|
||||
#' function. This can be used in R Markdown documents to create complete output
|
||||
#' widgets out of just the render function.
|
||||
#'
|
||||
#' Note that it is generally preferable to use [createRenderFunction()] instead
|
||||
#' of `markRenderFunction()`. It essentially wraps up the user-provided
|
||||
#' expression in the `transform` function passed to it, then passes the resulting
|
||||
#' function to `markRenderFunction()`. It also provides a simpler calling
|
||||
#' interface. There may be cases where `markRenderFunction()` must be used instead of
|
||||
#' [createRenderFunction()] -- for example, when the `transform` parameter of
|
||||
#' [createRenderFunction()] is not flexible enough for your needs.
|
||||
#'
|
||||
#' @param uiFunc A function that renders Shiny UI. Must take a single argument:
|
||||
#' an output ID.
|
||||
#' @param renderFunc A function that is suitable for assigning to a Shiny output
|
||||
@@ -37,7 +48,7 @@ utils::globalVariables('func', add = TRUE)
|
||||
#' is able to serve JS and CSS resources.
|
||||
#' @return The `renderFunc` function, with annotations.
|
||||
#'
|
||||
#' @seealso [createRenderFunction()], [quoToFunction()]
|
||||
#' @seealso [createRenderFunction()]
|
||||
#' @export
|
||||
markRenderFunction <- function(
|
||||
uiFunc,
|
||||
@@ -47,6 +58,12 @@ markRenderFunction <- function(
|
||||
cacheWriteHook = NULL,
|
||||
cacheReadHook = NULL
|
||||
) {
|
||||
# (Do not emit warning for superseded code, "since there’s no risk if you keep using it")
|
||||
# # This method is called by the superseding function, createRenderFunction().
|
||||
# if (in_devmode()) {
|
||||
# shinyDeprecated("1.1.0", "markRenderFunction()", "createRenderFunction()")
|
||||
# }
|
||||
|
||||
force(renderFunc)
|
||||
|
||||
# a mutable object that keeps track of whether `useRenderFunction` has been
|
||||
@@ -94,6 +111,7 @@ markRenderFunction <- function(
|
||||
# For everything else, do nothing.
|
||||
cacheHint <- lapply(cacheHint, function(x) {
|
||||
if (is.function(x)) formalsAndBody(x)
|
||||
else if (is_quosure(x)) zap_srcref(quo_get_expr(x))
|
||||
else if (is.language(x)) zap_srcref(x)
|
||||
else x
|
||||
})
|
||||
@@ -133,10 +151,27 @@ print.shiny.render.function <- function(x, ...) {
|
||||
cat_line("<shiny.render.function>")
|
||||
}
|
||||
|
||||
#' Implement render functions
|
||||
#' Implement custom render functions
|
||||
#'
|
||||
#' This function is a wrapper for [markRenderFunction()] which provides support
|
||||
#' for async computation via promises.
|
||||
#' Developer-facing utilities for implementing a custom `renderXXX()` function.
|
||||
#' Before using these utilities directly, consider using the [`htmlwidgets`
|
||||
#' package](http://www.htmlwidgets.org/develop_intro.html) to implement custom
|
||||
#' outputs (i.e., custom `renderXXX()`/`xxxOutput()` functions). That said,
|
||||
#' these utilities can be used more directly if a full-blown htmlwidget isn't
|
||||
#' needed and/or the user-supplied reactive expression needs to be wrapped in
|
||||
#' additional call(s).
|
||||
#'
|
||||
#' To implement a custom `renderXXX()` function, essentially 2 things are needed:
|
||||
#' 1. Capture the user's reactive expression as a function.
|
||||
#' * New `renderXXX()` functions can use `quoToFunction()` for this, but
|
||||
#' already existing `renderXXX()` functions that contain `env` and `quoted`
|
||||
#' parameters may want to continue using `installExprFunction()` for better
|
||||
#' legacy support (see examples).
|
||||
#' 2. Flag the resulting function (from 1) as a Shiny rendering function and
|
||||
#' also provide a UI container for displaying the result of the rendering
|
||||
#' function.
|
||||
#' * `createRenderFunction()` is currently recommended (instead of
|
||||
#' [markRenderFunction()]) for this step (see examples).
|
||||
#'
|
||||
#' @param func A function without parameters, that returns user data. If the
|
||||
#' returned value is a promise, then the render function will proceed in async
|
||||
@@ -153,16 +188,24 @@ print.shiny.render.function <- function(x, ...) {
|
||||
#' @return An annotated render function, ready to be assigned to an
|
||||
#' `output` slot.
|
||||
#'
|
||||
#' @seealso [quoToFunction()], [markRenderFunction()].
|
||||
#'
|
||||
#' @examples
|
||||
#' # A very simple render function
|
||||
#' renderTriple <- function(x) {
|
||||
#' x <- substitute(x)
|
||||
#' if (!rlang::is_quosure(x)) {
|
||||
#' x <- rlang::new_quosure(x, env = parent.frame())
|
||||
#' }
|
||||
#' func <- quoToFunction(x, "renderTriple")
|
||||
#' # A custom render function that repeats the supplied value 3 times
|
||||
#' renderTriple <- function(expr) {
|
||||
#' # Wrap user-supplied reactive expression into a function
|
||||
#' func <- quoToFunction(rlang::enquo0(expr))
|
||||
#'
|
||||
#' createRenderFunction(
|
||||
#' func,
|
||||
#' transform = function(value, session, name, ...) {
|
||||
#' paste(rep(value, 3), collapse=", ")
|
||||
#' },
|
||||
#' outputFunc = textOutput
|
||||
#' )
|
||||
#' }
|
||||
#'
|
||||
#' # For better legacy support, consider using installExprFunction() over quoToFunction()
|
||||
#' renderTripleLegacy <- function(expr, env = parent.frame(), quoted = FALSE) {
|
||||
#' func <- installExprFunction(expr, "func", env, quoted)
|
||||
#'
|
||||
#' createRenderFunction(
|
||||
#' func,
|
||||
@@ -174,10 +217,38 @@ print.shiny.render.function <- function(x, ...) {
|
||||
#' }
|
||||
#'
|
||||
#' # Test render function from the console
|
||||
#' a <- 1
|
||||
#' r <- renderTriple({ a + 1 })
|
||||
#' a <- 2
|
||||
#' reactiveConsole(TRUE)
|
||||
#'
|
||||
#' v <- reactiveVal("basic")
|
||||
#' r <- renderTriple({ v() })
|
||||
#' r()
|
||||
#' #> [1] "basic, basic, basic"
|
||||
#'
|
||||
#' # User can supply quoted code via rlang::quo(). Note that evaluation of the
|
||||
#' # expression happens when r2() is invoked, not when r2 is created.
|
||||
#' q <- rlang::quo({ v() })
|
||||
#' r2 <- rlang::inject(renderTriple(!!q))
|
||||
#' v("rlang")
|
||||
#' r2()
|
||||
#' #> [1] "rlang, rlang, rlang"
|
||||
#'
|
||||
#' # Supplying quoted code without rlang::quo() requires installExprFunction()
|
||||
#' expr <- quote({ v() })
|
||||
#' r3 <- renderTripleLegacy(expr, quoted = TRUE)
|
||||
#' v("legacy")
|
||||
#' r3()
|
||||
#' #> [1] "legacy, legacy, legacy"
|
||||
#'
|
||||
#' # The legacy approach also supports with quosures (env is ignored in this case)
|
||||
#' q <- rlang::quo({ v() })
|
||||
#' r4 <- renderTripleLegacy(q, quoted = TRUE)
|
||||
#' v("legacy-rlang")
|
||||
#' r4()
|
||||
#' #> [1] "legacy-rlang, legacy-rlang, legacy-rlang"
|
||||
#'
|
||||
#' # Turn off reactivity in the console
|
||||
#' reactiveConsole(FALSE)
|
||||
#'
|
||||
#' @export
|
||||
createRenderFunction <- function(
|
||||
func,
|
||||
@@ -316,9 +387,7 @@ markOutputAttrs <- function(renderFunc, snapshotExclude = NULL,
|
||||
#' the output, see [plotPNG()].
|
||||
#'
|
||||
#' @param expr An expression that returns a list.
|
||||
#' @param env The environment in which to evaluate `expr`.
|
||||
#' @param quoted Is `expr` a quoted expression (with `quote()`)? This
|
||||
#' is useful if you want to save an expression in a variable.
|
||||
#' @inheritParams renderUI
|
||||
#' @param deleteFile Should the file in `func()$src` be deleted after
|
||||
#' it is sent to the client browser? Generally speaking, if the image is a
|
||||
#' temp file generated within `func`, then this should be `TRUE`;
|
||||
@@ -397,11 +466,10 @@ markOutputAttrs <- function(renderFunc, snapshotExclude = NULL,
|
||||
#'
|
||||
#' shinyApp(ui, server)
|
||||
#' }
|
||||
renderImage <- function(expr, env=parent.frame(), quoted=FALSE,
|
||||
renderImage <- function(expr, env = parent.frame(), quoted = FALSE,
|
||||
deleteFile, outputArgs=list())
|
||||
{
|
||||
expr <- get_quosure(expr, env, quoted)
|
||||
func <- quoToFunction(expr, "renderImage")
|
||||
func <- installExprFunction(expr, "func", env, quoted, label = "renderImage")
|
||||
|
||||
# missing() must be used directly within the function with the given arg
|
||||
if (missing(deleteFile)) {
|
||||
@@ -523,9 +591,7 @@ isTemp <- function(path, tempDir = tempdir(), mustExist) {
|
||||
#' function return [invisible()].
|
||||
#'
|
||||
#' @param expr An expression to evaluate.
|
||||
#' @param env The environment in which to evaluate `expr`. For expert use only.
|
||||
#' @param quoted Is `expr` a quoted expression (with `quote()`)? This
|
||||
#' is useful if you want to save an expression in a variable.
|
||||
#' @inheritParams renderUI
|
||||
#' @param width Width of printed output.
|
||||
#' @param outputArgs A list of arguments to be passed through to the implicit
|
||||
#' call to [verbatimTextOutput()] or [textOutput()] when the functions are
|
||||
@@ -536,8 +602,7 @@ isTemp <- function(path, tempDir = tempdir(), mustExist) {
|
||||
renderPrint <- function(expr, env = parent.frame(), quoted = FALSE,
|
||||
width = getOption('width'), outputArgs=list())
|
||||
{
|
||||
expr <- get_quosure(expr, env, quoted)
|
||||
func <- quoToFunction(expr, "renderPrint")
|
||||
func <- installExprFunction(expr, "func", env, quoted, label = "renderPrint")
|
||||
|
||||
# Set a promise domain that sets the console width
|
||||
# and captures output
|
||||
@@ -569,7 +634,7 @@ renderPrint <- function(expr, env = parent.frame(), quoted = FALSE,
|
||||
outputArgs,
|
||||
cacheHint = list(
|
||||
label = "renderPrint",
|
||||
origUserExpr = get_expr(expr)
|
||||
origUserExpr = installedFuncExpr(func)
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -619,11 +684,10 @@ createRenderPrintPromiseDomain <- function(width) {
|
||||
#' element.
|
||||
#' @export
|
||||
#' @rdname renderPrint
|
||||
renderText <- function(expr, env=parent.frame(), quoted=FALSE,
|
||||
renderText <- function(expr, env = parent.frame(), quoted = FALSE,
|
||||
outputArgs=list(), sep=" ") {
|
||||
|
||||
expr <- get_quosure(expr, env, quoted)
|
||||
func <- quoToFunction(expr, "renderText")
|
||||
func <- installExprFunction(expr, "func", env, quoted, label = "renderText")
|
||||
|
||||
createRenderFunction(
|
||||
func,
|
||||
@@ -644,9 +708,13 @@ renderText <- function(expr, env=parent.frame(), quoted=FALSE,
|
||||
#'
|
||||
#' @param expr An expression that returns a Shiny tag object, [HTML()],
|
||||
#' or a list of such objects.
|
||||
#' @param env The environment in which to evaluate `expr`.
|
||||
#' @param quoted Is `expr` a quoted expression (with `quote()`)? This
|
||||
#' is useful if you want to save an expression in a variable.
|
||||
#' @template param-env
|
||||
#' @templateVar x expr
|
||||
#' @templateVar env env
|
||||
#' @templateVar quoted quoted
|
||||
#' @template param-quoted
|
||||
#' @templateVar x expr
|
||||
#' @templateVar quoted quoted
|
||||
#' @param outputArgs A list of arguments to be passed through to the implicit
|
||||
#' call to [uiOutput()] when `renderUI` is used in an
|
||||
#' interactive R Markdown document.
|
||||
@@ -675,8 +743,7 @@ renderText <- function(expr, env=parent.frame(), quoted=FALSE,
|
||||
renderUI <- function(expr, env = parent.frame(), quoted = FALSE,
|
||||
outputArgs = list())
|
||||
{
|
||||
expr <- get_quosure(expr, env, quoted)
|
||||
func <- quoToFunction(expr, "renderUI")
|
||||
func <- installExprFunction(expr, "func", env, quoted, label = "renderUI")
|
||||
|
||||
createRenderFunction(
|
||||
func,
|
||||
@@ -755,6 +822,10 @@ downloadHandler <- function(filename, content, contentType=NA, outputArgs=list()
|
||||
#' Table output with the JavaScript DataTables library
|
||||
#'
|
||||
#' @description
|
||||
#' `r lifecycle::badge("superseded")` Please use
|
||||
#' \href{https://rstudio.github.io/DT/shiny.html}{\code{DT::renderDataTable()}}.
|
||||
#' (Shiny 0.11.1)
|
||||
#'
|
||||
#' Makes a reactive version of the given function that returns a data frame (or
|
||||
#' matrix), which will be rendered with the [DataTables](https://datatables.net)
|
||||
#' library. Paging, searching, filtering, and sorting can be done on the R side
|
||||
@@ -829,8 +900,7 @@ renderDataTable <- function(expr, options = NULL, searchDelay = 500,
|
||||
)
|
||||
}
|
||||
|
||||
expr <- get_quosure(expr, env, quoted)
|
||||
func <- quoToFunction(expr, "renderDataTable")
|
||||
func <- installExprFunction(expr, "func", env, quoted, label = "renderDataTable")
|
||||
|
||||
renderFunc <- function(shinysession, name, ...) {
|
||||
if (is.function(options)) options <- options()
|
||||
@@ -883,7 +953,7 @@ renderDataTable <- function(expr, options = NULL, searchDelay = 500,
|
||||
DT10Names <- function() {
|
||||
rbind(
|
||||
utils::read.table(
|
||||
system.file('www/shared/datatables/upgrade1.10.txt', package = 'shiny'),
|
||||
system_file('www/shared/datatables/upgrade1.10.txt', package = 'shiny'),
|
||||
stringsAsFactors = FALSE
|
||||
),
|
||||
c('aoColumns', 'Removed') # looks like an omission on the upgrade guide
|
||||
|
||||
42
R/showcase.R
42
R/showcase.R
@@ -32,26 +32,40 @@ licenseLink <- function(licenseName) {
|
||||
showcaseHead <- function() {
|
||||
|
||||
deps <- list(
|
||||
htmlDependency("jqueryui", "1.12.1", c(href="shared/jqueryui"),
|
||||
script = "jquery-ui.min.js"),
|
||||
htmlDependency("showdown", "0.3.1", c(href="shared/showdown/compressed"),
|
||||
script = "showdown.js"),
|
||||
htmlDependency("highlight.js", "6.2", c(href="shared/highlight"),
|
||||
script = "highlight.pack.js")
|
||||
jqueryuiDependency(),
|
||||
htmlDependency(
|
||||
"showdown",
|
||||
"0.3.1",
|
||||
src = "www/shared/showdown/compressed",
|
||||
package="shiny",
|
||||
script = "showdown.js"
|
||||
),
|
||||
htmlDependency(
|
||||
"highlight.js",
|
||||
"6.2",
|
||||
src = "www/shared/highlight",
|
||||
package="shiny",
|
||||
script = "highlight.pack.js",
|
||||
stylesheet = "rstudio.css"
|
||||
),
|
||||
htmlDependency(
|
||||
"showcase",
|
||||
"0.1.0",
|
||||
src = "www/shared",
|
||||
package = "shiny",
|
||||
script = "shiny-showcase.js",
|
||||
stylesheet = "shiny-showcase.css",
|
||||
all_files = FALSE
|
||||
)
|
||||
)
|
||||
|
||||
mdfile <- file.path.ci(getwd(), 'Readme.md')
|
||||
html <- with(tags, tagList(
|
||||
script(src="shared/shiny-showcase.js"),
|
||||
link(rel="stylesheet", type="text/css",
|
||||
href="shared/highlight/rstudio.css"),
|
||||
link(rel="stylesheet", type="text/css",
|
||||
href="shared/shiny-showcase.css"),
|
||||
html <- tagList(
|
||||
if (file.exists(mdfile))
|
||||
script(type="text/markdown", id="showcase-markdown-content",
|
||||
tags$script(type="text/markdown", id="showcase-markdown-content",
|
||||
paste(readUTF8(mdfile), collapse="\n"))
|
||||
else ""
|
||||
))
|
||||
)
|
||||
|
||||
return(attachDependencies(html, deps))
|
||||
}
|
||||
|
||||
216
R/staticimports.R
Normal file
216
R/staticimports.R
Normal file
@@ -0,0 +1,216 @@
|
||||
# Generated by staticimports; do not edit by hand.
|
||||
# ======================================================================
|
||||
# Imported from pkg:staticimports
|
||||
# ======================================================================
|
||||
|
||||
# Given a vector, return TRUE if any elements are named, FALSE otherwise.
|
||||
# For zero-length vectors, always return FALSE.
|
||||
any_named <- function(x) {
|
||||
if (length(x) == 0) return(FALSE)
|
||||
nms <- names(x)
|
||||
!is.null(nms) && any(nzchar(nms))
|
||||
}
|
||||
|
||||
# Given a vector, return TRUE if any elements are unnamed, FALSE otherwise.
|
||||
# For zero-length vectors, always return FALSE.
|
||||
any_unnamed <- function(x) {
|
||||
if (length(x) == 0) return(FALSE)
|
||||
nms <- names(x)
|
||||
is.null(nms) || !all(nzchar(nms))
|
||||
}
|
||||
|
||||
# Borrowed from pkgload:::dev_meta, with some modifications.
|
||||
# Returns TRUE if `pkg` was loaded with `devtools::load_all()`.
|
||||
devtools_loaded <- function(pkg) {
|
||||
ns <- .getNamespace(pkg)
|
||||
if (is.null(ns) || is.null(ns$.__DEVTOOLS__)) {
|
||||
return(FALSE)
|
||||
}
|
||||
TRUE
|
||||
}
|
||||
|
||||
get_package_version <- function(pkg) {
|
||||
# `utils::packageVersion()` can be slow, so first try the fast path of
|
||||
# checking if the package is already loaded.
|
||||
ns <- .getNamespace(pkg)
|
||||
if (is.null(ns)) {
|
||||
utils::packageVersion(pkg)
|
||||
} else {
|
||||
as.package_version(ns$.__NAMESPACE__.$spec[["version"]])
|
||||
}
|
||||
}
|
||||
|
||||
is_installed <- function(pkg, version = NULL) {
|
||||
installed <- isNamespaceLoaded(pkg) || nzchar(system_file_cached(package = pkg))
|
||||
if (is.null(version)) {
|
||||
return(installed)
|
||||
}
|
||||
installed && isTRUE(get_package_version(pkg) >= version)
|
||||
}
|
||||
|
||||
register_upgrade_message <- function(pkg, version, error = FALSE) {
|
||||
|
||||
msg <- sprintf(
|
||||
"This version of '%s' is designed to work with '%s' >= %s.
|
||||
Please upgrade via install.packages('%s').",
|
||||
environmentName(environment(register_upgrade_message)),
|
||||
pkg, version, pkg
|
||||
)
|
||||
|
||||
cond <- if (error) stop else packageStartupMessage
|
||||
|
||||
if (pkg %in% loadedNamespaces() && !is_installed(pkg, version)) {
|
||||
cond(msg)
|
||||
}
|
||||
|
||||
# Always register hook in case pkg is loaded at some
|
||||
# point the future (or, potentially, but less commonly,
|
||||
# unloaded & reloaded)
|
||||
setHook(
|
||||
packageEvent(pkg, "onLoad"),
|
||||
function(...) {
|
||||
if (!is_installed(pkg, version)) cond(msg)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
# Simplified version rlang:::s3_register() that just uses
|
||||
# warning() instead of rlang::warn() when registration fails
|
||||
# https://github.com/r-lib/rlang/blob/main/R/compat-s3-register.R
|
||||
s3_register <- function(generic, class, method = NULL) {
|
||||
stopifnot(is.character(generic), length(generic) == 1)
|
||||
stopifnot(is.character(class), length(class) == 1)
|
||||
|
||||
pieces <- strsplit(generic, "::")[[1]]
|
||||
stopifnot(length(pieces) == 2)
|
||||
package <- pieces[[1]]
|
||||
generic <- pieces[[2]]
|
||||
|
||||
caller <- parent.frame()
|
||||
|
||||
get_method_env <- function() {
|
||||
top <- topenv(caller)
|
||||
if (isNamespace(top)) {
|
||||
asNamespace(environmentName(top))
|
||||
} else {
|
||||
caller
|
||||
}
|
||||
}
|
||||
get_method <- function(method, env) {
|
||||
if (is.null(method)) {
|
||||
get(paste0(generic, ".", class), envir = get_method_env())
|
||||
} else {
|
||||
method
|
||||
}
|
||||
}
|
||||
|
||||
register <- function(...) {
|
||||
envir <- asNamespace(package)
|
||||
|
||||
# Refresh the method each time, it might have been updated by
|
||||
# `devtools::load_all()`
|
||||
method_fn <- get_method(method)
|
||||
stopifnot(is.function(method_fn))
|
||||
|
||||
# Only register if generic can be accessed
|
||||
if (exists(generic, envir)) {
|
||||
registerS3method(generic, class, method_fn, envir = envir)
|
||||
} else {
|
||||
warning(
|
||||
"Can't find generic `", generic, "` in package ", package,
|
||||
" register S3 method. Do you need to update ", package,
|
||||
" to the latest version?", call. = FALSE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
# Always register hook in case package is later unloaded & reloaded
|
||||
setHook(packageEvent(package, "onLoad"), function(...) {
|
||||
register()
|
||||
})
|
||||
|
||||
# Avoid registration failures during loading (pkgload or regular).
|
||||
# Check that environment is locked because the registering package
|
||||
# might be a dependency of the package that exports the generic. In
|
||||
# that case, the exports (and the generic) might not be populated
|
||||
# yet (#1225).
|
||||
if (isNamespaceLoaded(package) && environmentIsLocked(asNamespace(package))) {
|
||||
register()
|
||||
}
|
||||
|
||||
invisible()
|
||||
}
|
||||
|
||||
# Borrowed from pkgload::shim_system.file, with some modifications. This behaves
|
||||
# like `system.file()`, except that (1) for packages loaded with
|
||||
# `devtools::load_all()`, it will return the path to files in the package's
|
||||
# inst/ directory, and (2) for other packages, the directory lookup is cached.
|
||||
# Also, to keep the implementation simple, it doesn't support specification of
|
||||
# lib.loc or mustWork.
|
||||
system_file <- function(..., package = "base") {
|
||||
if (!devtools_loaded(package)) {
|
||||
return(system_file_cached(..., package = package))
|
||||
}
|
||||
|
||||
if (!is.null(names(list(...)))) {
|
||||
stop("All arguments other than `package` must be unnamed.")
|
||||
}
|
||||
|
||||
# If package was loaded with devtools (the package loaded with load_all),
|
||||
# also search for files under inst/, and don't cache the results (it seems
|
||||
# more likely that the package path will change during the development
|
||||
# process)
|
||||
pkg_path <- find.package(package)
|
||||
|
||||
# First look in inst/
|
||||
files_inst <- file.path(pkg_path, "inst", ...)
|
||||
present_inst <- file.exists(files_inst)
|
||||
|
||||
# For any files that weren't present in inst/, look in the base path
|
||||
files_top <- file.path(pkg_path, ...)
|
||||
present_top <- file.exists(files_top)
|
||||
|
||||
# Merge them together. Here are the different possible conditions, and the
|
||||
# desired result. NULL means to drop that element from the result.
|
||||
#
|
||||
# files_inst: /inst/A /inst/B /inst/C /inst/D
|
||||
# present_inst: T T F F
|
||||
# files_top: /A /B /C /D
|
||||
# present_top: T F T F
|
||||
# result: /inst/A /inst/B /C NULL
|
||||
#
|
||||
files <- files_top
|
||||
files[present_inst] <- files_inst[present_inst]
|
||||
# Drop cases where not present in either location
|
||||
files <- files[present_inst | present_top]
|
||||
if (length(files) == 0) {
|
||||
return("")
|
||||
}
|
||||
# Make sure backslashes are replaced with slashes on Windows
|
||||
normalizePath(files, winslash = "/")
|
||||
}
|
||||
|
||||
# A wrapper for `system.file()`, which caches the results, because
|
||||
# `system.file()` can be slow. Note that because of caching, if
|
||||
# `system_file_cached()` is called on a package that isn't installed, then the
|
||||
# package is installed, and then `system_file_cached()` is called again, it will
|
||||
# still return "".
|
||||
system_file_cached <- local({
|
||||
pkg_dir_cache <- character()
|
||||
|
||||
function(..., package = "base") {
|
||||
if (!is.null(names(list(...)))) {
|
||||
stop("All arguments other than `package` must be unnamed.")
|
||||
}
|
||||
|
||||
not_cached <- is.na(match(package, names(pkg_dir_cache)))
|
||||
if (not_cached) {
|
||||
pkg_dir <- system.file(package = package)
|
||||
pkg_dir_cache[[package]] <<- pkg_dir
|
||||
} else {
|
||||
pkg_dir <- pkg_dir_cache[[package]]
|
||||
}
|
||||
|
||||
file.path(pkg_dir, ...)
|
||||
}
|
||||
})
|
||||
243
R/utils-lang.R
243
R/utils-lang.R
@@ -51,60 +51,199 @@ formalsAndBody <- function(x) {
|
||||
}
|
||||
|
||||
|
||||
# This function is to be called from functions like `reactive()`, `observe()`,
|
||||
# and the various render functions. It handles the following cases:
|
||||
# - The typical case where x is an unquoted expression, and `env` and `quoted`
|
||||
# are not used.
|
||||
# - New-style metaprogramming cases, where rlang::inject() is used to inline a
|
||||
# quosure into the AST, as in `inject(reactive(!!x))`.
|
||||
# - Old-style metaprogramming cases, where `env` and/or `quoted` are used.
|
||||
#
|
||||
# Much of the complexity is handling old-style metaprogramming cases. The code
|
||||
# in this function is more complicated because it needs to look at unevaluated
|
||||
# expressions in the _calling_ function. If this code were put directly in the
|
||||
# calling function, it would look like this:
|
||||
#
|
||||
# if (!missing(env) || !missing(quoted)) {
|
||||
# deprecatedEnvQuotedMessage()
|
||||
# if (!quoted) x <- substitute(x)
|
||||
# x <- new_quosure(x, env)
|
||||
#
|
||||
# } else {
|
||||
# x <- substitute(x)
|
||||
# if (!is_quosure(x)) {
|
||||
# x <- new_quosure(x, env = parent.frame())
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# In the future, the calling functions will not need to have the `env` and
|
||||
# `quoted` arguments -- `rlang::inject()` and quosures can be used instead.
|
||||
# Instead of using this function, `get_quosure()`, the caller can instead use
|
||||
# just the following code:
|
||||
#
|
||||
# x <- substitute(x)
|
||||
# if (!is_quosure(x)) {
|
||||
# x <- new_quosure(x, env = parent.frame())
|
||||
# }
|
||||
#
|
||||
get_quosure <- function(x, env, quoted) {
|
||||
if (!eval(substitute(missing(env)), parent.frame()) ||
|
||||
!eval(substitute(missing(quoted)), parent.frame()))
|
||||
{
|
||||
deprecatedEnvQuotedMessage()
|
||||
if (!quoted) {
|
||||
x <- eval(substitute(substitute(x)), parent.frame())
|
||||
}
|
||||
x <- new_quosure(x, env)
|
||||
#' @describeIn createRenderFunction convert a quosure to a function.
|
||||
#' @param q Quosure of the expression `x`. When capturing expressions to create
|
||||
#' your quosure, it is recommended to use [`enquo0()`] to not unquote the
|
||||
#' object too early. See [`enquo0()`] for more details.
|
||||
#' @inheritParams installExprFunction
|
||||
#' @export
|
||||
quoToFunction <- function(
|
||||
q,
|
||||
label = sys.call(-1)[[1]],
|
||||
..stacktraceon = FALSE
|
||||
) {
|
||||
func <- quoToSimpleFunction(as_quosure(q))
|
||||
wrapFunctionLabel(func, updateFunctionLabel(label), ..stacktraceon = ..stacktraceon, dots = FALSE)
|
||||
}
|
||||
|
||||
} else {
|
||||
x <- eval(substitute(substitute(x)), parent.frame())
|
||||
|
||||
# At this point, x can be a quosure if rlang::inject() is used, but the
|
||||
# typical case is that x is not a quosure.
|
||||
if (!is_quosure(x)) {
|
||||
x <- new_quosure(x, env = parent.frame(2L))
|
||||
updateFunctionLabel <- function(label) {
|
||||
badFnName <- "anonymous"
|
||||
if (all(is.language(label))) {
|
||||
# Prevent immediately invoked functions like as.language(a()())
|
||||
if (is.language(label) && length(label) > 1) {
|
||||
return(badFnName)
|
||||
}
|
||||
label <- deparse(label, width.cutoff = 500L)
|
||||
}
|
||||
label <- as.character(label)
|
||||
# Prevent function calls that are over one line; (Assignments are hard to perform)
|
||||
# Prevent immediately invoked functions like "a()()"
|
||||
if (length(label) > 1 || grepl("(", label, fixed = TRUE)) {
|
||||
return(badFnName)
|
||||
}
|
||||
if (label == "NULL") {
|
||||
return(badFnName)
|
||||
}
|
||||
label
|
||||
}
|
||||
|
||||
quoToSimpleFunction <- function(q) {
|
||||
# Should not use `new_function(list(), get_expr(q), get_env(q))` as extra logic
|
||||
# is done by rlang to convert the quosure to a function within `as_function(q)`
|
||||
fun <- as_function(q)
|
||||
|
||||
# If the quosure is empty, then the returned function can not be called.
|
||||
# https://github.com/r-lib/rlang/issues/1244
|
||||
if (quo_is_missing(q)) {
|
||||
fn_body(fun) <- quote({})
|
||||
}
|
||||
|
||||
x
|
||||
# `as_function()` returns a function that takes `...`. We need one that takes no
|
||||
# args.
|
||||
fn_fmls(fun) <- list()
|
||||
|
||||
fun
|
||||
}
|
||||
|
||||
|
||||
#' Convert an expression to a function
|
||||
#'
|
||||
#' `r lifecycle::badge("superseded")` Please use [`installExprFunction()`] for a better
|
||||
#' debugging experience (Shiny 0.8.0). If the `expr` and `quoted` parameters are not needed, please see
|
||||
#' [`quoToFunction()`] (Shiny 1.6.0).
|
||||
#'
|
||||
#' Similar to [installExprFunction()] but doesn't register debug hooks.
|
||||
#'
|
||||
#' @param expr A quoted or unquoted expression, or a quosure.
|
||||
#' @param env The desired environment for the function. Defaults to the
|
||||
#' calling environment two steps back.
|
||||
#' @param quoted Is the expression quoted?
|
||||
#' @seealso [`installExprFunction()`] for the modern approach to converting an expression to a function
|
||||
#' @export
|
||||
#' @keywords internal
|
||||
exprToFunction <- function(expr, env = parent.frame(), quoted = FALSE) {
|
||||
# If `expr` is a raw quosure, must say `quoted = TRUE`; (env is ignored)
|
||||
# If `inject()` a quosure, env is ignored, and quoted should be FALSE (aka ignored).
|
||||
# Make article of usage
|
||||
# * (by joe)
|
||||
|
||||
if (!quoted) {
|
||||
expr <- eval(substitute(substitute(expr)), parent.frame())
|
||||
}
|
||||
# MUST call with `quoted = TRUE` as exprToQuo() will not reach high enough
|
||||
q <- exprToQuo(expr, env, quoted = TRUE)
|
||||
|
||||
# MUST call `as_function()`. Can NOT call `new_function()`
|
||||
# rlang has custom logic for handling converting a quosure to a function
|
||||
quoToSimpleFunction(q)
|
||||
}
|
||||
# For internal use only; External users should be using `exprToFunction()` or `installExprFunction()`
|
||||
# MUST be the exact same logic as `exprToFunction()`, but without the `quoToSimpleFunction()` call
|
||||
exprToQuo <- function(expr, env = parent.frame(), quoted = FALSE) {
|
||||
if (!quoted) {
|
||||
expr <- eval(substitute(substitute(expr)), parent.frame())
|
||||
}
|
||||
q <-
|
||||
if (is_quosure(expr)) {
|
||||
# inject()ed quosure
|
||||
# do nothing
|
||||
expr
|
||||
} else if (is.language(expr) || rlang::is_atomic(expr) || is.null(expr)) {
|
||||
# Most common case...
|
||||
new_quosure(expr, env = env)
|
||||
} else {
|
||||
stop("Don't know how to convert '", class(expr)[1], "' to a function; a quosure or quoted expression was expected")
|
||||
}
|
||||
q
|
||||
}
|
||||
|
||||
#' @describeIn createRenderFunction converts a user's reactive `expr` into a
|
||||
#' function that's assigned to a `name` in the `assign.env`.
|
||||
#'
|
||||
#' @param name The name the function should be given
|
||||
#' @param eval.env The desired environment for the function. Defaults to the
|
||||
#' calling environment two steps back.
|
||||
#' @param assign.env The environment in which the function should be assigned.
|
||||
#' @param label A label for the object to be shown in the debugger. Defaults to
|
||||
#' the name of the calling function.
|
||||
#' @param wrappedWithLabel,..stacktraceon Advanced use only. For stack manipulation purposes; see
|
||||
#' [stacktrace()].
|
||||
#' @inheritParams exprToFunction
|
||||
#' @export
|
||||
installExprFunction <- function(expr, name, eval.env = parent.frame(2),
|
||||
quoted = FALSE,
|
||||
assign.env = parent.frame(1),
|
||||
label = sys.call(-1)[[1]],
|
||||
wrappedWithLabel = TRUE,
|
||||
..stacktraceon = FALSE) {
|
||||
if (!quoted) {
|
||||
quoted <- TRUE
|
||||
expr <- eval(substitute(substitute(expr)), parent.frame())
|
||||
}
|
||||
|
||||
func <- exprToFunction(expr, eval.env, quoted)
|
||||
if (length(label) > 1) {
|
||||
# Just in case the deparsed code is more complicated than we imagine. If we
|
||||
# have a label with length > 1 it causes warnings in wrapFunctionLabel.
|
||||
label <- paste0(label, collapse = "\n")
|
||||
}
|
||||
wrappedWithLabel <- isTRUE(wrappedWithLabel)
|
||||
if (wrappedWithLabel) {
|
||||
func <- wrapFunctionLabel(func, updateFunctionLabel(label), ..stacktraceon = ..stacktraceon, dots = FALSE)
|
||||
}
|
||||
assign(name, func, envir = assign.env)
|
||||
if (!wrappedWithLabel) {
|
||||
registerDebugHook(name, assign.env, label)
|
||||
}
|
||||
|
||||
invisible(func)
|
||||
}
|
||||
|
||||
# Utility function for creating a debugging label, given an expression.
|
||||
# `expr` is a quoted expression.
|
||||
# `function_name` is the name of the calling function.
|
||||
# `label` is an optional user-provided label. If NULL, it will be inferred.
|
||||
exprToLabel <- function(expr, function_name, label = NULL) {
|
||||
srcref <- attr(expr, "srcref", exact = TRUE)
|
||||
if (is.null(label)) {
|
||||
label <- rexprSrcrefToLabel(
|
||||
srcref[[1]],
|
||||
simpleExprToFunction(expr, function_name)
|
||||
)
|
||||
}
|
||||
if (length(srcref) >= 2) attr(label, "srcref") <- srcref[[2]]
|
||||
attr(label, "srcfile") <- srcFileOfRef(srcref[[1]])
|
||||
label
|
||||
}
|
||||
simpleExprToFunction <- function(expr, function_name) {
|
||||
sprintf('%s(%s)', function_name, paste(deparse(expr), collapse='\n'))
|
||||
}
|
||||
|
||||
installedFuncExpr <- function(func) {
|
||||
fn_body(attr(func, "wrappedFunc", exact = TRUE))
|
||||
}
|
||||
|
||||
funcToLabelBody <- function(func) {
|
||||
paste(deparse(installedFuncExpr(func)), collapse='\n')
|
||||
}
|
||||
funcToLabel <- function(func, functionLabel, label = NULL) {
|
||||
if (!is.null(label)) return(label)
|
||||
|
||||
sprintf(
|
||||
'%s(%s)',
|
||||
functionLabel,
|
||||
funcToLabelBody(func)
|
||||
)
|
||||
}
|
||||
quoToLabelBody <- function(q) {
|
||||
paste(deparse(quo_get_expr(q)), collapse='\n')
|
||||
}
|
||||
quoToLabel <- function(q, functionLabel, label = NULL) {
|
||||
if (!is.null(label)) return(label)
|
||||
|
||||
sprintf(
|
||||
'%s(%s)',
|
||||
functionLabel,
|
||||
quoToLabelBody(q)
|
||||
)
|
||||
}
|
||||
|
||||
252
R/utils.R
252
R/utils.R
@@ -2,6 +2,11 @@
|
||||
#' @include map.R
|
||||
NULL
|
||||
|
||||
# @staticimports pkg:staticimports
|
||||
# is_installed get_package_version system_file
|
||||
# s3_register register_upgrade_message
|
||||
# any_named any_unnamed
|
||||
|
||||
#' Make a random number generator repeatable
|
||||
#'
|
||||
#' Given a function that generates random data, returns a wrapped version of
|
||||
@@ -126,34 +131,6 @@ dropNullsOrEmpty <- function(x) {
|
||||
x[!vapply(x, nullOrEmpty, FUN.VALUE=logical(1))]
|
||||
}
|
||||
|
||||
# Given a vector/list, return TRUE if any elements are named, FALSE otherwise.
|
||||
anyNamed <- function(x) {
|
||||
# Zero-length vector
|
||||
if (length(x) == 0) return(FALSE)
|
||||
|
||||
nms <- names(x)
|
||||
|
||||
# List with no name attribute
|
||||
if (is.null(nms)) return(FALSE)
|
||||
|
||||
# List with name attribute; check for any ""
|
||||
any(nzchar(nms))
|
||||
}
|
||||
|
||||
# Given a vector/list, return TRUE if any elements are unnamed, FALSE otherwise.
|
||||
anyUnnamed <- function(x) {
|
||||
# Zero-length vector
|
||||
if (length(x) == 0) return(FALSE)
|
||||
|
||||
nms <- names(x)
|
||||
|
||||
# List with no name attribute
|
||||
if (is.null(nms)) return(TRUE)
|
||||
|
||||
# List with name attribute; check for any ""
|
||||
any(!nzchar(nms))
|
||||
}
|
||||
|
||||
|
||||
# Given a vector/list, returns a named vector/list (the labels will be blank).
|
||||
asNamed <- function(x) {
|
||||
@@ -173,7 +150,7 @@ empty_named_list <- function() {
|
||||
# name as elements in a, the element in a is dropped. Also, if there are any
|
||||
# duplicated names in a or b, only the last one with that name is kept.
|
||||
mergeVectors <- function(a, b) {
|
||||
if (anyUnnamed(a) || anyUnnamed(b)) {
|
||||
if (any_unnamed(a) || any_unnamed(b)) {
|
||||
stop("Vectors must be either NULL or have names for all elements")
|
||||
}
|
||||
|
||||
@@ -186,7 +163,7 @@ mergeVectors <- function(a, b) {
|
||||
# same name, preserve the original order of those items. For empty
|
||||
# vectors/lists/NULL, return the original value.
|
||||
sortByName <- function(x) {
|
||||
if (anyUnnamed(x))
|
||||
if (any_unnamed(x))
|
||||
stop("All items must be named")
|
||||
|
||||
# Special case for empty vectors/lists, and NULL
|
||||
@@ -404,165 +381,6 @@ getContentType <- function(file, defaultType = 'application/octet-stream') {
|
||||
mime::guess_type(file, unknown = defaultType, subtype = subtype)
|
||||
}
|
||||
|
||||
# Create a zero-arg function from a quoted expression and environment
|
||||
# @examples
|
||||
# makeFunction(body=quote(print(3)))
|
||||
makeFunction <- function(args = pairlist(), body, env = parent.frame()) {
|
||||
eval(call("function", args, body), env)
|
||||
}
|
||||
|
||||
#' Convert an expression to a function
|
||||
#'
|
||||
#' This is to be called from another function, because it will attempt to get
|
||||
#' an unquoted expression from two calls back. Note: as of Shiny 1.6.0, it is
|
||||
#' recommended to use [quoToFunction()] instead.
|
||||
#'
|
||||
#' If expr is a quoted expression, then this just converts it to a function.
|
||||
#' If expr is a function, then this simply returns expr (and prints a
|
||||
#' deprecation message).
|
||||
#' If expr was a non-quoted expression from two calls back, then this will
|
||||
#' quote the original expression and convert it to a function.
|
||||
#
|
||||
#' @param expr A quoted or unquoted expression, or a function.
|
||||
#' @param env The desired environment for the function. Defaults to the
|
||||
#' calling environment two steps back.
|
||||
#' @param quoted Is the expression quoted?
|
||||
#'
|
||||
#' @examples
|
||||
#' # Example of a new renderer, similar to renderText
|
||||
#' # This is something that toolkit authors will do
|
||||
#' renderTriple <- function(expr, env=parent.frame(), quoted=FALSE) {
|
||||
#' # Convert expr to a function
|
||||
#' func <- shiny::exprToFunction(expr, env, quoted)
|
||||
#'
|
||||
#' function() {
|
||||
#' value <- func()
|
||||
#' paste(rep(value, 3), collapse=", ")
|
||||
#' }
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' # Example of using the renderer.
|
||||
#' # This is something that app authors will do.
|
||||
#' values <- reactiveValues(A="text")
|
||||
#'
|
||||
#' \dontrun{
|
||||
#' # Create an output object
|
||||
#' output$tripleA <- renderTriple({
|
||||
#' values$A
|
||||
#' })
|
||||
#' }
|
||||
#'
|
||||
#' # At the R console, you can experiment with the renderer using isolate()
|
||||
#' tripleA <- renderTriple({
|
||||
#' values$A
|
||||
#' })
|
||||
#'
|
||||
#' isolate(tripleA())
|
||||
#' # "text, text, text"
|
||||
#' @export
|
||||
exprToFunction <- function(expr, env=parent.frame(), quoted=FALSE) {
|
||||
if (!quoted) {
|
||||
expr <- eval(substitute(substitute(expr)), parent.frame())
|
||||
}
|
||||
|
||||
# expr is a quoted expression
|
||||
makeFunction(body=expr, env=env)
|
||||
}
|
||||
|
||||
#' Install an expression as a function
|
||||
#'
|
||||
#' Installs an expression in the given environment as a function, and registers
|
||||
#' debug hooks so that breakpoints may be set in the function. Note: as of
|
||||
#' Shiny 1.6.0, it is recommended to use [quoToFunction()] instead.
|
||||
#'
|
||||
#' This function can replace `exprToFunction` as follows: we may use
|
||||
#' `func <- exprToFunction(expr)` if we do not want the debug hooks, or
|
||||
#' `installExprFunction(expr, "func")` if we do. Both approaches create a
|
||||
#' function named `func` in the current environment.
|
||||
#'
|
||||
#' @seealso Wraps [exprToFunction()]; see that method's documentation
|
||||
#' for more documentation and examples.
|
||||
#'
|
||||
#' @param expr A quoted or unquoted expression
|
||||
#' @param name The name the function should be given
|
||||
#' @param eval.env The desired environment for the function. Defaults to the
|
||||
#' calling environment two steps back.
|
||||
#' @param quoted Is the expression quoted?
|
||||
#' @param assign.env The environment in which the function should be assigned.
|
||||
#' @param label A label for the object to be shown in the debugger. Defaults to
|
||||
#' the name of the calling function.
|
||||
#' @param wrappedWithLabel,..stacktraceon Advanced use only. For stack manipulation purposes; see
|
||||
#' [stacktrace()].
|
||||
#' @export
|
||||
installExprFunction <- function(expr, name, eval.env = parent.frame(2),
|
||||
quoted = FALSE,
|
||||
assign.env = parent.frame(1),
|
||||
label = deparse(sys.call(-1)[[1]]),
|
||||
wrappedWithLabel = TRUE,
|
||||
..stacktraceon = FALSE) {
|
||||
if (!quoted) {
|
||||
quoted <- TRUE
|
||||
expr <- eval(substitute(substitute(expr)), parent.frame())
|
||||
}
|
||||
|
||||
func <- exprToFunction(expr, eval.env, quoted)
|
||||
if (length(label) > 1) {
|
||||
# Just in case the deparsed code is more complicated than we imagine. If we
|
||||
# have a label with length > 1 it causes warnings in wrapFunctionLabel.
|
||||
label <- paste0(label, collapse = "\n")
|
||||
}
|
||||
if (wrappedWithLabel) {
|
||||
func <- wrapFunctionLabel(func, label, ..stacktraceon = ..stacktraceon)
|
||||
} else {
|
||||
registerDebugHook(name, assign.env, label)
|
||||
}
|
||||
assign(name, func, envir = assign.env)
|
||||
}
|
||||
|
||||
#' Convert a quosure to a function for a Shiny render function
|
||||
#'
|
||||
#' This takes a quosure and label, and wraps them into a function that should be
|
||||
#' passed to [createRenderFunction()] or [markRenderFunction()].
|
||||
#'
|
||||
#' This function was added in Shiny 1.6.0. Previously, it was recommended to use
|
||||
#' [installExprFunction()] or [exprToFunction()] in render functions, but now we
|
||||
#' recommend using [quoToFunction()], because it does not require `env` and
|
||||
#' `quoted` arguments -- that information is captured by quosures provided by
|
||||
#' \pkg{rlang}.
|
||||
#'
|
||||
#' @param q A quosure.
|
||||
#' @inheritParams installExprFunction
|
||||
#' @seealso [createRenderFunction()] for example usage.
|
||||
#'
|
||||
#' @export
|
||||
quoToFunction <- function(q, label, ..stacktraceon = FALSE) {
|
||||
q <- as_quosure(q)
|
||||
func <- as_function(q)
|
||||
# as_function returns a function that takes `...`. We want one that takes no
|
||||
# args.
|
||||
formals(func) <- list()
|
||||
wrapFunctionLabel(func, label, ..stacktraceon = ..stacktraceon)
|
||||
}
|
||||
|
||||
|
||||
# Utility function for creating a debugging label, given an expression.
|
||||
# `expr` is a quoted expression.
|
||||
# `function_name` is the name of the calling function.
|
||||
# `label` is an optional user-provided label. If NULL, it will be inferred.
|
||||
exprToLabel <- function(expr, function_name, label = NULL) {
|
||||
srcref <- attr(expr, "srcref", exact = TRUE)
|
||||
if (is.null(label)) {
|
||||
label <- rexprSrcrefToLabel(
|
||||
srcref[[1]],
|
||||
sprintf('%s(%s)', function_name, paste(deparse(expr), collapse = '\n'))
|
||||
)
|
||||
}
|
||||
if (length(srcref) >= 2) attr(label, "srcref") <- srcref[[2]]
|
||||
attr(label, "srcfile") <- srcFileOfRef(srcref[[1]])
|
||||
label
|
||||
}
|
||||
|
||||
#' Parse a GET query string from a URL
|
||||
#'
|
||||
#' Returns a named list of key-value pairs.
|
||||
@@ -654,7 +472,7 @@ shinyCallingHandlers <- function(expr) {
|
||||
withCallingHandlers(captureStackTraces(expr),
|
||||
error = function(e) {
|
||||
# Don't intercept shiny.silent.error (i.e. validation errors)
|
||||
if (inherits(e, "shiny.silent.error"))
|
||||
if (cnd_inherits(e, "shiny.silent.error"))
|
||||
return()
|
||||
|
||||
handle <- getOption('shiny.error')
|
||||
@@ -1597,21 +1415,31 @@ dateYMD <- function(date = NULL, argName = "value") {
|
||||
# function which calls the original function using the specified name. This can
|
||||
# be helpful for profiling, because the specified name will show up on the stack
|
||||
# trace.
|
||||
wrapFunctionLabel <- function(func, name, ..stacktraceon = FALSE) {
|
||||
wrapFunctionLabel <- function(func, name, ..stacktraceon = FALSE, dots = TRUE) {
|
||||
if (name == "name" || name == "func" || name == "relabelWrapper") {
|
||||
stop("Invalid name for wrapFunctionLabel: ", name)
|
||||
}
|
||||
assign(name, func, environment())
|
||||
registerDebugHook(name, environment(), name)
|
||||
|
||||
if (..stacktraceon) {
|
||||
# We need to wrap the `...` in `!!quote(...)` so that R CMD check won't
|
||||
# complain about "... may be used in an incorrect context"
|
||||
body <- expr({ ..stacktraceon..((!!name)(!!quote(...))) })
|
||||
if (isTRUE(dots)) {
|
||||
if (..stacktraceon) {
|
||||
# We need to wrap the `...` in `!!quote(...)` so that R CMD check won't
|
||||
# complain about "... may be used in an incorrect context"
|
||||
body <- expr({ ..stacktraceon..((!!name)(!!quote(...))) })
|
||||
} else {
|
||||
body <- expr({ (!!name)(!!quote(...)) })
|
||||
}
|
||||
relabelWrapper <- new_function(pairlist2(... =), body, environment())
|
||||
} else {
|
||||
body <- expr({ (!!name)(!!quote(...)) })
|
||||
# Same logic as when `dots = TRUE`, but without the `...`
|
||||
if (..stacktraceon) {
|
||||
body <- expr({ ..stacktraceon..((!!name)()) })
|
||||
} else {
|
||||
body <- expr({ (!!name)() })
|
||||
}
|
||||
relabelWrapper <- new_function(list(), body, environment())
|
||||
}
|
||||
relabelWrapper <- new_function(pairlist2(... =), body, environment())
|
||||
|
||||
# Preserve the original function that was passed in; is used for caching.
|
||||
attr(relabelWrapper, "wrappedFunc") <- func
|
||||
@@ -1865,24 +1693,20 @@ findEnclosingApp <- function(path = ".") {
|
||||
}
|
||||
}
|
||||
|
||||
# Check if a package is installed, and if version is specified,
|
||||
# that we have at least that version
|
||||
is_available <- function(package, version = NULL) {
|
||||
installed <- nzchar(system.file(package = package))
|
||||
if (is.null(version)) {
|
||||
return(installed)
|
||||
}
|
||||
installed && isTRUE(utils::packageVersion(package) >= version)
|
||||
# Until `rlang::cnd_inherits()` is on CRAN
|
||||
cnd_inherits <- function(cnd, class) {
|
||||
cnd_some(cnd, ~ inherits(.x, class))
|
||||
}
|
||||
cnd_some <- function(.cnd, .p, ...) {
|
||||
.p <- rlang::as_function(.p)
|
||||
|
||||
|
||||
# cached version of utils::packageVersion("shiny")
|
||||
shinyPackageVersion <- local({
|
||||
version <- NULL
|
||||
function() {
|
||||
if (is.null(version)) {
|
||||
version <<- utils::packageVersion("shiny")
|
||||
while (rlang::is_condition(.cnd)) {
|
||||
if (.p(.cnd, ...)) {
|
||||
return(TRUE)
|
||||
}
|
||||
version
|
||||
|
||||
.cnd <- .cnd$parent
|
||||
}
|
||||
})
|
||||
|
||||
FALSE
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<!-- badges: start -->
|
||||
[](https://CRAN.R-project.org/package=shiny)
|
||||
[](https://github.com/rstudio/shiny/actions)
|
||||
[](https://github.com/rstudio/shiny/actions)
|
||||
[](https://community.rstudio.com/new-topic?category=shiny&tags=shiny)
|
||||
|
||||
<!-- badges: end -->
|
||||
@@ -47,13 +47,13 @@ For help with learning fundamental Shiny programming concepts, check out the [Ma
|
||||
|
||||
## Getting Help
|
||||
|
||||
To ask a question about Shiny, please use the [RStudio Community website](https://community.rstudio.com/new-topic?category=shiny&tags=shiny).
|
||||
To ask a question about Shiny, please use the [RStudio Community website](https://community.rstudio.com/new-topic?category=shiny&tags=shiny).
|
||||
|
||||
For bug reports, please use the [issue tracker](https://github.com/rstudio/shiny/issues) and also keep in mind that by [writing a good bug report](https://github.com/rstudio/shiny/wiki/Writing-Good-Bug-Reports), you're more likely to get help with your problem.
|
||||
For bug reports, please use the [issue tracker](https://github.com/rstudio/shiny/issues) and also keep in mind that by [writing a good bug report](https://github.com/rstudio/shiny/wiki/Writing-Good-Bug-Reports), you're more likely to get help with your problem.
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome contributions to the **shiny** package. Please see our [CONTRIBUTING.md](https://github.com/rstudio/shiny/blob/master/.github/CONTRIBUTING.md) file for detailed guidelines of how to contribute.
|
||||
We welcome contributions to the **shiny** package. Please see our [CONTRIBUTING.md](https://github.com/rstudio/shiny/blob/main/.github/CONTRIBUTING.md) file for detailed guidelines of how to contribute.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
/*! shiny 1.6.0.9021 | (c) 2012-2021 RStudio, PBC. | License: GPL-3 | file LICENSE */
|
||||
/*! shiny 1.7.1.9002 | (c) 2012-2022 RStudio, PBC. | License: GPL-3 | file LICENSE */
|
||||
(function(){var t="ws:";window.location.protocol==="https:"&&(t="wss:");var o=window.location.pathname;/\/$/.test(o)||(o+="/");o+="autoreload/";var n=new WebSocket(t+"//"+window.location.host+o);n.onmessage=function(a){a.data==="autoreload"&&window.location.reload()};})();
|
||||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vc3JjdHMvZXh0cmFzL3NoaW55LWF1dG9yZWxvYWQudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbIi8qIGVzbGludC1kaXNhYmxlIHVuaWNvcm4vZmlsZW5hbWUtY2FzZSAqL1xudmFyIHByb3RvY29sID0gXCJ3czpcIjtcbmlmICh3aW5kb3cubG9jYXRpb24ucHJvdG9jb2wgPT09IFwiaHR0cHM6XCIpIHByb3RvY29sID0gXCJ3c3M6XCI7XG52YXIgZGVmYXVsdFBhdGggPSB3aW5kb3cubG9jYXRpb24ucGF0aG5hbWU7XG5pZiAoIS9cXC8kLy50ZXN0KGRlZmF1bHRQYXRoKSkgZGVmYXVsdFBhdGggKz0gXCIvXCI7XG5kZWZhdWx0UGF0aCArPSBcImF1dG9yZWxvYWQvXCI7XG52YXIgd3MgPSBuZXcgV2ViU29ja2V0KHByb3RvY29sICsgXCIvL1wiICsgd2luZG93LmxvY2F0aW9uLmhvc3QgKyBkZWZhdWx0UGF0aCk7XG5cbndzLm9ubWVzc2FnZSA9IGZ1bmN0aW9uIChldmVudCkge1xuICBpZiAoZXZlbnQuZGF0YSA9PT0gXCJhdXRvcmVsb2FkXCIpIHtcbiAgICB3aW5kb3cubG9jYXRpb24ucmVsb2FkKCk7XG4gIH1cbn07XG5cbmV4cG9ydCB7fTsiXSwKICAibWFwcGluZ3MiOiAiO1lBQ0EsR0FBSSxHQUFXLE1BQ2YsQUFBSSxPQUFPLFNBQVMsV0FBYSxVQUFVLEdBQVcsUUFDdEQsR0FBSSxHQUFjLE9BQU8sU0FBUyxTQUNsQyxBQUFLLE1BQU0sS0FBSyxJQUFjLElBQWUsS0FDN0MsR0FBZSxjQUNmLEdBQUksR0FBSyxHQUFJLFdBQVUsRUFBVyxLQUFPLE9BQU8sU0FBUyxLQUFPLEdBRWhFLEVBQUcsVUFBWSxTQUFVLEVBQU8sQ0FDOUIsQUFBSSxFQUFNLE9BQVMsY0FDakIsT0FBTyxTQUFTIiwKICAibmFtZXMiOiBbXQp9Cg==
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
/*! shiny 1.6.0.9021 | (c) 2012-2021 RStudio, PBC. | License: GPL-3 | file LICENSE */
|
||||
/*! shiny 1.7.1.9002 | (c) 2012-2022 RStudio, PBC. | License: GPL-3 | file LICENSE */
|
||||
#showcase-well{border-radius:0}.shiny-code{background-color:#fff;margin-bottom:0}.shiny-code code{font-family:Menlo,Consolas,"Courier New",monospace}.shiny-code-container{margin-top:20px;clear:both}.shiny-code-container h3{display:inline;margin-right:15px}.showcase-header{font-size:16px;font-weight:normal}.showcase-code-link{text-align:right;padding:15px}#showcase-app-container{vertical-align:top}#showcase-code-tabs{margin-right:15px}#showcase-code-tabs pre{border:none;line-height:1em}#showcase-code-tabs .nav{margin-bottom:0}#showcase-code-tabs ul{margin-bottom:0}#showcase-code-tabs .tab-content{border-style:solid;border-color:#e5e5e5;border-width:0px 1px 1px 1px;overflow:auto;border-bottom-right-radius:4px;border-bottom-left-radius:4px}#showcase-app-code{width:100%}#showcase-code-position-toggle{float:right}#showcase-sxs-code{padding-top:20px;vertical-align:top}.showcase-code-license{display:block;text-align:right}#showcase-code-content pre{background-color:#fff}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
||||
/*! shiny 1.6.0.9021 | (c) 2012-2021 RStudio, PBC. | License: GPL-3 | file LICENSE */
|
||||
/*! shiny 1.7.1.9002 | (c) 2012-2022 RStudio, PBC. | License: GPL-3 | file LICENSE */
|
||||
(function(){var a=eval;window.addEventListener("message",function(i){var e=i.data;e.code&&a(e.code)});})();
|
||||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vc3JjdHMvc3JjL3V0aWxzL2V2YWwudHMiLCAiLi4vLi4vLi4vc3JjdHMvZXh0cmFzL3NoaW55LXRlc3Rtb2RlLnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyIvL2VzYnVpbGQuZ2l0aHViLmlvL2NvbnRlbnQtdHlwZXMvI2RpcmVjdC1ldmFsXG4vL3RsL2RyO1xuLy8gKiBEaXJlY3QgdXNhZ2Ugb2YgYGV2YWwoXCJ4XCIpYCBpcyBiYWQgd2l0aCBidW5kbGVkIGNvZGUuXG4vLyAqIEluc3RlYWQsIHVzZSBpbmRpcmVjdCBjYWxscyB0byBgZXZhbGAgc3VjaCBhcyBgaW5kaXJlY3RFdmFsKFwieFwiKWBcbi8vICAgKiBFdmVuIGp1c3QgcmVuYW1pbmcgdGhlIGZ1bmN0aW9uIHdvcmtzIHdlbGwgZW5vdWdoLlxuLy8gPiBUaGlzIGlzIGtub3duIGFzIFwiaW5kaXJlY3QgZXZhbFwiIGJlY2F1c2UgZXZhbCBpcyBub3QgYmVpbmcgY2FsbGVkIGRpcmVjdGx5LCBhbmQgc28gZG9lcyBub3QgdHJpZ2dlciB0aGUgZ3JhbW1hdGljYWwgc3BlY2lhbCBjYXNlIGZvciBkaXJlY3QgZXZhbCBpbiB0aGUgSmF2YVNjcmlwdCBWTS4gWW91IGNhbiBjYWxsIGluZGlyZWN0IGV2YWwgdXNpbmcgYW55IHN5bnRheCBhdCBhbGwgZXhjZXB0IGZvciBhbiBleHByZXNzaW9uIG9mIHRoZSBleGFjdCBmb3JtIGV2YWwoJ3gnKS4gRm9yIGV4YW1wbGUsIHZhciBldmFsMiA9IGV2YWw7IGV2YWwyKCd4JykgYW5kIFtldmFsXVswXSgneCcpIGFuZCB3aW5kb3cuZXZhbCgneCcpIGFyZSBhbGwgaW5kaXJlY3QgZXZhbCBjYWxscy5cbi8vID4gV2hlbiB5b3UgdXNlIGluZGlyZWN0IGV2YWwsIHRoZSBjb2RlIGlzIGV2YWx1YXRlZCBpbiB0aGUgZ2xvYmFsIHNjb3BlIGluc3RlYWQgb2YgaW4gdGhlIGlubGluZSBzY29wZSBvZiB0aGUgY2FsbGVyLlxudmFyIGluZGlyZWN0RXZhbCA9IGV2YWw7XG5leHBvcnQgeyBpbmRpcmVjdEV2YWwgfTsiLCAiLyogZXNsaW50LWRpc2FibGUgdW5pY29ybi9maWxlbmFtZS1jYXNlICovXG5pbXBvcnQgeyBpbmRpcmVjdEV2YWwgfSBmcm9tIFwiLi4vc3JjL3V0aWxzL2V2YWxcIjsgLy8gTGlzdGVuIGZvciBtZXNzYWdlcyBmcm9tIHBhcmVudCBmcmFtZS4gVGhpcyBmaWxlIGlzIG9ubHkgYWRkZWQgd2hlbiB0aGVcbi8vIHNoaW55LnRlc3Rtb2RlIG9wdGlvbiBpcyBUUlVFLlxuXG53aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcihcIm1lc3NhZ2VcIiwgZnVuY3Rpb24gKGUpIHtcbiAgdmFyIG1lc3NhZ2UgPSBlLmRhdGE7XG4gIGlmIChtZXNzYWdlLmNvZGUpIGluZGlyZWN0RXZhbChtZXNzYWdlLmNvZGUpO1xufSk7Il0sCiAgIm1hcHBpbmdzIjogIjtZQU9BLEdBQUksR0FBZSxLQ0huQixPQUFPLGlCQUFpQixVQUFXLFNBQVUsRUFBRyxDQUM5QyxHQUFJLEdBQVUsRUFBRSxLQUNoQixBQUFJLEVBQVEsTUFBTSxFQUFhLEVBQVEiLAogICJuYW1lcyI6IFtdCn0K
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*! shiny 1.6.0.9021 | (c) 2012-2021 RStudio, PBC. | License: GPL-3 | file LICENSE */
|
||||
/*! shiny 1.7.1.9002 | (c) 2012-2022 RStudio, PBC. | License: GPL-3 | file LICENSE */
|
||||
(function() {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
@@ -2131,6 +2131,19 @@
|
||||
}
|
||||
});
|
||||
|
||||
// node_modules/core-js/internals/array-for-each.js
|
||||
var require_array_for_each = __commonJS({
|
||||
"node_modules/core-js/internals/array-for-each.js": function(exports, module) {
|
||||
"use strict";
|
||||
var $forEach2 = require_array_iteration().forEach;
|
||||
var arrayMethodIsStrict4 = require_array_method_is_strict();
|
||||
var STRICT_METHOD4 = arrayMethodIsStrict4("forEach");
|
||||
module.exports = !STRICT_METHOD4 ? function forEach3(callbackfn) {
|
||||
return $forEach2(this, callbackfn, arguments.length > 1 ? arguments[1] : void 0);
|
||||
} : [].forEach;
|
||||
}
|
||||
});
|
||||
|
||||
// node_modules/core-js/internals/object-to-array.js
|
||||
var require_object_to_array = __commonJS({
|
||||
"node_modules/core-js/internals/object-to-array.js": function(exports, module) {
|
||||
@@ -2769,19 +2782,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
// node_modules/core-js/internals/array-for-each.js
|
||||
var require_array_for_each = __commonJS({
|
||||
"node_modules/core-js/internals/array-for-each.js": function(exports, module) {
|
||||
"use strict";
|
||||
var $forEach2 = require_array_iteration().forEach;
|
||||
var arrayMethodIsStrict4 = require_array_method_is_strict();
|
||||
var STRICT_METHOD4 = arrayMethodIsStrict4("forEach");
|
||||
module.exports = !STRICT_METHOD4 ? function forEach3(callbackfn) {
|
||||
return $forEach2(this, callbackfn, arguments.length > 1 ? arguments[1] : void 0);
|
||||
} : [].forEach;
|
||||
}
|
||||
});
|
||||
|
||||
// srcts/src/initialize/disableForm.ts
|
||||
var import_jquery = __toModule(require_jquery());
|
||||
function disableFormSubmission() {
|
||||
@@ -2877,6 +2877,9 @@
|
||||
} else {
|
||||
setIsQt(false);
|
||||
}
|
||||
if (/\bQt/.test(userAgent) && /\bMacintosh/.test(userAgent)) {
|
||||
(0, import_jquery3.default)(document.documentElement).addClass("qtmac");
|
||||
}
|
||||
if (/\bQt\/5/.test(userAgent) && /Linux/.test(userAgent)) {
|
||||
(0, import_jquery3.default)(document.documentElement).addClass("qt5");
|
||||
}
|
||||
@@ -3759,7 +3762,7 @@
|
||||
}, {
|
||||
key: "getId",
|
||||
value: function getId(el) {
|
||||
return el["data-input-id"] || el.id;
|
||||
return el.getAttribute("data-input-id") || el.id;
|
||||
}
|
||||
}, {
|
||||
key: "getType",
|
||||
@@ -8037,7 +8040,7 @@
|
||||
}, {
|
||||
key: "getId",
|
||||
value: function getId(el) {
|
||||
return el["data-input-id"] || el.id;
|
||||
return el.getAttribute("data-input-id") || el.id;
|
||||
}
|
||||
}, {
|
||||
key: "onValueChange",
|
||||
@@ -8822,29 +8825,53 @@
|
||||
var import_es_array_iterator20 = __toModule(require_es_array_iterator());
|
||||
var import_jquery28 = __toModule(require_jquery());
|
||||
|
||||
// srcts/src/shiny/render.ts
|
||||
var import_es_regexp_exec6 = __toModule(require_es_regexp_exec());
|
||||
// node_modules/core-js/modules/es.array.for-each.js
|
||||
"use strict";
|
||||
var $45 = require_export();
|
||||
var forEach = require_array_for_each();
|
||||
$45({ target: "Array", proto: true, forced: [].forEach != forEach }, {
|
||||
forEach: forEach
|
||||
});
|
||||
|
||||
// node_modules/core-js/modules/web.dom-collections.for-each.js
|
||||
var global6 = require_global();
|
||||
var DOMIterables2 = require_dom_iterables();
|
||||
var forEach2 = require_array_for_each();
|
||||
var createNonEnumerableProperty3 = require_create_non_enumerable_property();
|
||||
for (var COLLECTION_NAME in DOMIterables2) {
|
||||
Collection = global6[COLLECTION_NAME];
|
||||
CollectionPrototype = Collection && Collection.prototype;
|
||||
if (CollectionPrototype && CollectionPrototype.forEach !== forEach2)
|
||||
try {
|
||||
createNonEnumerableProperty3(CollectionPrototype, "forEach", forEach2);
|
||||
} catch (error) {
|
||||
CollectionPrototype.forEach = forEach2;
|
||||
}
|
||||
}
|
||||
var Collection;
|
||||
var CollectionPrototype;
|
||||
|
||||
// node_modules/core-js/modules/es.object.entries.js
|
||||
var $45 = require_export();
|
||||
var $46 = require_export();
|
||||
var $entries = require_object_to_array().entries;
|
||||
$45({ target: "Object", stat: true }, {
|
||||
$46({ target: "Object", stat: true }, {
|
||||
entries: function entries(O) {
|
||||
return $entries(O);
|
||||
}
|
||||
});
|
||||
|
||||
// srcts/src/shiny/render.ts
|
||||
var import_es_regexp_exec6 = __toModule(require_es_regexp_exec());
|
||||
var import_es_array_iterator19 = __toModule(require_es_array_iterator());
|
||||
|
||||
// node_modules/core-js/modules/es.array.from.js
|
||||
var $46 = require_export();
|
||||
var $47 = require_export();
|
||||
var from = require_array_from();
|
||||
var checkCorrectnessOfIteration = require_check_correctness_of_iteration();
|
||||
var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function(iterable) {
|
||||
Array.from(iterable);
|
||||
});
|
||||
$46({ target: "Array", stat: true, forced: INCORRECT_ITERATION }, {
|
||||
$47({ target: "Array", stat: true, forced: INCORRECT_ITERATION }, {
|
||||
from: from
|
||||
});
|
||||
|
||||
@@ -9061,9 +9088,7 @@
|
||||
}
|
||||
function renderDependencies(dependencies) {
|
||||
if (dependencies) {
|
||||
import_jquery27.default.each(dependencies, function(i, dep) {
|
||||
renderDependency(dep);
|
||||
});
|
||||
dependencies.forEach(renderDependency);
|
||||
}
|
||||
}
|
||||
function renderContent(el, content) {
|
||||
@@ -9071,7 +9096,7 @@
|
||||
if (where === "replace") {
|
||||
shinyUnbindAll(el);
|
||||
}
|
||||
var html;
|
||||
var html = "";
|
||||
var dependencies = [];
|
||||
if (content === null) {
|
||||
html = "";
|
||||
@@ -9120,128 +9145,208 @@
|
||||
}
|
||||
return htmlDependencies[names[idx]] === dep.version;
|
||||
}
|
||||
function renderDependency(dep) {
|
||||
var restyle = needsRestyle(dep);
|
||||
if (hasOwnProperty(htmlDependencies, dep.name) && !restyle)
|
||||
function renderDependency(dep_) {
|
||||
var dep = normalizeHtmlDependency(dep_);
|
||||
var stylesheetLinks = dep.stylesheet.map(function(x) {
|
||||
if (!hasOwnProperty(x, "rel"))
|
||||
x.rel = "stylesheet";
|
||||
if (!hasOwnProperty(x, "type"))
|
||||
x.type = "text/css";
|
||||
var link = document.createElement("link");
|
||||
Object.entries(x).forEach(function(_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 2), attr = _ref2[0], val = _ref2[1];
|
||||
if (attr === "href") {
|
||||
val = encodeURI(val);
|
||||
}
|
||||
link.setAttribute(attr, val ? val : "");
|
||||
});
|
||||
return link;
|
||||
});
|
||||
if (needsRestyle(dep)) {
|
||||
addStylesheetsAndRestyle(stylesheetLinks);
|
||||
return true;
|
||||
}
|
||||
if (hasOwnProperty(htmlDependencies, dep.name))
|
||||
return false;
|
||||
registerDependency(dep.name, dep.version);
|
||||
var href = dep.src.href;
|
||||
var $head = (0, import_jquery27.default)("head").first();
|
||||
if (dep.meta && !restyle) {
|
||||
var metas = import_jquery27.default.map(asArray(dep.meta), function(obj, idx) {
|
||||
var name = Object.keys(obj)[0];
|
||||
return (0, import_jquery27.default)("<meta>").attr("name", name).attr("content", obj[name]);
|
||||
idx;
|
||||
});
|
||||
$head.append(metas);
|
||||
}
|
||||
if (dep.stylesheet) {
|
||||
var links = import_jquery27.default.map(asArray(dep.stylesheet), function(stylesheet) {
|
||||
return (0, import_jquery27.default)("<link rel='stylesheet' type='text/css'>").attr("href", href + "/" + encodeURI(stylesheet));
|
||||
});
|
||||
if (!restyle) {
|
||||
$head.append(links);
|
||||
} else {
|
||||
var refreshStyle = function refreshStyle2(href2, oldSheet) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", href2);
|
||||
xhr.onload = function() {
|
||||
var id = "shiny_restyle_" + href2.split("?restyle")[0].replace(/\W/g, "_");
|
||||
var oldStyle = $head.find("style#" + id);
|
||||
var newStyle = (0, import_jquery27.default)("<style>").attr("id", id).html(xhr.responseText);
|
||||
$head.append(newStyle);
|
||||
oldStyle.remove();
|
||||
removeSheet(oldSheet);
|
||||
sendImageSizeFns.transitioned();
|
||||
};
|
||||
xhr.send();
|
||||
};
|
||||
var findSheet = function findSheet2(href2) {
|
||||
for (var i = 0; i < document.styleSheets.length; i++) {
|
||||
var sheet = document.styleSheets[i];
|
||||
if (typeof sheet.href === "string" && sheet.href.indexOf(href2) > -1) {
|
||||
return sheet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
var removeSheet = function removeSheet2(sheet) {
|
||||
if (!sheet)
|
||||
return;
|
||||
sheet.disabled = true;
|
||||
if (isIE())
|
||||
sheet.cssText = "";
|
||||
(0, import_jquery27.default)(sheet.ownerNode).remove();
|
||||
};
|
||||
import_jquery27.default.map(links, function(link) {
|
||||
var oldSheet = findSheet(link.attr("href"));
|
||||
var href2 = link.attr("href") + "?restyle=" + new Date().getTime();
|
||||
if (isIE()) {
|
||||
refreshStyle(href2, oldSheet);
|
||||
} else {
|
||||
link.attr("href", href2);
|
||||
link.attr("onload", function() {
|
||||
var $dummyEl = (0, import_jquery27.default)("<div>").css("transition", "0.1s all").css("position", "absolute").css("top", "-1000px").css("left", "0");
|
||||
$dummyEl.one("transitionend", function() {
|
||||
$dummyEl.remove();
|
||||
removeSheet(oldSheet);
|
||||
sendImageSizeFns.transitioned();
|
||||
});
|
||||
(0, import_jquery27.default)(document.body).append($dummyEl);
|
||||
var color = "#" + Math.floor(Math.random() * 16777215).toString(16);
|
||||
setTimeout(function() {
|
||||
return $dummyEl.css("color", color);
|
||||
}, 10);
|
||||
});
|
||||
$head.append(link);
|
||||
}
|
||||
});
|
||||
dep.meta.forEach(function(x) {
|
||||
var meta = document.createElement("meta");
|
||||
for (var _i2 = 0, _Object$entries = Object.entries(x); _i2 < _Object$entries.length; _i2++) {
|
||||
var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2), attr = _Object$entries$_i[0], val = _Object$entries$_i[1];
|
||||
meta.setAttribute(attr, val);
|
||||
}
|
||||
$head.append(meta);
|
||||
});
|
||||
if (stylesheetLinks.length !== 0) {
|
||||
$head.append(stylesheetLinks);
|
||||
}
|
||||
if (dep.script && !restyle) {
|
||||
var scriptsAttrs = asArray(dep.script);
|
||||
var scripts = import_jquery27.default.map(scriptsAttrs, function(x) {
|
||||
var script = document.createElement("script");
|
||||
if (typeof x === "string") {
|
||||
x = {
|
||||
src: x
|
||||
};
|
||||
dep.script.forEach(function(x) {
|
||||
var script = document.createElement("script");
|
||||
Object.entries(x).forEach(function(_ref3) {
|
||||
var _ref4 = _slicedToArray(_ref3, 2), attr = _ref4[0], val = _ref4[1];
|
||||
if (attr === "src") {
|
||||
val = encodeURI(val);
|
||||
}
|
||||
for (var _i = 0, _Object$entries = Object.entries(x); _i < _Object$entries.length; _i++) {
|
||||
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), attr = _Object$entries$_i[0], val = _Object$entries$_i[1];
|
||||
if (attr === "src") {
|
||||
val = href + "/" + encodeURI(val);
|
||||
}
|
||||
script.setAttribute(attr, val ? val : "");
|
||||
}
|
||||
return script;
|
||||
script.setAttribute(attr, val ? val : "");
|
||||
});
|
||||
$head.append(scripts);
|
||||
}
|
||||
if (dep.attachment && !restyle) {
|
||||
var attachments = dep.attachment;
|
||||
if (typeof attachments === "string")
|
||||
attachments = [attachments];
|
||||
if (Array.isArray(attachments)) {
|
||||
var tmp = {};
|
||||
import_jquery27.default.each(attachments, function(index, attachment) {
|
||||
var key = index + 1 + "";
|
||||
tmp[key] = attachment;
|
||||
});
|
||||
attachments = tmp;
|
||||
}
|
||||
var attach = import_jquery27.default.map(attachments, function(attachment, key) {
|
||||
return (0, import_jquery27.default)("<link rel='attachment'>").attr("id", dep.name + "-" + key + "-attachment").attr("href", href + "/" + encodeURI(attachment));
|
||||
});
|
||||
$head.append(attach);
|
||||
}
|
||||
if (dep.head && !restyle) {
|
||||
$head.append(script);
|
||||
});
|
||||
dep.attachment.forEach(function(x) {
|
||||
var link = (0, import_jquery27.default)("<link rel='attachment'>").attr("id", dep.name + "-" + x.key + "-attachment").attr("href", encodeURI(x.href));
|
||||
$head.append(link);
|
||||
});
|
||||
if (dep.head) {
|
||||
var $newHead = (0, import_jquery27.default)("<head></head>");
|
||||
$newHead.html(dep.head);
|
||||
$head.append($newHead.children());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function addStylesheetsAndRestyle(links) {
|
||||
var $head = (0, import_jquery27.default)("head").first();
|
||||
var refreshStyle = function refreshStyle2(href, oldSheet) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", href);
|
||||
xhr.onload = function() {
|
||||
var id = "shiny_restyle_" + href.split("?restyle")[0].replace(/\W/g, "_");
|
||||
var oldStyle = $head.find("style#" + id);
|
||||
var newStyle = (0, import_jquery27.default)("<style>").attr("id", id).html(xhr.responseText);
|
||||
$head.append(newStyle);
|
||||
oldStyle.remove();
|
||||
removeSheet(oldSheet);
|
||||
sendImageSizeFns.transitioned();
|
||||
};
|
||||
xhr.send();
|
||||
};
|
||||
var findSheet = function findSheet2(href) {
|
||||
if (!href)
|
||||
return null;
|
||||
for (var i = 0; i < document.styleSheets.length; i++) {
|
||||
var sheet = document.styleSheets[i];
|
||||
if (typeof sheet.href === "string" && sheet.href.indexOf(href) > -1) {
|
||||
return sheet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
var removeSheet = function removeSheet2(sheet) {
|
||||
if (!sheet)
|
||||
return;
|
||||
sheet.disabled = true;
|
||||
if (isIE())
|
||||
sheet.cssText = "";
|
||||
if (sheet.ownerNode instanceof Element) {
|
||||
(0, import_jquery27.default)(sheet.ownerNode).remove();
|
||||
}
|
||||
};
|
||||
links.map(function(link) {
|
||||
var $link = (0, import_jquery27.default)(link);
|
||||
var oldSheet = findSheet($link.attr("href"));
|
||||
var href = $link.attr("href") + "?restyle=" + new Date().getTime();
|
||||
if (isIE()) {
|
||||
refreshStyle(href, oldSheet);
|
||||
} else {
|
||||
$link.attr("href", href);
|
||||
$link.attr("onload", function() {
|
||||
var $dummyEl = (0, import_jquery27.default)("<div>").css("transition", "0.1s all").css("position", "absolute").css("top", "-1000px").css("left", "0");
|
||||
$dummyEl.one("transitionend", function() {
|
||||
$dummyEl.remove();
|
||||
removeSheet(oldSheet);
|
||||
sendImageSizeFns.transitioned();
|
||||
});
|
||||
(0, import_jquery27.default)(document.body).append($dummyEl);
|
||||
var color = "#" + Math.floor(Math.random() * 16777215).toString(16);
|
||||
setTimeout(function() {
|
||||
return $dummyEl.css("color", color);
|
||||
}, 10);
|
||||
});
|
||||
$head.append(link);
|
||||
}
|
||||
});
|
||||
}
|
||||
function normalizeHtmlDependency(dep) {
|
||||
var _dep$src;
|
||||
var hrefPrefix = (_dep$src = dep.src) === null || _dep$src === void 0 ? void 0 : _dep$src.href;
|
||||
var result = {
|
||||
name: dep.name,
|
||||
version: dep.version,
|
||||
restyle: dep.restyle,
|
||||
meta: [],
|
||||
stylesheet: [],
|
||||
script: [],
|
||||
attachment: [],
|
||||
head: dep.head
|
||||
};
|
||||
if (dep.meta) {
|
||||
if (Array.isArray(dep.meta)) {
|
||||
result.meta = dep.meta;
|
||||
} else {
|
||||
result.meta = Object.entries(dep.meta).map(function(_ref5) {
|
||||
var _ref6 = _slicedToArray(_ref5, 2), attr = _ref6[0], val = _ref6[1];
|
||||
return {
|
||||
name: attr,
|
||||
content: val
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
result.stylesheet = asArray(dep.stylesheet).map(function(s) {
|
||||
if (typeof s === "string") {
|
||||
s = {
|
||||
href: s
|
||||
};
|
||||
}
|
||||
if (hrefPrefix) {
|
||||
s.href = hrefPrefix + "/" + s.href;
|
||||
}
|
||||
return s;
|
||||
});
|
||||
result.script = asArray(dep.script).map(function(s) {
|
||||
if (typeof s === "string") {
|
||||
s = {
|
||||
src: s
|
||||
};
|
||||
}
|
||||
if (hrefPrefix) {
|
||||
s.src = hrefPrefix + "/" + s.src;
|
||||
}
|
||||
return s;
|
||||
});
|
||||
var attachments = dep.attachment;
|
||||
if (!attachments)
|
||||
attachments = [];
|
||||
if (typeof attachments === "string")
|
||||
attachments = [attachments];
|
||||
if (Array.isArray(attachments)) {
|
||||
var tmp = attachments;
|
||||
attachments = tmp.map(function(attachment, index) {
|
||||
if (typeof attachment === "string") {
|
||||
return {
|
||||
key: (index + 1).toString(),
|
||||
href: attachment
|
||||
};
|
||||
} else {
|
||||
return attachment;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
attachments = Object.entries(attachments).map(function(_ref7) {
|
||||
var _ref8 = _slicedToArray(_ref7, 2), attr = _ref8[0], val = _ref8[1];
|
||||
return {
|
||||
key: attr,
|
||||
href: val
|
||||
};
|
||||
});
|
||||
}
|
||||
result.attachment = attachments.map(function(s) {
|
||||
if (hrefPrefix) {
|
||||
s.href = hrefPrefix + "/" + s.href;
|
||||
}
|
||||
return s;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// srcts/src/bindings/output/html.ts
|
||||
function _typeof20(obj) {
|
||||
@@ -9369,11 +9474,11 @@
|
||||
|
||||
// node_modules/core-js/modules/es.array.filter.js
|
||||
"use strict";
|
||||
var $50 = require_export();
|
||||
var $51 = require_export();
|
||||
var $filter = require_array_iteration().filter;
|
||||
var arrayMethodHasSpeciesSupport5 = require_array_method_has_species_support();
|
||||
var HAS_SPECIES_SUPPORT4 = arrayMethodHasSpeciesSupport5("filter");
|
||||
$50({ target: "Array", proto: true, forced: !HAS_SPECIES_SUPPORT4 }, {
|
||||
$51({ target: "Array", proto: true, forced: !HAS_SPECIES_SUPPORT4 }, {
|
||||
filter: function filter(callbackfn) {
|
||||
return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : void 0);
|
||||
}
|
||||
@@ -11937,21 +12042,21 @@
|
||||
|
||||
// node_modules/core-js/modules/es.array-buffer.constructor.js
|
||||
"use strict";
|
||||
var $63 = require_export();
|
||||
var global6 = require_global();
|
||||
var $64 = require_export();
|
||||
var global7 = require_global();
|
||||
var arrayBufferModule = require_array_buffer();
|
||||
var setSpecies = require_set_species();
|
||||
var ARRAY_BUFFER = "ArrayBuffer";
|
||||
var ArrayBuffer2 = arrayBufferModule[ARRAY_BUFFER];
|
||||
var NativeArrayBuffer = global6[ARRAY_BUFFER];
|
||||
$63({ global: true, forced: NativeArrayBuffer !== ArrayBuffer2 }, {
|
||||
var NativeArrayBuffer = global7[ARRAY_BUFFER];
|
||||
$64({ global: true, forced: NativeArrayBuffer !== ArrayBuffer2 }, {
|
||||
ArrayBuffer: ArrayBuffer2
|
||||
});
|
||||
setSpecies(ARRAY_BUFFER);
|
||||
|
||||
// node_modules/core-js/modules/es.array-buffer.slice.js
|
||||
"use strict";
|
||||
var $64 = require_export();
|
||||
var $65 = require_export();
|
||||
var fails10 = require_fails();
|
||||
var ArrayBufferModule = require_array_buffer();
|
||||
var anObject9 = require_an_object();
|
||||
@@ -11964,7 +12069,7 @@
|
||||
var INCORRECT_SLICE = fails10(function() {
|
||||
return !new ArrayBuffer3(2).slice(1, void 0).byteLength;
|
||||
});
|
||||
$64({ target: "ArrayBuffer", proto: true, unsafe: true, forced: INCORRECT_SLICE }, {
|
||||
$65({ target: "ArrayBuffer", proto: true, unsafe: true, forced: INCORRECT_SLICE }, {
|
||||
slice: function slice2(start, end) {
|
||||
if (nativeArrayBufferSlice !== void 0 && end === void 0) {
|
||||
return nativeArrayBufferSlice.call(anObject9(this), start);
|
||||
@@ -11984,23 +12089,23 @@
|
||||
});
|
||||
|
||||
// node_modules/core-js/modules/es.data-view.js
|
||||
var $65 = require_export();
|
||||
var $66 = require_export();
|
||||
var ArrayBufferModule2 = require_array_buffer();
|
||||
var NATIVE_ARRAY_BUFFER = require_array_buffer_native();
|
||||
$65({ global: true, forced: !NATIVE_ARRAY_BUFFER }, {
|
||||
$66({ global: true, forced: !NATIVE_ARRAY_BUFFER }, {
|
||||
DataView: ArrayBufferModule2.DataView
|
||||
});
|
||||
|
||||
// node_modules/core-js/modules/es.array.reduce.js
|
||||
"use strict";
|
||||
var $66 = require_export();
|
||||
var $67 = require_export();
|
||||
var $reduce = require_array_reduce().left;
|
||||
var arrayMethodIsStrict3 = require_array_method_is_strict();
|
||||
var CHROME_VERSION = require_engine_v8_version();
|
||||
var IS_NODE = require_engine_is_node();
|
||||
var STRICT_METHOD3 = arrayMethodIsStrict3("reduce");
|
||||
var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
|
||||
$66({ target: "Array", proto: true, forced: !STRICT_METHOD3 || CHROME_BUG }, {
|
||||
$67({ target: "Array", proto: true, forced: !STRICT_METHOD3 || CHROME_BUG }, {
|
||||
reduce: function reduce(callbackfn) {
|
||||
return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : void 0);
|
||||
}
|
||||
@@ -12008,34 +12113,6 @@
|
||||
|
||||
// srcts/src/shiny/shinyapp.ts
|
||||
var import_es_regexp_exec9 = __toModule(require_es_regexp_exec());
|
||||
|
||||
// node_modules/core-js/modules/es.array.for-each.js
|
||||
"use strict";
|
||||
var $67 = require_export();
|
||||
var forEach = require_array_for_each();
|
||||
$67({ target: "Array", proto: true, forced: [].forEach != forEach }, {
|
||||
forEach: forEach
|
||||
});
|
||||
|
||||
// node_modules/core-js/modules/web.dom-collections.for-each.js
|
||||
var global7 = require_global();
|
||||
var DOMIterables2 = require_dom_iterables();
|
||||
var forEach2 = require_array_for_each();
|
||||
var createNonEnumerableProperty3 = require_create_non_enumerable_property();
|
||||
for (var COLLECTION_NAME in DOMIterables2) {
|
||||
Collection = global7[COLLECTION_NAME];
|
||||
CollectionPrototype = Collection && Collection.prototype;
|
||||
if (CollectionPrototype && CollectionPrototype.forEach !== forEach2)
|
||||
try {
|
||||
createNonEnumerableProperty3(CollectionPrototype, "forEach", forEach2);
|
||||
} catch (error) {
|
||||
CollectionPrototype.forEach = forEach2;
|
||||
}
|
||||
}
|
||||
var Collection;
|
||||
var CollectionPrototype;
|
||||
|
||||
// srcts/src/shiny/shinyapp.ts
|
||||
var import_jquery41 = __toModule(require_jquery());
|
||||
function _classCallCheck36(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
@@ -12815,8 +12892,8 @@
|
||||
}
|
||||
function getTabIndex($tabset2, tabsetId2) {
|
||||
var existingTabIds = [0];
|
||||
$tabset2.find("a[data-toggle='tab']").each(function() {
|
||||
var $tab = (0, import_jquery41.default)(this);
|
||||
$tabset2.find("> li").each(function() {
|
||||
var $tab = (0, import_jquery41.default)(this).find("> a[data-toggle='tab']");
|
||||
if ($tab.length > 0) {
|
||||
var href = $tab.attr("href").replace(/.*(?=#[^\s]+$)/, "");
|
||||
var _index = href.replace("#tab-" + tabsetId2 + "-", "");
|
||||
@@ -13245,7 +13322,6 @@
|
||||
(0, import_jquery42.default)(document).one("shiny:connected", function() {
|
||||
initDeferredIframes();
|
||||
});
|
||||
window.console.log("Shiny version: ", windowShiny3.version);
|
||||
}
|
||||
function initDeferredIframes() {
|
||||
if (!window.Shiny || !window.Shiny.shinyapp || !window.Shiny.shinyapp.isConnected()) {
|
||||
@@ -13263,7 +13339,7 @@
|
||||
var windowShiny2;
|
||||
function setShiny(windowShiny_) {
|
||||
windowShiny2 = windowShiny_;
|
||||
windowShiny2.version = "1.6.0.9021";
|
||||
windowShiny2.version = "1.7.1.9002";
|
||||
var _initInputBindings = initInputBindings(), inputBindings = _initInputBindings.inputBindings, fileInputBinding2 = _initInputBindings.fileInputBinding;
|
||||
var _initOutputBindings = initOutputBindings(), outputBindings = _initOutputBindings.outputBindings;
|
||||
setFileInputBinding(fileInputBinding2);
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
inst/www/shared/shiny.min.css
vendored
4
inst/www/shared/shiny.min.css
vendored
File diff suppressed because one or more lines are too long
4
inst/www/shared/shiny.min.js
vendored
4
inst/www/shared/shiny.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -295,6 +295,15 @@ pre.shiny-text-output {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
/* Workaround for radio buttons and checkboxes not showing on Qt on Mac.
|
||||
This occurs in the RStudio IDE on macOS 11.5.
|
||||
https://github.com/rstudio/shiny/issues/3484
|
||||
*/
|
||||
.qtmac input[type="radio"],
|
||||
.qtmac input[type="checkbox"] {
|
||||
zoom: 1.0000001;
|
||||
}
|
||||
|
||||
/* consistency with bootstrap.css for selectize.js */
|
||||
.selectize-control {
|
||||
margin-bottom: 10px;
|
||||
|
||||
6
man-roxygen/param-env.R
Normal file
6
man-roxygen/param-env.R
Normal file
@@ -0,0 +1,6 @@
|
||||
# Also update observeEvent param descriptions!
|
||||
# https://github.com/r-lib/roxygen2/issues/1241
|
||||
#' @param <%= env %> The parent environment for the reactive expression. By default,
|
||||
#' this is the calling environment, the same as when defining an ordinary
|
||||
#' non-reactive expression. If `<%= x %>` is a quosure and `<%= quoted %>` is `TRUE`,
|
||||
#' then `<%= env %>` is ignored.
|
||||
6
man-roxygen/param-quoted.R
Normal file
6
man-roxygen/param-quoted.R
Normal file
@@ -0,0 +1,6 @@
|
||||
# Also update observeEvent param descriptions!
|
||||
# https://github.com/r-lib/roxygen2/issues/1241
|
||||
#' @param <%= quoted %> If it is `TRUE`, then the [`quote()`]ed value of `<%= x %>`
|
||||
#' will be used when `<%= x %>` is evaluated. If `<%= x %>` is a quosure and you
|
||||
#' would like to use its expression as a value for `<%= x %>`, then you must set
|
||||
#' `<%= quoted %>` to `TRUE`.
|
||||
@@ -40,7 +40,7 @@ sense, namely:
|
||||
|
||||
In the example here, the \code{bindCache()} key consists of \code{input$x} and
|
||||
\code{input$y} combined, and the value is \code{input$x * input$y}. In this simple
|
||||
example, for any given key, there is only one possible returned value.\if{html}{\out{<div class="NA">}}\preformatted{r <- reactive(\{ input$x * input$y \}) \%>\%
|
||||
example, for any given key, there is only one possible returned value.\if{html}{\out{<div class="sourceCode NA">}}\preformatted{r <- reactive(\{ input$x * input$y \}) \%>\%
|
||||
bindCache(input$x, input$y)
|
||||
}\if{html}{\out{</div>}}
|
||||
|
||||
@@ -63,7 +63,7 @@ to do some sort of reduction on the data that still captures information
|
||||
about whether a value can be retrieved from the cache. For example, if you
|
||||
have a large data set with timestamps, it might make sense to extract the
|
||||
most recent timestamp and return that. Then, instead of hashing the entire
|
||||
data object, the cached reactive only needs to hash the timestamp.\if{html}{\out{<div class="NA">}}\preformatted{r <- reactive(\{ compute(bigdata()) \} \%>\%
|
||||
data object, the cached reactive only needs to hash the timestamp.\if{html}{\out{<div class="sourceCode NA">}}\preformatted{r <- reactive(\{ compute(bigdata()) \} \%>\%
|
||||
bindCache(\{ extract_most_recent_time(bigdata()) \})
|
||||
}\if{html}{\out{</div>}}
|
||||
|
||||
@@ -105,7 +105,7 @@ cache key is not too expensive.
|
||||
Remember that the key is \emph{reactive}, so it is not re-executed every single
|
||||
time that someone accesses the cached reactive. It is only re-executed if
|
||||
it has been invalidated by one of the reactives it depends on. For
|
||||
example, suppose we have this cached reactive:\if{html}{\out{<div class="NA">}}\preformatted{r <- reactive(\{ input$x * input$y \}) \%>\%
|
||||
example, suppose we have this cached reactive:\if{html}{\out{<div class="sourceCode NA">}}\preformatted{r <- reactive(\{ input$x * input$y \}) \%>\%
|
||||
bindCache(input$x, input$y)
|
||||
}\if{html}{\out{</div>}}
|
||||
|
||||
@@ -244,7 +244,7 @@ cache collisions, dealing with internal state that may be set by the,
|
||||
the cache.
|
||||
|
||||
You may need to provide a \code{cacheHint} to \code{\link[=createRenderFunction]{createRenderFunction()}} (or
|
||||
\code{\link[htmlwidgets:htmlwidgets-shiny]{htmlwidgets::shinyRenderWidget()}}, if you've authored an htmlwidget) in
|
||||
\code{htmlwidgets::shinyRenderWidget()}, if you've authored an htmlwidget) in
|
||||
order for \code{bindCache()} to correctly compute a cache key.
|
||||
|
||||
The potential problem is a cache collision. Consider the following:\preformatted{output$x1 <- renderText(\{ input$x \}) \%>\% bindCache(input$x)
|
||||
@@ -258,7 +258,7 @@ this, a \emph{cache hint} is automatically added when \code{\link[=renderText]{r
|
||||
\code{\link[=createRenderFunction]{createRenderFunction()}}. The cache hint is used as part of the actual
|
||||
cache key, in addition to the one passed to \code{bindCache()} by the user. The
|
||||
cache hint can be viewed by calling the internal Shiny function
|
||||
\code{extractCacheHint()}:\if{html}{\out{<div class="NA">}}\preformatted{r <- renderText(\{ input$x \})
|
||||
\code{extractCacheHint()}:\if{html}{\out{<div class="sourceCode NA">}}\preformatted{r <- renderText(\{ input$x \})
|
||||
shiny:::extractCacheHint(r)
|
||||
}\if{html}{\out{</div>}}
|
||||
|
||||
@@ -275,11 +275,11 @@ render function for cache collisions in a real application.
|
||||
In some cases, however, the automatic cache hint inference is not
|
||||
sufficient, and it is necessary to provide a cache hint. This is true
|
||||
for \code{renderPrint()}. Unlike \code{renderText()}, it wraps the user-provided
|
||||
expression in another function, before passing it to \code{\link[=markRenderFunction]{markRenderFunction()}}
|
||||
expression in another function, before passing it to \code{\link[=createRenderFunction]{createRenderFunction()}}
|
||||
(instead of \code{\link[=createRenderFunction]{createRenderFunction()}}). Because the user code is wrapped in
|
||||
another function, \code{markRenderFunction()} is not able to automatically
|
||||
another function, \code{createRenderFunction()} is not able to automatically
|
||||
extract the user-provided code and use it in the cache key. Instead,
|
||||
\code{renderPrint} calls \code{markRenderFunction()}, it explicitly passes along a
|
||||
\code{renderPrint} calls \code{createRenderFunction()}, it explicitly passes along a
|
||||
\code{cacheHint}, which includes a label and the original user expression.
|
||||
|
||||
In general, if you need to provide a \code{cacheHint}, it is best practice to
|
||||
@@ -290,19 +290,19 @@ For \pkg{htmlwidgets}, it will try to automatically infer a cache hint;
|
||||
again, you can inspect the cache hint with \code{shiny:::extractCacheHint()} and
|
||||
also test it in an application. If you do need to explicitly provide a
|
||||
cache hint, pass it to \code{shinyRenderWidget}. For example:\preformatted{renderMyWidget <- function(expr) \{
|
||||
expr <- substitute(expr)
|
||||
q <- rlang::enquo0(expr)
|
||||
|
||||
htmlwidgets::shinyRenderWidget(expr,
|
||||
htmlwidgets::shinyRenderWidget(
|
||||
q,
|
||||
myWidgetOutput,
|
||||
quoted = TRUE,
|
||||
env = parent.frame(),
|
||||
cacheHint = list(label = "myWidget", userExpr = expr)
|
||||
cacheHint = list(label = "myWidget", userQuo = q)
|
||||
)
|
||||
\}
|
||||
}
|
||||
|
||||
If your \code{render} function sets any internal state, you may find it useful
|
||||
in your call to \code{\link[=createRenderFunction]{createRenderFunction()}} or \code{\link[=markRenderFunction]{markRenderFunction()}} to use
|
||||
in your call to \code{\link[=createRenderFunction]{createRenderFunction()}} to use
|
||||
the \code{cacheWriteHook} and/or \code{cacheReadHook} parameters. These hooks are
|
||||
functions that run just before the object is stored in the cache, and just
|
||||
after the object is retrieved from the cache. They can modify the data
|
||||
@@ -321,8 +321,8 @@ Some render functions cannot be cached, typically because they have side
|
||||
effects or modify some external state, and they must re-execute each time
|
||||
in order to work properly.
|
||||
|
||||
For developers of such code, they should call \code{\link[=createRenderFunction]{createRenderFunction()}} or
|
||||
\code{\link[=markRenderFunction]{markRenderFunction()}} with \code{cacheHint = FALSE}.
|
||||
For developers of such code, they should call \code{\link[=createRenderFunction]{createRenderFunction()}} (or
|
||||
\code{\link[=markRenderFunction]{markRenderFunction()}}) with \code{cacheHint = FALSE}.
|
||||
}
|
||||
|
||||
\section{Caching with \code{renderPlot()}}{
|
||||
|
||||
@@ -171,7 +171,7 @@ user sets both \code{x} and \code{y}, and then clicks on an \link{actionButton}
|
||||
\code{go}.
|
||||
|
||||
To use both caching and events, the object should first be passed to
|
||||
\code{bindCache()}, then \code{bindEvent()}. For example:\if{html}{\out{<div class="NA">}}\preformatted{r <- reactive(\{
|
||||
\code{bindCache()}, then \code{bindEvent()}. For example:\if{html}{\out{<div class="sourceCode NA">}}\preformatted{r <- reactive(\{
|
||||
Sys.sleep(2) # Pretend this is an expensive computation
|
||||
input$x * input$y
|
||||
\}) \%>\%
|
||||
|
||||
@@ -14,6 +14,7 @@ bootstrapLib(theme = NULL)
|
||||
build of Bootstrap 3 with a customized version of Bootstrap 3 or higher.
|
||||
\item A character string pointing to an alternative Bootstrap stylesheet
|
||||
(normally a css file within the www directory, e.g. \code{www/bootstrap.css}).
|
||||
This option is here mainly for legacy reasons.
|
||||
}}
|
||||
}
|
||||
\description{
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/bootstrap.R
|
||||
\name{bootstrapPage}
|
||||
% Please edit documentation in R/bootstrap-layout.R, R/bootstrap.R
|
||||
\name{fluidPage}
|
||||
\alias{fluidPage}
|
||||
\alias{fixedPage}
|
||||
\alias{bootstrapPage}
|
||||
\alias{basicPage}
|
||||
\title{Create a Bootstrap page}
|
||||
\title{Create a Bootstrap UI page container}
|
||||
\usage{
|
||||
fluidPage(..., title = NULL, theme = NULL, lang = NULL)
|
||||
|
||||
fixedPage(..., title = NULL, theme = NULL, lang = NULL)
|
||||
|
||||
bootstrapPage(..., title = NULL, theme = NULL, lang = NULL)
|
||||
|
||||
basicPage(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{The contents of the document body.}
|
||||
\item{...}{UI elements (i.e., \link{tags}).}
|
||||
|
||||
\item{title}{The browser window title (defaults to the host URL of the page)}
|
||||
\item{title}{The browser window title (defaults to the host URL of the page).
|
||||
Can also be set as a side effect of the \code{\link[=titlePanel]{titlePanel()}} function.}
|
||||
|
||||
\item{theme}{One of the following:
|
||||
\itemize{
|
||||
@@ -21,30 +28,74 @@ basicPage(...)
|
||||
build of Bootstrap 3 with a customized version of Bootstrap 3 or higher.
|
||||
\item A character string pointing to an alternative Bootstrap stylesheet
|
||||
(normally a css file within the www directory, e.g. \code{www/bootstrap.css}).
|
||||
This option is here mainly for legacy reasons.
|
||||
}}
|
||||
|
||||
\item{lang}{ISO 639-1 language code for the HTML page, such as "en" or "ko".
|
||||
This will be used as the lang in the \code{<html>} tag, as in \code{<html lang="en">}.
|
||||
This will be used as the lang in the \verb{<html>} tag, as in \verb{<html lang="en">}.
|
||||
The default (NULL) results in an empty string.}
|
||||
}
|
||||
\value{
|
||||
A UI defintion that can be passed to the \link{shinyUI} function.
|
||||
A UI definition (i.e., a \link{tags} object) that can be passed to \code{\link[=shinyApp]{shinyApp()}}.
|
||||
}
|
||||
\description{
|
||||
Create a Shiny UI page that loads the CSS and JavaScript for
|
||||
\href{https://getbootstrap.com/}{Bootstrap}, and has no content in the page
|
||||
body (other than what you provide).
|
||||
Create a user interface (UI) page container based on
|
||||
\href{https://getbootstrap.com/}{Bootstrap}'s CSS and JavaScript. Most Shiny apps
|
||||
should use \code{\link[=fluidPage]{fluidPage()}} (or \code{\link[=navbarPage]{navbarPage()}}) to get a page container with a
|
||||
responsive page width, but in some cases you may want a fixed width container
|
||||
(\code{fixedPage()}) or just a bare \verb{<body>} container (\code{bootstrapPage()}).
|
||||
|
||||
Most Shiny apps make use of other Shiny UI functions for \href{https://shiny.rstudio.com/articles/layout-guide.html}{managing layout} (e.g.,
|
||||
\code{\link[=sidebarLayout]{sidebarLayout()}}, \code{\link[=fluidRow]{fluidRow()}}, etc), navigation (e.g., \code{\link[=tabPanel]{tabPanel()}}), and
|
||||
other styling (e.g., \code{\link[=wellPanel]{wellPanel()}}, \code{\link[=inputPanel]{inputPanel()}}). A good portion of these
|
||||
Shiny UI functions require Bootstrap to work properly (so most Shiny apps
|
||||
should use these functions to start their UI definitions), but more advanced
|
||||
usage (i.e., custom HTML/CSS/JS) can avoid Bootstrap entirely by using
|
||||
\code{\link[=htmlTemplate]{htmlTemplate()}} and/or HTML \link{tags}.
|
||||
}
|
||||
\details{
|
||||
This function is primarily intended for users who are proficient in HTML/CSS,
|
||||
and know how to lay out pages in Bootstrap. Most applications should use
|
||||
\code{\link[=fluidPage]{fluidPage()}} along with layout functions like
|
||||
\code{\link[=fluidRow]{fluidRow()}} and \code{\link[=sidebarLayout]{sidebarLayout()}}.
|
||||
\examples{
|
||||
|
||||
# First create some UI content.
|
||||
# See the layout guide to learn more about creating different layouts
|
||||
# https://shiny.rstudio.com/articles/layout-guide.html
|
||||
ui <- sidebarLayout(
|
||||
sidebarPanel(sliderInput("obs", "Number of observations:", 0, 1000, 500)),
|
||||
mainPanel(plotOutput("distPlot"))
|
||||
)
|
||||
server <- function(input, output) {
|
||||
output$distPlot <- renderPlot(hist(rnorm(input$obs)))
|
||||
}
|
||||
\note{
|
||||
The \code{basicPage} function is deprecated, you should use the
|
||||
\code{\link[=fluidPage]{fluidPage()}} function instead.
|
||||
|
||||
# Demonstrating difference between fluidPage(), fixedPage(), bootstrapPage()
|
||||
if (interactive()) {
|
||||
# Container width scales _fluidly_ with window size
|
||||
shinyApp(fluidPage(ui), server)
|
||||
# Container width changes with window size at fixed breakpoints
|
||||
shinyApp(fixedPage(ui), server)
|
||||
# Container width is equal to the window's width
|
||||
shinyApp(bootstrapPage(ui), server)
|
||||
}
|
||||
|
||||
# The default look is provided by Bootstrap 3, but {bslib} can be
|
||||
# used to customize the Bootstrap version and its default styling
|
||||
theme <- bslib::bs_theme(
|
||||
version = 5,
|
||||
bg = "#101010",
|
||||
fg = "#FDF7F7",
|
||||
primary = "#ED79F9",
|
||||
base_font = bslib::font_google("Prompt"),
|
||||
code_font = bslib::font_google("JetBrains Mono")
|
||||
)
|
||||
if (interactive()) {
|
||||
# Call thematic::thematic_shiny(font = "auto") to automatically
|
||||
# translate the theme/CSS to the R plot
|
||||
shinyApp(
|
||||
fluidPage(ui, theme = theme, title = "Hello Bootstrap 5"),
|
||||
server
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=fluidPage]{fluidPage()}}, \code{\link[=fixedPage]{fixedPage()}}
|
||||
\code{\link[=navbarPage]{navbarPage()}}, \code{\link[=fillPage]{fillPage()}}, \code{\link[=column]{column()}}, \code{\link[=tabPanel]{tabPanel()}}
|
||||
}
|
||||
|
||||
@@ -49,4 +49,3 @@ These functions give control over the \code{click}, \code{dblClick} and
|
||||
\seealso{
|
||||
\code{\link[=brushOpts]{brushOpts()}} for brushing events.
|
||||
}
|
||||
\keyword{internal}
|
||||
|
||||
@@ -1,26 +1,45 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/bootstrap-layout.R
|
||||
\name{column}
|
||||
\name{fluidRow}
|
||||
\alias{fluidRow}
|
||||
\alias{fixedRow}
|
||||
\alias{column}
|
||||
\title{Create a column within a UI definition}
|
||||
\title{Responsive row-column based layout}
|
||||
\usage{
|
||||
fluidRow(...)
|
||||
|
||||
fixedRow(...)
|
||||
|
||||
column(width, ..., offset = 0)
|
||||
}
|
||||
\arguments{
|
||||
\item{width}{The grid width of the column (must be between 1 and 12)}
|
||||
\item{...}{UI elements (i.e., \link{tags}). For \code{fluidRow()}, \code{...} should be a set of \code{column()}s.}
|
||||
|
||||
\item{...}{Elements to include within the column}
|
||||
\item{width}{The grid width of the column (must be between 1 and 12). When
|
||||
the device width is small (e.g., the viewer is on a mobile phone), the
|
||||
width is always 12. For more control over these responsive breakpoints, use
|
||||
Bootstrap's grid system more directly (e.g., \code{fluidRow(div(class = "col-lg-2", ...))}).}
|
||||
|
||||
\item{offset}{The number of columns to offset this column from the end of the
|
||||
previous column.}
|
||||
}
|
||||
\value{
|
||||
A column that can be included within a
|
||||
\code{\link[=fluidRow]{fluidRow()}} or \code{\link[=fixedRow]{fixedRow()}}.
|
||||
A UI element (i.e., \link{tags}).
|
||||
}
|
||||
\description{
|
||||
Create a column for use within a \code{\link[=fluidRow]{fluidRow()}} or
|
||||
\code{\link[=fixedRow]{fixedRow()}}
|
||||
Layout UI components using Bootstrap's grid layout system. Use
|
||||
\code{fluidRow()} to group elements that should appear on the same line (if the
|
||||
browser has adequate width) and \code{column()} to define how much horizontal
|
||||
space within a 12-unit wide grid each on of these elements should occupy. See
|
||||
the \href{https://shiny.rstudio.com/articles/layout-guide.html}{layout guide} for
|
||||
more context and examples.
|
||||
}
|
||||
\details{
|
||||
To work properly, these functions need \href{https://getbootstrap.com}{Bootstrap}
|
||||
included on the page. Since most Shiny apps use \code{\link[=bootstrapPage]{bootstrapPage()}}
|
||||
under-the-hood, this is usually the case, but custom page containers (i.e.,
|
||||
\code{\link[=htmlTemplate]{htmlTemplate()}}) may need to explicitly include \code{\link[=bootstrapLib]{bootstrapLib()}}
|
||||
dependencies.
|
||||
}
|
||||
\examples{
|
||||
## Only run examples in interactive R sessions
|
||||
@@ -46,21 +65,15 @@ server <- function(input, output) {
|
||||
|
||||
shinyApp(ui, server)
|
||||
|
||||
|
||||
|
||||
ui <- fluidPage(
|
||||
fluidRow(
|
||||
column(width = 4,
|
||||
"4"
|
||||
),
|
||||
column(width = 3, offset = 2,
|
||||
"3 offset 2"
|
||||
)
|
||||
column(width = 4, "4"),
|
||||
column(width = 3, offset = 2, "3 offset 2")
|
||||
)
|
||||
)
|
||||
shinyApp(ui, server = function(input, output) { })
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=fluidRow]{fluidRow()}}, \code{\link[=fixedRow]{fixedRow()}}.
|
||||
\code{\link[=fluidPage]{fluidPage()}}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/shinywrappers.R
|
||||
% Please edit documentation in R/shinywrappers.R, R/utils-lang.R
|
||||
\name{createRenderFunction}
|
||||
\alias{createRenderFunction}
|
||||
\title{Implement render functions}
|
||||
\alias{quoToFunction}
|
||||
\alias{installExprFunction}
|
||||
\title{Implement custom render functions}
|
||||
\usage{
|
||||
createRenderFunction(
|
||||
func,
|
||||
@@ -13,6 +15,19 @@ createRenderFunction(
|
||||
cacheWriteHook = NULL,
|
||||
cacheReadHook = NULL
|
||||
)
|
||||
|
||||
quoToFunction(q, label = sys.call(-1)[[1]], ..stacktraceon = FALSE)
|
||||
|
||||
installExprFunction(
|
||||
expr,
|
||||
name,
|
||||
eval.env = parent.frame(2),
|
||||
quoted = FALSE,
|
||||
assign.env = parent.frame(1),
|
||||
label = sys.call(-1)[[1]],
|
||||
wrappedWithLabel = TRUE,
|
||||
..stacktraceon = FALSE
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{func}{A function without parameters, that returns user data. If the
|
||||
@@ -55,23 +70,85 @@ argument, the value retrieved from the cache. This can be useful when some
|
||||
side effect needs to occur for a render function to behave correctly. For
|
||||
example, some render functions call \code{\link[=createWebDependency]{createWebDependency()}} so that Shiny
|
||||
is able to serve JS and CSS resources.}
|
||||
|
||||
\item{q}{Quosure of the expression \code{x}. When capturing expressions to create
|
||||
your quosure, it is recommended to use \code{\link[=enquo0]{enquo0()}} to not unquote the
|
||||
object too early. See \code{\link[=enquo0]{enquo0()}} for more details.}
|
||||
|
||||
\item{label}{A label for the object to be shown in the debugger. Defaults to
|
||||
the name of the calling function.}
|
||||
|
||||
\item{expr}{A quoted or unquoted expression, or a quosure.}
|
||||
|
||||
\item{name}{The name the function should be given}
|
||||
|
||||
\item{eval.env}{The desired environment for the function. Defaults to the
|
||||
calling environment two steps back.}
|
||||
|
||||
\item{quoted}{Is the expression quoted?}
|
||||
|
||||
\item{assign.env}{The environment in which the function should be assigned.}
|
||||
|
||||
\item{wrappedWithLabel, ..stacktraceon}{Advanced use only. For stack manipulation purposes; see
|
||||
\code{\link[=stacktrace]{stacktrace()}}.}
|
||||
}
|
||||
\value{
|
||||
An annotated render function, ready to be assigned to an
|
||||
\code{output} slot.
|
||||
}
|
||||
\description{
|
||||
This function is a wrapper for \code{\link[=markRenderFunction]{markRenderFunction()}} which provides support
|
||||
for async computation via promises.
|
||||
Developer-facing utilities for implementing a custom \code{renderXXX()} function.
|
||||
Before using these utilities directly, consider using the \href{http://www.htmlwidgets.org/develop_intro.html}{\code{htmlwidgets} package} to implement custom
|
||||
outputs (i.e., custom \code{renderXXX()}/\code{xxxOutput()} functions). That said,
|
||||
these utilities can be used more directly if a full-blown htmlwidget isn't
|
||||
needed and/or the user-supplied reactive expression needs to be wrapped in
|
||||
additional call(s).
|
||||
}
|
||||
\details{
|
||||
To implement a custom \code{renderXXX()} function, essentially 2 things are needed:
|
||||
\enumerate{
|
||||
\item Capture the user's reactive expression as a function.
|
||||
\itemize{
|
||||
\item New \code{renderXXX()} functions can use \code{quoToFunction()} for this, but
|
||||
already existing \code{renderXXX()} functions that contain \code{env} and \code{quoted}
|
||||
parameters may want to continue using \code{installExprFunction()} for better
|
||||
legacy support (see examples).
|
||||
}
|
||||
\item Flag the resulting function (from 1) as a Shiny rendering function and
|
||||
also provide a UI container for displaying the result of the rendering
|
||||
function.
|
||||
\itemize{
|
||||
\item \code{createRenderFunction()} is currently recommended (instead of
|
||||
\code{\link[=markRenderFunction]{markRenderFunction()}}) for this step (see examples).
|
||||
}
|
||||
}
|
||||
}
|
||||
\section{Functions}{
|
||||
\itemize{
|
||||
\item \code{quoToFunction}: convert a quosure to a function.
|
||||
|
||||
\item \code{installExprFunction}: converts a user's reactive \code{expr} into a
|
||||
function that's assigned to a \code{name} in the \code{assign.env}.
|
||||
}}
|
||||
|
||||
\examples{
|
||||
# A very simple render function
|
||||
renderTriple <- function(x) {
|
||||
x <- substitute(x)
|
||||
if (!rlang::is_quosure(x)) {
|
||||
x <- rlang::new_quosure(x, env = parent.frame())
|
||||
}
|
||||
func <- quoToFunction(x, "renderTriple")
|
||||
# A custom render function that repeats the supplied value 3 times
|
||||
renderTriple <- function(expr) {
|
||||
# Wrap user-supplied reactive expression into a function
|
||||
func <- quoToFunction(rlang::enquo0(expr))
|
||||
|
||||
createRenderFunction(
|
||||
func,
|
||||
transform = function(value, session, name, ...) {
|
||||
paste(rep(value, 3), collapse=", ")
|
||||
},
|
||||
outputFunc = textOutput
|
||||
)
|
||||
}
|
||||
|
||||
# For better legacy support, consider using installExprFunction() over quoToFunction()
|
||||
renderTripleLegacy <- function(expr, env = parent.frame(), quoted = FALSE) {
|
||||
func <- installExprFunction(expr, "func", env, quoted)
|
||||
|
||||
createRenderFunction(
|
||||
func,
|
||||
@@ -83,11 +160,36 @@ renderTriple <- function(x) {
|
||||
}
|
||||
|
||||
# Test render function from the console
|
||||
a <- 1
|
||||
r <- renderTriple({ a + 1 })
|
||||
a <- 2
|
||||
reactiveConsole(TRUE)
|
||||
|
||||
v <- reactiveVal("basic")
|
||||
r <- renderTriple({ v() })
|
||||
r()
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=quoToFunction]{quoToFunction()}}, \code{\link[=markRenderFunction]{markRenderFunction()}}.
|
||||
#> [1] "basic, basic, basic"
|
||||
|
||||
# User can supply quoted code via rlang::quo(). Note that evaluation of the
|
||||
# expression happens when r2() is invoked, not when r2 is created.
|
||||
q <- rlang::quo({ v() })
|
||||
r2 <- rlang::inject(renderTriple(!!q))
|
||||
v("rlang")
|
||||
r2()
|
||||
#> [1] "rlang, rlang, rlang"
|
||||
|
||||
# Supplying quoted code without rlang::quo() requires installExprFunction()
|
||||
expr <- quote({ v() })
|
||||
r3 <- renderTripleLegacy(expr, quoted = TRUE)
|
||||
v("legacy")
|
||||
r3()
|
||||
#> [1] "legacy, legacy, legacy"
|
||||
|
||||
# The legacy approach also supports with quosures (env is ignored in this case)
|
||||
q <- rlang::quo({ v() })
|
||||
r4 <- renderTripleLegacy(q, quoted = TRUE)
|
||||
v("legacy-rlang")
|
||||
r4()
|
||||
#> [1] "legacy-rlang, legacy-rlang, legacy-rlang"
|
||||
|
||||
# Turn off reactivity in the console
|
||||
reactiveConsole(FALSE)
|
||||
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ displays a message once every 8 hrs (by default)
|
||||
value and Developer message. This registration method allows package
|
||||
authors to write one message in a single location.
|
||||
|
||||
For example, the following Shiny Developer Mode options are registered:\if{html}{\out{<div class="r">}}\preformatted{# Reload the Shiny app when a sourced R file changes
|
||||
For example, the following Shiny Developer Mode options are registered:\if{html}{\out{<div class="sourceCode r">}}\preformatted{# Reload the Shiny app when a sourced R file changes
|
||||
register_devmode_option(
|
||||
"shiny.autoreload",
|
||||
"Turning on shiny autoreload. To disable, call `options(shiny.autoreload = FALSE)`",
|
||||
@@ -126,7 +126,7 @@ register_devmode_option(
|
||||
Other known, non-Shiny Developer Mode options:
|
||||
\itemize{
|
||||
\item Sass:
|
||||
}\if{html}{\out{<div class="r">}}\preformatted{# Display the full stack trace when errors occur during Shiny app execution
|
||||
}\if{html}{\out{<div class="sourceCode r">}}\preformatted{# Display the full stack trace when errors occur during Shiny app execution
|
||||
register_devmode_option(
|
||||
"sass.cache",
|
||||
"Turning off sass cache. To use default caching, call `options(sass.cache = TRUE)`",
|
||||
@@ -165,7 +165,7 @@ re-implementing these two functions:
|
||||
|
||||
This function should return \code{TRUE} if \code{getOption("shiny.devmode")} is set.
|
||||
In addition, we strongly recommend that it also checks to make sure
|
||||
\code{testthat} is not testing.\if{html}{\out{<div class="r">}}\preformatted{in_devmode <- function() \{
|
||||
\code{testthat} is not testing.\if{html}{\out{<div class="sourceCode r">}}\preformatted{in_devmode <- function() \{
|
||||
isTRUE(getOption("shiny.devmode", FALSE)) &&
|
||||
!identical(Sys.getenv("TESTTHAT"), "true")
|
||||
\}
|
||||
@@ -201,7 +201,7 @@ recommend displaying a message (\code{devmode_message}) to \code{stderr()} once
|
||||
hours using \code{\link[rlang:abort]{rlang::inform()}}. This will keep the author up to date as to
|
||||
which Dev Mode options are being altered. To allow developers a chance to
|
||||
disable Dev Mode messages, the message should be skipped if
|
||||
\code{getOption("shiny.devmode.verbose", TRUE)} is not \code{TRUE}.\if{html}{\out{<div class="r">}}\preformatted{get_devmode_option <- function(name, default = NULL, devmode_default, devmode_message) \{
|
||||
\code{getOption("shiny.devmode.verbose", TRUE)} is not \code{TRUE}.\if{html}{\out{<div class="sourceCode r">}}\preformatted{get_devmode_option <- function(name, default = NULL, devmode_default, devmode_message) \{
|
||||
if (!in_devmode()) \{
|
||||
# Dev Mode disabled, act like `getOption()`
|
||||
return(getOption(name, default = default))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/utils.R
|
||||
% Please edit documentation in R/utils-lang.R
|
||||
\name{exprToFunction}
|
||||
\alias{exprToFunction}
|
||||
\title{Convert an expression to a function}
|
||||
@@ -7,7 +7,7 @@
|
||||
exprToFunction(expr, env = parent.frame(), quoted = FALSE)
|
||||
}
|
||||
\arguments{
|
||||
\item{expr}{A quoted or unquoted expression, or a function.}
|
||||
\item{expr}{A quoted or unquoted expression, or a quosure.}
|
||||
|
||||
\item{env}{The desired environment for the function. Defaults to the
|
||||
calling environment two steps back.}
|
||||
@@ -15,47 +15,14 @@ calling environment two steps back.}
|
||||
\item{quoted}{Is the expression quoted?}
|
||||
}
|
||||
\description{
|
||||
This is to be called from another function, because it will attempt to get
|
||||
an unquoted expression from two calls back. Note: as of Shiny 1.6.0, it is
|
||||
recommended to use \code{\link[=quoToFunction]{quoToFunction()}} instead.
|
||||
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} Please use \code{\link[=installExprFunction]{installExprFunction()}} for a better
|
||||
debugging experience (Shiny 0.8.0). If the \code{expr} and \code{quoted} parameters are not needed, please see
|
||||
\code{\link[=quoToFunction]{quoToFunction()}} (Shiny 1.6.0).
|
||||
}
|
||||
\details{
|
||||
If expr is a quoted expression, then this just converts it to a function.
|
||||
If expr is a function, then this simply returns expr (and prints a
|
||||
deprecation message).
|
||||
If expr was a non-quoted expression from two calls back, then this will
|
||||
quote the original expression and convert it to a function.
|
||||
Similar to \code{\link[=installExprFunction]{installExprFunction()}} but doesn't register debug hooks.
|
||||
}
|
||||
\examples{
|
||||
# Example of a new renderer, similar to renderText
|
||||
# This is something that toolkit authors will do
|
||||
renderTriple <- function(expr, env=parent.frame(), quoted=FALSE) {
|
||||
# Convert expr to a function
|
||||
func <- shiny::exprToFunction(expr, env, quoted)
|
||||
|
||||
function() {
|
||||
value <- func()
|
||||
paste(rep(value, 3), collapse=", ")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Example of using the renderer.
|
||||
# This is something that app authors will do.
|
||||
values <- reactiveValues(A="text")
|
||||
|
||||
\dontrun{
|
||||
# Create an output object
|
||||
output$tripleA <- renderTriple({
|
||||
values$A
|
||||
})
|
||||
}
|
||||
|
||||
# At the R console, you can experiment with the renderer using isolate()
|
||||
tripleA <- renderTriple({
|
||||
values$A
|
||||
})
|
||||
|
||||
isolate(tripleA())
|
||||
# "text, text, text"
|
||||
\seealso{
|
||||
\code{\link[=installExprFunction]{installExprFunction()}} for the modern approach to converting an expression to a function
|
||||
}
|
||||
\keyword{internal}
|
||||
|
||||
@@ -37,10 +37,11 @@ shown in the document).}
|
||||
build of Bootstrap 3 with a customized version of Bootstrap 3 or higher.
|
||||
\item A character string pointing to an alternative Bootstrap stylesheet
|
||||
(normally a css file within the www directory, e.g. \code{www/bootstrap.css}).
|
||||
This option is here mainly for legacy reasons.
|
||||
}}
|
||||
|
||||
\item{lang}{ISO 639-1 language code for the HTML page, such as "en" or "ko".
|
||||
This will be used as the lang in the \code{<html>} tag, as in \code{<html lang="en">}.
|
||||
This will be used as the lang in the \verb{<html>} tag, as in \verb{<html lang="en">}.
|
||||
The default (NULL) results in an empty string.}
|
||||
}
|
||||
\description{
|
||||
@@ -101,9 +102,7 @@ fillPage(
|
||||
}
|
||||
\seealso{
|
||||
Other layout functions:
|
||||
\code{\link{fixedPage}()},
|
||||
\code{\link{flowLayout}()},
|
||||
\code{\link{fluidPage}()},
|
||||
\code{\link{navbarPage}()},
|
||||
\code{\link{sidebarLayout}()},
|
||||
\code{\link{splitLayout}()},
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/bootstrap-layout.R
|
||||
\name{fixedPage}
|
||||
\alias{fixedPage}
|
||||
\alias{fixedRow}
|
||||
\title{Create a page with a fixed layout}
|
||||
\usage{
|
||||
fixedPage(..., title = NULL, theme = NULL, lang = NULL)
|
||||
|
||||
fixedRow(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{Elements to include within the container}
|
||||
|
||||
\item{title}{The browser window title (defaults to the host URL of the page)}
|
||||
|
||||
\item{theme}{One of the following:
|
||||
\itemize{
|
||||
\item \code{NULL} (the default), which implies a "stock" build of Bootstrap 3.
|
||||
\item A \code{\link[bslib:bs_theme]{bslib::bs_theme()}} object. This can be used to replace a stock
|
||||
build of Bootstrap 3 with a customized version of Bootstrap 3 or higher.
|
||||
\item A character string pointing to an alternative Bootstrap stylesheet
|
||||
(normally a css file within the www directory, e.g. \code{www/bootstrap.css}).
|
||||
}}
|
||||
|
||||
\item{lang}{ISO 639-1 language code for the HTML page, such as "en" or "ko".
|
||||
This will be used as the lang in the \code{<html>} tag, as in \code{<html lang="en">}.
|
||||
The default (NULL) results in an empty string.}
|
||||
}
|
||||
\value{
|
||||
A UI defintion that can be passed to the \link{shinyUI} function.
|
||||
}
|
||||
\description{
|
||||
Functions for creating fixed page layouts. A fixed page layout consists of
|
||||
rows which in turn include columns. Rows exist for the purpose of making sure
|
||||
their elements appear on the same line (if the browser has adequate width).
|
||||
Columns exist for the purpose of defining how much horizontal space within a
|
||||
12-unit wide grid it's elements should occupy. Fixed pages limit their width
|
||||
to 940 pixels on a typical display, and 724px or 1170px on smaller and larger
|
||||
displays respectively.
|
||||
}
|
||||
\details{
|
||||
To create a fixed page use the \code{fixedPage} function and include
|
||||
instances of \code{fixedRow} and \code{\link[=column]{column()}} within it. Note that
|
||||
unlike \code{\link[=fluidPage]{fluidPage()}}, fixed pages cannot make use of higher-level
|
||||
layout functions like \code{sidebarLayout}, rather, all layout must be done
|
||||
with \code{fixedRow} and \code{column}.
|
||||
}
|
||||
\note{
|
||||
See the \href{https://shiny.rstudio.com/articles/layout-guide.html}{ Shiny Application Layout Guide} for additional details on laying out fixed
|
||||
pages.
|
||||
}
|
||||
\examples{
|
||||
## Only run examples in interactive R sessions
|
||||
if (interactive()) {
|
||||
|
||||
ui <- fixedPage(
|
||||
title = "Hello, Shiny!",
|
||||
fixedRow(
|
||||
column(width = 4,
|
||||
"4"
|
||||
),
|
||||
column(width = 3, offset = 2,
|
||||
"3 offset 2"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
shinyApp(ui, server = function(input, output) { })
|
||||
}
|
||||
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=column]{column()}}
|
||||
|
||||
Other layout functions:
|
||||
\code{\link{fillPage}()},
|
||||
\code{\link{flowLayout}()},
|
||||
\code{\link{fluidPage}()},
|
||||
\code{\link{navbarPage}()},
|
||||
\code{\link{sidebarLayout}()},
|
||||
\code{\link{splitLayout}()},
|
||||
\code{\link{verticalLayout}()}
|
||||
}
|
||||
\concept{layout functions}
|
||||
@@ -34,8 +34,6 @@ shinyApp(ui, server = function(input, output) { })
|
||||
\seealso{
|
||||
Other layout functions:
|
||||
\code{\link{fillPage}()},
|
||||
\code{\link{fixedPage}()},
|
||||
\code{\link{fluidPage}()},
|
||||
\code{\link{navbarPage}()},
|
||||
\code{\link{sidebarLayout}()},
|
||||
\code{\link{splitLayout}()},
|
||||
|
||||
119
man/fluidPage.Rd
119
man/fluidPage.Rd
@@ -1,119 +0,0 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/bootstrap-layout.R
|
||||
\name{fluidPage}
|
||||
\alias{fluidPage}
|
||||
\alias{fluidRow}
|
||||
\title{Create a page with fluid layout}
|
||||
\usage{
|
||||
fluidPage(..., title = NULL, theme = NULL, lang = NULL)
|
||||
|
||||
fluidRow(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{Elements to include within the page}
|
||||
|
||||
\item{title}{The browser window title (defaults to the host URL of the page).
|
||||
Can also be set as a side effect of the \code{\link[=titlePanel]{titlePanel()}} function.}
|
||||
|
||||
\item{theme}{One of the following:
|
||||
\itemize{
|
||||
\item \code{NULL} (the default), which implies a "stock" build of Bootstrap 3.
|
||||
\item A \code{\link[bslib:bs_theme]{bslib::bs_theme()}} object. This can be used to replace a stock
|
||||
build of Bootstrap 3 with a customized version of Bootstrap 3 or higher.
|
||||
\item A character string pointing to an alternative Bootstrap stylesheet
|
||||
(normally a css file within the www directory, e.g. \code{www/bootstrap.css}).
|
||||
}}
|
||||
|
||||
\item{lang}{ISO 639-1 language code for the HTML page, such as "en" or "ko".
|
||||
This will be used as the lang in the \code{<html>} tag, as in \code{<html lang="en">}.
|
||||
The default (NULL) results in an empty string.}
|
||||
}
|
||||
\value{
|
||||
A UI defintion that can be passed to the \link{shinyUI} function.
|
||||
}
|
||||
\description{
|
||||
Functions for creating fluid page layouts. A fluid page layout consists of
|
||||
rows which in turn include columns. Rows exist for the purpose of making sure
|
||||
their elements appear on the same line (if the browser has adequate width).
|
||||
Columns exist for the purpose of defining how much horizontal space within a
|
||||
12-unit wide grid it's elements should occupy. Fluid pages scale their
|
||||
components in realtime to fill all available browser width.
|
||||
}
|
||||
\details{
|
||||
To create a fluid page use the \code{fluidPage} function and include
|
||||
instances of \code{fluidRow} and \code{\link[=column]{column()}} within it. As an
|
||||
alternative to low-level row and column functions you can also use
|
||||
higher-level layout functions like \code{\link[=sidebarLayout]{sidebarLayout()}}.
|
||||
}
|
||||
\note{
|
||||
See the \href{https://shiny.rstudio.com/articles/layout-guide.html}{ Shiny-Application-Layout-Guide} for additional details on laying out fluid
|
||||
pages.
|
||||
}
|
||||
\examples{
|
||||
## Only run examples in interactive R sessions
|
||||
if (interactive()) {
|
||||
|
||||
# Example of UI with fluidPage
|
||||
ui <- fluidPage(
|
||||
|
||||
# Application title
|
||||
titlePanel("Hello Shiny!"),
|
||||
|
||||
sidebarLayout(
|
||||
|
||||
# Sidebar with a slider input
|
||||
sidebarPanel(
|
||||
sliderInput("obs",
|
||||
"Number of observations:",
|
||||
min = 0,
|
||||
max = 1000,
|
||||
value = 500)
|
||||
),
|
||||
|
||||
# Show a plot of the generated distribution
|
||||
mainPanel(
|
||||
plotOutput("distPlot")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
# Server logic
|
||||
server <- function(input, output) {
|
||||
output$distPlot <- renderPlot({
|
||||
hist(rnorm(input$obs))
|
||||
})
|
||||
}
|
||||
|
||||
# Complete app with UI and server components
|
||||
shinyApp(ui, server)
|
||||
|
||||
|
||||
# UI demonstrating column layouts
|
||||
ui <- fluidPage(
|
||||
title = "Hello Shiny!",
|
||||
fluidRow(
|
||||
column(width = 4,
|
||||
"4"
|
||||
),
|
||||
column(width = 3, offset = 2,
|
||||
"3 offset 2"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
shinyApp(ui, server = function(input, output) { })
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=column]{column()}}
|
||||
|
||||
Other layout functions:
|
||||
\code{\link{fillPage}()},
|
||||
\code{\link{fixedPage}()},
|
||||
\code{\link{flowLayout}()},
|
||||
\code{\link{navbarPage}()},
|
||||
\code{\link{sidebarLayout}()},
|
||||
\code{\link{splitLayout}()},
|
||||
\code{\link{verticalLayout}()}
|
||||
}
|
||||
\concept{layout functions}
|
||||
@@ -1,50 +0,0 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/utils.R
|
||||
\name{installExprFunction}
|
||||
\alias{installExprFunction}
|
||||
\title{Install an expression as a function}
|
||||
\usage{
|
||||
installExprFunction(
|
||||
expr,
|
||||
name,
|
||||
eval.env = parent.frame(2),
|
||||
quoted = FALSE,
|
||||
assign.env = parent.frame(1),
|
||||
label = deparse(sys.call(-1)[[1]]),
|
||||
wrappedWithLabel = TRUE,
|
||||
..stacktraceon = FALSE
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{expr}{A quoted or unquoted expression}
|
||||
|
||||
\item{name}{The name the function should be given}
|
||||
|
||||
\item{eval.env}{The desired environment for the function. Defaults to the
|
||||
calling environment two steps back.}
|
||||
|
||||
\item{quoted}{Is the expression quoted?}
|
||||
|
||||
\item{assign.env}{The environment in which the function should be assigned.}
|
||||
|
||||
\item{label}{A label for the object to be shown in the debugger. Defaults to
|
||||
the name of the calling function.}
|
||||
|
||||
\item{wrappedWithLabel, ..stacktraceon}{Advanced use only. For stack manipulation purposes; see
|
||||
\code{\link[=stacktrace]{stacktrace()}}.}
|
||||
}
|
||||
\description{
|
||||
Installs an expression in the given environment as a function, and registers
|
||||
debug hooks so that breakpoints may be set in the function. Note: as of
|
||||
Shiny 1.6.0, it is recommended to use \code{\link[=quoToFunction]{quoToFunction()}} instead.
|
||||
}
|
||||
\details{
|
||||
This function can replace \code{exprToFunction} as follows: we may use
|
||||
\code{func <- exprToFunction(expr)} if we do not want the debug hooks, or
|
||||
\code{installExprFunction(expr, "func")} if we do. Both approaches create a
|
||||
function named \code{func} in the current environment.
|
||||
}
|
||||
\seealso{
|
||||
Wraps \code{\link[=exprToFunction]{exprToFunction()}}; see that method's documentation
|
||||
for more documentation and examples.
|
||||
}
|
||||
@@ -24,3 +24,4 @@ knit_print.reactive(x, ..., inline = FALSE)
|
||||
These S3 methods are necessary to help Shiny applications and UI chunks embed
|
||||
themselves in knitr/rmarkdown documents.
|
||||
}
|
||||
\keyword{internal}
|
||||
|
||||
@@ -51,12 +51,24 @@ is able to serve JS and CSS resources.}
|
||||
The \code{renderFunc} function, with annotations.
|
||||
}
|
||||
\description{
|
||||
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} Please use \code{\link[=createRenderFunction]{createRenderFunction()}} to
|
||||
support async execution. (Shiny 1.1.0)
|
||||
}
|
||||
\details{
|
||||
Should be called by implementers of \code{renderXXX} functions in order to mark
|
||||
their return values as Shiny render functions, and to provide a hint to Shiny
|
||||
regarding what UI function is most commonly used with this type of render
|
||||
function. This can be used in R Markdown documents to create complete output
|
||||
widgets out of just the render function.
|
||||
|
||||
Note that it is generally preferable to use \code{\link[=createRenderFunction]{createRenderFunction()}} instead
|
||||
of \code{markRenderFunction()}. It essentially wraps up the user-provided
|
||||
expression in the \code{transform} function passed to it, then passes the resulting
|
||||
function to \code{markRenderFunction()}. It also provides a simpler calling
|
||||
interface. There may be cases where \code{markRenderFunction()} must be used instead of
|
||||
\code{\link[=createRenderFunction]{createRenderFunction()}} -- for example, when the \code{transform} parameter of
|
||||
\code{\link[=createRenderFunction]{createRenderFunction()}} is not flexible enough for your needs.
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=createRenderFunction]{createRenderFunction()}}, \code{\link[=quoToFunction]{quoToFunction()}}
|
||||
\code{\link[=createRenderFunction]{createRenderFunction()}}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ layout.}
|
||||
build of Bootstrap 3 with a customized version of Bootstrap 3 or higher.
|
||||
\item A character string pointing to an alternative Bootstrap stylesheet
|
||||
(normally a css file within the www directory, e.g. \code{www/bootstrap.css}).
|
||||
This option is here mainly for legacy reasons.
|
||||
}}
|
||||
|
||||
\item{windowTitle}{the browser window title (as a character string). The
|
||||
@@ -79,7 +80,7 @@ default value, \code{NA}, means to use any character strings that appear in
|
||||
default).}
|
||||
|
||||
\item{lang}{ISO 639-1 language code for the HTML page, such as "en" or "ko".
|
||||
This will be used as the lang in the \code{<html>} tag, as in \code{<html lang="en">}.
|
||||
This will be used as the lang in the \verb{<html>} tag, as in \verb{<html lang="en">}.
|
||||
The default (NULL) results in an empty string.}
|
||||
|
||||
\item{menuName}{A name that identifies this \code{navbarMenu}. This
|
||||
@@ -124,9 +125,7 @@ navbarPage("App Title",
|
||||
|
||||
Other layout functions:
|
||||
\code{\link{fillPage}()},
|
||||
\code{\link{fixedPage}()},
|
||||
\code{\link{flowLayout}()},
|
||||
\code{\link{fluidPage}()},
|
||||
\code{\link{sidebarLayout}()},
|
||||
\code{\link{splitLayout}()},
|
||||
\code{\link{verticalLayout}()}
|
||||
|
||||
@@ -23,11 +23,13 @@ ignored.}
|
||||
|
||||
\item{env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression.}
|
||||
non-reactive expression. If \code{x} is a quosure and \code{quoted} is \code{TRUE},
|
||||
then \code{env} is ignored.}
|
||||
|
||||
\item{quoted}{Is the expression quoted? By default, this is \code{FALSE}.
|
||||
This is useful when you want to use an expression that is stored in a
|
||||
variable; to do so, it must be quoted with \code{quote()}.}
|
||||
\item{quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{x}
|
||||
will be used when \code{x} is evaluated. If \code{x} is a quosure and you
|
||||
would like to use its expression as a value for \code{x}, then you must set
|
||||
\code{quoted} to \code{TRUE}.}
|
||||
|
||||
\item{...}{Not used.}
|
||||
|
||||
@@ -116,12 +118,12 @@ obsB <- observe({
|
||||
print(values$A + 1)
|
||||
})
|
||||
|
||||
# Can use quoted expressions
|
||||
obsC <- observe(quote({ print(values$A + 2) }), quoted = TRUE)
|
||||
# To store expressions for later conversion to observe, use rlang::quo()
|
||||
myquo <- rlang::quo({ print(values$A + 3) })
|
||||
obsC <- rlang::inject(observe(!!myquo))
|
||||
|
||||
# To store expressions for later conversion to observe, use quote()
|
||||
expr_q <- quote({ print(values$A + 3) })
|
||||
obsD <- observe(expr_q, quoted = TRUE)
|
||||
# (Legacy) Can use quoted expressions
|
||||
obsD <- observe(quote({ print(values$A + 2) }), quoted = TRUE)
|
||||
|
||||
# In a normal Shiny app, the web client will trigger flush events. If you
|
||||
# are at the console, you can force a flush with flushReact()
|
||||
|
||||
@@ -48,21 +48,25 @@ invalidated. This should be a side-effect-producing action (the return
|
||||
value will be ignored). It will be executed within an \code{\link[=isolate]{isolate()}}
|
||||
scope.}
|
||||
|
||||
\item{event.env}{The parent environment for \code{eventExpr}. By default,
|
||||
this is the calling environment.}
|
||||
\item{event.env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{eventExpr} is a quosure and \code{event.quoted} is \code{TRUE},
|
||||
then \code{event.env} is ignored.}
|
||||
|
||||
\item{event.quoted}{Is the \code{eventExpr} expression quoted? By default,
|
||||
this is \code{FALSE}. This is useful when you want to use an expression
|
||||
that is stored in a variable; to do so, it must be quoted with
|
||||
\code{quote()}.}
|
||||
\item{event.quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{eventExpr}
|
||||
will be used when \code{eventExpr} is evaluated. If \code{eventExpr} is a quosure and you
|
||||
would like to use its expression as a value for \code{eventExpr}, then you must set
|
||||
\code{event.quoted} to \code{TRUE}.}
|
||||
|
||||
\item{handler.env}{The parent environment for \code{handlerExpr}. By default,
|
||||
this is the calling environment.}
|
||||
\item{handler.env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{handlerExpr} is a quosure and \code{handler.quoted} is \code{TRUE},
|
||||
then \code{handler.env} is ignored.}
|
||||
|
||||
\item{handler.quoted}{Is the \code{handlerExpr} expression quoted? By
|
||||
default, this is \code{FALSE}. This is useful when you want to use an
|
||||
expression that is stored in a variable; to do so, it must be quoted with
|
||||
\code{quote()}.}
|
||||
\item{handler.quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{handlerExpr}
|
||||
will be used when \code{handlerExpr} is evaluated. If \code{handlerExpr} is a quosure and you
|
||||
would like to use its expression as a value for \code{handlerExpr}, then you must set
|
||||
\code{handler.quoted} to \code{TRUE}.}
|
||||
|
||||
\item{...}{Currently not used.}
|
||||
|
||||
@@ -99,12 +103,15 @@ happen once.}
|
||||
\code{eventReactive}. It will be executed within an \code{\link[=isolate]{isolate()}}
|
||||
scope.}
|
||||
|
||||
\item{value.env}{The parent environment for \code{valueExpr}. By default,
|
||||
this is the calling environment.}
|
||||
\item{value.env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{valueExpr} is a quosure and \code{value.quoted} is \code{TRUE},
|
||||
then \code{value.env} is ignored.}
|
||||
|
||||
\item{value.quoted}{Is the \code{valueExpr} expression quoted? By default,
|
||||
this is \code{FALSE}. This is useful when you want to use an expression
|
||||
that is stored in a variable; to do so, it must be quoted with \code{quote()}.}
|
||||
\item{value.quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{valueExpr}
|
||||
will be used when \code{valueExpr} is evaluated. If \code{valueExpr} is a quosure and you
|
||||
would like to use its expression as a value for \code{valueExpr}, then you must set
|
||||
\code{value.quoted} to \code{TRUE}.}
|
||||
}
|
||||
\value{
|
||||
\code{observeEvent} returns an observer reference class object (see
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/utils.R
|
||||
\name{quoToFunction}
|
||||
\alias{quoToFunction}
|
||||
\title{Convert a quosure to a function for a Shiny render function}
|
||||
\usage{
|
||||
quoToFunction(q, label, ..stacktraceon = FALSE)
|
||||
}
|
||||
\arguments{
|
||||
\item{q}{A quosure.}
|
||||
|
||||
\item{label}{A label for the object to be shown in the debugger. Defaults to
|
||||
the name of the calling function.}
|
||||
|
||||
\item{..stacktraceon}{Advanced use only. For stack manipulation purposes; see
|
||||
\code{\link[=stacktrace]{stacktrace()}}.}
|
||||
}
|
||||
\description{
|
||||
This takes a quosure and label, and wraps them into a function that should be
|
||||
passed to \code{\link[=createRenderFunction]{createRenderFunction()}} or \code{\link[=markRenderFunction]{markRenderFunction()}}.
|
||||
}
|
||||
\details{
|
||||
This function was added in Shiny 1.6.0. Previously, it was recommended to use
|
||||
\code{\link[=installExprFunction]{installExprFunction()}} or \code{\link[=exprToFunction]{exprToFunction()}} in render functions, but now we
|
||||
recommend using \code{\link[=quoToFunction]{quoToFunction()}}, because it does not require \code{env} and
|
||||
\code{quoted} arguments -- that information is captured by quosures provided by
|
||||
\pkg{rlang}.
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=createRenderFunction]{createRenderFunction()}} for example usage.
|
||||
}
|
||||
@@ -18,16 +18,17 @@ reactive(
|
||||
is.reactive(x)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{For \code{reactive}, an expression (quoted or unquoted). For
|
||||
\code{is.reactive}, an object to test.}
|
||||
\item{x}{For \code{is.reactive()}, an object to test. For \code{reactive()}, an expression. When passing in a \code{\link[=quo]{quo()}}sure with \code{reactive()}, remember to use \code{\link[rlang:inject]{rlang::inject()}} to distinguish that you are passing in the content of your quosure, not the expression of the quosure.}
|
||||
|
||||
\item{env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression.}
|
||||
non-reactive expression. If \code{x} is a quosure and \code{quoted} is \code{TRUE},
|
||||
then \code{env} is ignored.}
|
||||
|
||||
\item{quoted}{Is the expression quoted? By default, this is \code{FALSE}.
|
||||
This is useful when you want to use an expression that is stored in a
|
||||
variable; to do so, it must be quoted with \code{quote()}.}
|
||||
\item{quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{x}
|
||||
will be used when \code{x} is evaluated. If \code{x} is a quosure and you
|
||||
would like to use its expression as a value for \code{x}, then you must set
|
||||
\code{quoted} to \code{TRUE}.}
|
||||
|
||||
\item{...}{Not used.}
|
||||
|
||||
@@ -58,21 +59,32 @@ See the \href{https://shiny.rstudio.com/tutorial/}{Shiny tutorial} for
|
||||
more information about reactive expressions.
|
||||
}
|
||||
\examples{
|
||||
library(rlang)
|
||||
values <- reactiveValues(A=1)
|
||||
|
||||
reactiveB <- reactive({
|
||||
values$A + 1
|
||||
})
|
||||
|
||||
# Can use quoted expressions
|
||||
reactiveC <- reactive(quote({ values$A + 2 }), quoted = TRUE)
|
||||
|
||||
# To store expressions for later conversion to reactive, use quote()
|
||||
expr_q <- quote({ values$A + 3 })
|
||||
reactiveD <- reactive(expr_q, quoted = TRUE)
|
||||
|
||||
# View the values from the R console with isolate()
|
||||
isolate(reactiveB())
|
||||
# 2
|
||||
|
||||
# To store expressions for later conversion to reactive, use quote()
|
||||
myquo <- rlang::quo(values$A + 2)
|
||||
# Unexpected value! Sending a quosure directly will not work as expected.
|
||||
reactiveC <- reactive(myquo)
|
||||
# We'd hope for `3`, but instead we get the quosure that was supplied.
|
||||
isolate(reactiveC())
|
||||
|
||||
# Instead, the quosure should be `rlang::inject()`ed
|
||||
reactiveD <- rlang::inject(reactive(!!myquo))
|
||||
isolate(reactiveD())
|
||||
# 3
|
||||
|
||||
# (Legacy) Can use quoted expressions
|
||||
expr <- quote({ values$A + 3 })
|
||||
reactiveE <- reactive(expr, quoted = TRUE)
|
||||
isolate(reactiveE())
|
||||
# 4
|
||||
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ registerInputHandler("mypackage.validint", function(x, shinysession, name) {
|
||||
})
|
||||
|
||||
## On the Javascript side, the associated input binding must have a corresponding getType method:
|
||||
getType: function(el) {
|
||||
return "mypackage.validint";
|
||||
}
|
||||
# getType: function(el) {
|
||||
# return "mypackage.validint";
|
||||
# }
|
||||
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[=removeInputHandler]{removeInputHandler()}}
|
||||
\code{\link[=removeInputHandler]{removeInputHandler()}} \code{\link[=applyInputHandlers]{applyInputHandlers()}}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ shinyOptions(cache = cachem::cache_mem(max_size = 20e6, max_age = 3600))
|
||||
# At the top of app.R, this set the application-scoped cache to be a disk
|
||||
# cache that can be shared among multiple concurrent R processes, and is
|
||||
# deleted when the system reboots.
|
||||
shinyOptions(cache = cachem::cache_disk(file.path(dirname(tempdir()), "myapp-cache"))
|
||||
shinyOptions(cache = cachem::cache_disk(file.path(dirname(tempdir()), "myapp-cache")))
|
||||
|
||||
# At the top of app.R, this set the application-scoped cache to be a disk
|
||||
# cache that can be shared among multiple concurrent R processes, and
|
||||
|
||||
@@ -48,16 +48,25 @@ indicate which columns to escape, e.g. \code{1:5} (the first 5 columns),
|
||||
\code{c(1, 3, 4)}, or \code{c(-1, -3)} (all columns except the first and
|
||||
third), or \code{c('Species', 'Sepal.Length')}.}
|
||||
|
||||
\item{env}{The environment in which to evaluate \code{expr}.}
|
||||
\item{env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{expr} is a quosure and \code{quoted} is \code{TRUE},
|
||||
then \code{env} is ignored.}
|
||||
|
||||
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})?
|
||||
This is useful if you want to save an expression in a variable.}
|
||||
\item{quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{expr}
|
||||
will be used when \code{expr} is evaluated. If \code{expr} is a quosure and you
|
||||
would like to use its expression as a value for \code{expr}, then you must set
|
||||
\code{quoted} to \code{TRUE}.}
|
||||
|
||||
\item{outputArgs}{A list of arguments to be passed through to the implicit
|
||||
call to \code{dataTableOutput()} when \code{renderDataTable()} is used
|
||||
in an interactive R Markdown document.}
|
||||
}
|
||||
\description{
|
||||
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} Please use
|
||||
\href{https://rstudio.github.io/DT/shiny.html}{\code{DT::renderDataTable()}}.
|
||||
(Shiny 0.11.1)
|
||||
|
||||
Makes a reactive version of the given function that returns a data frame (or
|
||||
matrix), which will be rendered with the \href{https://datatables.net}{DataTables}
|
||||
library. Paging, searching, filtering, and sorting can be done on the R side
|
||||
|
||||
@@ -15,10 +15,15 @@ renderImage(
|
||||
\arguments{
|
||||
\item{expr}{An expression that returns a list.}
|
||||
|
||||
\item{env}{The environment in which to evaluate \code{expr}.}
|
||||
\item{env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{expr} is a quosure and \code{quoted} is \code{TRUE},
|
||||
then \code{env} is ignored.}
|
||||
|
||||
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This
|
||||
is useful if you want to save an expression in a variable.}
|
||||
\item{quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{expr}
|
||||
will be used when \code{expr} is evaluated. If \code{expr} is a quosure and you
|
||||
would like to use its expression as a value for \code{expr}, then you must set
|
||||
\code{quoted} to \code{TRUE}.}
|
||||
|
||||
\item{deleteFile}{Should the file in \code{func()$src} be deleted after
|
||||
it is sent to the client browser? Generally speaking, if the image is a
|
||||
|
||||
@@ -50,10 +50,15 @@ ggplot objects; for other plots, \code{NA} results in alt text of "Plot object".
|
||||
\code{NULL} or \code{""} is not recommended because those should be limited to
|
||||
decorative images.}
|
||||
|
||||
\item{env}{The environment in which to evaluate \code{expr}.}
|
||||
\item{env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{expr} is a quosure and \code{quoted} is \code{TRUE},
|
||||
then \code{env} is ignored.}
|
||||
|
||||
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This
|
||||
is useful if you want to save an expression in a variable.}
|
||||
\item{quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{expr}
|
||||
will be used when \code{expr} is evaluated. If \code{expr} is a quosure and you
|
||||
would like to use its expression as a value for \code{expr}, then you must set
|
||||
\code{quoted} to \code{TRUE}.}
|
||||
|
||||
\item{execOnResize}{If \code{FALSE} (the default), then when a plot is
|
||||
resized, Shiny will \emph{replay} the plot drawing commands with
|
||||
|
||||
@@ -24,10 +24,15 @@ renderText(
|
||||
\arguments{
|
||||
\item{expr}{An expression to evaluate.}
|
||||
|
||||
\item{env}{The environment in which to evaluate \code{expr}. For expert use only.}
|
||||
\item{env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{expr} is a quosure and \code{quoted} is \code{TRUE},
|
||||
then \code{env} is ignored.}
|
||||
|
||||
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This
|
||||
is useful if you want to save an expression in a variable.}
|
||||
\item{quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{expr}
|
||||
will be used when \code{expr} is evaluated. If \code{expr} is a quosure and you
|
||||
would like to use its expression as a value for \code{expr}, then you must set
|
||||
\code{quoted} to \code{TRUE}.}
|
||||
|
||||
\item{width}{Width of printed output.}
|
||||
|
||||
|
||||
@@ -71,10 +71,15 @@ columns will be displayed in scientific format with a precision of
|
||||
\item{...}{Arguments to be passed through to \code{\link[xtable:xtable]{xtable::xtable()}}
|
||||
and \code{\link[xtable:print.xtable]{xtable::print.xtable()}}.}
|
||||
|
||||
\item{env}{The environment in which to evaluate \code{expr}.}
|
||||
\item{env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{expr} is a quosure and \code{quoted} is \code{TRUE},
|
||||
then \code{env} is ignored.}
|
||||
|
||||
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})?
|
||||
This is useful if you want to save an expression in a variable.}
|
||||
\item{quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{expr}
|
||||
will be used when \code{expr} is evaluated. If \code{expr} is a quosure and you
|
||||
would like to use its expression as a value for \code{expr}, then you must set
|
||||
\code{quoted} to \code{TRUE}.}
|
||||
|
||||
\item{outputArgs}{A list of arguments to be passed through to the
|
||||
implicit call to \code{\link[=tableOutput]{tableOutput()}} when \code{renderTable} is
|
||||
|
||||
@@ -10,10 +10,15 @@ renderUI(expr, env = parent.frame(), quoted = FALSE, outputArgs = list())
|
||||
\item{expr}{An expression that returns a Shiny tag object, \code{\link[=HTML]{HTML()}},
|
||||
or a list of such objects.}
|
||||
|
||||
\item{env}{The environment in which to evaluate \code{expr}.}
|
||||
\item{env}{The parent environment for the reactive expression. By default,
|
||||
this is the calling environment, the same as when defining an ordinary
|
||||
non-reactive expression. If \code{expr} is a quosure and \code{quoted} is \code{TRUE},
|
||||
then \code{env} is ignored.}
|
||||
|
||||
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This
|
||||
is useful if you want to save an expression in a variable.}
|
||||
\item{quoted}{If it is \code{TRUE}, then the \code{\link[=quote]{quote()}}ed value of \code{expr}
|
||||
will be used when \code{expr} is evaluated. If \code{expr} is a quosure and you
|
||||
would like to use its expression as a value for \code{expr}, then you must set
|
||||
\code{quoted} to \code{TRUE}.}
|
||||
|
||||
\item{outputArgs}{A list of arguments to be passed through to the implicit
|
||||
call to \code{\link[=uiOutput]{uiOutput()}} when \code{renderUI} is used in an
|
||||
|
||||
@@ -30,7 +30,10 @@ expression that produces a Shiny app object.
|
||||
\item{port}{The TCP port that the application should listen on. If the
|
||||
\code{port} is not specified, and the \code{shiny.port} option is set (with
|
||||
\code{options(shiny.port = XX)}), then that port will be used. Otherwise,
|
||||
use a random port.}
|
||||
use a random port between 3000:8000, excluding ports that are blocked
|
||||
by Google Chrome for being considered unsafe: 3659, 4045, 5060,
|
||||
5061, 6000, 6566, 6665:6669 and 6697. Up to twenty random
|
||||
ports will be tried.}
|
||||
|
||||
\item{launch.browser}{If true, the system's default web browser will be
|
||||
launched automatically after the app is started. Defaults to true in
|
||||
|
||||
@@ -19,7 +19,10 @@ list the available examples.}
|
||||
\item{port}{The TCP port that the application should listen on. If the
|
||||
\code{port} is not specified, and the \code{shiny.port} option is set (with
|
||||
\code{options(shiny.port = XX)}), then that port will be used. Otherwise,
|
||||
use a random port.}
|
||||
use a random port between 3000:8000, excluding ports that are blocked
|
||||
by Google Chrome for being considered unsafe: 3659, 4045, 5060,
|
||||
5061, 6000, 6566, 6665:6669 and 6697. Up to twenty random
|
||||
ports will be tried.}
|
||||
|
||||
\item{launch.browser}{If true, the system's default web browser will be
|
||||
launched automatically after the app is started. Defaults to true in
|
||||
|
||||
@@ -62,10 +62,10 @@ respectively.
|
||||
\examples{
|
||||
## Only run this example in interactive R sessions
|
||||
if (interactive()) {
|
||||
runUrl('https://github.com/rstudio/shiny_example/archive/master.tar.gz')
|
||||
runUrl('https://github.com/rstudio/shiny_example/archive/main.tar.gz')
|
||||
|
||||
# Can run an app from a subdirectory in the archive
|
||||
runUrl("https://github.com/rstudio/shiny_example/archive/master.zip",
|
||||
runUrl("https://github.com/rstudio/shiny_example/archive/main.zip",
|
||||
subdir = "inst/shinyapp/")
|
||||
}
|
||||
## Only run this example in interactive R sessions
|
||||
|
||||
@@ -17,4 +17,3 @@ value. The returned value will be used for the test snapshot.}
|
||||
\description{
|
||||
Add a function for serializing an input before bookmarking application state
|
||||
}
|
||||
\keyword{internal}
|
||||
|
||||
@@ -4,7 +4,13 @@
|
||||
\alias{shinyDeprecated}
|
||||
\title{Print message for deprecated functions in Shiny}
|
||||
\usage{
|
||||
shinyDeprecated(version, what, with = NULL, details = NULL)
|
||||
shinyDeprecated(
|
||||
version,
|
||||
what,
|
||||
with = NULL,
|
||||
details = NULL,
|
||||
type = c("deprecated", "superseded")
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{version}{Shiny version when the function was deprecated}
|
||||
|
||||
@@ -83,9 +83,7 @@ shinyApp(ui, server)
|
||||
\seealso{
|
||||
Other layout functions:
|
||||
\code{\link{fillPage}()},
|
||||
\code{\link{fixedPage}()},
|
||||
\code{\link{flowLayout}()},
|
||||
\code{\link{fluidPage}()},
|
||||
\code{\link{navbarPage}()},
|
||||
\code{\link{splitLayout}()},
|
||||
\code{\link{verticalLayout}()}
|
||||
|
||||
@@ -64,9 +64,7 @@ shinyApp(ui, server)
|
||||
\seealso{
|
||||
Other layout functions:
|
||||
\code{\link{fillPage}()},
|
||||
\code{\link{fixedPage}()},
|
||||
\code{\link{flowLayout}()},
|
||||
\code{\link{fluidPage}()},
|
||||
\code{\link{navbarPage}()},
|
||||
\code{\link{sidebarLayout}()},
|
||||
\code{\link{verticalLayout}()}
|
||||
|
||||
@@ -76,10 +76,10 @@ value when it is a single choice input and the empty string is not in the
|
||||
The resulting server \code{input} value will be returned as:
|
||||
\itemize{
|
||||
\item A symbol if \code{multiple = FALSE}. The \code{input} value should be
|
||||
used with rlang's \code{\link[rlang:bang-bang]{rlang::!!()}}. For example,
|
||||
used with rlang's \code{\link[rlang:nse-force]{rlang::!!()}}. For example,
|
||||
\code{ggplot2::aes(!!input$variable)}.
|
||||
\item A list of symbols if \code{multiple = TRUE}. The \code{input} value
|
||||
should be used with rlang's \code{\link[rlang:bang-bang]{rlang::!!!()}} to expand
|
||||
should be used with rlang's \code{\link[rlang:nse-force]{rlang::!!!()}} to expand
|
||||
the symbol list as individual arguments. For example,
|
||||
\code{dplyr::select(mtcars, !!!input$variabls)} which is
|
||||
equivalent to \code{dplyr::select(mtcars, !!input$variabls[[1]], !!input$variabls[[2]], ..., !!input$variabls[[length(input$variabls)]])}.
|
||||
|
||||
@@ -33,9 +33,7 @@ shinyApp(ui, server = function(input, output) { })
|
||||
\seealso{
|
||||
Other layout functions:
|
||||
\code{\link{fillPage}()},
|
||||
\code{\link{fixedPage}()},
|
||||
\code{\link{flowLayout}()},
|
||||
\code{\link{fluidPage}()},
|
||||
\code{\link{navbarPage}()},
|
||||
\code{\link{sidebarLayout}()},
|
||||
\code{\link{splitLayout}()}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"homepage": "https://shiny.rstudio.com",
|
||||
"repository": "github:rstudio/shiny",
|
||||
"name": "@types/rstudio-shiny",
|
||||
"version": "1.6.0-alpha.9021",
|
||||
"version": "1.7.1-alpha.9002",
|
||||
"license": "GPL-3.0-only",
|
||||
"main": "",
|
||||
"browser": "",
|
||||
@@ -51,7 +51,7 @@
|
||||
"esbuild": "^0.12.4",
|
||||
"esbuild-plugin-babel": "https://github.com/schloerke/esbuild-plugin-babel#patch-2",
|
||||
"esbuild-plugin-globals": "^0.1.1",
|
||||
"esbuild-plugin-sass": "https://github.com/schloerke/esbuild-plugin-sass#js-files-typo",
|
||||
"esbuild-plugin-sass": "^0.5.2",
|
||||
"eslint": "^7.27.0",
|
||||
"eslint-config-prettier": "^7.2.0",
|
||||
"eslint-plugin-jest": "^24.3.6",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user