Interface ElectronUpdater

Auto-updater interface for application updates. Provides methods for checking, downloading, and installing updates.

interface ElectronUpdater {
/**
* Checks for available updates from the update server.
* @param options Optional configuration for the check
* @param options.allowPrerelease Whether to include prerelease versions (default: false)
* @returns Promise with update availability and version information
*/
checkForUpdates: (options?: { allowPrerelease?: boolean }) => Promise<{
updateAvailable: boolean;
version?: string;
releaseNotes?: string;
releaseDate?: string;
}>;

/**
* Initiates download of an available update.
* @returns Promise that resolves when download starts
*/
downloadUpdate: () => Promise<void>;

/**
* Quits the application and installs the downloaded update.
* @returns Promise that resolves before app quits
*/
installUpdate: () => Promise<void>;

/**
* Subscribes to update available events.
* @param callback Function to call when an update is available
* @returns Function to unsubscribe from the event
*/
onUpdateAvailable: (
callback: (info: {
version: string;
releaseNotes: string;
releaseDate: string;
}) => void,
) => () => void;

/**
* Subscribes to download progress events.
* @param callback Function to call with download progress updates
* @returns Function to unsubscribe from the event
*/
onDownloadProgress: (
callback: (progress: {
percent: number;
bytesPerSecond: number;
transferred: number;
total: number;
}) => void,
) => () => void;

/**
* Subscribes to update downloaded events.
* @param callback Function to call when download is complete
* @returns Function to unsubscribe from the event
*/
onUpdateDownloaded: (
callback: (info: { version: string }) => void,
) => () => void;

/**
* Subscribes to update error events.
* @param callback Function to call when an update error occurs
* @returns Function to unsubscribe from the event
*/
onUpdateError: (
callback: (error: {
message: string;
stack?: string;
name?: string;
}) => void,
) => () => void;
}
interface ElectronUpdater {
    checkForUpdates: (
        options?: { allowPrerelease?: boolean },
    ) => Promise<
        {
            updateAvailable: boolean;
            version?: string;
            releaseNotes?: string;
            releaseDate?: string;
        },
    >;
    downloadUpdate: () => Promise<void>;
    installUpdate: () => Promise<void>;
    onUpdateAvailable: (
        callback: (
            info: { version: string; releaseNotes: string; releaseDate: string },
        ) => void,
    ) => () => void;
    onDownloadProgress: (
        callback: (
            progress: {
                percent: number;
                bytesPerSecond: number;
                transferred: number;
                total: number;
            },
        ) => void,
    ) => () => void;
    onUpdateDownloaded: (
        callback: (info: { version: string }) => void,
    ) => () => void;
    onUpdateError: (
        callback: (
            error: { message: string; stack?: string; name?: string },
        ) => void,
    ) => () => void;
}

Properties

checkForUpdates: (
    options?: { allowPrerelease?: boolean },
) => Promise<
    {
        updateAvailable: boolean;
        version?: string;
        releaseNotes?: string;
        releaseDate?: string;
    },
>

Checks for available updates from the update server.

Type declaration

    • (
          options?: { allowPrerelease?: boolean },
      ): Promise<
          {
              updateAvailable: boolean;
              version?: string;
              releaseNotes?: string;
              releaseDate?: string;
          },
      >
    • Parameters

      • Optionaloptions: { allowPrerelease?: boolean }

        Optional configuration for the check

        • OptionalallowPrerelease?: boolean

          Whether to include prerelease versions (default: false)

      Returns Promise<
          {
              updateAvailable: boolean;
              version?: string;
              releaseNotes?: string;
              releaseDate?: string;
          },
      >

      Promise with update availability and version information

downloadUpdate: () => Promise<void>

Initiates download of an available update.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

      Promise that resolves when download starts

installUpdate: () => Promise<void>

Quits the application and installs the downloaded update.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

      Promise that resolves before app quits

onUpdateAvailable: (
    callback: (
        info: { version: string; releaseNotes: string; releaseDate: string },
    ) => void,
) => () => void

Subscribes to update available events.

Type declaration

    • (
          callback: (
              info: { version: string; releaseNotes: string; releaseDate: string },
          ) => void,
      ): () => void
    • Parameters

      • callback: (info: { version: string; releaseNotes: string; releaseDate: string }) => void

        Function to call when an update is available

      Returns () => void

      Function to unsubscribe from the event

onDownloadProgress: (
    callback: (
        progress: {
            percent: number;
            bytesPerSecond: number;
            transferred: number;
            total: number;
        },
    ) => void,
) => () => void

Subscribes to download progress events.

Type declaration

    • (
          callback: (
              progress: {
                  percent: number;
                  bytesPerSecond: number;
                  transferred: number;
                  total: number;
              },
          ) => void,
      ): () => void
    • Parameters

      • callback: (
            progress: {
                percent: number;
                bytesPerSecond: number;
                transferred: number;
                total: number;
            },
        ) => void

        Function to call with download progress updates

      Returns () => void

      Function to unsubscribe from the event

onUpdateDownloaded: (
    callback: (info: { version: string }) => void,
) => () => void

Subscribes to update downloaded events.

Type declaration

    • (callback: (info: { version: string }) => void): () => void
    • Parameters

      • callback: (info: { version: string }) => void

        Function to call when download is complete

      Returns () => void

      Function to unsubscribe from the event

onUpdateError: (
    callback: (
        error: { message: string; stack?: string; name?: string },
    ) => void,
) => () => void

Subscribes to update error events.

Type declaration

    • (
          callback: (
              error: { message: string; stack?: string; name?: string },
          ) => void,
      ): () => void
    • Parameters

      • callback: (error: { message: string; stack?: string; name?: string }) => void

        Function to call when an update error occurs

      Returns () => void

      Function to unsubscribe from the event