Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

* Proxy Web Worker communication through the main thread when using the `SharedArrayBuffer` communication channel (#576).

* The R version is now exposed at `webR.versionR` and as the `R_VERSION` environment variable (#577).

# webR 0.5.5

## New features
Expand Down
7 changes: 5 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TS_SOURCES = $(shell find $(ROOT) \
BASE_URL ?= "./"
PKG_BASE_URL ?= "https://repo.r-wasm.org"
WEBR_VERSION ?= $(shell node -p "require('./package.json').version")
R_VERSION = $(shell cat ../R/R-VERSION)

HTML_DIST = $(addprefix $(DIST)/,$(HTML_TEMPLATES))
$(DIST)/webr.mjs: $(TS_SOURCES) $(HTML_DIST) \
Expand All @@ -30,12 +31,14 @@ $(DIST)/webr.mjs: $(TS_SOURCES) $(HTML_DIST) \
$(DIST)/%.html: templates/%.html
sed -e "s|@@BASE_URL@@|$(BASE_URL)|" \
-e "s|@@PKG_BASE_URL@@|$(PKG_BASE_URL)|" \
-e "s|@@WEBR_VERSION@@|$(WEBR_VERSION)|" $< > $@
-e "s|@@WEBR_VERSION@@|$(WEBR_VERSION)|" \
-e "s|@@R_VERSION@@|$(R_VERSION)|" $< > $@

webR/config.ts: webR/config.ts.in
sed -e "s|@@BASE_URL@@|$(BASE_URL)|" \
-e "s|@@PKG_BASE_URL@@|$(PKG_BASE_URL)|" \
-e "s|@@WEBR_VERSION@@|$(WEBR_VERSION)|" webR/config.ts.in > webR/config.ts
-e "s|@@WEBR_VERSION@@|$(WEBR_VERSION)|" \
-e "s|@@R_VERSION@@|$(R_VERSION)|" webR/config.ts.in > webR/config.ts

.PHONY: lint
lint: $(DIST)
Expand Down
1 change: 1 addition & 0 deletions src/webR/config.ts.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ import { IN_NODE } from './compat';
export const BASE_URL = IN_NODE ? __dirname + '/' : '@@BASE_URL@@';
export const PKG_BASE_URL = '@@PKG_BASE_URL@@';
export const WEBR_VERSION = '@@WEBR_VERSION@@';
export const R_VERSION = '@@R_VERSION@@';
4 changes: 3 additions & 1 deletion src/webR/webr-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { ChannelMain } from './chan/channel';
import { newChannelMain, ChannelType } from './chan/channel-common';
import { CloseWebSocketMessage, Message, PostMessageWorkerMessage, ProxyWebSocketMessage, ProxyWorkerMessage, SendWebSocketMessage, TerminateWorkerMessage } from './chan/message';
import { BASE_URL, PKG_BASE_URL, WEBR_VERSION } from './config';
import { BASE_URL, PKG_BASE_URL, WEBR_VERSION, R_VERSION } from './config';
import { EmPtr } from './emscripten';
import { WebRPayloadPtr } from './payload';
import { newRProxy, newRClassProxy } from './proxy';
Expand Down Expand Up @@ -209,6 +209,7 @@ const defaultEnv = {
ALL_PROXY: 'socks5h://localhost:8580',
WEBR: '1',
WEBR_VERSION: WEBR_VERSION,
R_VERSION: R_VERSION,
};

const defaultOptions = {
Expand Down Expand Up @@ -237,6 +238,7 @@ export class WebR {
#initialised: Promise<unknown>;
globalShelter!: Shelter;
version: string = WEBR_VERSION;
versionR: string = R_VERSION;

RObject!: ReturnType<typeof newRClassProxy<typeof RWorker.RObject, RObject>>;
RLogical!: ReturnType<typeof newRClassProxy<typeof RWorker.RLogical, RLogical>>;
Expand Down