Electron Updater API リファレンス
このプラグインのインストール手順とマークダウン ガイドの全てを含むセットアップ コマンドをコピーしてください。
このページでは、Electron Updater の利用可能なすべてのメソッド、イベント、設定オプションをドキュメント化しています。
Core メソッド
「Core Methods」というタイトルのセクションnotifyAppReady()
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});パラメータ:
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
url | 文字列 | はい | ダウンロードするためのバンドルURL |
version | 文字列 | はい | バンドルのバージョン識別子 |
checksum | 日本語 | なし | SHA256のチェックサムの検証用 |
sessionKey | なし | セッション キーで暗号化されたバンドルの場合 | 戻り値: |
オブジェクトに BundleInfo next(options)のセクション id, version, status
次のアプリ再起動時にロードされるようにバンドルをキューします。
クリップボードにコピー__CAPGO_KEEP_0__
await updater.next({ id: 'bundle-id' });Parameters:
| オプション | 型 | 必要 | 説明 |
|---|---|---|---|
id | 文字列 | はい | バンドルIDをキュー |
set(options)
セクションのタイトル “set(options)”アプリをすぐにバンドルに切り替え、再読み込みする
await updater.set({ id: 'bundle-id' });パラメータ:
| オプション | タイプ | 必要 | 説明 |
|---|---|---|---|
id | 文字列 | はい | アプリを再起動するためのバンドルID |
セクション「reload()」
現在のバンドルでアプリを手動で再起動します。クリップボードにコピー
await updater.reload();__CAPGO_KEEP_0__
__CAPGO_KEEP_1____CAPGO_KEEP_2__
await updater.delete({ id: 'bundle-id' });__CAPGO_KEEP_4__
| __CAPGO_KEEP_5__ | __CAPGO_KEEP_6__ | __CAPGO_KEEP_7__ | __CAPGO_KEEP_8__ |
|---|---|---|---|
id | __CAPGO_KEEP_9__ | __CAPGO_KEEP_10__ | __CAPGO_KEEP_11__ |
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 | 利用可能なバージョン | __CAPGO_KEEP_0__ |
checksum | string | SHA256のチェックサム |
sessionKey | string | 暗号化セッションキー |
error | string | チェックが失敗した場合のエラーメッセージ |
message | string | サーバーメッセージ |
チャンネル管理
チャンネル管理setChannel(options)
setChannel(options)__CAPGO_KEEP_0__を特定のチャネルに割り当てます。
await updater.setChannel({ channel: 'beta' });unsetChannel(options)
__CAPGO_KEEP_2__のセクション__CAPGO_KEEP_0__の割り当てを解除してデフォルトを使用
await updater.unsetChannel();getChannel()
__CAPGO_KEEP_3__のセクション__CAPGO_KEEP_0__の現在の割り当てを取得
const channel = await updater.getChannel();// { channel: 'production', status: 'set' }listChannels()
__CAPGO_KEEP_4__のセクションこのアプリの利用可能なチャンネルをすべて表示します。
const channels = await updater.listChannels();// ['production', 'beta', 'staging']延期条件
「延期条件」のセクションダウンロードした更新を適用するタイミングを制御します。
__CAPGO_KEEP_0__
「__CAPGO_KEEP_0__」のセクション更新が適用される前に満たす必要がある条件を設定します。
// 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__ | アプリがバックグラウンドに遷移するのを待つ |
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()
Section titled “getAppId()”現在のアプリIDを取得します。
const appId = await updater.getAppId();デバッグメニューを有効または無効にします。
Section titled “setDebugMenu(options)”クリップボードにコピー
await updater.setDebugMenu({ enabled: true });Section titled “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() __CAPGO_KEEP_0__が呼び出されました |
例:フルイベントハンドリング
「例:フルイベントハンドリング」のセクション// 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 リファレンスから続けるCapgo を使用している場合 Electron Updater API リファレンス ダッシュボードと API の作業を計画する場合、Capgo を使用して接続してください。 Capgo を使用して、@capgo/electron-updater を使用してネイティブ機能を実装する Capgo を使用して、@capgo/electron-updater の実装詳細を実装する Capgo を使用して、API の概要を実装する Capgo を使用して、API の実装詳細を実装する 概要 概要の実装詳細について API キー API キーの実装詳細について デバイス デバイスの実装詳細について