Electron Updater API リファレンス
インストール手順とこのプラグインのフル マークダウン ガイドを含むセットアップ コマンドをコピーします。
すべての利用可能なメソッド、イベント、設定オプションをドキュメント化しています。
Core Methods
Core MethodsnotifyAppReady()
notifyAppReady()のセクションアプリ起動毎に呼び出す必要があります。 bundleの正常なロードを確認し、自動ロールバックを防止します。
await updater.notifyAppReady();download(options)
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__
| オプション | 型 | 必要 | 説明 |
|---|---|---|---|
url | 文字列 | はい | ダウンロードするためのバンドルURL |
version | 文字列 | はい | バンドルのバージョン識別子 |
checksum | string | なし | SHA256のチェックサムによる検証 |
sessionKey | string | なし | 暗号化されたバンドルのセッションキー |
戻り値: BundleInfo オブジェクトに id, version, status
次のオプション
セクション「次のオプション」アプリ再起動時に次のバンドルをロードするようにキューします。
await updater.next({ id: 'bundle-id' });パラメータ:
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
id | 文字列 | はい | バンドル ID をキューに設定 |
set(options) というセクション
すぐにバンドルに切り替え、再読み込みします。クリップボードにコピー
await updater.set({ id: 'bundle-id' });パラメータ:
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
id | 文字列 | はい | 現在のバンドルでアプリを手動で再読み込みします。 |
reload()をクリップボードにコピー
await updater.reload();__CAPGO_KEEP_0__
削除(options)バンドルをストレージから削除します。
await updater.delete({ id: 'bundle-id' });パラメータ
| オプション | 型 | 必要 | 説明 |
|---|---|---|---|
id | 文字列 | はい | 削除するバンドルID |
__CAPGO_KEEP_0__
reset(options)のセクションバンドルをリセットするか、ビルトインバージョンに戻す
// Reset to builtinawait updater.reset({ toLastSuccessful: false });
// Reset to last successful bundleawait updater.reset({ toLastSuccessful: true });パラメータ
| オプション | 型 | 必要 | 説明 |
|---|---|---|---|
toLastSuccessful | boolean | No | trueの場合、最後の成功バンドルに戻す |
Bundle Information
Bundle情報current()
現在のバンドルBundle情報とネイティブバージョンの情報を取得します。
const info = await updater.current();// { bundle: { id, version, status }, native: '1.0.0' }list(options)
オプションのリストダウンロードしたバンドルのリストを表示します。
const bundles = await updater.list();// [{ id, version, status, downloaded, checksum }, ...]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'アップデートチェック
getFailedUpdate()__CAPGO_KEEP_0__
「__CAPGO_KEEP_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 | string | __CAPGO_KEEP_0__ |
sessionKey | string | __CAPGO_KEEP_0__ |
error | string | __CAPGO_KEEP_0__ |
message | string | サーバーメッセージ |
チャンネル管理
チャンネル管理setChannel(オプション)
setChannel(オプション)__CAPGO_KEEP_0__を特定のチャネルに割り当てます。
await updater.setChannel({ channel: 'beta' });__CAPGO_KEEP_0__(options)
__CAPGO_KEEP_2__のセクション__CAPGO_KEEP_0__を解除してデフォルトに戻します。
await updater.unsetChannel();__CAPGO_KEEP_0__()
__CAPGO_KEEP_2__のセクション__CAPGO_KEEP_0__の現在の割り当てを取得します。
const channel = await updater.getChannel();// { channel: 'production', status: 'set' }__CAPGO_KEEP_0__()
__CAPGO_KEEP_2__のセクションこのアプリの利用可能なチャンネルをすべて表示します。
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' } ]});値
| __CAPGO_KEEP_0__ | __CAPGO_KEEP_1__ | 概要 |
|---|---|---|
background | __CAPGO_KEEP_0__ | アプリがバックグラウンドに遷移するのを待つ |
kill | - | アプリが終了し再起動されるのを待つ |
date | ISO 日付文字列 | 特定の日時まで待つ |
nativeVersion | バージョン文字列 | ネイティブアプリの更新を待つ |
cancelDelay()
cancelDelay()すべての遅延条件をクリアし、次のチェックで即座に更新を適用する
await updater.cancelDelay();デバイスの識別
「デバイスの識別」getDeviceId()
「getDeviceId()」一意のデバイス識別子を取得します。
const deviceId = await updater.getDeviceId();// 'uuid-xxxx-xxxx-xxxx'setCustomId(options)
「setCustomId(options)」デバイスにカスタム識別子を設定します (分析用)。
await updater.setCustomId({ customId: 'user-123' });設定
「設定」setUpdateUrl(options)
setUpdateUrl(options)のセクション実行時で更新サーバーURLを変更します。
await updater.setUpdateUrl({ url: 'https://my-server.com/updates' });setStatsUrl(options)
setStatsUrl(options)のセクション実行時で統計報告URLを変更します。
await updater.setStatsUrl({ url: 'https://my-server.com/stats' });__CAPGO_KEEP_0__
__CAPGO_KEEP_1____CAPGO_KEEP_2__
await updater.setChannelUrl({ url: 'https://my-server.com/channel' });__CAPGO_KEEP_4__
__CAPGO_KEEP_5____CAPGO_KEEP_6__
await updater.setAppId({ appId: 'com.example.newapp' });getAppId()
getAppId()のセクション現在のApp IDを取得します。
const appId = await updater.getAppId();デバッグ
デバッグのセクションsetDebugMenu(options)
setDebugMenu(options)のセクションデバッグメニューを有効または無効にします。
await updater.setDebugMenu({ enabled: true });isDebugMenuEnabled()
isDebugMenuEnabled()のセクションデバッグメニューが有効かどうかを確認します。
const enabled = await updater.isDebugMenuEnabled();イベント
「イベント」セクション更新イベントを使用して 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 リファレンス ダッシュボードと API の計画と実行に使用している場合、API を接続してください Electron Updater capgo を使用して、@capgo/electron-updater Electron Updater capgo のネイティブ機能を使用する場合、@capgo/electron-updater API の概要 API の実装詳細 Introduction for the implementation detail in Introduction, APIの実装詳細については API Keysの実装詳細については デバイス for the implementation detail in Devices.