Skip to content

Commit

Permalink
Add env.uiKind API
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mäder <tmader@redhat.com>
  • Loading branch information
tsmaeder committed Jun 17, 2020
1 parent 0dce814 commit 93b19e5
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,24 @@ export interface ConfigStorage {
hostGlobalStoragePath: string;
}

export enum UIKind {

/**
* Extensions are accessed from a desktop application.
*/
Desktop = 1,

/**
* Extensions are accessed from a web browser.
*/
Web = 2
}

export interface EnvInit {
queryParams: QueryParameters;
language: string;
shell: string;
uiKind: UIKind,
appName: string;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { injectable, inject, interfaces, named, postConstruct } from 'inversify'
import { PluginWorker } from '../../main/browser/plugin-worker';
import { PluginMetadata, getPluginId, HostedPluginServer, DeployedPlugin } from '../../common/plugin-protocol';
import { HostedPluginWatcher } from './hosted-plugin-watcher';
import { MAIN_RPC_CONTEXT, PluginManagerExt, ConfigStorage } from '../../common/plugin-api-rpc';
import { MAIN_RPC_CONTEXT, PluginManagerExt, ConfigStorage, UIKind } from '../../common/plugin-api-rpc';
import { setUpPluginApi } from '../../main/browser/main-context';
import { RPCProtocol, RPCProtocolImpl } from '../../common/rpc-protocol';
import {
Expand Down Expand Up @@ -60,6 +60,7 @@ import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-servi
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
import URI from '@theia/core/lib/common/uri';
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
import { environment } from '@theia/application-package/lib/environment';

export type PluginHost = 'frontend' | string;
export type DebugActivationEvent = 'onDebugResolve' | 'onDebugInitialConfigurations' | 'onDebugAdapterProtocolTracker';
Expand Down Expand Up @@ -454,6 +455,7 @@ export class HostedPluginSupport {
queryParams: getQueryParameters(),
language: navigator.language,
shell: defaultShell,
uiKind: environment.electron.is() ? UIKind.Desktop : UIKind.Web,
appName: FrontendApplicationConfigProvider.get().applicationName
},
extApi,
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-ext/src/plugin/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export abstract class EnvExtImpl {
private lang: string;
private applicationName: string;
private defaultShell: string;
private ui: theia.UIKind;
private envMachineId: string;
private envSessionId: string;

Expand Down Expand Up @@ -68,6 +69,10 @@ export abstract class EnvExtImpl {
this.defaultShell = shell;
}

setUIKind(uiKind: theia.UIKind): void {
this.ui = uiKind;
}

getClientOperatingSystem(): Promise<theia.OperatingSystem> {
return this.proxy.$getClientOperatingSystem();
}
Expand All @@ -93,4 +98,7 @@ export abstract class EnvExtImpl {
get shell(): string {
return this.defaultShell;
}
get uiKind(): theia.UIKind {
return this.ui;
}
}
3 changes: 3 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import {
ColorPresentation,
OperatingSystem,
WebviewPanelTargetArea,
UIKind,
FileSystemError,
CommentThreadCollapsibleState,
QuickInputButtons,
Expand Down Expand Up @@ -510,6 +511,7 @@ export function createAPIFactory(
get sessionId(): string { return envExt.sessionId; },
get uriScheme(): string { return envExt.uriScheme; },
get shell(): string { return envExt.shell; },
get uiKind(): theia.UIKind { return envExt.uiKind; },
clipboard,
getEnvVariable(envVarName: string): PromiseLike<string | undefined> {
return envExt.getEnvVariable(envVarName);
Expand Down Expand Up @@ -876,6 +878,7 @@ export function createAPIFactory(
FoldingRangeKind,
OperatingSystem,
WebviewPanelTargetArea,
UIKind,
FileSystemError,
CommentThreadCollapsibleState,
QuickInputButtons,
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-ext/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
this.envExt.setQueryParameters(params.env.queryParams);
this.envExt.setLanguage(params.env.language);
this.envExt.setShell(params.env.shell);
this.envExt.setUIKind(params.env.uiKind);
this.envExt.setApplicationName(params.env.appName);

this.preferencesManager.init(params.preferences);
Expand Down
17 changes: 17 additions & 0 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,23 @@ export enum WebviewPanelTargetArea {
Right = 'right',
Bottom = 'bottom'
}

/**
* Possible kinds of UI that can use extensions.
*/
export enum UIKind {

/**
* Extensions are accessed from a desktop application.
*/
Desktop = 1,

/**
* Extensions are accessed from a web browser.
*/
Web = 2
}

export class CallHierarchyItem {
_sessionId?: string;
_itemId?: string;
Expand Down
23 changes: 23 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3150,6 +3150,22 @@ declare module '@theia/plugin' {
writeText(value: string): PromiseLike<void>;
}

/**
* Possible kinds of UI that can use extensions.
*/
export enum UIKind {

/**
* Extensions are accessed from a desktop application.
*/
Desktop = 1,

/**
* Extensions are accessed from a web browser.
*/
Web = 2
}

/**
* A uri handler is responsible for handling system-wide [uris](#Uri).
*
Expand Down Expand Up @@ -5295,6 +5311,13 @@ declare module '@theia/plugin' {
*/
export const shell: string;

/**
* The UI kind property indicates from which UI extensions
* are accessed from. For example, extensions could be accessed
* from a desktop application or a web browser.
*/
export const uiKind: UIKind;

/**
* The system clipboard.
*/
Expand Down

0 comments on commit 93b19e5

Please sign in to comment.