1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.getChannelFilename = getChannelFilename;
|
7 | exports.newBaseUrl = newBaseUrl;
|
8 | exports.newUrlFromBase = newUrlFromBase;
|
9 | Object.defineProperty(exports, "AppUpdater", {
|
10 | enumerable: true,
|
11 | get: function () {
|
12 | return _AppUpdater().AppUpdater;
|
13 | }
|
14 | });
|
15 | Object.defineProperty(exports, "NoOpLogger", {
|
16 | enumerable: true,
|
17 | get: function () {
|
18 | return _AppUpdater().NoOpLogger;
|
19 | }
|
20 | });
|
21 | Object.defineProperty(exports, "CancellationToken", {
|
22 | enumerable: true,
|
23 | get: function () {
|
24 | return _builderUtilRuntime().CancellationToken;
|
25 | }
|
26 | });
|
27 | Object.defineProperty(exports, "Provider", {
|
28 | enumerable: true,
|
29 | get: function () {
|
30 | return _Provider().Provider;
|
31 | }
|
32 | });
|
33 | Object.defineProperty(exports, "AppImageUpdater", {
|
34 | enumerable: true,
|
35 | get: function () {
|
36 | return _AppImageUpdater().AppImageUpdater;
|
37 | }
|
38 | });
|
39 | Object.defineProperty(exports, "MacUpdater", {
|
40 | enumerable: true,
|
41 | get: function () {
|
42 | return _MacUpdater().MacUpdater;
|
43 | }
|
44 | });
|
45 | Object.defineProperty(exports, "NsisUpdater", {
|
46 | enumerable: true,
|
47 | get: function () {
|
48 | return _NsisUpdater().NsisUpdater;
|
49 | }
|
50 | });
|
51 | exports.UpdaterSignal = exports.UPDATE_DOWNLOADED = exports.DOWNLOAD_PROGRESS = void 0;
|
52 |
|
53 | function _url() {
|
54 | const data = require("url");
|
55 |
|
56 | _url = function () {
|
57 | return data;
|
58 | };
|
59 |
|
60 | return data;
|
61 | }
|
62 |
|
63 | function _AppUpdater() {
|
64 | const data = require("./AppUpdater");
|
65 |
|
66 | _AppUpdater = function () {
|
67 | return data;
|
68 | };
|
69 |
|
70 | return data;
|
71 | }
|
72 |
|
73 | function _builderUtilRuntime() {
|
74 | const data = require("builder-util-runtime");
|
75 |
|
76 | _builderUtilRuntime = function () {
|
77 | return data;
|
78 | };
|
79 |
|
80 | return data;
|
81 | }
|
82 |
|
83 | function _Provider() {
|
84 | const data = require("./providers/Provider");
|
85 |
|
86 | _Provider = function () {
|
87 | return data;
|
88 | };
|
89 |
|
90 | return data;
|
91 | }
|
92 |
|
93 | function _AppImageUpdater() {
|
94 | const data = require("./AppImageUpdater");
|
95 |
|
96 | _AppImageUpdater = function () {
|
97 | return data;
|
98 | };
|
99 |
|
100 | return data;
|
101 | }
|
102 |
|
103 | function _MacUpdater() {
|
104 | const data = require("./MacUpdater");
|
105 |
|
106 | _MacUpdater = function () {
|
107 | return data;
|
108 | };
|
109 |
|
110 | return data;
|
111 | }
|
112 |
|
113 | function _NsisUpdater() {
|
114 | const data = require("./NsisUpdater");
|
115 |
|
116 | _NsisUpdater = function () {
|
117 | return data;
|
118 | };
|
119 |
|
120 | return data;
|
121 | }
|
122 |
|
123 |
|
124 | let _autoUpdater;
|
125 |
|
126 | function doLoadAutoUpdater() {
|
127 |
|
128 | if (process.platform === "win32") {
|
129 | _autoUpdater = new (require("./NsisUpdater").NsisUpdater)();
|
130 | } else if (process.platform === "darwin") {
|
131 | _autoUpdater = new (require("./MacUpdater").MacUpdater)();
|
132 | } else {
|
133 | _autoUpdater = new (require("./AppImageUpdater").AppImageUpdater)();
|
134 | }
|
135 |
|
136 | return _autoUpdater;
|
137 | }
|
138 |
|
139 | Object.defineProperty(exports, "autoUpdater", {
|
140 | enumerable: true,
|
141 | get: () => {
|
142 | return _autoUpdater || doLoadAutoUpdater();
|
143 | }
|
144 | });
|
145 |
|
146 | function getChannelFilename(channel) {
|
147 | return `${channel}.yml`;
|
148 | }
|
149 |
|
150 | const DOWNLOAD_PROGRESS = "download-progress";
|
151 | exports.DOWNLOAD_PROGRESS = DOWNLOAD_PROGRESS;
|
152 | const UPDATE_DOWNLOADED = "update-downloaded";
|
153 | exports.UPDATE_DOWNLOADED = UPDATE_DOWNLOADED;
|
154 |
|
155 | class UpdaterSignal {
|
156 | constructor(emitter) {
|
157 | this.emitter = emitter;
|
158 | }
|
159 | |
160 |
|
161 |
|
162 |
|
163 |
|
164 | login(handler) {
|
165 | addHandler(this.emitter, "login", handler);
|
166 | }
|
167 |
|
168 | progress(handler) {
|
169 | addHandler(this.emitter, DOWNLOAD_PROGRESS, handler);
|
170 | }
|
171 |
|
172 | updateDownloaded(handler) {
|
173 | addHandler(this.emitter, UPDATE_DOWNLOADED, handler);
|
174 | }
|
175 |
|
176 | updateCancelled(handler) {
|
177 | addHandler(this.emitter, "update-cancelled", handler);
|
178 | }
|
179 |
|
180 | }
|
181 |
|
182 | exports.UpdaterSignal = UpdaterSignal;
|
183 | const isLogEvent = false;
|
184 |
|
185 | function addHandler(emitter, event, handler) {
|
186 | if (isLogEvent) {
|
187 | emitter.on(event, (...args) => {
|
188 | console.log("%s %s", event, args);
|
189 | handler(...args);
|
190 | });
|
191 | } else {
|
192 | emitter.on(event, handler);
|
193 | }
|
194 | }
|
195 |
|
196 |
|
197 |
|
198 |
|
199 | function newBaseUrl(url) {
|
200 | const result = new (_url().URL)(url);
|
201 |
|
202 | if (!result.pathname.endsWith("/")) {
|
203 | result.pathname += "/";
|
204 | }
|
205 |
|
206 | return result;
|
207 | }
|
208 |
|
209 |
|
210 |
|
211 | function newUrlFromBase(pathname, baseUrl, addRandomQueryToAvoidCaching = false) {
|
212 | const result = new (_url().URL)(pathname, baseUrl);
|
213 |
|
214 | const search = baseUrl.search;
|
215 |
|
216 | if (search != null && search.length !== 0) {
|
217 | result.search = search;
|
218 | } else if (addRandomQueryToAvoidCaching) {
|
219 | result.search = `noCache=${Date.now().toString(32)}`;
|
220 | }
|
221 |
|
222 | return result;
|
223 | }
|
224 |
|
225 |
|
\ | No newline at end of file |