progress.d.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /** Stages of progress while downloading VS Code */
  2. export declare enum ProgressReportStage {
  3. /** Initial fetch of the latest version if not explicitly given */
  4. FetchingVersion = "fetchingVersion",
  5. /** Always fired when the version is determined. */
  6. ResolvedVersion = "resolvedVersion",
  7. /** Fired before fetching info about the latest Insiders version, when requesting insiders builds */
  8. FetchingInsidersMetadata = "fetchingInsidersMetadata",
  9. /** Fired if the current Insiders is out of date */
  10. ReplacingOldInsiders = "replacingOldInsiders",
  11. /** Fired when an existing install is found which does not require a download */
  12. FoundMatchingInstall = "foundMatchingInstall",
  13. /** Fired before the URL to the download zip or tarball is looked up */
  14. ResolvingCDNLocation = "resolvingCDNLocation",
  15. /** Fired continuously while a download happens */
  16. Downloading = "downloading",
  17. /** Fired when the command is issued to do a synchronous extraction. May not fire depending on the platform and options. */
  18. ExtractingSynchonrously = "extractingSynchonrously",
  19. /** Fired when the download fails and a retry will be attempted */
  20. Retrying = "retrying",
  21. /** Fired after folder is downloaded and unzipped */
  22. NewInstallComplete = "newInstallComplete"
  23. }
  24. export type ProgressReport = {
  25. stage: ProgressReportStage.FetchingVersion;
  26. } | {
  27. stage: ProgressReportStage.ResolvedVersion;
  28. version: string;
  29. } | {
  30. stage: ProgressReportStage.FetchingInsidersMetadata;
  31. } | {
  32. stage: ProgressReportStage.ReplacingOldInsiders;
  33. downloadedPath: string;
  34. oldHash: string;
  35. oldDate: Date;
  36. newHash: string;
  37. newDate: Date;
  38. } | {
  39. stage: ProgressReportStage.FoundMatchingInstall;
  40. downloadedPath: string;
  41. } | {
  42. stage: ProgressReportStage.ResolvingCDNLocation;
  43. url: string;
  44. } | {
  45. stage: ProgressReportStage.Downloading;
  46. url: string;
  47. totalBytes: number;
  48. bytesSoFar: number;
  49. } | {
  50. stage: ProgressReportStage.Retrying;
  51. error: Error;
  52. attempt: number;
  53. totalAttempts: number;
  54. } | {
  55. stage: ProgressReportStage.ExtractingSynchonrously;
  56. } | {
  57. stage: ProgressReportStage.NewInstallComplete;
  58. downloadedPath: string;
  59. };
  60. export interface ProgressReporter {
  61. report(report: ProgressReport): void;
  62. error(err: unknown): void;
  63. }
  64. /** Silent progress reporter */
  65. export declare class SilentReporter implements ProgressReporter {
  66. report(): void;
  67. error(): void;
  68. }
  69. /** Default progress reporter that logs VS Code download progress to console */
  70. export declare const makeConsoleReporter: () => Promise<ProgressReporter>;