sussudio
Version:
An unofficial VS Code Internal API
43 lines (42 loc) • 1.91 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { isBoolean } from "../../../base/common/types.mjs";
import { RequestService } from "../browser/requestService.mjs";
import { RequestChannelClient } from "../common/requestIpc.mjs";
export class SharedProcessRequestService {
configurationService;
productService;
logService;
browserRequestService;
mainRequestService;
constructor(mainProcessService, configurationService, productService, logService) {
this.configurationService = configurationService;
this.productService = productService;
this.logService = logService;
this.browserRequestService = new RequestService(configurationService, logService);
this.mainRequestService = new RequestChannelClient(mainProcessService.getChannel('request'));
}
request(options, token) {
return this.getRequestService().request(options, token);
}
async resolveProxy(url) {
return this.getRequestService().resolveProxy(url);
}
getRequestService() {
if (this.isMainRequestServiceEnabled()) {
this.logService.trace('Using main request service');
return this.mainRequestService;
}
this.logService.trace('Using browser request service');
return this.browserRequestService;
}
isMainRequestServiceEnabled() {
const value = this.configurationService.getValue('developer.sharedProcess.redirectRequestsToMain');
if (isBoolean(value)) {
return value;
}
return this.productService.quality !== 'stable';
}
}