0.8.1 • Published 1 year ago

@vscode/sync-api-client v0.8.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

VS Code Sync API Client

Build Status

This npm module implements a client that allows accessing VS Code API in sync from from a worker different than the extension host worker. The actually implementation depends on @vscode/syc-api-common.

History

0.8.0

  • replaced terminal/read and terminal/write with characterDevice/read and characterDevice/write to support character devices in general and not only ttys.

Example

Extension host worker that offers access to VS Code extension host API. The setup in the extension host code looks like this:

import { ServiceConnection } from '@vscode/sync-api-common/browser';
import { APIRequests, ApiService } from '@vscode/sync-api-service';

const worker = new Worker(...);
const connection = new ServiceConnection<APIRequests>(worker);
const apiService = new ApiService('Worker Name', connection);

// A terminal in case the worker write to one.
const terminal = window.createTerminal({ name: 'Worker name', pty: apiService.getPty() });
terminal.show();


connection.signalReady();

The worker side looks as follows:

import { ClientConnection } from '@vscode/sync-api-common/browser';
import { ApiClient, APIRequests } from '@vscode/sync-api-client';

const connection = new ClientConnection<APIRequests>(parentPort);
await connection.serviceReady();

const apiClient = new ApiClient(connection);
// Get the current workspace folders.
const workspaceFolders = apiClient.vscode.workspace.workspaceFolders;

// Read a file for a given uri
const content = apiClient.vscode.workspace.filesystem.readFile(uri);

For code executed in the desktop exchange the import @vscode/sync-api-common/browser with @vscode/sync-api-common/node.

0.9.0

1 year ago

0.8.1

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago