メインコンテンツにジャンプ

Electron Updater API リファレンス

GitHub

This page documents all available methods, events, and configuration options for the Electron Updater.

すべてのアプリ起動時に呼び出す必要があります。 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

クリップボードにコピー

await updater.next({ id: 'bundle-id' });

__CAPGO_KEEP_0__

オプションタイプ必要説明
id文字列はいバンドルIDをキュー

即座にバンドルに切り替え、再読み込みアプリ

await updater.set({ id: 'bundle-id' });

パラメータ:

オプションタイプ必要説明
id文字列はいbundle IDを有効化する

現在のbundleでアプリを手動で再読み込みします。

await updater.reload();

指定されたIDのバンドルを削除します。

await updater.delete({ id: 'bundle-id' });

引数:

オプション必要説明
idstringはい削除するバンドルのID

バンドルをリセットするか、最後に成功したバンドルに戻します。

// Reset to builtin
await updater.reset({ toLastSuccessful: false });
// Reset to last successful bundle
await updater.reset({ toLastSuccessful: true });

パラメータ

オプション必要説明
toLastSuccessfulbooleanNotrueの場合、最後に成功したバンドルに戻します。

現在のバンドルとネイティブバージョンの情報を取得します。

const info = await updater.current();
// { bundle: { id, version, status }, native: '1.0.0' }

ダウンロードしたすべてのバンドルをリストします。

const bundles = await updater.list();
// [{ id, version, status, downloaded, checksum }, ...]

次の再起動で実行されるバンドルの情報を取得します。

const next = await updater.getNextBundle();
// { id, version, status } or null

最後の失敗した更新情報を取得する (ロールバックのデバッグに役立ちます)。

const failed = await updater.getFailedUpdate();
// { id, version, reason } or null

アプリバイナリに組み込まれたバージョンを取得する。

const version = await updater.getBuiltinVersion();
// '1.0.0'

最新バージョンが利用可能かどうかをサーバーで確認します。

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文字列サーバーメッセージ

デバイスを特定のチャネルに割り当てる

await updater.setChannel({ channel: 'beta' });

デフォルトの設定に戻す

await updater.unsetChannel();

現在のチャンネル設定を取得

const channel = await updater.getChannel();
// { channel: 'production', status: 'set' }

このアプリの利用可能なチャンネルの一覧を表示

const channels = await updater.listChannels();
// ['production', 'beta', 'staging']

ダウンロードされた更新が適用されるタイミングを制御します。

更新が適用される前に満たす必要がある条件を設定します。

// Wait for app to be backgrounded
await updater.setMultiDelay({
delayConditions: [{ kind: 'background' }]
});
// Wait until specific date
await updater.setMultiDelay({
delayConditions: [{ kind: 'date', value: '2024-12-25T00:00:00Z' }]
});
// Wait for app to be killed and restarted
await 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-アプリが終了して再起動されるのを待つ
dateISO 日付文字列特定の日時まで待つ
nativeVersionバージョン文字列ネイティブアプリの更新を待つ

cancelDelay()

cancelDelay()

すべての遅延条件をクリアし、次のチェックで即座に更新を適用する

await updater.cancelDelay();

一意のデバイス識別子を取得します。

const deviceId = await updater.getDeviceId();
// 'uuid-xxxx-xxxx-xxxx'

デバイスにカスタム識別子を設定します(分析用)。

await updater.setCustomId({ customId: 'user-123' });

実行時で更新サーバー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' });

実行時App IDを変更する

await updater.setAppId({ appId: 'com.example.newapp' });

getApp IDを取得する

const appId = await updater.getAppId();

デバッグメニューの有効化/無効化

await updater.setDebugMenu({ enabled: true });

デバッグメニューが有効かどうかを確認する

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 tracking
updater.addListener('download', (event) => {
updateProgressBar(event.percent);
});
// Update available notification
updater.addListener('updateAvailable', (event) => {
showNotification(`Update ${event.bundle.version} available!`);
});
// Handle completion
updater.addListener('downloadComplete', async (event) => {
// Queue for next restart
await updater.next({ id: event.bundle.id });
showNotification('Update will apply on next restart');
});
// Handle failures
updater.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 キー、 デバイス 実装詳細についてはデバイス。