Repository navigation
feat(ide): run VS Code extensions with code in an extension host process (#259) - #291
Merged
Merged
Conversation
…ess (#259) - src/extensionHost/: a Node child process per window (ELECTRON_RUN_AS_NODE) that answers require('vscode') with a per-extension API, activates on declared and implicit events after dependencies, and deactivates on close. - The vscode API: commands, window (messages, quick picks, input boxes, dialogs, progress, status bar items, output channels), workspace (configuration, fs, findFiles, openTextDocument, watchers), env, extensions, l10n, ExtensionContext (state, secrets, storage) and the API's classes and enums. Missing API is reported once in the Extensions channel and replaced by inert stand-ins instead of throwing. - main: ExtensionHostManager (start, restart on changes and crashes, stop), the extensions' own settings file, secrets in the OS store, dialogs, clipboard, links, and the UI requests forwarded to the renderer. - renderer: the host bridge (messages with buttons, pickers, input boxes, progress, status bar items, contributed commands in the palette, VS Code command ids mapped onto the IDE's) and onLanguage activation. - Tests: protocol, API values, configuration, documents, and a real host process running three test extensions.
…ension host (#259) On Windows Uri.fsPath lower-cases the drive letter, so asRelativePath and getWorkspaceFolder failed against the folder as the main process spells it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adrián · project thread
Story #259 of epic #251: extensions with code now run in the IDE.
What changes
src/extensionHost/, new Vite targetout/extensionHost/index.cjs): a Node child process per window on Electron's own Node. It answersrequire('vscode')with an API object made for each extension, activates on declared and implicit events (onCommand:,onView:,onLanguage:) afterextensionDependencies, reports activation state and errors, and callsdeactivate()on close.vscodeAPI (api.ts,types.ts): commands; window (messages with buttons, modal messages as native dialogs,showQuickPick,showInputBox,createQuickPick,createInputBox, open/save dialogs,withProgress, status bar items, output and log channels); workspace (configuration withcontributes.configurationdefaults,fs,findFiles,openTextDocument, file watchers, content providers, trust); env (clipboard,openExternal, randommachineId, telemetry always off); extensions; l10n;ExtensionContext(global/workspace state, secrets in the OS store, storage and log folders); the API's classes and enums with VS Code's numbers. Missing API is logged once per extension in the Extensions output channel and replaced by inert stand-ins (inert.ts) instead of throwing.extensionHostManager.ts): starts the host when the workbench is ready, restarts it when extensions, the folder or its trust change and after crashes (3 in 5 minutes, then asks), forwards UI requests to the renderer and checks what the host asks (files only inside the folder, links http/https/mailto). Extension settings live in<userData>/extensions/settings.json. The host is unpacked from the asar in installers.hostBridge.ts): messages, pickers, input boxes (masked for passwords), progress, status bar items,setContext, contributed commands in the palette, VS Code command ids mapped onto the IDE's (workbench.action.files.save→file.save...),onLanguage:as files open. Developer: Restart Extension Host.docs/ide/extensions.md(host section, security, how to try it), README security row.Next: #260 (documents of the editor, diagnostics, language features).
Tests
npm run test --workspace=code-xr-ide: typecheck, lint, 726 tests pass. Newtest/extensionHost.test.tsruns a real host process with three test extensions (activation by event, command and dependency, failed activation, messages, configuration writes, state on disk, workbench commands, missing API,findFiles,deactivate).npm run smoke: OK.vscode-extension-samplescompiled from source and installed as.vsix: helloworld-minimal (palette command, message), progress (*activation, progress notification), statusbar (status bar item), configuration (two quick picks, thengetConfiguration().updatewritten to the settings file) and quickinput (showQuickPickand its messages).