Electron Updater API 참조
__CAPGO_KEEP_1__
__CAPGO_KEEP_8__
__CAPGO_KEEP_9__
__CAPGO_KEEP_10____CAPGO_KEEP_11__
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 | SHA256 체크섬을 사용하여 검증 |
sessionKey | 문자열 | No | 세션 키를 사용하여 암호화된 패키지를 암호화 |
반환: BundleInfo 다음 옵션을 포함하는 객체 id, version, status
다음(options)
다음(options) 제목다음 앱 리스타트 시 로드될 패키지를 큐에 추가.
await updater.next({ id: 'bundle-id' });매개변수:
| 옵션 | 타입 | 필수 | 설명 |
|---|---|---|---|
id | 문자열 | 예 | queue에 등록할 Bundle ID를 설정합니다. |
set(options)라는 섹션
즉시 Bundle로 switch하고 앱을 reload합니다.클립보드에 복사
await updater.set({ id: 'bundle-id' });set(options)
| Option | 타입 | 필수 | 설명 |
|---|---|---|---|
id | string | Yes | 앱 활성화에 필요한 Bundle ID |
reload()
reload() 섹션현재 Bundle로 앱을 수동으로 다시 로드합니다.
await updater.reload();delete(options)
삭제(옵션)스토리지에서 패키지를 삭제합니다.
await updater.delete({ id: 'bundle-id' });매개 변수:
| 옵션 | 타입 | 필수 | 설명 |
|---|---|---|---|
id | 문자열 | 네 | 삭제할 패키지 ID |
reset(옵션)
선택 항목 ‘reset(options)’빌트인 버전 또는 마지막 성공적인 번들로 리셋합니다.
// Reset to builtinawait updater.reset({ toLastSuccessful: false });
// Reset to last successful bundleawait updater.reset({ toLastSuccessful: true });매개 변수:
| 옵션 | 타입 | 필수 | 설명 |
|---|---|---|---|
toLastSuccessful | boolean | 아니요 | true가면 마지막 성공적인 번들로 리셋합니다. |
current()
Section titled “현재 버전”현재 Bundle 및 네이티브 버전 정보를 가져옵니다.
const info = await updater.current();// { bundle: { id, version, status }, native: '1.0.0' }list(options)
Section titled “다운로드 된 Bundle 목록”다운로드 된 Bundle 목록을 표시합니다.
const bundles = await updater.list();// [{ id, version, status, downloaded, checksum }, ...]getNextBundle()
Section titled “다음 재시작 Bundle”다음 재시작에 대기 중인 Bundle을 가져옵니다.
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 checksum |
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 | 선택적 지속 시간 (ms) | 앱이 백그라운드에 들어가기를 기다립니다. |
kill | - | 앱이 죽고 다시 시작될 때까지 기다립니다. |
date | ISO 날짜 문자열 | 특정 날짜/시간까지 기다립니다. |
nativeVersion | 버전 문자열 | 네이티브 앱 업데이트를 기다립니다. |
cancelDelay()
cancelDelay() 섹션모든 지연 조건을 취소하고 다음 체크 시 즉시 업데이트를 적용합니다.
await updater.cancelDelay();장치 식별
__CAPGO_KEEP_0____CAPGO_KEEP_1__
__CAPGO_KEEP_2____CAPGO_KEEP_3__
const deviceId = await updater.getDeviceId();// 'uuid-xxxx-xxxx-xxxx'__CAPGO_KEEP_5__
__CAPGO_KEEP_6____CAPGO_KEEP_7__
await updater.setCustomId({ customId: 'user-123' });__CAPGO_KEEP_9__
__CAPGO_KEEP_10____CAPGO_KEEP_11__
__CAPGO_KEEP_0____CAPGO_KEEP_1__
await updater.setUpdateUrl({ url: 'https://my-server.com/updates' });__CAPGO_KEEP_0__
__CAPGO_KEEP_1____CAPGO_KEEP_2__
await updater.setStatsUrl({ url: 'https://my-server.com/stats' });__CAPGO_KEEP_4__
__CAPGO_KEEP_0____CAPGO_KEEP_1__
await updater.setChannelUrl({ url: 'https://my-server.com/channel' });__CAPGO_KEEP_3__
__CAPGO_KEEP_4____CAPGO_KEEP_5__
await updater.setAppId({ appId: 'com.example.newapp' });__CAPGO_KEEP_11__
getAppId()현재 App ID를 가져옵니다.
const appId = await updater.getAppId();Debug
DebugsetDebugMenu(options)
Debug 메뉴를 활성화하거나 비활성화합니다.Copy to clipboard
await updater.setDebugMenu({ enabled: true });Debug 메뉴가 활성화되어 있는지 확인합니다.
__CAPGO_KEEP_0____CAPGO_KEEP_0__
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 참조 Electron Updater API 참조와 함께 Electron Updater capgo 참조를 사용하여 Electron Updater capgo 참조를 사용하여 Electron Updater API 참조를 사용하여 Electron Updater API 참조를 사용하여 Electron Updater __CAPGO_KEEP_0__ 참조를 사용하여 __CAPGO_KEEP_0__ 소개에서 구현 세부 정보를 위한 API 키 API 키의 소개에서 구현 세부 정보를 위한 장치 __CAPGO_KEEP_0__ 소개에서 구현 세부 정보를 위한