### Install Dependencies for Next Release - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Installs project dependencies, running prepare steps like clean and build, required before preparing a next release. ```bash npm install ``` -------------------------------- ### Install Dependencies for Latest Release - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Installs project dependencies, running prepare steps like clean and build, required before manually updating versions for a latest release. ```bash npm install ``` -------------------------------- ### Using vscode-messenger in a VS Code Extension (TypeScript) Source: https://github.com/typefox/vscode-messenger/blob/main/README.md This snippet demonstrates how to initialize the messenger in a VS Code extension, register webviews, handle incoming notifications and requests from webviews, and send messages back to webviews. It shows examples of defining message types and implementing handlers. ```typescript const messenger = new Messenger(); // register one or more views messenger.registerWebviewView(webviewView); // Handle incoming view notification const colorSelectType: NotificationType = { method: 'colorSelected' }; messenger.onNotification(colorSelectType, (params: string) => { vscode.window.activeTextEditor?.insertSnippet(new vscode.SnippetString(`#${params}`)); }); // Handle view requests and return a result const availableColorsType: RequestType = { method: 'availableColor' }; messenger.onRequest(availableColorsType, (params: string) => { return ['020202', 'f1eeee', 'a85b20', 'daab70', 'efcb99']; }); // Send a notification to a view of type 'calicoColors.colorsView' const colorModifyType: NotificationType = { method: 'colorModify' }; messenger.sendNotification(colorModifyType, {type: 'webview', webviewType: 'calicoColors.colorsView' }, 'clear'); // Send a request to a view of type 'calicoColors.colorsView' and get a result const selectedColor = await messenger.sendRequest({ method: 'getSelectedColor' }, {type: 'webview', webviewType: 'calicoColors.colorsView' }, ''); ``` -------------------------------- ### Login to VS Code Marketplace - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Logs into the VS Code marketplace publisher account (typefox) using vsce before publishing the extension. ```bash vsce login typefox ``` -------------------------------- ### Using vscode-messenger in a Webview (JavaScript) Source: https://github.com/typefox/vscode-messenger/blob/main/README.md This snippet shows how to initialize the messenger within a webview context, acquire the VS Code API, handle incoming notifications from the extension, and send requests to the extension. It demonstrates setting up a notification handler and sending a request to the host extension. ```javascript const vscode = acquireVsCodeApi(); const vscode_messenger = require("vscode-messenger-webview"); const messenger = new vscode_messenger.Messenger(vscode); // Handle extension Notifications. For requests use `onRequest()` messenger.onNotification({method: 'colorModify'}, (params) => { switch(params) { case 'add': { addColor(); break; } case 'clear': { colors = []; updateColorList(colors); break; } } }); messenger.start(); // start listening for incoming events // Send a request to your extension. // For notification use `sendNotification()` const colors = await messenger.sendRequest({ method: 'availableColors'}, HOST_EXTENSION, ''); console.log(colors); ``` -------------------------------- ### Publish Devtools Extension to Open VSX - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Publishes the packaged devtools extension to the Open VSX marketplace using ovsx and a provided access token. ```bash npx ovsx publish -p ``` -------------------------------- ### Prepare Next Version - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Updates package versions by adding a -next. suffix, preparing them for a next release. ```bash npm run prepare-next ``` -------------------------------- ### Publish Next Version - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Publishes the prepared next version of the packages to NPM with the next tag. ```bash npm run publish-next ``` -------------------------------- ### Activating Extension and Exposing Diagnostic API (TypeScript) Source: https://github.com/typefox/vscode-messenger/blob/main/packages/vscode-messenger-devtools/README.md This snippet shows the basic structure of a VS Code extension's 'activate' function when using 'vscode-messenger'. It initializes the Messenger and returns its diagnostic API instance, which is required for the vscode-messenger devtools to inspect the extension's messaging. ```TypeScript import * as vscode from 'vscode'; import { Messenger } from 'vscode-messenger'; const messenger = new Messenger(); export function activate(context: vscode.ExtensionContext) { // Your activation code... return messenger.diagnosticApi(); } ``` -------------------------------- ### Package Devtools Extension - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Changes directory to the devtools extension folder and packages the extension using vsce, excluding dependencies. This also triggers the vscode:prepublish script. ```bash cd ../vscode-messenger-devtools vsce package --no-dependencies ``` -------------------------------- ### Publish Devtools Extension to VS Code Marketplace - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Publishes the packaged devtools extension to the VS Code marketplace using vsce. ```bash vsce publish ``` -------------------------------- ### Publish Latest Version - Bash Source: https://github.com/typefox/vscode-messenger/blob/main/releasing.md Publishes the manually versioned packages to NPM with the latest tag. ```bash npm run publish-latest ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.