deploy: current vibn theia state
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2024 EclipseSource and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
|
||||
import { PluginDeployerDirectoryHandlerContext, PluginDeployerEntryType, PluginPackage } from '@theia/plugin-ext';
|
||||
import { AbstractPluginDirectoryHandler } from '@theia/plugin-ext/lib/main/node/handlers/plugin-theia-directory-handler';
|
||||
|
||||
@injectable()
|
||||
export class PluginTheiaHeadlessDirectoryHandler extends AbstractPluginDirectoryHandler {
|
||||
|
||||
protected acceptManifest(plugin: PluginPackage): boolean {
|
||||
return plugin?.engines?.theiaPlugin === undefined && 'theiaHeadlessPlugin' in plugin.engines;
|
||||
}
|
||||
|
||||
async handle(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
|
||||
await this.copyDirectory(context);
|
||||
const types: PluginDeployerEntryType[] = [PluginDeployerEntryType.HEADLESS];
|
||||
context.pluginEntry().accept(...types);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2024 EclipseSource and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import {
|
||||
CancellationToken,
|
||||
ProgressClient, ProgressMessage, ProgressUpdate
|
||||
} from '@theia/core';
|
||||
|
||||
/**
|
||||
* A simple progress client for headless plugins that just writes debug messages to the console
|
||||
* because there is no one connected frontend to which it is appropriate to send the messages.
|
||||
*/
|
||||
@injectable()
|
||||
export class HeadlessProgressClient implements ProgressClient {
|
||||
async showProgress(_progressId: string, message: ProgressMessage, cancellationToken: CancellationToken): Promise<string | undefined> {
|
||||
if (cancellationToken.isCancellationRequested) {
|
||||
return ProgressMessage.Cancel;
|
||||
}
|
||||
console.debug(message.text);
|
||||
}
|
||||
|
||||
async reportProgress(_progressId: string, update: ProgressUpdate, message: ProgressMessage, cancellationToken: CancellationToken): Promise<void> {
|
||||
if (cancellationToken.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const progress = update.work && update.work.total ? `[${100 * Math.min(update.work.done, update.work.total) / update.work.total}%]` : '';
|
||||
const text = `${progress} ${update.message ?? 'completed ...'}`;
|
||||
console.debug(text);
|
||||
}
|
||||
}
|
||||
35
packages/plugin-ext-headless/src/main/node/main-context.ts
Normal file
35
packages/plugin-ext-headless/src/main/node/main-context.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2024 EclipseSource and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
import { interfaces } from '@theia/core/shared/inversify';
|
||||
import { RPCProtocol } from '@theia/plugin-ext/lib/common/rpc-protocol';
|
||||
import { EnvMainImpl } from '@theia/plugin-ext/lib/main/common/env-main';
|
||||
import { BasicMessageRegistryMainImpl } from '@theia/plugin-ext/lib/main/common/basic-message-registry-main';
|
||||
import { BasicNotificationMainImpl } from '@theia/plugin-ext/lib/main/common/basic-notification-main';
|
||||
|
||||
import { HEADLESSMAIN_RPC_CONTEXT, HEADLESSPLUGIN_RPC_CONTEXT } from '../../common/headless-plugin-rpc';
|
||||
|
||||
// This sets up only the minimal plugin API required by the plugin manager to report
|
||||
// messages and notifications to the main side and to initialize plugins.
|
||||
export function setUpPluginApi(rpc: RPCProtocol, container: interfaces.Container): void {
|
||||
const envMain = new EnvMainImpl(rpc, container);
|
||||
rpc.set(HEADLESSPLUGIN_RPC_CONTEXT.ENV_MAIN, envMain);
|
||||
|
||||
const messageRegistryMain = new BasicMessageRegistryMainImpl(container);
|
||||
rpc.set(HEADLESSPLUGIN_RPC_CONTEXT.MESSAGE_REGISTRY_MAIN, messageRegistryMain);
|
||||
|
||||
const notificationMain = new BasicNotificationMainImpl(rpc, container, HEADLESSMAIN_RPC_CONTEXT.NOTIFICATION_EXT);
|
||||
rpc.set(HEADLESSPLUGIN_RPC_CONTEXT.NOTIFICATION_MAIN, notificationMain);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2024 EclipseSource and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
|
||||
import { interfaces } from '@theia/core/shared/inversify';
|
||||
import {
|
||||
MessageClient, MessageService,
|
||||
ProgressClient, ProgressService,
|
||||
bindContributionProvider
|
||||
} from '@theia/core';
|
||||
import { MainPluginApiProvider, PluginDeployerDirectoryHandler } from '@theia/plugin-ext';
|
||||
import { PluginTheiaHeadlessDirectoryHandler } from './handlers/plugin-theia-headless-directory-handler';
|
||||
import { HeadlessProgressClient } from './headless-progress-client';
|
||||
|
||||
export function bindHeadlessMain(bind: interfaces.Bind): void {
|
||||
bind(PluginDeployerDirectoryHandler).to(PluginTheiaHeadlessDirectoryHandler).inSingletonScope();
|
||||
}
|
||||
|
||||
export function bindBackendMain(bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind): void {
|
||||
bindContributionProvider(bind, MainPluginApiProvider);
|
||||
|
||||
//
|
||||
// Main API dependencies
|
||||
//
|
||||
|
||||
bind(MessageService).toSelf().inSingletonScope();
|
||||
bind(MessageClient).toSelf().inSingletonScope(); // Just logs to console
|
||||
bind(ProgressService).toSelf().inSingletonScope();
|
||||
bind(ProgressClient).to(HeadlessProgressClient).inSingletonScope();
|
||||
}
|
||||
Reference in New Issue
Block a user