Package {shinyelectron}


Title: Export 'Shiny' Applications as Desktop Apps using 'Electron'
Version: 0.3.0
Description: Provides tools to export 'Shiny' applications written in 'R' or 'Python' as standalone desktop applications using 'Electron'. The applications run as native, cross-platform programs. Depending on the runtime strategy chosen, end users do not need 'R' or 'Python' installed on their machine.
License: AGPL (≥ 3)
URL: https://r-pkg.thecoatlessprofessor.com/shinyelectron/, https://github.com/coatless-rpkg/shinyelectron
BugReports: https://github.com/coatless-rpkg/shinyelectron/issues
Depends: R (≥ 4.5.0)
Imports: cli (≥ 3.6.6), fs (≥ 2.1.0), jsonlite (≥ 2.0.0), rappdirs (≥ 0.3.4), rlang (≥ 1.1.0), whisker (≥ 0.4.1), processx (≥ 3.9.0), stats, tools, utils, yaml (≥ 2.3.12)
Suggests: testthat (≥ 3.3.2), mockery (≥ 0.4.5), quarto (≥ 1.5.1), renv (≥ 1.2.3), shinylive (≥ 0.5.0), withr (≥ 3.0.3)
VignetteBuilder: quarto
SystemRequirements: Node.js (>= 22.12.0), npm (>= 11.5.0)
Encoding: UTF-8
Config/testthat/edition: 3
Config/roxygen2/version: 8.1.1
NeedsCompilation: no
Packaged: 2026-12-03 03:50:04 UTC; ronin
Author: James Joseph Balamuta ORCID iD [aut, cre, cph]
Maintainer: James Joseph Balamuta <james.balamuta@gmail.com>
Repository: CRAN
Date/Publication: 2026-12-03 04:20:02 UTC

Configuration file name

Description

Configuration file name

Usage

CONFIG_FILENAME

First line of a dev-app-update.yml written by the package

Description

Only a file whose first line is exactly this text is ever replaced or removed by the package.

Usage

DEV_UPDATE_CONFIG_MARKER

Settings that take only true or false

Description

The dotted names of the settings check_logical_settings() checks. The Windows installer flags and dependencies.r.prune take only true or false as well, but are left out: config_flag() reads those, with its own rules.

Usage

LOGICAL_SETTINGS

Default configuration values for shinyelectron

Description

A list containing all default values used when no configuration file exists or when specific values are not provided.

Usage

SHINYELECTRON_DEFAULTS

Format

A named list with the following elements:

window_width

Default window width in pixels (1200)

window_height

Default window height in pixels (800)

server_port

Default local server port (3838)

app_version

Default application version ("1.0.0")

valid_app_types

Valid application types

valid_platforms

Valid target platforms

valid_architectures

Valid CPU architectures

valid_runtime_strategies

Valid runtime strategies

valid_container_engines

Valid container engines

splash

Default splash screen settings

tray

Default system tray settings

menu

Default application menu settings

updates

Default auto-update settings

preloader

Default preloader settings

container

Default container strategy settings

dependencies

Default dependency detection and runtime settings

logging

Default logging settings

signing

Default code-signing settings

lifecycle

Default lifecycle and prompt settings

installer

Default installer branding settings

runtime_versions

Maintained "latest known" runtime version pins (r, python, electron)

electron_toolchain

Pinned versions for electron-builder, electron-updater, electron-log (not config-settable)

dependencies$electron

Default Electron dependency settings; version is NULL (use pin) or a version string

dependencies$system_packages

Default system package list (NULL)


Abort because the update feed server did not start

Description

Abort because the update feed server did not start

Usage

abort_update_feed_failed(problem, stderr, call)

Arguments

problem

What went wrong, as text already formatted.

stderr

What the server wrote to standard error.

call

Call to name in the error.


Mark a UTF-8 text file with a byte order mark

Description

NSIS reads a license text file that has no byte order mark in the build machine's ANSI code page, so UTF-8 text with characters such as the copyright sign, curly quotes or accented letters shows up garbled in the installer. electron-builder converts only localized ⁠license_<lang>⁠ files. This prepends the UTF-8 byte order mark when the file is valid UTF-8 with some non-ASCII content, and leaves ASCII files, files that already start with a byte order mark, other encodings such as Latin-1, and files containing NUL bytes (such as UTF-16) unchanged.

Usage

add_utf8_bom(path)

Arguments

path

Character. Path to the text file, rewritten in place.

Value

Invisibly, TRUE when the byte order mark was added.


Report the app's display name and slug

Description

Prints the display name with the slug in export()'s progress output. When the slug came from the folder rather than from app.slug and differs from the slug the display name would give, it also says how to choose another and what changing it means for installed copies.

Usage

alert_app_identity(label, app_name, slug, pinned)

Arguments

label

Character. What the name belongs to, such as "Application".

app_name

Character. The display name.

slug

Character or NULL. The slug.

pinned

Logical. Whether the configuration sets app.slug.

Value

Called for its messages.


Ask for an app slug when none could be derived

Description

init_config() and wizard() write the slug, which comes from the directory name, into the new configuration. When the directory name has no ASCII letters or digits, they leave it out and say so with this alert.

Usage

alert_missing_slug()

Value

Called for its message.


Check Shiny Application Readiness for Export

Description

Validates that a Shiny application can be built as an Electron app. Checks app structure, configuration, build targets, runtime availability, dependencies, and signing credentials. Reports issues without aborting.

Usage

app_check(
  appdir = ".",
  app_type = NULL,
  runtime_strategy = NULL,
  platform = NULL,
  sign = NULL,
  verbose = TRUE
)

Arguments

appdir

Character string. Path to the app directory. Default ".".

app_type

Character string or NULL. App type override. If NULL, reads from config or autodetects from files in appdir.

runtime_strategy

Character string or NULL. Runtime strategy override.

platform

Character vector or NULL. Target platforms override. If NULL, uses build.platforms from ⁠_shinyelectron.yml⁠, then the current platform, as export() does. The architectures come from build.architectures, then the current architecture.

sign

Logical or NULL. Signing override.

verbose

Logical. Whether to print the report. Default TRUE.

Details

Files named in ⁠_shinyelectron.yml⁠, such as icon or splash.image, are looked up relative to appdir, as export() does. A missing icon is an error, because export() stops on it; other missing files are warnings. So is an icon that a target platform cannot use, because of its format or the size of its image, since that platform's build shows the default Electron icon, and an icons entry that the build leaves out, since it gives one icon to every target platform.

An R package the app uses that is not on dependencies.r.repos, or a Python requirement that points at a URL, a git repository, or a path, is an error too, since export() stops on it. Other dependency problems are warnings.

Value

Invisible list with:

pass

Logical. TRUE if no errors found.

errors

Character vector of fatal issues.

warnings

Character vector of non-fatal issues.

info

Character vector of informational notes.

Examples


# Check a bundled example app
app_check(example_app("r"))

# Check with explicit overrides
app_check(example_app("r"), app_type = "r-shiny", runtime_strategy = "system")



Detect an app's package dependencies

Description

Scans a Shiny app's source for the R or Python packages it uses, with the same detection shinyelectron applies at build time. This is useful before a shinylive build, in CI especially, because shinylive::export() compiles the WebAssembly bundle from the packages installed in the current session, so an app's dependencies must be installed before conversion.

Usage

app_dependencies(appdir, app_type = NULL)

Arguments

appdir

Character string. Path to the app or multi-app suite directory.

app_type

Character string or NULL. "r-shiny" or "py-shiny", or NULL to autodetect from appdir.

Value

Character vector of detected package names, excluding base R packages (for R) or the Python standard library (for Python).

Examples

# Detect the packages a bundled example app uses
app_dependencies(example_app("r"))

Name of the app directory

Description

The last part of the directory's absolute path, where base::basename() gives "." or ".." for a path such as "." or "app/..". The path is made absolute from its text alone, without resolving symbolic links: a link named in appdir keeps the link's name, and "link/.." gives the name of the folder that holds the link, not of the parent of its target. A relative path starts from the working directory that base::getwd() reports, which on macOS and Linux has its links resolved, so "." in a linked directory gives the name of the folder the link points to.

Usage

app_dir_name(appdir)

Arguments

appdir

Character string. Path to the app directory.

Value

Character string. The directory's name.


Inspect an app directory for Shiny entrypoints

Description

Returns a named list of logical flags for each entrypoint file. Used by the detector and by structure validators to avoid duplicating fs::file_exists calls.

Usage

app_entrypoints(appdir)

Arguments

appdir

Character path to the candidate app directory.

Value

Named list with elements app_py, app_r, server_r, ui_r.


Build path of a suite app's launcher icon

Description

copy_brand_assets() copies each app's icon here, and the apps manifest points the launcher at it.

Usage

app_icon_asset(app)

Arguments

app

List. One apps entry, with its icon already resolved.

Value

"assets/apps/<id>.<ext>", relative to the Electron project, or NULL when the app has no icon.


Collect the app metadata settings

Description

Reads app.description, app.author, app.homepage, and app.copyright for package.json and the About dialog, keeping only usable values: text is reduced to one line with metadata_text(), so blank text counts as unset, the author is normalized with normalize_app_author(), and a homepage must be an http or https URL (validate_config() rejects any other homepage).

Usage

app_metadata(config)

Arguments

config

List. The effective configuration.

Value

A list with description, author, homepage, and copyright entries, each NULL when unset.


Refuse to overwrite a protected directory

Description

Aborts with an informative error when dir resolves to a well-known system path (~, /, R.home()) or a path whose absolute form is three characters or fewer (covers drive roots such as ⁠C:\⁠ on Windows).

Usage

assert_safe_to_overwrite(dir)

Arguments

dir

Character string. Path to check.

Value

Invisible TRUE when the path is safe.


List Available Examples

Description

Shows all bundled example applications with their descriptions.

Usage

available_examples()

Value

A data frame with columns: name (character ID), language ("r" or "python"), type (app type, "r-shiny" or "py-shiny"), and description (human-readable summary).

Examples

available_examples()


Append app-specific package installs to the Dockerfile

Description

Bakes system dependencies (via the Posit Package Manager sysreqs API and config$dependencies$system_packages) and R/Python package installs into the image at build time so container launch does not have to compile/install packages on the user's machine.

Usage

bake_dockerfile_dependencies(output_dir, dockerfile_dest, config = NULL)

Details

For R apps the base image is rocker/r-ver, which pre-wires P3M binaries; packages are therefore installed via install.packages().


Build Electron Application

Description

Builds a distributable Electron application from a converted Shiny app. Creates platform-specific installers and executables.

Usage

build_electron_app(
  app_dir,
  output_dir,
  app_name = NULL,
  app_type = "r-shiny",
  runtime_strategy = "shinylive",
  sign = FALSE,
  platform = NULL,
  arch = NULL,
  icon = NULL,
  config = NULL,
  overwrite = FALSE,
  verbose = TRUE
)

Arguments

app_dir

Character string. Path to the converted Shiny/shinylive application.

output_dir

Character string. Path where the built Electron app will be saved.

app_name

Character string. Name of the application. If NULL, uses the name of the app_dir directory.

app_type

Character string. Language of the Shiny app: "r-shiny" (default) or "py-shiny". Unlike export(), this function does not autodetect the language from source files – the default "r-shiny" is used when app_type is not supplied. Supply "py-shiny" explicitly for Python Shiny applications. The legacy values "r-shinylive" / "py-shinylive" are accepted with a deprecation warning and translate to the canonical language plus runtime_strategy = "shinylive".

runtime_strategy

Character string. Runtime strategy: "shinylive", "bundled", "system", "auto-download", or "container". Default "shinylive".

sign

Logical. Whether to enable code signing for the built application. Default is FALSE.

platform

Character vector. Target platforms: "win", "mac", "linux". If NULL, builds for current platform. The build.platforms key of config is not read here; export() reads it.

arch

Character vector. Target architectures: "x64", "arm64". If NULL, uses current architecture. The build.architectures key of config is not read here; export() reads it.

icon

Character string. Path to application icon file, absolute or relative to the working directory. A PNG (1024x1024 or larger) or an .icns file serves every platform; an .ico file serves Windows only. The icon and icons keys of config are not read here.

config

List. Configuration from _shinyelectron.yml file (optional). Used for template variables like window dimensions, port, and app version. File paths in it, such as splash.image, tray.icon, signing.win.certificate_file and installer.license_file, are used as given: absolute, or relative to the working directory, like the icon argument. export() reads ⁠_shinyelectron.yml⁠ itself and first resolves those paths against the app directory. A splash image or tray icon that does not exist is left out with a warning; a missing license file stops the build.

overwrite

Logical. Whether to overwrite existing output directory. Default is FALSE.

verbose

Logical. Whether to display detailed progress information. Default is TRUE.

Value

Character string. Path to the built Electron application directory.

Details

This function creates a complete Electron application by:

Examples


# Build Electron app for current platform
build_electron_app(
  app_dir = "path/to/shinylive/app",
  output_dir = "path/to/electron/build",
  app_name = "My Shiny App",
  app_type = "r-shiny"
)

# Build for multiple platforms
build_electron_app(
  app_dir = "path/to/app",
  output_dir = "path/to/build",
  app_name = "My App",
  app_type = "r-shiny",
  platform = c("win", "mac", "linux")
)


Build for target platforms

Description

Build for target platforms

Usage

build_for_platforms(
  output_dir,
  platform,
  arch,
  sign = FALSE,
  config = NULL,
  verbose = TRUE
)

Arguments

output_dir

Character Electron project directory

platform

Character vector of target platforms

arch

Character vector of target architectures

sign

Logical whether to code-sign the build

config

List. The effective configuration, or NULL. A signed build passes its signing.mac.team_id to electron-builder (see electron_builder_env()).

verbose

Logical whether to show progress


Build multi-app Electron application

Description

Build multi-app Electron application

Usage

build_multi_app(
  apps_dir,
  output_dir,
  app_name,
  apps_manifest,
  default_type,
  runtime_strategy,
  sign,
  platform,
  arch,
  icon,
  config,
  overwrite,
  verbose,
  r_packages = NULL,
  r_repos = NULL,
  py_packages = NULL,
  py_index_urls = NULL,
  shinylive_site_dir = NULL
)

Build the electron-builder nsis block from installer config

Description

Maps installer.one_click, installer.allow_to_change_installation_directory and installer.per_machine onto electron-builder's oneClick, allowToChangeInstallationDirectory and perMachine. Each option is emitted only when the config sets it, so electron-builder's own defaults apply otherwise: the one-click installer installs for the current user, and the wizard (one_click: false) asks whether to install for all users and does not offer a directory page. validate_config() has already checked the values.

Usage

build_nsis_config(config)

Arguments

config

List. The effective configuration.

Details

installer.license_file becomes the NSIS license, pointing at the copy that copy_installer_license() places in the generated project.

Value

A named list for the package.json build.nsis field, empty when no installer option is set.


Clear the asset cache

Description

Removes cached R installations and/or npm packages from the cache directory.

Usage

cache_clear(what = c("all", "r", "npm", "nodejs", "python"))

Arguments

what

Character string specifying what to clear. One of "all", "r", "npm", "nodejs", or "python".

Value

Invisibly returns NULL.

Details

Use this function to free disk space or force re-downloading of assets:

If the cache directory doesn't exist, a message is shown and nothing is done.

Examples


# Clear everything in the cache
cache_clear()

# Clear only R installations
cache_clear("r")

# Clear only npm packages
cache_clear("npm")

# Clear only Node.js installations
cache_clear("nodejs")

# Clear only Python installations
cache_clear("python")


Get or create the cache directory path

Description

Returns the path where shinyelectron stores downloaded runtimes (R, Python, Node.js) and other cached assets. By default, the directory is created if it doesn't already exist. Pass create = FALSE to query the path without side effects.

Usage

cache_dir(create = TRUE)

Arguments

create

Logical. Whether to create the directory if it doesn't exist. Default is TRUE.

Value

Character string. Absolute path to the cache directory, typically ⁠~/.cache/shinyelectron/assets⁠ on Linux, ⁠~/Library/Caches/shinyelectron/assets⁠ on macOS, or ⁠\%LOCALAPPDATA\%/shinyelectron/shinyelectron/Cache/assets⁠ on Windows.

Cache Layout

Cached runtimes are organized by type, platform, architecture, and version:

assets/
|-- r/
|   |-- win/x64/4.5.3/
|   |-- mac/arm64/4.5.3/
|-- python/
|   |-- win/x64/3.14.6/
|   |-- mac/arm64/3.14.6/
|-- nodejs/
|   |-- v22.11.0/darwin-arm64/
|   |-- v22.11.0/win-x64/

Use cache_info() to see what's actually installed with disk usage.

See Also

cache_info() to see what's cached, cache_clear() to remove cached assets, cache_remove() to remove a specific version.

Examples

# Query the cache path without creating it
cache_dir(create = FALSE)

# Get or create the cache directory (writes to the user cache dir)
if (interactive()) {
  cache_dir()
}


Show cached runtime information

Description

