diff --git a/CHANGELOG.md b/CHANGELOG.md index d49e58e21eaa1..8eca987b175b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,10 @@ - [repo] with the upgrade to Inversify 6.0, a few initialization methods were adjusted. See also [this migration guide entry](https://github.com/eclipse-theia/theia/blob/master/doc/Migration.md#inversify-60). Additionally, other changes include: [#12425](https://github.com/eclipse-theia/theia/pull/12425) - The type expected by the `PreferenceProxySchema` symbol has been changed from `PromiseLike` to `() => PromiseLike` - The symbol `OnigasmPromise` has been changed to `OnigasmProvider` and injects a function of type `() => Promise` - - The symbol `PreferenceTransactionPrelude` has been changed to `PreferenceTransactionPreludeProvider ` and injects a function of type `() => Promise` + - The symbol `PreferenceTransactionPrelude` has been changed to `PreferenceTransactionPreludeProvider` and injects a function of type `() => Promise` +- [rpc] Renamed suffixes of classes and types that were still referencing the old rpc protocol. From `JsonRpc*` to `Rpc*`. + - Old classes and types are still available but haven been deprecated and will be removed future releases [#12588](https://github.com/eclipse-theia/theia/pull/12588) + - e.g. `JsonRpcProxyFactory` is deprecated, use `RpcProxyFactory` instead. ## v1.38.0 - 05/25/2023 diff --git a/examples/api-samples/src/common/updater/sample-updater.ts b/examples/api-samples/src/common/updater/sample-updater.ts index 92ef9c807b0b1..0c2b1859ea605 100644 --- a/examples/api-samples/src/common/updater/sample-updater.ts +++ b/examples/api-samples/src/common/updater/sample-updater.ts @@ -13,7 +13,7 @@ // // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; export enum UpdateStatus { InProgress = 'in-progress', @@ -23,7 +23,7 @@ export enum UpdateStatus { export const SampleUpdaterPath = '/services/sample-updater'; export const SampleUpdater = Symbol('SampleUpdater'); -export interface SampleUpdater extends JsonRpcServer { +export interface SampleUpdater extends RpcServer { checkForUpdates(): Promise<{ status: UpdateStatus }>; onRestartToUpdateRequested(): void; disconnectClient(client: SampleUpdaterClient): void; diff --git a/examples/api-samples/src/electron-main/update/sample-updater-main-module.ts b/examples/api-samples/src/electron-main/update/sample-updater-main-module.ts index 1673f6ad855b4..b92e76576bf37 100644 --- a/examples/api-samples/src/electron-main/update/sample-updater-main-module.ts +++ b/examples/api-samples/src/electron-main/update/sample-updater-main-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule } from '@theia/core/shared/inversify'; -import { JsonRpcConnectionHandler } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcConnectionHandler } from '@theia/core/lib/common/messaging/proxy-factory'; import { ElectronMainApplicationContribution } from '@theia/core/lib/electron-main/electron-main-application'; import { ElectronConnectionHandler } from '@theia/core/lib/electron-common/messaging/electron-connection-handler'; import { SampleUpdaterPath, SampleUpdater, SampleUpdaterClient } from '../../common/updater/sample-updater'; @@ -26,7 +26,7 @@ export default new ContainerModule(bind => { bind(SampleUpdater).toService(SampleUpdaterImpl); bind(ElectronMainApplicationContribution).toService(SampleUpdater); bind(ElectronConnectionHandler).toDynamicValue(context => - new JsonRpcConnectionHandler(SampleUpdaterPath, client => { + new RpcConnectionHandler(SampleUpdaterPath, client => { const server = context.container.get(SampleUpdater); server.setClient(client); client.onDidCloseConnection(() => server.disconnectClient(client)); diff --git a/packages/core/src/browser/messaging/ws-connection-provider.ts b/packages/core/src/browser/messaging/ws-connection-provider.ts index 66a6a518189a0..a5ad8ab4437c4 100644 --- a/packages/core/src/browser/messaging/ws-connection-provider.ts +++ b/packages/core/src/browser/messaging/ws-connection-provider.ts @@ -15,14 +15,14 @@ // ***************************************************************************** import { injectable, interfaces, decorate, unmanaged } from 'inversify'; -import { JsonRpcProxyFactory, JsonRpcProxy, Emitter, Event, Channel } from '../../common'; +import { RpcProxyFactory, RpcProxy, Emitter, Event, Channel } from '../../common'; import { Endpoint } from '../endpoint'; import { AbstractConnectionProvider } from '../../common/messaging/abstract-connection-provider'; import { io, Socket } from 'socket.io-client'; import { IWebSocket, WebSocketChannel } from '../../common/messaging/web-socket-channel'; -decorate(injectable(), JsonRpcProxyFactory); -decorate(unmanaged(), JsonRpcProxyFactory, 0); +decorate(injectable(), RpcProxyFactory); +decorate(unmanaged(), RpcProxyFactory, 0); export interface WebSocketOptions { /** @@ -44,7 +44,7 @@ export class WebSocketConnectionProvider extends AbstractConnectionProvider(container: interfaces.Container, path: string, arg?: object): JsonRpcProxy { + static override createProxy(container: interfaces.Container, path: string, arg?: object): RpcProxy { return container.get(WebSocketConnectionProvider).createProxy(path, arg); } diff --git a/packages/core/src/common/logger-protocol.ts b/packages/core/src/common/logger-protocol.ts index 3b5b4b7cd2618..57327924c901c 100644 --- a/packages/core/src/common/logger-protocol.ts +++ b/packages/core/src/common/logger-protocol.ts @@ -15,13 +15,13 @@ // ***************************************************************************** import { injectable } from 'inversify'; -import { JsonRpcServer } from './messaging/proxy-factory'; +import { RpcServer } from './messaging/proxy-factory'; export const ILoggerServer = Symbol('ILoggerServer'); export const loggerPath = '/services/logger'; -export interface ILoggerServer extends JsonRpcServer { +export interface ILoggerServer extends RpcServer { setLogLevel(name: string, logLevel: number): Promise; getLogLevel(name: string): Promise; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/core/src/common/messaging/abstract-connection-provider.ts b/packages/core/src/common/messaging/abstract-connection-provider.ts index c7f41d99a76da..2e2c8c8956232 100644 --- a/packages/core/src/common/messaging/abstract-connection-provider.ts +++ b/packages/core/src/common/messaging/abstract-connection-provider.ts @@ -17,7 +17,7 @@ import { injectable, interfaces } from 'inversify'; import { Emitter, Event } from '../event'; import { ConnectionHandler } from './handler'; -import { JsonRpcProxy, JsonRpcProxyFactory } from './proxy-factory'; +import { RpcProxy, RpcProxyFactory } from './proxy-factory'; import { Channel, ChannelMultiplexer } from '../message-rpc/channel'; /** @@ -32,7 +32,7 @@ export abstract class AbstractConnectionProvider * Create a proxy object to remote interface of T type * over an electron ipc connection for the given path and proxy factory. */ - static createProxy(container: interfaces.Container, path: string, factory: JsonRpcProxyFactory): JsonRpcProxy; + static createProxy(container: interfaces.Container, path: string, factory: RpcProxyFactory): RpcProxy; /** * Create a proxy object to remote interface of T type * over an electron ipc connection for the given path. @@ -40,7 +40,7 @@ export abstract class AbstractConnectionProvider * An optional target can be provided to handle * notifications and requests from a remote side. */ - static createProxy(container: interfaces.Container, path: string, target?: object): JsonRpcProxy { + static createProxy(container: interfaces.Container, path: string, target?: object): RpcProxy { throw new Error('abstract'); } @@ -53,7 +53,7 @@ export abstract class AbstractConnectionProvider * Create a proxy object to remote interface of T type * over a web socket connection for the given path and proxy factory. */ - createProxy(path: string, factory: JsonRpcProxyFactory): JsonRpcProxy; + createProxy(path: string, factory: RpcProxyFactory): RpcProxy; /** * Create a proxy object to remote interface of T type * over a web socket connection for the given path. @@ -61,9 +61,9 @@ export abstract class AbstractConnectionProvider * An optional target can be provided to handle * notifications and requests from a remote side. */ - createProxy(path: string, target?: object): JsonRpcProxy; - createProxy(path: string, arg?: object): JsonRpcProxy { - const factory = arg instanceof JsonRpcProxyFactory ? arg : new JsonRpcProxyFactory(arg); + createProxy(path: string, target?: object): RpcProxy; + createProxy(path: string, arg?: object): RpcProxy { + const factory = arg instanceof RpcProxyFactory ? arg : new RpcProxyFactory(arg); this.listen({ path, onConnection: c => factory.listen(c) diff --git a/packages/core/src/common/messaging/proxy-factory.spec.ts b/packages/core/src/common/messaging/proxy-factory.spec.ts index dc7fa609633aa..14790d9d3b02c 100644 --- a/packages/core/src/common/messaging/proxy-factory.spec.ts +++ b/packages/core/src/common/messaging/proxy-factory.spec.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import * as chai from 'chai'; -import { JsonRpcProxyFactory, JsonRpcProxy } from './proxy-factory'; +import { RpcProxyFactory, RpcProxy } from './proxy-factory'; import { ChannelPipe } from '../message-rpc/channel.spec'; const expect = chai.expect; @@ -84,19 +84,19 @@ describe('Proxy-Factory', () => { function getSetup(): { client: TestClient; - clientProxy: JsonRpcProxy; + clientProxy: RpcProxy; server: TestServer; - serverProxy: JsonRpcProxy; + serverProxy: RpcProxy; } { const client = new TestClient(); const server = new TestServer(); - const serverProxyFactory = new JsonRpcProxyFactory(client); + const serverProxyFactory = new RpcProxyFactory(client); const pipe = new ChannelPipe(); serverProxyFactory.listen(pipe.right); const serverProxy = serverProxyFactory.createProxy(); - const clientProxyFactory = new JsonRpcProxyFactory(server); + const clientProxyFactory = new RpcProxyFactory(server); clientProxyFactory.listen(pipe.left); const clientProxy = clientProxyFactory.createProxy(); return { diff --git a/packages/core/src/common/messaging/proxy-factory.ts b/packages/core/src/common/messaging/proxy-factory.ts index ca1f6393009b7..ab654ca871a46 100644 --- a/packages/core/src/common/messaging/proxy-factory.ts +++ b/packages/core/src/common/messaging/proxy-factory.ts @@ -24,28 +24,29 @@ import { Channel } from '../message-rpc/channel'; import { RequestHandler, RpcProtocol } from '../message-rpc/rpc-protocol'; import { ConnectionHandler } from './handler'; import { Deferred } from '../promise-util'; +import { decorate, injectable, unmanaged } from '../../../shared/inversify'; -export type JsonRpcServer = Disposable & { +export type RpcServer = Disposable & { /** * If this server is a proxy to a remote server then * a client is used as a local object - * to handle JSON-RPC messages from the remote server. + * to handle RPC messages from the remote server. */ setClient(client: Client | undefined): void; getClient?(): Client | undefined; }; -export interface JsonRpcConnectionEventEmitter { +export interface RpcConnectionEventEmitter { readonly onDidOpenConnection: Event; readonly onDidCloseConnection: Event; } -export type JsonRpcProxy = T & JsonRpcConnectionEventEmitter; +export type RpcProxy = T & RpcConnectionEventEmitter; -export class JsonRpcConnectionHandler implements ConnectionHandler { +export class RpcConnectionHandler implements ConnectionHandler { constructor( readonly path: string, - readonly targetFactory: (proxy: JsonRpcProxy) => any, - readonly factoryConstructor: new () => JsonRpcProxyFactory = JsonRpcProxyFactory + readonly targetFactory: (proxy: RpcProxy) => any, + readonly factoryConstructor: new () => RpcProxyFactory = RpcProxyFactory ) { } onConnection(connection: Channel): void { @@ -63,12 +64,12 @@ export type RpcProtocolFactory = (channel: Channel, requestHandler: RequestHandl const defaultRpcProtocolFactory: RpcProtocolFactory = (channel, requestHandler) => new RpcProtocol(channel, requestHandler); /** - * Factory for JSON-RPC proxy objects. + * Factory for RPC proxy objects. * - * A JSON-RPC proxy exposes the programmatic interface of an object through - * JSON-RPC. This allows remote programs to call methods of this objects by - * sending JSON-RPC requests. This takes place over a bi-directional stream, - * where both ends can expose an object and both can call methods each other's + * A RPC proxy exposes the programmatic interface of an object through + * Theia's RPC protocol. This allows remote programs to call methods of this objects by + * sending RPC requests. This takes place over a bi-directional stream, + * where both ends can expose an object and both can call methods on each other' * exposed object. * * For example, assuming we have an object of the following type on one end: @@ -77,16 +78,16 @@ const defaultRpcProtocolFactory: RpcProtocolFactory = (channel, requestHandler) * bar(baz: number): number { return baz + 1 } * } * - * which we want to expose through a JSON-RPC interface. We would do: + * which we want to expose through a RPC interface. We would do: * * let target = new Foo() - * let factory = new JsonRpcProxyFactory('/foo', target) + * let factory = new RpcProxyFactory('/foo', target) * factory.onConnection(connection) * * The party at the other end of the `connection`, in order to remotely call * methods on this object would do: * - * let factory = new JsonRpcProxyFactory('/foo') + * let factory = new RpcProxyFactory('/foo') * factory.onConnection(connection) * let proxy = factory.createProxy(); * let result = proxy.bar(42) @@ -94,18 +95,18 @@ const defaultRpcProtocolFactory: RpcProtocolFactory = (channel, requestHandler) * * One the wire, it would look like this: * - * --> {"jsonrpc": "2.0", "id": 0, "method": "bar", "params": {"baz": 42}} - * <-- {"jsonrpc": "2.0", "id": 0, "result": 43} + * --> { "type":"1", "id": 1, "method": "bar", "args": [42]} + * <-- { "type":"3", "id": 1, "res": 43} * * Note that in the code of the caller, we didn't pass a target object to - * JsonRpcProxyFactory, because we don't want/need to expose an object. + * RpcProxyFactory, because we don't want/need to expose an object. * If we had passed a target object, the other side could've called methods on * it. * - * @param - The type of the object to expose to JSON-RPC. + * @param - The type of the object to expose to RPC. */ -export class JsonRpcProxyFactory implements ProxyHandler { +export class RpcProxyFactory implements ProxyHandler { protected readonly onDidOpenConnectionEmitter = new Emitter(); protected readonly onDidCloseConnectionEmitter = new Emitter(); @@ -113,9 +114,9 @@ export class JsonRpcProxyFactory implements ProxyHandler { protected rpcDeferred: Deferred; /** - * Build a new JsonRpcProxyFactory. + * Build a new RpcProxyFactory. * - * @param target - The object to expose to JSON-RPC methods calls. If this + * @param target - The object to expose to RPC methods calls. If this * is omitted, the proxy won't be able to handle requests, only send them. */ constructor(public target?: any, protected rpcProtocolFactory = defaultRpcProtocolFactory) { @@ -135,10 +136,10 @@ export class JsonRpcProxyFactory implements ProxyHandler { } /** - * Connect a MessageConnection to the factory. + * Connect a {@link Channel} to the factory by creating an {@link RpcProtocol} on top of it. * - * This connection will be used to send/receive JSON-RPC requests and - * response. + * This protocol will be used to send/receive RPC requests and + * responses. */ listen(channel: Channel): void { const protocol = this.rpcProtocolFactory(channel, (meth, args) => this.onRequest(meth, ...args)); @@ -148,9 +149,9 @@ export class JsonRpcProxyFactory implements ProxyHandler { } /** - * Process an incoming JSON-RPC method call. + * Process an incoming RPC method call. * - * onRequest is called when the JSON-RPC connection received a method call + * onRequest is called when the RPC connection received a method call * request. It calls the corresponding method on [[target]]. * * The return value is a Promise object that is resolved with the return @@ -179,7 +180,7 @@ export class JsonRpcProxyFactory implements ProxyHandler { } /** - * Process an incoming JSON-RPC notification. + * Process an incoming RPC notification. * * Same as [[onRequest]], but called on incoming notifications rather than * methods calls. @@ -192,37 +193,37 @@ export class JsonRpcProxyFactory implements ProxyHandler { /** * Create a Proxy exposing the interface of an object of type T. This Proxy - * can be used to do JSON-RPC method calls on the remote target object as + * can be used to do RPC method calls on the remote target object as * if it was local. * - * If `T` implements `JsonRpcServer` then a client is used as a target object for a remote target object. + * If `T` implements `RpcServer` then a client is used as a target object for a remote target object. */ - createProxy(): JsonRpcProxy { + createProxy(): RpcProxy { const result = new Proxy(this as any, this); return result as any; } /** - * Get a callable object that executes a JSON-RPC method call. + * Get a callable object that executes a RPC method call. * * Getting a property on the Proxy object returns a callable that, when - * called, executes a JSON-RPC call. The name of the property defines the + * called, executes a RPC call. The name of the property defines the * method to be called. The callable takes a variable number of arguments, - * which are passed in the JSON-RPC method call. + * which are passed in the RPC method call. * * For example, if you have a Proxy object: * - * let fooProxyFactory = JsonRpcProxyFactory('/foo') + * let fooProxyFactory = RpcProxyFactory('/foo') * let fooProxy = fooProxyFactory.createProxy() * * accessing `fooProxy.bar` will return a callable that, when called, - * executes a JSON-RPC method call to method `bar`. Therefore, doing + * executes a RPC method call to method `bar`. Therefore, doing * `fooProxy.bar()` will call the `bar` method on the remote Foo object. * * @param target - unused. * @param p - The property accessed on the Proxy object. * @param receiver - unused. - * @returns A callable that executes the JSON-RPC call. + * @returns A callable that executes the RPC call. */ get(target: T, p: PropertyKey, receiver: any): any { if (p === 'setClient') { @@ -306,3 +307,37 @@ export class JsonRpcProxyFactory implements ProxyHandler { } +/** + * @deprecated since 1.39.0 use `RpcConnectionEventEmitter` instead + */ +export type JsonRpcConnectionEventEmitter = RpcConnectionEventEmitter; + +/** + * @deprecated since 1.39.0 use `RpcServer` instead + */ +export type JsonRpcServer = RpcServer; + +/** + * @deprecated since 1.39.0 use `RpcProxy` instead + */ +export type JsonRpcProxy = RpcProxy; + +/** + * @deprecated since 1.39.0 use `RpcConnectionHandler` instead + */ +export class JsonRpcConnectionHandler extends RpcConnectionHandler { + +} + +/** + * @deprecated since 1.39.0 use `RpcProxyFactory` instead + */ +export class JsonRpcProxyFactory extends RpcProxyFactory { + +} + +// eslint-disable-next-line deprecation/deprecation +decorate(injectable(), JsonRpcProxyFactory); +// eslint-disable-next-line deprecation/deprecation +decorate(unmanaged(), JsonRpcProxyFactory, 0); + diff --git a/packages/core/src/electron-browser/messaging/electron-ipc-connection-provider.ts b/packages/core/src/electron-browser/messaging/electron-ipc-connection-provider.ts index 943e5fad28e89..1551e3ab9c8ed 100644 --- a/packages/core/src/electron-browser/messaging/electron-ipc-connection-provider.ts +++ b/packages/core/src/electron-browser/messaging/electron-ipc-connection-provider.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { injectable, interfaces } from 'inversify'; -import { JsonRpcProxy } from '../../common/messaging'; +import { RpcProxy } from '../../common/messaging'; import { AbstractConnectionProvider } from '../../common/messaging/abstract-connection-provider'; import { AbstractChannel, Channel, WriteBuffer } from '../../common'; import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '../../common/message-rpc/uint8-array-message-buffer'; @@ -29,7 +29,7 @@ export interface ElectronIpcOptions { @injectable() export class ElectronIpcConnectionProvider extends AbstractConnectionProvider { - static override createProxy(container: interfaces.Container, path: string, arg?: object): JsonRpcProxy { + static override createProxy(container: interfaces.Container, path: string, arg?: object): RpcProxy { return container.get(ElectronIpcConnectionProvider).createProxy(path, arg); } diff --git a/packages/core/src/electron-main/electron-main-application-module.ts b/packages/core/src/electron-main/electron-main-application-module.ts index 8d2214bda8ada..0c789b617d675 100644 --- a/packages/core/src/electron-main/electron-main-application-module.ts +++ b/packages/core/src/electron-main/electron-main-application-module.ts @@ -17,7 +17,7 @@ import { ContainerModule } from 'inversify'; import { v4 } from 'uuid'; import { bindContributionProvider } from '../common/contribution-provider'; -import { JsonRpcConnectionHandler } from '../common/messaging/proxy-factory'; +import { RpcConnectionHandler } from '../common/messaging/proxy-factory'; import { ElectronSecurityToken } from '../electron-common/electron-token'; import { ElectronMainWindowService, electronMainWindowServicePath } from '../electron-common/electron-main-window-service'; import { ElectronMainApplication, ElectronMainApplicationContribution, ElectronMainProcessArgv } from './electron-main-application'; @@ -49,7 +49,7 @@ export default new ContainerModule(bind => { bind(ElectronMainWindowService).to(ElectronMainWindowServiceImpl).inSingletonScope(); bind(ElectronConnectionHandler).toDynamicValue(context => - new JsonRpcConnectionHandler(electronMainWindowServicePath, + new RpcConnectionHandler(electronMainWindowServicePath, () => context.container.get(ElectronMainWindowService)) ).inSingletonScope(); diff --git a/packages/core/src/electron-main/electron-main-application.ts b/packages/core/src/electron-main/electron-main-application.ts index 5f7c5c5f4616c..bf43b2cb025a4 100644 --- a/packages/core/src/electron-main/electron-main-application.ts +++ b/packages/core/src/electron-main/electron-main-application.ts @@ -77,7 +77,7 @@ export interface ElectronMainExecutionParams { * From an `electron-main` module: * * bind(ElectronConnectionHandler).toDynamicValue(context => - * new JsonRpcConnectionHandler(electronMainWindowServicePath, + * new RpcConnectionHandler(electronMainWindowServicePath, * () => context.container.get(ElectronMainWindowService)) * ).inSingletonScope(); * diff --git a/packages/core/src/electron-node/keyboard/electron-backend-keyboard-module.ts b/packages/core/src/electron-node/keyboard/electron-backend-keyboard-module.ts index 3110578a244cc..38bfd4482e74e 100644 --- a/packages/core/src/electron-node/keyboard/electron-backend-keyboard-module.ts +++ b/packages/core/src/electron-node/keyboard/electron-backend-keyboard-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule } from 'inversify'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '../../common/messaging'; +import { ConnectionHandler, RpcConnectionHandler } from '../../common/messaging'; import { KeyboardLayoutProvider, keyboardPath } from '../../common/keyboard/keyboard-layout-provider'; import { ElectronKeyboardLayoutProvider } from './electron-keyboard-layout-provider'; @@ -23,7 +23,7 @@ export default new ContainerModule(bind => { bind(ElectronKeyboardLayoutProvider).toSelf().inSingletonScope(); bind(KeyboardLayoutProvider).toService(ElectronKeyboardLayoutProvider); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(keyboardPath, () => + new RpcConnectionHandler(keyboardPath, () => ctx.container.get(KeyboardLayoutProvider) ) ).inSingletonScope(); diff --git a/packages/core/src/node/backend-application-module.ts b/packages/core/src/node/backend-application-module.ts index 339a2b58d380c..080afa203ba58 100644 --- a/packages/core/src/node/backend-application-module.ts +++ b/packages/core/src/node/backend-application-module.ts @@ -18,7 +18,7 @@ import { ContainerModule, decorate, injectable } from 'inversify'; import { ApplicationPackage } from '@theia/application-package'; import { REQUEST_SERVICE_PATH } from '@theia/request'; import { - bindContributionProvider, MessageService, MessageClient, ConnectionHandler, JsonRpcConnectionHandler, + bindContributionProvider, MessageService, MessageClient, ConnectionHandler, RpcConnectionHandler, CommandService, commandServicePath, messageServicePath } from '../common'; import { BackendApplication, BackendApplicationContribution, BackendApplicationCliContribution, BackendApplicationServer } from './backend-application'; @@ -86,14 +86,14 @@ export const backendApplicationModule = new ContainerModule(bind => { bind(ApplicationServerImpl).toSelf().inSingletonScope(); bind(ApplicationServer).toService(ApplicationServerImpl); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(applicationPath, () => + new RpcConnectionHandler(applicationPath, () => ctx.container.get(ApplicationServer) ) ).inSingletonScope(); bind(EnvVariablesServer).to(EnvVariablesServerImpl).inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(envVariablesPath, () => { + new RpcConnectionHandler(envVariablesPath, () => { const envVariablesServer = ctx.container.get(EnvVariablesServer); return envVariablesServer; }) @@ -108,7 +108,7 @@ export const backendApplicationModule = new ContainerModule(bind => { bindContributionProvider(bind, WsRequestValidatorContribution); bind(KeytarService).to(KeytarServiceImpl).inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(keytarServicePath, () => ctx.container.get(KeytarService)) + new RpcConnectionHandler(keytarServicePath, () => ctx.container.get(KeytarService)) ).inSingletonScope(); bind(ContributionFilterRegistry).to(ContributionFilterRegistryImpl).inSingletonScope(); @@ -124,7 +124,7 @@ export const backendApplicationModule = new ContainerModule(bind => { bind(BackendRequestFacade).toSelf().inSingletonScope(); bind(ConnectionHandler).toDynamicValue( - ctx => new JsonRpcConnectionHandler(REQUEST_SERVICE_PATH, () => ctx.container.get(BackendRequestFacade)) + ctx => new RpcConnectionHandler(REQUEST_SERVICE_PATH, () => ctx.container.get(BackendRequestFacade)) ).inSingletonScope(); bindNodeStopwatch(bind); diff --git a/packages/core/src/node/i18n/i18n-backend-module.ts b/packages/core/src/node/i18n/i18n-backend-module.ts index 2b5cfc03128b6..c378a10fca65d 100644 --- a/packages/core/src/node/i18n/i18n-backend-module.ts +++ b/packages/core/src/node/i18n/i18n-backend-module.ts @@ -17,7 +17,7 @@ import { ContainerModule } from 'inversify'; import { localizationPath } from '../../common/i18n/localization'; import { LocalizationProvider } from './localization-provider'; -import { ConnectionHandler, JsonRpcConnectionHandler, bindContributionProvider } from '../../common'; +import { ConnectionHandler, RpcConnectionHandler, bindContributionProvider } from '../../common'; import { LocalizationRegistry, LocalizationContribution } from './localization-contribution'; import { LocalizationBackendContribution } from './localization-backend-contribution'; import { BackendApplicationContribution } from '../backend-application'; @@ -26,7 +26,7 @@ import { TheiaLocalizationContribution } from './theia-localization-contribution export default new ContainerModule(bind => { bind(LocalizationProvider).toSelf().inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(localizationPath, () => ctx.container.get(LocalizationProvider)) + new RpcConnectionHandler(localizationPath, () => ctx.container.get(LocalizationProvider)) ).inSingletonScope(); bind(LocalizationRegistry).toSelf().inSingletonScope(); bindContributionProvider(bind, LocalizationContribution); diff --git a/packages/core/src/node/logger-backend-module.ts b/packages/core/src/node/logger-backend-module.ts index 54286dffafcc7..368b90885ebd2 100644 --- a/packages/core/src/node/logger-backend-module.ts +++ b/packages/core/src/node/logger-backend-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule, Container, interfaces } from 'inversify'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '../common/messaging'; +import { ConnectionHandler, RpcConnectionHandler } from '../common/messaging'; import { ILogger, LoggerFactory, Logger, setRootLogger, LoggerName, rootLoggerName } from '../common/logger'; import { ILoggerServer, ILoggerClient, loggerPath, DispatchingLoggerClient } from '../common/logger-protocol'; import { ConsoleLoggerServer } from './console-logger-server'; @@ -71,7 +71,7 @@ export const loggerBackendModule = new ContainerModule(bind => { }); bind(ConnectionHandler).toDynamicValue(({ container }) => - new JsonRpcConnectionHandler(loggerPath, client => { + new RpcConnectionHandler(loggerPath, client => { const dispatching = container.get(DispatchingLoggerClient); dispatching.clients.add(client); client.onDidCloseConnection(() => dispatching.clients.delete(client)); diff --git a/packages/core/src/node/messaging/connection-container-module.ts b/packages/core/src/node/messaging/connection-container-module.ts index 52406d1585d3b..af17687ef8ec7 100644 --- a/packages/core/src/node/messaging/connection-container-module.ts +++ b/packages/core/src/node/messaging/connection-container-module.ts @@ -17,11 +17,11 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { interfaces, ContainerModule } from 'inversify'; -import { JsonRpcProxyFactory, ConnectionHandler, JsonRpcConnectionHandler, JsonRpcProxy } from '../../common'; +import { RpcProxyFactory, ConnectionHandler, RpcConnectionHandler, RpcProxy } from '../../common'; export type BindFrontendService = (path: string, serviceIdentifier: interfaces.ServiceIdentifier) => interfaces.BindingWhenOnSyntax; export type BindBackendService = ( - path: string, serviceIdentifier: interfaces.ServiceIdentifier, onActivation?: (service: T, proxy: JsonRpcProxy) => T + path: string, serviceIdentifier: interfaces.ServiceIdentifier, onActivation?: (service: T, proxy: RpcProxy) => T ) => void; export type ConnectionContainerModuleCallBack = (registry: { bind: interfaces.Bind @@ -74,7 +74,7 @@ export const ConnectionContainerModule: symbol & { create(callback: ConnectionCo create(callback: ConnectionContainerModuleCallBack): ContainerModule { return new ContainerModule((bind, unbind, isBound, rebind) => { const bindFrontendService: BindFrontendService = (path, serviceIdentifier) => { - const serviceFactory = new JsonRpcProxyFactory(); + const serviceFactory = new RpcProxyFactory(); const service = serviceFactory.createProxy(); bind(ConnectionHandler).toConstantValue({ path, @@ -84,7 +84,7 @@ export const ConnectionContainerModule: symbol & { create(callback: ConnectionCo }; const bindBackendService: BindBackendService = (path, serviceIdentifier, onActivation) => { bind(ConnectionHandler).toDynamicValue(context => - new JsonRpcConnectionHandler(path, proxy => { + new RpcConnectionHandler(path, proxy => { const service = context.container.get(serviceIdentifier); return onActivation ? onActivation(service, proxy) : service; }) diff --git a/packages/core/src/node/performance/measurement-backend-bindings.ts b/packages/core/src/node/performance/measurement-backend-bindings.ts index f64ee3c91594a..b55af81ffe369 100644 --- a/packages/core/src/node/performance/measurement-backend-bindings.ts +++ b/packages/core/src/node/performance/measurement-backend-bindings.ts @@ -16,7 +16,7 @@ import { interfaces } from 'inversify'; import { - ConnectionHandler, DefaultBackendStopwatch, BackendStopwatch, JsonRpcConnectionHandler, + ConnectionHandler, DefaultBackendStopwatch, BackendStopwatch, RpcConnectionHandler, Stopwatch, stopwatchPath } from '../../common'; import { NodeStopwatch } from './node-stopwatch'; @@ -27,7 +27,7 @@ export function bindNodeStopwatch(bind: interfaces.Bind): interfaces.BindingWhen export function bindBackendStopwatchServer(bind: interfaces.Bind): interfaces.BindingWhenOnSyntax { bind(ConnectionHandler).toDynamicValue(({ container }) => - new JsonRpcConnectionHandler(stopwatchPath, () => container.get(BackendStopwatch)) + new RpcConnectionHandler(stopwatchPath, () => container.get(BackendStopwatch)) ).inSingletonScope(); bind(DefaultBackendStopwatch).toSelf().inSingletonScope(); diff --git a/packages/external-terminal/src/electron-node/external-terminal-backend-module.ts b/packages/external-terminal/src/electron-node/external-terminal-backend-module.ts index 52913477e2143..1e09308a85619 100644 --- a/packages/external-terminal/src/electron-node/external-terminal-backend-module.ts +++ b/packages/external-terminal/src/electron-node/external-terminal-backend-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule, interfaces } from '@theia/core/shared/inversify'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core/lib/common'; +import { ConnectionHandler, RpcConnectionHandler } from '@theia/core/lib/common'; import { isWindows, isOSX } from '@theia/core/lib/common/os'; import { ExternalTerminalService, externalTerminalServicePath } from '../common/external-terminal'; import { MacExternalTerminalService } from './mac-external-terminal-service'; @@ -29,7 +29,7 @@ export function bindExternalTerminalService(bind: interfaces.Bind): void { bind(ExternalTerminalService).toService(serviceProvider); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(externalTerminalServicePath, () => + new RpcConnectionHandler(externalTerminalServicePath, () => ctx.container.get(ExternalTerminalService) ) ).inSingletonScope(); diff --git a/packages/file-search/src/node/file-search-backend-module.ts b/packages/file-search/src/node/file-search-backend-module.ts index a3f7f00c31a80..79ea64eae26ed 100644 --- a/packages/file-search/src/node/file-search-backend-module.ts +++ b/packages/file-search/src/node/file-search-backend-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule } from '@theia/core/shared/inversify'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core/lib/common'; +import { ConnectionHandler, RpcConnectionHandler } from '@theia/core/lib/common'; import { FileSearchServiceImpl } from './file-search-service-impl'; import { fileSearchServicePath, FileSearchService } from '../common/file-search-service'; @@ -23,7 +23,7 @@ export default new ContainerModule(bind => { bind(FileSearchService).to(FileSearchServiceImpl).inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(fileSearchServicePath, () => + new RpcConnectionHandler(fileSearchServicePath, () => ctx.container.get(FileSearchService) ) ).inSingletonScope(); diff --git a/packages/filesystem/src/common/filesystem-watcher-protocol.ts b/packages/filesystem/src/common/filesystem-watcher-protocol.ts index 146f98a0022d9..47ec7f35a3dc8 100644 --- a/packages/filesystem/src/common/filesystem-watcher-protocol.ts +++ b/packages/filesystem/src/common/filesystem-watcher-protocol.ts @@ -14,7 +14,7 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { JsonRpcServer } from '@theia/core'; +import { RpcServer } from '@theia/core'; import { FileChangeType } from './files'; export { FileChangeType }; @@ -24,7 +24,7 @@ export const FileSystemWatcherService = Symbol('FileSystemWatcherServer2'); * * Since multiple clients all make requests to this service, we need to track those individually via a `clientId`. */ -export interface FileSystemWatcherService extends JsonRpcServer { +export interface FileSystemWatcherService extends RpcServer { /** * @param clientId arbitrary id used to identify a client. * @param uri the path to watch. @@ -60,7 +60,7 @@ export interface FileSystemWatcherErrorParams { } export const FileSystemWatcherServer = Symbol('FileSystemWatcherServer'); -export interface FileSystemWatcherServer extends JsonRpcServer { +export interface FileSystemWatcherServer extends RpcServer { /** * Start file watching for the given param. * Resolve when watching is started. diff --git a/packages/filesystem/src/common/remote-file-system-provider.ts b/packages/filesystem/src/common/remote-file-system-provider.ts index 257af0a2cd35d..62a60cb6d0ab2 100644 --- a/packages/filesystem/src/common/remote-file-system-provider.ts +++ b/packages/filesystem/src/common/remote-file-system-provider.ts @@ -25,7 +25,7 @@ import { hasOpenReadWriteCloseCapability, hasFileFolderCopyCapability, hasReadWriteCapability, hasAccessCapability, FileSystemProviderError, FileSystemProviderErrorCode, FileUpdateOptions, hasUpdateCapability, FileUpdateResult, FileReadStreamOptions, hasFileReadStreamCapability } from './files'; -import { JsonRpcServer, JsonRpcProxy, JsonRpcProxyFactory } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcServer, RpcProxy, RpcProxyFactory } from '@theia/core/lib/common/messaging/proxy-factory'; import { ApplicationError } from '@theia/core/lib/common/application-error'; import { Deferred } from '@theia/core/lib/common/promise-util'; import type { TextDocumentContentChangeEvent } from '@theia/core/shared/vscode-languageserver-protocol'; @@ -35,7 +35,7 @@ import { CancellationToken, cancelled } from '@theia/core/lib/common/cancellatio export const remoteFileSystemPath = '/services/remote-filesystem'; export const RemoteFileSystemServer = Symbol('RemoteFileSystemServer'); -export interface RemoteFileSystemServer extends JsonRpcServer { +export interface RemoteFileSystemServer extends RpcServer { getCapabilities(): Promise stat(resource: string): Promise; access(resource: string, mode?: number): Promise; @@ -79,7 +79,7 @@ export const RemoteFileSystemProviderError = ApplicationError.declare(-33005, ({ message, data, stack }) ); -export class RemoteFileSystemProxyFactory extends JsonRpcProxyFactory { +export class RemoteFileSystemProxyFactory extends RpcProxyFactory { // eslint-disable-next-line @typescript-eslint/no-explicit-any protected override serializeError(e: any): any { @@ -153,7 +153,7 @@ export class RemoteFileSystemProvider implements Required, D * Wrapped remote filesystem. */ @inject(RemoteFileSystemServer) - protected readonly server: JsonRpcProxy; + protected readonly server: RpcProxy; @postConstruct() protected init(): void { diff --git a/packages/filesystem/src/node/filesystem-backend-module.ts b/packages/filesystem/src/node/filesystem-backend-module.ts index c8e973f3f66b1..abb8ea9773789 100644 --- a/packages/filesystem/src/node/filesystem-backend-module.ts +++ b/packages/filesystem/src/node/filesystem-backend-module.ts @@ -16,7 +16,7 @@ import * as path from 'path'; import { ContainerModule, interfaces } from '@theia/core/shared/inversify'; -import { ConnectionHandler, JsonRpcConnectionHandler, ILogger } from '@theia/core/lib/common'; +import { ConnectionHandler, RpcConnectionHandler, ILogger } from '@theia/core/lib/common'; import { FileSystemWatcherServer, FileSystemWatcherService } from '../common/filesystem-watcher-protocol'; import { FileSystemWatcherServerClient } from './filesystem-watcher-client'; import { NsfwFileSystemWatcherService, NsfwFileSystemWatcherServerOptions } from './nsfw-watcher/nsfw-filesystem-service'; @@ -29,7 +29,7 @@ import { import { FileSystemProvider } from '../common/files'; import { EncodingService } from '@theia/core/lib/common/encoding-service'; import { BackendApplicationContribution, IPCConnectionProvider } from '@theia/core/lib/node'; -import { JsonRpcProxyFactory, ConnectionErrorHandler } from '@theia/core'; +import { RpcProxyFactory, ConnectionErrorHandler } from '@theia/core'; import { FileSystemWatcherServiceDispatcher } from './filesystem-watcher-dispatcher'; export const NSFW_SINGLE_THREADED = process.argv.includes('--no-cluster'); @@ -54,7 +54,7 @@ export default new ContainerModule(bind => { bind(FileSystemProviderServer).toSelf(); bind(RemoteFileSystemServer).toService(FileSystemProviderServer); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(remoteFileSystemPath, client => { + new RpcConnectionHandler(remoteFileSystemPath, client => { const server = ctx.container.get(RemoteFileSystemServer); server.setClient(client); client.onDidCloseConnection(() => server.dispose()); @@ -116,7 +116,7 @@ export function spawnNsfwFileSystemWatcherServiceProcess(ctx: interfaces.Context const logger = ctx.container.get(ILogger); const nsfwOptions = ctx.container.get(NsfwOptions); const ipcConnectionProvider = ctx.container.get(IPCConnectionProvider); - const proxyFactory = new JsonRpcProxyFactory(); + const proxyFactory = new RpcProxyFactory(); const serverProxy = proxyFactory.createProxy(); // We need to call `.setClient` before listening, else the JSON-RPC calls won't go through. serverProxy.setClient(dispatcher); diff --git a/packages/filesystem/src/node/nsfw-watcher/index.ts b/packages/filesystem/src/node/nsfw-watcher/index.ts index 82b64eab99973..92920b9aaa48b 100644 --- a/packages/filesystem/src/node/nsfw-watcher/index.ts +++ b/packages/filesystem/src/node/nsfw-watcher/index.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import * as yargs from '@theia/core/shared/yargs'; -import { JsonRpcProxyFactory } from '@theia/core'; +import { RpcProxyFactory } from '@theia/core'; import { FileSystemWatcherServiceClient } from '../../common/filesystem-watcher-protocol'; import { NsfwFileSystemWatcherService } from './nsfw-filesystem-service'; import { IPCEntryPoint } from '@theia/core/lib/node/messaging/ipc-protocol'; @@ -39,7 +39,7 @@ const options: { export default (connection => { const server = new NsfwFileSystemWatcherService(options); - const factory = new JsonRpcProxyFactory(server); + const factory = new RpcProxyFactory(server); server.setClient(factory.createProxy()); factory.listen(connection); }); diff --git a/packages/git/src/common/git-prompt.ts b/packages/git/src/common/git-prompt.ts index 0adf3d60a51f4..a74f72d2c4d77 100644 --- a/packages/git/src/common/git-prompt.ts +++ b/packages/git/src/common/git-prompt.ts @@ -15,15 +15,15 @@ // ***************************************************************************** import { inject, injectable, postConstruct } from '@theia/core/shared/inversify'; -import { JsonRpcProxy, JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcProxy, RpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable'; export const GitPromptServer = Symbol('GitPromptServer'); -export interface GitPromptServer extends JsonRpcServer { +export interface GitPromptServer extends RpcServer { } export const GitPromptServerProxy = Symbol('GitPromptServerProxy'); -export interface GitPromptServerProxy extends JsonRpcProxy { +export interface GitPromptServerProxy extends RpcProxy { } @injectable() diff --git a/packages/git/src/common/git-watcher.ts b/packages/git/src/common/git-watcher.ts index 159997a4cc223..16547e301a26c 100644 --- a/packages/git/src/common/git-watcher.ts +++ b/packages/git/src/common/git-watcher.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { injectable, inject } from '@theia/core/shared/inversify'; -import { JsonRpcServer, JsonRpcProxy, isObject } from '@theia/core'; +import { RpcServer, RpcProxy, isObject } from '@theia/core'; import { Repository, WorkingDirectoryStatus } from './git-model'; import { Disposable, DisposableCollection, Emitter, Event } from '@theia/core/lib/common'; @@ -73,7 +73,7 @@ export const GitWatcherServer = Symbol('GitWatcherServer'); /** * Service representation communicating between the backend and the frontend. */ -export interface GitWatcherServer extends JsonRpcServer { +export interface GitWatcherServer extends RpcServer { /** * Watches status changes in the given repository. @@ -89,7 +89,7 @@ export interface GitWatcherServer extends JsonRpcServer { } export const GitWatcherServerProxy = Symbol('GitWatcherServerProxy'); -export type GitWatcherServerProxy = JsonRpcProxy; +export type GitWatcherServerProxy = RpcProxy; @injectable() export class ReconnectingGitWatcherServer implements GitWatcherServer { diff --git a/packages/git/src/node/git-backend-module.ts b/packages/git/src/node/git-backend-module.ts index ca57956b5b19a..bc9e0b3de5bbb 100644 --- a/packages/git/src/node/git-backend-module.ts +++ b/packages/git/src/node/git-backend-module.ts @@ -19,7 +19,7 @@ import { Git, GitPath } from '../common/git'; import { GitWatcherPath, GitWatcherClient, GitWatcherServer } from '../common/git-watcher'; import { DugiteGit, OutputParser, NameStatusParser, CommitDetailsParser, GitBlameParser } from './dugite-git'; import { DugiteGitWatcherServer } from './dugite-git-watcher'; -import { ConnectionHandler, JsonRpcConnectionHandler, ILogger } from '@theia/core/lib/common'; +import { ConnectionHandler, RpcConnectionHandler, ILogger } from '@theia/core/lib/common'; import { GitRepositoryManager } from './git-repository-manager'; import { GitRepositoryWatcherFactory, GitRepositoryWatcherOptions, GitRepositoryWatcher } from './git-repository-watcher'; import { GitLocator } from './git-locator/git-locator-protocol'; @@ -101,7 +101,7 @@ export default new ContainerModule(bind => { bindRepositoryWatcher(bind); bind(ConnectionHandler).toDynamicValue(context => - new JsonRpcConnectionHandler(GitWatcherPath, client => { + new RpcConnectionHandler(GitWatcherPath, client => { const server = context.container.get(GitWatcherServer); server.setClient(client); client.onDidCloseConnection(() => server.dispose()); @@ -111,7 +111,7 @@ export default new ContainerModule(bind => { bindPrompt(bind); bind(ConnectionHandler).toDynamicValue(context => - new JsonRpcConnectionHandler(GitPrompt.WS_PATH, client => { + new RpcConnectionHandler(GitPrompt.WS_PATH, client => { const server = context.container.get(GitPromptServer); server.setClient(client); client.onDidCloseConnection(() => server.dispose()); diff --git a/packages/git/src/node/git-locator/git-locator-client.ts b/packages/git/src/node/git-locator/git-locator-client.ts index f58f4f0871f9a..ebf709ba13ed8 100644 --- a/packages/git/src/node/git-locator/git-locator-client.ts +++ b/packages/git/src/node/git-locator/git-locator-client.ts @@ -16,7 +16,7 @@ import * as paths from 'path'; import { inject, injectable } from '@theia/core/shared/inversify'; -import { JsonRpcProxyFactory, DisposableCollection } from '@theia/core'; +import { RpcProxyFactory, DisposableCollection } from '@theia/core'; import { IPCConnectionProvider } from '@theia/core/lib/node'; import { GitLocator, GitLocateOptions } from './git-locator-protocol'; @@ -38,7 +38,7 @@ export class GitLocatorClient implements GitLocator { serverName: 'git-locator', entryPoint: paths.join(__dirname, 'git-locator-host'), }, async connection => { - const proxyFactory = new JsonRpcProxyFactory(); + const proxyFactory = new RpcProxyFactory(); const remote = proxyFactory.createProxy(); proxyFactory.listen(connection); try { diff --git a/packages/git/src/node/git-locator/git-locator-host.ts b/packages/git/src/node/git-locator/git-locator-host.ts index c2a40b0cc90e4..1dac54d47a8d6 100644 --- a/packages/git/src/node/git-locator/git-locator-host.ts +++ b/packages/git/src/node/git-locator/git-locator-host.ts @@ -14,10 +14,10 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { JsonRpcProxyFactory } from '@theia/core'; +import { RpcProxyFactory } from '@theia/core'; import { IPCEntryPoint } from '@theia/core/lib/node/messaging/ipc-protocol'; import { GitLocatorImpl } from './git-locator-impl'; export default (connection => - new JsonRpcProxyFactory(new GitLocatorImpl()).listen(connection) + new RpcProxyFactory(new GitLocatorImpl()).listen(connection) ); diff --git a/packages/mini-browser/src/node/mini-browser-backend-module.ts b/packages/mini-browser/src/node/mini-browser-backend-module.ts index 53d6e1df069c4..60c24b9b4d52d 100644 --- a/packages/mini-browser/src/node/mini-browser-backend-module.ts +++ b/packages/mini-browser/src/node/mini-browser-backend-module.ts @@ -17,7 +17,7 @@ import { ContainerModule } from '@theia/core/shared/inversify'; import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider'; import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core/lib/common'; +import { ConnectionHandler, RpcConnectionHandler } from '@theia/core/lib/common'; import { MiniBrowserService, MiniBrowserServicePath } from '../common/mini-browser-service'; import { MiniBrowserEndpoint, MiniBrowserEndpointHandler, HtmlHandler, ImageHandler, PdfHandler, SvgHandler } from './mini-browser-endpoint'; import { WsRequestValidatorContribution } from '@theia/core/lib/node/ws-request-validators'; @@ -30,7 +30,7 @@ export default new ContainerModule(bind => { bind(MiniBrowserWsRequestValidator).toSelf().inSingletonScope(); bind(WsRequestValidatorContribution).toService(MiniBrowserWsRequestValidator); bind(MiniBrowserService).toService(MiniBrowserEndpoint); - bind(ConnectionHandler).toDynamicValue(context => new JsonRpcConnectionHandler(MiniBrowserServicePath, () => context.container.get(MiniBrowserService))).inSingletonScope(); + bind(ConnectionHandler).toDynamicValue(context => new RpcConnectionHandler(MiniBrowserServicePath, () => context.container.get(MiniBrowserService))).inSingletonScope(); bindContributionProvider(bind, MiniBrowserEndpointHandler); bind(MiniBrowserEndpointHandler).to(HtmlHandler).inSingletonScope(); bind(MiniBrowserEndpointHandler).to(ImageHandler).inSingletonScope(); diff --git a/packages/plugin-dev/src/common/plugin-dev-protocol.ts b/packages/plugin-dev/src/common/plugin-dev-protocol.ts index 1b04ebbb8513e..c14689928e7e0 100644 --- a/packages/plugin-dev/src/common/plugin-dev-protocol.ts +++ b/packages/plugin-dev/src/common/plugin-dev-protocol.ts @@ -14,12 +14,12 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; import { PluginMetadata } from '@theia/plugin-ext/lib/common/plugin-protocol'; export const pluginDevServicePath = '/services/plugin-dev'; export const PluginDevServer = Symbol('PluginDevServer'); -export interface PluginDevServer extends JsonRpcServer { +export interface PluginDevServer extends RpcServer { getHostedPlugin(): Promise; runHostedPluginInstance(uri: string): Promise; runDebugHostedPluginInstance(uri: string, debugConfig: PluginDebugConfiguration): Promise; diff --git a/packages/plugin-ext/src/common/plugin-protocol.ts b/packages/plugin-ext/src/common/plugin-protocol.ts index eac6bc3897303..32f27ae6178ba 100644 --- a/packages/plugin-ext/src/common/plugin-protocol.ts +++ b/packages/plugin-ext/src/common/plugin-protocol.ts @@ -13,7 +13,7 @@ // // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; import { RPCProtocol } from './rpc-protocol'; import { Disposable } from '@theia/core/lib/common/disposable'; import { LogPart, KeysToAnyValues, KeysToKeysToAnyValue } from './types'; @@ -944,7 +944,7 @@ export interface DeployedPlugin { } export const HostedPluginServer = Symbol('HostedPluginServer'); -export interface HostedPluginServer extends JsonRpcServer { +export interface HostedPluginServer extends RpcServer { getDeployedPluginIds(): Promise; diff --git a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts index 2a4ec49c7e713..df424168e1531 100644 --- a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts @@ -33,7 +33,7 @@ import { RPCProtocol, RPCProtocolImpl } from '../../common/rpc-protocol'; import { Disposable, DisposableCollection, Emitter, isCancelled, ILogger, ContributionProvider, CommandRegistry, WillExecuteCommandEvent, - CancellationTokenSource, JsonRpcProxy, ProgressService, nls + CancellationTokenSource, RpcProxy, ProgressService, nls } from '@theia/core'; import { PreferenceServiceImpl, PreferenceProviderProvider } from '@theia/core/lib/browser/preferences'; import { WorkspaceService } from '@theia/workspace/lib/browser'; @@ -87,7 +87,7 @@ export class HostedPluginSupport { protected readonly logger: ILogger; @inject(HostedPluginServer) - protected readonly server: JsonRpcProxy; + protected readonly server: RpcProxy; @inject(HostedPluginWatcher) protected readonly watcher: HostedPluginWatcher; diff --git a/packages/plugin-ext/src/hosted/node/plugin-ext-hosted-backend-module.ts b/packages/plugin-ext/src/hosted/node/plugin-ext-hosted-backend-module.ts index a03391217c1be..78ce8fe2175e5 100644 --- a/packages/plugin-ext/src/hosted/node/plugin-ext-hosted-backend-module.ts +++ b/packages/plugin-ext/src/hosted/node/plugin-ext-hosted-backend-module.ts @@ -36,7 +36,7 @@ import { FilePluginUriFactory } from './scanners/file-plugin-uri-factory'; import { HostedPluginLocalizationService } from './hosted-plugin-localization-service'; import { LanguagePackService, languagePackServicePath } from '../../common/language-pack-service'; import { PluginLanguagePackService } from './plugin-language-pack-service'; -import { JsonRpcConnectionHandler } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcConnectionHandler } from '@theia/core/lib/common/messaging/proxy-factory'; import { ConnectionHandler } from '@theia/core/lib/common/messaging/handler'; const commonHostedConnectionModule = ConnectionContainerModule.create(({ bind, bindBackendService }) => { @@ -71,7 +71,7 @@ export function bindCommonHostedBackend(bind: interfaces.Bind): void { bind(PluginLanguagePackService).toSelf().inSingletonScope(); bind(LanguagePackService).toService(PluginLanguagePackService); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(languagePackServicePath, () => + new RpcConnectionHandler(languagePackServicePath, () => ctx.container.get(LanguagePackService) ) ).inSingletonScope(); diff --git a/packages/plugin-ext/src/main/node/plugin-ext-backend-module.ts b/packages/plugin-ext/src/main/node/plugin-ext-backend-module.ts index 24a26822bba67..f065137f69f30 100644 --- a/packages/plugin-ext/src/main/node/plugin-ext-backend-module.ts +++ b/packages/plugin-ext/src/main/node/plugin-ext-backend-module.ts @@ -30,7 +30,7 @@ import { PluginTheiaFileHandler } from './handlers/plugin-theia-file-handler'; import { PluginTheiaDirectoryHandler } from './handlers/plugin-theia-directory-handler'; import { GithubPluginDeployerResolver } from './plugin-github-resolver'; import { HttpPluginDeployerResolver } from './plugin-http-resolver'; -import { ConnectionHandler, JsonRpcConnectionHandler, bindContributionProvider } from '@theia/core'; +import { ConnectionHandler, RpcConnectionHandler, bindContributionProvider } from '@theia/core'; import { PluginPathsService, pluginPathsServicePath } from '../common/plugin-paths-protocol'; import { PluginPathsServiceImpl } from './paths/plugin-paths-service'; import { PluginServerHandler } from './plugin-server-handler'; @@ -71,13 +71,13 @@ export function bindMainBackend(bind: interfaces.Bind, unbind: interfaces.Unbind bind(PluginPathsService).to(PluginPathsServiceImpl).inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(pluginPathsServicePath, () => + new RpcConnectionHandler(pluginPathsServicePath, () => ctx.container.get(PluginPathsService) ) ).inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(pluginServerJsonRpcPath, () => + new RpcConnectionHandler(pluginServerJsonRpcPath, () => ctx.container.get(PluginServer) ) ).inSingletonScope(); diff --git a/packages/plugin-metrics/src/node/plugin-metrics-backend-module.ts b/packages/plugin-metrics/src/node/plugin-metrics-backend-module.ts index d07bf3558b804..02689f51e22e3 100644 --- a/packages/plugin-metrics/src/node/plugin-metrics-backend-module.ts +++ b/packages/plugin-metrics/src/node/plugin-metrics-backend-module.ts @@ -19,7 +19,7 @@ import { PluginMetricsContribution } from './plugin-metrics'; import { PluginMetrics, metricsJsonRpcPath } from '../common/metrics-protocol'; import { PluginMetricsImpl } from './plugin-metrics-impl'; import { ConnectionHandler } from '@theia/core/lib/common/messaging/handler'; -import { JsonRpcConnectionHandler } from '@theia/core'; +import { RpcConnectionHandler } from '@theia/core'; import { ContainerModule } from '@theia/core/shared/inversify'; import { PluginMetricsContributor } from './metrics-contributor'; import { PluginMetricTimeSum } from './metric-output/plugin-metrics-time-sum'; @@ -34,7 +34,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(PluginMetricsContributor).toSelf().inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => { const clients = ctx.container.get(PluginMetricsContributor); - return new JsonRpcConnectionHandler(metricsJsonRpcPath, client => { + return new RpcConnectionHandler(metricsJsonRpcPath, client => { const pluginMetricsHandler: PluginMetrics = ctx.container.get(PluginMetrics); clients.clients.add(pluginMetricsHandler); client.onDidCloseConnection(() => { diff --git a/packages/search-in-workspace/src/common/search-in-workspace-interface.ts b/packages/search-in-workspace/src/common/search-in-workspace-interface.ts index 8a9c54b75b29d..bade899bdda86 100644 --- a/packages/search-in-workspace/src/common/search-in-workspace-interface.ts +++ b/packages/search-in-workspace/src/common/search-in-workspace-interface.ts @@ -14,7 +14,7 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { JsonRpcServer } from '@theia/core'; +import { RpcServer } from '@theia/core'; export interface SearchInWorkspaceOptions { /** @@ -134,7 +134,7 @@ export interface SearchInWorkspaceClient { export const SIW_WS_PATH = '/services/search-in-workspace'; export const SearchInWorkspaceServer = Symbol('SearchInWorkspaceServer'); -export interface SearchInWorkspaceServer extends JsonRpcServer { +export interface SearchInWorkspaceServer extends RpcServer { /** * Start a search for WHAT in directories ROOTURIS. Return a unique search id. */ diff --git a/packages/search-in-workspace/src/node/search-in-workspace-backend-module.ts b/packages/search-in-workspace/src/node/search-in-workspace-backend-module.ts index 83339fa398bab..b35cb926f2d9f 100644 --- a/packages/search-in-workspace/src/node/search-in-workspace-backend-module.ts +++ b/packages/search-in-workspace/src/node/search-in-workspace-backend-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule } from '@theia/core/shared/inversify'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core/lib/common'; +import { ConnectionHandler, RpcConnectionHandler } from '@theia/core/lib/common'; import { SearchInWorkspaceServer, SearchInWorkspaceClient, SIW_WS_PATH } from '../common/search-in-workspace-interface'; import { RipgrepSearchInWorkspaceServer, RgPath } from './ripgrep-search-in-workspace-server'; import { rgPath } from '@vscode/ripgrep'; @@ -23,7 +23,7 @@ import { rgPath } from '@vscode/ripgrep'; export default new ContainerModule(bind => { bind(SearchInWorkspaceServer).to(RipgrepSearchInWorkspaceServer); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(SIW_WS_PATH, client => { + new RpcConnectionHandler(SIW_WS_PATH, client => { const server = ctx.container.get(SearchInWorkspaceServer); server.setClient(client); client.onDidCloseConnection(() => server.dispose()); diff --git a/packages/task/src/common/task-protocol.ts b/packages/task/src/common/task-protocol.ts index 2d191dd47cd9b..af24fa5ab2812 100644 --- a/packages/task/src/common/task-protocol.ts +++ b/packages/task/src/common/task-protocol.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { Event } from '@theia/core'; -import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; import { IJSONSchema } from '@theia/core/lib/common/json-schema'; import { ProblemMatcher, ProblemMatch, WatchingMatcherContribution, ProblemMatcherContribution, ProblemPatternContribution } from './problem-matcher-protocol'; export { WatchingMatcherContribution, ProblemMatcherContribution, ProblemPatternContribution }; @@ -203,7 +203,7 @@ export interface TaskInfo { readonly [key: string]: any; } -export interface TaskServer extends JsonRpcServer { +export interface TaskServer extends RpcServer { /** Run a task. Optionally pass a context. */ run(task: TaskConfiguration, ctx?: string, option?: RunTaskOption): Promise; /** Kill a task, by id. */ diff --git a/packages/task/src/node/task-backend-module.ts b/packages/task/src/node/task-backend-module.ts index fd2568b70afff..f98acf942a18e 100644 --- a/packages/task/src/node/task-backend-module.ts +++ b/packages/task/src/node/task-backend-module.ts @@ -16,7 +16,7 @@ import { ContainerModule } from '@theia/core/shared/inversify'; import { bindContributionProvider } from '@theia/core'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core/lib/common/messaging'; +import { ConnectionHandler, RpcConnectionHandler } from '@theia/core/lib/common/messaging'; import { BackendApplicationContribution } from '@theia/core/lib/node'; import { bindProcessTaskRunnerModule } from './process/process-task-runner-backend-module'; import { bindCustomTaskRunnerModule } from './custom/custom-task-runner-backend-module'; @@ -34,7 +34,7 @@ export default new ContainerModule(bind => { bind(TaskServer).to(TaskServerImpl).inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(taskPath, client => { + new RpcConnectionHandler(taskPath, client => { const taskServer = ctx.container.get(TaskServer); taskServer.setClient(client); // when connection closes, cleanup that client of task-server diff --git a/packages/terminal/src/common/base-terminal-protocol.ts b/packages/terminal/src/common/base-terminal-protocol.ts index d328ba656f611..23474b66e50f7 100644 --- a/packages/terminal/src/common/base-terminal-protocol.ts +++ b/packages/terminal/src/common/base-terminal-protocol.ts @@ -14,7 +14,7 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; +import { RpcServer } from '@theia/core/lib/common/messaging/proxy-factory'; import { Disposable } from '@theia/core'; export interface TerminalProcessInfo { @@ -24,7 +24,7 @@ export interface TerminalProcessInfo { export interface IBaseTerminalServerOptions { } -export interface IBaseTerminalServer extends JsonRpcServer { +export interface IBaseTerminalServer extends RpcServer { create(IBaseTerminalServerOptions: object): Promise; getProcessId(id: number): Promise; getProcessInfo(id: number): Promise; diff --git a/packages/terminal/src/common/shell-terminal-protocol.ts b/packages/terminal/src/common/shell-terminal-protocol.ts index 994227d244df6..2c06139b8181b 100644 --- a/packages/terminal/src/common/shell-terminal-protocol.ts +++ b/packages/terminal/src/common/shell-terminal-protocol.ts @@ -14,7 +14,7 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { JsonRpcProxy } from '@theia/core'; +import { RpcProxy } from '@theia/core'; import { IBaseTerminalServer, IBaseTerminalServerOptions } from './base-terminal-protocol'; import { OS } from '@theia/core/lib/common/os'; @@ -47,4 +47,4 @@ export interface IShellTerminalServerOptions extends IBaseTerminalServerOptions } export const ShellTerminalServerProxy = Symbol('ShellTerminalServerProxy'); -export type ShellTerminalServerProxy = JsonRpcProxy; +export type ShellTerminalServerProxy = RpcProxy; diff --git a/packages/terminal/src/node/terminal-backend-module.ts b/packages/terminal/src/node/terminal-backend-module.ts index 2bd9b3025d417..8ca31d3841163 100644 --- a/packages/terminal/src/node/terminal-backend-module.ts +++ b/packages/terminal/src/node/terminal-backend-module.ts @@ -16,7 +16,7 @@ import { ContainerModule, Container, interfaces } from '@theia/core/shared/inversify'; import { TerminalBackendContribution } from './terminal-backend-contribution'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core/lib/common/messaging'; +import { ConnectionHandler, RpcConnectionHandler } from '@theia/core/lib/common/messaging'; import { ShellProcess, ShellProcessFactory, ShellProcessOptions } from './shell-process'; import { ITerminalServer, terminalPath } from '../common/terminal-protocol'; import { IBaseTerminalClient, DispatchingBaseTerminalClient, IBaseTerminalServer } from '../common/base-terminal-protocol'; @@ -45,7 +45,7 @@ export function bindTerminalServer(bind: interfaces.Bind, { path, identifier, co return terminalServer; }); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(path, client => { + new RpcConnectionHandler(path, client => { const disposable = dispatchingClient.push(client); client.onDidCloseConnection(() => disposable.dispose()); return ctx.container.get(identifier); diff --git a/packages/workspace/src/node/workspace-backend-module.ts b/packages/workspace/src/node/workspace-backend-module.ts index 5c719b9f03f68..fa56d19ccc162 100644 --- a/packages/workspace/src/node/workspace-backend-module.ts +++ b/packages/workspace/src/node/workspace-backend-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule } from '@theia/core/shared/inversify'; -import { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core/lib/common'; +import { ConnectionHandler, RpcConnectionHandler } from '@theia/core/lib/common'; import { WorkspaceServer, workspacePath, CommonWorkspaceUtils } from '../common'; import { DefaultWorkspaceServer, WorkspaceCliContribution } from './default-workspace-server'; import { CliContribution } from '@theia/core/lib/node/cli'; @@ -30,7 +30,7 @@ export default new ContainerModule(bind => { bind(CommonWorkspaceUtils).toSelf().inSingletonScope(); bind(ConnectionHandler).toDynamicValue(ctx => - new JsonRpcConnectionHandler(workspacePath, () => + new RpcConnectionHandler(workspacePath, () => ctx.container.get(WorkspaceServer) ) ).inSingletonScope();