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 .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
!dist/resources/codicon.ttf
!dist/resources/LICENSE
!dist/resources/LICENSE-CODE
!dist/resources/webr-LICENSE.md
!src/webr/resources/languageserver.tgz
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,30 @@ Interactive session. Run the source/bootstrap checks with
`pnpm run test:sess-source`, or just the base-R identity checks with
`pnpm run test:sess-identity`.

## Testing the webR language service

After compiling the extension, set `VSCR_ACTIVATION_CASES=webr-language` and run
`pnpm run test:activation` to exercise the automatic fallback in an isolated
VS Code profile. This case uses an unavailable R executable and downloads the
pinned webR assets. It checks Outline and Go to Definition across two unsaved R
documents, then edits a declaration and checks the new symbol.

### Releasing the webR language service

The VSIX includes the R-universe `wasm32-unknown-emscripten` languageserver
archive because R-universe removes older builds when it publishes a replacement.
To update it, select the matching webR ABI from the upstream package's
[`_binaries` metadata](https://reditorsupport.r-universe.dev/api/packages/languageserver),
replace `src/webr/resources/languageserver.tgz` with that archive, and update
its upstream URL and SHA-256 in `src/webr/packages.json`.

The pinned Wasm build of languageserver 0.3.22 predates the exported
`run_embedded()` entry point. Development builds use checksummed upstream R
modules with that binary. Before releasing this feature, pin a published Wasm
package that exports the supported entry point from [languageserver #905](https://github.com/REditorSupport/languageserver/pull/905), remove the temporary source
overlay, and repeat the desktop and browser open-document tests. The loader
prefers the exported entry point whenever the selected binary provides it.

## Testing R Interactive

The [architecture and backend contract](src/interactive/README.md) live beside the implementation. User setup and behavior belong in the [R Interactive documentation page](https://reditorsupport.github.io/vscode-R/features/r-interactive).
Expand Down
34 changes: 34 additions & 0 deletions ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,37 @@ raster variant used as the extension icon.
The logo is distributed under Creative Commons Attribution-ShareAlike 4.0
International:
https://creativecommons.org/licenses/by-sa/4.0/

R languageserver
----------------

The webR extension includes the R-universe WebAssembly build of languageserver
0.3.22 from https://github.com/REditorSupport/languageserver/commit/beef692f643bf3bfb03266d15729452cbdb09bdb.
Copyright (c) 2018 Randy Lai.

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.

webR JavaScript API
-------------------

The extension bundles the JavaScript API from webR 0.6.1. Copyright 2023 webR
authors. The distribution's licensing terms are included in
dist/resources/webr-LICENSE.md. Runtime binaries and additional R packages are retrieved
from their upstream distributions when the user starts webR.
https://github.com/r-wasm/webr/tree/v0.6.1
3 changes: 3 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function copyResources() {
console.warn(`Warning: Resource not found: ${srcPath}`);
}
}
fs.copyFileSync(path.join(__dirname, 'node_modules/webr/LICENSE.md'), path.join(destDir, 'webr-LICENSE.md'));
console.log('Resources copied.');
}

Expand Down Expand Up @@ -72,6 +73,7 @@ async function main() {
sourcemap: !production,
sourcesContent: false,
platform: 'node',
alias: { webr: path.resolve(__dirname, 'node_modules/webr/dist/webr.cjs') },
target: 'node22',
outfile: 'dist/extension.js',
external: ['vscode', 'utf-8-validate', 'bufferutil'],
Expand All @@ -84,6 +86,7 @@ async function main() {
bundle: true,
format: 'cjs',
platform: 'node',
alias: { webr: path.resolve(__dirname, 'node_modules/webr/dist/webr.cjs') },
target: 'node18',
outfile: 'dist/interactive-agent.js',
sourcemap: !production,
Expand Down
19 changes: 18 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,19 @@
"default": false,
"markdownDescription": "Use renv library paths to launch R background processes (R languageserver, help server, etc.)."
},
"r.lsp.runtime": {
"type": "string",
"enum": ["auto", "native", "webR"],
"enumItemLabels": [null, null, "webR (experimental)"],
"enumDescriptions": [
"Use native R when available. Otherwise use the experimental webR integration.",
"Require a native R installation.",
"Analyze open documents in a webR worker. The first session downloads a pinned runtime and supporting packages."
],
"default": "auto",
"scope": "resource",
"description": "Select the language server runtime. The webR integration is experimental. Its implementation and behavior may change substantially between releases."
},
"r.lsp.enabled": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -2657,8 +2670,12 @@
"ejs": "^7.0.2",
"highlight.js": "^11.12.0",
"js-yaml": "^5.5.0",
"tar": "7.5.24",
"vscode-jsonrpc": "10.0.0",
"vscode-languageclient": "^11.0.0",
"winreg": "^1.2.5"
"webr": "0.6.1",
"winreg": "^1.2.5",
"ws": "^8.23.0"
},
"extensionDependencies": [
"REditorSupport.r-syntax"
Expand Down
Loading
Loading