@theia/plugin-ext 1.33.0-next.2 → 1.33.0-next.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/index.js +2 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/plugin-api-rpc-model.d.ts +78 -0
- package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc-model.js +17 -1
- package/lib/common/plugin-api-rpc-model.js.map +1 -1
- package/lib/common/plugin-api-rpc.d.ts +20 -7
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js +0 -2
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/plugin-protocol.d.ts +4 -4
- package/lib/common/plugin-protocol.d.ts.map +1 -1
- package/lib/common/proxy-handler.d.ts +66 -0
- package/lib/common/proxy-handler.d.ts.map +1 -0
- package/lib/common/proxy-handler.js +98 -0
- package/lib/common/proxy-handler.js.map +1 -0
- package/lib/common/reference-map.d.ts +8 -0
- package/lib/common/reference-map.d.ts.map +1 -0
- package/lib/common/reference-map.js +40 -0
- package/lib/common/reference-map.js.map +1 -0
- package/lib/common/rpc-protocol.d.ts +25 -51
- package/lib/common/rpc-protocol.d.ts.map +1 -1
- package/lib/common/rpc-protocol.js +126 -323
- package/lib/common/rpc-protocol.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin-watcher.d.ts +1 -1
- package/lib/hosted/browser/hosted-plugin-watcher.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin-watcher.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin.js +13 -8
- package/lib/hosted/browser/hosted-plugin.js.map +1 -1
- package/lib/hosted/browser/plugin-worker.d.ts.map +1 -1
- package/lib/hosted/browser/plugin-worker.js +14 -9
- package/lib/hosted/browser/plugin-worker.js.map +1 -1
- package/lib/hosted/browser/worker/worker-main.d.ts +1 -1
- package/lib/hosted/browser/worker/worker-main.d.ts.map +1 -1
- package/lib/hosted/browser/worker/worker-main.js +23 -22
- package/lib/hosted/browser/worker/worker-main.js.map +1 -1
- package/lib/hosted/node/hosted-plugin-process.d.ts +5 -4
- package/lib/hosted/node/hosted-plugin-process.d.ts.map +1 -1
- package/lib/hosted/node/hosted-plugin-process.js +20 -13
- package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
- package/lib/hosted/node/hosted-plugin-protocol.d.ts +22 -0
- package/lib/hosted/node/hosted-plugin-protocol.d.ts.map +1 -0
- package/lib/hosted/node/hosted-plugin-protocol.js +37 -0
- package/lib/hosted/node/hosted-plugin-protocol.js.map +1 -0
- package/lib/hosted/node/hosted-plugin.d.ts +1 -1
- package/lib/hosted/node/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/node/hosted-plugin.js.map +1 -1
- package/lib/hosted/node/plugin-host.d.ts +1 -1
- package/lib/hosted/node/plugin-host.d.ts.map +1 -1
- package/lib/hosted/node/plugin-host.js +10 -21
- package/lib/hosted/node/plugin-host.js.map +1 -1
- package/lib/hosted/node/plugin-service.d.ts +1 -1
- package/lib/hosted/node/plugin-service.d.ts.map +1 -1
- package/lib/hosted/node/plugin-service.js.map +1 -1
- package/lib/main/browser/file-system-main-impl.d.ts +1 -0
- package/lib/main/browser/file-system-main-impl.d.ts.map +1 -1
- package/lib/main/browser/file-system-main-impl.js +9 -2
- package/lib/main/browser/file-system-main-impl.js.map +1 -1
- package/lib/main/browser/languages-main.d.ts +1 -0
- package/lib/main/browser/languages-main.d.ts.map +1 -1
- package/lib/main/browser/languages-main.js +10 -0
- package/lib/main/browser/languages-main.js.map +1 -1
- package/lib/main/browser/main-context.d.ts.map +1 -1
- package/lib/main/browser/main-context.js +0 -3
- package/lib/main/browser/main-context.js.map +1 -1
- package/lib/main/browser/tasks-main.d.ts.map +1 -1
- package/lib/main/browser/tasks-main.js +13 -9
- package/lib/main/browser/tasks-main.js.map +1 -1
- package/lib/plugin/debug/debug-ext.d.ts +2 -1
- package/lib/plugin/debug/debug-ext.d.ts.map +1 -1
- package/lib/plugin/debug/debug-ext.js +10 -1
- package/lib/plugin/debug/debug-ext.js.map +1 -1
- package/lib/plugin/debug/plugin-debug-adapter-session.d.ts +6 -5
- package/lib/plugin/debug/plugin-debug-adapter-session.d.ts.map +1 -1
- package/lib/plugin/debug/plugin-debug-adapter-session.js +18 -4
- package/lib/plugin/debug/plugin-debug-adapter-session.js.map +1 -1
- package/lib/plugin/file-system-ext-impl.d.ts +2 -0
- package/lib/plugin/file-system-ext-impl.d.ts.map +1 -1
- package/lib/plugin/file-system-ext-impl.js +22 -5
- package/lib/plugin/file-system-ext-impl.js.map +1 -1
- package/lib/plugin/languages/inline-completion.d.ts +21 -0
- package/lib/plugin/languages/inline-completion.d.ts.map +1 -0
- package/lib/plugin/languages/inline-completion.js +94 -0
- package/lib/plugin/languages/inline-completion.js.map +1 -0
- package/lib/plugin/languages.d.ts +5 -2
- package/lib/plugin/languages.d.ts.map +1 -1
- package/lib/plugin/languages.js +16 -1
- package/lib/plugin/languages.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +107 -3
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/theming.d.ts.map +1 -1
- package/lib/plugin/theming.js +3 -0
- package/lib/plugin/theming.js.map +1 -1
- package/lib/plugin/type-converters.d.ts.map +1 -1
- package/lib/plugin/type-converters.js +6 -14
- package/lib/plugin/type-converters.js.map +1 -1
- package/lib/plugin/type-converters.spec.js +5 -4
- package/lib/plugin/type-converters.spec.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +149 -9
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +205 -32
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +25 -25
- package/src/common/index.ts +4 -0
- package/src/common/plugin-api-rpc-model.ts +96 -0
- package/src/common/plugin-api-rpc.ts +25 -7
- package/src/common/plugin-protocol.ts +4 -4
- package/src/common/proxy-handler.ts +126 -0
- package/src/common/reference-map.ts +38 -0
- package/src/common/rpc-protocol.ts +128 -401
- package/src/hosted/browser/hosted-plugin-watcher.ts +4 -3
- package/src/hosted/browser/hosted-plugin.ts +17 -8
- package/src/hosted/browser/plugin-worker.ts +16 -10
- package/src/hosted/browser/worker/worker-main.ts +25 -26
- package/src/hosted/node/hosted-plugin-process.ts +25 -16
- package/src/hosted/node/hosted-plugin-protocol.ts +49 -0
- package/src/hosted/node/hosted-plugin.ts +1 -1
- package/src/hosted/node/plugin-host.ts +11 -22
- package/src/hosted/node/plugin-service.ts +1 -1
- package/src/main/browser/file-system-main-impl.ts +12 -3
- package/src/main/browser/languages-main.ts +18 -1
- package/src/main/browser/main-context.ts +0 -4
- package/src/main/browser/tasks-main.ts +13 -9
- package/src/plugin/debug/debug-ext.ts +11 -2
- package/src/plugin/debug/plugin-debug-adapter-session.ts +17 -9
- package/src/plugin/file-system-ext-impl.ts +21 -5
- package/src/plugin/languages/inline-completion.ts +126 -0
- package/src/plugin/languages.ts +30 -3
- package/src/plugin/plugin-context.ts +142 -4
- package/src/plugin/theming.ts +3 -0
- package/src/plugin/type-converters.spec.ts +5 -4
- package/src/plugin/type-converters.ts +10 -12
- package/src/plugin/types-impl.ts +253 -27
|
@@ -838,7 +838,7 @@ export function buildFrontendModuleName(plugin: PluginPackage | PluginModel): st
|
|
|
838
838
|
|
|
839
839
|
export const HostedPluginClient = Symbol('HostedPluginClient');
|
|
840
840
|
export interface HostedPluginClient {
|
|
841
|
-
postMessage(pluginHost: string,
|
|
841
|
+
postMessage(pluginHost: string, buffer: Uint8Array): Promise<void>;
|
|
842
842
|
|
|
843
843
|
log(logPart: LogPart): void;
|
|
844
844
|
|
|
@@ -901,7 +901,7 @@ export interface HostedPluginServer extends JsonRpcServer<HostedPluginClient> {
|
|
|
901
901
|
|
|
902
902
|
getExtPluginAPI(): Promise<ExtPluginApi[]>;
|
|
903
903
|
|
|
904
|
-
onMessage(targetHost: string, message:
|
|
904
|
+
onMessage(targetHost: string, message: Uint8Array): Promise<void>;
|
|
905
905
|
|
|
906
906
|
}
|
|
907
907
|
|
|
@@ -944,9 +944,9 @@ export interface PluginServer {
|
|
|
944
944
|
export const ServerPluginRunner = Symbol('ServerPluginRunner');
|
|
945
945
|
export interface ServerPluginRunner {
|
|
946
946
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
947
|
-
acceptMessage(pluginHostId: string, jsonMessage:
|
|
947
|
+
acceptMessage(pluginHostId: string, jsonMessage: Uint8Array): boolean;
|
|
948
948
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
949
|
-
onMessage(pluginHostId: string, jsonMessage:
|
|
949
|
+
onMessage(pluginHostId: string, jsonMessage: Uint8Array): void;
|
|
950
950
|
setClient(client: HostedPluginClient): void;
|
|
951
951
|
setDefault(defaultRunner: ServerPluginRunner): void;
|
|
952
952
|
clientClosed(): void;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2022 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
|
+
import { Channel, RpcProtocol, RpcProtocolOptions } from '@theia/core/';
|
|
18
|
+
import { RpcMessageDecoder, RpcMessageEncoder } from '@theia/core/lib/common/message-rpc/rpc-message-encoder';
|
|
19
|
+
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
20
|
+
|
|
21
|
+
export interface RpcHandlerOptions {
|
|
22
|
+
id: string
|
|
23
|
+
encoder: RpcMessageEncoder,
|
|
24
|
+
decoder: RpcMessageDecoder
|
|
25
|
+
}
|
|
26
|
+
export interface ProxyHandlerOptions extends RpcHandlerOptions {
|
|
27
|
+
channelProvider: () => Promise<Channel>,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface InvocationHandlerOptions extends RpcHandlerOptions {
|
|
31
|
+
target: any
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A proxy handler that will send any method invocation on the proxied object
|
|
35
|
+
* as a rcp protocol message over a channel.
|
|
36
|
+
*/
|
|
37
|
+
export class ClientProxyHandler<T extends object> implements ProxyHandler<T> {
|
|
38
|
+
private rpcDeferred: Deferred<RpcProtocol> = new Deferred();
|
|
39
|
+
private isRpcInitialized = false;
|
|
40
|
+
|
|
41
|
+
readonly id: string;
|
|
42
|
+
private readonly channelProvider: () => Promise<Channel>;
|
|
43
|
+
private readonly encoder: RpcMessageEncoder;
|
|
44
|
+
private readonly decoder: RpcMessageDecoder;
|
|
45
|
+
|
|
46
|
+
constructor(options: ProxyHandlerOptions) {
|
|
47
|
+
Object.assign(this, options);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private initializeRpc(): void {
|
|
51
|
+
const clientOptions: RpcProtocolOptions = { encoder: this.encoder, decoder: this.decoder, mode: 'clientOnly' };
|
|
52
|
+
this.channelProvider().then(channel => {
|
|
53
|
+
const rpc = new RpcProtocol(channel, undefined, clientOptions);
|
|
54
|
+
this.rpcDeferred.resolve(rpc);
|
|
55
|
+
this.isRpcInitialized = true;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
get(target: any, name: string, receiver: any): any {
|
|
60
|
+
if (!this.isRpcInitialized) {
|
|
61
|
+
this.initializeRpc();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (target[name] || name.charCodeAt(0) !== 36 /* CharCode.DollarSign */) {
|
|
65
|
+
return target[name];
|
|
66
|
+
}
|
|
67
|
+
const isNotify = this.isNotification(name);
|
|
68
|
+
return (...args: any[]) => {
|
|
69
|
+
const method = name.toString();
|
|
70
|
+
return this.rpcDeferred.promise.then(async (connection: RpcProtocol) => {
|
|
71
|
+
if (isNotify) {
|
|
72
|
+
connection.sendNotification(method, args);
|
|
73
|
+
} else {
|
|
74
|
+
return await connection.sendRequest(method, args) as Promise<any>;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Return whether the given property represents a notification. If true,
|
|
82
|
+
* the promise returned from the invocation will resolve immediately to `undefined`
|
|
83
|
+
*
|
|
84
|
+
* A property leads to a notification rather than a method call if its name
|
|
85
|
+
* begins with `notify` or `on`.
|
|
86
|
+
*
|
|
87
|
+
* @param p - The property being called on the proxy.
|
|
88
|
+
* @return Whether `p` represents a notification.
|
|
89
|
+
*/
|
|
90
|
+
protected isNotification(p: PropertyKey): boolean {
|
|
91
|
+
let propertyString = p.toString();
|
|
92
|
+
if (propertyString.charCodeAt(0) === 36/* CharCode.DollarSign */) {
|
|
93
|
+
propertyString = propertyString.substring(1);
|
|
94
|
+
}
|
|
95
|
+
return propertyString.startsWith('notify') || propertyString.startsWith('on');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class RpcInvocationHandler {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
readonly target: any;
|
|
102
|
+
|
|
103
|
+
private rpcDeferred: Deferred<RpcProtocol> = new Deferred();
|
|
104
|
+
private readonly encoder: RpcMessageEncoder;
|
|
105
|
+
private readonly decoder: RpcMessageDecoder;
|
|
106
|
+
|
|
107
|
+
constructor(options: InvocationHandlerOptions) {
|
|
108
|
+
Object.assign(this, options);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
listen(channel: Channel): void {
|
|
112
|
+
const serverOptions: RpcProtocolOptions = { encoder: this.encoder, decoder: this.decoder, mode: 'serverOnly' };
|
|
113
|
+
const server = new RpcProtocol(channel, (method: string, args: any[]) => this.handleRequest(method, args), serverOptions);
|
|
114
|
+
server.onNotification((e: { method: string, args: any }) => this.onNotification(e.method, e.args));
|
|
115
|
+
this.rpcDeferred.resolve(server);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
protected handleRequest(method: string, args: any[]): Promise<any> {
|
|
119
|
+
return this.rpcDeferred.promise.then(() => this.target[method](...args));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
protected onNotification(method: string, args: any[]): void {
|
|
123
|
+
this.target[method](...args);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
// copied from hhttps://github.com/microsoft/vscode/blob/6261075646f055b99068d3688932416f2346dd3b/src/vs/workbench/api/common/extHostLanguageFeatures.ts#L1291-L1310.
|
|
18
|
+
|
|
19
|
+
export class ReferenceMap<T> {
|
|
20
|
+
private readonly _references = new Map<number, T>();
|
|
21
|
+
private _idPool = 1;
|
|
22
|
+
|
|
23
|
+
createReferenceId(value: T): number {
|
|
24
|
+
const id = this._idPool++;
|
|
25
|
+
this._references.set(id, value);
|
|
26
|
+
return id;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
disposeReferenceId(referenceId: number): T | undefined {
|
|
30
|
+
const value = this._references.get(referenceId);
|
|
31
|
+
this._references.delete(referenceId);
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get(referenceId: number): T | undefined {
|
|
36
|
+
return this._references.get(referenceId);
|
|
37
|
+
}
|
|
38
|
+
}
|