Skip to content

Commit

Permalink
Split hosted and main part in two folders (#7)
Browse files Browse the repository at this point in the history
* Split hosted and main part in two folders
also make CI green again
Signed-off-by: Florent BENOIT <fbenoit@redhat.com>
  • Loading branch information
benoitf committed Jun 20, 2018
1 parent 9e37f6a commit 64903a3
Show file tree
Hide file tree
Showing 37 changed files with 186 additions and 131 deletions.
10 changes: 4 additions & 6 deletions packages/plugin-ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"name": "@theia/plugin-ext",
"version": "0.3.8",
"description": "Theia - Plugin Extension",
"main": "lib/common/index.js",
"types": "lib/common/index.d.ts",
"dependencies": {
"@theia/core": "^0.3.8",
"@theia/filesystem": "^0.3.8",
Expand All @@ -14,9 +12,9 @@
},
"theiaExtensions": [
{
"backend": "lib/node/node-plugin-api-backend-module",
"backendElectron": "lib/node-electron/electron-plugin-api-backend-module",
"frontend": "lib/browser/plugin-api-frontend-module"
"backend": "lib/plugin-ext-backend-module",
"backendElectron": "lib/plugin-backend-electron-module",
"frontend": "lib/plugin-ext-frontend-module"
}
],
"keywords": [
Expand Down Expand Up @@ -49,4 +47,4 @@
"nyc": {
"extends": "../../configs/nyc.json"
}
}
}
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { JsonRpcServer } from '@theia/core/lib/common/messaging/proxy-factory';
import { RPCProtocol } from '../api/rpc-protocol';
import { Disposable } from '../plugin/types-impl';
import { Disposable } from './types-impl';

export const hostedServicePath = '/services/hostedPlugin';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { injectable } from "inversify";
import { Emitter, Event } from '@theia/core/lib/common/event';
import { HostedPluginClient } from '../common/plugin-protocol';
import { HostedPluginClient } from "../../common/plugin-protocol";