Lists all cached runtimes (R, Python, Node.js) with their versions, platforms, architectures, and disk usage. Modeled after shinylive::assets_info().

Usage

cache_info(quiet = FALSE)

Arguments

quiet

Logical. If TRUE, suppresses console output and returns the results invisibly. Default is FALSE.

Value

A data frame (returned invisibly) with columns: runtime (character), version (character), platform (character), arch (character), size (character, human-readable), and path (character).

See Also

cache_clear() to remove cached assets, cache_dir() for the cache location.

Examples

# Programmatic access (safe to run -- just inspects the cache dir)
df <- cache_info(quiet = TRUE)
nrow(df)  # number of cached runtimes

# Pretty-print the cache contents
cache_info()


Get path to cached R installation

Description

Creates the path to a specific R installation in the cache based on version, platform, and architecture.

Usage

cache_r_path(version, platform, arch)

Arguments

version

Character string. R version (e.g., "4.1.0").

platform

Character string. Target platform ("win", "mac", or "linux").

arch

Character string. Target architecture ("x64" or "arm64").

Value

Character string. The path to the cached R installation for the specified version, platform, and architecture.

Details

The path is structured as ⁠cache_dir()/r/[platform]/[arch]/[version]⁠. This function does not check if the installation exists at that location.


Remove a specific cached runtime version

Description

Removes a single cached runtime version instead of clearing the entire cache. Use cache_info() to see what's available.

Usage

cache_remove(runtime, version, platform = NULL, arch = NULL)

Arguments

runtime

Character string. One of "r", "python", or "nodejs".

version

Character string. Version to remove (e.g., "4.5.3", "3.14.6", "v22.11.0").

platform

Character string. Platform ("win", "mac", or "linux"). Required for all runtimes including Node.js. Use the same canonical names that cache_info() reports in the platform column (e.g. "mac", not "darwin").

arch

Character string. Architecture ("x64" or "arm64"). Required for all runtimes including Node.js.

Value

Invisibly returns TRUE if removed, FALSE if not found.

See Also

cache_info() to list cached versions, cache_clear() to remove all cached assets of a type.

Examples


# Remove a specific R version
cache_remove("r", "4.4.0", "mac", "arm64")

# Remove a cached Python version
cache_remove("python", "3.14.6", "win", "x64")

# Remove one platform/arch slot of a Node.js version
cache_remove("nodejs", "v22.11.0", "mac", "arm64")


Evaluate an expression, collecting its warnings and error

Description

Records every warning expr gives, in order, and lets it carry on, so app_check() can report each one. An error ends the evaluation; the warnings given before it are kept.

Usage

catch_conditions(expr)

Arguments

expr

An expression, evaluated in the calling function's environment.

Value

A list with value, the value of expr or NULL after an error, error, the error condition or NULL, and warnings, the messages of the warnings given.


Evaluate an expression and return its error

Description

Lets each check in app_check() record a failure in its own results.

Usage

catch_error(expr)

Arguments

expr

An expression, evaluated in the calling function's environment.

Value

NULL when expr finishes without an error, otherwise the error condition.


Check the app slug before a build starts

Description

The build uses the slug only when it assembles the Electron app, after the conversion and any runtime download. Checking it right after resolve_app_slug() reports an invalid app.slug, or a name and directory that give no slug, before that work.

Usage

check_app_slug(slug)

Arguments

slug

The resolved slug, or NULL when none could be derived.

Value

Invisible TRUE; aborts otherwise.


Check Auto-Update Status

Description

Reports the current auto-update configuration status.

Usage

check_auto_update_status(appdir)

Arguments

appdir

Character path to app directory

Value

Invisibly returns the updates configuration list, which is always present because read_config() deep-merges defaults. Elements include enabled (logical, FALSE by default when auto-updates have never been enabled), provider (character), check_on_startup, auto_download, auto_install (logical), github (a list with owner, repo, private), used by the GitHub provider, and generic (a list with url), used by the generic HTTP provider.

Examples

# Check update configuration on a temporary app
app <- file.path(tempdir(), "check-updates-demo")
dir.create(app, showWarnings = FALSE)
writeLines("library(shiny)", file.path(app, "app.R"))
enable_auto_updates(app, owner = "myusername", repo = "myapp", verbose = FALSE)
check_auto_update_status(app)


Stop when a macOS target is built on another system

Description

electron-builder makes macOS apps and their disk images only on macOS. Elsewhere a mac build fails, and build_for_platforms() only reports the failure, so export() would finish without an installer. It calls this before anything is converted instead.

Usage

check_build_host(platform, from_config = character(0))

Arguments

platform

Character vector. The resolved target platforms.

from_config

Character vector. The settings that supplied the targets, from resolve_build_targets().

Value

Invisibly TRUE. Stops with an error of class shinyelectron_mac_host when a target is mac and the build machine is not.


Warn when the configured Windows signing certificate does not exist

Description

export() calls this when it signs a Windows build, whether signing was turned on by the sign argument or by signing.sign. The key is kept, so electron-builder still fails on it rather than quietly building an unsigned installer.

Usage

check_config_certificate(config, base_dir = NULL)

Arguments

config

List. The configuration, with paths already resolved.

base_dir

Character or NULL. The directory relative paths in ⁠_shinyelectron.yml⁠ were resolved against, named in the warning.

Value

TRUE when the certificate is unset or exists, otherwise FALSE (invisibly).


Check the app icon named in the configuration

Description

A configured icon that does not exist stops the export, as a missing icon argument does in validate_icon(): a build that quietly fell back to the default Electron icon would be easy to ship by mistake.

Usage

check_config_icon(config, platform, base_dir, call = parent.frame())

Arguments

config

List. The configuration.

platform

Character. The target platform: "mac", "win" or "linux".

base_dir

Character. The directory relative paths in ⁠_shinyelectron.yml⁠ were resolved against, named in the error.

call

Environment. The function the error is reported from.

Value

The icon path, or NULL when no icon is configured.


Stop when the app folder holds a dev-app-update.yml the package did not write

Description

Stop when the app folder holds a dev-app-update.yml the package did not write

Usage

check_dev_update_config_free(app_dir)

Arguments

app_dir

App folder.

Value

The path of dev-app-update.yml, invisibly.


Abort unless a value is a single string matching a pattern

Description

The match is on bytes with PCRE and ⁠\\z⁠, so non-ASCII text, a trailing newline and a control character never match.

Usage

check_feed_value(x, pattern, arg, class, hint)

Arguments

x

Value to check.

pattern

PCRE pattern, anchored with ^ and ⁠\\z⁠.

arg

Argument name for the message.

class

Condition class.

hint

Text saying what is accepted.


Check the address of a generic update server

Description

The generic provider reads latest.yml and the installers from a folder on a static web server. The address must be an ⁠http://⁠ or ⁠https://⁠ URL. Plain ⁠http://⁠ lets anyone on the network change what the app downloads, so it warns unless the host is localhost or ⁠127.0.0.1⁠. An address with a backslash, whitespace or a control character is refused, because the updater would read it differently from how it looks.

Usage

check_generic_update_url(url, arg = "updates.generic.url")

Arguments

url

Value of updates.generic.url.

arg

Name of the setting, used in messages.

Details

enable_auto_updates() calls it for its url argument, and check_update_settings() for updates.generic.url.

Value

url, invisibly. Aborts with class shinyelectron_invalid_update_url when url is not a single ⁠http://⁠ or ⁠https://⁠ address, and warns with class shinyelectron_insecure_update_url for ⁠http://⁠ to any other host.


Stop or warn when app text contains $

Description

electron-builder passes the app name, description, author's name, and copyright to NSIS, which builds the Windows installer, without escaping $. NSIS reads $ as the start of a variable: the build fails on an unknown one (electron-builder treats NSIS warnings as errors), and a known one silently changes the text. So a $ stops an export that builds a Windows installer, before any conversion, and warns for any other.

Usage

check_installer_text(app_name, config, windows)

Arguments

app_name

Character string. The display name.

config

List. The effective configuration.

windows

Logical. Whether the export builds a Windows installer.

Value

Invisible TRUE; aborts or warns when a value contains $.


Check the settings that take only true or false

Description

Stops when one of the LOGICAL_SETTINGS holds anything but a single TRUE or FALSE: a string, a number, NA, a vector longer than one, or a list. A quoted "yes" or "false" is not read as the value it spells, because the build reads these settings in more than one way: a template renders a section for any non-empty string, while isTRUE() is false for one, so a quoted value could turn on only part of a feature. A setting that is absent is fine.

Usage

check_logical_settings(config)

Arguments

config

List of configuration values.

Value

config, invisibly. Aborts with class shinyelectron_invalid_logical_setting.


Stop when apps pin one Python package to different versions

Description

The apps of a bundled suite share one Python library, and pip installs none of their packages when two exact pins of a package disagree. Pins under different environment markers are left to pip, since both can hold.

Usage

check_py_pin_conflicts(specs_by_app)

Arguments

specs_by_app

Named list. Each app's requirement specs, named by the app's name.

Value

Invisibly, NULL.


Check that an app's R packages are on its repositories

Description

The system, auto-download and container strategies install an app's R packages from dependencies.r.repos when the app first starts, and the bundled strategy installs them from there at build time. A package the repositories lack, such as one installed on the build machine from GitHub or a local folder, stops the export here, before anything is downloaded.

Usage

check_r_packages_on_repos(packages, repos, strategy, lib.loc = NULL)

Arguments

packages

Character vector. The app's R packages, without the local packages of a bundled build.

repos

Character vector or list. Repository URLs.

strategy

Character. The runtime strategy, for the advice given.

lib.loc

Character vector or NULL. Libraries to look in for the installed copy of a missing package.

Details

Each repository's source index is read without R's filters for the build machine's R version and operating system, since the app's R may differ. A repository that cannot be read is passed over. When a package is on none of the repositories that were read and one could not be read, the check warns and the export goes on, so an offline build still works.

Value

Invisibly, the packages that were not found.


Stop when a runtime strategy cannot build every target

Description

The bundled and auto-download strategies embed a runtime, or a manifest for one, for a single platform and architecture, and it would be packaged into every installer. A build that uses either one needs a single target. export() checks this before anything is copied; build_electron_app() and build_multi_app() check it again for direct callers.

Usage

check_single_target(
  strategies,
  platform,
  arch,
  apps = NULL,
  from_config = character(0)
)

Arguments

strategies

Character vector. The runtime strategy of the app, or of each app in a suite.

platform, arch

Character vectors. The resolved targets.

apps

List or NULL. A suite's apps entries, in the order of strategies, to name the app in the error.

from_config

Character vector. The settings that supplied the targets, from resolve_build_targets().

Value

Invisibly TRUE. Stops with an error of class shinyelectron_single_target otherwise.


Warn when the tray cannot read its icon on a target platform

Description

The tray shows tray.icon, or else the app icon. main.js loads the file with Electron's nativeImage, which reads PNG and JPEG files on every platform and ICO files only on Windows, and cannot read an .icns file. Where it cannot read the file, the tray shows a default icon instead. When the tray is enabled, this warns about the target platforms where that happens, judging the file by its extension.

Usage

check_tray_icon(config, icon, platform = NULL)

Arguments

config

List. The effective configuration.

icon

Character path to the app icon, or NULL.

platform

Character vector of target platforms ("mac", "win", "linux"), or NULL for the current platform.

Value

Invisibly, the target platforms where the tray cannot read the file, or character(0).


Warn about the icons entries an export leaves out

Description

One export copies one app icon and gives it to every target platform that can use it: icon, or else the icons entry of the first target platform (see config_icon()). The icons entries of the other target platforms are then not used.

Usage

check_unused_icons(config, platform)

Arguments

config

List. The configuration.

platform

Character vector. The target platforms, the first one first.

Value

Invisibly, the fields of the entries that are not used, such as "icons.win", or character(0).


Check the update settings a build will use

Description

Only while updates.enabled is true: the generic provider needs a usable address (check_generic_update_url()), and the S3 provider stops, since the build does not support it yet. Called from three places: by validate_config(), so for every read_config(); by build_electron_app(); and by build_multi_app(). The two build functions take a configuration list that may not have come through read_config(), and check it before any output is deleted. export() has already read the configuration, so it muffles the second ⁠http://⁠ warning from its build call.

Usage

check_update_settings(config)

Arguments

config

List. The configuration, or NULL.

Value

config, invisibly. Aborts with class shinyelectron_invalid_update_url or shinyelectron_unsupported_update_provider, and warns with class shinyelectron_insecure_update_url.


Abort unless a version can be offered by a development update feed

Description

Accepts one string of three numbers separated by dots, such as "2.0.0", and nothing else: no leading v, no pre-release part, no NA.

Usage

check_update_version(version)

Arguments

version

Value given as update_version to run_electron_app().

Value

version, invisibly.


Abort unless an app was exported with auto-updates on, by this version

Description

An app exported without them does not depend on electron-updater and has no update check to try. An app exported with them by an earlier shinyelectron has a main.js that never turns on electron-updater's forceDevUpdateConfig, so it would not read the local feed.

Usage

check_updates_exported(package_json, app_dir)

Arguments

package_json

The app's package.json, as a list.

app_dir

App folder, named in the message.

Value

package_json, invisibly.


Collect unknown configuration keys

Description

Compares the keys in the config file against the accepted keys (config_schema()) and returns the dotted paths of any key that would otherwise be silently ignored. It descends only where both the config value and the default are named lists, the rule merge_config_deep() uses, so a value that the merge takes whole is not inspected: free-form maps (container.volumes, container.env), values whose default is a list (dependencies.r.repos), the entries of the multi-app apps list and the top-level icon shortcut.

Usage

collect_unknown_config_keys(
  config,
  defaults = config_schema(),
  path = character(0)
)

Arguments

config

List. User configuration parsed from the YAML file.

defaults

List. Schema to compare against (defaults to the full schema).

path

Character vector. Internal recursion path.

Value

Character vector of unknown dotted key paths (possibly empty).


Compute SHA256 checksum

Description

Uses tools::sha256sum() to compute SHA256 hash.

Usage

compute_sha256(file_path)

Arguments

file_path

Character path to file

Value

Character SHA256 hash, or NULL if unable to compute


Check that a configured path names an existing file

Description

Check that a configured path names an existing file

Usage

config_file_exists(path)

Arguments

path

A configuration value.

Value

TRUE when path is a single string naming an existing file (a directory does not count), otherwise FALSE.


Read a true/false setting from the configuration

Description

YAML's unquoted true and false (and yes and no, which the YAML parser also reads as logical) pass through. A quoted "true", "false", "yes" or "no", in any case, is read as the matching logical with a warning, because a quoted value is easy to write by accident and earlier versions passed it through. Anything else stops with an error that names the key.

Usage

config_flag(value, field, default = NULL)

Arguments

value

Value read from the configuration.

field

Character. Dotted name of the key, used in messages.

default

Value returned when value is NULL.

Value

TRUE, FALSE, or default.


Pick the app icon named in the configuration

Description

The top-level icon wins over the per-platform icons entry, as in export().

Usage

config_icon(config, platform)

Arguments

config

List. The configuration.

platform

Character. The target platform: "mac", "win" or "linux".

Value

NULL when no icon is configured; otherwise a list with field (the key, such as "icons.mac") and path.


Configuration keys accepted in _shinyelectron.yml

Description

The keys of default_config() plus the top-level keys that have no default: the icon shortcut, the multi-app apps list and the logging section that map_logging_config() maps onto app.log_dir and app.log_level.

Usage

config_schema()

Value

Named list shaped like default_config().


Get a nested configuration value

Description

Get a nested configuration value

Usage

config_value(config, key)

Arguments

config

List. The configuration.

key

Character vector. The names leading to the value, such as c("splash", "image").

Value

The value, or NULL when any level is missing.


Convert a Shiny app to the shinylive format

Description

Dispatches to the R or Python shinylive converter based on language.

Usage

convert_app_to_shinylive(appdir, destdir, app_type, verbose = TRUE)

Arguments

appdir

Character. Source Shiny app directory.

destdir

Character. Export destination.

app_type

Character. "r-shiny" or "py-shiny".

verbose

Logical.

Value

Character. Path to the converted shinylive app.


Convert Python Shiny Application to Shinylive

Description

Converts a Python Shiny application directory into a shinylive application that can run entirely in the browser using Pyodide.

Usage

convert_py_to_shinylive(
  appdir,
  output_dir,
  subdir = NULL,
  overwrite = FALSE,
  verbose = TRUE
)

Arguments

appdir

Character string. Path to the directory containing the Python Shiny application.

output_dir

Character string. Path where the converted shinylive app will be saved.

subdir

Character or NULL. When set, the app is exported into a <subdir> subdirectory of output_dir as an additive shared-site export, preserving existing contents (including a shared shinylive/ asset tree). When NULL (default), a single-app export is performed and an existing output_dir is removed when overwrite = TRUE.

overwrite

Logical. Whether to overwrite existing output directory. Default is FALSE.

verbose

Logical. Whether to display detailed progress information. Default is TRUE.

Value

