Releases: r-wasm/webr
webR 0.4.2
New features
- Added support for directly mounting (optionally compressed)
.tar
archives as filesystem images. Archives must be pre-processed using therwasm
R package to append filesystem image metadata to.tar
archive data.
Breaking changes
- When installing binary R packages, webR will now default to mounting the R package binary
.tgz
file as a filesystem image. If this fails (e.g. the.tgz
has not been processed to add filesystem image metadata) webR will fall back to a traditional install by extracting the contents of the.tgz
file.
Bug Fixes
- Mounting filesystem images using the
WORKERFS
filesystem type now works correctly under Node.js (#328).
New Contributors
- @luisDVA made their first contribution in #472
- @thomascwells made their first contribution in #473
Full Changelog: v0.4.1...v0.4.2
webR 0.4.1
New features
- When mounting Emscripten VFS images, filesystem
.data
files may be optionallygzip
compressed. Compressed VFS filesystem data must have the file extension.data.gz
, and the metadata JSON stored in the.js.metadata
file must include the propertygzip: true
(#460).
Breaking changes
-
R package dependencies listed only in the
LinkingTo
field are no longer downloaded bywebr::install()
. Such packages are required for building an R package, but not at runtime. This saves time and network resources when installing R packages from a WebAssembly CRAN-like repository (#463). -
Unrecoverable
WebAssembly.RuntimeError
errors are now handled by emitting an error message, closing the communication channel, and terminating the webR worker thread. -
When the communication channel has been closed, reject any attempts to to write to the channel (e.g.
webR.evalR()
,webR.writeConsole()
) with a relevant error message, rather than not resolving the returnedPromise
at all.
Bug Fixes
- Partially revert 7c624f7, returning HTML Canvas scaling to the behaviour in webR 0.3.3.
webR 0.4.0
New features
-
Updated to R version 4.4.1.
-
The capturing mechanism of
captureR()
has been updated so that memory reallocation is performed when outputting very long lines. If reallocation is not possible (e.g. the environment does not have enough free memory to hold the entire line), the previous behaviour of truncating the line output is maintained (#434). -
Enabled the Emscripten IDBFS virtual filesystem driver. This filesystem type can be used to persist data in web browser storage across page reloads. This filesystem type must be used with the
PostMessage
communication channel (#56, #442). -
Added resizable panels to the webR application (#396). The
canvas()
graphics device is now resized dynamically to fit to the plotting pane. -
The R
View()
command now invokes a simple data grid viewer in the webR application. -
A function
viewer_install()
is added to the webR support package. The function sets up R so as to generate an output message over the webR communication channel when a URL viewer is invoked (#295). -
Printing a HTML element or HTML widget in the webR application app now shows the HTML content in an embedded viewer
iframe
(#384, #431). With thanks to @timelyportfolio for the basic implementation method. -
The webR application now allows users to download an archive of a directory and its contents from the virtual filesystem (#388).
Breaking changes
-
The
ServiceWorker
communication channel has been deprecated. Users should use theSharedArrayBuffer
channel where cross-origin isolation is possible, or otherwise use thePostMessage
channel. For the moment theServiceWorker
channel can still be used, but emits a warning at start up. The channel will be removed entirely in a future version of webR. -
The R session is now set as non-interactive when capturing output using
captureR()
andevalR()
. After output capture is complete, the status is restored (#426).
Bug Fixes
-
Fix generation of R API documentation (#439).
-
The
rwasm
R package is now installed into the system library as part of the webR development Docker container (#443, r-wasm/actions#10). -
webR.installPackages()
now correctly handles bothstring
andstring[]
arguments for package names and binary repositories (#437). -
Resolved several syntax highlighting and code completion issues in the webR application.
webR 0.3.3
New features
-
A
webR.version
property has been added, containing the current version and build information (#409). -
An
RObject.class()
method has been added, returning anRCharacter
object with the names of the classes from which the given R object inherits. This has been implemented using R'sclass()
function, and so the implicit class is similarly returned when the R object has noclass
attribute. -
WebR now sets the environment variable
WEBR
equal to"1"
andWEBR_VERSION
equal to the webR version string in the WebAssembly environment (#414). -
Dev tools: Running
make help
now prints valid targets and their descriptions (#410).
Bug Fixes
webR 0.3.2
New features
-
The
captureGraphics
option inEvalROptions
now allows the caller to set the arguments to be passed to the capturingwebr::canvas()
device (#390). -
A subclass
RDataFrame
is now available for explicit construction of an R object with classdata.frame
.RDataFrame
extends theRList
class, and construction must be with data that can be coerced into an Rdata.frame
, otherwise an error is thrown. -
The
RList
constructor now takes an optional second argument to define names when constructing a list. The argument should be an array of strings, ornull
for an unnamed list (the default).
Breaking changes
- When using the generic
RObject
constructor, JavaScript objects and object arrays are now reserved for constructing an Rdata.frame
. To create a standard R list, use theRList
constructor directly (#398).
Bug Fixes
-
When capturing graphics with
captureR()
, clean-up now occurs even when the evaluated R code throws an error. This avoids leaking graphics devices on the device stack. -
Use backticks when reporting an R call as part of an error message (#397).
webR 0.3.1
Hotfix release to manage incompatible WebAssembly binary R packages due to ABI changes in Emscripten.
webR 0.3.0
New features
-
Updated to R version 4.3.3.
-
Support for building webR and LLVM Flang as Nix packages, using Nix flakes.
-
WebR's
./configure
script now detects the presence of aEMFC
environment variable in the user's environment. If this variable points to an existingflang-new
binary, and a Fortran runtime library for WebAssembly can also be found, webR will skip building LLVM flang and instead use the version provided by the environment. -
Additional optional Wasm system libraries for linking with R packages: libsodium (#333), webp (#334), imagemagick (#336), libarchive; lz4; zstd (#337), gmp; mpfr; glpk (#339), gsl (#340), libgit2 (#342).
-
The webR development Docker container now contains a Rust toolchain configured to produce binaries for the
wasm32-unknown-emscripten
target, enabling the building of R packages containing Rust code for webR. -
The
webr::canvas()
graphics device has a new argumentcapture
, defaulting toFALSE
. WhenTRUE
, plots are captured into a canvas cache on the webR worker thread. The cache may be accessed from JavaScript throughModule.webr.canvas
. Entries in the canvas cache are destroyed usingwebr::canvas_purge()
orwebr::canvas_destroy(id)
. In this way, thecaptureR()
method now captures plots by default (see below). -
The
RCall
andRFunction
classes now have acapture(options, ...args)
method that captures output during evaluation. -
Errors re-thrown by
evalR
now include information about the source R call, helping to identify the original location of the error. -
JavaScript objects of type
TypedArray
,ArrayBuffer
, andArrayBufferView
(e.g.Uint8Array
) may now be used with theRRaw
R object constructor. The genericRObject
constructor now converts objects of this type to R raw atomic vectors by default. -
Constructing new R objects using
await new RObject(...)
now supports input objects of the form:{a: [...], b: [...]}
or D3-style data arrays of the form:[{a: ..., b: ...}, {a: ..., b: ...}, {a: ..., b: ...}, ... ]
. Where possible, lists are constructed of classdata.frame
. Direct construction withRList()
does not create adata.frame
. -
R
data.frame
objects may be converted into D3-style data arrays using the new R list object method.toD3()
.
Breaking changes
-
The
captureR()
method now captures plots generated by the canvas graphics device by default. Captured plots are returned as an array ofImageBitmap
objects in the propertyimages
. The previous behaviour may be restored either by manually starting a non-capturingwebr::canvas()
device during execution, or by includingcaptureGraphics: false
as part of theoptions
argument. The default options forevalR()
are set so that plotting is not captured, retaining the current behaviour. -
Upgraded the base LLVM distribution from LLVM 14 to LLVM 18, rebasing our Fortran for WebAssembly patches on the latest release of LLVM at time of writing (v18.1.1). The LLVM Fortran compiler binary name is now
flang-new
and webR's build scripts have been updated to reflect this. Theemfc
wrapper script is no longer required, but for the moment the Make variable pointing to theflang-new
compiler is still namedEMFC
for backwards compatibility. -
The LLVM flang build scripts are now sourced using a git submodule, to simplify management of CI builds. The build scripts are available at https://github.com/r-wasm/flang-wasm and the patched LLVM source at https://github.com/r-wasm/llvm-project. This allows for an independent build of the patched LLVM flang for WebAssembly, including as a separate Nix package.
-
shim_install()
now shims base Rlibrary()
andrequire()
commands so that webR packages are downloaded automatically with an optional menu. This extends the functionality of the global package-not-found handler so that the same feature can be used when usingevalR()
(#324). The new shims also ensure thatlibrary()
andrequire()
do not need to be called again once the package is downloaded and available. -
It is no longer assumed that an interactive R session will be able to show a
menu()
when offering to download a missing R package. Instead this now defaults to not showing a menu, withoptions(webr.show_menu = TRUE)
enabling the menu feature globally. -
The
RObject.toObject()
methods have been refined for R lists anddata.frame
objects. The.toObject()
method no longer uses recursion by default when converting R lists and environments, due to the possibility of unconvertible nested R objects. However, for symbols, atomic vectors, and Rdata.frame
objects.toObject()
will convert the object to JavaScript in entirety. For a type-stable conversion, serialise the object with the.toJs()
method instead.
Bug Fixes
-
Fix showing content of lazy loaded files in webR demo app editor component (#320).
-
Contents of the code editor in the webR REPL application is now sourced as a temporary file, allowing for input longer than the default R console input buffer length (#326).
-
R error conditions raised during evaluation of an
RCall
orRFunction
object are now re-thrown as JavaScript exceptions. -
Fixed spelling errors in some JavaScript errors thrown by webR.
-
Useful POSIX scripts from libraries compiled for Wasm are now copied to
$(HOST)/bin
so that$(WASM)/bin
does not need to be put on the path when building Wasm R packages (#327). -
The
symbols.rds
make target should now work when building R packages usingrwasm
(r-wasm/rwasm#13). -
Rasters with negative width or height are now drawn mirrored or flipped when using the canvas graphics device (#350).
-
Include
cex
parameters when calculating font size in canvas graphics device (#348).
webR 0.2.2
New features
-
Updated
Dockerfile
to build webR with LLVMflang
and setup environment in preparation for building Wasm R packages. The Docker container is now built and published by GitHub Actions as part of webR CI deployment from themain
branch. -
The base R function
install.packages()
is has now been shimmed to usewebr::install()
in the webR demo app. -
Expose Emscripten's
FS.mount()
onwebr::mount
in R, andwebR.FS.mount()
in JavaScript. This allows images built using Emscripten'sfile_packager
to be mounted on the virtual filesystem and host directory paths to be mounted when running under Node. See the webR documentation for details. -
By default,
webr::install()
now useswebr::mount()
to mount Wasm R packages into the R library, rather than downloading package.tgz
archives and decompressing the contents to the virtual filesystem. This improves the performance of package installation. If the package repository does not provide.data
Emscripten filesystem images,webr::install()
will fallback to downloading.tgz
packages, as before.
Breaking changes
-
When starting webR using the
ChannelType.Automatic
channel (the default), thePostMessage
channel is now used as the fallback when the web page is not Cross-Origin Isolated. ThePostMessage
channel has the widest compatibility, but is unable to use functions that block for input (e.g.readline()
,menu()
,browser()
, etc). If blocking for input is required, theServiceWorker
channel is still available, but must be requested explicitly. -
Invoking the
system()
function now raises an R error condition. -
Invoking functions that block for input now raises an R error condition when running under the
PostMessage
communication channel. -
Options are now passed to the JavaScript function
webR.installPackages()
in the form of anoptions
argument, an object of typeInstallPackagesOptions
.
Bug fixes
webR 0.2.1
New features
- Added a new communication channel based on
postMessage
, to be used when both Cross Origin Isolation and Service Workers are unavailable. Nested R REPLs (e.g.readline()
,menu()
,browser()
, etc.) are unsupported when using this channel.
Bug fixes
webR 0.2.0
New features
-
Improve accessibility of xterm.js in the webR REPL app by enabling
screenReaderMode
. -
Issue an output message of type
'closed'
when the webR communication channel closes. -
Build Cairo graphics library and its prerequisites for Wasm as part of the webR build process. This allows the default Cairo-based graphics devices in R, such as
png()
,bmp()
andsvg()
, to work in webR. -
Build Pango text layout library and its prerequisites for Wasm. This provides modern text rendering features and better support for internationalisation (e.g. font-fallback and RTL scripts) for the Cairo-based bitmap graphics devices.
-
Update webR's version of R to 4.3.0.
-
Include additional type predicate functions for subclasses of
RObject
, such asisRDouble()
. These can be used by TypeScript applications to narrow the typing of anRObject
without assertion using theas
keyword. The new type predicate functions have also been re-exported through the defaultWebR
module. -
Introduce lazy virtual filesystem entries. The webR filesystem is populated at initialisation time with only the files required to startup R. Other files made available (e.g. documentation and HTML pages) are downloaded on demand when the files are opened for reading by some process. The optional lazy filesystem entries can be avoided in entirety by setting
createLazyFilesystem: false
inWebROptions
. -
Add a
quiet
argument towebr::install()
andwebR.installPackages()
APIs that allows for silencing webR package downloading messages. -
Add custom
WebRError
classes so that errors from webR can be identified by testing thrown exceptions withinstanceof WebRError
. -
Reimplemented the demo webR REPL app using the React framework, allowing us to drop jQuery as a dependency. The reworked app has various new features and improvements: now includes a tabbed CodeMirror editor with R syntax highlighting and autocomplete, support for text document paging and displaying built-in R help/demos/documentation, expanded UI for virtual filesystem management, improved plot handling including paged multiple plots.
Breaking changes
-
The webR npm package has been renamed from '@r-wasm/webr' to simply 'webr'. An npm depreciation notice will be put in place for the old package name.
-
Removed the legacy
console.mjs
build target. TheConsole
class is re-exported on the defaultWebR
entrypoint, and so the extra build target is not required. This is technically a breaking change, but the legacy entrypoint was never documented and so we believe the change has only minor effect. -
The webR HTML
canvas()
graphics device has been moved from the default grDevices package to the webr support package. In addition, it has been reimplemented using theOffscreenCanvas
API. Users of the Safari web browser will now require at least version 16.4 to use the canvas graphics device. Users with older browsers not supportingOffscreenCanvas
will need to use an alternative plotting method, such as bitmap graphics using thepng()
Cairo device. -
Output messages from the
canvas()
graphics device have been restructured so as to handle more event types in addition to transmitting image bitmap data. For example, an output message is now also emitted when the device creates a new empty plot. WebR apps making use of HTML canvas graphics will need to be updated for the new message structure. See the newly added "Plotting" section in the webR documentation for further details. -
The version of Emscripten used to build the public webR binaries hosted on r-wasm.org and npm has been set to v3.1.37. R packages built for Wasm should be compiled with this same version of Emscripten to ensure Wasm ABI compatibility.
Bug fixes
- The
REnv
property of a user providedWebROptions
is now merged with the default value, rather than replacing it. With this a user need not explicitly include the defaultR_HOME
value when adding new environment variables.