Skip to content

Commit

Permalink
Bump webR version from 0.3.1 to 0.3.2 (#188)
Browse files Browse the repository at this point in the history
* Bump webR version from 0.3.1 to 0.3.2

* Rework captureR to use the new image options

* Add release note
  • Loading branch information
coatless authored Apr 10, 2024
1 parent 4dabeca commit c1bc7db
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion _extensions/webr/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: webr
title: Embedded webr code cells
author: James Joseph Balamuta
version: 0.4.2-dev.3
version: 0.4.2-dev.4
quarto-required: ">=1.2.198"
contributes:
filters:
Expand Down
37 changes: 27 additions & 10 deletions _extensions/webr/qwebr-compute-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,37 @@ globalThis.qwebrComputeEngine = async function(
// Initialize webR
await mainWebR.init();

// Configure capture output
let captureOutputOptions = {
withAutoprint: true,
captureStreams: true,
captureConditions: false,
// env: webR.objs.emptyEnv, // maintain a global environment for webR v0.2.0
};

// Determine if the browser supports OffScreen
if (typeof OffscreenCanvas !== 'undefined') {
// Mirror default options of webr::canvas()
// with changes to figure height and width.
captureOutputOptions.captureGraphics = {
width: fig_width,
height: fig_height,
bg: "white", // default: transparent
pointsize: 12,
capture: true
};
} else {
// Disable generating graphics
captureOutputOptions.captureGraphics = false;
}

// Setup a webR canvas by making a namespace call into the {webr} package
// Evaluate the R code
// Remove the active canvas silently
const result = await mainWebRCodeShelter.captureR(
`webr::canvas(width=${fig_width}, height=${fig_height}, capture = TRUE)
.webr_cvs_id <- dev.cur()
${codeToRun}
invisible(dev.off(.webr_cvs_id))
`, {
withAutoprint: true,
captureStreams: true,
captureConditions: false//,
// env: webR.objs.emptyEnv, // maintain a global environment for webR v0.2.0
});
`${codeToRun}`,
captureOutputOptions
);

// -----

Expand Down
2 changes: 1 addition & 1 deletion _extensions/webr/webr-serviceworker.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
importScripts('https://webr.r-wasm.org/v0.3.1/webr-serviceworker.js');
importScripts('https://webr.r-wasm.org/v0.3.2/webr-serviceworker.js');
2 changes: 1 addition & 1 deletion _extensions/webr/webr-worker.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
importScripts('https://webr.r-wasm.org/v0.3.1/webr-worker.js');
importScripts('https://webr.r-wasm.org/v0.3.2/webr-worker.js');
2 changes: 1 addition & 1 deletion _extensions/webr/webr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local hasDoneWebRSetup = false
-- https://docs.r-wasm.org/webr/latest/api/js/interfaces/WebR.WebROptions.html

-- Define a base compatibile version
local baseVersionWebR = "0.3.1"
local baseVersionWebR = "0.3.2"

-- Define where WebR can be found
local baseUrl = "https://webr.r-wasm.org/v".. baseVersionWebR .."/"
Expand Down
2 changes: 2 additions & 0 deletions docs/qwebr-release-notes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Features listed under the `-dev` version have not yet been solidified and may ch

## Features

- Upgraded to webR v0.3.2 ([#187](https://github.com/coatless/quarto-webr/issues/187)!)

- Added `cell-options` document-level option to specify global defaults for `{webr-r}` options ([#173](https://github.com/coatless/quarto-webr/pulls/173), thanks [ute](https://github.com/ute)!)

- Added `editor-max-height` cell option to limit growth of the editor window. ([#177](https://github.com/coatless/quarto-webr/issues/177), thanks [ute](https://github.com/ute)!)
Expand Down

0 comments on commit c1bc7db

Please sign in to comment.