Skip to content

Commit

Permalink
Add release post for webR 0.3.1 (#689)
Browse files Browse the repository at this point in the history
* Update webR to v0.3.0-rc.0

* webR 0.3.0

* webR 0.3.1

* Update content/blog/webr-0-3-1/index.md

Co-authored-by: Lionel Henry <[email protected]>

* Apply suggestions from review

* Update date

* Style nit

---------

Co-authored-by: Lionel Henry <[email protected]>
  • Loading branch information
georgestagg and lionel- committed Apr 2, 2024
1 parent 8c1565d commit 047ba0e
Show file tree
Hide file tree
Showing 8 changed files with 771 additions and 23 deletions.
384 changes: 384 additions & 0 deletions content/blog/webr-0-3-1/index.Rmd

Large diffs are not rendered by default.

366 changes: 366 additions & 0 deletions content/blog/webr-0-3-1/index.md

Large diffs are not rendered by default.

Binary file added content/blog/webr-0-3-1/thumbnail-sq.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/blog/webr-0-3-1/thumbnail-wd.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 16 additions & 17 deletions layouts/shortcodes/webr-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
withAutoprint: true,
captureStreams: true,
captureConditions: false,
captureGraphics: false,
env: {},
});
try {
Expand All @@ -35,6 +36,17 @@
evt => evt.type == 'stdout' || evt.type == 'stderr'
).map((evt) => evt.data).join('\n');

outputDiv.innerHTML = '';
const pre = document.createElement("pre");
if (/\S/.test(out)) {
const code = document.createElement("code");
code.innerText = out;
pre.appendChild(code);
} else {
pre.style.visibility = 'hidden';
}
outputDiv.appendChild(pre);

const msgs = await webR.flush();
msgs.forEach(msg => {
if (msg.type === 'canvas'){
Expand All @@ -49,26 +61,13 @@
canvas.style.width="700px";
canvas.style.display="block";
canvas.style.margin="auto";
// Add it to the output block
const p = document.createElement("p");
p.appendChild(canvas);
outputDiv.appendChild(p);
}
}
});

outputDiv.innerHTML = '';
const pre = document.createElement("pre");
if (/\S/.test(out)) {
const code = document.createElement("code");
code.innerText = out;
pre.appendChild(code);
} else {
pre.style.visibility = 'hidden';
}
outputDiv.appendChild(pre);

if (canvas) {
const p = document.createElement("p");
p.appendChild(canvas);
outputDiv.appendChild(p);
}
} finally {
webRCodeShelter.purge();
runButton.disabled = false;
Expand Down
9 changes: 5 additions & 4 deletions layouts/shortcodes/webr-init.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/mode/r/r.js"></script>
<script type="module">
import { WebR } from 'https://webr.r-wasm.org/v0.2.0/webr.mjs';
globalThis.webR = new WebR({
serviceWorkerUrl: '/'
});
import { WebR } from 'https://webr.r-wasm.org/v0.3.1/webr.mjs';
globalThis.webR = new WebR();
await globalThis.webR.init();
await webR.evalRVoid("webr::shim_install()");
await webR.evalRVoid("webr::global_prompt_install()", { withHandlers: false });

globalThis.webRCodeShelter = await new globalThis.webR.Shelter();
document.querySelectorAll(".btn-webr").forEach((btn) => {
btn.innerText = 'Run code';
Expand Down
1 change: 0 additions & 1 deletion static/webr-serviceworker.js

This file was deleted.

1 change: 0 additions & 1 deletion static/webr-worker.js

This file was deleted.

0 comments on commit 047ba0e

Please sign in to comment.