mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 01:58:53 +01:00
adopt ext host service world, add dummy implementations for some services
This commit is contained in:
55
src/vs/workbench/api/worker/extHostExtensionService.ts
Normal file
55
src/vs/workbench/api/worker/extHostExtensionService.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createApiFactoryAndRegisterActors } from 'vs/workbench/api/common/extHost.api.impl';
|
||||
import { ExtensionActivationTimesBuilder } from 'vs/workbench/api/common/extHostExtensionActivator';
|
||||
import { AbstractExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
|
||||
import { endsWith } from 'vs/base/common/strings';
|
||||
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
|
||||
export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
|
||||
protected async _beforeAlmostReadyToRunExtensions(): Promise<void> {
|
||||
// initialize API and register actors
|
||||
const factory = this._instaService.invokeFunction(createApiFactoryAndRegisterActors);
|
||||
|
||||
// globally define the vscode module and share that for all extensions
|
||||
// todo@joh have an instance per extension, not a shared one....
|
||||
const sharedApiInstance = factory(nullExtensionDescription, this._registry, await this._extHostConfiguration.getConfigProvider());
|
||||
define('vscode', sharedApiInstance);
|
||||
}
|
||||
|
||||
protected _loadCommonJSModule<T>(modulePath: string, activationTimesBuilder: ExtensionActivationTimesBuilder): Promise<T> {
|
||||
// fake commonjs world
|
||||
const module = { exports: {} };
|
||||
//@ts-ignore
|
||||
self['module'] = module;
|
||||
//@ts-ignore
|
||||
self['exports'] = module.exports;
|
||||
// that's improper but might help extensions that aren't author correctly
|
||||
// @ts-ignore
|
||||
self['window'] = self;
|
||||
|
||||
try {
|
||||
activationTimesBuilder.codeLoadingStart();
|
||||
// import the single (!) script, make sure it's a JS-file
|
||||
const suffix = '.js';
|
||||
if (endsWith(modulePath, suffix)) {
|
||||
importScripts(modulePath);
|
||||
} else {
|
||||
importScripts(modulePath + suffix);
|
||||
}
|
||||
} finally {
|
||||
activationTimesBuilder.codeLoadingStop();
|
||||
}
|
||||
|
||||
// return what it exported
|
||||
return Promise.resolve(module.exports as T);
|
||||
}
|
||||
|
||||
public async $setRemoteEnvironment(env: { [key: string]: string | null }): Promise<void> {
|
||||
throw new Error('Not supported');
|
||||
}
|
||||
}
|
||||
23
src/vs/workbench/api/worker/extHostStoragePaths.ts
Normal file
23
src/vs/workbench/api/worker/extHostStoragePaths.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
export class ExtensionStoragePaths implements IExtensionStoragePaths {
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
readonly whenReady: Promise<any> = Promise.resolve();
|
||||
|
||||
//todo@joh -> this isn't proper but also hard to get right...
|
||||
workspaceValue(_extension: IExtensionDescription): string | undefined {
|
||||
return '';
|
||||
}
|
||||
|
||||
globalValue(_extension: IExtensionDescription): string {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user