diff --git a/.vscodeignore b/.vscodeignore index c86893494..66354a46c 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 272550e27..1e18bfaaf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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). diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt index 638152cb6..6b6b1ff30 100644 --- a/ThirdPartyNotices.txt +++ b/ThirdPartyNotices.txt @@ -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 diff --git a/esbuild.js b/esbuild.js index 990278cf4..6db33b0cc 100644 --- a/esbuild.js +++ b/esbuild.js @@ -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.'); } @@ -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'], @@ -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, diff --git a/package.json b/package.json index d9054fad0..4b85b8522 100644 --- a/package.json +++ b/package.json @@ -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, @@ -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" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 88c5f2410..18a16a662 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,12 +32,24 @@ importers: js-yaml: specifier: ^5.5.0 version: 5.5.0 + tar: + specifier: 7.5.24 + version: 7.5.24 + vscode-jsonrpc: + specifier: 10.0.0 + version: 10.0.0 vscode-languageclient: specifier: ^11.0.0 version: 11.0.0 + webr: + specifier: 0.6.1 + version: 0.6.1 winreg: specifier: ^1.2.5 version: 1.2.5 + ws: + specifier: ^8.23.0 + version: 8.23.0 devDependencies: '@microsoft/tui-test': specifier: 0.1.1 @@ -210,6 +222,30 @@ packages: resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} engines: {node: '>=18'} + '@codemirror/autocomplete@6.20.4': + resolution: {integrity: sha512-yF8RhOf2SXlg00+qtupzLhrglcas61boqaONiNcbPIebHCpJocpqTBA6dyrtUrQO47hqyTdeob/3XnYilT7TaQ==} + + '@codemirror/commands@6.11.2': + resolution: {integrity: sha512-NbH6Q9lmcXvf9s5/mMJIwL2Hjl2NEdsN/dDlezGnaFOQgNZ59dT7ndKUf21/PIjJacD/Ti2Ifi4TsBkO6WHvsg==} + + '@codemirror/language@6.13.1': + resolution: {integrity: sha512-zfvU2r3TyylQLMj/te+5CnQ0rSqZi8B1oTCBbQkagcLW4Xc6imab6qN+pEJhsuNOLaJqiRyBXp9UhWA1DhVvDw==} + + '@codemirror/lint@6.9.8': + resolution: {integrity: sha512-qNvtcE73xUto/D1RvtgSRI4A1Hg8ekxlvtZpjHpdpisLBnhyu82EUEJMEgaxkjuQCA8vqnrylENWKOsEDCOHcw==} + + '@codemirror/search@6.7.3': + resolution: {integrity: sha512-pD3bONMUhzkg4+cTpk3mkh3UAveJbZ5fhqPlRhYsP7mgBPEGhyy+8aUvy7Nggsc8MlZMkS1SKGzC7iFGh4YkUw==} + + '@codemirror/state@6.7.6': + resolution: {integrity: sha512-kAz+AncRtKuIknedxT1bq4XwXv4UowhbkHU1myPrtVb/jZtImWuV5BXzv5vK6i3kYACsdiZiQKFQQ5Mq7elW8w==} + + '@codemirror/streamparser@6.0.0': + resolution: {integrity: sha512-JTFPF6xrfjt0mnfGPgzcLiMwYmvIyNaoizp8BYzv8FE8KrT6GBGDZ190rtt+O7Wke3gG/MFHyiY9YGNeimof4w==} + + '@codemirror/view@6.44.2': + resolution: {integrity: sha512-7yxTh7+iCbxIV9QCJAVlkYjWV/TCHD0zmLIaIR3NOb47YpCWwVUuFUnHwkRC3z+8cXNgeJzrCy4QtlR3fVt5kg==} + '@esbuild/aix-ppc64@0.28.2': resolution: {integrity: sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==} engines: {node: '>=18'} @@ -504,6 +540,10 @@ packages: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} + '@isaacs/fs-minipass@4.0.1': + resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==} + engines: {node: '>=18.0.0'} + '@istanbuljs/schema@0.1.3': resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} engines: {node: '>=8'} @@ -618,6 +658,18 @@ packages: cpu: [x64] os: [win32] + '@lezer/common@1.5.7': + resolution: {integrity: sha512-3+3PN+M/3xSjrlQz8/wBPOl+JYGJ+G37ZszHfnhphFwj41qPUPxsz4WEic3ZyVpL23rX1qefaGqz0lA7jGUqwg==} + + '@lezer/highlight@1.2.5': + resolution: {integrity: sha512-O1GMVKgtf5YspFaRzpmqkVgMtIk2HG9uMAbH6wdAIdNh3TVzCsch/+cRi+6l2//UGDKe6NB9BW3cvuR5ezMQ0w==} + + '@lezer/lr@1.4.13': + resolution: {integrity: sha512-Ez6qF9rXdnR/7hTcA6kHq1uTcPV+17hyUFjiHBVYNi0a81TgbkC0SwiNvxcuUMkvX7phuhTHo+QAXh9L2kjGdg==} + + '@marijn/find-cluster-break@1.0.4': + resolution: {integrity: sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==} + '@microsoft/tui-test-darwin-arm64@0.1.1': resolution: {integrity: sha512-5AbGcOKsDnvRiYuJPc/5vensFgSjG7Jo1H8B80zcPb2CTC78Z+Ma33hANweE3xgUjNrrBP0Jxkg1j94Ex0PfLQ==} engines: {node: '>=20'} @@ -668,6 +720,10 @@ packages: resolution: {integrity: sha512-wIovmT/fkcHve2lYKJdtlIQcBrzA98yVp7l5hdjEHFmSELPTzdtCfJ5H+6rMqXEYpC0PDPdErUVqYp4YnTDNfg==} engines: {node: '>=20'} + '@msgpack/msgpack@2.8.0': + resolution: {integrity: sha512-h9u4u/jiIRKbq25PM+zymTyW6bhTzELvOoUd+AvYriWOAKpLGnIamaET3pnHYoI5iYphAHBI4ayx0MehR+VVPQ==} + engines: {node: '>= 10'} + '@napi-rs/keyring-darwin-arm64@1.3.0': resolution: {integrity: sha512-pl76hJvdYUBn6I24bXiOBMA9nbDapo3I5B+f3OorjDU4dUMSypXeKbOVehJe8fhgTiH24flMyTS3aAIy43xegQ==} engines: {node: '>= 10'} @@ -1366,6 +1422,14 @@ packages: engines: {node: '>= 22'} hasBin: true + '@xterm/addon-fit@0.10.0': + resolution: {integrity: sha512-UFYkDm4HUahf2lnEyHvio51TNGiLK66mqP2JoATy7hRZeXaGMRDr00JiSF7m63vR5WKATF605yEggJKsw0JpMQ==} + peerDependencies: + '@xterm/xterm': ^5.0.0 + + '@xterm/xterm@5.5.0': + resolution: {integrity: sha512-hqJHYaQb5OptNunnyAnkHyM8aCjZ1MEIDTQu1iIbbTD/xops91NB5yq1ZK/dC2JDbVWtF23zUtl9JE2NqwT87A==} + ag-charts-types@14.3.0: resolution: {integrity: sha512-6VtzUYBKN5mFY24/Eye3RUn1AAq7s+/B4hEu83ZOK/Pjqx26tHq2MoxiXlBE8F7oQO0VpjV5rZZaw6wxSpMNJg==} @@ -1498,10 +1562,17 @@ packages: resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} engines: {node: '>= 20.19.0'} + chownr@3.0.0: + resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==} + engines: {node: '>=18'} + ci-info@4.5.0: resolution: {integrity: sha512-d1uM8k5UZEyPza1n/MG3ko8nKupKN0KJpFsipgPcgaCCvV+IqIfJ+NzTjetlLM+UcXZx3+cLrNr76+eAO7G1Mw==} engines: {node: '>=8'} + classnames@2.5.1: + resolution: {integrity: sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==} + cli-cursor@5.0.0: resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==} engines: {node: '>=18'} @@ -1522,10 +1593,20 @@ packages: resolution: {integrity: sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==} engines: {node: '>=20'} + clsx@2.1.1: + resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} + engines: {node: '>=6'} + cockatiel@3.2.1: resolution: {integrity: sha512-gfrHV6ZPkquExvMh9IOkKsBzNDk6sDuZ6DdBGUBkvFnTCqCxzpuq48RySgP0AnaqQkw2zynOFj9yly6T1Q2G5Q==} engines: {node: '>=16'} + codemirror-lang-r@0.1.1: + resolution: {integrity: sha512-ke9Bm7IPKOoEk0p8LxZJaRlqp8CGOOZns9eKyj/WUaNV58h4uEeWbMpWeJJhVIPvfiuXYkv4FG1hD70gguWJLQ==} + + codemirror@6.0.2: + resolution: {integrity: sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==} + color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -1547,6 +1628,9 @@ packages: core-util-is@1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} + crelt@1.0.7: + resolution: {integrity: sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==} + cross-keychain@1.1.0: resolution: {integrity: sha512-244DWNdGepLKD5vEn3reZqwzZFiE/LD4U+XV9IaXQbtIXKvQkf0VkRaOj/9vPYauPdR12PSGB3U0cE7jJi3WTQ==} engines: {node: '>=18'} @@ -1596,6 +1680,10 @@ packages: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + diff@7.0.0: resolution: {integrity: sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==} engines: {node: '>=0.3.1'} @@ -1729,6 +1817,11 @@ packages: resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==} engines: {node: '>=14'} + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} @@ -1953,6 +2046,9 @@ packages: jackspeak@3.4.3: resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + js-yaml@4.3.2: resolution: {integrity: sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==} hasBin: true @@ -1983,9 +2079,86 @@ packages: koffi@3.3.8: resolution: {integrity: sha512-CTDlV3BDh8LFyCgv9vamD+5eu49HQ5wBetAJ9wxERAoAy6rfodahgo28tqhz010l2OGcZvrnBC6MOTyQUt4EIQ==} + lezer-r@0.1.3: + resolution: {integrity: sha512-tk+7Q54+ZYHKlLZj69GuZNC8+nMYPIFhGjrSe2fTyQAk9GyUsxgRsmF8V4r7cUiB65+lRu5/SrePeTEKQx5ZAQ==} + lie@3.3.0: resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==} + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + locate-path@6.0.0: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} @@ -2019,6 +2192,10 @@ packages: resolution: {integrity: sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==} engines: {node: '>=18'} + loose-envify@1.4.0: + resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} + hasBin: true + lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} @@ -2068,6 +2245,10 @@ packages: resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==} engines: {node: '>=16 || 14 >=14.17'} + minizlib@3.1.0: + resolution: {integrity: sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==} + engines: {node: '>= 18'} + mocha@11.8.0: resolution: {integrity: sha512-VyCeUdGN3A9lmCTTgG4yuvY9ixxaDk+xt2R/7/+1AP6EqNG+G9OKkzBwhVtVYoNX8YsxNSgAl8mOv3IAeOpFbw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2095,6 +2276,10 @@ packages: nth-check@2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} + object-assign@4.1.1: + resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} + engines: {node: '>=0.10.0'} + object-inspect@1.13.4: resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==} engines: {node: '>= 0.4'} @@ -2167,6 +2352,9 @@ packages: pako@1.0.11: resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} + pako@2.2.0: + resolution: {integrity: sha512-zJq6RP/5q+TO2OpFV3FHzlPnFjmkb7Nc99a5SNjJE+uu/PkpChs+NIZSSzbBoD+6kjiISXjfYdwj1ZRQ81dz/w==} + parse-ms@4.0.0: resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} engines: {node: '>=18'} @@ -2224,6 +2412,9 @@ packages: process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + prop-types@15.8.1: + resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} + proper-lockfile@4.1.2: resolution: {integrity: sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==} @@ -2231,6 +2422,43 @@ packages: resolution: {integrity: sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==} engines: {node: '>=0.6'} + react-accessible-treeview@2.11.2: + resolution: {integrity: sha512-qui0g/gBDpP7VbtqelgJezAzAjKOY3IVi1Rq1NRJ7Z627RXKyKiQ4ooxLK2yauxTvNyU0ke9S0a2d9YUMbJJbA==} + peerDependencies: + classnames: ^2.2.6 + prop-types: ^15.7.2 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + + react-data-grid@7.0.0-beta.44: + resolution: {integrity: sha512-VTql8VPBJEf7E+zkrqYW+jaQT1/m47dxigWzPq59QESJ8LhU59kHyzIx06BUpjdZKdK/tzbWaw2yyJpKoNnt5g==} + peerDependencies: + react: ^18.0 + react-dom: ^18.0 + + react-dom@18.3.1: + resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==} + peerDependencies: + react: ^18.3.1 + + react-icons@4.12.0: + resolution: {integrity: sha512-IBaDuHiShdZqmfc/TwHu6+d6k2ltNCf3AszxNmjJc1KUfXdEeRJOKyNvLmAHaarhzGmTSVygNdyu8/opXv2gaw==} + peerDependencies: + react: '*' + + react-is@16.13.1: + resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} + + react-resizable-panels@2.1.9: + resolution: {integrity: sha512-z77+X08YDIrgAes4jl8xhnUu1LNIRp4+E7cv4xHmLOxxUPO/ML7PSrE813b90vj7xvQ1lcf7g2uA9GeMZonjhQ==} + peerDependencies: + react: ^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc + react-dom: ^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc + + react@18.3.1: + resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==} + engines: {node: '>=0.10.0'} + read@1.0.7: resolution: {integrity: sha512-rSOKNYUmaxy0om1BNjMN4ezNT6VKK+2xF4GBhc81mkH7L60i6dp8qPYrkndNLT3QPphoII3maL9PVC9XmhHwVQ==} engines: {node: '>=0.8'} @@ -2272,6 +2500,9 @@ packages: resolution: {integrity: sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==} engines: {node: '>=11.0.0'} + scheduler@0.23.2: + resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} + semver@7.7.4: resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==} engines: {node: '>=10'} @@ -2373,6 +2604,9 @@ packages: structured-source@4.0.0: resolution: {integrity: sha512-qGzRFNJDjFieQkl/sVOI2dUjHKRyL9dAJi2gCPGJLbJHBIkyOHxjuocpIEfbLioX+qSJpvbYdT49/YCdMznKxA==} + style-mod@4.1.5: + resolution: {integrity: sha512-WQ2llCZa9sZSkJA+aOwpg5DkfbAXFKGh//t3MRTBeruFiSBC+GXUmbBzrw3bXyboCWAbtCW9InDfBsXrRD/rAg==} + supports-color@10.2.2: resolution: {integrity: sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==} engines: {node: '>=18'} @@ -2389,6 +2623,10 @@ packages: resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==} engines: {node: '>=6'} + tar@7.5.24: + resolution: {integrity: sha512-to/OxuCk5DeVONcjjODT7aeoRq5NIPPlfPc0tNML+wLlnf6u5BcJz97Uukv3pT3jzorkFhUevylkAiBr+ZmV2w==} + engines: {node: '>=18'} + test-exclude@8.0.0: resolution: {integrity: sha512-ZOffsNrXYggvU1mDGHk54I96r26P8SyMjO5slMKSc7+IWmtB/MQKnEC2fP51imB3/pT6YK5cT5E8f+Dd9KdyOQ==} engines: {node: 20 || >=22} @@ -2408,6 +2646,11 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + tsx@4.23.15: + resolution: {integrity: sha512-Yiex1Ovn8z2xPpOWckIiysV1SSyRMY9BkLF++q0yKiDxCqRhosKfMg3janKkiLBwZ5c/YryloKwGZcrEmtwxKw==} + engines: {node: '>=18.0.0'} + hasBin: true + tunnel@0.0.6: resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==} engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'} @@ -2476,6 +2719,13 @@ packages: vscode-languageserver-types@3.18.5: resolution: {integrity: sha512-kPd6+JQNz3HMJvjKlqUxERSlZHAntl/aGpsk7ImwIh0ewDKDcjgAEyVSYciPiOJD3ftbK9IrfiqUeTZLSbCizw==} + w3c-keyname@2.2.8: + resolution: {integrity: sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==} + + webr@0.6.1: + resolution: {integrity: sha512-dOyIK2ul4zbtrbylcfSdgS8uC7vygr6f4uUbCVJaqpKaPlSNo2cr+cjjI1RgzrS5GSiwAmrmVSI++M8fTnQupg==} + engines: {node: '>=17.0.0'} + whatwg-encoding@3.1.1: resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} engines: {node: '>=18'} @@ -2515,6 +2765,18 @@ packages: resolution: {integrity: sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==} engines: {node: '>=18'} + ws@8.23.0: + resolution: {integrity: sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + wsl-utils@1.0.1: resolution: {integrity: sha512-c16PKLIRxBYpR3jSWsdS7SFp0COm5SOQdiFjY818dYFHJbMGuLBszpF07LBWmOS1uzrHa9VGdynsEgoeKy0oOQ==} engines: {node: '>=20'} @@ -2527,6 +2789,15 @@ packages: resolution: {integrity: sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==} engines: {node: '>=4.0'} + xmlhttprequest-ssl@2.1.2: + resolution: {integrity: sha512-TEU+nJVUUnA4CYJFLvK5X9AOeH4KvDvhIfm0vV1GaQRtchnG0hgK5p8hw/xjv8cunWYCsiPCSDzObPyhEwq3KQ==} + engines: {node: '>=0.4.0'} + + xterm-readline@1.3.1: + resolution: {integrity: sha512-5dyP/rP3oj6Cm0Cf4g+h+AfzK+1nTC0uD48iI99NyJBnyzmXK8uKci7E30576hD+LpqclQb0mLYarWj6mKXw5w==} + peerDependencies: + '@xterm/xterm': ^5.5.0 || ^6.0.0 + y18n@5.0.8: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} @@ -2534,6 +2805,10 @@ packages: yallist@4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + yallist@5.0.0: + resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} + engines: {node: '>=18'} + yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} @@ -2692,6 +2967,55 @@ snapshots: '@bcoe/v8-coverage@1.0.2': {} + '@codemirror/autocomplete@6.20.4': + dependencies: + '@codemirror/language': 6.13.1 + '@codemirror/state': 6.7.6 + '@codemirror/view': 6.44.2 + '@lezer/common': 1.5.7 + + '@codemirror/commands@6.11.2': + dependencies: + '@codemirror/language': 6.13.1 + '@codemirror/state': 6.7.6 + '@codemirror/view': 6.44.2 + '@lezer/common': 1.5.7 + + '@codemirror/language@6.13.1': + dependencies: + '@codemirror/state': 6.7.6 + '@codemirror/streamparser': 6.0.0 + '@codemirror/view': 6.44.2 + '@lezer/common': 1.5.7 + '@lezer/highlight': 1.2.5 + '@lezer/lr': 1.4.13 + style-mod: 4.1.5 + + '@codemirror/lint@6.9.8': + dependencies: + '@codemirror/state': 6.7.6 + '@codemirror/view': 6.44.2 + crelt: 1.0.7 + + '@codemirror/search@6.7.3': + dependencies: + '@codemirror/state': 6.7.6 + '@codemirror/view': 6.44.2 + crelt: 1.0.7 + + '@codemirror/state@6.7.6': + dependencies: + '@marijn/find-cluster-break': 1.0.4 + + '@codemirror/streamparser@6.0.0': {} + + '@codemirror/view@6.44.2': + dependencies: + '@codemirror/state': 6.7.6 + crelt: 1.0.7 + style-mod: 4.1.5 + w3c-keyname: 2.2.8 + '@esbuild/aix-ppc64@0.28.2': optional: true @@ -2904,6 +3228,10 @@ snapshots: wrap-ansi: 8.1.0 wrap-ansi-cjs: wrap-ansi@7.0.0 + '@isaacs/fs-minipass@4.0.1': + dependencies: + minipass: 7.1.3 + '@istanbuljs/schema@0.1.3': {} '@jridgewell/resolve-uri@3.1.2': {} @@ -2975,6 +3303,18 @@ snapshots: '@koromix/koffi-win32-x64@3.3.8': optional: true + '@lezer/common@1.5.7': {} + + '@lezer/highlight@1.2.5': + dependencies: + '@lezer/common': 1.5.7 + + '@lezer/lr@1.4.13': + dependencies: + '@lezer/common': 1.5.7 + + '@marijn/find-cluster-break@1.0.4': {} + '@microsoft/tui-test-darwin-arm64@0.1.1': optional: true @@ -3008,6 +3348,8 @@ snapshots: '@microsoft/tui-test-linux-x64-musl': 0.1.1 '@microsoft/tui-test-win32-x64-msvc': 0.1.1 + '@msgpack/msgpack@2.8.0': {} + '@napi-rs/keyring-darwin-arm64@1.3.0': optional: true @@ -3476,6 +3818,12 @@ snapshots: transitivePeerDependencies: - supports-color + '@xterm/addon-fit@0.10.0(@xterm/xterm@5.5.0)': + dependencies: + '@xterm/xterm': 5.5.0 + + '@xterm/xterm@5.5.0': {} + ag-charts-types@14.3.0: {} ag-grid-community@36.3.0: @@ -3620,8 +3968,12 @@ snapshots: dependencies: readdirp: 5.1.1 + chownr@3.0.0: {} + ci-info@4.5.0: {} + classnames@2.5.1: {} + cli-cursor@5.0.0: dependencies: restore-cursor: 5.1.0 @@ -3642,8 +3994,25 @@ snapshots: strip-ansi: 7.2.0 wrap-ansi: 9.0.2 + clsx@2.1.1: {} + cockatiel@3.2.1: {} + codemirror-lang-r@0.1.1: + dependencies: + '@codemirror/language': 6.13.1 + lezer-r: 0.1.3 + + codemirror@6.0.2: + dependencies: + '@codemirror/autocomplete': 6.20.4 + '@codemirror/commands': 6.11.2 + '@codemirror/language': 6.13.1 + '@codemirror/lint': 6.9.8 + '@codemirror/search': 6.7.3 + '@codemirror/state': 6.7.6 + '@codemirror/view': 6.44.2 + color-convert@2.0.1: dependencies: color-name: 1.1.4 @@ -3658,6 +4027,8 @@ snapshots: core-util-is@1.0.3: {} + crelt@1.0.7: {} + cross-keychain@1.1.0(@types/node@22.20.5): dependencies: '@inquirer/prompts': 7.10.1(@types/node@22.20.5) @@ -3712,6 +4083,8 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 + detect-libc@2.1.2: {} + diff@7.0.0: {} diff@9.0.0: {} @@ -3856,6 +4229,9 @@ snapshots: cross-spawn: 7.0.6 signal-exit: 4.1.0 + fsevents@2.3.3: + optional: true + function-bind@1.1.2: {} get-caller-file@2.0.5: {} @@ -4060,6 +4436,8 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 + js-tokens@4.0.0: {} + js-yaml@4.3.2: dependencies: argparse: 2.0.1 @@ -4126,10 +4504,64 @@ snapshots: '@koromix/koffi-win32-ia32': 3.3.8 '@koromix/koffi-win32-x64': 3.3.8 + lezer-r@0.1.3: + dependencies: + '@lezer/highlight': 1.2.5 + '@lezer/lr': 1.4.13 + lie@3.3.0: dependencies: immediate: 3.0.6 + lightningcss-android-arm64@1.33.0: + optional: true + + lightningcss-darwin-arm64@1.33.0: + optional: true + + lightningcss-darwin-x64@1.33.0: + optional: true + + lightningcss-freebsd-x64@1.33.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + + lightningcss-linux-arm64-musl@1.33.0: + optional: true + + lightningcss-linux-x64-gnu@1.33.0: + optional: true + + lightningcss-linux-x64-musl@1.33.0: + optional: true + + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + + lightningcss-win32-x64-msvc@1.33.0: + optional: true + + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.33.0 + lightningcss-darwin-arm64: 1.33.0 + lightningcss-darwin-x64: 1.33.0 + lightningcss-freebsd-x64: 1.33.0 + lightningcss-linux-arm-gnueabihf: 1.33.0 + lightningcss-linux-arm64-gnu: 1.33.0 + lightningcss-linux-arm64-musl: 1.33.0 + lightningcss-linux-x64-gnu: 1.33.0 + lightningcss-linux-x64-musl: 1.33.0 + lightningcss-win32-arm64-msvc: 1.33.0 + lightningcss-win32-x64-msvc: 1.33.0 + locate-path@6.0.0: dependencies: p-locate: 5.0.0 @@ -4158,6 +4590,10 @@ snapshots: chalk: 5.6.2 is-unicode-supported: 1.3.0 + loose-envify@1.4.0: + dependencies: + js-tokens: 4.0.0 + lru-cache@10.4.3: {} lru-cache@11.5.3: {} @@ -4190,6 +4626,10 @@ snapshots: minipass@7.1.3: {} + minizlib@3.1.0: + dependencies: + minipass: 7.1.3 + mocha@11.8.0: dependencies: browser-stdout: 1.3.1 @@ -4248,6 +4688,8 @@ snapshots: dependencies: boolbase: 1.0.0 + object-assign@4.1.1: {} + object-inspect@1.13.4: {} object-keys@1.1.1: {} @@ -4358,6 +4800,8 @@ snapshots: pako@1.0.11: {} + pako@2.2.0: {} + parse-ms@4.0.0: {} parse5-htmlparser2-tree-adapter@7.1.0: @@ -4407,6 +4851,12 @@ snapshots: process-nextick-args@2.0.1: {} + prop-types@15.8.1: + dependencies: + loose-envify: 1.4.0 + object-assign: 4.1.1 + react-is: 16.13.1 + proper-lockfile@4.1.2: dependencies: graceful-fs: 4.2.11 @@ -4418,6 +4868,40 @@ snapshots: es-define-property: 1.0.1 side-channel: 1.1.1 + react-accessible-treeview@2.11.2(classnames@2.5.1)(prop-types@15.8.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + classnames: 2.5.1 + prop-types: 15.8.1 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + + react-data-grid@7.0.0-beta.44(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + clsx: 2.1.1 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + + react-dom@18.3.1(react@18.3.1): + dependencies: + loose-envify: 1.4.0 + react: 18.3.1 + scheduler: 0.23.2 + + react-icons@4.12.0(react@18.3.1): + dependencies: + react: 18.3.1 + + react-is@16.13.1: {} + + react-resizable-panels@2.1.9(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + + react@18.3.1: + dependencies: + loose-envify: 1.4.0 + read@1.0.7: dependencies: mute-stream: 0.0.8 @@ -4453,6 +4937,10 @@ snapshots: sax@1.6.1: {} + scheduler@0.23.2: + dependencies: + loose-envify: 1.4.0 + semver@7.7.4: {} semver@7.8.5: {} @@ -4555,6 +5043,8 @@ snapshots: dependencies: boundary: 2.0.0 + style-mod@4.1.5: {} + supports-color@10.2.2: {} supports-color@7.2.0: @@ -4567,6 +5057,14 @@ snapshots: tapable@2.3.3: {} + tar@7.5.24: + dependencies: + '@isaacs/fs-minipass': 4.0.1 + chownr: 3.0.0 + minipass: 7.1.3 + minizlib: 3.1.0 + yallist: 5.0.0 + test-exclude@8.0.0: dependencies: '@istanbuljs/schema': 0.1.3 @@ -4586,6 +5084,12 @@ snapshots: tslib@2.8.1: {} + tsx@4.23.15: + dependencies: + esbuild: 0.28.2 + optionalDependencies: + fsevents: 2.3.3 + tunnel@0.0.6: {} type-detect@4.0.8: {} @@ -4661,6 +5165,35 @@ snapshots: vscode-languageserver-types@3.18.5: {} + w3c-keyname@2.2.8: {} + + webr@0.6.1: + dependencies: + '@codemirror/autocomplete': 6.20.4 + '@codemirror/commands': 6.11.2 + '@codemirror/state': 6.7.6 + '@codemirror/view': 6.44.2 + '@msgpack/msgpack': 2.8.0 + '@xterm/addon-fit': 0.10.0(@xterm/xterm@5.5.0) + '@xterm/xterm': 5.5.0 + classnames: 2.5.1 + codemirror: 6.0.2 + codemirror-lang-r: 0.1.1 + jszip: 3.10.1 + lezer-r: 0.1.3 + lightningcss: 1.33.0 + pako: 2.2.0 + prop-types: 15.8.1 + react: 18.3.1 + react-accessible-treeview: 2.11.2(classnames@2.5.1)(prop-types@15.8.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + react-data-grid: 7.0.0-beta.44(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + react-dom: 18.3.1(react@18.3.1) + react-icons: 4.12.0(react@18.3.1) + react-resizable-panels: 2.1.9(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + tsx: 4.23.15 + xmlhttprequest-ssl: 2.1.2 + xterm-readline: 1.3.1(@xterm/xterm@5.5.0) + whatwg-encoding@3.1.1: dependencies: iconv-lite: 0.6.3 @@ -4701,6 +5234,8 @@ snapshots: string-width: 7.2.0 strip-ansi: 7.2.0 + ws@8.23.0: {} + wsl-utils@1.0.1: dependencies: is-wsl: 3.1.1 @@ -4713,10 +5248,19 @@ snapshots: xmlbuilder@11.0.1: {} + xmlhttprequest-ssl@2.1.2: {} + + xterm-readline@1.3.1(@xterm/xterm@5.5.0): + dependencies: + '@xterm/xterm': 5.5.0 + string-width: 4.2.3 + y18n@5.0.8: {} yallist@4.0.0: {} + yallist@5.0.0: {} + yargs-parser@21.1.1: {} yargs-parser@22.0.0: {} diff --git a/scripts/test-activation.cjs b/scripts/test-activation.cjs index 5f99fdc83..7137d8675 100644 --- a/scripts/test-activation.cjs +++ b/scripts/test-activation.cjs @@ -190,6 +190,21 @@ exports.run = async (api) => { probeLanguageServer(root, 'ps::ps_suspend(server)'); break; } + case 'webr-language': { + const definition = await vscode.workspace.openTextDocument({language:'r', content:'double_it <- function(x) x * 2\n'}); + const caller = await vscode.workspace.openTextDocument({language:'r', content:'answer <- double_it(21)\n'}); + await vscode.window.showTextDocument(caller); + const symbols = () => vscode.commands.executeCommand('vscode.executeDocumentSymbolProvider', definition.uri); + await until(async () => (await symbols())?.some(symbol => symbol.name === 'double_it'), + 'The webR language server did not publish an outline', 180000); + const target = await vscode.commands.executeCommand('vscode.executeDefinitionProvider', caller.uri, new vscode.Position(0, 14)); + assert.ok(target.some(location => (location.uri ?? location.targetUri).toString() === definition.uri.toString())); + const edits = new vscode.WorkspaceEdit(); + edits.replace(definition.uri, new vscode.Range(0, 0, 0, 9), 'triple_it'); + assert.ok(await vscode.workspace.applyEdit(edits)); + await until(async () => (await symbols())?.some(symbol => symbol.name === 'triple_it'), 'Outline did not update'); + break; + } case 'no-folder': assert.equal(vscode.workspace.workspaceFolders, undefined); break; @@ -470,7 +485,7 @@ async function main() { const { spawnSync } = require('node:child_process'); const executable = process.env.VSCR_ACTIVATION_VSCODE || await downloadAndUnzipVSCode(); const selected = process.env.VSCR_ACTIVATION_CASES?.split(',') || cases; - selected.forEach((testCase) => assert.ok(cases.includes(testCase), `Unknown case: ${testCase}`)); + selected.forEach((testCase) => assert.ok(cases.includes(testCase) || testCase === 'webr-language', `Unknown case: ${testCase}`)); for (const prefix of ['interactive-', 'interactive-background-', 'terminal-revive-']) { if (selected.includes(`${prefix}restore`)) { assert.ok(selected.includes(`${prefix}create`), 'Restore requires its create stage in the same run'); @@ -542,7 +557,9 @@ exports.activate = async () => { fs.mkdirSync(workspace, { recursive: true }); fs.mkdirSync(path.join(profile, 'User'), { recursive: true }); fs.writeFileSync(path.join(profile, 'User', 'settings.json'), JSON.stringify({ - 'r.lsp.enabled': lspShutdown, 'r.sessionWatcher': persistentTerminal, 'r.plot.backend': revive ? 'standard' : 'native', + 'r.lsp.enabled': lspShutdown || testCase === 'webr-language', + ...(testCase === 'webr-language' ? { 'r.executablePath': path.join(caseRoot, 'missing-R') } : {}), + 'r.sessionWatcher': persistentTerminal, 'r.plot.backend': revive ? 'standard' : 'native', ...(lspShutdown ? { 'r.lsp.use_stdio': false, 'r.lsp.args': ['-e', "saveRDS(list(pid=Sys.getpid(), time=ps::ps_create_time()), file.path(Sys.getenv('VSCR_ACTIVATION_ROOT'), 'lsp-process.rds'))"] } : {}), 'r.interactive.restore': false, 'r.interactive.storagePath': path.join(caseRoot, 'sessions'), diff --git a/src/helpViewer/index.ts b/src/helpViewer/index.ts index c9cba0d53..33e2ffa34 100644 --- a/src/helpViewer/index.ts +++ b/src/helpViewer/index.ts @@ -45,7 +45,7 @@ export async function initializeHelp( void vscode.commands.executeCommand('setContext', 'r.helpViewer.show', true); // get the "vanilla" R path from config - const rPath = await getRpath(); + const rPath = await getRpath(false, undefined, false); if (!rPath) { return undefined; } diff --git a/src/languageServerClient.ts b/src/languageServerClient.ts index e34eb8c60..c6697297a 100644 --- a/src/languageServerClient.ts +++ b/src/languageServerClient.ts @@ -217,6 +217,10 @@ export class CancellableLanguageClient extends LanguageClient { return child; } + ownResource(release: () => void): void { + this.resources?.own(release); + } + ownSocket(socket: Socket): void { this.resources?.own(() => socket.destroy()); } diff --git a/src/languageService.ts b/src/languageService.ts index 46332603f..19aece9b7 100644 --- a/src/languageService.ts +++ b/src/languageService.ts @@ -40,6 +40,10 @@ import { completionMiddleware } from './completionMiddleware'; import { connectTcpLanguageServer } from './languageServerTransport'; import { CancellableLanguageClient } from './languageServerClient'; import { withRpcCancellation } from './nativeRpc'; +import { prepareNodeWebR } from './webr/nodeRuntime'; +import { cachedWebRAssets } from './webr/assetCache'; +import { createWebRLanguageSession } from './webr/languageSession'; +import { createWebRMessageTransports } from './webr/messageTransports'; export class LanguageService implements Disposable { private readonly clients: Map = new Map(); @@ -49,7 +53,7 @@ export class LanguageService implements Disposable { private readonly sessionSignatures = new SessionSignatureHelpProvider(); private readonly clientUpdates = new Map>(); private readonly listeners: Disposable[] = []; - private readonly startup: Promise; + private startup: Promise; private readonly startupCancellation = new AbortController(); private readonly startingClients = new Set(); private readonly stoppingClients = new Set>(); @@ -59,9 +63,85 @@ export class LanguageService implements Disposable { constructor() { this.outputChannel = window.createOutputChannel('R Language Server', { log: true }); this.config = workspace.getConfiguration('r'); - this.startup = this.startLanguageService().catch((error: unknown) => { - this.outputChannel.appendLine(`Failed to start language server: ${String(error)}`); - }); + this.startup = this.startWithRetry(); + } + + private async startWithRetry(): Promise { + try { + await this.startLanguageService(); + } catch (error) { + const retry = this.disposed ? '' : ' Open an R document to retry.'; + this.outputChannel.appendLine( + `Failed to start language server: ${String(error)}.${retry}`, + ); + if (this.disposed) { + return; + } + const nextDocument = workspace.onDidOpenTextDocument((doc) => { + if (doc.languageId === 'r' || doc.languageId === 'rmd') { + nextDocument.dispose(); + this.startup = this.startWithRetry(); + } + }); + this.listeners.push(nextDocument); + } + } + + /** Retry the same client so it re-registers its providers and reopens current buffers. */ + private offerWebRRetry(client: CancellableLanguageClient, reason: string): void { + const key = [...this.clients].find(([, active]) => active === client)?.[0]; + if (!key || this.disposed || client.isRunning()) { + return; + } + client.cancelStartup(); + const generation = client.startupSignal; + let attempted = false; + let nextDocument: Disposable | undefined; + const retry = async () => { + if (attempted) { + return; + } + attempted = true; + nextDocument?.dispose(); + if ( + this.disposed || + this.clients.get(key) !== client || + client.startupSignal !== generation || + client.isRunning() || + this.initSet.has(key) + ) { + return; + } + this.startingClients.add(client); + try { + await client.start(); + } catch (error) { + this.offerWebRRetry(client, String(error)); + } finally { + this.startingClients.delete(client); + } + }; + // Per-resource clients already retry on document open. The global client + // stays registered with the service even when its connection has closed. + if (key === 'global') { + nextDocument = workspace.onDidOpenTextDocument((doc) => { + if (doc.languageId === 'r' || doc.languageId === 'rmd') { + void retry(); + } + }); + this.listeners.push(nextDocument); + } + this.outputChannel.appendLine(`The webR language server stopped: ${reason}`); + void window + .showErrorMessage( + 'The webR language server stopped. Restart it for open R documents?', + 'Retry', + ) + .then((action) => { + if (action === 'Retry') { + void retry(); + } + }); } dispose(): Promise { @@ -162,16 +242,20 @@ export class LanguageService implements Disposable { const resourceConfig = config(resource); const debug = this.config.get('lsp.debug'); const useRenvLibPath = this.config.get('useRenvLibPath') ?? false; + const policy = resourceConfig.get('lsp.runtime', 'auto'); const rPath = - target?.rPath || - (await withRpcCancellation( - () => getRpath(false, resource), - this.startupCancellation.signal, - )); + policy === 'webR' + ? '' + : target?.rPath || + (await withRpcCancellation( + () => getRpath(false, resource, policy === 'native'), + this.startupCancellation.signal, + )) || + ''; if (this.disposed) { throw new Error('The R language service is shutting down.'); } - if (!rPath) { + if (!rPath && policy === 'native') { this.outputChannel.appendLine( `Skipping the R language server in ${cwd} because no R executable was found.`, ); @@ -225,34 +309,36 @@ export class LanguageService implements Disposable { return transport; }; - const fileWatcher = workspace.createFileSystemWatcher('**/*.{R,r}'); + const fileWatcher = rPath ? workspace.createFileSystemWatcher('**/*.{R,r}') : undefined; // Options to control the language client const clientOptions: LanguageClientOptions = { // Register the server for selected R documents documentSelector: selector, - uriConverters: { - // VS Code by default %-encodes even the colon after the drive letter - // NodeJS handles it much better - // languageserver interprets vscode-notebook-cell paths as real files. - // Unsaved Interactive notebooks have no such file; namespace linters - // call normalizePath even with lint_cache disabled. Use an opaque - // scheme so the server lints the text like an unsaved input document. - // Preserve the full path/fragment and translate every result back. - code2Protocol: (uri) => - new URL( - (uri.scheme === 'vscode-notebook-cell' && pathlessNotebook - ? uri.with({ scheme: 'vscode-r-cell' }) - : uri - ).toString(true), - ).toString(), - protocol2Code: (str) => { - const uri = Uri.parse(str); - return uri.scheme === 'vscode-r-cell' - ? uri.with({ scheme: 'vscode-notebook-cell' }) - : uri; - }, - }, + uriConverters: !rPath + ? undefined + : { + // VS Code by default %-encodes even the colon after the drive letter + // NodeJS handles it much better + // languageserver interprets vscode-notebook-cell paths as real files. + // Unsaved Interactive notebooks have no such file; namespace linters + // call normalizePath even with lint_cache disabled. Use an opaque + // scheme so the server lints the text like an unsaved input document. + // Preserve the full path/fragment and translate every result back. + code2Protocol: (uri) => + new URL( + (uri.scheme === 'vscode-notebook-cell' && pathlessNotebook + ? uri.with({ scheme: 'vscode-r-cell' }) + : uri + ).toString(true), + ).toString(), + protocol2Code: (str) => { + const uri = Uri.parse(str); + return uri.scheme === 'vscode-r-cell' + ? uri.with({ scheme: 'vscode-notebook-cell' }) + : uri; + }, + }, workspaceFolder: workspaceFolder, outputChannel: this.outputChannel, synchronize: { @@ -319,15 +405,46 @@ export class LanguageService implements Disposable { }; }, closed: () => { - return { - action: CloseAction.DoNotRestart, - }; + if (!rPath && !this.disposed && client.isRunning()) { + // The language client unregisters disconnected providers after + // this callback. Offer recovery once that cleanup has finished. + setTimeout( + () => this.offerWebRRetry(client, 'Worker connection closed.'), + 0, + ); + return { action: CloseAction.DoNotRestart, handled: true }; + } + return { action: CloseAction.DoNotRestart }; }, }, }; // Create the language client and start the client. - if (use_stdio && process.platform !== 'win32') { + if (!rPath) { + client = new CancellableLanguageClient( + 'r', + 'R Language Server (webR)', + async () => { + await this.waitForRDocument(client.startupSignal); + const baseUrl = await withRpcCancellation( + () => prepareNodeWebR(extensionContext.globalStorageUri.fsPath), + client.startupSignal, + ); + this.outputChannel.appendLine( + 'Starting the webR language server for open documents.', + ); + const session = await createWebRLanguageSession({ + baseUrl, + signal: client.startupSignal, + loadAsset: cachedWebRAssets(extensionContext), + }); + client.ownResource(() => session.close()); + return createWebRMessageTransports(session); + }, + clientOptions, + this.startupCancellation.signal, + ); + } else if (use_stdio && process.platform !== 'win32') { client = new CancellableLanguageClient( 'r', 'R Language Server', @@ -351,10 +468,13 @@ export class LanguageService implements Disposable { if (this.disposed) { throw new Error('The R language service is shutting down.'); } - extensionContext.subscriptions.push(client, fileWatcher); + extensionContext.subscriptions.push(client); + if (fileWatcher) { + extensionContext.subscriptions.push(fileWatcher); + } return client; } catch (error) { - fileWatcher.dispose(); + fileWatcher?.dispose(); await client.dispose(); throw error; } finally { @@ -362,6 +482,31 @@ export class LanguageService implements Disposable { } } + private async waitForRDocument(signal: AbortSignal): Promise { + const isR = (doc: TextDocument) => doc.languageId === 'r' || doc.languageId === 'rmd'; + if (workspace.textDocuments.some(isR)) { + return; + } + signal.throwIfAborted(); + await new Promise((resolve, reject) => { + const listener = workspace.onDidOpenTextDocument((doc) => { + if (isR(doc)) { + cleanup(); + resolve(); + } + }); + const cancel = () => { + cleanup(); + reject(signal.reason); + }; + const cleanup = () => { + listener.dispose(); + signal.removeEventListener('abort', cancel); + }; + signal.addEventListener('abort', cancel, { once: true }); + }); + } + private checkClient(name: string): boolean { if (this.initSet.has(name)) { return true; diff --git a/src/test/node/webRNodeRuntime.test.ts b/src/test/node/webRNodeRuntime.test.ts new file mode 100644 index 000000000..6729677f2 --- /dev/null +++ b/src/test/node/webRNodeRuntime.test.ts @@ -0,0 +1,87 @@ +import * as assert from 'node:assert/strict'; +import { cp, mkdtemp, mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import { prepareNodeWebR } from '../../webr/nodeRuntime'; + +suite('cached webR Node worker', function () { + this.timeout(60000); + test('runs from an escaped host path, mounts project files, and recovers incomplete generations', async () => { + const root = await mkdtemp(path.join(os.tmpdir(), 'webR # 100% ')); + let installs = 0; + const unpack = async (directory: string) => { + installs++; + await cp(path.dirname(require.resolve('webr')), directory, { recursive: true }); + }; + try { + const [first, second] = await Promise.all([ + prepareNodeWebR(root, unpack), + prepareNodeWebR(root, unpack), + ]); + assert.equal(first, second); + assert.equal(installs, 1); + const { WebR } = await import('webr'); + const runtime = new WebR({ baseUrl: first }); + try { + await runtime.init(); + const project = path.join(root, 'project #1 %22'); + await mkdir(project); + await writeFile(path.join(project, 'value.R'), 'value <- 21\n'); + await runtime.FS.mkdir('/project'); + await runtime.FS.mount('NODEFS', { root: project }, '/project'); + await runtime.evalRVoid( + 'setwd("/project"); source("value.R"); writeLines(as.character(value * 2), "result.txt")', + ); + assert.equal( + (await readFile(path.join(project, 'result.txt'), 'utf8')).trim(), + '42', + ); + if (process.platform === 'win32') { + const drive = path.parse(project).root; + const relative = path + .relative(drive, path.join(project, 'value.R')) + .split(path.sep) + .join('/'); + await runtime.FS.mkdir('/drive'); + await runtime.FS.mount('NODEFS', { root: drive }, '/drive'); + assert.equal( + new TextDecoder().decode(await runtime.FS.readFile('/drive/' + relative)), + 'value <- 21\n', + ); + } + } finally { + runtime.close(); + } + // Model a second extension host publishing after this installer sees + // a cache miss and before it renames its completed staging directory. + const competingRoot = path.join(root, 'other host'); + const competingDir = path.join(competingRoot, 'runtimes', path.basename(first)); + const raced = await prepareNodeWebR(competingRoot, async (stage) => { + await cp(path.dirname(require.resolve('webr')), stage, { recursive: true }); + await cp(first, competingDir, { recursive: true }); + }); + assert.equal(raced, competingDir + path.sep); + assert.deepEqual(await readdir(path.dirname(competingDir)), [path.basename(first)]); + await rm(path.join(first, 'R.wasm')); + const repaired = await prepareNodeWebR(root, unpack); + assert.notEqual(repaired, first); + assert.equal(installs, 2); + // A damaged binary can have the original length and marker. + const binary = await readFile(path.join(repaired, 'R.wasm')); + const damaged = Buffer.from(binary); + damaged[damaged.length - 1] ^= 1; + await writeFile(path.join(repaired, 'R.wasm'), damaged); + const valid = await prepareNodeWebR(root, unpack); + assert.notEqual(valid, repaired); + assert.ok((await readFile(path.join(valid, 'R.wasm'))).equals(binary)); + assert.equal(installs, 3); + await rm(path.join(valid, '.complete')); + const fourth = await prepareNodeWebR(root, unpack); + assert.notEqual(fourth, valid); + assert.equal(await prepareNodeWebR(root, unpack), fourth); + assert.equal(installs, 4); + } finally { + await rm(root, { recursive: true, force: true }); + } + }); +}); diff --git a/src/test/node/webRTransport.test.ts b/src/test/node/webRTransport.test.ts new file mode 100644 index 000000000..094c05a03 --- /dev/null +++ b/src/test/node/webRTransport.test.ts @@ -0,0 +1,84 @@ +import * as assert from 'node:assert/strict'; +import 'vscode-jsonrpc/node'; +import { createWebRMessageTransports } from '../../webr/messageTransports'; + +suite('webR language transport', () => { + test('preserves message order and closes a worker exactly once', async () => { + const received: string[] = []; + let release!: () => void; + const gate = new Promise((resolve) => { + release = resolve; + }); + let calls = 0; + let closes = 0; + const { reader, writer } = createWebRMessageTransports({ + async dispatch(message) { + if (++calls === 1) { + await gate; + } + return [message]; + }, + close() { + closes++; + }, + }); + let delivered!: () => void; + const both = new Promise((resolve) => { + delivered = resolve; + }); + reader.listen((message) => { + received.push(JSON.stringify(message)); + if (received.length === 2) { + delivered(); + } + }); + const first = { jsonrpc: '2.0', id: 1, method: 'initialize' }; + const second = { jsonrpc: '2.0', id: 2, method: 'shutdown' }; + const writes = Promise.all([writer.write(first), writer.write(second)]); + await writes; + release(); + await both; + assert.deepEqual(received, [JSON.stringify(first), JSON.stringify(second)]); + writer.end(); + reader.dispose(); + writer.dispose(); + assert.equal(closes, 1); + }); + + test('cancels queued requests without evaluating their R code', async () => { + let release!: () => void; + const gate = new Promise((resolve) => { + release = resolve; + }); + const executed: string[] = []; + const responses: string[] = []; + const { reader, writer } = createWebRMessageTransports({ + async dispatch(message) { + executed.push(JSON.stringify(message)); + await gate; + return []; + }, + close() {}, + }); + reader.listen((reply) => responses.push(JSON.stringify(reply))); + const first = { jsonrpc: '2.0', id: 1, method: 'textDocument/hover' }; + const next = { ...first, id: 2 }; + const cancel = { jsonrpc: '2.0', method: '$/cancelRequest', params: { id: 2 } }; + const writes = Promise.all([writer.write(first), writer.write(next)]); + await writes; + await writer.write(cancel); + release(); + await writer.write({ jsonrpc: '2.0', method: 'exit' } as typeof first); + assert.deepEqual(executed, [ + JSON.stringify(first), + JSON.stringify({ jsonrpc: '2.0', method: 'exit' }), + ]); + assert.deepEqual(JSON.parse(responses[0]) as unknown, { + jsonrpc: '2.0', + id: 2, + error: { code: -32800, message: 'Request cancelled' }, + }); + reader.dispose(); + writer.dispose(); + }); +}); diff --git a/src/test/suite/languageService.test.ts b/src/test/suite/languageService.test.ts index a3f14dde3..de08511f5 100644 --- a/src/test/suite/languageService.test.ts +++ b/src/test/suite/languageService.test.ts @@ -19,6 +19,9 @@ import { LanguageService } from '../../languageService'; import { connectTcpLanguageServer } from '../../languageServerTransport'; import { CancellableLanguageClient } from '../../languageServerClient'; import * as util from '../../util'; +import * as webRNode from '../../webr/nodeRuntime'; +import * as webRLanguage from '../../webr/languageSession'; +import { Message } from 'vscode-jsonrpc'; import { mockExtensionContext } from '../common/mockvscode'; import { deferred } from '../common/sessionConnections'; @@ -48,10 +51,10 @@ suite('Language service startup lifecycle', () => { }); teardown(() => sandbox.restore()); - test('missing R skips the global client and keeps session document listeners', async () => { + test('missing native R skips the global client and keeps session document listeners', async () => { mockExtensionContext(path.resolve(__dirname, '../../..'), sandbox); (vscode.workspace.getConfiguration as sinon.SinonStub).returns({ - get: () => undefined, + get: (key: string) => (key === 'lsp.runtime' ? 'native' : undefined), } as unknown as vscode.WorkspaceConfiguration); sandbox.stub(util, 'getRpath').resolves(''); const watcher = sandbox.stub(vscode.workspace, 'createFileSystemWatcher').throws(); @@ -408,6 +411,64 @@ suite('Language service initialization cancellation', () => { } }); + test('Retry recovers an initialized webR connection without restarting the extension', async () => { + (util.getRpath as sinon.SinonStub).resolves(undefined); + sandbox.stub(webRNode, 'prepareNodeWebR').resolves(directory); + let generation = 0; + sandbox.stub(webRLanguage, 'createWebRLanguageSession').callsFake(() => { + const instance = ++generation; + return Promise.resolve({ + dispatch(message) { + if (!Message.isRequest(message)) { + return Promise.resolve([]); + } + if (message.method === 'test/crash') { + return Promise.reject(new Error('worker stopped')); + } + const result = + message.method === 'initialize' + ? { capabilities: {} } + : message.method === 'shutdown' + ? null + : instance; + return Promise.resolve([{ jsonrpc: '2.0', id: message.id, result }]); + }, + close() {}, + }); + }); + let answer: ((choice: string) => void) | undefined; + (vscode.window.showErrorMessage as sinon.SinonStub).callsFake((message: string) => { + if (!message.includes('Restart it for open R documents')) { + return Promise.resolve(undefined); + } + return new Promise((resolve) => { + answer = resolve; + }); + }); + await vscode.workspace.openTextDocument({ language: 'r', content: 'x <- 1' }); + service = new LanguageService(); + const state = service as unknown as { + clients: Map; + startup: Promise; + }; + await state.startup; + const client = state.clients.get('global')!; + assert.equal(await client.sendRequest('test/generation'), 1); + await assert.rejects(client.sendRequest('test/crash')); + await waitFor(() => answer !== undefined); + answer!('Retry'); + await waitFor(() => generation === 2 && client.isRunning()); + assert.equal(await client.sendRequest('test/generation'), 2); + answer = undefined; + await assert.rejects(client.sendRequest('test/crash')); + await waitFor(() => answer !== undefined); + await service.dispose(); + service = undefined; + (answer as unknown as (choice: string) => void)('Retry'); + await new Promise((resolve) => setTimeout(resolve, 0)); + assert.equal(generation, 2, 'A retired client must not restart'); + }); + async function waitFor(predicate: () => boolean): Promise { const deadline = Date.now() + 5000; while (!predicate()) { diff --git a/src/util.ts b/src/util.ts index 0535d501f..e3ebcc415 100644 --- a/src/util.ts +++ b/src/util.ts @@ -84,7 +84,11 @@ export function getRPathConfigEntry(term: boolean = false): string { let pendingMissingRMessage: Promise | undefined; -export async function getRpath(quote = false, resource?: vscode.Uri): Promise { +export async function getRpath( + quote = false, + resource?: vscode.Uri, + warnIfMissing = true, +): Promise { const configEntry = getRPathConfigEntry(); const resolution = await resolveBackgroundR( getRPathResolverDependencies(resource), @@ -92,7 +96,7 @@ export async function getRpath(quote = false, resource?: vscode.Uri): Promise { pendingMissingRMessage = undefined; }; diff --git a/src/webr/assetCache.ts b/src/webr/assetCache.ts new file mode 100644 index 000000000..e9824f5fe --- /dev/null +++ b/src/webr/assetCache.ts @@ -0,0 +1,34 @@ +import { type ExtensionContext, Uri, workspace } from 'vscode'; +import { downloadWebRAsset, hasExpectedDigest, LoadWebRAsset } from './assets'; + +/** The digest is also the cache key, so different server versions can coexist. */ +export function cachedWebRAssets(context: ExtensionContext): LoadWebRAsset { + const root = Uri.joinPath(context.globalStorageUri, 'webr-packages'); + return async (asset, signal) => { + if (asset.bundledPath) { + const uri = Uri.joinPath(context.extensionUri, asset.bundledPath); + const bytes = new Uint8Array(await workspace.fs.readFile(uri)); + if (!(await hasExpectedDigest(bytes, asset.sha256))) { + throw new Error(`Invalid checksum for bundled webR dependency ${asset.name}`); + } + return bytes; + } + const file = Uri.joinPath(root, asset.sha256); + try { + const bytes = new Uint8Array(await workspace.fs.readFile(file)); + if (await hasExpectedDigest(bytes, asset.sha256)) { + return bytes; + } + } catch { + // Remote and browser providers can discard cached assets. + } + const bytes = await downloadWebRAsset(asset, signal); + try { + await workspace.fs.createDirectory(root); + await workspace.fs.writeFile(file, bytes); + } catch { + // A full or read-only cache still permits the current session. + } + return bytes; + }; +} diff --git a/src/webr/assets.ts b/src/webr/assets.ts new file mode 100644 index 000000000..d325079b3 --- /dev/null +++ b/src/webr/assets.ts @@ -0,0 +1,31 @@ +export interface WebRAsset { + name: string; + url: string; + sha256: string; + bundledPath?: string; +} + +export type LoadWebRAsset = ( + asset: WebRAsset, + signal?: AbortSignal, +) => Promise>; + +export async function hasExpectedDigest( + bytes: Uint8Array, + expected: string, +): Promise { + const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', bytes)); + return Array.from(digest, (octet) => octet.toString(16).padStart(2, '0')).join('') === expected; +} + +export const downloadWebRAsset: LoadWebRAsset = async (asset, signal) => { + const response = await fetch(asset.url, { signal }); + if (!response.ok) { + throw new Error(`Cannot download ${asset.name}: HTTP ${response.status} from ${asset.url}`); + } + const bytes = new Uint8Array(await response.arrayBuffer()); + if (!(await hasExpectedDigest(bytes, asset.sha256))) { + throw new Error(`Invalid checksum for webR dependency ${asset.name}`); + } + return bytes; +}; diff --git a/src/webr/languageSession.ts b/src/webr/languageSession.ts new file mode 100644 index 000000000..78c80dc45 --- /dev/null +++ b/src/webr/languageSession.ts @@ -0,0 +1,85 @@ +import { WebR } from 'webr'; +import type { Message } from 'vscode-jsonrpc'; +import { downloadWebRAsset, type LoadWebRAsset } from './assets'; +import packages from './packages.json'; +import serverModules from './serverModules.json'; + +export interface WebRLanguageSession { + dispatch(message: Message): Promise; + close(): void; +} + +/** A language worker has its own package library and never shares the user's evaluation session. */ +export async function createWebRLanguageSession(options: { + baseUrl: string; + signal?: AbortSignal; + loadAsset?: LoadWebRAsset; +}): Promise { + const { signal, loadAsset = downloadWebRAsset } = options; + signal?.throwIfAborted(); + const runtime = new WebR({ baseUrl: options.baseUrl, interactive: false }); + const lifetime = new AbortController(); + const close = () => { + if (!lifetime.signal.aborted) { + lifetime.abort(); + runtime.close(); + } + }; + signal?.addEventListener('abort', close, { once: true }); + try { + await runtime.init(); + await runtime.FS.mkdir('/language-library'); + // Keep peak memory bounded while downloading packages concurrently. + for (let first = 0; first < packages.length; first += 4) { + const batch = await Promise.all( + packages.slice(first, first + 4).map(async (asset) => ({ + bytes: await loadAsset(asset, lifetime.signal), + })), + ); + for (const { bytes } of batch) { + await runtime.FS.writeFile('/tmp/pkg.tgz', bytes); + await runtime.evalRVoid( + 'utils::untar("/tmp/pkg.tgz", exdir = "/language-library", tar = "internal")', + ); + } + } + await runtime.FS.unlink('/tmp/pkg.tgz'); + await runtime.evalRVoid('.libPaths(c("/language-library", .libPaths()))'); + if ( + await runtime.evalRBoolean('"run_embedded" %in% getNamespaceExports("languageserver")') + ) { + await runtime.evalRVoid('server_api <- asNamespace("languageserver")'); + } else { + // Compatibility for the pinned 0.3.22 Wasm build, which predates run_embedded(). + await runtime.evalRVoid( + 'server_api <- new.env(parent = asNamespace("languageserver"))', + ); + for (const asset of serverModules) { + await runtime.FS.writeFile( + '/tmp/server.R', + await loadAsset(asset, lifetime.signal), + ); + await runtime.evalRVoid('sys.source("/tmp/server.R", envir = server_api)'); + } + } + await runtime.evalRVoid('dispatch_lsp <- server_api$run_embedded()'); + signal?.throwIfAborted(); + return { + async dispatch(message) { + const json = await runtime.evalRString( + 'as.character(jsonlite::toJSON(dispatch_lsp(packet), auto_unbox = FALSE))', + { + env: { packet: JSON.stringify(message) }, + }, + ); + return (JSON.parse(json) as string[]).map((reply) => JSON.parse(reply) as Message); + }, + close, + }; + } catch (error) { + close(); + throw error; + } finally { + signal?.removeEventListener('abort', close); + } +} diff --git a/src/webr/messageTransports.ts b/src/webr/messageTransports.ts new file mode 100644 index 000000000..c3295c644 --- /dev/null +++ b/src/webr/messageTransports.ts @@ -0,0 +1,104 @@ +import { AbstractMessageReader, AbstractMessageWriter, Emitter, Message } from 'vscode-jsonrpc'; +import type { DataCallback, MessageReader, MessageWriter } from 'vscode-jsonrpc'; +import type { WebRLanguageSession } from './languageSession'; + +/** The same decoded JSON-RPC transport is used by the browser and Node language clients. */ +export function createWebRMessageTransports(session: WebRLanguageSession): { + reader: MessageReader; + writer: MessageWriter; +} { + const messages = new Emitter(); + const requests = new Map(); + let queue = Promise.resolve(); + let closed = false; + function close() { + if (closed) { + return; + } + closed = true; + requests.clear(); + messages.dispose(); + session.close(); + } + const reader = new (class extends AbstractMessageReader { + disconnect() { + this.fireClose(); + close(); + } + listen(callback: DataCallback) { + return messages.event(callback); + } + override dispose() { + close(); + super.dispose(); + } + })(); + const writer = new (class extends AbstractMessageWriter { + write(message: Message): Promise { + if (closed) { + return Promise.reject(new Error('The webR language server has closed.')); + } + if (Message.isNotification(message) && message.method === '$/cancelRequest') { + const id = (message.params as { id?: number | string } | undefined)?.id; + const request = id === undefined ? undefined : requests.get(id); + if (request && !request.cancelled) { + request.cancelled = true; + const reply = { + jsonrpc: '2.0', + id, + error: { code: -32800, message: 'Request cancelled' }, + }; + messages.fire(reply); + } + return Promise.resolve(); + } + const id = Message.isRequest(message) ? message.id : null; + const request = { cancelled: false }; + if (id !== null) { + requests.set(id, request); + } + const dispatch = queue + .then(async () => { + if (closed || request.cancelled) { + return; + } + const replies = await session.dispatch(message); + if (!closed) { + for (const reply of replies) { + if ( + !request.cancelled || + !Message.isResponse(reply) || + reply.id !== id + ) { + messages.fire(reply); + } + } + } + }) + .finally(() => { + if (id !== null && requests.get(id) === request) { + requests.delete(id); + } + }); + queue = dispatch.catch((error: unknown) => { + if (!closed) { + this.fireError(error, message); + reader.disconnect(); + } + }); + // A request write acknowledges admission; cancellation can arrive while R is busy. + // Wait for exit itself so client disposal cannot close the worker before shutdown finishes. + return Message.isNotification(message) && message.method === 'exit' + ? dispatch + : Promise.resolve(); + } + end() { + void queue.then(close); + } + override dispose() { + close(); + super.dispose(); + } + })(); + return { reader, writer }; +} diff --git a/src/webr/nodeRuntime.ts b/src/webr/nodeRuntime.ts new file mode 100644 index 000000000..155f8b65b --- /dev/null +++ b/src/webr/nodeRuntime.ts @@ -0,0 +1,181 @@ +import { createHash } from 'node:crypto'; +import { createReadStream } from 'node:fs'; +import { lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises'; +import * as path from 'node:path'; +import { pipeline } from 'node:stream/promises'; +import { extract } from 'tar'; +import { WEBR_VERSION } from './runtime'; + +const integrity = + 'dOyIK2ul4zbtrbylcfSdgS8uC7vygr6f4uUbCVJaqpKaPlSNo2cr+cjjI1RgzrS5GSiwAmrmVSI++M8fTnQupg=='; +const cacheName = 'webr-' + WEBR_VERSION + '-node1'; +const downloads = new Map>(); +const assets = ['webr-worker.js', 'R.js', 'R.wasm', 'libRblas.so', 'libRlapack.so']; +class InvalidAsset extends Error {} + +/** Publish a complete runtime atomically so detached agents can reopen it after IDE updates. + * Offline tests can populate staging from the pinned npm distribution already on disk. + */ +export function prepareNodeWebR(root: string, unpack = download): Promise { + const directory = path.join(root, 'runtimes', cacheName); + const pending = downloads.get(directory); + if (pending) { + return pending; + } + const install = prepare(directory, unpack).finally(() => downloads.delete(directory)); + downloads.set(directory, install); + return install; +} + +async function download(stage: string): Promise { + const url = `https://registry.npmjs.org/webr/-/webr-${WEBR_VERSION}.tgz`; + const response = await fetch(url, { signal: AbortSignal.timeout(120000) }); + if (!response.ok) { + throw new Error(`Cannot download webR: HTTP ${response.status} from ${url}`); + } + const bytes = Buffer.from(await response.arrayBuffer()); + if (createHash('sha512').update(bytes).digest('base64') !== integrity) { + throw new Error('The downloaded webR archive failed its integrity check.'); + } + const archive = path.join(stage, 'runtime.tgz'); + await writeFile(archive, bytes); + await pipeline( + createReadStream(archive), + extract({ + cwd: stage, + strip: 2, + filter: (entry) => entry.startsWith('package/dist/'), + }), + ); + await rm(archive); +} + +async function prepareWorker(stage: string): Promise { + // webR 0.6.1 imports path.resolve(".../R.js") as an ESM specifier. Node treats + // a drive letter as a protocol and interprets # and % in unescaped filenames. + const file = path.join(stage, 'webr-worker.js'); + const worker = await readFile(file, 'utf8'); + const original = 'await import((await import("path")).default.resolve(e))'; + const portable = + 'await import((await import("node:url")).pathToFileURL((await import("node:path")).resolve(e)).href)'; + if (worker.split(original).length !== 2) { + throw new Error('The pinned webR Node loader has changed.'); + } + // The synchronous XMLHttpRequest shim invokes process.argv[0] in a child. + // Only this Wasm worker's children should inherit Electron's Node mode. + const bootstrap = 'if (process.versions.electron) process.env.ELECTRON_RUN_AS_NODE = "1";\n'; + await writeFile(file, bootstrap + worker.replace(original, portable)); +} + +/** Verify the runtime binaries and lazy VFS contents, including after an editor restart. */ +async function signature(directory: string): Promise { + const files = [...assets]; + async function walk(relative: string): Promise { + if (!(await lstat(path.join(directory, relative))).isDirectory()) { + throw new InvalidAsset('Invalid webR asset directory: ' + relative); + } + for (const entry of await readdir(path.join(directory, relative), { + withFileTypes: true, + })) { + const name = relative + '/' + entry.name; + if (entry.isDirectory()) { + await walk(name); + } else { + files.push(name); + } + } + } + await walk('vfs'); + const digest = createHash('sha256'); + for (const relative of files.sort()) { + const file = path.join(directory, relative); + const entry = await lstat(file); + if (!entry.isFile()) { + throw new InvalidAsset('Invalid webR asset: ' + relative); + } + digest.update(relative).update('\0').update(String(entry.size)).update('\0'); + for await (const bytes of createReadStream(file)) { + digest.update(bytes as Buffer); + } + } + return digest.digest('hex'); +} + +async function state(directory: string): Promise<'missing' | 'ready' | 'incomplete'> { + try { + if (!(await lstat(directory)).isDirectory()) { + return 'incomplete'; + } + } catch (error) { + if ((error as NodeJS.ErrnoException).code === 'ENOENT') { + return 'missing'; + } + throw error; + } + try { + const marker = await readFile(path.join(directory, '.complete'), 'utf8'); + if (/^[0-9a-f]{64}$/.test(marker) && marker === (await signature(directory))) { + return 'ready'; + } + } catch (error) { + if ( + !(error instanceof InvalidAsset) && + !['ENOENT', 'ENOTDIR', 'EISDIR'].includes((error as NodeJS.ErrnoException).code ?? '') + ) { + throw error; + } + } + return 'incomplete'; +} + +async function prepare( + directory: string, + unpack: (stage: string) => Promise, +): Promise { + await mkdir(path.dirname(directory), { recursive: true }); + let stage: string | undefined; + try { + for (let index = 0; ; index++) { + const target = index ? directory + '-' + index : directory; + const status = await state(target); + if (status === 'ready') { + return target + path.sep; + } + // An old worker may still use parts of this generation. Leave it in + // place and publish the repair at a fresh path. + if (status === 'incomplete') { + continue; + } + if (!stage) { + stage = await mkdtemp(directory + '-staging-'); + await unpack(stage); + await prepareWorker(stage); + await writeFile(path.join(stage, '.complete'), await signature(stage)); + } + try { + await rename(stage, target); + stage = undefined; + return target + path.sep; + } catch (error) { + if ( + !['EEXIST', 'ENOTEMPTY', 'EPERM', 'EACCES'].includes( + (error as NodeJS.ErrnoException).code ?? '', + ) + ) { + throw error; + } + const raced = await state(target); + if (raced === 'ready') { + return target + path.sep; + } + if (raced === 'missing') { + throw error; + } + } + } + } finally { + if (stage) { + await rm(stage, { recursive: true, force: true }); + } + } +} diff --git a/src/webr/packages.json b/src/webr/packages.json new file mode 100644 index 000000000..01a99a796 --- /dev/null +++ b/src/webr/packages.json @@ -0,0 +1,173 @@ +[ + { + "name": "R.cache", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/R.cache_0.17.0.tgz", + "sha256": "ba53cb4704e8298b69835f2d4965471bd5558b8a063b9a7af3f5791dede93a96" + }, + { + "name": "R.methodsS3", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/R.methodsS3_1.8.2.tgz", + "sha256": "b3d2d789f50fd72bb9a7074768d5dfa08f5c54bbe8e0b1cceac605cbd3de5e52" + }, + { + "name": "R.oo", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/R.oo_1.27.1.tgz", + "sha256": "791826747b52bd1ad1548531df858e77ec5e1bbe7eb1077dd82b0e24e7700381" + }, + { + "name": "R.utils", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/R.utils_2.13.0.tgz", + "sha256": "249d0ab8c8df3134860f837385424443e6736b100dc57b52521ff7b7881ba676" + }, + { + "name": "R6", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/R6_2.6.1.tgz", + "sha256": "134d30277b1c64afe9ae31a4a52857822bc21d32db46479eb3ea2f3a7397c8d6" + }, + { + "name": "callr", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/callr_3.8.0.tgz", + "sha256": "c4093fa70e16cb0b067ba95faef423a8ae4068fcc6d764fe74f537216eb93482" + }, + { + "name": "cli", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/cli_3.6.6.tgz", + "sha256": "efa9c2b12c2da09cccb0a27d2e7a079ebd4c38fc1d03560d599f7634eb7f9932" + }, + { + "name": "codetools", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/codetools_0.2-20.tgz", + "sha256": "36b3c58993dffe36937ff8470b2d185f9f6588412605ca0709fc95d970ce5014" + }, + { + "name": "collections", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/collections_0.3.12.tgz", + "sha256": "35f265a5d51ed2e21310a5b1807c89032b27a815cf70af1030878dcac499d0d0" + }, + { + "name": "digest", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/digest_0.6.39.tgz", + "sha256": "0531577e58efa9e61aeb4505c31766c53507d7bb59db9c4ce0ed2e7e9e862d07" + }, + { + "name": "evaluate", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/evaluate_1.0.5.tgz", + "sha256": "78e951393968c4d2298d9ea380bb06ab31f037dc9eaf74fac9b59a77c3801c3c" + }, + { + "name": "fs", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/fs_2.1.0.tgz", + "sha256": "c5c986963981c09e40a50cd4ff3b1cc98f2f7758880f7fcc91a71855a96c9d9b" + }, + { + "name": "glue", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/glue_1.8.1.tgz", + "sha256": "3b025aa5fd067ad9b87fecd219e561d4537d488b33581af8beabe2b06024d44d" + }, + { + "name": "highr", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/highr_0.12.tgz", + "sha256": "007f33651dca953ffa35db7362776aa8a00993c6f3986c46cfdc2e0759581871" + }, + { + "name": "jsonlite", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/jsonlite_2.0.0.tgz", + "sha256": "35df0622339690661adc69521caab76a7b54e3a2f39b4b0d53832d2be3ccd5ea" + }, + { + "name": "knitr", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/knitr_1.52.tgz", + "sha256": "7d6a45ce61a39380eae654dbcf1cc79b9a4f4d3d06560e20c08fd017faaf80ac" + }, + { + "name": "languageserver", + "url": "https://r2.ropensci.org/3034dd8c5fd6681b6728a91ac8823aa0ac36a00625e58064b35747c6866c32fa", + "sha256": "3034dd8c5fd6681b6728a91ac8823aa0ac36a00625e58064b35747c6866c32fa", + "bundledPath": "src/webr/resources/languageserver.tgz" + }, + { + "name": "lifecycle", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/lifecycle_1.0.5.tgz", + "sha256": "c2f8c5905f58b4526c3b68c6163f891b9a12f81d7e50347ad49a70b1f6592527" + }, + { + "name": "lintr", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/lintr_3.4.0.tgz", + "sha256": "1860d098a5ea2c94b9695242b8085eda466803d554644d7523cefe4a4bffa295" + }, + { + "name": "magrittr", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/magrittr_2.0.5.tgz", + "sha256": "ff7c81a6839f611a9a7d16b2e03ba6e99859992128012f8e9d3d7a8ef1ad5588" + }, + { + "name": "otel", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/otel_0.2.0.tgz", + "sha256": "722eed201325be994c5ce729f0d016571b9987c51193e87134fd2fe65d6ce09b" + }, + { + "name": "processx", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/processx_3.9.0.tgz", + "sha256": "c994d967a7daf02b3a1fc816cf7e2cc58520b7e887b1fa11d83f878ed79dccbc" + }, + { + "name": "ps", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/ps_1.9.3.tgz", + "sha256": "ec2e4d31b380325725ccc5618ff3335c8adb451eca347ede3e30d856b56b6614" + }, + { + "name": "purrr", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/purrr_1.2.2.tgz", + "sha256": "bd87e3e08ace87d8d6be7a47f4d2620843f15beb2f6e54f28eb90b1bdbb731e0" + }, + { + "name": "rex", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/rex_1.2.2.tgz", + "sha256": "2098a2912b3f1a52b8c8fa050dd9f2cdfc137cb3f16756a9414a669095785bc1" + }, + { + "name": "rlang", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/rlang_1.3.0.tgz", + "sha256": "c5562dc07b5d3c62fb85ee856a670b83105ba7793c778a30c1d9512d914e208a" + }, + { + "name": "rprojroot", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/rprojroot_2.1.1.tgz", + "sha256": "ed74ec20e04afbc9ae96ac61b3503801f52e93adbe32f71b3122a63463190a0f" + }, + { + "name": "styler", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/styler_1.11.0.tgz", + "sha256": "098a80aecb75125f9caa90a918e428d7dd9f74e3e5ed4c3ad768750c147815a3" + }, + { + "name": "vctrs", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/vctrs_0.7.3.tgz", + "sha256": "42cc19d325e7de2160490273d97099049f261e8b6c3e6736391d96e43923798d" + }, + { + "name": "withr", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/withr_3.0.3.tgz", + "sha256": "65530833ac1e34d41a8e991aab69713aae1a24500af11257b637256af7cc2195" + }, + { + "name": "xfun", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/xfun_0.61.tgz", + "sha256": "62e6499ecbf49a3a2fc7343ac836c91c80f4d6bab5edeaed97fc1450230ff686" + }, + { + "name": "xml2", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/xml2_1.6.0.tgz", + "sha256": "3618879568c846e1c4b298604297addf1867c2c461ad13361b623c0352a3ac86" + }, + { + "name": "xmlparsedata", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/xmlparsedata_1.0.5.tgz", + "sha256": "d845e8ee3549cc03035ae53c081f23d13f62b0173e754211e09789f0daea0926" + }, + { + "name": "yaml", + "url": "https://repo.r-wasm.org/bin/emscripten/contrib/4.6/yaml_2.3.12.tgz", + "sha256": "027e4bd87fcd16d0ba744dd41c51e2eb711c07d873f6050e65c8daf454d74f13" + } +] diff --git a/src/webr/resources/languageserver.tgz b/src/webr/resources/languageserver.tgz new file mode 100644 index 000000000..10e35c3fa Binary files /dev/null and b/src/webr/resources/languageserver.tgz differ diff --git a/src/webr/runtime.ts b/src/webr/runtime.ts new file mode 100644 index 000000000..da52d6393 --- /dev/null +++ b/src/webr/runtime.ts @@ -0,0 +1,3 @@ +/** Match the Wasm assets to the JavaScript API installed through pnpm. */ +export const WEBR_VERSION = '0.6.1'; +export const WEBR_BASE_URL = `https://webr.r-wasm.org/v${WEBR_VERSION}/`; diff --git a/src/webr/serverModules.json b/src/webr/serverModules.json new file mode 100644 index 000000000..66d4d7bb3 --- /dev/null +++ b/src/webr/serverModules.json @@ -0,0 +1,37 @@ +[ + { + "name": "workspace.R", + "url": "https://raw.githubusercontent.com/REditorSupport/languageserver/8afd6768773640648f92cc083425c6b17ad44f23/R/workspace.R", + "sha256": "35c0e4b2220e4976b296333cce14f0c1d1f1c860f45f0d5788acdcdd264bfb1e" + }, + { + "name": "source-path-completion.R", + "url": "https://raw.githubusercontent.com/REditorSupport/languageserver/8afd6768773640648f92cc083425c6b17ad44f23/R/source-path-completion.R", + "sha256": "0c8864a76fc6ac4518b535fede6b3ccbbf8d68fa479565ca3111eeb880c575dd" + }, + { + "name": "completion.R", + "url": "https://raw.githubusercontent.com/REditorSupport/languageserver/8afd6768773640648f92cc083425c6b17ad44f23/R/completion.R", + "sha256": "63f644dae9cd6e8f4ea9a4baf89cad2ae517ebf2913f8f421c3d3fc97126f4d5" + }, + { + "name": "definition.R", + "url": "https://raw.githubusercontent.com/REditorSupport/languageserver/8afd6768773640648f92cc083425c6b17ad44f23/R/definition.R", + "sha256": "47f0adcb30954398c2027f78fa764c01dfe7f8f6a678dabd23a5359ea736846d" + }, + { + "name": "glue-provider.R", + "url": "https://raw.githubusercontent.com/REditorSupport/languageserver/8afd6768773640648f92cc083425c6b17ad44f23/R/glue-provider.R", + "sha256": "66f320e73289151bc9da9557246c0217b0153a54ac57b86cb86f5d000c83eb41" + }, + { + "name": "backend-styler.R", + "url": "https://raw.githubusercontent.com/REditorSupport/languageserver/8afd6768773640648f92cc083425c6b17ad44f23/R/backend-styler.R", + "sha256": "1f7c0a999e645662a7c1f700d840d5b42d19dd67a5ca861d7ee2a8f2369d5f5e" + }, + { + "name": "embedded.R", + "url": "https://raw.githubusercontent.com/REditorSupport/languageserver/8afd6768773640648f92cc083425c6b17ad44f23/R/embedded.R", + "sha256": "3c42f013ca3a9b075b47b26f48869760e26e0a6cb44071ac5f870166f6c3e1d2" + } +] diff --git a/tsconfig.json b/tsconfig.json index ba4b80a31..0c87da6ab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,9 @@ "compilerOptions": { "module": "Node16", "moduleResolution": "Node16", + "resolveJsonModule": true, + // webR ships declarations for both the main thread and Emscripten worker internals. + "skipLibCheck": true, "target": "ES2022", "outDir": "out", "lib": [ diff --git a/website/docs/configuration/extension-settings.md b/website/docs/configuration/extension-settings.md index a0f751e8d..8f5ac62a2 100644 --- a/website/docs/configuration/extension-settings.md +++ b/website/docs/configuration/extension-settings.md @@ -150,6 +150,10 @@ longer forces the standard viewer: if that was your 2.x configuration, set The following settings could be set up to deviate from the default behavior: - `r.lsp.enabled`: Enable the R language server (default). +- `r.lsp.runtime` selects the runtime for source editors. The default, `auto`, + uses native R when available and falls back to webR. Set `native` to require + a native R installation or `webR` to use the experimental integration. + Its implementation and behavior may change substantially between releases. - `r.executablePath`: Path to the vanilla R binary used to launch the R Language Server and other background processes. Examples: `/usr/bin/R` (Linux/macOS), `C:\\Program Files\\R\\R-4.1.0\\bin\\x64\\R.exe` (Windows). If diff --git a/website/docs/features/language-service.md b/website/docs/features/language-service.md index 86c6ced38..2d7f8ef43 100644 --- a/website/docs/features/language-service.md +++ b/website/docs/features/language-service.md @@ -1,5 +1,35 @@ # R Language Service +## Language server runtime + +vscode-R’s webR integration is **experimental**. Its implementation and behavior +may change substantially between releases, including when `auto` selects webR. + +With `r.lsp.runtime` set to `auto`, vscode-R uses your configured R installation +when available. If it cannot find R, it starts the WebAssembly build of R +(webR) in a separate worker when you open an R document. Use `webR` to choose +this runtime explicitly or `native` to require a native installation. +`r.lsp.enabled` controls both runtimes. Reload the window after changing the +runtime setting. With the default `r.lsp.multiServer = false`, open files share +one server and the first workspace folder supplies its runtime preference. With +`r.lsp.multiServer = true`, each workspace folder uses its own preference. If an initialized webR worker +stops, choose **Retry** to reopen the current documents with a new worker. + +The VSIX includes the Wasm languageserver package. The first webR session +downloads its pinned runtime, supporting packages and development R modules. +Downloads are cached in extension storage. The +language worker analyzes the open editor buffers locally, including unsaved +changes. Cross-file navigation and rename cover open documents in the same +workspace. Package information reflects the packages installed in the worker. +The native server can additionally index closed files and use your project's R +library. + +When renaming a project-level symbol with webR, review the edits in VS Code. +The preview covers open files in the same workspace folder. Closed files can +still contain the old name. Renaming a local variable inside a function works +directly. Adding or removing a workspace folder updates which open buffers +can refer to each other, including buffers with unsaved edits. + The [R language server](https://github.com/REditorSupport/languageserver#servers-implemented) implements the