@injectable()
export class HostedPluginWatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { injectable, inject, interfaces } from 'inversify';
import { HostedPluginServer, PluginModel, PluginLifecycle } from '../common/plugin-protocol';
import { PluginWorker } from './plugin-worker';
import { setUpPluginApi } from './main-context';
import { MAIN_RPC_CONTEXT, Plugin } from '../api/plugin-api';
import { PluginWorker } from '../../main/browser/plugin-worker';
import { HostedPluginServer, PluginLifecycle, PluginModel } from '../../common/plugin-protocol';
import { HostedPluginWatcher } from './hosted-plugin-watcher';
import { RPCProtocol, RPCProtocolImpl } from '../api/rpc-protocol';
import { MAIN_RPC_CONTEXT, Plugin } from '../../api/plugin-api';
import { setUpPluginApi } from '../../main/browser/main-context';
import { RPCProtocol, RPCProtocolImpl } from '../../api/rpc-protocol';
@injectable()
export class HostedPluginSupport {
private worker: PluginWorker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import { RPCProtocolImpl } from '../api/rpc-protocol';
import { Emitter } from '@theia/core/lib/common/event';
import { createAPI, startPlugin } from '../plugin/plugin-context';
import { MAIN_RPC_CONTEXT } from '../api/plugin-api';
import { HostedPluginManagerExtImpl } from '../plugin/hosted-plugin-manager';
import { Plugin } from '../api/plugin-api';
import { RPCProtocolImpl } from '../../../api/rpc-protocol';
import { HostedPluginManagerExtImpl } from '../../plugin/hosted-plugin-manager';
import { MAIN_RPC_CONTEXT, Plugin } from '../../../api/plugin-api';
import { createAPI, startPlugin } from '../../plugin/plugin-context';

const ctx = self as any;
const plugins = new Map<string, () => void>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import { ContainerModule } from "inversify";
import { HostedPluginManager, ElectronNodeHostedPluginRunner } from '../node/hosted-plugin-manager';
import { bindCommonPart } from "../node/plugin-api-backend-module";
import { interfaces } from 'inversify';
import { bindCommonHostedBackend } from '../node/plugin-ext-hosted-backend-module';

export default new ContainerModule(bind => {
export function bindElectronBackend(bind: interfaces.Bind): void {
bind(HostedPluginManager).to(ElectronNodeHostedPluginRunner);

bindCommonPart(bind);
});
bindCommonHostedBackend(bind);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* Red Hat, Inc. - initial API and implementation
*/

import { BackendInitializationFn } from '../../common/plugin-protocol';
import { createAPI } from '../../plugin/plugin-context';
import { BackendInitializationFn } from '../../../common/plugin-protocol';

export const doInitialization: BackendInitializationFn = (rpc: any) => {
const theia = createAPI(rpc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* Red Hat, Inc. - initial API and implementation
*/

import { BackendInitializationFn } from '../../common/plugin-protocol';
import { createAPI } from '../../plugin/plugin-context';
import { BackendInitializationFn } from '../../../common/plugin-protocol';

export const doInitialization: BackendInitializationFn = (rpc: any) => {
const module = require('module');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import * as path from 'path';
import * as cp from "child_process";
import { injectable, inject } from "inversify";
import { HostedPluginClient, PluginModel } from '../common/plugin-protocol';
import { ILogger, ConnectionErrorHandler } from "@theia/core/lib/common";
import { Emitter } from '@theia/core/lib/common/event';
import { createIpcEnv } from "@theia/core/lib/node/messaging/ipc-protocol";
import { MAIN_RPC_CONTEXT } from '../api/plugin-api';
import { RPCProtocolImpl } from '../api/rpc-protocol';
import { HostedPluginClient, PluginModel } from '../../common/plugin-protocol';
import { RPCProtocolImpl } from '../../api/rpc-protocol';
import { MAIN_RPC_CONTEXT } from '../../api/plugin-api';

export interface IPCConnectionOptions {
readonly serverName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import { injectable, multiInject } from 'inversify';
import { PluginPackage, PluginScanner, PluginMetadata } from '../common/plugin-protocol';
import { PluginPackage, PluginScanner, PluginMetadata } from '../../common/plugin-protocol';

@injectable()
export class MetadataScanner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import { bindContributionProvider } from "@theia/core/lib/common/contribution-provider";
import { HostedPluginManager, NodeHostedPluginRunner } from './hosted-plugin-manager';
import { HostedPluginUriPostProcessor } from "./hosted-plugin-uri-postprocessor";
import { interfaces } from "inversify";
import { ConnectionHandler, JsonRpcConnectionHandler } from "@theia/core/lib/common/messaging";
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
import { MetadataScanner } from './metadata-scanner';
import { PluginApiContribution, HostedPluginServerImpl } from './plugin-service';
import { HostedPluginServerImpl } from './plugin-service';
import { HostedPluginReader } from './plugin-reader';
import { HostedPluginClient, HostedPluginServer, hostedServicePath, PluginScanner } from '../common/plugin-protocol';
import { HostedPluginSupport } from './hosted-plugin';
import { TheiaPluginScanner } from './scanners/scanner-theia';
import { VsCodePluginScanner } from './scanners/scanner-vscode';
import { HostedPluginServer, PluginScanner, HostedPluginClient, hostedServicePath } from "../../common/plugin-protocol";

export function bindCommonPart(bind: interfaces.Bind): void {
bind(PluginApiContribution).toSelf().inSingletonScope();
export function bindCommonHostedBackend(bind: interfaces.Bind): void {
bind(HostedPluginReader).toSelf().inSingletonScope();
bind(HostedPluginServer).to(HostedPluginServerImpl).inSingletonScope();
bind(HostedPluginSupport).toSelf().inSingletonScope();
bind(PluginScanner).to(TheiaPluginScanner).inSingletonScope();
bind(PluginScanner).to(VsCodePluginScanner).inSingletonScope();
bind(MetadataScanner).toSelf().inSingletonScope();

bind(BackendApplicationContribution).toDynamicValue(ctx => ctx.container.get(PluginApiContribution)).inSingletonScope();
bind(BackendApplicationContribution).toDynamicValue(ctx => ctx.container.get(HostedPluginReader)).inSingletonScope();

bind(ConnectionHandler).toDynamicValue(ctx =>
Expand All @@ -37,3 +38,9 @@ export function bindCommonPart(bind: interfaces.Bind): void {
})
).inSingletonScope();
}

export function bindHostedBackend(bind: interfaces.Bind): void {
bind(HostedPluginManager).to(NodeHostedPluginRunner).inSingletonScope();
bindContributionProvider(bind, HostedPluginUriPostProcessor);
bindCommonHostedBackend(bind);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
*/

import { resolve } from 'path';
import { RPCProtocolImpl } from '../api/rpc-protocol';
import { Emitter } from '@theia/core/lib/common/event';
import { startPlugin } from '../plugin/plugin-context';
import { MAIN_RPC_CONTEXT } from '../api/plugin-api';
import { HostedPluginManagerExtImpl } from '../plugin/hosted-plugin-manager';
import { Plugin } from '../api/plugin-api';
import { RPCProtocolImpl } from '../../api/rpc-protocol';
import { MAIN_RPC_CONTEXT, Plugin } from '../../api/plugin-api';

const plugins = new Map<string, () => void>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { inject, injectable } from "inversify";
import * as express from 'express';
import * as fs from 'fs';
import { resolve } from 'path';
import { PluginPackage, PluginMetadata } from '../common/plugin-protocol';
import { MetadataScanner } from './metadata-scanner';
import { PluginMetadata, PluginPackage } from '../../common/plugin-protocol';

@injectable()
export class HostedPluginReader implements BackendApplicationContribution {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,12 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import * as express from 'express';
import URI from '@theia/core/lib/common/uri';
import { injectable, inject } from "inversify";
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
import { HostedPluginServer, HostedPluginClient, PluginMetadata } from '../common/plugin-protocol';
import { injectable, inject } from 'inversify';
import { HostedPluginServer, HostedPluginClient, PluginMetadata } from '../../common/plugin-protocol';
import { HostedPluginReader } from './plugin-reader';
import { HostedPluginSupport } from './hosted-plugin';
import { HostedPluginManager } from './hosted-plugin-manager';

const pluginPath = (process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE) + './theia/plugins/';

@injectable()
export class PluginApiContribution implements BackendApplicationContribution {
configure(app: express.Application): void {
app.get('/plugin/:path(*)', (req, res) => {
const filePath: string = req.params.path;
res.sendFile(pluginPath + filePath);
});
}
}
import { HostedPluginSupport } from './hosted-plugin';
import URI from '@theia/core/lib/common/uri';

@injectable()
export class HostedPluginServerImpl implements HostedPluginServer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
PluginScanner,
PluginLifecycle,
buildFrontendModuleName
} from '../../common/plugin-protocol';
} from '../../../common/plugin-protocol';

@injectable()
export class TheiaPluginScanner implements PluginScanner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import { injectable } from 'inversify';
import { PluginEngine, PluginModel, PluginPackage, PluginScanner, PluginLifecycle } from '../../common/plugin-protocol';
import { PluginScanner, PluginEngine, PluginPackage, PluginModel, PluginLifecycle } from '../../../common/plugin-protocol';

@injectable()
export class VsCodePluginScanner implements PluginScanner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { CommandRegistryExt, PLUGIN_RPC_CONTEXT as Ext, CommandRegistryMain } from '../api/plugin-api';
import { RPCProtocol } from '../api/rpc-protocol';
import * as theia from '@theia/plugin';
import { Disposable } from './types-impl';
import { CommandRegistryExt, PLUGIN_RPC_CONTEXT as Ext, CommandRegistryMain } from '../../api/plugin-api';
import { RPCProtocol } from '../../api/rpc-protocol';
import { Disposable } from '../../common/types-impl';

export type Handler = <T>(...args: any[]) => T | PromiseLike<T>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { HostedPluginManagerExt, Plugin } from '../api/plugin-api';
import { getPluginId } from '../common/plugin-protocol';

import { HostedPluginManagerExt, Plugin } from "../../api/plugin-api";
import { getPluginId } from "../../common/plugin-protocol";

export interface PluginHost {
initialize(contextPath: string): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { MAIN_RPC_CONTEXT } from '../api/plugin-api';
import { RPCProtocol } from '../api/rpc-protocol';
import * as theia from '@theia/plugin';
import { CommandRegistryImpl } from './command-registry';
import { Disposable } from './types-impl';
import { Emitter } from '@theia/core/lib/common/event';
import { CancellationTokenSource } from '@theia/core/lib/common/cancellation';
import { QuickOpenExtImpl } from './quick-open';
import { Plugin } from '../api/plugin-api';
import { getPluginId } from '../common/plugin-protocol';
import { MAIN_RPC_CONTEXT, Plugin } from '../../api/plugin-api';
import { RPCProtocol } from '../../api/rpc-protocol';
import { getPluginId } from '../../common/plugin-protocol';
import { Disposable } from '../../common/types-impl';

export function createAPI(rpc: RPCProtocol): typeof theia {
const commandRegistryExt = rpc.set(MAIN_RPC_CONTEXT.COMMAND_REGISTRY_EXT, new CommandRegistryImpl(rpc));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { QuickOpenExt, PLUGIN_RPC_CONTEXT as Ext, QuickOpenMain, PickOpenItem } from '../api/plugin-api';
import { RPCProtocol } from '../api/rpc-protocol';
import { QuickOpenExt, PLUGIN_RPC_CONTEXT as Ext, QuickOpenMain, PickOpenItem } from '../../api/plugin-api';
import { QuickPickOptions, QuickPickItem } from '@theia/plugin';
import { CancellationToken } from '@theia/core/lib/common/cancellation';
import { ExtendedPromise } from '../api/extended-promise';
import { hookCancellationToken } from '../api/async-util';
import { RPCProtocol } from '../../api/rpc-protocol';
import { ExtendedPromise } from '../../api/extended-promise';
import { hookCancellationToken } from '../../api/async-util';

export type Item = string | QuickPickItem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { CommandRegistryExt, MAIN_RPC_CONTEXT, CommandRegistryMain } from '../api/plugin-api';
import { interfaces } from "inversify";
import { CommandRegistry } from '@theia/core/lib/common/command';
import * as theia from '@theia/plugin';
import { Disposable } from '@theia/core/lib/common/disposable';
import { RPCProtocol } from '../api/rpc-protocol';
import { CommandRegistryMain, CommandRegistryExt, MAIN_RPC_CONTEXT } from "../../api/plugin-api";
import { RPCProtocol } from "../../api/rpc-protocol";

export class CommandRegistryMainImpl implements CommandRegistryMain {
private proxy: CommandRegistryExt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { interfaces } from 'inversify';
import { RPCProtocol } from '../api/rpc-protocol';
import { CommandRegistryMainImpl } from './command-registry-main';
import { PLUGIN_RPC_CONTEXT } from '../api/plugin-api';
import { QuickOpenMainImpl } from './quick-open-main';
import { RPCProtocol } from '../../api/rpc-protocol';
import { PLUGIN_RPC_CONTEXT } from '../../api/plugin-api';

export function setUpPluginApi(rpc: RPCProtocol, container: interfaces.Container): void {
const commandRegistryMain = new CommandRegistryMainImpl(rpc, container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { FrontendApplicationContribution, FrontendApplication } from "@theia/cor
import { MaybePromise, CommandContribution } from "@theia/core/lib/common";
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging';
import { PluginWorker } from './plugin-worker';
import { HostedPluginServer, hostedServicePath } from '../common/plugin-protocol';
import { HostedPluginSupport } from './hosted-plugin';
import { setUpPluginApi } from './main-context';
import { HostedPluginWatcher } from './hosted-plugin-watcher';
import { PluginApiFrontendContribution } from './plugin-api-frontend-contribution';
import { HostedPluginManagerClient } from "./hosted-plugin-manager-client";
import { HostedPluginSupport } from "../../hosted/browser/hosted-plugin";
import { HostedPluginWatcher } from "../../hosted/browser/hosted-plugin-watcher";
import { HostedPluginManagerClient } from "./plugin-manager-client";
import { PluginApiFrontendContribution } from "./plugin-frontend-contribution";
import { setUpPluginApi } from "./main-context";
import { HostedPluginServer, hostedServicePath } from "../../common/plugin-protocol";

export default new ContainerModule(bind => {
bind(PluginWorker).toSelf().inSingletonScope();
Expand Down
Loading

0 comments on commit 64903a3

Please sign in to comment.