-
-
Notifications
You must be signed in to change notification settings - Fork 748
Expand file tree
/
Copy pathautoUpdater.js
More file actions
130 lines (130 loc) · 6.07 KB
/
autoUpdater.js
File metadata and controls
130 lines (130 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
"use strict";
const electron_updater_1 = require("electron-updater");
let electronSocket;
function normalize(updateInfo) {
if (typeof updateInfo?.releaseNotes === "string") {
updateInfo.releaseNotes = [updateInfo.releaseNotes];
}
}
module.exports = (socket) => {
electronSocket = socket;
socket.on("register-autoUpdater-error", (id) => {
electron_updater_1.autoUpdater.on("error", (error) => {
electronSocket.emit("autoUpdater-error" + id, error.message);
});
});
socket.on("register-autoUpdater-checking-for-update", (id) => {
electron_updater_1.autoUpdater.on("checking-for-update", () => {
electronSocket.emit("autoUpdater-checking-for-update" + id);
});
});
socket.on("register-autoUpdater-update-available", (id) => {
electron_updater_1.autoUpdater.on("update-available", (updateInfo) => {
normalize(updateInfo);
electronSocket.emit("autoUpdater-update-available" + id, updateInfo);
});
});
socket.on("register-autoUpdater-update-not-available", (id) => {
electron_updater_1.autoUpdater.on("update-not-available", (updateInfo) => {
normalize(updateInfo);
electronSocket.emit("autoUpdater-update-not-available" + id, updateInfo);
});
});
socket.on("register-autoUpdater-download-progress", (id) => {
electron_updater_1.autoUpdater.on("download-progress", (progressInfo) => {
electronSocket.emit("autoUpdater-download-progress" + id, progressInfo);
});
});
socket.on("register-autoUpdater-update-downloaded", (id) => {
electron_updater_1.autoUpdater.on("update-downloaded", (updateInfo) => {
normalize(updateInfo);
electronSocket.emit("autoUpdater-update-downloaded" + id, updateInfo);
});
});
// Properties *****
socket.on("autoUpdater-autoDownload", () => {
electronSocket.emit("autoUpdater-autoDownload-completed", electron_updater_1.autoUpdater.autoDownload);
});
socket.on("autoUpdater-autoDownload-set", (value) => {
electron_updater_1.autoUpdater.autoDownload = value;
});
socket.on("autoUpdater-autoInstallOnAppQuit", () => {
electronSocket.emit("autoUpdater-autoInstallOnAppQuit-completed", electron_updater_1.autoUpdater.autoInstallOnAppQuit);
});
socket.on("autoUpdater-autoInstallOnAppQuit-set", (value) => {
electron_updater_1.autoUpdater.autoInstallOnAppQuit = value;
});
socket.on("autoUpdater-allowPrerelease", () => {
electronSocket.emit("autoUpdater-allowPrerelease-completed", electron_updater_1.autoUpdater.allowPrerelease);
});
socket.on("autoUpdater-allowPrerelease-set", (value) => {
electron_updater_1.autoUpdater.allowPrerelease = value;
});
socket.on("autoUpdater-fullChangelog", () => {
electronSocket.emit("autoUpdater-fullChangelog-completed", electron_updater_1.autoUpdater.fullChangelog);
});
socket.on("autoUpdater-fullChangelog-set", (value) => {
electron_updater_1.autoUpdater.fullChangelog = value;
});
socket.on("autoUpdater-allowDowngrade", () => {
electronSocket.emit("autoUpdater-allowDowngrade-completed", electron_updater_1.autoUpdater.allowDowngrade);
});
socket.on("autoUpdater-allowDowngrade-set", (value) => {
electron_updater_1.autoUpdater.allowDowngrade = value;
});
socket.on("autoUpdater-updateConfigPath", () => {
electronSocket.emit("autoUpdater-updateConfigPath-completed", electron_updater_1.autoUpdater.updateConfigPath || "");
});
socket.on("autoUpdater-updateConfigPath-set", (value) => {
electron_updater_1.autoUpdater.updateConfigPath = value;
});
socket.on("autoUpdater-currentVersion", () => {
electronSocket.emit("autoUpdater-currentVersion-completed", electron_updater_1.autoUpdater.currentVersion);
});
socket.on("autoUpdater-channel", () => {
electronSocket.emit("autoUpdater-channel-completed", electron_updater_1.autoUpdater.channel || "");
});
socket.on("autoUpdater-channel-set", (value) => {
electron_updater_1.autoUpdater.channel = value;
});
socket.on("autoUpdater-requestHeaders", () => {
electronSocket.emit("autoUpdater-requestHeaders-completed", electron_updater_1.autoUpdater.requestHeaders);
});
socket.on("autoUpdater-requestHeaders-set", (value) => {
electron_updater_1.autoUpdater.requestHeaders = value;
});
socket.on("autoUpdater-checkForUpdatesAndNotify", async (guid) => {
electron_updater_1.autoUpdater
.checkForUpdatesAndNotify()
.then((updateCheckResult) => {
normalize(updateCheckResult?.updateInfo);
electronSocket.emit("autoUpdater-checkForUpdatesAndNotify-completed" + guid, updateCheckResult);
})
.catch((error) => {
electronSocket.emit("autoUpdater-checkForUpdatesAndNotifyError" + guid, error);
});
});
socket.on("autoUpdater-checkForUpdates", async (guid) => {
electron_updater_1.autoUpdater
.checkForUpdates()
.then((updateCheckResult) => {
normalize(updateCheckResult?.updateInfo);
electronSocket.emit("autoUpdater-checkForUpdates-completed" + guid, updateCheckResult);
})
.catch((error) => {
electronSocket.emit("autoUpdater-checkForUpdatesError" + guid, error);
});
});
socket.on("autoUpdater-quitAndInstall", async (isSilent, isForceRunAfter) => {
electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
});
socket.on("autoUpdater-downloadUpdate", async (guid) => {
const downloadedPath = await electron_updater_1.autoUpdater.downloadUpdate();
electronSocket.emit("autoUpdater-downloadUpdate-completed" + guid, downloadedPath);
});
socket.on("autoUpdater-getFeedURL", async (guid) => {
const feedUrl = await electron_updater_1.autoUpdater.getFeedURL();
electronSocket.emit("autoUpdater-getFeedURL-completed" + guid, feedUrl || "");
});
};
//# sourceMappingURL=autoUpdater.js.map