Skip to content
Open
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 CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ documents, then edits a declaration and checks the new symbol.

Run `pnpm run test:web` for the headless Chromium suite. The test runner downloads VS Code for the Web, the R syntax extension, and Playwright's Chromium. The first R session fetches the pinned webR assets and package library over HTTPS. Linux CI images also need the Playwright browser system dependencies. To provision Chromium and its system dependencies explicitly for the tested runner, run `pnpm dlx playwright@1.65.1 install --with-deps chromium` before the suite.

Run `pnpm run test:web:project` to exercise the portable webR project workspace in Chromium.

The suite opens virtual and unsaved documents, runs editor commands, transfers files, exercises cancellation on a cross-origin isolated workbench, and reopens a saved Interactive transcript. Manually testing a browser development extension on `vscode.dev` can prompt for notebook trust when opening a notebook for the first time.

### Releasing the webR language service
Expand Down
80 changes: 80 additions & 0 deletions ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,83 @@ Copyright (c) 2007, Nick Galbreath -- nickg [at] client9 [dot] com
All rights reserved.
http://code.google.com/p/stringencoders/
Released under the MIT license.

webR project bundles
--------------------

@zip.js/zip.js 2.25.0 (https://github.com/gildas-lormeau/zip.js)
Bundled source files also credit Copyright (c) 2022, 2025, 2026 Gildas Lormeau.
BSD 3-Clause License

Copyright (c) 2023, Gildas Lormeau

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

proper-lockfile 4.1.2 (https://github.com/moxystudio/node-proper-lockfile)
retry 0.12.0 (https://github.com/tim-kos/node-retry)
Copyright (c) 2011:
Tim Koschützki (tim@debuggable.com)
Felix Geisendörfer (felix@debuggable.com)
The MIT License (MIT)

Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

graceful-fs 4.2.11 (https://github.com/isaacs/node-graceful-fs)
signal-exit 3.0.7 (https://github.com/tapjs/signal-exit)
Copyright (c) 2015, Contributors (signal-exit)
The ISC License

Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
40 changes: 39 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,30 @@
"onLanguage:r",
"onLanguage:rmd",
"onNotebook:r-interactive",
"onFileSystem:vscode-r-webr"
"onFileSystem:vscode-r-webr",
"onFileSystem:vscode-r-project"
],
"main": "./dist/extension",
"browser": "./dist/web-extension.js",
"contributes": {
"customEditors": [
{
"viewType": "r.webRProject",
"displayName": "webR Project",
"selector": [{ "filenamePattern": "*.webrproj" }],
"priority": "default"
}
],
"terminal": {
"profiles": [
{
"title": "R Terminal",
"id": "r.terminal-profile"
},
{
"title": "webR Project Terminal",
"id": "r.webr-project-terminal",
"icon": "terminal"
}
]
},
Expand Down Expand Up @@ -902,6 +916,22 @@
"category": "R",
"icon": "$(folder-opened)"
},
{
"command": "r.webR.newProject",
"title": "New webR Project…",
"category": "R"
},
{
"command": "r.webR.openProject",
"title": "Open webR Project…",
"category": "R"
},
{
"command": "r.webR.projectTerminal",
"title": "Open webR Project Terminal",
"category": "R",
"enablement": "r.hasWebRProject"
},
{
"command": "r.interactive.open",
"title": "Open Interactive Session",
Expand Down Expand Up @@ -1081,6 +1111,11 @@
}
],
"keybindings": [
{
"command": "r.webR.projectTerminal",
"key": "ctrl+shift+`",
"when": "isWeb && !terminalProcessSupported && virtualWorkspace == vscode-r-project && workspaceFolderCount == 1"
},
{
"command": "r.runSelection",
"key": "Ctrl+enter",
Expand Down Expand Up @@ -2773,6 +2808,7 @@
"test:node": "mocha \"out/test/node/**/*.test.js\" --config .mocharc.interactive.cjs",
"test:extension": "vscode-test",
"test:web": "pnpm run compile && pnpm --allow-build=@playwright/browser-chromium dlx @vscode/test-web@0.0.81 --browser chromium --headless --coi --quality stable --extensionId REditorSupport.r-syntax --extensionDevelopmentPath=. --extensionTestsPath=src/test/web/webR.cjs",
"test:web:project": "pnpm run compile && pnpm --allow-build=@playwright/browser-chromium dlx @vscode/test-web@0.0.81 --browser chromium --headless --coi --quality stable --extensionId REditorSupport.r-syntax --extensionDevelopmentPath=. --extensionTestsPath=src/test/web/webRProject.cjs",
"test:activation": "node --test scripts/activation-environment.test.cjs && node scripts/test-activation.cjs",
"lint": "oxlint src",
"format": "oxfmt .",
Expand Down Expand Up @@ -2816,11 +2852,13 @@
},
"dependencies": {
"@vscode/codicons": "0.0.46-24",
"@zip.js/zip.js": "2.25.0",
"ag-grid-community": "^36.3.0",
"cheerio": "1.2.0",
"ejs": "^7.0.2",
"highlight.js": "^11.12.0",
"js-yaml": "^5.5.0",
"proper-lockfile": "4.1.2",
"tar": "7.5.24",
"vscode-jsonrpc": "10.0.0",
"vscode-languageclient": "^11.0.0",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { globalRHelp } from './extension';
import { config } from './util';
import { getChunks } from './rmarkdown';
import { CompletionItemKind } from 'vscode-languageclient';
import { WEBR_FILE_SCHEME } from './webr/sessionFiles';
import { WEBR_PROJECT_SCHEME } from './webr/projectWorkspace';

// Get with names(roxygen2:::default_tags())
const roxygenTagCompletionItems = [
Expand Down Expand Up @@ -230,6 +232,17 @@ export class HelpLinkHoverProvider implements vscode.HoverProvider {
) {
return null;
}
// The webR language worker supplies help from its own package library.
// Looking up a native Help-panel link here also starts a host R process.
const scheme = document.uri.scheme;
if (
scheme === WEBR_PROJECT_SCHEME ||
scheme === WEBR_FILE_SCHEME ||
((scheme === 'vscode-interactive-input' || scheme === 'vscode-notebook-cell') &&
session.boundSessionForDocument(document.uri)?.interactiveProvider === 'webr')
) {
return null;
}

if (document.languageId === 'rmd') {
const chunks = getChunks(document);
Expand Down
9 changes: 8 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';
import { registerWebRProjects } from './webr/projectWorkspace';
import { createDesktopProjectHost } from './interactive/projectHost';

// interfaces, functions, etc. provided by vscode
import { WebRSessionFiles } from './webr/sessionFiles';
Expand Down Expand Up @@ -273,7 +275,12 @@ export async function activate(
// initialize the package/help related functions
globalRHelp = await rHelp.initializeHelp(context, rExtension);
const sessionFiles = new WebRSessionFiles(context.workspaceState);
context.subscriptions.push(new InteractiveManager(context, sessionFiles), sessionFiles);
const interactive = new InteractiveManager(context, sessionFiles);
context.subscriptions.push(
interactive,
sessionFiles,
registerWebRProjects(context, createDesktopProjectHost(context, interactive)),
);

// register codelens and completion providers for r markdown and r files
const codeLensProvider = new rmarkdown.RMarkdownCodeLensProvider();
Expand Down
19 changes: 11 additions & 8 deletions src/helpViewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ export async function initializeHelp(
// set context value to indicate that the help related tree-view should be shown
void vscode.commands.executeCommand('setContext', 'r.helpViewer.show', true);

// get the "vanilla" R path from config
const rPath = await getRpath(false, undefined, false);
// A native child can only use a directory on its extension host. In a
// pure virtual workspace, leave its cwd unset just as in an empty window.
const folder = vscode.workspace.workspaceFolders?.find(
({ uri }) =>
uri.scheme === 'file' ||
(uri.scheme === 'vscode-remote' &&
context.extensionUri.scheme === uri.scheme &&
uri.authority === context.extensionUri.authority),
);
const rPath = await getRpath(false, folder?.uri, false);
if (!rPath) {
return undefined;
}

// get the current working directory from vscode
const cwd = vscode.workspace.workspaceFolders?.length
? vscode.workspace.workspaceFolders[0].uri.fsPath
: undefined;

// get the Memento for storing cached help files (or create a dummy for this session)
const cacheConfig = config().get<'None' | 'Workspace' | 'Global'>('helpPanel.cacheIndexFiles');
const persistentState =
Expand All @@ -72,7 +75,7 @@ export async function initializeHelp(
indexTemplatePath: context.asAbsolutePath('./dist/webviews/help/00Index.ejs'),
rdToHtmlScriptFile: context.asAbsolutePath('./R/help/rdToHtml.R'),
rPath: rPath,
cwd: cwd,
cwd: folder?.uri.fsPath,
persistentState: persistentState,
};

Expand Down
1 change: 1 addition & 0 deletions src/interactive/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export class SessionAgent {
label: config.label,
host: os.hostname(),
directory: config.directory,
projectBundle: config.projectBundle,
endpoint: localEndpoint(this.runtime, 'control.sock'),
token: randomBytes(32).toString('hex'),
agentPid: process.pid,
Expand Down
Loading