Compare commits

...

4 commits

Author SHA1 Message Date
João Moreno 3084b7d7ac
add comment 2021-11-25 15:14:36 +01:00
João Moreno 2ff9b87972
wip: send message ports upfront 2021-11-24 21:38:32 +01:00
João Moreno 68117af61a
wip: ipc api 2021-11-23 19:46:38 +01:00
João Moreno ee541af5df
build: 👷 give names to the api proposal tasks
cc @jrieken
2021-11-23 13:31:53 +01:00
9 changed files with 55 additions and 19 deletions

View file

@ -16,10 +16,12 @@ const { monacoTypecheckTask/* , monacoTypecheckWatchTask */ } = require('./gulpf
const { compileExtensionsTask, watchExtensionsTask, compileExtensionMediaTask } = require('./gulpfile.extensions');
// Fast compile for development time
const compileClientTask = task.define('compile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compilation.compileApiProposalNames(), compilation.compileTask('src', 'out', false)));
const compileApiProposalNames = task.define('compile-api-proposal-names', compilation.compileApiProposalNames());
const compileClientTask = task.define('compile-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), compileApiProposalNames, compilation.compileTask('src', 'out', false)));
gulp.task(compileClientTask);
const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), task.parallel(compilation.watchTask('out', false), compilation.watchApiProposalNames())));
const watchApiProposalNames = task.define('watch-api-proposal-names', compilation.watchApiProposalNames());
const watchClientTask = task.define('watch-client', task.series(util.rimraf('out'), util.buildWebNodePaths('out'), task.parallel(compilation.watchTask('out', false), watchApiProposalNames)));
gulp.task(watchClientTask);
// All

View file

@ -113,6 +113,7 @@ export interface IInitData {
autoStart: boolean;
remote: { isRemote: boolean; authority: string | undefined; connectionData: IRemoteConnectionData | null; };
uiKind: UIKind;
messagePorts?: ReadonlyMap<string, MessagePort>;
}
export interface IConfigurationInitData extends IConfigurationData {
@ -295,7 +296,7 @@ export interface MainThreadTextEditorsShape extends IDisposable {
}
export interface MainThreadTreeViewsShape extends IDisposable {
$registerTreeViewDataProvider(treeViewId: string, options: { showCollapseAll: boolean, canSelectMany: boolean, dragAndDropMimeTypes: string[] | undefined}): Promise<void>;
$registerTreeViewDataProvider(treeViewId: string, options: { showCollapseAll: boolean, canSelectMany: boolean, dragAndDropMimeTypes: string[] | undefined }): Promise<void>;
$refresh(treeViewId: string, itemsToRefresh?: { [treeItemHandle: string]: ITreeItem; }): Promise<void>;
$reveal(treeViewId: string, itemInfo: { item: ITreeItem, parentChain: ITreeItem[] } | undefined, options: IRevealOptions): Promise<void>;
$setMessage(treeViewId: string, message: string): void;
@ -2253,7 +2254,7 @@ export const MainContext = {
MainThreadTheming: createMainId<MainThreadThemingShape>('MainThreadTheming'),
MainThreadTunnelService: createMainId<MainThreadTunnelServiceShape>('MainThreadTunnelService'),
MainThreadTimeline: createMainId<MainThreadTimelineShape>('MainThreadTimeline'),
MainThreadTesting: createMainId<MainThreadTestingShape>('MainThreadTesting')
MainThreadTesting: createMainId<MainThreadTestingShape>('MainThreadTesting'),
};
export const ExtHostContext = {

View file

@ -447,7 +447,8 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
checkProposedApiEnabled(extensionDescription, 'extensionRuntime');
return that.extensionRuntime;
},
get environmentVariableCollection() { return that._extHostTerminalService.getEnvironmentVariableCollection(extensionDescription); }
get environmentVariableCollection() { return that._extHostTerminalService.getEnvironmentVariableCollection(extensionDescription); },
messagePort: this._initData.messagePorts?.get(ExtensionIdentifier.toKey(extensionDescription.identifier))
});
});
}

View file

@ -295,6 +295,12 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost
}
);
// TODO@joao: let's use this mechanism to invert the regular MessagePort sending.
// it is currently being sent from the extension host to the outside. we could
// send it in this collection instead
const messagePorts = this._environmentService.options?.messagePorts ?? new Map();
worker.postMessage(messagePorts as any, [...messagePorts.values()]);
// await MessagePort and use it to directly communicate
// with the worker extension host
await barrier.wait();

View file

@ -45,7 +45,8 @@ export class ExtensionHostMain {
protocol: IMessagePassingProtocol,
initData: IInitData,
hostUtils: IHostUtils,
uriTransformer: IURITransformer | null
uriTransformer: IURITransformer | null,
messagePorts?: ReadonlyMap<string, MessagePort>
) {
this._isTerminating = false;
this._hostUtils = hostUtils;
@ -56,7 +57,7 @@ export class ExtensionHostMain {
// bootstrap services
const services = new ServiceCollection(...getSingletonServiceDescriptors());
services.set(IExtHostInitDataService, { _serviceBrand: undefined, ...initData });
services.set(IExtHostInitDataService, { _serviceBrand: undefined, ...initData, messagePorts });
services.set(IExtHostRpcService, new ExtHostRpcService(this._rpcProtocol));
services.set(IURITransformerService, new URITransformerService(uriTransformer));
services.set(IHostUtils, hostUtils);

View file

@ -25,6 +25,7 @@ export const allApiProposals = Object.freeze({
fsChunks: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fsChunks.d.ts',
inlayHints: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlayHints.d.ts',
inlineCompletions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts',
ipc: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.ipc.d.ts',
languageStatus: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.languageStatus.d.ts',
notebookCellExecutionState: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCellExecutionState.d.ts',
notebookConcatTextDocument: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookConcatTextDocument.d.ts',

View file

@ -219,18 +219,24 @@ function connectToRenderer(protocol: IMessagePassingProtocol): Promise<IRenderer
let onTerminate = (reason: string) => nativeClose();
export function create(): void {
const res = new ExtensionWorker();
export function create(): { onmessage: (message: any) => void } {
performance.mark(`code/extHost/willConnectToRenderer`);
connectToRenderer(res.protocol).then(data => {
performance.mark(`code/extHost/didWaitForInitData`);
const extHostMain = new ExtensionHostMain(
data.protocol,
data.initData,
hostUtil,
null,
);
onTerminate = (reason: string) => extHostMain.terminate(reason);
});
return {
onmessage(messagePorts: ReadonlyMap<string, MessagePort>) {
const res = new ExtensionWorker();
connectToRenderer(res.protocol).then(data => {
performance.mark(`code/extHost/didWaitForInitData`);
const extHostMain = new ExtensionHostMain(
data.protocol,
data.initData,
hostUtil,
null,
messagePorts
);
onTerminate = (reason: string) => extHostMain.terminate(reason);
});
}
};
}

View file

@ -525,6 +525,13 @@ interface IWorkbenchConstructionOptions {
//#endregion
//#region IPC
readonly messagePorts?: ReadonlyMap<ExtensionId, MessagePort>;
//#endregion
//#region Development options
readonly developmentOptions?: IDevelopmentOptions;

11
src/vscode-dts/vscode.proposed.ipc.d.ts vendored Normal file
View file

@ -0,0 +1,11 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
export interface ExtensionContext {
readonly messagePort: MessagePort | undefined;
}
}