mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
remove any type usage (#276894)
* remove any type usage * remove more usages
This commit is contained in:
committed by
GitHub
parent
119d21a125
commit
bee4d296a0
@@ -442,19 +442,6 @@ export default tseslint.config(
|
|||||||
'src/vs/platform/diagnostics/common/diagnostics.ts',
|
'src/vs/platform/diagnostics/common/diagnostics.ts',
|
||||||
'src/vs/platform/diagnostics/node/diagnosticsService.ts',
|
'src/vs/platform/diagnostics/node/diagnosticsService.ts',
|
||||||
'src/vs/platform/download/common/downloadIpc.ts',
|
'src/vs/platform/download/common/downloadIpc.ts',
|
||||||
'src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/allowedExtensionsService.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/extensionGalleryManifestServiceIpc.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/extensionGalleryService.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/extensionManagement.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/extensionManagementIpc.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/extensionManagementUtil.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/extensionNls.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/extensionStorage.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/extensionsProfileScannerService.ts',
|
|
||||||
'src/vs/platform/extensionManagement/common/implicitActivationEvents.ts',
|
|
||||||
'src/vs/platform/extensionManagement/node/extensionManagementService.ts',
|
|
||||||
'src/vs/platform/extensionRecommendations/common/extensionRecommendationsIpc.ts',
|
|
||||||
'src/vs/platform/extensions/common/extensionValidator.ts',
|
'src/vs/platform/extensions/common/extensionValidator.ts',
|
||||||
'src/vs/platform/extensions/common/extensions.ts',
|
'src/vs/platform/extensions/common/extensions.ts',
|
||||||
'src/vs/platform/instantiation/common/descriptors.ts',
|
'src/vs/platform/instantiation/common/descriptors.ts',
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
|
|||||||
protected async installExtensions(extensions: InstallableExtension[]): Promise<InstallExtensionResult[]> {
|
protected async installExtensions(extensions: InstallableExtension[]): Promise<InstallExtensionResult[]> {
|
||||||
const installExtensionResultsMap = new Map<string, InstallExtensionResult & { profileLocation: URI }>();
|
const installExtensionResultsMap = new Map<string, InstallExtensionResult & { profileLocation: URI }>();
|
||||||
const installingExtensionsMap = new Map<string, { task: IInstallExtensionTask; root: IInstallExtensionTask | undefined; uninstallTaskToWaitFor?: IUninstallExtensionTask }>();
|
const installingExtensionsMap = new Map<string, { task: IInstallExtensionTask; root: IInstallExtensionTask | undefined; uninstallTaskToWaitFor?: IUninstallExtensionTask }>();
|
||||||
const alreadyRequestedInstallations: Promise<any>[] = [];
|
const alreadyRequestedInstallations: Promise<ILocalExtension>[] = [];
|
||||||
|
|
||||||
const getInstallExtensionTaskKey = (extension: IGalleryExtension, profileLocation: URI) => `${ExtensionKey.create(extension).toString()}-${profileLocation.toString()}`;
|
const getInstallExtensionTaskKey = (extension: IGalleryExtension, profileLocation: URI) => `${ExtensionKey.create(extension).toString()}-${profileLocation.toString()}`;
|
||||||
const createInstallExtensionTask = (manifest: IExtensionManifest, extension: IGalleryExtension | URI, options: InstallExtensionTaskOptions, root: IInstallExtensionTask | undefined): void => {
|
const createInstallExtensionTask = (manifest: IExtensionManifest, extension: IGalleryExtension | URI, options: InstallExtensionTaskOptions, root: IInstallExtensionTask | undefined): void => {
|
||||||
@@ -303,6 +303,7 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
|
|||||||
// Extension failed to install
|
// Extension failed to install
|
||||||
throw new Error(`Extension ${identifier.id} is not installed`);
|
throw new Error(`Extension ${identifier.id} is not installed`);
|
||||||
}
|
}
|
||||||
|
return result.local;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -410,7 +411,7 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
|
|||||||
reportTelemetry(this.telemetryService, task.operation === InstallOperation.Update ? 'extensionGallery:update' : 'extensionGallery:install', {
|
reportTelemetry(this.telemetryService, task.operation === InstallOperation.Update ? 'extensionGallery:update' : 'extensionGallery:install', {
|
||||||
extensionData: getGalleryExtensionTelemetryData(task.source),
|
extensionData: getGalleryExtensionTelemetryData(task.source),
|
||||||
error,
|
error,
|
||||||
source: task.options.context?.[EXTENSION_INSTALL_SOURCE_CONTEXT]
|
source: task.options.context?.[EXTENSION_INSTALL_SOURCE_CONTEXT] as string | undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
installExtensionResultsMap.set(key, { error, identifier: task.identifier, operation: task.operation, source: task.source, context: task.options.context, profileLocation: task.options.profileLocation, applicationScoped: task.options.isApplicationScoped });
|
installExtensionResultsMap.set(key, { error, identifier: task.identifier, operation: task.operation, source: task.source, context: task.options.context, profileLocation: task.options.profileLocation, applicationScoped: task.options.isApplicationScoped });
|
||||||
@@ -425,7 +426,7 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
|
|||||||
verificationStatus: task.verificationStatus,
|
verificationStatus: task.verificationStatus,
|
||||||
duration: new Date().getTime() - startTime,
|
duration: new Date().getTime() - startTime,
|
||||||
durationSinceUpdate,
|
durationSinceUpdate,
|
||||||
source: task.options.context?.[EXTENSION_INSTALL_SOURCE_CONTEXT]
|
source: task.options.context?.[EXTENSION_INSTALL_SOURCE_CONTEXT] as string | undefined
|
||||||
});
|
});
|
||||||
// In web, report extension install statistics explicitly. In Desktop, statistics are automatically updated while downloading the VSIX.
|
// In web, report extension install statistics explicitly. In Desktop, statistics are automatically updated while downloading the VSIX.
|
||||||
if (isWeb && task.operation !== InstallOperation.Update) {
|
if (isWeb && task.operation !== InstallOperation.Update) {
|
||||||
@@ -765,7 +766,7 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
|
|||||||
|
|
||||||
const allTasks: { task: IUninstallExtensionTask; installTaskToWaitFor?: IInstallExtensionTask }[] = [];
|
const allTasks: { task: IUninstallExtensionTask; installTaskToWaitFor?: IInstallExtensionTask }[] = [];
|
||||||
const processedTasks: IUninstallExtensionTask[] = [];
|
const processedTasks: IUninstallExtensionTask[] = [];
|
||||||
const alreadyRequestedUninstalls: Promise<any>[] = [];
|
const alreadyRequestedUninstalls: Promise<void>[] = [];
|
||||||
const extensionsToRemove: ILocalExtension[] = [];
|
const extensionsToRemove: ILocalExtension[] = [];
|
||||||
|
|
||||||
const installedExtensionsMap = new ResourceMap<ILocalExtension[]>();
|
const installedExtensionsMap = new ResourceMap<ILocalExtension[]>();
|
||||||
@@ -1003,7 +1004,7 @@ function reportTelemetry(telemetryService: ITelemetryService, eventName: string,
|
|||||||
source,
|
source,
|
||||||
durationSinceUpdate
|
durationSinceUpdate
|
||||||
}: {
|
}: {
|
||||||
extensionData: any;
|
extensionData: object;
|
||||||
verificationStatus?: ExtensionSignatureVerificationCode;
|
verificationStatus?: ExtensionSignatureVerificationCode;
|
||||||
duration?: number;
|
duration?: number;
|
||||||
durationSinceUpdate?: number;
|
durationSinceUpdate?: number;
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ import { IConfigurationService } from '../../configuration/common/configuration.
|
|||||||
import { isBoolean, isObject, isUndefined } from '../../../base/common/types.js';
|
import { isBoolean, isObject, isUndefined } from '../../../base/common/types.js';
|
||||||
import { Emitter } from '../../../base/common/event.js';
|
import { Emitter } from '../../../base/common/event.js';
|
||||||
|
|
||||||
function isGalleryExtension(extension: any): extension is IGalleryExtension {
|
function isGalleryExtension(extension: unknown): extension is IGalleryExtension {
|
||||||
return extension.type === 'gallery';
|
return (extension as IGalleryExtension).type === 'gallery';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isIExtension(extension: any): extension is IExtension {
|
function isIExtension(extension: unknown): extension is IExtension {
|
||||||
return extension.type === ExtensionType.User || extension.type === ExtensionType.System;
|
return (extension as IExtension).type === ExtensionType.User || (extension as IExtension).type === ExtensionType.System;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import { Barrier } from '../../../base/common/async.js';
|
import { Barrier } from '../../../base/common/async.js';
|
||||||
import { Emitter, Event } from '../../../base/common/event.js';
|
import { Emitter, Event } from '../../../base/common/event.js';
|
||||||
import { IPCServer } from '../../../base/parts/ipc/common/ipc.js';
|
import { IChannelServer } from '../../../base/parts/ipc/common/ipc.js';
|
||||||
import { IProductService } from '../../product/common/productService.js';
|
import { IProductService } from '../../product/common/productService.js';
|
||||||
import { IExtensionGalleryManifest, IExtensionGalleryManifestService, ExtensionGalleryManifestStatus } from './extensionGalleryManifest.js';
|
import { IExtensionGalleryManifest, IExtensionGalleryManifestService, ExtensionGalleryManifestStatus } from './extensionGalleryManifest.js';
|
||||||
import { ExtensionGalleryManifestService } from './extensionGalleryManifestService.js';
|
import { ExtensionGalleryManifestService } from './extensionGalleryManifestService.js';
|
||||||
@@ -28,12 +28,13 @@ export class ExtensionGalleryManifestIPCService extends ExtensionGalleryManifest
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
server: IPCServer<any>,
|
server: IChannelServer<unknown>,
|
||||||
@IProductService productService: IProductService
|
@IProductService productService: IProductService
|
||||||
) {
|
) {
|
||||||
super(productService);
|
super(productService);
|
||||||
server.registerChannel('extensionGalleryManifest', {
|
server.registerChannel('extensionGalleryManifest', {
|
||||||
listen: () => Event.None,
|
listen: () => Event.None,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
call: async (context: any, command: string, args?: any): Promise<any> => {
|
call: async (context: any, command: string, args?: any): Promise<any> => {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'setExtensionGalleryManifest': return Promise.resolve(this.setExtensionGalleryManifest(args[0]));
|
case 'setExtensionGalleryManifest': return Promise.resolve(this.setExtensionGalleryManifest(args[0]));
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ function setTelemetry(extension: IGalleryExtension, index: number, querySource?:
|
|||||||
extension.telemetryData = { index, querySource, queryActivityId: extension.queryContext?.[SEARCH_ACTIVITY_HEADER_NAME] };
|
extension.telemetryData = { index, querySource, queryActivityId: extension.queryContext?.[SEARCH_ACTIVITY_HEADER_NAME] };
|
||||||
}
|
}
|
||||||
|
|
||||||
function toExtension(galleryExtension: IRawGalleryExtension, version: IRawGalleryExtensionVersion, allTargetPlatforms: TargetPlatform[], extensionGalleryManifest: IExtensionGalleryManifest, productService: IProductService, queryContext?: IStringDictionary<any>): IGalleryExtension {
|
function toExtension(galleryExtension: IRawGalleryExtension, version: IRawGalleryExtensionVersion, allTargetPlatforms: TargetPlatform[], extensionGalleryManifest: IExtensionGalleryManifest, productService: IProductService, queryContext?: IStringDictionary<unknown>): IGalleryExtension {
|
||||||
const latestVersion = galleryExtension.versions[0];
|
const latestVersion = galleryExtension.versions[0];
|
||||||
const assets: IGalleryExtensionAssets = {
|
const assets: IGalleryExtensionAssets = {
|
||||||
manifest: getVersionAsset(version, AssetType.Manifest),
|
manifest: getVersionAsset(version, AssetType.Manifest),
|
||||||
@@ -614,7 +614,7 @@ export abstract class AbstractExtensionGalleryService implements IExtensionGalle
|
|||||||
|
|
||||||
getExtensions(extensionInfos: ReadonlyArray<IExtensionInfo>, token: CancellationToken): Promise<IGalleryExtension[]>;
|
getExtensions(extensionInfos: ReadonlyArray<IExtensionInfo>, token: CancellationToken): Promise<IGalleryExtension[]>;
|
||||||
getExtensions(extensionInfos: ReadonlyArray<IExtensionInfo>, options: IExtensionQueryOptions, token: CancellationToken): Promise<IGalleryExtension[]>;
|
getExtensions(extensionInfos: ReadonlyArray<IExtensionInfo>, options: IExtensionQueryOptions, token: CancellationToken): Promise<IGalleryExtension[]>;
|
||||||
async getExtensions(extensionInfos: ReadonlyArray<IExtensionInfo>, arg1: any, arg2?: any): Promise<IGalleryExtension[]> {
|
async getExtensions(extensionInfos: ReadonlyArray<IExtensionInfo>, arg1: CancellationToken | IExtensionQueryOptions, arg2?: CancellationToken): Promise<IGalleryExtension[]> {
|
||||||
const extensionGalleryManifest = await this.extensionGalleryManifestService.getExtensionGalleryManifest();
|
const extensionGalleryManifest = await this.extensionGalleryManifestService.getExtensionGalleryManifest();
|
||||||
if (!extensionGalleryManifest) {
|
if (!extensionGalleryManifest) {
|
||||||
throw new Error('No extension gallery service configured.');
|
throw new Error('No extension gallery service configured.');
|
||||||
@@ -1570,7 +1570,8 @@ export abstract class AbstractExtensionGalleryService implements IExtensionGalle
|
|||||||
fallbackUri: `${extension.assets.download.fallbackUri}${URI.parse(extension.assets.download.fallbackUri).query ? '&' : '?'}${operationParam}=true`
|
fallbackUri: `${extension.assets.download.fallbackUri}${URI.parse(extension.assets.download.fallbackUri).query ? '&' : '?'}${operationParam}=true`
|
||||||
} : extension.assets.download;
|
} : extension.assets.download;
|
||||||
|
|
||||||
const headers: IHeaders | undefined = extension.queryContext?.[SEARCH_ACTIVITY_HEADER_NAME] ? { [SEARCH_ACTIVITY_HEADER_NAME]: extension.queryContext[SEARCH_ACTIVITY_HEADER_NAME] } : undefined;
|
const activityId = extension.queryContext?.[SEARCH_ACTIVITY_HEADER_NAME];
|
||||||
|
const headers: IHeaders | undefined = activityId && typeof activityId === 'string' ? { [SEARCH_ACTIVITY_HEADER_NAME]: activityId } : undefined;
|
||||||
const context = await this.getAsset(extension.identifier.id, downloadAsset, AssetType.VSIX, extension.version, headers ? { headers } : undefined);
|
const context = await this.getAsset(extension.identifier.id, downloadAsset, AssetType.VSIX, extension.version, headers ? { headers } : undefined);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -190,8 +190,9 @@ export interface IGalleryExtensionAssets {
|
|||||||
coreTranslations: [string, IGalleryExtensionAsset][];
|
coreTranslations: [string, IGalleryExtensionAsset][];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIExtensionIdentifier(thing: any): thing is IExtensionIdentifier {
|
export function isIExtensionIdentifier(obj: unknown): obj is IExtensionIdentifier {
|
||||||
return thing
|
const thing = obj as IExtensionIdentifier | undefined;
|
||||||
|
return !!thing
|
||||||
&& typeof thing === 'object'
|
&& typeof thing === 'object'
|
||||||
&& typeof thing.id === 'string'
|
&& typeof thing.id === 'string'
|
||||||
&& (!thing.uuid || typeof thing.uuid === 'string');
|
&& (!thing.uuid || typeof thing.uuid === 'string');
|
||||||
@@ -244,8 +245,8 @@ export interface IGalleryExtension {
|
|||||||
detailsLink?: string;
|
detailsLink?: string;
|
||||||
ratingLink?: string;
|
ratingLink?: string;
|
||||||
supportLink?: string;
|
supportLink?: string;
|
||||||
telemetryData?: any;
|
telemetryData?: IStringDictionary<unknown>;
|
||||||
queryContext?: IStringDictionary<any>;
|
queryContext?: IStringDictionary<unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InstallSource = 'gallery' | 'vsix' | 'resource';
|
export type InstallSource = 'gallery' | 'vsix' | 'resource';
|
||||||
@@ -435,7 +436,7 @@ export interface InstallExtensionResult {
|
|||||||
readonly source?: URI | IGalleryExtension;
|
readonly source?: URI | IGalleryExtension;
|
||||||
readonly local?: ILocalExtension;
|
readonly local?: ILocalExtension;
|
||||||
readonly error?: Error;
|
readonly error?: Error;
|
||||||
readonly context?: IStringDictionary<any>;
|
readonly context?: IStringDictionary<unknown>;
|
||||||
readonly profileLocation: URI;
|
readonly profileLocation: URI;
|
||||||
readonly applicationScoped?: boolean;
|
readonly applicationScoped?: boolean;
|
||||||
readonly workspaceScoped?: boolean;
|
readonly workspaceScoped?: boolean;
|
||||||
@@ -578,7 +579,7 @@ export type InstallOptions = {
|
|||||||
/**
|
/**
|
||||||
* Context passed through to InstallExtensionResult
|
* Context passed through to InstallExtensionResult
|
||||||
*/
|
*/
|
||||||
context?: IStringDictionary<any>;
|
context?: IStringDictionary<unknown>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UninstallOptions = {
|
export type UninstallOptions = {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { ExtensionType, IExtensionManifest, TargetPlatform } from '../../extensi
|
|||||||
import { IProductService } from '../../product/common/productService.js';
|
import { IProductService } from '../../product/common/productService.js';
|
||||||
import { CommontExtensionManagementService } from './abstractExtensionManagementService.js';
|
import { CommontExtensionManagementService } from './abstractExtensionManagementService.js';
|
||||||
import { language } from '../../../base/common/platform.js';
|
import { language } from '../../../base/common/platform.js';
|
||||||
|
import { RemoteAgentConnectionContext } from '../../remote/common/remoteAgentEnvironment.js';
|
||||||
|
|
||||||
function transformIncomingURI(uri: UriComponents, transformer: IURITransformer | null): URI;
|
function transformIncomingURI(uri: UriComponents, transformer: IURITransformer | null): URI;
|
||||||
function transformIncomingURI(uri: UriComponents | undefined, transformer: IURITransformer | null): URI | undefined;
|
function transformIncomingURI(uri: UriComponents | undefined, transformer: IURITransformer | null): URI | undefined;
|
||||||
@@ -44,7 +45,7 @@ function transformOutgoingExtension(extension: ILocalExtension, transformer: IUR
|
|||||||
return transformer ? cloneAndChange(extension, value => value instanceof URI ? transformer.transformOutgoingURI(value) : undefined) : extension;
|
return transformer ? cloneAndChange(extension, value => value instanceof URI ? transformer.transformOutgoingURI(value) : undefined) : extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExtensionManagementChannel implements IServerChannel {
|
export class ExtensionManagementChannel<TContext = RemoteAgentConnectionContext | string> implements IServerChannel<TContext> {
|
||||||
|
|
||||||
readonly onInstallExtension: Event<InstallExtensionEvent>;
|
readonly onInstallExtension: Event<InstallExtensionEvent>;
|
||||||
readonly onDidInstallExtensions: Event<readonly InstallExtensionResult[]>;
|
readonly onDidInstallExtensions: Event<readonly InstallExtensionResult[]>;
|
||||||
@@ -52,7 +53,7 @@ export class ExtensionManagementChannel implements IServerChannel {
|
|||||||
readonly onDidUninstallExtension: Event<DidUninstallExtensionEvent>;
|
readonly onDidUninstallExtension: Event<DidUninstallExtensionEvent>;
|
||||||
readonly onDidUpdateExtensionMetadata: Event<DidUpdateExtensionMetadata>;
|
readonly onDidUpdateExtensionMetadata: Event<DidUpdateExtensionMetadata>;
|
||||||
|
|
||||||
constructor(private service: IExtensionManagementService, private getUriTransformer: (requestContext: any) => IURITransformer | null) {
|
constructor(private service: IExtensionManagementService, private getUriTransformer: (requestContext: TContext) => IURITransformer | null) {
|
||||||
this.onInstallExtension = Event.buffer(service.onInstallExtension, true);
|
this.onInstallExtension = Event.buffer(service.onInstallExtension, true);
|
||||||
this.onDidInstallExtensions = Event.buffer(service.onDidInstallExtensions, true);
|
this.onDidInstallExtensions = Event.buffer(service.onDidInstallExtensions, true);
|
||||||
this.onUninstallExtension = Event.buffer(service.onUninstallExtension, true);
|
this.onUninstallExtension = Event.buffer(service.onUninstallExtension, true);
|
||||||
@@ -60,6 +61,7 @@ export class ExtensionManagementChannel implements IServerChannel {
|
|||||||
this.onDidUpdateExtensionMetadata = Event.buffer(service.onDidUpdateExtensionMetadata, true);
|
this.onDidUpdateExtensionMetadata = Event.buffer(service.onDidUpdateExtensionMetadata, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
listen(context: any, event: string): Event<any> {
|
listen(context: any, event: string): Event<any> {
|
||||||
const uriTransformer = this.getUriTransformer(context);
|
const uriTransformer = this.getUriTransformer(context);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
@@ -108,6 +110,7 @@ export class ExtensionManagementChannel implements IServerChannel {
|
|||||||
throw new Error('Invalid listen');
|
throw new Error('Invalid listen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
async call(context: any, command: string, args?: any): Promise<any> {
|
async call(context: any, command: string, args?: any): Promise<any> {
|
||||||
const uriTransformer: IURITransformer | null = this.getUriTransformer(context);
|
const uriTransformer: IURITransformer | null = this.getUriTransformer(context);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
@@ -236,14 +239,13 @@ export class ExtensionManagementChannelClient extends CommontExtensionManagement
|
|||||||
this._onDidUpdateExtensionMetadata.fire(event);
|
this._onDidUpdateExtensionMetadata.fire(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private isUriComponents(thing: unknown): thing is UriComponents {
|
private isUriComponents(obj: unknown): obj is UriComponents {
|
||||||
if (!thing) {
|
if (!obj) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const thing = obj as UriComponents | undefined;
|
||||||
return typeof (<any>thing).path === 'string' &&
|
return typeof thing?.path === 'string' &&
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
typeof thing?.scheme === 'string';
|
||||||
typeof (<any>thing).scheme === 'string';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _targetPlatformPromise: Promise<TargetPlatform> | undefined;
|
protected _targetPlatformPromise: Promise<TargetPlatform> | undefined;
|
||||||
@@ -343,10 +345,12 @@ export class ExtensionTipsChannel implements IServerChannel {
|
|||||||
constructor(private service: IExtensionTipsService) {
|
constructor(private service: IExtensionTipsService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
listen(context: any, event: string): Event<any> {
|
listen(context: any, event: string): Event<any> {
|
||||||
throw new Error('Invalid listen');
|
throw new Error('Invalid listen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
call(context: any, command: string, args?: any): Promise<any> {
|
call(context: any, command: string, args?: any): Promise<any> {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'getConfigBasedTips': return this.service.getConfigBasedTips(URI.revive(args[0]));
|
case 'getConfigBasedTips': return this.service.getConfigBasedTips(URI.revive(args[0]));
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class ExtensionKey {
|
|||||||
return `${this.id}-${this.version}${this.targetPlatform !== TargetPlatform.UNDEFINED ? `-${this.targetPlatform}` : ''}`;
|
return `${this.id}-${this.version}${this.targetPlatform !== TargetPlatform.UNDEFINED ? `-${this.targetPlatform}` : ''}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
equals(o: any): boolean {
|
equals(o: unknown): boolean {
|
||||||
if (!(o instanceof ExtensionKey)) {
|
if (!(o instanceof ExtensionKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export function localizeManifest(logger: ILogger, extensionManifest: IExtensionM
|
|||||||
* The root element is an object literal
|
* The root element is an object literal
|
||||||
*/
|
*/
|
||||||
function replaceNLStrings(logger: ILogger, extensionManifest: IExtensionManifest, messages: ITranslations, originalMessages?: ITranslations): void {
|
function replaceNLStrings(logger: ILogger, extensionManifest: IExtensionManifest, messages: ITranslations, originalMessages?: ITranslations): void {
|
||||||
const processEntry = (obj: any, key: string | number, command?: boolean) => {
|
const processEntry = (obj: Record<string, unknown>, key: string | number, command?: boolean) => {
|
||||||
const value = obj[key];
|
const value = obj[key];
|
||||||
if (isString(value)) {
|
if (isString(value)) {
|
||||||
const str = value;
|
const str = value;
|
||||||
@@ -72,11 +72,11 @@ function replaceNLStrings(logger: ILogger, extensionManifest: IExtensionManifest
|
|||||||
} else if (isObject(value)) {
|
} else if (isObject(value)) {
|
||||||
for (const k in value) {
|
for (const k in value) {
|
||||||
if (value.hasOwnProperty(k)) {
|
if (value.hasOwnProperty(k)) {
|
||||||
k === 'commands' ? processEntry(value, k, true) : processEntry(value, k, command);
|
k === 'commands' ? processEntry(value as Record<string, unknown>, k, true) : processEntry(value as Record<string, unknown>, k, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Array.isArray(value)) {
|
} else if (Array.isArray(value)) {
|
||||||
for (let i = 0; i < value.length; i++) {
|
for (let i = 0; i < (value as Array<unknown>).length; i++) {
|
||||||
processEntry(value, i, command);
|
processEntry(value, i, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ export const IExtensionStorageService = createDecorator<IExtensionStorageService
|
|||||||
export interface IExtensionStorageService {
|
export interface IExtensionStorageService {
|
||||||
readonly _serviceBrand: undefined;
|
readonly _serviceBrand: undefined;
|
||||||
|
|
||||||
getExtensionState(extension: IExtension | IGalleryExtension | string, global: boolean): IStringDictionary<any> | undefined;
|
getExtensionState(extension: IExtension | IGalleryExtension | string, global: boolean): IStringDictionary<unknown> | undefined;
|
||||||
getExtensionStateRaw(extension: IExtension | IGalleryExtension | string, global: boolean): string | undefined;
|
getExtensionStateRaw(extension: IExtension | IGalleryExtension | string, global: boolean): string | undefined;
|
||||||
setExtensionState(extension: IExtension | IGalleryExtension | string, state: IStringDictionary<any> | undefined, global: boolean): void;
|
setExtensionState(extension: IExtension | IGalleryExtension | string, state: object | undefined, global: boolean): void;
|
||||||
|
|
||||||
readonly onDidChangeExtensionStorageToSync: Event<void>;
|
readonly onDidChangeExtensionStorageToSync: Event<void>;
|
||||||
setKeysForSync(extensionIdWithVersion: IExtensionIdWithVersion, keys: string[]): void;
|
setKeysForSync(extensionIdWithVersion: IExtensionIdWithVersion, keys: string[]): void;
|
||||||
@@ -140,7 +140,7 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto
|
|||||||
return getExtensionId(publisher, name);
|
return getExtensionId(publisher, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
getExtensionState(extension: IExtension | IGalleryExtension | string, global: boolean): IStringDictionary<any> | undefined {
|
getExtensionState(extension: IExtension | IGalleryExtension | string, global: boolean): IStringDictionary<unknown> | undefined {
|
||||||
const extensionId = this.getExtensionId(extension);
|
const extensionId = this.getExtensionId(extension);
|
||||||
const jsonValue = this.getExtensionStateRaw(extension, global);
|
const jsonValue = this.getExtensionStateRaw(extension, global);
|
||||||
if (jsonValue) {
|
if (jsonValue) {
|
||||||
@@ -167,7 +167,7 @@ export class ExtensionStorageService extends Disposable implements IExtensionSto
|
|||||||
return rawState;
|
return rawState;
|
||||||
}
|
}
|
||||||
|
|
||||||
setExtensionState(extension: IExtension | IGalleryExtension | string, state: IStringDictionary<any> | undefined, global: boolean): void {
|
setExtensionState(extension: IExtension | IGalleryExtension | string, state: IStringDictionary<unknown> | undefined, global: boolean): void {
|
||||||
const extensionId = this.getExtensionId(extension);
|
const extensionId = this.getExtensionId(extension);
|
||||||
if (state === undefined) {
|
if (state === undefined) {
|
||||||
this.storageService.remove(extensionId, global ? StorageScope.PROFILE : StorageScope.WORKSPACE);
|
this.storageService.remove(extensionId, global ? StorageScope.PROFILE : StorageScope.WORKSPACE);
|
||||||
|
|||||||
@@ -390,20 +390,21 @@ export abstract class AbstractExtensionsProfileScannerService extends Disposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isStoredProfileExtension(candidate: any): candidate is IStoredProfileExtension {
|
function isStoredProfileExtension(obj: unknown): obj is IStoredProfileExtension {
|
||||||
|
const candidate = obj as IStoredProfileExtension | undefined;
|
||||||
return isObject(candidate)
|
return isObject(candidate)
|
||||||
&& isIExtensionIdentifier(candidate.identifier)
|
&& isIExtensionIdentifier(candidate.identifier)
|
||||||
&& (isUriComponents(candidate.location) || (isString(candidate.location) && candidate.location))
|
&& (isUriComponents(candidate.location) || (isString(candidate.location) && !!candidate.location))
|
||||||
&& (isUndefined(candidate.relativeLocation) || isString(candidate.relativeLocation))
|
&& (isUndefined(candidate.relativeLocation) || isString(candidate.relativeLocation))
|
||||||
&& candidate.version && isString(candidate.version);
|
&& !!candidate.version
|
||||||
|
&& isString(candidate.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUriComponents(thing: unknown): thing is UriComponents {
|
function isUriComponents(obj: unknown): obj is UriComponents {
|
||||||
if (!thing) {
|
if (!obj) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const thing = obj as UriComponents | undefined;
|
||||||
return isString((<any>thing).path) &&
|
return typeof thing?.path === 'string' &&
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
typeof thing?.scheme === 'string';
|
||||||
isString((<any>thing).scheme);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { IStringDictionary } from '../../../base/common/collections.js';
|
||||||
import { onUnexpectedError } from '../../../base/common/errors.js';
|
import { onUnexpectedError } from '../../../base/common/errors.js';
|
||||||
import { ExtensionIdentifier, IExtensionDescription } from '../../extensions/common/extensions.js';
|
import { ExtensionIdentifier, IExtensionDescription } from '../../extensions/common/extensions.js';
|
||||||
|
|
||||||
@@ -12,11 +13,11 @@ export interface IActivationEventsGenerator<T> {
|
|||||||
|
|
||||||
export class ImplicitActivationEventsImpl {
|
export class ImplicitActivationEventsImpl {
|
||||||
|
|
||||||
private readonly _generators = new Map<string, IActivationEventsGenerator<any>>();
|
private readonly _generators = new Map<string, IActivationEventsGenerator<unknown>>();
|
||||||
private readonly _cache = new WeakMap<IExtensionDescription, string[]>();
|
private readonly _cache = new WeakMap<IExtensionDescription, string[]>();
|
||||||
|
|
||||||
public register<T>(extensionPointName: string, generator: IActivationEventsGenerator<T>): void {
|
public register<T>(extensionPointName: string, generator: IActivationEventsGenerator<T>): void {
|
||||||
this._generators.set(extensionPointName, generator);
|
this._generators.set(extensionPointName, generator as IActivationEventsGenerator<unknown>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,8 +71,7 @@ export class ImplicitActivationEventsImpl {
|
|||||||
// There's no generator for this extension point
|
// There's no generator for this extension point
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line local/code-no-any-casts
|
const contrib = (desc.contributes as IStringDictionary<unknown>)[extPointName];
|
||||||
const contrib = (desc.contributes as any)[extPointName];
|
|
||||||
const contribArr = Array.isArray(contrib) ? contrib : [contrib];
|
const contribArr = Array.isArray(contrib) ? contrib : [contrib];
|
||||||
try {
|
try {
|
||||||
activationEvents.push(...generator(contribArr));
|
activationEvents.push(...generator(contribArr));
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ export class ExtensionManagementService extends AbstractExtensionManagementServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async downloadAndExtractGalleryExtension(extensionKey: ExtensionKey, gallery: IGalleryExtension, operation: InstallOperation, options: InstallExtensionTaskOptions, token: CancellationToken): Promise<ExtractExtensionResult> {
|
private async downloadAndExtractGalleryExtension(extensionKey: ExtensionKey, gallery: IGalleryExtension, operation: InstallOperation, options: InstallExtensionTaskOptions, token: CancellationToken): Promise<ExtractExtensionResult> {
|
||||||
const { verificationStatus, location } = await this.downloadExtension(gallery, operation, !options.donotVerifySignature, options.context?.[EXTENSION_INSTALL_CLIENT_TARGET_PLATFORM_CONTEXT]);
|
const { verificationStatus, location } = await this.downloadExtension(gallery, operation, !options.donotVerifySignature, options.context?.[EXTENSION_INSTALL_CLIENT_TARGET_PLATFORM_CONTEXT] as TargetPlatform | undefined);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (token.isCancellationRequested) {
|
if (token.isCancellationRequested) {
|
||||||
@@ -534,7 +534,7 @@ type UpdateMetadataErrorEvent = {
|
|||||||
export class ExtensionsScanner extends Disposable {
|
export class ExtensionsScanner extends Disposable {
|
||||||
|
|
||||||
private readonly obsoletedResource: URI;
|
private readonly obsoletedResource: URI;
|
||||||
private readonly obsoleteFileLimiter: Queue<any>;
|
private readonly obsoleteFileLimiter: Queue<IStringDictionary<boolean>>;
|
||||||
|
|
||||||
private readonly _onExtract = this._register(new Emitter<URI>());
|
private readonly _onExtract = this._register(new Emitter<URI>());
|
||||||
readonly onExtract = this._onExtract.event;
|
readonly onExtract = this._onExtract.event;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { ConfigurationTarget } from '../../../configuration/common/configuration
|
|||||||
import { getGalleryExtensionId } from '../../common/extensionManagementUtil.js';
|
import { getGalleryExtensionId } from '../../common/extensionManagementUtil.js';
|
||||||
import { generateUuid } from '../../../../base/common/uuid.js';
|
import { generateUuid } from '../../../../base/common/uuid.js';
|
||||||
import { URI } from '../../../../base/common/uri.js';
|
import { URI } from '../../../../base/common/uri.js';
|
||||||
|
import { IStringDictionary } from '../../../../base/common/collections.js';
|
||||||
|
|
||||||
suite('AllowedExtensionsService', () => {
|
suite('AllowedExtensionsService', () => {
|
||||||
|
|
||||||
@@ -208,14 +209,14 @@ suite('AllowedExtensionsService', () => {
|
|||||||
} as IProductService;
|
} as IProductService;
|
||||||
}
|
}
|
||||||
|
|
||||||
function aGalleryExtension(name: string, properties: any = {}, galleryExtensionProperties: any = {}): IGalleryExtension {
|
function aGalleryExtension(name: string, properties: Partial<IGalleryExtension> = {}, galleryExtensionProperties: IStringDictionary<unknown> = {}): IGalleryExtension {
|
||||||
const galleryExtension = <IGalleryExtension>Object.create({ type: 'gallery', name, publisher: 'pub', publisherDisplayName: 'Pub', version: '1.0.0', allTargetPlatforms: [TargetPlatform.UNIVERSAL], properties: {}, assets: {}, isSigned: true, ...properties });
|
const galleryExtension = <IGalleryExtension>Object.create({ type: 'gallery', name, publisher: 'pub', publisherDisplayName: 'Pub', version: '1.0.0', allTargetPlatforms: [TargetPlatform.UNIVERSAL], properties: {}, assets: {}, isSigned: true, ...properties });
|
||||||
galleryExtension.properties = { ...galleryExtension.properties, dependencies: [], ...galleryExtensionProperties };
|
galleryExtension.properties = { ...galleryExtension.properties, dependencies: [], ...galleryExtensionProperties };
|
||||||
galleryExtension.identifier = { id: getGalleryExtensionId(galleryExtension.publisher, galleryExtension.name), uuid: generateUuid() };
|
galleryExtension.identifier = { id: getGalleryExtensionId(galleryExtension.publisher, galleryExtension.name), uuid: generateUuid() };
|
||||||
return <IGalleryExtension>galleryExtension;
|
return <IGalleryExtension>galleryExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
function aLocalExtension(id: string, manifest: Partial<IExtensionManifest> = {}, properties: any = {}): ILocalExtension {
|
function aLocalExtension(id: string, manifest: Partial<IExtensionManifest> = {}, properties: IStringDictionary<unknown> = {}): ILocalExtension {
|
||||||
const [publisher, name] = id.split('.');
|
const [publisher, name] = id.split('.');
|
||||||
manifest = { name, publisher, ...manifest };
|
manifest = { name, publisher, ...manifest };
|
||||||
properties = {
|
properties = {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { TestInstantiationService } from '../../../instantiation/test/common/ins
|
|||||||
import { ILogService, NullLogService } from '../../../log/common/log.js';
|
import { ILogService, NullLogService } from '../../../log/common/log.js';
|
||||||
import { IUriIdentityService } from '../../../uriIdentity/common/uriIdentity.js';
|
import { IUriIdentityService } from '../../../uriIdentity/common/uriIdentity.js';
|
||||||
import { UriIdentityService } from '../../../uriIdentity/common/uriIdentityService.js';
|
import { UriIdentityService } from '../../../uriIdentity/common/uriIdentityService.js';
|
||||||
|
import { IStringDictionary } from '../../../../base/common/collections.js';
|
||||||
|
|
||||||
const ROOT = URI.file('tests').with({ scheme: 'vscode-tests' });
|
const ROOT = URI.file('tests').with({ scheme: 'vscode-tests' });
|
||||||
|
|
||||||
@@ -144,7 +145,7 @@ suite('ExtensionDownloader Tests', () => {
|
|||||||
return disposables.add(instantiationService.createInstance(TestExtensionDownloader));
|
return disposables.add(instantiationService.createInstance(TestExtensionDownloader));
|
||||||
}
|
}
|
||||||
|
|
||||||
function aGalleryExtension(name: string, properties: Partial<IGalleryExtension> = {}, galleryExtensionProperties: any = {}, assets: Partial<IGalleryExtensionAssets> = {}): IGalleryExtension {
|
function aGalleryExtension(name: string, properties: Partial<IGalleryExtension> = {}, galleryExtensionProperties: IStringDictionary<unknown> = {}, assets: Partial<IGalleryExtensionAssets> = {}): IGalleryExtension {
|
||||||
const targetPlatform = getTargetPlatform(platform, arch);
|
const targetPlatform = getTargetPlatform(platform, arch);
|
||||||
const galleryExtension = <IGalleryExtension>Object.create({ name, publisher: 'pub', version: '1.0.0', allTargetPlatforms: [targetPlatform], properties: {}, assets: {}, ...properties });
|
const galleryExtension = <IGalleryExtension>Object.create({ name, publisher: 'pub', version: '1.0.0', allTargetPlatforms: [targetPlatform], properties: {}, assets: {}, ...properties });
|
||||||
galleryExtension.properties = { ...galleryExtension.properties, dependencies: [], targetPlatform, ...galleryExtensionProperties };
|
galleryExtension.properties = { ...galleryExtension.properties, dependencies: [], targetPlatform, ...galleryExtensionProperties };
|
||||||
|
|||||||
@@ -33,10 +33,12 @@ export class ExtensionRecommendationNotificationServiceChannel implements IServe
|
|||||||
|
|
||||||
constructor(private service: IExtensionRecommendationNotificationService) { }
|
constructor(private service: IExtensionRecommendationNotificationService) { }
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
listen(_: unknown, event: string): Event<any> {
|
listen(_: unknown, event: string): Event<any> {
|
||||||
throw new Error(`Event not found: ${event}`);
|
throw new Error(`Event not found: ${event}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
call(_: unknown, command: string, args?: any): Promise<any> {
|
call(_: unknown, command: string, args?: any): Promise<any> {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'promptImportantExtensionsInstallNotification': return this.service.promptImportantExtensionsInstallNotification(args[0]);
|
case 'promptImportantExtensionsInstallNotification': return this.service.promptImportantExtensionsInstallNotification(args[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user