Character string. Path to the converted shinylive application directory.

Details

This function converts a Python Shiny application to shinylive format using the Python shinylive package. The application will run entirely in the browser using Pyodide (Python compiled to WebAssembly).

Requirements:

Examples


convert_py_to_shinylive(
  appdir = "path/to/python/shiny/app",
  output_dir = "path/to/shinylive/output"
)


Convert Shiny Application to Shinylive

Description

Converts a regular Shiny application directory into a shinylive application that can run entirely in the browser without requiring an R server.

Usage

convert_shiny_to_shinylive(
  appdir,
  output_dir,
  subdir = NULL,
  overwrite = FALSE,
  verbose = TRUE
)

Arguments

appdir

Character string. Path to the directory containing the Shiny application.

output_dir

Character string. Path where the converted shinylive app will be saved.

subdir

Character or NULL. When set, the app is exported into a <subdir> subdirectory of output_dir as an additive shared-site export: existing contents of output_dir (including a shared shinylive/ asset tree) are preserved. When NULL (default), a single-app export is performed and an existing output_dir is removed when overwrite = TRUE.

overwrite

Logical. Whether to overwrite existing output directory. Default is FALSE.

verbose

Logical. Whether to display detailed progress information. Default is TRUE.

Value

Character string. Path to the converted shinylive application directory.

Details

This function converts a Shiny application to shinylive format, which allows the application to run entirely in the browser using WebR. The conversion process:

Examples


# Convert a Shiny app to shinylive
convert_shiny_to_shinylive(
  appdir = "path/to/shiny/app",
  output_dir = "path/to/shinylive/output"
)


Copy the Dockerfile for the container strategy and bake in app dependencies

Description

Copy the Dockerfile for the container strategy and bake in app dependencies

Usage

copy_and_bake_dockerfiles(output_dir, app_type, config = NULL, verbose = TRUE)

Arguments

output_dir

Character. Destination build directory.

app_type

Character. Application type (e.g. "r-shiny", "py-shiny").

config

List of configuration values from the config file, or NULL. Used to resolve the runtime version that is baked into the ARG default line of the copied Dockerfile.

verbose

Logical. Whether to show progress messages.


Copy application files to Electron project

Description

Copy application files to Electron project

Usage

copy_app_files(
  app_dir,
  output_dir,
  app_type,
  runtime_strategy = NULL,
  verbose = TRUE
)

Arguments

app_dir

Character source app directory

output_dir

Character destination directory

app_type

Character application type

runtime_strategy

Character resolved runtime strategy. When "shinylive" the source is already a WebAssembly bundle, so the Shiny entrypoint sanity check is skipped.

verbose

Logical whether to show progress


Copy backend module(s) and their shared JS helpers into the build

Description

Copy backend module(s) and their shared JS helpers into the build

Usage

copy_backend_modules(output_dir, backend_module, is_multi_app)

Copy branding assets into the build

Description

Copies the app icon (to icon_asset_path()), the splash image, the tray icon (to tray_icon_file()) and, for a multi-app suite, each app's launcher icon (to app_icon_asset()). The paths are used as given: export() has resolved them against the app directory, and process_templates() has dropped optional files that do not exist.

Usage

copy_brand_assets(output_dir, icon, config, apps = NULL)

Arguments

output_dir

Character. The Electron project directory.

icon

Character path to the app icon, or NULL.

config

List. The effective configuration.

apps

List or NULL. The apps entries of a multi-app suite.


Copy the top-level contents of one directory into another

Description

fs::dir_copy(src, dst) has different semantics across platforms and fs versions: on some it creates dst and copies the contents of src into it, on others it creates dst/basename(src)/.... This helper forces the "copy contents into target" semantics by creating a fresh, empty dst and then copying each top-level entry from src into it with base R.

Usage

copy_dir_contents(src, dst)

Arguments

src

Character path to the source directory.

dst

Character path to the destination directory. Created if absent; wiped if present.

Value

Invisible dst.


Copy the Windows installer license into the build

Description

electron-builder runs inside the generated project, so the file named by installer.license_file is copied to installer_license_path(), which build_nsis_config() references as the NSIS license. export() has already resolved the path against the app directory; a config passed directly to build_electron_app() uses paths relative to the working directory. A plain-text copy is passed through add_utf8_bom() so NSIS reads it as UTF-8.

Usage

copy_installer_license(output_dir, config)

Arguments

output_dir

Character. The Electron project directory.

config

List. The effective configuration.

Value

Invisibly, the path of the copy, or NULL when no license is set.


Get default configuration values

Description

Returns the default configuration used when no config file exists or for values not specified in the config file.

Usage

default_config()

Value

List of default configuration values


Valid demo build matrix

Description

Enumerates every (demo, strategy, platform, arch) combination the demo build workflow produces, after applying validity rules. The CI workflow and the download tables in the README and the download-demos article all read this, so the build matrix and the published links cannot drift.

Usage

demo_release_matrix()

Value

A data frame with one row per valid combination and columns demo, name, language, strategy, platform, arch, runner, asset_name, requirement.


Autodetect the app type from a directory

Description

Scans appdir for Shiny entrypoints and returns the implied language. R apps may use app.R or the pair server.R plus ui.R. Python apps use app.py. A directory that carries both R and Python entrypoints is rejected; the multi-app-suite path is the right place to combine them.

Usage

detect_app_type(appdir)

Arguments

appdir

Character path to the candidate app directory. Must exist.

Value

Character, either "r-shiny" or "py-shiny".


Detect available container engine

Description

Searches for Docker or Podman on the system.

Usage

detect_container_engine(preference = NULL)

Arguments

preference

Character string or NULL. Preferred engine ("docker" or "podman").

Value

Character string ("docker" or "podman") or NULL if none found.


Detect current architecture

Description

Detect current architecture

Usage

detect_current_arch()

Value

Character string representing current architecture ("x64" or "arm64")


Detect current platform

Description

Detect current platform

Usage

detect_current_platform()

Value

Character string representing current platform ("win", "mac", or "linux")


Detect Python package dependencies from requirements files

Description

Reads requirements.txt or pyproject.toml to determine Python package dependencies. Does NOT parse import statements – the module-name-to-package-name mapping (e.g., ⁠import cv2⁠ maps to opencv-python) makes import parsing unreliable.

Usage

detect_py_dependencies(appdir)

Arguments

appdir

Character string. Path to the app directory.

Details

Prefers requirements.txt over pyproject.toml when both exist. Warns if neither file is found, or if pyproject.toml has no packages in the dependencies of its ⁠[project]⁠ table.

Value

Character vector of unique package names (sorted).


Detect R package dependencies from source files

Description

Uses renv::dependencies() to scan R source files for package references. This catches library(), require(), pkg::func(), loadNamespace(), and other patterns.

Usage

detect_r_dependencies(appdir)

Arguments

appdir

Character string. Path to the app directory.

Value

Character vector of unique package names (sorted), excluding base and recommended R packages.


Path of the development update config in an app folder

Description

Path of the development update config in an app folder

Usage

dev_update_config_path(app_dir)

Arguments

app_dir

App folder.

Value

Path string.


Disable Auto-Updates

Description

Disables automatic update checking in the configuration file.

Usage

disable_auto_updates(appdir, verbose = TRUE)

Arguments

appdir

Character path to app directory

verbose

Logical whether to show progress messages. Default TRUE.

Value

Invisibly returns the path to the updated config file.

Examples

# Disable updates on a temporary app
app <- file.path(tempdir(), "disable-updates-demo")
dir.create(app, showWarnings = FALSE)
writeLines("library(shiny)", file.path(app, "app.R"))
enable_auto_updates(app, owner = "myusername", repo = "myapp", verbose = FALSE)
disable_auto_updates(app)


Check whether electron-builder produced output for a platform

Description

electron-builder 26.x has a known bug where the build completes and the installer is written to disk, but the process then exits with status 1 during post-build publish metadata. When that happens, processx-invoked npm inherits the non-zero exit even though the .dmg/.exe/.AppImage is sitting right there. We treat "artifact exists" as success.

Usage

dist_has_platform_artifact(output_dir, p)

Arguments

output_dir

Character Electron project directory

p

Character platform identifier ("mac", "win", or "linux")

Value

Logical: TRUE if a platform-specific installer is present.


Download and extract a portable runtime into a cache directory

Description

Shared helper for install_r_portable() and install_python_standalone(). Handles the common flow: cache-hit short-circuit, download to temp file, extract by archive type, verify the expected executable appears, cleanup.

Usage

download_and_extract_portable_tool(
  label,
  version,
  install_path,
  download_url,
  executable_finder,
  force = FALSE,
  is_installed = FALSE,
  expected_sha256 = NULL,
  verbose = TRUE
)

Arguments

label

Character. Human-readable tool name for messages ("R", "Python").

version

Character. Version string.

install_path

Character. Target cache directory for the extracted archive. Already-populated path is returned unless force is TRUE.

download_url

Character. URL to the archive.

executable_finder

Function with no arguments that returns the path to the tool's executable after extraction, or NULL if not found.

force

Logical. Reinstall even if install_path already exists.

is_installed

Logical. Whether the runtime is already present.

expected_sha256

Character or NULL. Expected SHA-256 of the archive. When supplied, the download is verified before extraction.

verbose

Logical. Whether to print progress messages.

Details

install_nodejs() has additional requirements (SHA256 checksums, directory renaming after extraction) and implements its own flow.

Value

Invisibly returns the installation path.


Warn about and drop the optional configured files that do not exist

Description

Dropping the key makes the build use its default instead of referring to a file that is never copied. export() calls this once the paths are resolved, and process_templates() calls it again for a configuration passed straight to build_electron_app().

Usage

drop_missing_config_files(config, base_dir = NULL)

Arguments

config

List. The configuration.

base_dir

Character or NULL. The directory relative paths in ⁠_shinyelectron.yml⁠ were resolved against, named in the warning.

Value

config, without the missing files.


Environment for the electron-builder processes

Description

electron-builder 26 reads the notarization team ID only from the APPLE_TEAM_ID environment variable; its configuration has no field for it. For a signed build, signing.mac.team_id is therefore passed to electron-builder as APPLE_TEAM_ID. A team ID already set in APPLE_TEAM_ID wins, as the build leaves the signing variables the user set alone. An empty one counts as unset, as it does for electron-builder.

Usage

electron_builder_env(config, sign)

Arguments

config

List. The effective configuration, or NULL.

sign

Logical. Whether the build is signed.

Value

A value for the env argument of processx::run(): the result of nodejs_subprocess_env(), extended with APPLE_TEAM_ID when the configuration supplies it.


Fetch the latest published Electron version from the npm registry

Description

Queries ⁠https://registry.npmjs.org/electron/latest⁠ and returns the version field as a character string. Used when dependencies$electron$version is set to "latest".

Usage

electron_latest_version()

Value

Character version string (e.g. "45.5.0").


Describe why the Electron version an export uses is out of support

Description

Electron supports only its newest ELECTRON_SUPPORTED_MAJORS major versions. The newest is looked up with electron_latest_version() under a five-second timeout, which is restored on exit. The check is advisory, so it returns NULL when the version is "latest", cannot be read as a version number, or the lookup fails.

Usage

electron_support_problem(config)

Arguments

config

Full app configuration list.

Value

A single sentence, or NULL when there is no problem to report.


Embed a portable Python runtime into a bundled Electron build

Description

Behavior-preserving extraction of the Python bundled-embedding block from build_electron_app(). ALWAYS installs + copies the interpreter so the shared runtime/Python path exists for suite-wide bundled detection; only the pip install is gated on a non-empty packages set. Warn-only (not abort) on pip failure; the result is not verified, matching the original block. Reproduces the three output_dir-derived paths and the unix-only fallback glob so the native-py.js sys.path expectations hold.

Usage

embed_python_runtime(
  output_dir,
  packages,
  index_urls,
  version,
  platform,
  arch,
  verbose = TRUE
)

Arguments

output_dir

Character. The Electron app output directory.

packages

Character vector. Python package specs (may be empty/NULL).

index_urls

Character vector. PyPI-like index URLs.

version

Character. Resolved Python version (non-NULL from callers).

platform

Character scalar. Target platform.

arch

Character scalar. Target architecture.

verbose

Logical. Whether to display progress.

Value

Invisibly, the path to the embedded runtime/Python directory.


Embed a portable R runtime into a bundled Electron build

Description

Behavior-preserving extraction of the R bundled-embedding block from build_electron_app(). ALWAYS installs + copies the interpreter (and resolves symlinks) so the shared runtime/R path exists for suite-wide bundled detection; only the package install is gated on a non-empty package set (packages plus any local packages and their declared dependencies). packages is the DIRECT set (as stored in dependencies.json); the recursive dependency closure and the pre_installed setdiff are resolved here, against the freshly-created runtime/R/library. Local packages are installed last, with install_local_r_packages().

Usage

embed_r_runtime(
  output_dir,
  packages,
  repos,
  version,
  platform,
  arch,
  verbose = TRUE,
  prune = TRUE,
  local_packages = character(0)
)

Arguments

output_dir

Character. The Electron app output directory.

packages

Character vector. DIRECT R package names (may be empty/NULL).

repos

Character vector. CRAN-like repository URLs. NULL uses the default CRAN mirror.

version

Character. Resolved R version (non-NULL from callers).

platform

Character scalar. Target platform ("win"/"mac"/"linux").

arch

Character scalar. Target architecture ("x64"/"arm64").

verbose

Logical. Whether to display progress.

prune

Logical. Whether to remove the test and documentation files that prune_bundled_r_runtime() allowlists once the packages are installed. Callers pass the validated dependencies.r.prune setting.

local_packages

Local R packages to install into the bundled library after the repository packages: the list resolve_local_packages() returned, which is used as it was read, or paths to package source folders or .tar.gz source tarballs, which are read here. export() passes the packages it read; relative paths resolve against the working directory.

Value

Invisibly, the path to the embedded runtime/R directory.


Enable Auto-Updates

Description

Configures automatic update checking for your Electron application. GitHub Releases and generic HTTP servers are supported. An S3 provider is planned and will be added in a future release.

Usage

enable_auto_updates(
  appdir,
  provider = "github",
  owner = NULL,
  repo = NULL,
  url = NULL,
  check_on_startup = TRUE,
  auto_download = FALSE,
  auto_install = FALSE,
  verbose = TRUE
)

Arguments

appdir

Character path to app directory containing ⁠_shinyelectron.yml⁠

provider

Character update provider: "github" (the default) or "generic". "s3" is not yet wired into the build and will be added in a future release.

owner

Character GitHub username or organization (required for github provider)

repo

Character GitHub repository name (required for github provider)

url

Character address of the folder that holds the update files (required for the generic provider). It must start with ⁠http://⁠ or ⁠https://⁠ and hold no backslash or space. ⁠http://⁠ warns unless the host is localhost or ⁠127.0.0.1⁠.

check_on_startup

Logical whether to check for updates when app starts. Default TRUE.

auto_download

Logical whether to download updates automatically. Default FALSE.

auto_install

Logical whether to install updates automatically on quit. Default FALSE.

verbose

Logical whether to show progress messages. Default TRUE.

Details

Auto-updates require:

  1. A published application (e.g., to GitHub Releases)

  2. Proper code signing for macOS and Windows (recommended)

  3. The electron-updater package (automatically included in build)

Update Providers

GitHub Releases (recommended for open source):

S3 Bucket (planned, not yet supported):

Generic HTTP Server:

Publishing Updates (GitHub Releases)

After enabling auto-updates, follow this workflow to publish updates:

  1. Bump version in ⁠_shinyelectron.yml⁠ (e.g., version: "1.1.0")

  2. Rebuild with export(appdir, destdir, build = TRUE)

  3. Create a GitHub Release with a semver tag matching the version:

    • Tag: v1.1.0 (the v prefix is required)

    • Upload the built artifacts from ⁠destdir/electron-app/dist/⁠:

      • macOS: .dmg and latest-mac.yml

      • Windows: .exe installer and latest.yml

      • Linux: .AppImage and latest-linux.yml

  4. The app checks for updates on startup (if check_on_startup = TRUE) and notifies the user when a new version is available

Code Signing

