src/vs/platform/update/common/update.ts
127 LOC · 127 covered · 0 uncovered · 1 ranges · 46 concepts · 1 introducers · 36 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
/*---------------------------------------------------------------------------------------------
updateUtils.ts ×13
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from '../../../base/common/event.js';
import { upcast } from '../../../base/common/types.js';
import { createDecorator } from '../../instantiation/common/instantiation.js';
export interface IUpdate {
version: string; // Build commit ID
productVersion?: string; // Product version like 1.2.3
timestamp?: number;
url?: string;
sha256hash?: string;
}
/**
* Updates are run as a state machine:
*
* Uninitialized
* ↓
* Idle
* ↓ ↑
* Checking for Updates → Available for Download
* ↓ ↓
* ← Overwriting
* Downloading ↑
* → Ready
* ↓ ↑
* Downloaded → Updating
*
* Available: There is an update available for download (linux, darwin on metered connection).
* Ready: Code will be updated as soon as it restarts (win32, darwin).
* Downloaded: There is an update ready to be installed in the background (win32).
* Overwriting: A newer update is being downloaded to replace the pending update (darwin).
* Cancelling: Updates are being disabled at runtime; in-flight/pending work is being torn down before Disabled.
*/
export const enum StateType {
Uninitialized = 'uninitialized',
Idle = 'idle',
Disabled = 'disabled',
CheckingForUpdates = 'checking for updates',
AvailableForDownload = 'available for download',
Downloading = 'downloading',
Downloaded = 'downloaded',
Updating = 'updating',
Ready = 'ready',
Overwriting = 'overwriting',
Cancelling = 'cancelling',
Restarting = 'restarting',
}
export const enum UpdateType {
Setup,
Archive,
Snap
}
export const enum DisablementReason {
NotBuilt,
DisabledByEnvironment,
ManuallyDisabled,
Policy,
MissingConfiguration,
InvalidConfiguration,
RunningAsAdmin,
}
export type Uninitialized = { type: StateType.Uninitialized };
export type Disabled = { type: StateType.Disabled; reason: DisablementReason };
export type Idle = { type: StateType.Idle; updateType: UpdateType; error?: string; notAvailable?: boolean };
export type CheckingForUpdates = { type: StateType.CheckingForUpdates; explicit: boolean };
export type AvailableForDownload = { type: StateType.AvailableForDownload; update: IUpdate; canInstall?: boolean };
export type Downloading = { type: StateType.Downloading; update?: IUpdate; explicit: boolean; overwrite: boolean; downloadedBytes?: number; totalBytes?: number; startTime?: number };
export type Downloaded = { type: StateType.Downloaded; update: IUpdate; explicit: boolean; overwrite: boolean };
export type Updating = { type: StateType.Updating; update: IUpdate; currentProgress?: number; maxProgress?: number; explicit: boolean };
export type Ready = { type: StateType.Ready; update: IUpdate; explicit: boolean; overwrite: boolean };
export type Overwriting = { type: StateType.Overwriting; update: IUpdate; explicit: boolean };
export type Cancelling = { type: StateType.Cancelling };
export type Restarting = { type: StateType.Restarting; update: IUpdate };
export type State = Uninitialized | Disabled | Idle | CheckingForUpdates | AvailableForDownload | Downloading | Downloaded | Updating | Ready | Overwriting | Cancelling | Restarting;
export const State = {
Uninitialized: upcast<Uninitialized>({ type: StateType.Uninitialized }),
Disabled: (reason: DisablementReason): Disabled => ({ type: StateType.Disabled, reason }),
Idle: (updateType: UpdateType, error?: string, notAvailable?: boolean): Idle => ({ type: StateType.Idle, updateType, error, notAvailable }),
CheckingForUpdates: (explicit: boolean): CheckingForUpdates => ({ type: StateType.CheckingForUpdates, explicit }),
AvailableForDownload: (update: IUpdate, canInstall?: boolean): AvailableForDownload => ({ type: StateType.AvailableForDownload, update, canInstall }),
Downloading: (update: IUpdate | undefined, explicit: boolean, overwrite: boolean, downloadedBytes?: number, totalBytes?: number, startTime?: number): Downloading => ({ type: StateType.Downloading, update, explicit, overwrite, downloadedBytes, totalBytes, startTime }),
Downloaded: (update: IUpdate, explicit: boolean, overwrite: boolean): Downloaded => ({ type: StateType.Downloaded, update, explicit, overwrite }),
Updating: (update: IUpdate, explicit: boolean, currentProgress?: number, maxProgress?: number): Updating => ({ type: StateType.Updating, update, explicit, currentProgress, maxProgress }),
Ready: (update: IUpdate, explicit: boolean, overwrite: boolean): Ready => ({ type: StateType.Ready, update, explicit, overwrite }),
Overwriting: (update: IUpdate, explicit: boolean): Overwriting => ({ type: StateType.Overwriting, update, explicit }),
Cancelling: upcast<Cancelling>({ type: StateType.Cancelling }),
Restarting: (update: IUpdate): Restarting => ({ type: StateType.Restarting, update }),
};
export interface IAutoUpdater extends Event.NodeEventEmitter {
setFeedURL(url: string): void;
checkForUpdates(): void;
applyUpdate?(): Promise<void>;
quitAndInstall(): void;
}
export const IUpdateService = createDecorator<IUpdateService>('updateService');
export interface IUpdateService {
readonly _serviceBrand: undefined;
readonly onStateChange: Event<State>;
readonly state: State;
checkForUpdates(explicit: boolean): Promise<void>;
downloadUpdate(explicit: boolean): Promise<void>;
applyUpdate(): Promise<void>;
quitAndInstall(): Promise<void>;
/**
* @deprecated This method should not be used any more. It will be removed in a future release.
*/
isLatestVersion(): Promise<boolean | undefined>;
_applySpecificUpdate(packagePath: string): Promise<void>;
setInternalOrg(internalOrg: string | undefined): Promise<void>;
}