Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Plug-in System #2007

Merged
merged 40 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a3595b6
POC of the new Plug-in System
evidolob Apr 10, 2018
b5e366d
Cleanup the code, registerPlugin being handled differently now
benoitf Apr 9, 2018
07757fe
Remove main entry from the module: there is no export from this modul…
benoitf Apr 11, 2018
d553999
Add alias for plugin package
benoitf Apr 12, 2018
42620dd
eclipse/che#9286 introduce quick pick api
evidolob Apr 13, 2018
501759d
Add test file to enable tests
benoitf Apr 13, 2018
57bdceb
Theia plugin metadata (#1)
akurinnoy Apr 20, 2018
0ea0c90
Add Hosted Plugin Manager
mmorhun Apr 23, 2018
c26a493
split plugin module in two : one module for API, one module for the e…
benoitf Apr 24, 2018
25eb1b1
Handle blocking of opening of new tab
mmorhun Apr 25, 2018
a735801
Split hosted and main part in two folders (#7)
benoitf Apr 25, 2018
b1c9b8d
move some files related to plugin API implementation to 'plugin' folder
evidolob Apr 27, 2018
738e6f0
Fix code based on upstream changes
benoitf Apr 27, 2018
a2e0db2
Sync with upstream
benoitf May 2, 2018
60deb06
Add notification manager API (#2)
olexii4 May 7, 2018
34d8f41
Make plugin-ext npm module (#12)
mmorhun May 8, 2018
50a9ed7
Handle the deployment with deployers (#11)
benoitf May 11, 2018
c92853d
Split vscode into a new module
benoitf May 11, 2018
77cd3d7
Make HostedPluginUriPostProcessor symbol global (#15)
mmorhun May 15, 2018
13d8a0c
Add dev dependency to @theia/plugin module from @theia/plugin-ext (#16)
mmorhun May 16, 2018
8cb59d9
Moves @theia/plugin dependency from dev to main
mmorhun May 16, 2018
4443d59
Add support for plugins hosted on github repository in releases secti…
benoitf May 17, 2018
f1004f1
Add support for vscode:extension/ resolver and http(s):// resolver (#19)
benoitf May 17, 2018
44a46a9
Use process tree to shutdown Theia instance (#10)
mmorhun May 22, 2018
c3fd269
Add window state API (#21)
mmorhun May 22, 2018
9b5432c
Introduce a command to deploy on the fly a plugin into Theia (#22)
benoitf May 29, 2018
40e0148
CHE-9494 add the status bar API
olexii4 May 29, 2018
3f94e8e
fix dependency
olexii4 May 31, 2018
e639dd4
code cleanup
olexii4 May 31, 2018
7b90da6
avoid Shadowed variable
benoitf Jun 4, 2018
612b21a
merge with upstream changes with maxListener on events
benoitf Jun 4, 2018
d0ca188
UI for manage Theia development mode (#13)
Jun 6, 2018
823b1e4
Add dialog window to ask user if opening of a new tab is blocked by b…
mmorhun Jun 6, 2018
6d059a8
Fix problem with stopping instance of hosted plugin (#27)
Jun 7, 2018
df13fb7
eclipse/che#9434 implement all editor objects (#28)
evidolob Jun 11, 2018
d5edd8b
Update to 0.3.11 version
benoitf Jun 13, 2018
d1ec795
CHE-9845: Introduce new namespace for current environment in Plugins …
mmorhun Jun 13, 2018
9af4333
Add Preference API (#30)
akurinnoy Jun 18, 2018
ad0f594
Add editor life cycle methods: open, save and close (#31)
evidolob Jun 18, 2018
b9a2ee8
CHE-9836 add output channel API (#32)
olexii4 Jun 19, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ cache:
- packages/navigator/node_modules
- packages/outline-view/node_modules
- packages/output/node_modules
- packages/plugin/node_modules
- packages/plugin-ext/node_modules
- packages/preferences/node_modules
- packages/preview/node_modules
- packages/process/node_modules
Expand Down
3 changes: 2 additions & 1 deletion dev-packages/application-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"umd-compat-loader": "^2.1.1",
"url-loader": "^1.0.1",
"webpack": "^4.0.0",
"webpack-cli": "2.0.12"
"webpack-cli": "2.0.12",
"worker-loader": "^1.1.1"
},
"devDependencies": {
"@theia/ext-scripts": "^0.3.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ module.exports = {
},
module: {
rules: [
{
test: /worker-main\\.js$/,
loader: 'worker-loader',
options: {
name: 'worker-ext.[hash].js'
}
},
{
test: /\\.css$/,
exclude: /\\.useable\\.css$/,
Expand Down
2 changes: 2 additions & 0 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"@theia/navigator": "^0.3.11",
"@theia/outline-view": "^0.3.11",
"@theia/output": "^0.3.11",
"@theia/plugin-ext": "^0.3.11",
"@theia/plugin-ext-vscode": "^0.3.11",
"@theia/preferences": "^0.3.11",
"@theia/preview": "^0.3.11",
"@theia/process": "^0.3.11",
Expand Down
2 changes: 2 additions & 0 deletions examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"@theia/navigator": "^0.3.11",
"@theia/outline-view": "^0.3.11",
"@theia/output": "^0.3.11",
"@theia/plugin-ext": "^0.3.11",
"@theia/plugin-ext-vscode": "^0.3.11",
"@theia/preferences": "^0.3.11",
"@theia/preview": "^0.3.11",
"@theia/process": "^0.3.11",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/browser/preferences/preference-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export class PreferenceServiceImpl implements PreferenceService, FrontendApplica
}
}

getPreferences(): { [key: string]: any } {
return this.preferences;
}

has(preferenceName: string): boolean {
return this.preferences[preferenceName] !== undefined;
}
Expand Down
16 changes: 16 additions & 0 deletions packages/plugin-ext-vscode/compile.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../configs/base.tsconfig",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib",
"lib": [
"es6",
"dom",
"webworker"
]
},
"include": [
"src"
]
}

46 changes: 46 additions & 0 deletions packages/plugin-ext-vscode/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@theia/plugin-ext-vscode",
"version": "0.3.11",
"description": "Theia - Plugin Extension for VsCode",
"dependencies": {
"@theia/plugin-ext": "^0.3.11"
},
"publishConfig": {
"access": "public"
},
"theiaExtensions": [
{
"backend": "lib/node/plugin-vscode-backend-module"
}
],
"keywords": [
"theia-extension"
],
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/theia-ide/theia.git"
},
"bugs": {
"url": "https://github.com/theia-ide/theia/issues"
},
"homepage": "https://github.com/theia-ide/theia",
"files": [
"lib",
"src"
],
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "theiaext clean",
"build": "theiaext build",
"watch": "theiaext watch",
"test": "theiaext test",
"docs": "theiaext docs"
},
"devDependencies": {
"@theia/ext-scripts": "^0.3.11"
},
"nyc": {
"extends": "../../configs/nyc.json"
}
}
20 changes: 20 additions & 0 deletions packages/plugin-ext-vscode/src/node/package.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2018 Red Hat, Inc. and others.
*
* 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
*/

/* note: this bogus test file is required so that
we are able to run mocha unit tests on this
package, without having any actual unit tests in it.
This way a coverage report will be generated,
showing 0% coverage, instead of no report.
This file can be removed once we have real unit
tests in place. */

describe("plugin-ext-vscode package", () => {

it("support code coverage statistics", () =>
true);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2018 Red Hat, Inc. and others.
*
* 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 { ContainerModule } from 'inversify';
import { PluginDeployerFileHandler, PluginDeployerDirectoryHandler, PluginScanner, PluginDeployerResolver } from "@theia/plugin-ext";
import { PluginVsCodeFileHandler } from "./plugin-vscode-file-handler";
import { PluginVsCodeDirectoryHandler } from "./plugin-vscode-directory-handler";
import { VsCodePluginScanner } from "./scanner-vscode";
import { VsCodePluginDeployerResolver } from './plugin-vscode-resolver';

export default new ContainerModule(bind => {
bind(PluginDeployerFileHandler).to(PluginVsCodeFileHandler).inSingletonScope();
bind(PluginDeployerDirectoryHandler).to(PluginVsCodeDirectoryHandler).inSingletonScope();
bind(PluginScanner).to(VsCodePluginScanner).inSingletonScope();
bind(PluginDeployerResolver).to(VsCodePluginDeployerResolver).inSingletonScope();
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2018 Red Hat, Inc. and others.
*
* 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 {
PluginDeployerDirectoryHandler,
PluginDeployerEntry, PluginPackage, PluginDeployerDirectoryHandlerContext,
PluginDeployerEntryType
} from "@theia/plugin-ext";
import { injectable } from "inversify";
import * as fs from "fs";
import * as path from "path";

@injectable()
export class PluginVsCodeDirectoryHandler implements PluginDeployerDirectoryHandler {

accept(resolvedPlugin: PluginDeployerEntry): boolean {

console.log('PluginTheiaDirectoryHandler: accepting plugin with path', resolvedPlugin.path());

// handle only directories
if (resolvedPlugin.isFile()) {
return false;
}

// is there a extension.vsixmanifest and extension folder
const extensionVsixManifestPath = path.resolve(resolvedPlugin.path(), 'extension.vsixmanifest');
const existsExtensionVsixManifest: boolean = fs.existsSync(extensionVsixManifestPath);
if (!existsExtensionVsixManifest) {
return false;
}

const extensionPath = path.resolve(resolvedPlugin.path(), 'extension');
const existsExtension: boolean = fs.existsSync(extensionPath);
if (!existsExtension) {
return false;
}

// is there a package.json ?
const packageJsonPath = path.resolve(extensionPath, 'package.json');
const existsPackageJson: boolean = fs.existsSync(packageJsonPath);
if (!existsPackageJson) {
return false;
}

let packageJson: PluginPackage = resolvedPlugin.getValue('package.json');
if (!packageJson) {
packageJson = require(packageJsonPath);
resolvedPlugin.storeValue('package.json', packageJson);
}

if (!packageJson.engines) {
return false;
}

if (packageJson.engines && packageJson.engines.vscode) {
console.log("accepting packagejson with engines", packageJson.engines);
return true;
}

return false;

}

handle(context: PluginDeployerDirectoryHandlerContext): Promise<any> {
const packageJson: PluginPackage = context.pluginEntry().getValue('package.json');
if (packageJson.main) {
context.pluginEntry().accept(PluginDeployerEntryType.BACKEND);
}

const extensionPath = path.resolve(context.pluginEntry().path(), 'extension');
context.pluginEntry().updatePath(extensionPath);

return Promise.resolve(true);
}
}
35 changes: 35 additions & 0 deletions packages/plugin-ext-vscode/src/node/plugin-vscode-file-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2018 Red Hat, Inc. and others.
*
* 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 { PluginDeployerFileHandler, PluginDeployerEntry, PluginDeployerFileHandlerContext } from "@theia/plugin-ext";
import { injectable } from "inversify";
import * as os from "os";
import * as path from "path";

@injectable()
export class PluginVsCodeFileHandler implements PluginDeployerFileHandler {

private unpackedFolder: string;
constructor() {
this.unpackedFolder = path.resolve(os.tmpdir(), 'vscode-unpacked');
}

accept(resolvedPlugin: PluginDeployerEntry): boolean {
return resolvedPlugin.isFile() && resolvedPlugin.path() !== null && resolvedPlugin.path().endsWith(".vsix");
}

async handle(context: PluginDeployerFileHandlerContext): Promise<void> {
// need to unzip
console.log('unzipping the plugin', context.pluginEntry());

const unpackedPath = path.resolve(this.unpackedFolder, path.basename(context.pluginEntry().path()));
await context.unzip(context.pluginEntry().path(), unpackedPath);

context.pluginEntry().updatePath(unpackedPath);
return Promise.resolve();
}
}
58 changes: 58 additions & 0 deletions packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2018 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

import { BackendInitializationFn, createAPI, PluginMetadata } from '@theia/plugin-ext';

export const doInitialization: BackendInitializationFn = (rpc: any, pluginMetadata: PluginMetadata) => {
const module = require('module');
const vscodeModuleName = 'vscode';
const vscode = createAPI(rpc);

// register the commands that are in the package.json file
const contributes: any = pluginMetadata.source.contributes;
if (contributes && contributes.commands) {
contributes.commands.forEach((commandItem: any) => {
vscode.commands.registerCommand({ id: commandItem.command, label: commandItem.title });
});
}

// replace command API as it will send only the ID as a string parameter
vscode.commands.registerCommand = function registerCommand(command: any, handler?: <T>(...args: any[]) => T | Thenable<T>): any {
// use of the ID when registering commands
if (typeof command === 'string' && handler) {
return vscode.commands.registerHandler(command, handler);
}
};

// add theia into global goal as 'vscode'
const g = global as any;
g[vscodeModuleName] = vscode;

// add vscode object as module into npm cache
require.cache[vscodeModuleName] = {
id: vscodeModuleName,
filename: vscodeModuleName,
loaded: true,
exports: g[vscodeModuleName]
};

// save original resolve method
const internalResolve = module._resolveFilename;

// if we try to resolve vscode module, return the filename entry to use cache.
module._resolveFilename = (request: string, parent: {}) => {
if (vscodeModuleName === request) {
return request;
}
const retVal = internalResolve(request, parent);
return retVal;
};
};
Loading