Skip to content

Commit

Permalink
Replace deprecated imports
Browse files Browse the repository at this point in the history
  • Loading branch information
tortmayr committed May 30, 2023
1 parent 01f00ce commit d273b71
Show file tree
Hide file tree
Showing 42 changed files with 113 additions and 112 deletions.
4 changes: 2 additions & 2 deletions examples/api-samples/src/common/updater/sample-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 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',
Expand All @@ -23,7 +23,7 @@ export enum UpdateStatus {

export const SampleUpdaterPath = '/services/sample-updater';
export const SampleUpdater = Symbol('SampleUpdater');
export interface SampleUpdater extends JsonRpcServer<SampleUpdaterClient> {
export interface SampleUpdater extends RpcServer<SampleUpdaterClient> {
checkForUpdates(): Promise<{ status: UpdateStatus }>;
onRestartToUpdateRequested(): void;
disconnectClient(client: SampleUpdaterClient): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -26,7 +26,7 @@ export default new ContainerModule(bind => {
bind(SampleUpdater).toService(SampleUpdaterImpl);
bind(ElectronMainApplicationContribution).toService(SampleUpdater);
bind(ElectronConnectionHandler).toDynamicValue(context =>
new JsonRpcConnectionHandler<SampleUpdaterClient>(SampleUpdaterPath, client => {
new RpcConnectionHandler<SampleUpdaterClient>(SampleUpdaterPath, client => {
const server = context.container.get<SampleUpdater>(SampleUpdater);
server.setClient(client);
client.onDidCloseConnection(() => server.disconnectClient(client));
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/browser/messaging/ws-connection-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
// *****************************************************************************

import { injectable, interfaces, decorate, unmanaged } from 'inversify';
import { JsonRpcProxyFactory, JsonRpcProxy, Emitter, Event, Channel } from '../../common';
import { JsonRpcProxyFactory, 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(), RpcProxyFactory);
decorate(unmanaged(), RpcProxyFactory, 0);
decorate(injectable(), JsonRpcProxyFactory);
decorate(unmanaged(), JsonRpcProxyFactory, 0);

export interface WebSocketOptions {
/**
* True by default.
Expand All @@ -44,7 +45,7 @@ export class WebSocketConnectionProvider extends AbstractConnectionProvider<WebS
return this.onSocketDidCloseEmitter.event;
}

static override createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): JsonRpcProxy<T> {
static override createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): RpcProxy<T> {
return container.get(WebSocketConnectionProvider).createProxy<T>(path, arg);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/logger-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ILoggerClient> {
export interface ILoggerServer extends RpcServer<ILoggerClient> {
setLogLevel(name: string, logLevel: number): Promise<void>;
getLogLevel(name: string): Promise<number>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -32,15 +32,15 @@ export abstract class AbstractConnectionProvider<AbstractOptions extends object>
* Create a proxy object to remote interface of T type
* over an electron ipc connection for the given path and proxy factory.
*/
static createProxy<T extends object>(container: interfaces.Container, path: string, factory: JsonRpcProxyFactory<T>): JsonRpcProxy<T>;
static createProxy<T extends object>(container: interfaces.Container, path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
/**
* Create a proxy object to remote interface of T type
* over an electron ipc connection for the given path.
*
* An optional target can be provided to handle
* notifications and requests from a remote side.
*/
static createProxy<T extends object>(container: interfaces.Container, path: string, target?: object): JsonRpcProxy<T> {
static createProxy<T extends object>(container: interfaces.Container, path: string, target?: object): RpcProxy<T> {
throw new Error('abstract');
}

Expand All @@ -53,17 +53,17 @@ export abstract class AbstractConnectionProvider<AbstractOptions extends object>
* Create a proxy object to remote interface of T type
* over a web socket connection for the given path and proxy factory.
*/
createProxy<T extends object>(path: string, factory: JsonRpcProxyFactory<T>): JsonRpcProxy<T>;
createProxy<T extends object>(path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
/**
* Create a proxy object to remote interface of T type
* over a web socket connection for the given path.
*
* An optional target can be provided to handle
* notifications and requests from a remote side.
*/
createProxy<T extends object>(path: string, target?: object): JsonRpcProxy<T>;
createProxy<T extends object>(path: string, arg?: object): JsonRpcProxy<T> {
const factory = arg instanceof JsonRpcProxyFactory ? arg : new JsonRpcProxyFactory<T>(arg);
createProxy<T extends object>(path: string, target?: object): RpcProxy<T>;
createProxy<T extends object>(path: string, arg?: object): RpcProxy<T> {
const factory = arg instanceof RpcProxyFactory ? arg : new RpcProxyFactory<T>(arg);
this.listen({
path,
onConnection: c => factory.listen(c)
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/common/messaging/proxy-factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,19 +84,19 @@ describe('Proxy-Factory', () => {

function getSetup(): {
client: TestClient;
clientProxy: JsonRpcProxy<TestClient>;
clientProxy: RpcProxy<TestClient>;
server: TestServer;
serverProxy: JsonRpcProxy<TestServer>;
serverProxy: RpcProxy<TestServer>;
} {
const client = new TestClient();
const server = new TestServer();

const serverProxyFactory = new JsonRpcProxyFactory<TestServer>(client);
const serverProxyFactory = new RpcProxyFactory<TestServer>(client);
const pipe = new ChannelPipe();
serverProxyFactory.listen(pipe.right);
const serverProxy = serverProxyFactory.createProxy();

const clientProxyFactory = new JsonRpcProxyFactory<TestClient>(server);
const clientProxyFactory = new RpcProxyFactory<TestClient>(server);
clientProxyFactory.listen(pipe.left);
const clientProxy = clientProxyFactory.createProxy();
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -29,7 +29,7 @@ export interface ElectronIpcOptions {
@injectable()
export class ElectronIpcConnectionProvider extends AbstractConnectionProvider<ElectronIpcOptions> {

static override createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): JsonRpcProxy<T> {
static override createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): RpcProxy<T> {
return container.get(ElectronIpcConnectionProvider).createProxy<T>(path, arg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface ElectronMainExecutionParams {
* From an `electron-main` module:
*
* bind(ElectronConnectionHandler).toDynamicValue(context =>
* new JsonRpcConnectionHandler(electronMainWindowServicePath,
* new RpcConnectionHandler(electronMainWindowServicePath,
* () => context.container.get(ElectronMainWindowService))
* ).inSingletonScope();
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
// *****************************************************************************

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';

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();
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/node/backend-application-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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>(EnvVariablesServer);
return envVariablesServer;
})
Expand All @@ -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>(KeytarService))
new RpcConnectionHandler(keytarServicePath, () => ctx.container.get<KeytarService>(KeytarService))
).inSingletonScope();

bind(ContributionFilterRegistry).to(ContributionFilterRegistryImpl).inSingletonScope();
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/node/i18n/i18n-backend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/node/logger-backend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -54,11 +54,11 @@ export function bindLogger(bind: interfaces.Bind, props?: {
*/
export const loggerBackendModule = new ContainerModule(bind => {
bind(BackendApplicationContribution).toDynamicValue(ctx =>
({
initialize(): void {
setRootLogger(ctx.container.get<ILogger>(ILogger));
}
}));
({
initialize(): void {
setRootLogger(ctx.container.get<ILogger>(ILogger));
}
}));

bind(DispatchingLoggerClient).toSelf().inSingletonScope();
bindLogger(bind, {
Expand All @@ -71,7 +71,7 @@ export const loggerBackendModule = new ContainerModule(bind => {
});

bind(ConnectionHandler).toDynamicValue(({ container }) =>
new JsonRpcConnectionHandler<ILoggerClient>(loggerPath, client => {
new RpcConnectionHandler<ILoggerClient>(loggerPath, client => {
const dispatching = container.get(DispatchingLoggerClient);
dispatching.clients.add(client);
client.onDidCloseConnection(() => dispatching.clients.delete(client));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T extends object>(path: string, serviceIdentifier: interfaces.ServiceIdentifier<T>) => interfaces.BindingWhenOnSyntax<T>;
export type BindBackendService = <T extends object, C extends object = object>(
path: string, serviceIdentifier: interfaces.ServiceIdentifier<T>, onActivation?: (service: T, proxy: JsonRpcProxy<C>) => T
path: string, serviceIdentifier: interfaces.ServiceIdentifier<T>, onActivation?: (service: T, proxy: RpcProxy<C>) => T
) => void;
export type ConnectionContainerModuleCallBack = (registry: {
bind: interfaces.Bind
Expand Down Expand Up @@ -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>(ConnectionHandler).toConstantValue({
path,
Expand All @@ -84,7 +84,7 @@ export const ConnectionContainerModule: symbol & { create(callback: ConnectionCo
};
const bindBackendService: BindBackendService = (path, serviceIdentifier, onActivation) => {
bind(ConnectionHandler).toDynamicValue(context =>
new JsonRpcConnectionHandler<any>(path, proxy => {
new RpcConnectionHandler<any>(path, proxy => {
const service = context.container.get(serviceIdentifier);
return onActivation ? onActivation(service, proxy) : service;
})
Expand Down

0 comments on commit d273b71

Please sign in to comment.