| 1 |
|
| 2 |
#' Print message for deprecated functions in Shiny |
| 3 |
#' |
| 4 |
#' To disable these messages, use `options(shiny.deprecation.messages=FALSE)`. |
| 5 |
#' |
| 6 |
#' @param version Shiny version when the function was deprecated |
| 7 |
#' @param what Function with possible arguments |
| 8 |
#' @param with Possible function with arguments that should be used instead |
| 9 |
#' @param details Additional information to be added after a new line to the displayed message |
| 10 |
#' @keywords internal |
| 11 |
shinyDeprecated <- function( |
| 12 |
version, |
| 13 |
what, |
| 14 |
with = NULL, |
| 15 |
details = NULL, |
| 16 |
type = c("deprecated", "superseded") |
| 17 |
) { |
| 18 |
if (is_false(getOption("shiny.deprecation.messages"))) { |
| 19 |
return(invisible()) |
| 20 |
} |
| 21 |
|
| 22 |
type <- match.arg(type) |
| 23 |
|
| 24 |
msg <- paste0("`", what, "` is ", type, " as of shiny ", version, ".") |
| 25 |
if (!is.null(with)) { |
| 26 |
msg <- paste0(msg, "\n", "Please use `", with, "` instead.") |
| 27 |
} |
| 28 |
if (!is.null(details)) { |
| 29 |
msg <- paste0(msg, "\n", details) |
| 30 |
} |
| 31 |
|
| 32 |
# lifecycle::deprecate_soft(when, what, with = with, details = details, id = id, env = env) |
| 33 |
rlang::inform(message = msg, .frequency = "always", .frequency_id = msg, .file = stderr()) |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
deprecatedEnvQuotedMessage <- function() { |
| 38 |
if (!in_devmode()) return(invisible()) |
| 39 |
if (is_false(getOption("shiny.deprecation.messages"))) return(invisible()) |
| 40 |
|
| 41 |
# Capture calling function |
| 42 |
grandparent_call <- sys.call(-2) |
| 43 |
# Turn language into user friendly string |
| 44 |
grandparent_txt <- paste0(utils::capture.output({grandparent_call}), collapse = "\n") |
| 45 |
|
| 46 |
msg <- paste0( |
| 47 |
"The `env` and `quoted` arguments are deprecated as of shiny 1.7.0.", |
| 48 |
" Please use quosures from `rlang` instead.\n", |
| 49 |
"See <https://github.com/rstudio/shiny/issues/3108> for more information.\n", |
| 50 |
"Function call:\n", |
| 51 |
grandparent_txt |
| 52 |
) |
| 53 |
# Call less often as users do not have much control over this warning |
| 54 |
rlang::inform(message = msg, .frequency = "regularly", .frequency_id = msg, .file = stderr()) |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
#' Create disk cache (deprecated) |
| 59 |
#' |
| 60 |
#' @param exec_missing Deprecated. |
| 61 |
#' @inheritParams cachem::cache_disk |
| 62 |
#' @keywords internal |
| 63 |
#' @export |
| 64 |
diskCache <- function( |
| 65 |
dir = NULL, |
| 66 |
max_size = 500 * 1024 ^ 2, |
| 67 |
max_age = Inf, |
| 68 |
max_n = Inf, |
| 69 |
evict = c("lru", "fifo"), |
| 70 |
destroy_on_finalize = FALSE, |
| 71 |
missing = key_missing(), |
| 72 |
exec_missing = deprecated(), |
| 73 |
logfile = NULL |
| 74 |
) { |
| 75 |
shinyDeprecated("1.6.0", "diskCache()", "cachem::cache_disk()") |
| 76 |
if (is_present(exec_missing)) { |
| 77 |
shinyDeprecated("1.6.0", "diskCache(exec_missing =)") |
| 78 |
} |
| 79 |
|
| 80 |
cachem::cache_disk( |
| 81 |
dir = dir, |
| 82 |
max_size = max_size, |
| 83 |
max_age = max_age, |
| 84 |
max_n = max_n, |
| 85 |
evict = evict, |
| 86 |
destroy_on_finalize = destroy_on_finalize, |
| 87 |
missing = missing, |
| 88 |
logfile = logfile |
| 89 |
) |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
#' Create memory cache (deprecated) |
| 94 |
#' |
| 95 |
#' @param exec_missing Deprecated. |
| 96 |
#' @inheritParams cachem::cache_mem |
| 97 |
#' @keywords internal |
| 98 |
#' @export |
| 99 |
memoryCache <- function( |
| 100 |
max_size = 200 * 1024 ^ 2, |
| 101 |
max_age = Inf, |
| 102 |
max_n = Inf, |
| 103 |
evict = c("lru", "fifo"), |
| 104 |
missing = key_missing(), |
| 105 |
exec_missing = deprecated(), |
| 106 |
logfile = NULL) |
| 107 |
{ |
| 108 |
shinyDeprecated("1.6.0", "diskCache()", "cachem::cache_mem()") |
| 109 |
if (is_present(exec_missing)) { |
| 110 |
shinyDeprecated("1.6.0", "diskCache(exec_missing =)") |
| 111 |
} |
| 112 |
|
| 113 |
cachem::cache_mem( |
| 114 |
max_size = max_size, |
| 115 |
max_age = max_age, |
| 116 |
max_n = max_n, |
| 117 |
evict = evict, |
| 118 |
missing = missing, |
| 119 |
logfile = logfile |
| 120 |
) |
| 121 |
} |