Electron UpdaterAPIリファレンス
このプラグインのインストールステップとフルマークダウンガイドを含むセットアップの質問をコピーできます。
このページでは、すべての利用可能なメソッド、イベント、設定オプションについて、Electron Updaterのドキュメントを提供しています。
Core Methods
Core MethodsnotifyAppReady()
アプリ起動時に常に呼び出してください。notifyAppReady() notifyAppReady()を呼び出すと、バンドルが正常に読み込まれたことを確認し、自動ロールバックを防止します。
await updater.notifyAppReady();download(options)
Section titled “ダウンロード(オプション)”URLからバンドルをダウンロードします。
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});パラメーター:
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
url | 文字列 | はい | ダウンロードするバンドルのURL |
version | 文字列 | はい | バンドルのバージョン識別子 |
checksum | 文字列 | いいえ | 暗号化されたバンドルの検証用SHA256チェックサム |
sessionKey | 文字列 | いいえ | 暗号化されたバンドルのセッションキー |
戻り値: BundleInfo オブジェクト id, version, status
次のオプションを指定して呼び出す
セクション「次のオプション」を参照次のアプリ再起動時にバンドルを読み込むようにキューします。
await updater.next({ id: 'bundle-id' });パラメーター
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
id | 文字列 | はい | バンドルIDをキューする |
set(options)
「set(options)」のセクション即時でアプリを再読み込みします。
await updater.set({ id: 'bundle-id' });パラメータ:
| オプション | タイプ | 必須 | 説明 |
|---|---|---|---|
id | 文字列 | はい | アクティブ化するバンドルID |
reload()
「reload()」セクション現在のバンドルでアプリを手動で再読み込みします。
await updater.reload();クリップボードにコピー
delete(options)のセクションストレージからバンドルを削除します。
await updater.delete({ id: 'bundle-id' });パラメータ:
| オプション | 型 | 必須 | 説明 |
|---|---|---|---|
id | 文字列 | はい | 削除するバンドルID |
reset(options)
「reset(options)」セクションバuiltinバージョンまたは最後の成功バンドルにリセットします。
// Reset to builtinawait updater.reset({ toLastSuccessful: false });
// Reset to last successful bundleawait updater.reset({ toLastSuccessful: true });パラメータ:
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
toLastSuccessful | boolean | No | trueの場合、ビルトインではなく最後の成功バンドルにリセットします。 |
Bundle Information
「Bundle Information」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(オプション)
setChannel(オプション)のセクション特定のチャンネルにデバイスを割り当てる。
await updater.setChannel({ channel: 'beta' });unsetChannel(オプション)
unsetChannel(オプション)のセクションチャンネル割り当てを削除し、デフォルトを使用します。
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 | オプションの時間 (ms) | アプリがバックグラウンドに遷移するのを待つ |
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' });setChannelUrl(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()
「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);});コンストラクタのオプション
「コンストラクタのオプション」セクションElectron Updater __CAPGO_KEEP_0__ の完全な構成オプション 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 リファレンスから続ける」セクションCapgo を使用している場合、Electron Updater __CAPGO_KEEP_0__ を使用して、計画ダッシュボードと __CAPGO_KEEP_0__ の操作を実行します。 Electron Updater API リファレンス Capgo を使用して、Electron Updater API を使用して、計画ダッシュボードと API の操作を実行します。 Capgo を使用して、Electron Updater capgo を使用して、計画ダッシュボードと capgo の操作を実行します。 Capacitor を使用して、Electron Updater capgo を使用して、計画ダッシュボードと capgo の操作を実行します。 API Overview API の概要 Introduction __CAPGO_KEEP_0__ の概要 API Keys API キー Devices デバイス