Signing is what lets an app check who published an update. A signed Windows app installs only an update signed by the same publisher; an unsigned one, like a Linux AppImage, installs whatever the update address serves, so it trusts that server (and, over ⁠http://⁠, the network) completely. Set signing: sign: true in your config and provide credentials via environment variables (see ?validate_signing_config).

Value

Invisibly returns the path to the updated config file.

See Also

init_config() for creating initial configuration

Examples

# Enable GitHub-based updates on a temporary app
app <- file.path(tempdir(), "enable-updates-demo")
dir.create(app, showWarnings = FALSE)
writeLines("library(shiny)", file.path(app, "app.R"))
enable_auto_updates(app, owner = "myusername", repo = "myapp")

# Enable with automatic download
enable_auto_updates(app, owner = "myorg", repo = "dashboard",
                    auto_download = TRUE)


Get Path to an Example Application

Description

Returns the path to a bundled example application directory. Use this path as the appdir argument to export().

Usage

example_app(name)

Arguments

name

Character string. Name of the example (see available_examples()).

Value

Character string. Path to the example app directory.

Examples

# Get the path to a bundled example
example_app("r")
example_app("python")

if (interactive()) {
  # Pass the path to export() to build a desktop app
  path <- example_app("r")
  export(path, "output", app_type = "r-shiny", runtime_strategy = "system")
}


Export Shiny Application as Electron Desktop Application

Description

Main entry point function that wraps the conversion, building, and optionally running of a Shiny application as an Electron desktop application.

Usage

export(
  appdir,
  destdir,
  app_name = NULL,
  app_type = NULL,
  runtime_strategy = NULL,
  sign = FALSE,
  platform = NULL,
  arch = NULL,
  icon = NULL,
  overwrite = FALSE,
  build = TRUE,
  run_after = FALSE,
  open_after = FALSE,
  verbose = TRUE
)

Arguments

appdir

Character string. Path to the directory containing the Shiny application.

destdir

Character string. Path to the destination directory where the Electron app will be created.

app_name

Character string. Display name of the application. If NULL, uses app.name from ⁠_shinyelectron.yml⁠, then the name of the app directory. Unless app.slug is set, this argument also gives the app's slug, its identity for installed copies and updates; without it the slug comes from the name of the app directory, never from app.name.

app_type

Character string or NULL. Language of the Shiny app: "r-shiny" or "py-shiny". If NULL (default), the type is autodetected from files in appdir. The legacy values "r-shinylive" and "py-shinylive" are accepted with a deprecation warning and translate to the canonical language plus runtime_strategy = "shinylive".

runtime_strategy

Character string or NULL. How R or Python reaches the end user: "shinylive", "bundled", "system", "auto-download", or "container". Default "shinylive" when neither argument nor config sets one.

sign

Logical. Whether to enable code signing for the built application. When TRUE, electron-builder will attempt to sign the app using credentials from environment variables or the config file. Default is FALSE.

platform

Character vector. Target platforms: "win", "mac", "linux". If NULL, uses build.platforms from ⁠_shinyelectron.yml⁠, then the current platform. macOS apps build only on macOS, so a "mac" target stops the export on Windows and Linux unless build = FALSE.

arch

Character vector. Target architectures: "x64", "arm64". If NULL, uses build.architectures from ⁠_shinyelectron.yml⁠, then the current architecture. Each of platform and arch replaces only its own list, so platform = "win" still builds for every architecture in build.architectures.

icon

Character string. Path to application icon file, absolute or relative to the working directory. A PNG (1024x1024 or larger) or an .icns file serves every platform; an .ico file serves Windows only. Overrides icon and icons in ⁠_shinyelectron.yml⁠, whose paths are relative to appdir.

overwrite

Logical. Whether to overwrite existing output directory. Default is FALSE.

build

Logical. Whether to build distributable packages. Default is TRUE.

run_after

Logical. Whether to run the application in development mode after export. Default is FALSE.

open_after

Logical. Whether to open the generated project directory after export. Default is FALSE.

verbose

Logical. Whether to display detailed progress information. Default is TRUE.

Value

List containing paths to the converted app and built Electron app (if built).

Details

This is the main function of the package that orchestrates the entire process:

Supported Combinations

Two languages, five delivery strategies.

Examples


# Simplest call: app_type autodetects, runtime_strategy defaults to shinylive
export(
  appdir = "path/to/shiny/app",
  destdir = "path/to/electron/output"
)

# Run against a real R process instead of shinylive
export(
  appdir = "path/to/shiny/app",
  destdir = "path/to/output",
  runtime_strategy = "bundled"
)

# Pin language explicitly when autodetection is ambiguous
export(
  appdir = "path/to/shiny/app",
  destdir = "path/to/output",
  app_type = "r-shiny",
  runtime_strategy = "system"
)


Export multi-app Shiny suite as Electron application

Description

export() settles the suite's slug before it calls this function. When called directly without app.slug, the slug comes from the resolved suite name, as it did in earlier releases.

Usage

export_multi_app(
  appdir,
  destdir,
  config,
  app_name = NULL,
  runtime_strategy = NULL,
  sign = FALSE,
  platform = NULL,
  arch = NULL,
  icon = NULL,
  overwrite = FALSE,
  build = TRUE,
  run_after = FALSE,
  open_after = FALSE,
  verbose = TRUE,
  slug_pinned = !is.null(config$app$slug)
)

Arguments

slug_pinned

Logical. Whether the configuration sets app.slug, for the progress output; export() passes it because it fills in the slug before the call.


Installer extension for a platform

Description

The shinyelectron electron-builder template targets dmg on macOS, nsis (an .exe) on Windows, and AppImage on Linux.

Usage

ext_for(platform)

Arguments

platform

Character vector of "mac", "win", or "linux".

Value

Character vector of file extensions.


Select the tar program used to unpack a .tar.gz runtime archive

Description

Windows ships bsdtar (libarchive) at ⁠System32\\tar.exe⁠. It handles the PAX / long-name records in python-build-standalone archives that R's internal tar cannot (those surface as "embedded nul in string" errors), and unlike a GNU tar from Git for Windows it does not misparse ⁠C:\\...⁠ paths as remote hosts. Fall back to R's internal tar only when bsdtar is unavailable. On macOS / Linux the system tar (bsdtar or GNU tar) already handles PAX records, including the Apple com.apple.cs.CodeSignature xattrs in portable R archives.

Usage

extract_tar_program(
  os_type = .Platform$OS.type,
  system_root = Sys.getenv("SystemRoot", unset = "C:\\Windows")
)

Arguments

os_type

Operating system family, defaulting to .Platform$OS.type.

system_root

Windows system root, defaulting to the SystemRoot environment variable.

Value

A value suitable for the tar argument of utils::untar(): a path to a tar executable, the string "internal", or the result of Sys.which().


Fetch a published SHA-256 checksum for a portable runtime archive

Description

Reads a checksum file published alongside a runtime release and returns the hash for one archive. Two layouts are supported, both in the standard sha256sum format (⁠<hash> <filename>⁠):

Usage

fetch_published_sha256(checksum_url, asset_filename = NULL)

Arguments

checksum_url

Character. URL of the .sha256 sidecar or SHA256SUMS.

asset_filename

Character or NULL. Archive file name to match within a combined SHA256SUMS; NULL for a single-asset sidecar.

Details

Returns NULL when the checksum cannot be fetched or no matching entry is found, so callers can continue without verification rather than failing on a transient network error (the same graceful-skip behavior as the Node.js installer).

Value

Character SHA-256 hash, or NULL.


Locate Rscript inside a bundled portable-R runtime directory

Description

The portable-r distribution extracts to a subdirectory named ⁠portable-r-<version>-<os>-<arch>/⁠. Rscript lives at ⁠<subdir>/bin/Rscript[.exe]⁠. Searches for that layout first, then falls back to a flat layout in case a future portable build drops the subdir.

Usage

find_bundled_rscript(runtime_dir)

Arguments

runtime_dir

Character path to runtime/R inside the Electron app.

Value

Character path to Rscript, or NULL if not found.


Find configuration file

Description

Searches for _shinyelectron.yml in the given directory.

Usage

find_config(appdir)

Arguments

appdir

Character path to app directory

Value

Character path to config file, or NULL if not found


Find the Python command

Description

Searches for python3 first (Unix) or python first (Windows) on the system PATH and verifies it actually runs (Windows Store aliases exist but fail).

Usage

find_python_command()

Value

Character string or NULL. The Python command name, or NULL if not found.


Format directory size as human-readable string

Description

Format directory size as human-readable string

Usage

format_dir_size(path)

Arguments

path

Directory path.

Value

Character string like "142 MB".


Build the container backend configuration

Description

Produces the container-specific settings that are merged into backend_config (see generate_template_variables()) and consumed by inst/electron/backends/container.js at runtime. The configured engine is passed through as-is; image selection and engine auto-detection happen on the end user's machine in container.js.

Usage

generate_container_config(config, app_type = NULL)

Arguments

config

List. Full app configuration.

app_type

Character or NULL. Application type (e.g. "r-shiny", "py-shiny"). Used to resolve the runtime version for container_tag when no BYO image is configured. When NULL and no tag is configured, falls back to "latest".

Value

Named list of container settings.


Generate a dependency manifest file

Description

Creates a JSON manifest describing the packages an app needs. This manifest is written into the Electron app and used by the auto-download and container strategies to install packages at runtime.

Usage

generate_dependency_manifest(
  packages,
  language,
  repos = NULL,
  index_urls = NULL,
  local_packages = character(0),
  requirements = NULL
)

Arguments

packages

Character vector of package names.

language

Character string: "r" or "python".

repos

List of R repository URLs (for language = "r").

index_urls

List of Python index URLs (for language = "python").

local_packages

Character vector. Names of R packages installed from dependencies.r.local_packages. They stay in the manifest but are left out of the system-requirements lookup, which only knows repository packages and rejects the whole query when one name is unknown.

requirements

Character vector. For Python, the requirement specs to install, with their versions and environment markers. NULL installs packages by name.

Value

Character string of JSON content.


Generate package.json content for Electron app

Description

Programmatically creates the package.json content based on the backend type and configuration. This replaces the previous Whisker template approach to avoid fragile JSON + Mustache comma handling.

Usage

generate_package_json(
  app_slug,
  app_version,
  backend,
  config,
  icon = NULL,
  sign = FALSE,
  is_multi_app = FALSE,
  app_name = NULL
)

Arguments

app_slug

Character string. The slugified app name.

app_version

Character string. The app version.

backend

Character string. The backend module name without .js (e.g., "shinylive", "native-r").

config

List. The effective configuration.

icon

Character string or NULL. Path to the app icon, which copy_brand_assets() copies to icon_asset_path(). Each platform in icon_platforms() gets that copy as its icon; the others, and every platform when NULL, use the default Electron icon.

app_name

Character string or NULL. Display name, used as the electron-builder productName. NULL uses the slug.

Value

Character string. The JSON content for package.json.


Generate a Python runtime manifest for auto-download

Description

Generate a Python runtime manifest for auto-download

Usage

generate_python_runtime_manifest(
  version,
  platform = NULL,
  arch = NULL,
  release_date = NULL
)

Arguments

version

Character string. Python version.

platform

Character string. Target platform.

arch

Character string. Target architecture.

release_date

Character string. python-build-standalone release tag (YYYYMMDD). If NULL, resolved automatically via resolve_python_pbs().

Value

Character string. JSON content.


Generate a runtime manifest for auto-download

Description

Creates a JSON manifest that the Electron app reads on first launch to download the R runtime.

Usage

generate_runtime_manifest(version, platform = NULL, arch = NULL)

Arguments

version

Character string. R version.

platform

Character string. Target platform.

arch

Character string. Target architecture.

Value

Character string. JSON content.


Build the Whisker template variable list for the shared shell

Description

Constructs the named list passed to whisker::whisker.render() when assembling the Electron app. Kept separate from process_templates() so the variable construction is testable independently.

Usage

generate_template_variables(
  app_name,
  app_slug,
  app_type,
  runtime_strategy,
  icon,
  backend_module,
  brand,
  config,
  is_multi_app = FALSE,
  apps_manifest = NULL
)

Arguments

app_name

Character. Display name of the app.

app_slug

Character. Path-safe slug derived from app_name.

app_type

Character. "r-shiny" or "py-shiny".

runtime_strategy

Character. Resolved runtime strategy.

icon

Character path to icon file, or NULL.

backend_module

Character. Resolved backend filename (e.g., "native-r.js").

brand

List or NULL. Parsed ⁠_brand.yml⁠ contents if present.

config

List. Effective merged configuration.

is_multi_app

Logical.

apps_manifest

List or NULL. Multi-app manifest entries.

Details

Most variables here correspond to a {{...}} placeholder in inst/electron/shared/main.js, lifecycle.html, or launcher.html. The list is a superset: some entries are serialized into backend_config_json (and consumed by the backend modules rather than a template) or are reserved for future placeholders. Adding a new placeholder requires adding it here.

A configuration string that a template's JavaScript (main.js or an inline ⁠<script>⁠ in an HTML template) places inside a single-quoted literal also has an escaped ⁠*_js⁠ entry (see js_str()), which the template renders with a triple mustache, as in '{{{app_name_js}}}'. JSON inlined into a script is built with json_for_script(). The plain entries are HTML-escaped by a double mustache and belong in HTML markup.

Value

Named list suitable for Whisker rendering.


Get Node.js command

Description

Returns the path to the Node.js executable, preferring locally installed versions managed by shinyelectron.

Usage

get_node_command(prefer_local = TRUE)

Arguments

prefer_local

Logical. Whether to prefer the local shinyelectron-managed installation over the system installation. Default TRUE.

Value

Character string path to node executable


Get npm command

Description

Returns the path to the npm executable, preferring locally installed versions managed by shinyelectron.

Usage

get_npm_command(prefer_local = TRUE)

Arguments

prefer_local

Logical. Whether to prefer the local shinyelectron-managed installation over the system installation. Default TRUE.

Value

Character string path to npm executable


Find the tag of a GitHub repository's newest release

Description

Reads the location header that ⁠https://github.com/<repo>/releases/latest⁠ redirects with and takes what follows ⁠/releases/tag/⁠. This page redirect is not subject to the hourly request limit of GitHub's API. The lookup never throws and never warns.

Usage

github_latest_release_tag(repo, timeout = 5)

Arguments

repo

Character string. The repository, as "owner/name".

timeout

Number. Seconds the request may take.

Value

Character string. The tag (e.g., "v4.6.2"), or NULL when it cannot be found.


Project path of the app icon

Description

copy_brand_assets() copies the app icon into the generated project under this name, and package.json and main.js refer to the copy. The extension is kept, lowercased: up to version 26.14, electron-builder recognizes the format of an icon file only by a lower-case extension, and stops the build when asked to make a Linux icon set from a file named, say, icon.PNG.

Usage

icon_asset_path(icon)

Arguments

icon

Character. Path to the app icon.

Value

Character. The icon path relative to the Electron project, such as "assets/icon.png".


Smallest icon image each platform takes

Description

electron-builder makes each platform's icon from the file it is given. It converts a PNG to a macOS .icns file and a Windows .ico file, and uses it as it is for Linux. It converts an .icns file to a Windows icon and a Linux icon set, and gives it to macOS as it is. It cannot make a macOS icon or a Linux icon set from an .ico file, and stops the build when asked to, so an .ico file serves Windows only.

Usage

icon_min_size(icon)

Arguments

icon

Character. Path to the app icon.

Details

It also stops the build when the image is too small. A PNG must be at least 512x512 pixels for macOS and 256x256 for Windows, and an .icns or .ico file must hold an image of 256x256 pixels or more for Windows (a PNG image, in an .icns file). Up to version 26.14, electron-builder needs both sides of a PNG to be that large; later versions look at the longer side. Linux is not checked. Since version 26.15, which ⁠npm install⁠ picks for the generated project, electron-builder uses a PNG of any size as it is for Linux; whether it makes a Linux icon set from an .icns file without such a PNG image depends on the version. The format is read from the extension, ignoring case.

Value

Named numeric vector. For each platform that can use the format of icon, the smallest size, in pixels, that it takes, to compare with icon_size(). Empty for another format.


Platforms whose icon can come from the app icon

Description

A platform can use the app icon when electron-builder can make its icon from the file's format and the image is large enough (see icon_min_size()). When icon_size() cannot read the size, the format alone decides.

Usage

icon_platforms(icon)

Arguments

icon

Character. Path to the app icon.

Value

Character vector of the platforms ("win", "mac", "linux") that can use icon, empty for another format.


Size of an icon file's image

Description

Reads the header of the file, which electron-builder checks against icon_min_size() before it converts the icon: the width and height of a PNG, the images listed in an .ico file, and, in an .icns file, the PNG images of 256x256 pixels or more, which are the ones electron-builder makes a Windows icon from.

Usage

icon_size(icon)

Arguments

icon

Character. Path to the app icon.

Value

Numeric. The side, in pixels, of the largest square image the file gives: the shorter side of a PNG, or the largest image of an .ico file or of those in an .icns file (0 when there are none). NA when the file cannot be read as the format its extension names.


Initialize configuration file

Description

Creates a template _shinyelectron.yml file in the specified directory.

Usage

init_config(appdir, app_name = NULL, overwrite = FALSE, verbose = TRUE)

Arguments

appdir

Character path to app directory

app_name

Character application name. If NULL, derived from directory name.

overwrite

Logical whether to overwrite existing config. Default FALSE.

verbose

Logical whether to show progress. Default TRUE.

Value

Invisibly returns the path to the created config file.

See Also

wizard() for an interactive configuration generator; show_config() to display the merged effective configuration.

Examples

# Create a config for a temporary app
app <- file.path(tempdir(), "init-config-demo")
dir.create(app, showWarnings = FALSE)
writeLines("library(shiny)", file.path(app, "app.R"))
init_config(app, app_name = "My App")


Install local R package sources into the bundled library

Description

Installs each local package with the cached portable Rscript that also installs the repository packages, one package at a time and after the local packages it depends on (local_r_install_order()). A source folder is first built into a tarball in a temporary directory with the same portable R's ⁠R CMD build⁠, so nothing is compiled or written inside the folder and stale object files in it never reach the bundle. The build waits until the repository packages and the earlier local packages are in the library, because ⁠R CMD build⁠ installs the package to process help pages with build-stage Sexpr macros, and that install needs the package's dependencies.

Usage

install_local_r_packages(
  rscript,
  local_packages,
  lib_path,
  verbose = TRUE,
  timeout = 1800
)

Arguments

rscript

Character. Path to the cached portable Rscript.

local_packages

List. The local packages as resolve_local_packages() or local_r_package_info() read them from their source folders or source tarballs.

lib_path

Character. Destination library (the bundled library).

verbose

Logical. Whether to display progress.

timeout

Numeric. Seconds allowed for building or installing one package. The default of 30 minutes leaves room for large packages with compiled code.

Details

A package counts as installed only when a fresh process of the same Rscript loads it from the bundled library. That check catches compile errors, .onLoad() failures and timed-out installs, and because it looks for a line printed after loading rather than at the exit status, it also tolerates the Windows crash described below. On failure the build stops with the load error and the last lines of the install output.

The build, the install and the check run with the caller's environment plus R_LIBS, R_LIBS_USER and R_LIBS_SITE set to the bundled library. R_LIBS_SITE is the one that matters: the portable R's Rprofile.site resets .libPaths() to its own library plus the site library, including in the child processes of ⁠R CMD build⁠ and ⁠R CMD INSTALL⁠. These processes read no user environ file or user profile and ignore inherited R_ENVIRON and R_PROFILE settings, so startup files meant for the calling R (such as the ones callr passes down, or a project profile that activates renv) cannot point the library paths elsewhere; each R still reads its own site files.

On Windows hosts the install adds --no-staged-install --no-clean-on-error. There the bundled R's lazy-load step can crash while exiting, after it has written the package, and ⁠R CMD INSTALL⁠ then reports a failure. These options keep the files in place so the load check can decide. Elsewhere the default staged install keeps a failed package out of the library.

Value

Invisibly, the installed package names in install order.


Install Node.js locally

Description

Downloads and installs Node.js to the shinyelectron cache directory. This allows using Node.js/npm without requiring system-wide installation.

Usage

install_nodejs(
  version = NULL,
  platform = NULL,
  arch = NULL,
  force = FALSE,
  verbose = TRUE
)

Arguments

version

Character Node.js version to install. If NULL (default), automatically detects the latest LTS version.

platform

Character target platform ("win", "mac", "linux"). Default is current platform.

arch

Character target architecture ("x64", "arm64"). Default is current architecture.

force

Logical whether to reinstall if already exists. Default FALSE.

verbose

Logical whether to show progress. Default TRUE.

Value

Invisibly returns the path to the installed Node.js directory.

See Also

install_r_portable(), install_python_standalone() for other runtime installers.

Examples


# Install latest LTS version
install_nodejs()

# Install specific version
install_nodejs(version = "22.12.0")

# Force reinstall
install_nodejs(force = TRUE)


Install npm dependencies

Description

Install npm dependencies

Usage

install_npm_dependencies(output_dir, verbose = TRUE)

Arguments

output_dir

Character Electron project directory

verbose

Logical whether to show progress


Install a portable Python distribution

Description

Downloads and caches a portable Python build from python-build-standalone.

Usage

install_python_standalone(
  version = NULL,
  platform = NULL,
  arch = NULL,
  force = FALSE,
  verbose = TRUE
)

Arguments

version

Character string. Python version to install (e.g., "3.14.6"). If NULL, the maintained pin in SHINYELECTRON_DEFAULTS$runtime_versions$python$version is used.

platform

Character string. Target platform.

arch

Character string. Target architecture.

force

Logical. Whether to reinstall if already cached.

verbose

Logical. Whether to show progress.

Value

Character string. Path to the installed Python directory.

See Also

install_r_portable(), install_nodejs() for other runtime installers; python_executable() to find the installed Python path.

Examples


# Install default Python version
install_python_standalone()

# Install specific version
install_python_standalone(version = "3.12.0")


Install a portable R distribution

Description

Downloads and caches a portable R build. Follows the same pattern as install_nodejs().

Usage

install_r_portable(
  version = NULL,
  platform = NULL,
  arch = NULL,
  force = FALSE,
  verbose = TRUE
)

Arguments

version

Character string. R version to install. If NULL, installs latest.

platform

Character string. Target platform.

arch

Character string. Target architecture.

force

Logical. Whether to reinstall if already cached.

verbose

Logical. Whether to show progress.

Value

Character string. Path to the installed R directory.

See Also

install_python_standalone(), install_nodejs() for other runtime installers; r_executable() to find the installed Rscript path.

Examples


# Install latest R release
install_r_portable()

# Install specific version for a target platform
install_r_portable(version = "4.4.0", platform = "win", arch = "x64")


Project path of the Windows installer license

Description

The license file is copied into the generated project's build resources under a fixed name. Names that electron-builder finds on its own, such as license.txt or eula.txt, are avoided because they would also add the license to other targets, for example as a Linux AppImage EULA. The extension is kept (lowercased) since electron-builder shows .html licenses differently from plain text and RTF. electron-builder only recognizes the .html suffix, so .htm becomes .html; a file without an extension is treated as plain text.

Usage

installer_license_path(license_file)

Arguments

license_file

Character. Path to the license file.

Value

Character. The license path relative to the Electron project.


Is a dev-app-update.yml one the package wrote?

Description

True only when the file's first line is exactly the marker. A carriage return is accepted only directly before the line feed that ends the line, since a file written on Windows may come back with CRLF. Anything else (trailing spaces, a carriage return with no line feed after it, the marker on a later line, an empty or unreadable file, a folder, a symbolic link) is the author's.

Usage

is_dev_update_config_ours(path)

Arguments

path

Path to the file.

Value

TRUE or FALSE.


Test for an http or https URL

Description

Test for an http or https URL

Usage

is_http_url(x)

Arguments

x

Value to test.

Value

TRUE when x is a single string that starts with ⁠http://⁠ or ⁠https://⁠ (in any case) followed by more text, otherwise FALSE.


Check if config is multi-app mode

Description

Check if config is multi-app mode

Usage

is_multi_app(config)

Arguments

config

List. Configuration.

Value

Logical.


Test for a map-like list

Description

TRUE for a list whose elements all have non-empty names, the shape YAML gives a mapping. YAML sequences, scalars and lists with an unnamed element are not map-like.

Usage

is_named_list(x)

Arguments

x

Object to test.

Value

A single logical.


Test for a single non-empty string

Description

Template flags use this so an optional setting renders only when it holds real text: NULL, "", NA, and non-character values all count as unset.

Usage

is_nonempty_string(x)

Arguments

x

Value to test.

Value

TRUE or FALSE.


Check a lifecycle timeout value

Description

Check a lifecycle timeout value

Usage

is_timeout_ms(x)

Arguments

x

Value to check.

Value

TRUE if x is a single whole number of milliseconds between 1000 and 2147483647 (the largest R integer), otherwise FALSE.


Escape a value for a single-quoted JavaScript string literal

Description

Rendered templates place configuration strings between single quotes in JavaScript, both in main.js and in the inline ⁠<script>⁠ of lifecycle.html, as in title: 'Close {{{app_name_js}}}'. This escapes backslashes and then single quotes, turns carriage returns and line feeds into spaces, and writes U+2028, U+2029, and every < as escape sequences (< becomes ⁠\u003C⁠). No value can then end the literal early, change its meaning (a Windows path keeps its backslashes), or end or disturb an HTML ⁠<script>⁠ block. Double quotes are left alone, so use the result only inside single quotes.

Usage

js_str(x)

Arguments

x

A character vector, a non-character scalar (coerced with as.character(), such as a version that YAML read as a number), or NULL.

Details

Render the result with a triple mustache ({{{name_js}}}). A double mustache would HTML-escape it again and turn & into ⁠&amp;⁠. HTML markup, such as the page title in lifecycle.html, keeps the double mustache.

Value

A character vector, or NULL when x is NULL.


Serialize a value as JSON to inline in a script

Description

JSON from jsonlite::toJSON() is a valid JavaScript expression, but a string in it that contains ⁠<!--⁠ followed by ⁠<script⁠ can stop the HTML parser from ending the surrounding ⁠<script>⁠ block at its closing tag. This writes every < as ⁠\u003C⁠, and U+2028 and U+2029 as escape sequences, so the JSON stays valid and keeps its value. Templates use it for every JSON value they inline into script code, such as ⁠var apps = {{{apps_json}}};⁠ in launcher.html and the backend config in main.js.

Usage

json_for_script(x)

Arguments

x

Value to serialize (with auto_unbox = TRUE).

Value

A single string of JSON.


Look up a lifecycle timeout for the generated app

Description

Look up a lifecycle timeout for the generated app

Usage

lifecycle_timeout(config, key)

Arguments

config

List. Effective configuration.

key

Character. "startup_timeout" or "shutdown_timeout".

Value

Integer milliseconds: the configured value, or the default when it is missing or invalid (for example a config that skipped validate_config()).


Order local R packages so each installs after the local packages it needs

Description

A stable topological sort over Depends, Imports and LinkingTo, restricted to the local packages themselves. Packages keep their listed order where their dependencies allow it.

Usage

local_r_install_order(info)

Arguments

info

List from local_r_package_info().

Value

Character vector of package names in install order.


Declared dependencies of local R packages

Description

The packages that each local package's Depends, Imports and LinkingTo name (directories and archives alike), so the repository install step can install them before the local package is installed from source. local_r_package_info() has already stripped version constraints and R; base/recommended packages are dropped here.

Usage

local_r_package_deps(packages)

Arguments

packages

List. Local packages as resolve_local_packages() or local_r_package_info() return them.

Value

Character vector of dependency package names.


Read the metadata of local R package sources

Description

Reads the DESCRIPTION of each source folder, or the one in a source tarball's top-level folder. resolve_local_packages() calls this, and the later steps of an export take its result rather than reading again.

Usage

local_r_package_info(paths)

Arguments

paths

Character vector. Paths to package source folders or .tar.gz / .tgz source tarballs.

Value

A list with one element per path, named by package. Each element holds path, package, version, deps (the package names from Depends, Imports and LinkingTo, without R) and is_dir.


Package names of local R packages

Description

Package names of local R packages

Usage

local_r_package_names(packages)

Arguments

packages

List. Local packages as resolve_local_packages() or local_r_package_info() return them.

Value

Character vector of package names (empty when packages is empty).


Manifest Schemas (R to JS Contract)

Description

shinyelectron generates three JSON manifest files at build time that the Electron runtime reads on the end user's machine. These are the de-facto API contract between R and JavaScript.

Details

Each manifest carries a schema_version field (the MANIFEST_SCHEMA_VERSION constant in R, mirrored in inst/electron/backends/utils.js). The JS side warns on mismatch rather than crashing, so older apps can keep running after a schema bump.

dependencies.json

Generated by generate_dependency_manifest(). Consumed by inst/electron/backends/dependency-checker.js. Describes the packages an app needs at runtime.

{
  "schema_version": "2",
  "language": "r" | "python",
  "packages": ["shiny", "bslib", ...],
  "binary_only": true,
  "repos": ["https://cloud.r-project.org"],       // R only
  "index_urls": ["https://pypi.org/simple"],      // Python only
  "system_deps": {                                 // optional, R only
    "debian": ["libcurl4-openssl-dev", ...],
    "fedora": ["libcurl-devel", ...]
  }
}

runtime-manifest.json

Generated by generate_runtime_manifest() (R) and generate_python_runtime_manifest() (Python). Consumed by inst/electron/backends/runtime-downloader.js. Tells the auto-download strategy where to fetch the runtime.

{
  "schema_version": "2",
  "language": "r" | "python",
  "version": "4.5.3",
  "download_url": "https://...",
  "install_path": "~/.shinyelectron/runtimes/R-4.5.3",
  "platform": "win" | "mac" | "linux",
  "arch": "x64" | "arm64",
  "sha256": "..."                                  // optional
}

apps-manifest.json

Generated by export_multi_app(). Consumed by inst/electron/shared/main.js. Drives the multi-app launcher UI.

{
  "schema_version": "2",
  "default_type": "r-shiny",
  "runtime_strategy": "auto-download",
  "apps": [
    {
      "id": "dashboard",
      "name": "Dashboard",
      "description": "...",
      "type": "r-shiny",
      "runtime_strategy": "auto-download",
      "icon": null,
      "serve": { "kind": "native", "path": "src/apps/dashboard", "runtime_strategy": "auto-download" }
    },
    {
      "id": "viewer",
      "name": "Viewer",
      "description": "...",
      "type": "r-shiny",
      "runtime_strategy": "shinylive",
      "icon": null,
      "serve": { "kind": "shinylive", "site": "src/shinylive-site", "subdir": "viewer" }
    },
    {
      "id": "boxed",
      "name": "Boxed",
      "description": "...",
      "type": "r-shiny",
      "runtime_strategy": "container",
      "icon": null,
      "serve": { "kind": "container", "path": "src/apps/boxed" }
    }
  ]
}

Map the logging section onto the app section

Description

⁠_shinyelectron.yml⁠ documents the log settings under a top-level ⁠logging:⁠ section, while the build reads them from app.log_dir and app.log_level, which the file may also set directly. This copies logging.log_dir and logging.log_level into app on the parsed YAML, before merge_config_deep() fills in the defaults. When both spellings set a field to different values, the logging value wins and a warning of class shinyelectron_logging_conflict names the field. Any other key under logging stays in place so that collect_unknown_config_keys() reports it. A logging value that is not a map, such as logging: debug or a list, is dropped with a warning of class shinyelectron_invalid_logging_section.

Usage

map_logging_config(config)

Arguments

config

List. User configuration parsed from the YAML file.

Value

config with the logging fields moved into app.


Deep merge two lists

Description

Recursively merges config into defaults, where config values override defaults.

Usage

merge_config_deep(defaults, config)

Arguments

defaults

List of default values

config

List of config values to merge

Value

Merged list


Merge detected Python dependencies with config declarations

Description

Merge detected Python dependencies with config declarations

Usage

merge_py_dependencies(detected, config_deps, requirements = detected)

Arguments

detected

Character vector of detected package names.

config_deps

List from config$dependencies.

requirements

Character vector. The requirement specs behind detected, with their versions and environment markers.

Value

List with packages (sorted package names), requirements (the specs to install) and index_urls (list).


Merge detected R dependencies with config declarations

Description

Combines auto-detected packages with user-declared packages from config. When auto_detect is FALSE, only declared packages are used.

Usage

merge_r_dependencies(detected, config_deps)

Arguments

detected

Character vector of detected package names.

config_deps

List from config$dependencies.

Value

List with packages (character vector) and repos (list).


Reduce a metadata setting to one line of text

Description

electron-builder writes the description, copyright, and author name into single-line fields such as the Windows file properties, so line breaks become spaces and surrounding whitespace is dropped.

Usage

metadata_text(x)

Arguments

x

Value to clean.

Value

A single string, or NULL when x is not a string or holds only whitespace.


Find the optional configured files that do not exist

Description

The splash image, the tray icon and the launcher icon of each suite app are optional: without them the build uses a default.

Usage

missing_config_files(config)

Arguments

config

List. The configuration.

Value

A list with one element per missing file. Each is a list with field (the key), path, consequence (what the build uses instead), and either key (the location in config) or app (the index in config$apps) and id.


Initialize a sitrep results list with the standard shape

Description

Each sitrep function accumulates issues and recommendations as it runs. This helper ensures all sitrep results expose the same two fields so the top-level sitrep_shinyelectron() aggregator can iterate over them uniformly.

Usage

new_sitrep_results(extra = list())

Arguments

extra

Named list of additional fields to merge in.

Value

List with issues and recommendations character vectors plus any extras.


Download Node.js checksums

Description

Download Node.js checksums

Usage

nodejs_download_checksums(version)

Arguments

version

Character Node.js version

Value

Named character vector (filename = checksum)


Generate Node.js download URL

Description

Generate Node.js download URL

Usage

nodejs_download_url(version, platform, arch)

Arguments

version

Character Node.js version (e.g., "22.12.0")

platform

Character platform ("win", "mac", "linux")

arch

Character architecture ("x64", "arm64")

Value

Character URL to download Node.js


Get path to local Node.js executable

Description

Get path to local Node.js executable

Usage

nodejs_executable(version = NULL, platform = NULL, arch = NULL)

Arguments

version

Character Node.js version (NULL = latest installed)

platform

Character target platform (NULL = current)

arch

Character target architecture (NULL = current)

Value

Character path to node executable, or NULL if not found


Get Node.js installation path in cache

Description

Get Node.js installation path in cache

Usage

nodejs_install_path(version = NULL, platform = NULL, arch = NULL)

Arguments

version

Character Node.js version (NULL for base path)

platform

Character platform (defaults to current)

arch

Character architecture (defaults to current)

Value

Character path to Node.js installation


Check if Node.js is installed locally

Description

Check if Node.js is installed locally

Usage

nodejs_is_installed(version = NULL)

Arguments

version

Character Node.js version (NULL = any version)

Value

Logical TRUE if installed


Get latest Node.js LTS version

Description

Queries the Node.js distribution API to find the latest LTS version.

Usage

nodejs_latest_lts()

Value

Character string with version number (without 'v' prefix)


List installed Node.js versions

Description

List installed Node.js versions

Usage

nodejs_list_installed()

Value

Character vector of installed versions (sorted newest first)


Get Node.js SHASUMS URL

Description

Get Node.js SHASUMS URL

Usage

nodejs_shasums_url(version)

Arguments

version

Character Node.js version

Value

Character URL to SHASUMS256.txt


Environment for Node.js and npm child processes

Description

npm can be launched by its absolute path, but package lifecycle scripts invoke node by name. When shinyelectron manages a Node.js install that is not already on PATH, this makes that directory discoverable to npm and every process it starts.

Usage

nodejs_subprocess_env()

Details

The result uses processx's special "current" entry so the child inherits the full parent environment with PATH extended, rather than replacing it. Replacing it would drop variables that npm and electron-builder depend on (for example APPDATA and LOCALAPPDATA on Windows, or HOME elsewhere).

Value

A character vector for the env argument of processx::run() and run_command_safe(), or NULL when Node.js is already on PATH or cannot be resolved (the inherited environment is then used unchanged).


Verify file checksum

Description

Verify file checksum

Usage

nodejs_verify_checksum(file_path, expected_checksum)

Arguments

file_path

Character path to file

expected_checksum

Character expected SHA256 checksum

Value

Logical TRUE if valid (or if verification unavailable)


Normalize the app author

Description

app.author takes either form npm uses for a person: a string "Name <email> (url)", where each part is optional, or a map with name, email, and url entries. Both become the same list, which fills the author field of package.json and the About dialog. The string is split the way npm and electron-builder split it.

Usage

normalize_app_author(x)

Arguments

x

The app.author setting.

Value

A list with name, email, and url entries, each a string or NULL, or NULL when x is unset or blank. Any other shape warns and returns NULL.


Normalize app_type and runtime_strategy arguments

Description

Translates legacy app_type values (r-shinylive, py-shinylive) to the canonical language pair (r-shiny, py-shiny) and backfills runtime_strategy = "shinylive" when the caller has not set it. Emits a deprecation warning of class "shinyelectron_deprecated_app_type" so callers can muffle it and tests can match it precisely. Errors when a legacy type is combined with an explicit non-shinylive strategy, since that combination never worked under the old API.

Usage

normalize_app_type_arg(app_type, runtime_strategy = NULL)

Arguments

app_type

Character string or NULL. Raw app_type from the user.

runtime_strategy

Character string or NULL. Raw runtime_strategy.

Value

List with elements app_type (canonical or NULL), runtime_strategy (may still be NULL), and deprecated (logical).


Get path to local npm executable

Description

Get path to local npm executable

Usage

npm_executable(version = NULL, platform = NULL, arch = NULL)

Arguments

version

Character Node.js version (NULL = latest installed)

platform

Character target platform (NULL = current)

arch

Character target architecture (NULL = current)

Value

Character path to npm executable, or NULL if not found


Parse pyproject.toml dependencies section

Description

Simple parser for the ⁠[project] dependencies⁠ array in pyproject.toml, where PEP 621 lists runtime dependencies. dependencies arrays in other tables, such as Hatch's ⁠[tool.hatch.envs.*]⁠ environments, are ignored. Entries may use double or single quotes, and ⁠#⁠ comments are skipped. Does not handle complex TOML such as multi-line strings, a quoted ⁠["project"]⁠ header, or a dotted project.dependencies key.

Usage

parse_pyproject_toml(path)

Arguments

path

Character string. Path to pyproject.toml.

Details

A dependency that ⁠[tool.uv.sources]⁠ takes from git, a URL, a path, or a workspace member is a direct reference, and one it takes from a named uv index is listed in indexed.

Value

A list as read_py_requirements() returns.


Parse requirements.txt file

Description

Lines that end in a backslash continue on the next line, as pip reads them, and a ⁠#⁠ at the start of a line or after a space starts a comment. Options that follow a requirement, such as the --hash options that ⁠uv export⁠ and pip-compile write, are dropped from it.

Usage

parse_requirements_txt(path)

Arguments

path

Character string. Path to requirements.txt.

Value

A list as read_py_requirements() returns.


Fetch the latest python-build-standalone release from GitHub

Description

Queries the single releases/latest endpoint. This is a small, reliable call, unlike the full release list which is large enough to time out (HTTP 504) on this repository. The latest release carries the newest patch of every currently supported CPython minor, so it resolves "latest" and any current version on its own. A thin network wrapper so tests can stub it.

Usage

pbs_latest_release()

Value

A single release object with a tag_name field and an assets list.


List python-build-standalone releases from GitHub

Description

Fetches release metadata from the astral-sh/python-build-standalone GitHub API. Returns a list of release objects, each with a tag_name field and an assets list whose elements have a name field. Releases are ordered newest first (GitHub API default). This function is intentionally a thin network wrapper so it can be stubbed in tests.

Usage

pbs_list_releases()

Value

List of release objects from the GitHub releases API.


pip arguments for a set of package indexes

Description

pip arguments for a set of package indexes

Usage

pip_index_args(index_urls)

Arguments

index_urls

Character vector or list. Package index URLs; the first is the main index and the rest are extra ones.

Value

Character vector of pip arguments.


Environment for processes of a portable R

Description

The caller's environment without R_ENVIRON and R_PROFILE, so a portable R reads its own site files instead of site files chosen for the calling R (callr sets both for the R it starts, and a user can set them too). On macOS the portable R's Rprofile.site rewrites the shared-library references of the binary packages it installs, which is what lets them load. The user's environ file and profile and every other variable are kept.

Usage

portable_r_env()

Value

Named character vector for the env argument of processx::run().


Prepare native Shiny app files for packaging

Description

Copies the app source into ⁠destdir/shiny-app/⁠, detects package dependencies, and writes runtime + dependency manifests that the Electron backends will consume at launch time.

Usage

prepare_native_app_files(
  appdir,
  destdir,
  app_type,
  runtime_strategy,
  platform,
  arch,
  config,
  verbose = TRUE,
  dependencies = NULL
)

Arguments

appdir

Character. Source Shiny app directory.

destdir

Character. Export destination.

app_type

Character. "r-shiny" or "py-shiny".

runtime_strategy

Character. Resolved runtime strategy.

platform, arch

Character. Target platform / architecture.

config

List. Effective merged configuration.

verbose

Logical.

dependencies

List or NULL. The app's dependencies when the caller has resolved them already, as resolve_app_dependencies() returns them. NULL resolves them here.

Value

List with elements converted_app (path) and dependencies (NULL or the resolved dep info).


Process and copy Electron templates

Description

Orchestrates the Electron project assembly: renders shared Whisker templates, copies the appropriate backend modules, sets up Dockerfiles for container strategy, generates package.json, and copies brand assets. Each step is a focused helper in this file.

Usage

process_templates(
  output_dir,
  app_name,
  app_type,
  runtime_strategy = "shinylive",
  icon = NULL,
  config = NULL,
  sign = FALSE,
  is_multi_app = FALSE,
  apps_manifest = NULL,
  platform = NULL,
  verbose = TRUE
)

Arguments

output_dir

Character destination directory

app_name

Character application display name

app_type

Character application type

runtime_strategy

Character resolved runtime strategy

icon

Character path to icon file or NULL

config

List of configuration values from config file (optional)

platform

Character vector of target platforms, used to check that the tray can read its icon (see check_tray_icon()). NULL means the current platform.

verbose

Logical whether to show progress


Remove test suites and bulky documentation from an embedded R runtime

Description

Shrinks a bundled R runtime by deleting files that a running app does not read. The removed names form a fixed allowlist; everything else is kept.

Usage

prune_bundled_r_runtime(runtime_dir, verbose = TRUE)

Arguments

runtime_dir

Character. The embedded runtime/R directory.

verbose

Logical. Whether to report what was removed.

Details

The allowlist covers:

Package ⁠examples/⁠, ⁠demo/⁠, NEWS and CHANGELOG files and ⁠include/⁠ headers are kept, because some packages and apps read them at runtime (for example shinyjs::runExample(), a "What's new" panel that shows NEWS.md via system.file(), or Rcpp::sourceCpp()). In the portable R's ⁠doc/⁠, COPYING, COPYRIGHTS (third-party notices that binary distributions of R must include), AUTHORS, THANKS, RESOURCES, the mirror lists read by utils::getCRANmirrors() and the KEYWORDS files are kept.

Symbolic links are never followed: a link is removed itself, and its target is neither touched nor counted. The totals count only the regular files that are actually gone afterwards.

Value

Invisibly, a list with the number of files and bytes removed.


Remove allowlisted entries directly under one directory

Description

Matches entry names exactly (case-sensitively). A name in dir_names is removed only when it is a directory, and a name in file_names only when it is a regular file. A symbolic link with a listed name is removed as a link. Anything else is left untouched, and nothing happens when dir is missing or is itself a symbolic link.

Usage

prune_r_paths(dir, dir_names = character(0), file_names = character(0))

Arguments

dir

Character. Directory to prune.

dir_names, file_names

Character vectors of names to remove.

Value

List with the number of files and bytes removed.


Construct download URL for portable Python

Description

Uses python-build-standalone releases for portable Python builds.

Usage

python_download_url(version, platform = NULL, arch = NULL, release_date)

Arguments

version

Character string. Python version (e.g., "3.14.6").

platform

Character string. Target platform.

arch

Character string. Target architecture.

release_date

Character string. python-build-standalone release tag (YYYYMMDD). Required; must match a release tag on https://github.com/astral-sh/python-build-standalone/releases.

Value

Character string. Download URL.


Get the path to the Python executable in a cached installation

Description

Get the path to the Python executable in a cached installation

Usage

python_executable(version, platform = NULL, arch = NULL)

Arguments

version

Character string. Python version.

platform

Character string. Platform (default: current).

arch

Character string. Architecture (default: current).

Value

Character string or NULL.


Published SHA-256 checksum for a portable Python archive

Description

python-build-standalone publishes one SHA256SUMS file per release listing every asset. Returns NULL when unavailable or unmatched so the caller can continue without verification.

Usage

python_expected_sha256(version, platform = NULL, arch = NULL, release_date)

Arguments

version

Character string. Python version (e.g., "3.14.6").

platform

Character string. Target platform.

arch

Character string. Target architecture.

release_date

Character string. python-build-standalone release tag (YYYYMMDD). Required; must match a release tag on https://github.com/astral-sh/python-build-standalone/releases.

Value

Character SHA-256 hash, or NULL.


Get the installation path for a cached Python version

Description

Get the installation path for a cached Python version

Usage

python_install_path(version, platform = NULL, arch = NULL)

Arguments

version

Character string. Python version.

platform

Character string. Platform (default: current).

arch

Character string. Architecture (default: current).

Value

Character string. Path to the cached Python installation.


Check if a portable Python version is installed

Description

Check if a portable Python version is installed

Usage

python_is_installed(version, platform = NULL, arch = NULL)

Arguments

version

Character string. Python version to check.

platform

Character string. Platform (default: current).

arch

Character string. Architecture (default: current).

Value

Logical.


Resolve a Python version to its python-build-standalone release

Description

Scans release asset names of the form ⁠cpython-<ver>+<release>-<arch>-<os>-install_only.tar.gz⁠. For an explicit version, returns the newest release that contains an asset for that version. For "latest", returns the first CPython version found in the newest release.

Usage

python_resolve_pbs(version = "latest")

Arguments

version

Character string. A concrete Python version such as "3.14.6", or "latest" for the newest available build.

Details

Resolution tries the lightweight releases/latest endpoint first via pbs_latest_release(), which carries the newest patch of every supported minor and resolves the common case in one reliable call. It falls back to the full release history (pbs_list_releases(), which can time out) only when the latest release does not contain the requested version. Network access is isolated to those two helpers so tests can stub them.

Value

Named list with elements version (character) and release (character YYYYMMDD tag).


URL of the python-build-standalone SHA256SUMS file for a release

Description

URL of the python-build-standalone SHA256SUMS file for a release

Usage

python_sha256sums_url(release_date)

Arguments

release_date

Character. python-build-standalone release tag (YYYYMMDD).

Value

Character URL.


Environment for spawning Python child processes

Description

R prepends its own and related library directories to LD_LIBRARY_PATH (its lib directory plus system paths such as ⁠/usr/lib/x86_64-linux-gnu⁠). When a Python child inherits that, the dynamic loader can resolve a system libpython ahead of the interpreter's own; the interpreter then computes a different sys.prefix and its site module drops site-packages from sys.path, so pip-installed packages (for example the Python shinylive CLI) become unimportable and the process fails with ⁠No module named ...⁠ even though the package is installed. Python resolves its own libraries via rpath, so LD_LIBRARY_PATH is removed for Python children. A no-op on platforms / installs where it is not set (Windows, macOS, most user setups).

Usage

python_subprocess_env()

Value

A named character vector suitable for the env argument of processx::run().


Query Linux system package names for a set of R packages

Description

Resolves the distribution system packages required by pkgs and their recursive dependencies using the Posit Package Manager system-requirements service. Returns character(0) on any failure so callers degrade gracefully (a user can still name packages via dependencies.system_packages).

Usage

query_sysreqs(pkgs, distribution = "ubuntu", release = "24.04")

Arguments

pkgs

Character vector of R package names.

distribution

Linux distribution, e.g. "ubuntu" or "redhat".

release

Distribution release, e.g. "24.04" or "9".

Details

Queried over HTTP directly rather than through pak::pkg_sysreqs(), whose resolver returns an empty mapping in common configurations even when the underlying data is available.

Value

Character vector of system package names (sorted, de-duplicated).


Construct download URL for portable R

Description

Generates the download URL for an R build from CRAN.

Usage

r_download_url(version, platform = NULL, arch = NULL)

Arguments

version

Character string. R version (e.g., "4.4.0").

platform

Character string. Target platform: "win", "mac", "linux".

arch

Character string. Target architecture: "x64", "arm64".

Value

Character string. Download URL.


Get the path to the Rscript executable in a cached installation

Description

Get the path to the Rscript executable in a cached installation

Usage

r_executable(version, platform = NULL, arch = NULL)

Arguments

version

Character string. R version.

platform

Character string. Platform (default: current).

arch

Character string. Architecture (default: current).

Value

Character string or NULL. Path to Rscript, or NULL if not found.


Published SHA-256 checksum for a portable R archive

Description

Portable R publishes a per-asset .sha256 sidecar next to each release archive (⁠<archive-url>.sha256⁠). Returns NULL when unavailable so the caller can continue without verification.

Usage

r_expected_sha256(version, platform = NULL, arch = NULL)

Arguments

version

Character string. R version (e.g., "4.4.0").

platform

Character string. Target platform: "win", "mac", "linux".

arch

Character string. Target architecture: "x64", "arm64".

Value

Character SHA-256 hash, or NULL.


Get the installation path for a cached R version

Description

Get the installation path for a cached R version

Usage

r_install_path(version, platform = NULL, arch = NULL)

Arguments

version

Character string. R version.

platform

Character string. Platform (default: current).

arch

Character string. Architecture (default: current).

Value

Character string. Path to the cached R installation.


Check if a portable R version is installed

Description

Check if a portable R version is installed

Usage

r_is_installed(version, platform = NULL, arch = NULL)

Arguments

version

Character string. R version to check.

platform

Character string. Platform (default: current).

arch

Character string. Architecture (default: current).

Value

Logical.


Get the latest R release version

Description

Queries the R API for the current release version.

Usage

r_latest_version()

Value

Character string. The latest R version (e.g., "4.4.1").


Where the installed copy of an R package came from

Description

Reads the fields that remotes, pak and R repositories write into an installed package's DESCRIPTION.

Usage

r_package_origin(package, lib.loc = NULL)

Arguments

package

Character. A package name.

lib.loc

Character vector or NULL. Libraries to look in.

Value

A phrase such as "installed here from GitHub (user/repo)".


Get the newest R version available as a portable-r build

Description

The bundled and auto-download strategies download R from the portable-r release repos, which can lag behind the newest R release (so the latest R from r_latest_version() may have no portable build yet, yielding a 404). For "win" and "mac" this returns the newest release of the platform's portable-r repo, found with github_latest_release_tag(). For any other platform it returns r_latest_version(), given five seconds.

Usage

r_portable_latest_version(platform = NULL)

Arguments

platform

Character string. Target platform: "win", "mac", "linux". NULL for the build machine.

Details

When the lookup fails, or does not give a major.minor.patch version, this returns SHINYELECTRON_DEFAULTS$runtime_versions$r instead and says so in a message of class shinyelectron_r_version_fallback. It never aborts.

Value

Character string. The newest portable R version, or the fallback.


Read _brand.yml file

Description

Reads a _brand.yml file from the app directory for visual customization. Follows the Posit brand.yml specification.

Usage

read_brand_yml(appdir)

Arguments

appdir

Character string. Path to the app directory.

Value

List with brand settings, or NULL if no file found.


Read configuration file

Description

Reads and parses _shinyelectron.yml from the app directory. If the file doesn't exist, returns default configuration.

Usage

read_config(appdir)

Arguments

appdir

Character path to app directory

Value

List of configuration values (merged with defaults)


Read an app's Python requirements

Description

Reads requirements.txt, or pyproject.toml when there is no requirements.txt, and sorts each entry by whether pip can install it by name from a package index. Warns as detect_py_dependencies() describes.

Usage

read_py_requirements(appdir)

Arguments

appdir

Character string. Path to the app directory.

Value

A list with


Wait for the update feed server's address

Description

Reads the server's standard output until a whole line arrives, the output ends, or timeout seconds pass, and returns as soon as one of these happens. The line is the address only if it is exactly ⁠http://127.0.0.1:<port>/⁠ once a carriage return before its line feed is dropped. Anything else aborts, quoting the server's standard error.

Usage

read_update_feed_address(process, timeout)

Arguments

process

The processx::process running the server.

timeout

Seconds to wait.

Value

The address.


Read what is left of the update feed server's standard error

Description

Read what is left of the update feed server's standard error

Usage

read_update_feed_error(process, err, wait = 2)

Arguments

process

The processx::process running the server.

err

Standard error read so far.

wait

Seconds to wait for the end of the output.

Value

err with the rest appended.


Remove dev-app-update.yml if the package wrote it

Description

Remove dev-app-update.yml if the package wrote it

Usage

remove_dev_update_config(app_dir)

Arguments

app_dir

App folder.

Value

TRUE invisibly if a file was removed, otherwise FALSE.


Render shared Electron templates (main.js, lifecycle.html, usage.html, preload.js, launcher.html)

Description

Render shared Electron templates (main.js, lifecycle.html, usage.html, preload.js, launcher.html)

Usage

render_shared_templates(output_dir, template_vars, is_multi_app)

Resolve application dependencies

Description

Top-level function that detects, merges, and returns the final list of package dependencies for an app. Called from export() for native app types.

Usage

resolve_app_dependencies(appdir, app_type, runtime_strategy, config)

Arguments

appdir

Character string. Path to the app directory.

app_type

Character string. The app type ("r-shiny" or "py-shiny").

runtime_strategy

Character string. The resolved runtime strategy. Returns NULL when "shinylive", since shinylive manages its own deps.

config

List. The effective configuration.

Value

List with packages, language, and repos, or for Python requirements and index_urls; NULL for the shinylive strategy.


Resolve the app slug

Description

The slug is the app's identity. It names the package in package.json, the user data folder, the per-app caches under ⁠~/.shinyelectron⁠, and the installer files, and unless installer.app_id is set it also gives the app ID, which Windows installers and macOS use to recognize an installed copy. app.slug wins when set. Otherwise the slug comes from name, and then from the name of the app directory: when name is NULL, or, with a message, when it has no ASCII letters or digits.

Usage

resolve_app_slug(config, name, appdir)

Arguments

config

List. The effective configuration.

name

Character string or NULL. The name the slug comes from when app.slug is unset, such as the app_name argument of export().

appdir

Character string. The app directory.

Details

export() passes its app_name argument as name, so app.name in the configuration sets only the display name and never the slug, as in earlier releases: editing the display name never changes the app's identity.

Value

The slug, or NULL when neither name nor the directory gives one. It is not validated here; check_app_slug() does that before a build.


Resolve the runtime strategy for a multi-app entry

Description

Order of precedence: explicit per-app runtime_strategy, then legacy per-app type (forces "shinylive"), then suite-level build.runtime_strategy, then the package default "shinylive".

Usage

resolve_app_strategy(app, config)

Arguments

app

List. Single app entry from config$apps.

config

List. Full configuration.

Value

Character string. The resolved runtime strategy.


Resolve the app type for a multi-app entry

Description

Reads per-app type, falls back to suite-level build.type, and routes legacy values through normalize_app_type_arg() so the caller always sees canonical "r-shiny" / "py-shiny". A legacy per-app type is treated as a self-contained shinylive declaration and does not mix with the suite-level runtime_strategy, since the two could otherwise conflict (e.g. a legacy "r-shinylive" entry inside a suite whose default strategy is "system").

Usage

resolve_app_type(app, config)

Arguments

app

List. Single app entry from config$apps.

config

List. Full configuration.

Value

Character string. The resolved canonical app type.


Determine the backend module filename for an app type and runtime strategy

Description

Determine the backend module filename for an app type and runtime strategy

Usage

resolve_backend_module(app_type, runtime_strategy)

Arguments

app_type

Character string. The app type.

runtime_strategy

Character string. The resolved runtime strategy.

Value

Character string. The backend module filename (e.g., "shinylive.js").


Resolve Posit brand.yml palette references

Description

In a brand.yml color block the semantic roles (primary, background, foreground, ...) may either hold a colour directly or name an entry in color.palette. shinyelectron reads these roles verbatim for the Electron shell, so a reference such as primary: plum must be resolved to its palette value before use. Roles that already hold a literal colour are left untouched.

Usage

resolve_brand_palette(brand)

Arguments

brand

List or NULL. Parsed ⁠_brand.yml⁠ contents.

Value

The brand list with color roles resolved against color.palette.


Resolve the active _brand.yml for template rendering

Description

Prefers the single-app location (src/app); for multi-app, falls back to the first listed app if the shared location has no brand file.

Usage

resolve_brand_yml(output_dir, is_multi_app, apps_manifest)

Resolve the platforms and architectures to build for

Description

The platform and arch arguments of export() win over build.platforms and build.architectures in ⁠_shinyelectron.yml⁠, which win over the platform and architecture of the build machine. Each argument replaces only its own list, and repeated values are dropped. The result is checked as build_electron_app() checks its arguments, so an invalid value stops the export before anything is converted or built.

Usage

resolve_build_targets(platform, arch, config)

Arguments

platform, arch

Character vectors or NULL. The arguments.

config

List. The effective configuration.

Value

A list with the character vectors platform and arch, and from_config, the settings that supplied them ("build.platforms", "build.architectures", both or neither), for error messages.


Resolve a path written in the configuration file

Description

Paths in ⁠_shinyelectron.yml⁠ are relative to the directory that holds the file: the app directory, or the suite root of a multi-app suite. ~ is expanded, and an absolute path is kept as it is.

Usage

resolve_config_path(path, base_dir)

Arguments

path

Character. A path as written in the configuration.

base_dir

Character. The directory that holds ⁠_shinyelectron.yml⁠.

Value

Character. The absolute path.


Resolve the file paths in a configuration

Description

Makes every configuration value that names a file on the build machine absolute with resolve_config_path(): icon, icons.mac, icons.win, icons.linux, splash.image, tray.icon, signing.win.certificate_file, and the path and icon of each apps entry. export() calls this right after reading ⁠_shinyelectron.yml⁠, so the paths no longer depend on the working directory. An empty string counts as unset and is removed. Other values that are not a single string are left for the later checks to report.

Usage

resolve_config_paths(config, base_dir)

Arguments

config

List. The merged configuration.

base_dir

Character. The directory that holds ⁠_shinyelectron.yml⁠.

Value

config, with those paths made absolute.


Resolve the Windows installer license against the app directory

Description

installer.license_file is written relative to the app directory, while electron-builder runs inside the generated Electron project. Resolving the path up front lets the build copy the file into the project, and stops on a missing file before any runtime is downloaded.

Usage

resolve_installer_license(config, appdir)

Arguments

config

List. The effective configuration.

appdir

Character. The app directory the configuration was read from.

Value

config, with installer$license_file made absolute when it is set.


Resolve, check and read the configured local R package sources

Description

Turns the dependencies.r.local_packages entries into absolute paths and reads each package's DESCRIPTION before anything is copied or downloaded. export() and the multi-app export call this with the directory that holds ⁠_shinyelectron.yml⁠ (the app directory, or the suite root) and put the result in the configuration, so the later steps of the export use what was read here instead of reading each source again. embed_r_runtime() calls it again for direct callers; a list that this function returned comes back unchanged. Each entry must be a package source folder (with a DESCRIPTION) or a .tar.gz / .tgz source tarball.

Usage

resolve_local_packages(local_packages, base_dir, bundled_r = TRUE)

Arguments

local_packages

Character vector or list. The configured entries, or a list that this function returned.

base_dir

Character. Directory that relative entries resolve against.

bundled_r

Logical. Whether an R app in this build uses the bundled strategy. Local packages are only installed into a bundled R library, so a non-empty list aborts when this is FALSE.

Value

The packages as local_r_package_info() reads them, with absolute paths, in a list of class shinyelectron_local_packages (empty when nothing is set).


Resolve an app's Python dependencies for an export

Description

Reads the app's requirements and merges them with the configured packages. Stops when a requirement points at a URL, a version control repository, or a path, since the built app installs its packages by name from a package index. Warns about pip options in requirements.txt, which are not read, and about packages that ⁠[tool.uv.sources]⁠ takes from a uv index.

Usage

resolve_py_dependencies(
  appdir,
  config_deps,
  reqs = read_py_requirements(appdir)
)

Arguments

appdir

Character string. Path to the app directory.

config_deps

List from config$dependencies.

reqs

List. The app's requirements, as read_py_requirements() reads them.

Details

When dependencies.auto_detect is off the app's requirements are not installed, so they are not read or checked either.

Value

List with packages, requirements, and index_urls, as merge_py_dependencies() returns.


Resolve a Python version to its python-build-standalone release (offline-first)

Description

Uses the offline default pin when the version matches it (no network), and only queries the registry for a custom or "latest" version.

Usage

resolve_python_pbs(version)

Arguments

version

Character string. A concrete Python version such as "3.14.6", or "latest" for the newest available build.

Value

Named list with elements version (character) and release (character YYYYMMDD tag).


Resolve the dependencies.r.prune setting

Description

Returns whether a bundled R runtime is pruned: the configured value, or TRUE when it is unset. A quoted "true" or "false" is read as the matching logical with a warning, and any other value aborts (see config_flag()), so a typo never silently decides which files ship.

Usage

resolve_r_prune(config)

Arguments

config

List. Configuration, as from read_config(). May be NULL.

Value

TRUE or FALSE.


Resolve the runtime version to use for a build

Description

An explicit ⁠dependencies.<runtime>.version⁠ in config wins. For R, unset and the literal "latest" both give the newest portable R for the platform, from r_portable_latest_version(), which falls back to the version in SHINYELECTRON_DEFAULTS$runtime_versions when the lookup fails. For Python and Electron, "latest" calls the live resolver and unset gives the maintained pin in SHINYELECTRON_DEFAULTS$runtime_versions.

Usage

resolve_runtime_version(runtime, config, platform = NULL)

Arguments

runtime

One of "r", "python", "electron".

config

Full app configuration list.

platform

Character string or NULL. Target platform of the R lookup, NULL for the build machine. Python and Electron ignore it.

Value

Character version string.


Resolve the dependencies of every app in a suite

Description

The Python apps of a suite share one runtime, so they share the requirements at the suite root (requirements.txt or pyproject.toml) when it lists any. An R app, or a Python app in a suite without root requirements, is read on its own. Shinylive apps manage their own packages and are skipped, and the suite's requirements are not read when every Python app is one.

Usage

resolve_suite_dependencies(appdir, app_type, config, verbose = TRUE)

Arguments

appdir

Character. The suite root.

app_type

Character. The suite's default app type.

config

List. The suite configuration, with its paths resolved.

verbose

Logical. Whether to report the suite-level packages.

Details

Stops when the bundled Python apps pin one package to different versions, as check_py_pin_conflicts() describes.

Value

A list named by app id, each entry NULL or as resolve_app_dependencies() returns.


Restore environment variables

Description

Restore environment variables

Usage

restore_environment(old_env)

Arguments

old_env

Named list of environment variables to restore


Run a command safely and return the result

Description

Wraps processx::run() with consistent error handling. Returns a list with status, stdout, and stderr. Never throws: a command that cannot be started, fails, or times out is reported as a non-zero status, so a diagnostic probe cannot abort the calling session.

Usage

run_command_safe(command, args = character(), timeout = 30, env = NULL)

Arguments

command

Character command to run.

args

Character vector of arguments.

timeout

Numeric timeout in seconds. Default 30.

env

Environment for the child process. NULL (the default) inherits the current environment; otherwise the supplied value is used, where the special "current" entry extends rather than replaces it. In every case NODE_COMPILE_CACHE is added so Node's compile cache is written to a temporary directory that is removed when the call returns.

Details

processx is used rather than base::system2() because a modified env is honored on every platform (system2's env is a no-op on Windows for programs like node and python), and arguments are passed as an argv array without shell quoting.

Value

List with status, stdout, stderr.


Run Electron Application for Testing

Description

Launches a previously exported Electron application for testing and debugging without building distributable packages. Pass the electron-app directory from a prior export() call.

Usage

run_electron_app(
  app_dir,
  port = 3000,
  open_devtools = TRUE,
  verbose = TRUE,
  update_version = NULL
)

Arguments

app_dir

Character string. Path to the Electron application directory (the electron-app subdirectory from export()).

port

Integer. Port number for the development server. Default is 3000.

open_devtools

Logical. Whether to open Chromium DevTools automatically. Default is TRUE.

verbose

Logical. Whether to display detailed progress information. Default is TRUE.

update_version

Character string or NULL. A version such as "2.0.0" runs the app against a local update feed offering that version, so the update check can be tried without publishing a release. The app must have been exported with auto-updates on (see enable_auto_updates()) by this version of shinyelectron. Download is expected to fail, because the feed holds no installer. On macOS only the startup notice shows the result, so the app must check on startup (check_on_startup, the default), since Help > About has no Check for Updates there. Default is NULL, a normal run.

Value

Invisibly returns the completed processx::run() result list (with status, stdout, and stderr) after Electron exits, or NULL if the run is interrupted. Note that this call blocks until the Electron window is closed.

Details

This function starts the Electron application for testing, which:

Examples


# Run a previously exported Electron app in development mode
run_electron_app("path/to/electron/app")

# Run with custom port and no dev tools
run_electron_app(
  app_dir = "path/to/app",
  port = 8080,
  open_devtools = FALSE
)

# Try the update check against a local feed offering version 2.0.0
run_electron_app("path/to/electron/app", update_version = "2.0.0")


Set development environment variables

Description

Set development environment variables

Usage

set_dev_environment(port, open_devtools)

Arguments

port

Integer port number

open_devtools

Logical whether to open dev tools

Value

Named list of old environment variables


Setup Electron project structure

Description

Setup Electron project structure

Usage

setup_electron_project(output_dir, app_name, app_type, verbose = TRUE)

Arguments

output_dir

Character path to output directory

app_name

Character application name

app_type

Character application type

verbose

Logical whether to show progress


Show Effective Configuration

Description

Pretty-prints the merged effective configuration (params + config file + defaults) for a shinyelectron app directory. Useful for debugging and verifying settings.

Usage

show_config(appdir = ".")

Arguments

appdir

Character path to the app directory.

Value

Invisibly returns the merged configuration list.

Examples

# Show the merged configuration for a bundled example app
show_config(example_app("r"))


Report a configured file that does not exist

Description

Names the key and the absolute path that was checked, and says what happens next.

Usage

signal_missing_config_file(
  field,
  path,
  consequence = NULL,
  base_dir = NULL,
  app_id = NULL,
  error = FALSE,
  call = parent.frame()
)

Arguments

field

Character. The key, such as "splash.image".

path

The configured value.

consequence

Character. What the build does without the file.

base_dir

Character or NULL. The directory relative paths in ⁠_shinyelectron.yml⁠ were resolved against. NULL for a configuration passed straight to build_electron_app(), whose relative paths are taken from the working directory.

app_id

Character or NULL. The suite app the key belongs to.

error

Logical. Whether to stop instead of warning.

call

Environment. The function the error is reported from.


Build Tools Situation Report

Description

Checks platform-specific build tools required for creating Electron distributables.

Usage

sitrep_electron_build_tools(verbose = TRUE)

Arguments

verbose

Logical. Whether to print detailed output. Default is TRUE.

Value

Invisibly returns a list with build tools information.

Examples


# Check build tools
sitrep_electron_build_tools()



Dependencies Situation Report

Description

Checks R package dependencies required for shinyelectron functionality.

Usage

sitrep_electron_dependencies(verbose = TRUE)

Arguments

verbose

Logical. Whether to print detailed output. Default is TRUE.

Value

Invisibly returns a list with dependency information.

Examples

# Check R package dependencies (quiet = returns a list invisibly)
deps <- sitrep_electron_dependencies(verbose = FALSE)
length(deps$missing_required)


# Pretty-printed report
sitrep_electron_dependencies()



Project Situation Report

Description

Checks if the current directory contains a valid Electron project and diagnoses common project-related issues.

Usage

sitrep_electron_project(project_dir = ".", verbose = TRUE)

Arguments

project_dir

Character. Path to the project directory. Default is current directory.

verbose

Logical. Whether to print detailed output. Default is TRUE.

Value

Invisibly returns a list with project diagnostic information.

Examples


# Check the current directory for a shinyelectron project
sitrep_electron_project()

# Check a specific directory
sitrep_electron_project(tempdir())



System Requirements Situation Report

Description

Checks system requirements for shinyelectron including Node.js, npm, operating system, and architecture.

Usage

sitrep_electron_system(verbose = TRUE)

Arguments

verbose

Logical. Whether to print detailed output. Default is TRUE.

Value

Invisibly returns a list with diagnostic information.

Examples


# Check system requirements
sitrep_electron_system()

# Get diagnostic info without printing
info <- sitrep_electron_system(verbose = FALSE)



Complete Situation Report

Description

Runs all diagnostic checks and provides a comprehensive report of your shinyelectron setup.

Usage

sitrep_shinyelectron(project_dir = ".", verbose = TRUE)

Arguments

project_dir

Character. Path to the project directory to check. Default is current directory.

verbose

Logical. Whether to print detailed output. Default is TRUE.

Value

Invisibly returns a list with all diagnostic information.

Examples


# Complete diagnostic check of the current setup
sitrep_shinyelectron()

# Get results as a list, without printing
results <- sitrep_shinyelectron(verbose = FALSE)

# Check a specific project directory
sitrep_shinyelectron(tempdir())


Slugify a name, or return NULL when nothing usable is left

Description

Slugify a name, or return NULL when nothing usable is left

Usage

slug_or_null(name)

Arguments

name

The name to slugify. Anything but a single non-empty string gives NULL.

Value

The slugify() result, or NULL when the name has no ASCII letters or digits.


Convert a display name to a path-safe slug

Description

Converts an application display name to a lowercase, hyphen-separated string safe for use in file paths, container names, and npm package names.

Usage

slugify(name)

Arguments

name

Character string. The display name to slugify.

Value

Character string. The slugified name.


Replace straight double quotes with typographic ones

Description

electron-builder writes the product name, the copyright, and the author's name into double-quoted strings of the Windows installer (NSIS) script without escaping them, so a straight double quote ends the string and the installer build fails. electron-builder already turns the quotes in the description into typographic ones; this applies the same rule to the other values generate_package_json() writes.

Usage

smart_quotes(x)

Arguments

x

A string, or NULL.

Value

x with each ⁠"⁠ replaced by an opening or closing typographic quote, or NULL when x is NULL.


Set up a development update feed for an app

Description

Checks that the app folder holds no dev-app-update.yml of the author's before anything is written or started, then writes the feed files to a new temporary folder, starts the server on it, and writes dev-app-update.yml pointing at the server. If a later step fails or is interrupted, the earlier ones are undone.

Usage

start_update_feed(app_dir, version, app_slug)

Arguments

app_dir

App folder.

version

Version the feed offers, such as "2.0.0".

app_slug

Name of the app's package.json, as a slug.

Details

The result holds the server's process object, and a collected process object ends the server, so keep the result referenced until stop_update_feed() is called on it. Register that call with on.exit() before starting the feed, with the variable set to NULL first, which stop_update_feed() accepts:

feed <- NULL
on.exit(stop_update_feed(feed), add = TRUE)
feed <- start_update_feed(app_dir, version, app_slug)

Value

A list with app_dir, dir (the feed folder) and server (from start_update_feed_server()).


Start the local update feed server

Description

Runs update-feed-server.js with Node.js to serve dir on ⁠127.0.0.1⁠ at a free port, and waits for the address it prints.

Usage

start_update_feed_server(dir, timeout = 10)

Arguments

dir

Folder to serve.

timeout

Seconds to wait for the address.

Details

The server does not outlive the R session that started it. It is started and held with interrupts suspended, so from then on an error or an interrupt before its address arrives kills it here, and stop_update_feed_server() kills it later. Supervision is set up after that, since it can take a moment the first time and can fail; a failure ends the server and is reported as such. If the returned list is garbage collected, processx kills the server, so keep the list for as long as the feed is in use. If R exits or dies without running exit handlers, processx's supervisor kills the server, and the server also exits by itself once R's end of its standard input closes. Only R holds that end: processx keeps it from being inherited by any other child process.

Value

A list with process, the processx::process running the server, and url, its address, such as "http://127.0.0.1:43210/".


Tear down a development update feed

Description

Removes dev-app-update.yml if the package wrote it, stops the server and removes the feed folder. An author's own dev-app-update.yml, including one put in place during the run, is left alone. Safe in any state: twice, on NULL, on a feed whose server never started or already exited, and with the folder already gone. A step that fails is reported as a message and the others still run, so it never throws from an exit handler. The steps run with interrupts suspended, so a second Ctrl+C during teardown is held until every step has run.

Usage

stop_update_feed(feed)

Arguments

feed

A list from start_update_feed(), or NULL.

Value

NULL, invisibly.


Stop the local update feed server

Description

Kills the server if it is still running and closes R's ends of its pipes. A server that already exited, for whatever reason, is only let go of. Safe to call more than once and on NULL, and never throws, since it runs from exit handlers. An interrupt that arrives meanwhile is held until it is done.

Usage

stop_update_feed_server(server)

Arguments

server

A list from start_update_feed_server(), or NULL.

Value

NULL, invisibly.


Register the update feed server with the processx supervisor

Description

The supervisor kills the server if R exits or dies without running exit handlers. Registering can fail, for example when antivirus software blocks the supervisor on Windows; start_update_feed_server() then ends the server and reports it.

Usage

supervise_update_feed_server(process)

Arguments

process

The processx::process running the server.


File name of the tray icon in the build

Description

copy_brand_assets() copies tray.icon into ⁠assets/⁠ under this name, and main.js loads it from there. The file keeps its own name unless that is the name of the app icon's copy (see icon_asset_path()), ignoring case. Then it gets a ⁠tray-⁠ prefix, so that neither copy replaces the other: every platform's build takes its icon from the app icon's copy.

Usage

tray_icon_file(tray_icon, icon = NULL)

Arguments

tray_icon

Character. Path to the tray icon.

icon

Character path to the app icon, or NULL.

Value

Character. The file name of the copy in ⁠assets/⁠.


Run one step of tearing down a development update feed

Description

A failure is reported as a message instead of an error, so the other steps still run and an exit handler never hides the error that ended the run.

Usage

try_update_feed_cleanup(expr, what)

Arguments

expr

The step.

what

What the step does, as plain text.

Value

NULL, invisibly.


Path of the local update feed server script

Description

Path of the local update feed server script

Usage

update_feed_server_script()

Value

Path to update-feed-server.js, or "" if it cannot be found.


Validate application name

Description

Validate application name

Usage

validate_app_name(app_name, field = "app_name")

Arguments

app_name

Character application name

field

Character. Where the name came from, for the error message: "app_name" for the argument, or "app.name" for the config key.


Validate application type

Description

Validate application type

Usage

validate_app_type(app_type)

Arguments

app_type

Character application type


Validate target architecture

Description

Validate target architecture

Usage

validate_arch(arch)

Arguments

arch

Character vector of architectures


Validate build output

Description

Validate build output

Usage

validate_build_output(output_dir, platform)

Arguments

output_dir

Character Electron project directory

platform

Character vector of target platforms


Validate a command is available and executable

Description

Shared pattern: resolve a command, abort if not found, run it with a version flag, abort if execution fails. Returns the resolved command.

Usage

validate_command_available(
  command_resolver,
  not_found,
  label = "Command",
  version_arg = "--version"
)

Arguments

command_resolver

Function returning the command path or NULL.

not_found

Character vector passed to cli::cli_abort when the command is not found. Use "i" = "..." entries for install hints.

label

Character string used in the generic "found but failed" message. Defaults to "Command".

version_arg

Character. Argument used to check the command runs. Defaults to "–version".

Value

Invisibly returns the resolved command path.


Validate configuration values

Description

Checks configuration values and warns about invalid entries. The Windows installer flags are read with config_flag(): a quoted "true" or "false" is used with a warning, but any other invalid value aborts, as does installer.allow_to_change_installation_directory: true without installer.one_click: false, because falling back to a default would build a different installer than the one requested. The other settings that take only true or false abort on anything else, a quoted value included (see check_logical_settings()).

Usage

validate_config(config)

Arguments

config

List of configuration values

Value

List of validated configuration


Validate a configuration file

Description

Checks a _shinyelectron.yml file for common issues and warns about them.

Usage

validate_config_file(config_path)

Arguments

config_path

Character string. Path to the config file.

Value

Invisible TRUE if valid, with warnings for issues.


Validate a container engine is available

Description

Checks that Docker or Podman is installed and can be executed.

Usage

validate_container_available(preference = NULL)

Arguments

preference

Character string or NULL. Preferred engine.

Value

Invisible character string with the engine name.


Validate that a directory exists

Description

Validate that a directory exists

Usage

validate_directory_exists(dir, name = "Directory")

Arguments

dir

Character path to directory

name

Character descriptive name for error messages


Validate Electron project structure

Description

Validate Electron project structure

Usage

validate_electron_project(app_dir)

Arguments

app_dir

Character path to Electron app directory


Validate icon file for target platform

Description

Checks that the icon file exists and that each target platform can use it, for its format and for the size of its image (see icon_platforms()). A platform that cannot gets the default Electron icon, so this warns rather than errors and the build continues.

Usage

validate_icon(icon, platform = NULL)

Arguments

icon

Character path to icon file.

platform

Character vector of target platforms.


Validate multi-app configuration

Description

Validate multi-app configuration

Usage

validate_multi_app_config(config, basedir)

Arguments

config

List. Configuration with apps array.

basedir

Character. Base directory for resolving relative paths (see resolve_config_path()).


Validate Node.js and npm availability

Description

Checks for Node.js and npm, preferring locally installed versions managed by shinyelectron over system installations, and stops with class shinyelectron_node_too_old when Node.js is older than NODE_MIN_VERSION.

Usage

validate_node_npm()

Value

Invisibly returns a list with node and npm paths and versions.


Validate target platform

Description

Validate target platform

Usage

validate_platform(platform)

Arguments

platform

Character vector of platforms


Validate port number

Description

Validate port number

Usage

validate_port(port)

Arguments

port

Integer port number


Validate Python app structure

Description

Validate Python app structure

Usage

validate_python_app_structure(appdir)

Arguments

appdir

Character string. Path to the app directory.


Validate Python is available on the system

Description

Validate Python is available on the system

Usage

validate_python_available()

Value

Invisible character string with the Python command name.


Validate the Python shiny package is installed

Description

Used by the native py-shiny app type. Only checks importability – the export pipeline spawns ⁠python -m shiny run⁠ at runtime on the user's machine, not at build time.

Usage

validate_python_shiny_installed()

Value

Invisible character string with the detected shiny version.


Validate the Python shinylive package CLI is usable

Description

Mirrors the command preference used by convert_py_to_shinylive(): first the shinylive console script on PATH, then ⁠python -m shinylive⁠ as a fallback. Runs --version to confirm the CLI actually executes (an import check is not enough – shinylive ships no ⁠__main__.py⁠, so a package that imports fine can still fail at export time).

Usage

validate_python_shinylive_installed()

Value

Invisible character string with the detected shinylive version.


Validate R is available on the system

Description

Checks that Rscript can be found and executed. Used by the "system" runtime strategy where the end user must have R installed.

Usage

validate_r_available()

Value

Invisible character string with the path to Rscript.


Validate runtime strategy

Description

Validate runtime strategy

Usage

validate_runtime_strategy(strategy)

Arguments

strategy

Character string. The runtime strategy to validate.


Validate Shiny application structure

Description

Validate Shiny application structure

Usage

validate_shiny_app_structure(appdir)

Arguments

appdir

Character path to Shiny app directory


Validate shinylive output

Description

Validate shinylive output

Usage

validate_shinylive_output(output_dir, subdir = NULL)

Arguments

output_dir

Character path to shinylive output (the site root).

subdir

Character or NULL. When set, the app entry lives at ⁠output_dir/<subdir>/index.html⁠ and the shared asset tree at ⁠output_dir/shinylive/⁠ (multi-app shared-site export). When NULL the single-app root layout is checked.


Validate code signing configuration

Description

Checks that required credentials are available when signing is enabled. Issues warnings (not errors) for missing credentials so the build can continue – electron-builder will handle the actual failure.

Usage

validate_signing_config(
  config,
  platform = NULL,
  sign = isTRUE(config$signing$sign)
)

Arguments

config

List. The effective configuration.

platform

Character string. Target platform ("mac", "win", "linux").

sign

Logical. Whether the build is signed. export() and app_check() pass the value their sign argument resolves to, which can turn signing on when signing.sign is off. Defaults to signing.sign.

Details

On macOS, electron-builder notarizes with the first kind of credentials it finds in the environment: an Apple ID (APPLE_ID and APPLE_APP_SPECIFIC_PASSWORD, plus a team ID from APPLE_TEAM_ID or signing.mac.team_id), an App Store Connect API key (APPLE_API_KEY, APPLE_API_KEY_ID and APPLE_API_ISSUER), or a notarytool keychain profile (APPLE_KEYCHAIN_PROFILE).


Validate a slug string

Description

Checks that a slug contains only lowercase alphanumeric characters and hyphens, and is not empty.

Usage

validate_slug(slug)

Arguments

slug

Character string. The slug to validate.

Value

Invisible TRUE if valid, otherwise aborts with an error.


Validate that each language uses a single native runtime strategy

Description

Native strategies (system, bundled, auto-download) share one backend module and one suite-wide runtime detection per language, so a suite may declare at most one distinct native strategy per language. shinylive and container apps use their own backends and are exempt.

Usage

validate_suite_strategies(apps, config)

Arguments

apps

List. config$apps entries.

config

List. Full suite configuration.


Warn when an export uses an Electron that is out of support

Description

Warn when an export uses an Electron that is out of support

Usage

warn_if_electron_unsupported(config)

Arguments

config

Full app configuration list.

Value

NULL, invisibly.


Run a build call without repeating the ⁠http://⁠ address warning

Description

export() wraps its call to build_electron_app() or build_multi_app() in this, since its read_config() has already given the warning. Only that warning class is muffled.

Usage

without_repeated_update_url_warning(expr)

Arguments

expr

The build call.

Value

The value of expr.


Interactive Configuration Wizard

Description

Walks through setup questions and generates a _shinyelectron.yml configuration file for your Shiny app.

Usage

wizard(appdir)

Arguments

appdir

Character string. Path to the app directory.

Value

Invisible path to the generated config file.

See Also

init_config() to create a template config file; show_config() to display the merged effective configuration.

Examples


wizard(tempdir())


Write dev-app-update.yml, pointing an unpackaged app at a local feed

Description

Replaces a file the package wrote earlier; stops on any other. The updater cache folder is ⁠<app_slug>-dev-updater⁠, not the ⁠<app_slug>-updater⁠ that an installed copy of the app uses, so a download tried in a development run never touches an update the installed copy has already downloaded.

Usage

write_dev_update_config(app_dir, url, app_slug)

Arguments

app_dir

App folder.

url

Address of the feed, such as "http://127.0.0.1:43210/".

app_slug

Name of the app's package.json, as a slug.

Value

The path written, invisibly.


Write lines with LF endings on every platform

Description

Write lines with LF endings on every platform

Usage

write_lf_lines(lines, path)

Arguments

lines

Character vector.

path

File to write.


Write a runtime-manifest.json for the auto-download strategy

Description

Write a runtime-manifest.json for the auto-download strategy

Usage

write_runtime_manifest(
  app_dir,
  app_type,
  platform,
  arch,
  config,
  verbose = TRUE
)

Write the update feed files electron-updater's generic provider reads

Description

Writes latest.yml, latest-mac.yml, latest-linux.yml and latest-linux-arm64.yml, each offering version with an installer that is not served, so a check finds the update and a download fails.

Usage

write_update_feed(dir, version, app_slug)

Arguments

dir

Folder to write into, created if needed.

version

Version to offer: three numbers separated by dots, optionally followed by a hyphen and a pre-release part of letters, digits, dots and hyphens, such as "1.2.3" or "1.2.3-beta.1".

app_slug

App name used in the installer file names. Lowercase letters, numbers and inner hyphens.

Value

dir, invisibly.


Quote a string as a YAML single-quoted scalar

Description

Quoting keeps a reader from taking a slug such as true or 123 for a boolean or number, or the releaseDate timestamp for a date. It is not an escape: callers validate every value first, because a newline would be folded to a space and a control character would make the reader throw.

Usage

yaml_quote(x)

Arguments

x

Character scalar.

Value

Character scalar.