@theia/plugin-ext 1.53.0-next.6 → 1.53.0-next.64
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/plugin-api-rpc.d.ts +16 -4
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js +4 -2
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/rpc-protocol.d.ts +14 -13
- package/lib/common/rpc-protocol.d.ts.map +1 -1
- package/lib/common/rpc-protocol.js +56 -53
- package/lib/common/rpc-protocol.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin.d.ts +1 -0
- package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin.js +13 -3
- package/lib/hosted/browser/hosted-plugin.js.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.js +13 -1
- package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
- package/lib/main/browser/authentication-main.d.ts +6 -5
- package/lib/main/browser/authentication-main.d.ts.map +1 -1
- package/lib/main/browser/authentication-main.js +15 -9
- package/lib/main/browser/authentication-main.js.map +1 -1
- package/lib/main/browser/custom-editors/custom-editor-opener.d.ts +9 -3
- package/lib/main/browser/custom-editors/custom-editor-opener.d.ts.map +1 -1
- package/lib/main/browser/custom-editors/custom-editor-opener.js +120 -31
- package/lib/main/browser/custom-editors/custom-editor-opener.js.map +1 -1
- package/lib/main/browser/custom-editors/custom-editor-widget.d.ts +7 -4
- package/lib/main/browser/custom-editors/custom-editor-widget.d.ts.map +1 -1
- package/lib/main/browser/custom-editors/custom-editor-widget.js +21 -7
- package/lib/main/browser/custom-editors/custom-editor-widget.js.map +1 -1
- package/lib/main/browser/custom-editors/custom-editors-main.d.ts +3 -4
- package/lib/main/browser/custom-editors/custom-editors-main.d.ts.map +1 -1
- package/lib/main/browser/custom-editors/custom-editors-main.js +5 -55
- package/lib/main/browser/custom-editors/custom-editors-main.js.map +1 -1
- package/lib/main/browser/custom-editors/plugin-custom-editor-registry.d.ts +4 -3
- package/lib/main/browser/custom-editors/plugin-custom-editor-registry.d.ts.map +1 -1
- package/lib/main/browser/custom-editors/plugin-custom-editor-registry.js +24 -16
- package/lib/main/browser/custom-editors/plugin-custom-editor-registry.js.map +1 -1
- package/lib/main/browser/editors-and-documents-main.d.ts.map +1 -1
- package/lib/main/browser/editors-and-documents-main.js +14 -2
- package/lib/main/browser/editors-and-documents-main.js.map +1 -1
- package/lib/main/browser/main-context.d.ts.map +1 -1
- package/lib/main/browser/main-context.js +3 -0
- package/lib/main/browser/main-context.js.map +1 -1
- package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
- package/lib/main/browser/menus/menus-contribution-handler.js +1 -1
- package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
- package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts +1 -0
- package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts.map +1 -1
- package/lib/main/browser/menus/plugin-menu-command-adapter.js +22 -1
- package/lib/main/browser/menus/plugin-menu-command-adapter.js.map +1 -1
- package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts +2 -2
- package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts.map +1 -1
- package/lib/main/browser/menus/vscode-theia-menu-mappings.js +2 -0
- package/lib/main/browser/menus/vscode-theia-menu-mappings.js.map +1 -1
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.d.ts.map +1 -1
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js +3 -1
- package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js.map +1 -1
- package/lib/main/browser/notebooks/notebook-documents-main.d.ts.map +1 -1
- package/lib/main/browser/notebooks/notebook-documents-main.js +22 -3
- package/lib/main/browser/notebooks/notebook-documents-main.js.map +1 -1
- package/lib/main/browser/notebooks/notebook-editors-main.d.ts +1 -1
- package/lib/main/browser/notebooks/notebook-editors-main.d.ts.map +1 -1
- package/lib/main/browser/notebooks/notebook-editors-main.js +16 -2
- package/lib/main/browser/notebooks/notebook-editors-main.js.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.js +18 -0
- package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
- package/lib/main/browser/tabs/tabs-main.d.ts +1 -1
- package/lib/main/browser/tabs/tabs-main.d.ts.map +1 -1
- package/lib/main/browser/tabs/tabs-main.js +1 -1
- package/lib/main/browser/tabs/tabs-main.js.map +1 -1
- package/lib/main/browser/text-editor-main.d.ts +6 -3
- package/lib/main/browser/text-editor-main.d.ts.map +1 -1
- package/lib/main/browser/text-editor-main.js +39 -5
- package/lib/main/browser/text-editor-main.js.map +1 -1
- package/lib/main/browser/uri-main.d.ts +16 -0
- package/lib/main/browser/uri-main.d.ts.map +1 -0
- package/lib/main/browser/uri-main.js +64 -0
- package/lib/main/browser/uri-main.js.map +1 -0
- package/lib/main/browser/webview/webview.d.ts +1 -3
- package/lib/main/browser/webview/webview.d.ts.map +1 -1
- package/lib/main/browser/webview/webview.js +5 -4
- package/lib/main/browser/webview/webview.js.map +1 -1
- package/lib/main/browser/webviews-main.d.ts.map +1 -1
- package/lib/main/browser/webviews-main.js +6 -1
- package/lib/main/browser/webviews-main.js.map +1 -1
- package/lib/plugin/authentication-ext.d.ts +3 -2
- package/lib/plugin/authentication-ext.d.ts.map +1 -1
- package/lib/plugin/authentication-ext.js +8 -5
- package/lib/plugin/authentication-ext.js.map +1 -1
- package/lib/plugin/custom-editors.d.ts +2 -4
- package/lib/plugin/custom-editors.d.ts.map +1 -1
- package/lib/plugin/custom-editors.js +5 -7
- package/lib/plugin/custom-editors.js.map +1 -1
- package/lib/plugin/env.d.ts +2 -0
- package/lib/plugin/env.d.ts.map +1 -1
- package/lib/plugin/env.js +4 -1
- package/lib/plugin/env.js.map +1 -1
- package/lib/plugin/known-commands.d.ts.map +1 -1
- package/lib/plugin/known-commands.js +1 -0
- package/lib/plugin/known-commands.js.map +1 -1
- package/lib/plugin/notebook/notebooks.d.ts +1 -0
- package/lib/plugin/notebook/notebooks.d.ts.map +1 -1
- package/lib/plugin/notebook/notebooks.js +22 -2
- package/lib/plugin/notebook/notebooks.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +17 -6
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/plugin/plugin-manager.js +2 -1
- package/lib/plugin/plugin-manager.js.map +1 -1
- package/lib/plugin/terminal-ext.d.ts +2 -0
- package/lib/plugin/terminal-ext.d.ts.map +1 -1
- package/lib/plugin/terminal-ext.js +2 -0
- package/lib/plugin/terminal-ext.js.map +1 -1
- package/lib/plugin/text-editor.d.ts +1 -1
- package/lib/plugin/text-editor.d.ts.map +1 -1
- package/lib/plugin/text-editor.js.map +1 -1
- package/lib/plugin/type-converters.d.ts +5 -0
- package/lib/plugin/type-converters.d.ts.map +1 -1
- package/lib/plugin/type-converters.js +24 -3
- package/lib/plugin/type-converters.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +5 -0
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +9 -1
- package/lib/plugin/types-impl.js.map +1 -1
- package/lib/plugin/uri-ext.d.ts +37 -0
- package/lib/plugin/uri-ext.d.ts.map +1 -0
- package/lib/plugin/uri-ext.js +50 -0
- package/lib/plugin/uri-ext.js.map +1 -0
- package/lib/plugin/webviews.js +1 -1
- package/lib/plugin/webviews.js.map +1 -1
- package/package.json +29 -29
- package/src/common/plugin-api-rpc.ts +21 -6
- package/src/common/rpc-protocol.ts +62 -66
- package/src/hosted/browser/hosted-plugin.ts +16 -5
- package/src/hosted/node/scanners/scanner-theia.ts +12 -1
- package/src/main/browser/authentication-main.ts +24 -11
- package/src/main/browser/custom-editors/custom-editor-opener.tsx +125 -25
- package/src/main/browser/custom-editors/custom-editor-widget.ts +20 -11
- package/src/main/browser/custom-editors/custom-editors-main.ts +11 -70
- package/src/main/browser/custom-editors/plugin-custom-editor-registry.ts +20 -14
- package/src/main/browser/editors-and-documents-main.ts +25 -2
- package/src/main/browser/main-context.ts +4 -0
- package/src/main/browser/menus/menus-contribution-handler.ts +2 -1
- package/src/main/browser/menus/plugin-menu-command-adapter.ts +22 -1
- package/src/main/browser/menus/vscode-theia-menu-mappings.ts +3 -1
- package/src/main/browser/notebooks/notebook-documents-and-editors-main.ts +5 -2
- package/src/main/browser/notebooks/notebook-documents-main.ts +24 -4
- package/src/main/browser/notebooks/notebook-editors-main.ts +15 -2
- package/src/main/browser/plugin-ext-frontend-module.ts +23 -4
- package/src/main/browser/tabs/tabs-main.ts +6 -2
- package/src/main/browser/text-editor-main.ts +55 -14
- package/src/main/browser/uri-main.ts +72 -0
- package/src/main/browser/webview/pre/service-worker.js +2 -1
- package/src/main/browser/webview/webview.ts +5 -6
- package/src/main/browser/webviews-main.ts +6 -1
- package/src/plugin/authentication-ext.ts +9 -5
- package/src/plugin/custom-editors.ts +8 -10
- package/src/plugin/env.ts +6 -1
- package/src/plugin/known-commands.ts +1 -0
- package/src/plugin/notebook/notebooks.ts +21 -0
- package/src/plugin/plugin-context.ts +19 -8
- package/src/plugin/plugin-manager.ts +2 -1
- package/src/plugin/terminal-ext.ts +3 -0
- package/src/plugin/text-editor.ts +1 -1
- package/src/plugin/type-converters.ts +20 -0
- package/src/plugin/types-impl.ts +10 -0
- package/src/plugin/uri-ext.ts +60 -0
- package/src/plugin/webviews.ts +1 -1
- package/lib/common/proxy-handler.d.ts +0 -73
- package/lib/common/proxy-handler.d.ts.map +0 -1
- package/lib/common/proxy-handler.js +0 -106
- package/lib/common/proxy-handler.js.map +0 -1
- package/src/common/proxy-handler.ts +0 -143
|
@@ -97,6 +97,13 @@ export class NotebooksExtImpl implements NotebooksExt {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
|
+
|
|
101
|
+
textDocumentsAndEditors.onDidChangeActiveTextEditor(e => {
|
|
102
|
+
if (e && e?.document.uri.scheme !== CellUri.cellUriScheme && this.activeNotebookEditor) {
|
|
103
|
+
this.activeNotebookEditor = undefined;
|
|
104
|
+
this.onDidChangeActiveNotebookEditorEmitter.fire(undefined);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
async $provideNotebookCellStatusBarItems(handle: number, uri: UriComponents, index: number, token: CancellationToken): Promise<NotebookCellStatusBarListDto | undefined> {
|
|
@@ -131,6 +138,15 @@ export class NotebooksExtImpl implements NotebooksExt {
|
|
|
131
138
|
this.statusBarRegistry.delete(cacheId);
|
|
132
139
|
}
|
|
133
140
|
|
|
141
|
+
$acceptActiveCellEditorChange(newActiveEditor: string | null): void {
|
|
142
|
+
const newActiveEditorId = this.textDocumentsAndEditors.allEditors().find(editor => editor.document.uri.toString() === newActiveEditor)?.id;
|
|
143
|
+
if (newActiveEditorId || newActiveEditor === null) {
|
|
144
|
+
this.textDocumentsAndEditors.acceptEditorsAndDocumentsDelta({
|
|
145
|
+
newActiveEditor: newActiveEditorId ?? null
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
134
150
|
// --- serialize/deserialize
|
|
135
151
|
|
|
136
152
|
private currentSerializerHandle = 0;
|
|
@@ -319,6 +335,11 @@ export class NotebooksExtImpl implements NotebooksExt {
|
|
|
319
335
|
console.error(`FAILED to find active notebook editor ${delta.newActiveEditor}`);
|
|
320
336
|
}
|
|
321
337
|
this.activeNotebookEditor = this.editors.get(delta.newActiveEditor);
|
|
338
|
+
if (this.textDocumentsAndEditors.activeEditor()?.document.uri.path !== this.activeNotebookEditor?.notebookData.uri.path) {
|
|
339
|
+
this.textDocumentsAndEditors.acceptEditorsAndDocumentsDelta({
|
|
340
|
+
newActiveEditor: null
|
|
341
|
+
});
|
|
342
|
+
}
|
|
322
343
|
}
|
|
323
344
|
if (delta.newActiveEditor !== undefined) {
|
|
324
345
|
this.onDidChangeActiveNotebookEditorEmitter.fire(this.activeNotebookEditor?.apiEditor);
|
|
@@ -228,7 +228,8 @@ import {
|
|
|
228
228
|
LanguageModelError,
|
|
229
229
|
PortAutoForwardAction,
|
|
230
230
|
PortAttributes,
|
|
231
|
-
DebugVisualization
|
|
231
|
+
DebugVisualization,
|
|
232
|
+
TerminalShellExecutionCommandLineConfidence
|
|
232
233
|
} from './types-impl';
|
|
233
234
|
import { AuthenticationExtImpl } from './authentication-ext';
|
|
234
235
|
import { SymbolKind } from '../common/plugin-api-rpc-model';
|
|
@@ -275,6 +276,7 @@ import { NotebookKernelsExtImpl } from './notebook/notebook-kernels';
|
|
|
275
276
|
import { NotebookDocumentsExtImpl } from './notebook/notebook-documents';
|
|
276
277
|
import { NotebookEditorsExtImpl } from './notebook/notebook-editors';
|
|
277
278
|
import { TestingExtImpl } from './tests';
|
|
279
|
+
import { UriExtImpl } from './uri-ext';
|
|
278
280
|
|
|
279
281
|
export function createAPIFactory(
|
|
280
282
|
rpc: RPCProtocol,
|
|
@@ -319,10 +321,11 @@ export function createAPIFactory(
|
|
|
319
321
|
const themingExt = rpc.set(MAIN_RPC_CONTEXT.THEMING_EXT, new ThemingExtImpl(rpc));
|
|
320
322
|
const commentsExt = rpc.set(MAIN_RPC_CONTEXT.COMMENTS_EXT, new CommentsExtImpl(rpc, commandRegistry, documents));
|
|
321
323
|
const tabsExt = rpc.set(MAIN_RPC_CONTEXT.TABS_EXT, new TabsExtImpl(rpc));
|
|
322
|
-
const customEditorExt = rpc.set(MAIN_RPC_CONTEXT.CUSTOM_EDITORS_EXT, new CustomEditorsExtImpl(rpc, documents, webviewExt
|
|
324
|
+
const customEditorExt = rpc.set(MAIN_RPC_CONTEXT.CUSTOM_EDITORS_EXT, new CustomEditorsExtImpl(rpc, documents, webviewExt));
|
|
323
325
|
const webviewViewsExt = rpc.set(MAIN_RPC_CONTEXT.WEBVIEW_VIEWS_EXT, new WebviewViewsExtImpl(rpc, webviewExt));
|
|
324
326
|
const telemetryExt = rpc.set(MAIN_RPC_CONTEXT.TELEMETRY_EXT, new TelemetryExtImpl());
|
|
325
327
|
const testingExt = rpc.set(MAIN_RPC_CONTEXT.TESTING_EXT, new TestingExtImpl(rpc, commandRegistry));
|
|
328
|
+
const uriExt = rpc.set(MAIN_RPC_CONTEXT.URI_EXT, new UriExtImpl(rpc));
|
|
326
329
|
rpc.set(MAIN_RPC_CONTEXT.DEBUG_EXT, debugExt);
|
|
327
330
|
|
|
328
331
|
return function (plugin: InternalPlugin): typeof theia {
|
|
@@ -335,6 +338,9 @@ export function createAPIFactory(
|
|
|
335
338
|
},
|
|
336
339
|
get onDidChangeSessions(): theia.Event<theia.AuthenticationSessionsChangeEvent> {
|
|
337
340
|
return authenticationExt.onDidChangeSessions;
|
|
341
|
+
},
|
|
342
|
+
getAccounts(providerId: string): Thenable<readonly theia.AuthenticationSessionAccountInformation[]> {
|
|
343
|
+
return authenticationExt.getAccounts(providerId);
|
|
338
344
|
}
|
|
339
345
|
};
|
|
340
346
|
function commandIsDeclaredInPackage(id: string, model: PluginPackage): boolean {
|
|
@@ -595,8 +601,7 @@ export function createAPIFactory(
|
|
|
595
601
|
return decorationsExt.registerFileDecorationProvider(provider, pluginToPluginInfo(plugin));
|
|
596
602
|
},
|
|
597
603
|
registerUriHandler(handler: theia.UriHandler): theia.Disposable {
|
|
598
|
-
|
|
599
|
-
return new Disposable(() => { });
|
|
604
|
+
return uriExt.registerUriHandler(handler, pluginToPluginInfo(plugin));
|
|
600
605
|
},
|
|
601
606
|
createInputBox(): theia.InputBox {
|
|
602
607
|
return quickOpenExt.createInputBox(plugin);
|
|
@@ -636,6 +641,12 @@ export function createAPIFactory(
|
|
|
636
641
|
|
|
637
642
|
/** @stubbed ShareProvider */
|
|
638
643
|
registerShareProvider: () => Disposable.NULL,
|
|
644
|
+
/** @stubbed Terminal Shell Ingration */
|
|
645
|
+
onDidChangeTerminalShellIntegration: Event.None,
|
|
646
|
+
/** @stubbed Terminal Shell Ingration */
|
|
647
|
+
onDidEndTerminalShellExecution: Event.None,
|
|
648
|
+
/** @stubbed Terminal Shell Ingration */
|
|
649
|
+
onDidStartTerminalShellExecution: Event.None
|
|
639
650
|
};
|
|
640
651
|
|
|
641
652
|
const workspace: typeof theia.workspace = {
|
|
@@ -740,9 +751,8 @@ export function createAPIFactory(
|
|
|
740
751
|
} else {
|
|
741
752
|
throw new Error('Invalid arguments');
|
|
742
753
|
}
|
|
743
|
-
|
|
744
|
-
return
|
|
745
|
-
|
|
754
|
+
// Notebook extension will create a document in openNotebookDocument() or create openNotebookDocument()
|
|
755
|
+
return notebooksExt.getNotebookDocument(uri).apiNotebook;
|
|
746
756
|
},
|
|
747
757
|
createFileSystemWatcher: (pattern, ignoreCreate, ignoreChange, ignoreDelete): theia.FileSystemWatcher =>
|
|
748
758
|
extHostFileSystemEvent.createFileSystemWatcher(fromGlobPattern(pattern), ignoreCreate, ignoreChange, ignoreDelete),
|
|
@@ -1495,7 +1505,8 @@ export function createAPIFactory(
|
|
|
1495
1505
|
LanguageModelError,
|
|
1496
1506
|
PortAutoForwardAction,
|
|
1497
1507
|
PortAttributes,
|
|
1498
|
-
DebugVisualization
|
|
1508
|
+
DebugVisualization,
|
|
1509
|
+
TerminalShellExecutionCommandLineConfidence
|
|
1499
1510
|
};
|
|
1500
1511
|
};
|
|
1501
1512
|
}
|
|
@@ -252,7 +252,7 @@ export abstract class AbstractPluginManagerExtImpl<P extends Record<string, any>
|
|
|
252
252
|
}
|
|
253
253
|
for (let activationEvent of activationEvents) {
|
|
254
254
|
if (activationEvent === 'onUri') {
|
|
255
|
-
activationEvent = `onUri
|
|
255
|
+
activationEvent = `onUri:${this.envExt.uriScheme}://${plugin.model.id}`;
|
|
256
256
|
}
|
|
257
257
|
this.setActivation(activationEvent, activation);
|
|
258
258
|
}
|
|
@@ -481,6 +481,7 @@ export class PluginManagerExtImpl extends AbstractPluginManagerExtImpl<PluginMan
|
|
|
481
481
|
this.envExt.setApplicationName(params.env.appName);
|
|
482
482
|
this.envExt.setAppHost(params.env.appHost);
|
|
483
483
|
this.envExt.setAppRoot(params.env.appRoot);
|
|
484
|
+
this.envExt.setAppUriScheme(params.env.appUriScheme);
|
|
484
485
|
|
|
485
486
|
this.preferencesManager.init(params.preferences);
|
|
486
487
|
|
|
@@ -478,6 +478,9 @@ export class TerminalExtImpl implements theia.Terminal {
|
|
|
478
478
|
this.creationOptions = this.options;
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
+
/** @stubbed Terminal Shell Ingration */
|
|
482
|
+
shellIntegration: theia.TerminalShellIntegration | undefined = undefined;
|
|
483
|
+
|
|
481
484
|
sendText(text: string, shouldExecute: boolean = true): void {
|
|
482
485
|
this.id.promise.then(id => this.proxy.$sendText(id, text, shouldExecute));
|
|
483
486
|
}
|
|
@@ -30,7 +30,7 @@ export class TextEditorExt implements theia.TextEditor {
|
|
|
30
30
|
private disposed = false;
|
|
31
31
|
constructor(
|
|
32
32
|
private readonly proxy: TextEditorsMain,
|
|
33
|
-
|
|
33
|
+
readonly id: string,
|
|
34
34
|
document: DocumentDataExt,
|
|
35
35
|
private _selections: Selection[],
|
|
36
36
|
options: TextEditorConfiguration,
|
|
@@ -731,6 +731,26 @@ export function toSymbolTag(kind: model.SymbolTag): types.SymbolTag {
|
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Creates a merged symbol of type theia.SymbolInformation & theia.DocumentSymbol.
|
|
736
|
+
* Is only used as the result type of the `vscode.executeDocumentSymbolProvider` command.
|
|
737
|
+
*/
|
|
738
|
+
export function toMergedSymbol(uri: UriComponents, symbol: model.DocumentSymbol): theia.SymbolInformation & theia.DocumentSymbol {
|
|
739
|
+
const uriValue = URI.revive(uri);
|
|
740
|
+
const location = new types.Location(uriValue, toRange(symbol.range));
|
|
741
|
+
return {
|
|
742
|
+
name: symbol.name,
|
|
743
|
+
containerName: symbol.containerName ?? '',
|
|
744
|
+
kind: SymbolKind.toSymbolKind(symbol.kind),
|
|
745
|
+
tags: [],
|
|
746
|
+
location,
|
|
747
|
+
detail: symbol.detail,
|
|
748
|
+
range: location.range,
|
|
749
|
+
selectionRange: toRange(symbol.selectionRange),
|
|
750
|
+
children: symbol.children?.map(child => toMergedSymbol(uri, child)) ?? []
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
|
|
734
754
|
export function isModelLocation(arg: unknown): arg is model.Location {
|
|
735
755
|
return isObject<model.Location>(arg) &&
|
|
736
756
|
isModelRange(arg.range) &&
|
package/src/plugin/types-impl.ts
CHANGED
|
@@ -3999,3 +3999,13 @@ export class DebugVisualization {
|
|
|
3999
3999
|
}
|
|
4000
4000
|
|
|
4001
4001
|
// #endregion
|
|
4002
|
+
|
|
4003
|
+
// #region Terminal Shell Integration
|
|
4004
|
+
|
|
4005
|
+
export enum TerminalShellExecutionCommandLineConfidence {
|
|
4006
|
+
Low = 0,
|
|
4007
|
+
Medium = 1,
|
|
4008
|
+
High = 2
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
// #endregion
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 STMicroelectronics.
|
|
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-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as theia from '@theia/plugin';
|
|
18
|
+
import {
|
|
19
|
+
UriExt,
|
|
20
|
+
PLUGIN_RPC_CONTEXT, PluginInfo, UriMain
|
|
21
|
+
} from '../common/plugin-api-rpc';
|
|
22
|
+
import { RPCProtocol } from '../common/rpc-protocol';
|
|
23
|
+
import { Disposable, URI } from './types-impl';
|
|
24
|
+
import { UriComponents } from '../common/uri-components';
|
|
25
|
+
|
|
26
|
+
export class UriExtImpl implements UriExt {
|
|
27
|
+
|
|
28
|
+
private handlers = new Map<string, theia.UriHandler>();
|
|
29
|
+
|
|
30
|
+
private readonly proxy: UriMain;
|
|
31
|
+
|
|
32
|
+
constructor(readonly rpc: RPCProtocol) {
|
|
33
|
+
this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.URI_MAIN);
|
|
34
|
+
console.log(this.proxy);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
registerUriHandler(handler: theia.UriHandler, plugin: PluginInfo): theia.Disposable {
|
|
38
|
+
const pluginId = plugin.id;
|
|
39
|
+
if (this.handlers.has(pluginId)) {
|
|
40
|
+
throw new Error(`URI handler already registered for plugin ${pluginId}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.handlers.set(pluginId, handler);
|
|
44
|
+
this.proxy.$registerUriHandler(pluginId, plugin.displayName || plugin.name);
|
|
45
|
+
|
|
46
|
+
return new Disposable(() => {
|
|
47
|
+
this.proxy.$unregisterUriHandler(pluginId);
|
|
48
|
+
this.handlers.delete(pluginId);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
$handleExternalUri(uri: UriComponents): Promise<void> {
|
|
53
|
+
const handler = this.handlers.get(uri.authority);
|
|
54
|
+
if (!handler) {
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
}
|
|
57
|
+
handler.handleUri(URI.revive(uri));
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/plugin/webviews.ts
CHANGED
|
@@ -255,7 +255,7 @@ export class WebviewImpl implements theia.Webview {
|
|
|
255
255
|
.replace('{{authority}}', resource.authority)
|
|
256
256
|
.replace('{{path}}', resource.path.replace(/^\//, ''))
|
|
257
257
|
.replace('{{uuid}}', this.origin ?? this.viewId);
|
|
258
|
-
return URI.parse(uri);
|
|
258
|
+
return URI.parse(uri).with({ query: resource.query });
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
get cspSource(): string {
|
|
@@ -1,73 +0,0 @@
|
|
|
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-only WITH Classpath-exception-2.0
|
|
15
|
-
********************************************************************************/
|
|
16
|
-
import { Channel } from '@theia/core/';
|
|
17
|
-
import { RpcMessageDecoder, RpcMessageEncoder } from '@theia/core/lib/common/message-rpc/rpc-message-encoder';
|
|
18
|
-
export interface RpcHandlerOptions {
|
|
19
|
-
id: string;
|
|
20
|
-
encoder: RpcMessageEncoder;
|
|
21
|
-
decoder: RpcMessageDecoder;
|
|
22
|
-
}
|
|
23
|
-
export interface ProxyHandlerOptions extends RpcHandlerOptions {
|
|
24
|
-
channelProvider: () => Promise<Channel>;
|
|
25
|
-
proxySynchronizer: ProxySynchronizer;
|
|
26
|
-
}
|
|
27
|
-
export interface InvocationHandlerOptions extends RpcHandlerOptions {
|
|
28
|
-
target: any;
|
|
29
|
-
}
|
|
30
|
-
export interface ProxySynchronizer {
|
|
31
|
-
startProxyInitialization(id: string, init: Promise<void>): void;
|
|
32
|
-
pendingProxyInitializations(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* A proxy handler that will send any method invocation on the proxied object
|
|
36
|
-
* as a rcp protocol message over a channel.
|
|
37
|
-
*/
|
|
38
|
-
export declare class ClientProxyHandler<T extends object> implements ProxyHandler<T> {
|
|
39
|
-
private rpcDeferred;
|
|
40
|
-
private isRpcInitialized;
|
|
41
|
-
readonly id: string;
|
|
42
|
-
private readonly channelProvider;
|
|
43
|
-
private readonly proxySynchronizer;
|
|
44
|
-
private readonly encoder;
|
|
45
|
-
private readonly decoder;
|
|
46
|
-
constructor(options: ProxyHandlerOptions);
|
|
47
|
-
private initializeRpc;
|
|
48
|
-
get(target: any, name: string, receiver: any): any;
|
|
49
|
-
private sendWhenNoInit;
|
|
50
|
-
/**
|
|
51
|
-
* Return whether the given property represents a notification. If true,
|
|
52
|
-
* the promise returned from the invocation will resolve immediately to `undefined`
|
|
53
|
-
*
|
|
54
|
-
* A property leads to a notification rather than a method call if its name
|
|
55
|
-
* begins with `notify` or `on`.
|
|
56
|
-
*
|
|
57
|
-
* @param p - The property being called on the proxy.
|
|
58
|
-
* @return Whether `p` represents a notification.
|
|
59
|
-
*/
|
|
60
|
-
protected isNotification(p: PropertyKey): boolean;
|
|
61
|
-
}
|
|
62
|
-
export declare class RpcInvocationHandler {
|
|
63
|
-
readonly id: string;
|
|
64
|
-
readonly target: any;
|
|
65
|
-
private rpcDeferred;
|
|
66
|
-
private readonly encoder;
|
|
67
|
-
private readonly decoder;
|
|
68
|
-
constructor(options: InvocationHandlerOptions);
|
|
69
|
-
listen(channel: Channel): void;
|
|
70
|
-
protected handleRequest(method: string, args: any[]): Promise<any>;
|
|
71
|
-
protected onNotification(method: string, args: any[]): void;
|
|
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OAAO,EAAE,mBAAmB;IAIxC,OAAO,CAAC,aAAa;IAYrB,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG;IAqBlD,OAAO,CAAC,cAAc;IAItB;;;;;;;;;OASG;IACH,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO;CAOpD;AAED,qBAAa,oBAAoB;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAErB,OAAO,CAAC,WAAW,CAAyC;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;gBAEhC,OAAO,EAAE,wBAAwB;IAI7C,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAO9B,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAIlE,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAK9D"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RpcInvocationHandler = exports.ClientProxyHandler = void 0;
|
|
4
|
-
/********************************************************************************
|
|
5
|
-
* Copyright (C) 2022 STMicroelectronics and others.
|
|
6
|
-
*
|
|
7
|
-
* This program and the accompanying materials are made available under the
|
|
8
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
9
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
10
|
-
*
|
|
11
|
-
* This Source Code may also be made available under the following Secondary
|
|
12
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
13
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
14
|
-
* with the GNU Classpath Exception which is available at
|
|
15
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
16
|
-
*
|
|
17
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
18
|
-
********************************************************************************/
|
|
19
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
|
-
const core_1 = require("@theia/core/");
|
|
21
|
-
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
22
|
-
/**
|
|
23
|
-
* A proxy handler that will send any method invocation on the proxied object
|
|
24
|
-
* as a rcp protocol message over a channel.
|
|
25
|
-
*/
|
|
26
|
-
class ClientProxyHandler {
|
|
27
|
-
constructor(options) {
|
|
28
|
-
this.rpcDeferred = new promise_util_1.Deferred();
|
|
29
|
-
this.isRpcInitialized = false;
|
|
30
|
-
Object.assign(this, options);
|
|
31
|
-
}
|
|
32
|
-
initializeRpc() {
|
|
33
|
-
// we need to set the flag to true before waiting for the channel provider. Otherwise `get` might
|
|
34
|
-
// get called again and we'll try to open a channel more than once
|
|
35
|
-
this.proxySynchronizer.startProxyInitialization(this.id, this.rpcDeferred.promise.then(() => { }));
|
|
36
|
-
this.isRpcInitialized = true;
|
|
37
|
-
const clientOptions = { encoder: this.encoder, decoder: this.decoder, mode: 'clientOnly' };
|
|
38
|
-
this.channelProvider().then(channel => {
|
|
39
|
-
const rpc = new core_1.RpcProtocol(channel, undefined, clientOptions);
|
|
40
|
-
this.rpcDeferred.resolve(rpc);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
get(target, name, receiver) {
|
|
44
|
-
if (!this.isRpcInitialized) {
|
|
45
|
-
this.initializeRpc();
|
|
46
|
-
}
|
|
47
|
-
if (target[name] || name.charCodeAt(0) !== 36 /* CharCode.DollarSign */) {
|
|
48
|
-
return target[name];
|
|
49
|
-
}
|
|
50
|
-
const isNotify = this.isNotification(name);
|
|
51
|
-
return (...args) => {
|
|
52
|
-
const method = name.toString();
|
|
53
|
-
return this.sendWhenNoInit(async (connection) => {
|
|
54
|
-
if (isNotify) {
|
|
55
|
-
connection.sendNotification(method, args);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return await connection.sendRequest(method, args);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
sendWhenNoInit(send) {
|
|
64
|
-
return this.proxySynchronizer.pendingProxyInitializations().then(() => this.rpcDeferred.promise.then(send));
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Return whether the given property represents a notification. If true,
|
|
68
|
-
* the promise returned from the invocation will resolve immediately to `undefined`
|
|
69
|
-
*
|
|
70
|
-
* A property leads to a notification rather than a method call if its name
|
|
71
|
-
* begins with `notify` or `on`.
|
|
72
|
-
*
|
|
73
|
-
* @param p - The property being called on the proxy.
|
|
74
|
-
* @return Whether `p` represents a notification.
|
|
75
|
-
*/
|
|
76
|
-
isNotification(p) {
|
|
77
|
-
let propertyString = p.toString();
|
|
78
|
-
if (propertyString.charCodeAt(0) === 36 /* CharCode.DollarSign */) {
|
|
79
|
-
propertyString = propertyString.substring(1);
|
|
80
|
-
}
|
|
81
|
-
return propertyString.startsWith('notify') || propertyString.startsWith('on');
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.ClientProxyHandler = ClientProxyHandler;
|
|
85
|
-
class RpcInvocationHandler {
|
|
86
|
-
constructor(options) {
|
|
87
|
-
this.rpcDeferred = new promise_util_1.Deferred();
|
|
88
|
-
Object.assign(this, options);
|
|
89
|
-
}
|
|
90
|
-
listen(channel) {
|
|
91
|
-
const serverOptions = { encoder: this.encoder, decoder: this.decoder, mode: 'serverOnly' };
|
|
92
|
-
const server = new core_1.RpcProtocol(channel, (method, args) => this.handleRequest(method, args), serverOptions);
|
|
93
|
-
server.onNotification((e) => this.onNotification(e.method, e.args));
|
|
94
|
-
this.rpcDeferred.resolve(server);
|
|
95
|
-
}
|
|
96
|
-
handleRequest(method, args) {
|
|
97
|
-
return this.rpcDeferred.promise.then(() => this.target[method](...args));
|
|
98
|
-
}
|
|
99
|
-
onNotification(method, args) {
|
|
100
|
-
this.rpcDeferred.promise.then(() => {
|
|
101
|
-
this.target[method](...args);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.RpcInvocationHandler = RpcInvocationHandler;
|
|
106
|
-
//# sourceMappingURL=proxy-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-handler.js","sourceRoot":"","sources":["../../src/common/proxy-handler.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,uDAAuD;AACvD,uCAAwE;AAExE,sEAA+D;AAqB/D;;;GAGG;AACH,MAAa,kBAAkB;IAU3B,YAAY,OAA4B;QAThC,gBAAW,GAA0B,IAAI,uBAAQ,EAAE,CAAC;QACpD,qBAAgB,GAAG,KAAK,CAAC;QAS7B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAEO,aAAa;QACjB,iGAAiG;QACjG,kEAAkE;QAClE,IAAI,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACnG,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,MAAM,aAAa,GAAuB,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QAC/G,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YAClC,MAAM,GAAG,GAAG,IAAI,kBAAW,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;YAC/D,IAAI,CAAC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CAAC,GAAG,EAAE;YAC/B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA5BD,oDA4BC"}
|
|
@@ -1,143 +0,0 @@
|
|
|
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-only 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
|
-
proxySynchronizer: ProxySynchronizer,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface InvocationHandlerOptions extends RpcHandlerOptions {
|
|
32
|
-
target: any
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface ProxySynchronizer {
|
|
36
|
-
startProxyInitialization(id: string, init: Promise<void>): void
|
|
37
|
-
pendingProxyInitializations(): Promise<void>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* A proxy handler that will send any method invocation on the proxied object
|
|
42
|
-
* as a rcp protocol message over a channel.
|
|
43
|
-
*/
|
|
44
|
-
export class ClientProxyHandler<T extends object> implements ProxyHandler<T> {
|
|
45
|
-
private rpcDeferred: Deferred<RpcProtocol> = new Deferred();
|
|
46
|
-
private isRpcInitialized = false;
|
|
47
|
-
|
|
48
|
-
readonly id: string;
|
|
49
|
-
private readonly channelProvider: () => Promise<Channel>;
|
|
50
|
-
private readonly proxySynchronizer: ProxySynchronizer;
|
|
51
|
-
private readonly encoder: RpcMessageEncoder;
|
|
52
|
-
private readonly decoder: RpcMessageDecoder;
|
|
53
|
-
|
|
54
|
-
constructor(options: ProxyHandlerOptions) {
|
|
55
|
-
Object.assign(this, options);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private initializeRpc(): void {
|
|
59
|
-
// we need to set the flag to true before waiting for the channel provider. Otherwise `get` might
|
|
60
|
-
// get called again and we'll try to open a channel more than once
|
|
61
|
-
this.proxySynchronizer.startProxyInitialization(this.id, this.rpcDeferred.promise.then(() => { }));
|
|
62
|
-
this.isRpcInitialized = true;
|
|
63
|
-
const clientOptions: RpcProtocolOptions = { encoder: this.encoder, decoder: this.decoder, mode: 'clientOnly' };
|
|
64
|
-
this.channelProvider().then(channel => {
|
|
65
|
-
const rpc = new RpcProtocol(channel, undefined, clientOptions);
|
|
66
|
-
this.rpcDeferred.resolve(rpc);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
get(target: any, name: string, receiver: any): any {
|
|
71
|
-
if (!this.isRpcInitialized) {
|
|
72
|
-
this.initializeRpc();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (target[name] || name.charCodeAt(0) !== 36 /* CharCode.DollarSign */) {
|
|
76
|
-
return target[name];
|
|
77
|
-
}
|
|
78
|
-
const isNotify = this.isNotification(name);
|
|
79
|
-
return (...args: any[]) => {
|
|
80
|
-
const method = name.toString();
|
|
81
|
-
return this.sendWhenNoInit(async (connection: RpcProtocol) => {
|
|
82
|
-
if (isNotify) {
|
|
83
|
-
connection.sendNotification(method, args);
|
|
84
|
-
} else {
|
|
85
|
-
return await connection.sendRequest(method, args) as Promise<any>;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private sendWhenNoInit(send: (connection: RpcProtocol) => Promise<any>): Promise<any> {
|
|
92
|
-
return this.proxySynchronizer.pendingProxyInitializations().then(() => this.rpcDeferred.promise.then(send));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Return whether the given property represents a notification. If true,
|
|
97
|
-
* the promise returned from the invocation will resolve immediately to `undefined`
|
|
98
|
-
*
|
|
99
|
-
* A property leads to a notification rather than a method call if its name
|
|
100
|
-
* begins with `notify` or `on`.
|
|
101
|
-
*
|
|
102
|
-
* @param p - The property being called on the proxy.
|
|
103
|
-
* @return Whether `p` represents a notification.
|
|
104
|
-
*/
|
|
105
|
-
protected isNotification(p: PropertyKey): boolean {
|
|
106
|
-
let propertyString = p.toString();
|
|
107
|
-
if (propertyString.charCodeAt(0) === 36/* CharCode.DollarSign */) {
|
|
108
|
-
propertyString = propertyString.substring(1);
|
|
109
|
-
}
|
|
110
|
-
return propertyString.startsWith('notify') || propertyString.startsWith('on');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export class RpcInvocationHandler {
|
|
115
|
-
readonly id: string;
|
|
116
|
-
readonly target: any;
|
|
117
|
-
|
|
118
|
-
private rpcDeferred: Deferred<RpcProtocol> = new Deferred();
|
|
119
|
-
private readonly encoder: RpcMessageEncoder;
|
|
120
|
-
private readonly decoder: RpcMessageDecoder;
|
|
121
|
-
|
|
122
|
-
constructor(options: InvocationHandlerOptions) {
|
|
123
|
-
Object.assign(this, options);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
listen(channel: Channel): void {
|
|
127
|
-
const serverOptions: RpcProtocolOptions = { encoder: this.encoder, decoder: this.decoder, mode: 'serverOnly' };
|
|
128
|
-
const server = new RpcProtocol(channel, (method: string, args: any[]) => this.handleRequest(method, args), serverOptions);
|
|
129
|
-
server.onNotification((e: { method: string, args: any }) => this.onNotification(e.method, e.args));
|
|
130
|
-
this.rpcDeferred.resolve(server);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
protected handleRequest(method: string, args: any[]): Promise<any> {
|
|
134
|
-
return this.rpcDeferred.promise.then(() => this.target[method](...args));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected onNotification(method: string, args: any[]): void {
|
|
138
|
-
this.rpcDeferred.promise.then(() => {
|
|
139
|
-
this.target[method](...args);
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|