Path: blob/main/src/vs/platform/extensionManagement/common/extensionGalleryManifestServiceIpc.ts
5281 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Barrier } from '../../../base/common/async.js';6import { Emitter, Event } from '../../../base/common/event.js';7import { IChannelServer } from '../../../base/parts/ipc/common/ipc.js';8import { IProductService } from '../../product/common/productService.js';9import { IExtensionGalleryManifest, IExtensionGalleryManifestService, ExtensionGalleryManifestStatus } from './extensionGalleryManifest.js';10import { ExtensionGalleryManifestService } from './extensionGalleryManifestService.js';1112export class ExtensionGalleryManifestIPCService extends ExtensionGalleryManifestService implements IExtensionGalleryManifestService {1314declare readonly _serviceBrand: undefined;1516private _onDidChangeExtensionGalleryManifest = this._register(new Emitter<IExtensionGalleryManifest | null>());17override readonly onDidChangeExtensionGalleryManifest = this._onDidChangeExtensionGalleryManifest.event;1819private _onDidChangeExtensionGalleryManifestStatus = this._register(new Emitter<ExtensionGalleryManifestStatus>());20override readonly onDidChangeExtensionGalleryManifestStatus = this._onDidChangeExtensionGalleryManifestStatus.event;2122private _extensionGalleryManifest: IExtensionGalleryManifest | null | undefined;23private readonly barrier = new Barrier();2425override get extensionGalleryManifestStatus(): ExtensionGalleryManifestStatus {26return this._extensionGalleryManifest ? ExtensionGalleryManifestStatus.Available : ExtensionGalleryManifestStatus.Unavailable;27}2829constructor(30server: IChannelServer<unknown>,31@IProductService productService: IProductService32) {33super(productService);34server.registerChannel('extensionGalleryManifest', {35listen: () => Event.None,36// eslint-disable-next-line @typescript-eslint/no-explicit-any37call: async (context: any, command: string, args?: any): Promise<any> => {38switch (command) {39case 'setExtensionGalleryManifest': return Promise.resolve(this.setExtensionGalleryManifest(args[0]));40}41throw new Error('Invalid call');42}43});44}4546override async getExtensionGalleryManifest(): Promise<IExtensionGalleryManifest | null> {47await this.barrier.wait();48return this._extensionGalleryManifest ?? null;49}5051private setExtensionGalleryManifest(manifest: IExtensionGalleryManifest | null): void {52this._extensionGalleryManifest = manifest;53this._onDidChangeExtensionGalleryManifest.fire(manifest);54this._onDidChangeExtensionGalleryManifestStatus.fire(this.extensionGalleryManifestStatus);55this.barrier.open();56}5758}596061