sussudio
Version:
An unofficial VS Code Internal API
83 lines (82 loc) • 4.7 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
import { CancellationToken } from "../../../base/common/cancellation.mjs";
import { IConfigurationService } from "../../configuration/common/configuration.mjs";
import { IEnvironmentMainService } from "../../environment/electron-main/environmentMainService.mjs";
import { ILifecycleMainService } from "../../lifecycle/electron-main/lifecycleMainService.mjs";
import { ILogService } from "../../log/common/log.mjs";
import { INativeHostMainService } from "../../native/electron-main/nativeHostMainService.mjs";
import { IProductService } from "../../product/common/productService.mjs";
import { asJson, IRequestService } from "../../request/common/request.mjs";
import { ITelemetryService } from "../../telemetry/common/telemetry.mjs";
import { State } from "../common/update.mjs";
import { AbstractUpdateService, createUpdateURL } from "./abstractUpdateService.mjs";
let LinuxUpdateService = class LinuxUpdateService extends AbstractUpdateService {
telemetryService;
nativeHostMainService;
constructor(lifecycleMainService, configurationService, telemetryService, environmentMainService, requestService, logService, nativeHostMainService, productService) {
super(lifecycleMainService, configurationService, environmentMainService, requestService, logService, productService);
this.telemetryService = telemetryService;
this.nativeHostMainService = nativeHostMainService;
}
buildUpdateFeedUrl(quality) {
return createUpdateURL(`linux-${process.arch}`, quality, this.productService);
}
doCheckForUpdates(context) {
if (!this.url) {
return;
}
this.setState(State.CheckingForUpdates(context));
this.requestService.request({ url: this.url }, CancellationToken.None)
.then(asJson)
.then(update => {
if (!update || !update.url || !update.version || !update.productVersion) {
this.telemetryService.publicLog2('update:notAvailable', { explicit: !!context });
this.setState(State.Idle(1 /* UpdateType.Archive */));
}
else {
this.setState(State.AvailableForDownload(update));
}
})
.then(undefined, err => {
this.logService.error(err);
this.telemetryService.publicLog2('update:notAvailable', { explicit: !!context });
// only show message when explicitly checking for updates
const message = !!context ? (err.message || err) : undefined;
this.setState(State.Idle(1 /* UpdateType.Archive */, message));
});
}
async doDownloadUpdate(state) {
// Use the download URL if available as we don't currently detect the package type that was
// installed and the website download page is more useful than the tarball generally.
if (this.productService.downloadUrl && this.productService.downloadUrl.length > 0) {
this.nativeHostMainService.openExternal(undefined, this.productService.downloadUrl);
}
else if (state.update.url) {
this.nativeHostMainService.openExternal(undefined, state.update.url);
}
this.setState(State.Idle(1 /* UpdateType.Archive */));
}
};
LinuxUpdateService = __decorate([
__param(0, ILifecycleMainService),
__param(1, IConfigurationService),
__param(2, ITelemetryService),
__param(3, IEnvironmentMainService),
__param(4, IRequestService),
__param(5, ILogService),
__param(6, INativeHostMainService),
__param(7, IProductService)
], LinuxUpdateService);
export { LinuxUpdateService };