File: globals.R

package info (click to toggle)
r-cran-shiny 1.7.4%2Bdfsg-2%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,256 kB
  • sloc: javascript: 24,779; sh: 28; makefile: 20
file content (25 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# A scope where we can put mutable global state
.globals <- new.env(parent = emptyenv())

.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
  # the private seed during load.
  withPrivateSeed(set.seed(NULL))

  # Create this at the top level, but since the object is from a different
  # package, we don't want to bake it into the built binary package.
  restoreCtxStack <<- fastmap::faststack()

  # Make sure these methods are available to knitr if shiny is loaded but not
  # attached.
  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
  # includes a fix for this problem
  # https://github.com/rstudio/shiny/issues/2630
  register_upgrade_message("htmlwidgets", 1.5)
}