Skip to content

Commit 7c624f7

Browse files
authored
Release webR 0.4.0 (#452)
* webR 0.4.0-rc.0 * Minor design tweaks for use on mobile devices * webR 0.4.0 * Update NEWS.md
1 parent c012034 commit 7c624f7

File tree

8 files changed

+42
-14
lines changed

8 files changed

+42
-14
lines changed

NEWS.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# webR (development version)
22

3+
# webR 0.4.0
4+
35
## New features
46

5-
* Updated to R version 4.4.0.
7+
* Updated to R version 4.4.1.
68

79
* 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).
810

flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# cd src; prefetch-npm-deps package-lock.json
2727
srcNpmDeps = pkgs.fetchNpmDeps {
2828
src = "${self}/src";
29-
hash = "sha256-FgkBQyaMKHHjSsXvFu6Raj6gegslbvyBT1SvNz52UdY=";
29+
hash = "sha256-TdFaeMYs/U/VIX56cN2gqzwJJ3M5Crge2fl/T9L5D4M=";
3030
};
3131

3232
inherit system;

packages/webr/DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: webr
33
Title: WebR Support Package
4-
Version: 0.3.3.9000
4+
Version: 0.4.0
55
Authors@R: c(
66
person("George", "Stagg", , "[email protected]", role = c("aut", "cre")),
77
person("Lionel", "Henry", , "[email protected]", role = "aut"),

src/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webr",
3-
"version": "0.3.4-dev",
3+
"version": "0.4.0",
44
"description": "The statistical programming language R compiled into WASM for use in a web browser and node.",
55
"keywords": [
66
"webR",

src/repl/App.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ body {
22
padding: 0;
33
margin: 0;
44
font-family: sans-serif;
5+
overflow: hidden;
56
}
67

78
:root {
@@ -15,7 +16,8 @@ body {
1516

1617
.repl {
1718
width: 100vw;
18-
height: 100vh;
19+
height: 100vh; /* Fallback for dvh */
20+
height: 100dvh;
1921
}
2022

2123
div[data-panel] {

src/repl/App.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Readline } from 'xterm-readline';
88
import { WebR } from '../webR/webr-main';
99
import { bufferToBase64 } from '../webR/utils';
1010
import { CanvasMessage, PagerMessage, ViewMessage, BrowseMessage } from '../webR/webr-chan';
11-
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
11+
import { Panel, PanelGroup, PanelResizeHandle, ImperativePanelHandle } from 'react-resizable-panels';
1212
import './App.css';
1313
import { NamedObject, WebRDataJsAtomic } from '../webR/robj';
1414

@@ -147,6 +147,14 @@ const onPanelResize = (size: number) => {
147147
};
148148

149149
function App() {
150+
const rightPanelRef = React.useRef<ImperativePanelHandle | null>(null);
151+
React.useEffect(() => {
152+
window.addEventListener("resize", () => {
153+
if (!rightPanelRef.current) return;
154+
onPanelResize(rightPanelRef.current.getSize());
155+
});
156+
}, []);
157+
150158
return (
151159
<div className='repl'>
152160
<PanelGroup direction="horizontal">
@@ -162,7 +170,7 @@ function App() {
162170
</PanelGroup>
163171
</Panel>
164172
<PanelResizeHandle />
165-
<Panel onResize={onPanelResize} minSize={10}>
173+
<Panel ref={rightPanelRef} onResize={onPanelResize} minSize={10}>
166174
<PanelGroup direction="vertical">
167175
<Files webR={webR} filesInterface={filesInterface} />
168176
<PanelResizeHandle />
@@ -195,7 +203,7 @@ void (async () => {
195203
await webR.evalRVoid('webr::shim_install()');
196204

197205
// If supported, show a menu when prompted for missing package installation
198-
const showMenu = crossOriginIsolated || navigator.serviceWorker.controller;
206+
const showMenu = crossOriginIsolated;
199207
await webR.evalRVoid('options(webr.show_menu = show_menu)', { env: { show_menu: !!showMenu } });
200208
await webR.evalRVoid('webr::global_prompt_install()', { withHandlers: false });
201209

src/repl/components/Plot.tsx

+20-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import './Plot.css';
33
import { PlotInterface } from '../App';
44
import { FaArrowCircleLeft, FaArrowCircleRight, FaRegSave, FaTrashAlt } from 'react-icons/fa';
5-
import { Panel } from 'react-resizable-panels';
5+
import { Panel, ImperativePanelHandle } from 'react-resizable-panels';
66
import { WebR } from '../../webR/webr-main';
77

88
export function Plot({
@@ -13,6 +13,7 @@ export function Plot({
1313
plotInterface: PlotInterface;
1414
}) {
1515
const plotContainerRef = React.useRef<HTMLDivElement | null>(null);
16+
const panelRef = React.useRef<ImperativePanelHandle | null>(null);
1617
const canvasRef = React.useRef<HTMLCanvasElement | null>(null);
1718
const canvasElements = React.useRef<HTMLCanvasElement[]>([]);
1819
const plotSize = React.useRef<{width: number, height: number}>({width: 1008, height: 1008});
@@ -42,7 +43,8 @@ export function Plot({
4243

4344
// Resize the canvas() device when the plotting pane changes size
4445
plotInterface.resize = (direction, px) => {
45-
plotSize.current[direction] = Math.max(px / 1.5, 150);
46+
const pixelRatio = window.devicePixelRatio || 1.0;
47+
plotSize.current[direction] = Math.max( pixelRatio * px / 1.5, 150);
4648
void webR.init().then(async () => {
4749
await webR.evalRVoid(`
4850
# Close any active canvas devices
@@ -61,6 +63,14 @@ export function Plot({
6163
};
6264
}, [plotInterface]);
6365

66+
const onResize = (size:number) => plotInterface.resize("height", size * window.innerHeight / 100);
67+
React.useEffect(() => {
68+
window.addEventListener("resize", () => {
69+
if (!panelRef.current) return;
70+
onResize(panelRef.current.getSize());
71+
});
72+
}, []);
73+
6474
// Update the plot container to display the currently selected canvas element
6575
React.useEffect(() => {
6676
if (!plotContainerRef.current) {
@@ -91,10 +101,16 @@ export function Plot({
91101

92102
const nextPlot = () => setSelectedCanvas((selectedCanvas === null) ? null : selectedCanvas + 1);
93103
const prevPlot = () => setSelectedCanvas((selectedCanvas === null) ? null : selectedCanvas - 1);
94-
const onResize = (size:number) => plotInterface.resize("height", size * window.innerHeight / 100);
95104

96105
return (
97-
<Panel id="plot" role="region" aria-label="Plotting Pane" minSize={20} onResize={onResize}>
106+
<Panel
107+
id="plot"
108+
role="region"
109+
aria-label="Plotting Pane"
110+
minSize={20}
111+
onResize={onResize}
112+
ref={panelRef}
113+
>
98114
<div className="plot-header">
99115
<div role="toolbar" aria-label="Plotting Toolbar" className="plot-actions">
100116
<button

0 commit comments

Comments
 (0)