@el3um4s/ipc-for-electron-auto-updater
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -39,2 +39,6 @@ interface VersionNumber { | ||
}) => Promise<VersionNumber>; | ||
checkingForUpdate: (options: { | ||
callback?: () => void; | ||
apiKey?: string; | ||
}) => Promise<void>; | ||
errorOnAutoUpdate: (options: { | ||
@@ -41,0 +45,0 @@ callback?: ((arg0: Error) => void) | undefined; |
@@ -41,2 +41,15 @@ "use strict"; | ||
}); | ||
const checkingForUpdate = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
const { callback } = options; | ||
const apiKey = (options === null || options === void 0 ? void 0 : options.apiKey) || defaultApiKey; | ||
const api = globalThis[apiKey][nameAPI]; | ||
return new Promise((resolve) => { | ||
api.receive("checkingForUpdate", () => { | ||
if (callback) { | ||
callback(); | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
const updateAvailable = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -125,2 +138,3 @@ const { callback } = options; | ||
getVersionNumber, | ||
checkingForUpdate, | ||
errorOnAutoUpdate, | ||
@@ -127,0 +141,0 @@ updateAvailable, |
{ | ||
"name": "@el3um4s/ipc-for-electron-auto-updater", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Allow the renderer to update electron apps", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -95,3 +95,3 @@ # IPC for Electron: Auto Updater (NOT YET TESTED) | ||
globalThis.api.autoUpdater.send("requestVersionNumber", null); | ||
globalThis.api.systemInfo.receive("getVersionNumber", (data) => { | ||
globalThis.api.autoUpdater.receive("getVersionNumber", (data) => { | ||
version = data.version; | ||
@@ -201,3 +201,3 @@ }); | ||
systemInfo.on.errorOnAutoUpdate({ | ||
autoUpdater.on.errorOnAutoUpdate({ | ||
callback: (data) => { | ||
@@ -210,2 +210,18 @@ console.log("Error on auto update"); | ||
`on.checkingForUpdate = async (options: { callback?: () => void; apiKey?: string; }): Promise<void>` | ||
example: | ||
```ts | ||
import autoUpdater from "@el3um4s/renderer-for-electron-auto-updater"; | ||
autoUpdater.checkForUpdates(); | ||
autoUpdater.on.checkingForUpdate({ | ||
callback: () => { | ||
console.log("Checking for update..."); | ||
}, | ||
}); | ||
``` | ||
`on.updateAvailable = async (options: { callback?: (arg0: UpdateInfo) => void; apiKey?: string; }): Promise<UpdateInfo>` | ||
@@ -220,3 +236,3 @@ | ||
systemInfo.on.updateAvailable({ | ||
autoUpdater.on.updateAvailable({ | ||
callback: (data) => { | ||
@@ -239,3 +255,3 @@ const { version, releaseName, releaseDate } = data; | ||
systemInfo.on.updateNotAvailable({ | ||
autoUpdater.on.updateNotAvailable({ | ||
callback: (data) => { | ||
@@ -242,0 +258,0 @@ console.log("Update not available", data); |
23949
316
345