Electron Updater API リファレンス
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
This page documents all available methods, events, and configuration options for the Electron Updater.
Core Methods
Section titled “Core Methods”notifyAppReady()
notifyAppReady() というセクションすべてのアプリ起動時に呼び出す必要があります。 bundle が正常に読み込まれたことを確認し、自動ロールバックを防止します。
await updater.notifyAppReady();download(options) というセクション
URL から bundle をダウンロードします。クリップボードにコピー
const bundle = await updater.download({ url: 'https://example.com/bundle.zip', version: '1.0.1', checksum: 'sha256-hash', // Optional but recommended sessionKey: '...', // For encrypted bundles});__CAPGO_KEEP_0__
| __CAPGO_KEEP_1__ | __CAPGO_KEEP_2__ | __CAPGO_KEEP_3__ | __CAPGO_KEEP_4__ |
|---|---|---|---|
url | __CAPGO_KEEP_5__ | __CAPGO_KEEP_6__ | __CAPGO_KEEP_7__ |
version | __CAPGO_KEEP_8__ | __CAPGO_KEEP_9__ | __CAPGO_KEEP_10__ |
checksum | __CAPGO_KEEP_11__ | No | __CAPGO_KEEP_0__ |
sessionKey | 文字列 | No | __CAPGO_KEEP_0__ |
戻り値: BundleInfo オブジェクトに id, version, status
next(options)というセクション
アプリ再起動時に次のバンドルをロードするようにキューします。クリップボードにコピー
await updater.next({ id: 'bundle-id' });__CAPGO_KEEP_0__
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
id | 文字列 | はい | バンドルIDをキュー |
set(options)
セクションのタイトル “set(options)”即座にバンドルに切り替え、再読み込みアプリ
await updater.set({ id: 'bundle-id' });パラメータ:
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
id | 文字列 | はい | bundle IDを有効化する |
reload()
セクションのタイトル “reload()”現在のbundleでアプリを手動で再読み込みします。
await updater.reload();delete(options)
「delete(options)」セクション指定されたIDのバンドルを削除します。
await updater.delete({ id: 'bundle-id' });引数:
| オプション | 型 | 必要 | 説明 |
|---|---|---|---|
id | string | はい | 削除するバンドルのID |
reset(options)
セクションのタイトル “reset(options)”バンドルをリセットするか、最後に成功したバンドルに戻します。
// Reset to builtinawait updater.reset({ toLastSuccessful: false });
// Reset to last successful bundleawait updater.reset({ toLastSuccessful: true });パラメータ
| オプション | 型 | 必要 | 説明 |
|---|---|---|---|
toLastSuccessful | boolean | No | trueの場合、最後に成功したバンドルに戻します。 |
バンドル情報
「バンドル情報」セクションcurrent()
「current()」セクション現在のバンドルとネイティブバージョンの情報を取得します。
const info = await updater.current();// { bundle: { id, version, status }, native: '1.0.0' }list(options)
「list(options)」セクションダウンロードしたすべてのバンドルをリストします。
const bundles = await updater.list();// [{ id, version, status, downloaded, checksum }, ...]getNextBundle()
「getNextBundle()」セクション次の再起動で実行されるバンドルの情報を取得します。
const next = await updater.getNextBundle();// { id, version, status } or nullgetFailedUpdate()
getFailedUpdate()のセクション最後の失敗した更新情報を取得する (ロールバックのデバッグに役立ちます)。
const failed = await updater.getFailedUpdate();// { id, version, reason } or nullgetBuiltinVersion()
getBuiltinVersion()のセクションアプリバイナリに組み込まれたバージョンを取得する。
const version = await updater.getBuiltinVersion();// '1.0.0'アップデートチェック
アップデートチェックのセクションgetLatest(options)
最新バージョンを取得する(getLatest(options))最新バージョンが利用可能かどうかをサーバーで確認します。
const latest = await updater.getLatest();
if (latest.url && !latest.error) { // Update available console.log('New version:', latest.version); console.log('Download URL:', latest.url);} else if (latest.error) { console.error('Error checking updates:', latest.error);}戻り値:
| プロパティ | 型 | 説明 |
|---|---|---|
url | 文字列 | ダウンロードURL(更新がない場合は空) |
version | 文字列 | 利用可能なバージョン |
checksum | 文字列 | SHA256 チェックサム |
sessionKey | 文字列 | 暗号化セッション キー |
error | 文字列 | チェックが失敗した場合のエラーメッセージ |
message | 文字列 | サーバーメッセージ |
チャネル管理
チャネル管理のセクションsetChannel(options)
setChannel(options)のセクションデバイスを特定のチャネルに割り当てる
await updater.setChannel({ channel: 'beta' });unsetChannel(options)
unsetChannel(options)のセクションデフォルトの設定に戻す
await updater.unsetChannel();getChannel()
getChannel()のセクション現在のチャンネル設定を取得
const channel = await updater.getChannel();// { channel: 'production', status: 'set' }listChannels()
listChannels()のセクションこのアプリの利用可能なチャンネルの一覧を表示
const channels = await updater.listChannels();// ['production', 'beta', 'staging']遅延条件
「遅延条件」セクションダウンロードされた更新が適用されるタイミングを制御します。
setMultiDelay(options)
「setMultiDelay(options)」セクション更新が適用される前に満たす必要がある条件を設定します。
// Wait for app to be backgroundedawait updater.setMultiDelay({ delayConditions: [{ kind: 'background' }]});
// Wait until specific dateawait updater.setMultiDelay({ delayConditions: [{ kind: 'date', value: '2024-12-25T00:00:00Z' }]});
// Wait for app to be killed and restartedawait updater.setMultiDelay({ delayConditions: [{ kind: 'kill' }]});
// Multiple conditions (all must be met)await updater.setMultiDelay({ delayConditions: [ { kind: 'background' }, { kind: 'date', value: '2024-12-25T00:00:00Z' } ]});遅延条件の種類:
| 種類 | 値 | 説明 |
|---|---|---|
background | __CAPGO_KEEP_0__ (ms) | アプリがバックグラウンドに移動するのを待つ |
kill | - | アプリが終了して再起動されるのを待つ |
date | ISO 日付文字列 | 特定の日時まで待つ |
nativeVersion | バージョン文字列 | ネイティブアプリの更新を待つ |
cancelDelay()
cancelDelay()すべての遅延条件をクリアし、次のチェックで即座に更新を適用する
await updater.cancelDelay();デバイス識別
Section titled “デバイスの識別”getDeviceId()
Section titled “getDeviceId()”一意のデバイス識別子を取得します。
const deviceId = await updater.getDeviceId();// 'uuid-xxxx-xxxx-xxxx'setCustomId(options)
Section titled “setCustomId(options)”デバイスにカスタム識別子を設定します(分析用)。
await updater.setCustomId({ customId: 'user-123' });setUpdateUrl(options)
セクション「setUpdateUrl(options)」実行時で更新サーバーURLを変更します。
await updater.setUpdateUrl({ url: 'https://my-server.com/updates' });セクション「setStatsUrl(options)」
実行時で統計報告URLを変更します。クリップボードにコピー
await updater.setStatsUrl({ url: 'https://my-server.com/stats' });setUpdateUrl(options)セクションの説明
「setChannelUrl(options)」セクションチャンネル管理URLを変更する
await updater.setChannelUrl({ url: 'https://my-server.com/channel' });setAppId(options)
「setAppId(options)」セクション実行時App IDを変更する
await updater.setAppId({ appId: 'com.example.newapp' });getAppId()
Section titled “getAppId()”getApp IDを取得する
const appId = await updater.getAppId();setDebugMenu(options)
Section titled “setDebugMenu(options)”デバッグメニューの有効化/無効化
await updater.setDebugMenu({ enabled: true });isDebugMenuEnabled()
Section titled “isDebugMenuEnabled()”デバッグメニューが有効かどうかを確認する
const enabled = await updater.isDebugMenuEnabled();イベント
「イベント」セクション__CAPGO_KEEP_0__を使用して更新イベントをリスン addListener:
updater.addListener('eventName', (event) => { // Handle event});利用可能なイベント
「利用可能なイベント」セクション| イベント | ペイロード | 説明 |
|---|---|---|
download | { percent, status } | ダウンロード進行状況の更新 |
updateAvailable | { bundle } | 新しい更新が利用可能 |
noNeedUpdate | { message } | 既に最新です |
downloadComplete | { bundle } | ダウンロードが正常に完了しました |
downloadFailed | { bundle, error } | ダウンロードに失敗しました |
breakingAvailable | { bundle } | 非ネイティブの更新が必要です (ネイティブの更新が必要です) |
updateFailed | { bundle, reason } | 更新のインストールに失敗しました |
appReloaded | {} | アプリが再読み込みされました |
appReady | {} | notifyAppReady() が呼び出されました |
例:フル イベント ハンドリング
セクション「例:フル イベント ハンドリング」// Progress trackingupdater.addListener('download', (event) => { updateProgressBar(event.percent);});
// Update available notificationupdater.addListener('updateAvailable', (event) => { showNotification(`Update ${event.bundle.version} available!`);});
// Handle completionupdater.addListener('downloadComplete', async (event) => { // Queue for next restart await updater.next({ id: event.bundle.id }); showNotification('Update will apply on next restart');});
// Handle failuresupdater.addListener('updateFailed', (event) => { console.error('Update failed:', event.reason); reportError(event);});コンストラクタ オプション
セクション「コンストラクタ オプション」全ての設定オプション ElectronUpdater:
const updater = new ElectronUpdater({ // Required appId: 'com.example.app',
// Version override version: '1.0.0', // Override builtin version detection
// Server URLs updateUrl: 'https://plugin.capgo.app/updates', channelUrl: 'https://plugin.capgo.app/channel_self', statsUrl: 'https://plugin.capgo.app/stats',
// Behavior autoUpdate: true, // Enable automatic update checks appReadyTimeout: 10000, // Milliseconds before rollback (default: 10000) autoDeleteFailed: true, // Auto-delete failed bundles autoDeletePrevious: true, // Auto-delete old bundles resetWhenUpdate: true, // Reset to builtin on native update
// Channels defaultChannel: 'production',
// Direct Update Mode directUpdate: false, // 'atInstall' | 'onLaunch' | 'always' | false
// Security publicKey: '...', // RSA public key for E2E encryption
// Dynamic Configuration allowModifyUrl: false, // Allow runtime URL changes allowModifyAppId: false, // Allow runtime App ID changes persistCustomId: false, // Persist custom ID across updates persistModifyUrl: false, // Persist URL changes
// Debug debugMenu: false, // Enable debug menu (Ctrl+Shift+D) disableJSLogging: false, // Disable console logs
// Periodic Updates periodCheckDelay: 0, // Seconds between auto-checks (0 = disabled, min 600)});Electron Updater API リファレンスから続ける
Electron Updater API リファレンスから続けるセクションElectron Updater __CAPGO_KEEP_0__ リファレンスを使用している場合 Electron Updater API リファレンス Electron Updater API リファレンスを使用して、ダッシュボードと API のオペレーションを計画するには、API を接続する必要があります。 @capgo/electron-updater を使用することで、ネイティブ機能を実現することができます。 @capgo/electron-updater を使用することで、ネイティブ機能を実現することができます。 API の概要 API の実装詳細 導入 Introductionの実装詳細について API キー 実装詳細についてはAPI キー、 デバイス 実装詳細についてはデバイス。