UNPKG

4.99 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getChannelFilename = getChannelFilename;
7exports.newBaseUrl = newBaseUrl;
8exports.newUrlFromBase = newUrlFromBase;
9Object.defineProperty(exports, "AppUpdater", {
10 enumerable: true,
11 get: function () {
12 return _AppUpdater().AppUpdater;
13 }
14});
15Object.defineProperty(exports, "NoOpLogger", {
16 enumerable: true,
17 get: function () {
18 return _AppUpdater().NoOpLogger;
19 }
20});
21Object.defineProperty(exports, "CancellationToken", {
22 enumerable: true,
23 get: function () {
24 return _builderUtilRuntime().CancellationToken;
25 }
26});
27Object.defineProperty(exports, "Provider", {
28 enumerable: true,
29 get: function () {
30 return _Provider().Provider;
31 }
32});
33Object.defineProperty(exports, "AppImageUpdater", {
34 enumerable: true,
35 get: function () {
36 return _AppImageUpdater().AppImageUpdater;
37 }
38});
39Object.defineProperty(exports, "MacUpdater", {
40 enumerable: true,
41 get: function () {
42 return _MacUpdater().MacUpdater;
43 }
44});
45Object.defineProperty(exports, "NsisUpdater", {
46 enumerable: true,
47 get: function () {
48 return _NsisUpdater().NsisUpdater;
49 }
50});
51exports.UpdaterSignal = exports.UPDATE_DOWNLOADED = exports.DOWNLOAD_PROGRESS = void 0;
52
53function _url() {
54 const data = require("url");
55
56 _url = function () {
57 return data;
58 };
59
60 return data;
61}
62
63function _AppUpdater() {
64 const data = require("./AppUpdater");
65
66 _AppUpdater = function () {
67 return data;
68 };
69
70 return data;
71}
72
73function _builderUtilRuntime() {
74 const data = require("builder-util-runtime");
75
76 _builderUtilRuntime = function () {
77 return data;
78 };
79
80 return data;
81}
82
83function _Provider() {
84 const data = require("./providers/Provider");
85
86 _Provider = function () {
87 return data;
88 };
89
90 return data;
91}
92
93function _AppImageUpdater() {
94 const data = require("./AppImageUpdater");
95
96 _AppImageUpdater = function () {
97 return data;
98 };
99
100 return data;
101}
102
103function _MacUpdater() {
104 const data = require("./MacUpdater");
105
106 _MacUpdater = function () {
107 return data;
108 };
109
110 return data;
111}
112
113function _NsisUpdater() {
114 const data = require("./NsisUpdater");
115
116 _NsisUpdater = function () {
117 return data;
118 };
119
120 return data;
121}
122
123// autoUpdater to mimic electron bundled autoUpdater
124let _autoUpdater;
125
126function doLoadAutoUpdater() {
127 // tslint:disable:prefer-conditional-expression
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
139Object.defineProperty(exports, "autoUpdater", {
140 enumerable: true,
141 get: () => {
142 return _autoUpdater || doLoadAutoUpdater();
143 }
144});
145
146function getChannelFilename(channel) {
147 return `${channel}.yml`;
148}
149
150const DOWNLOAD_PROGRESS = "download-progress";
151exports.DOWNLOAD_PROGRESS = DOWNLOAD_PROGRESS;
152const UPDATE_DOWNLOADED = "update-downloaded";
153exports.UPDATE_DOWNLOADED = UPDATE_DOWNLOADED;
154
155class UpdaterSignal {
156 constructor(emitter) {
157 this.emitter = emitter;
158 }
159 /**
160 * Emitted when an authenticating proxy is [asking for user credentials](https://github.com/electron/electron/blob/master/docs/api/client-request.md#event-login).
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
182exports.UpdaterSignal = UpdaterSignal;
183const isLogEvent = false;
184
185function 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} // if baseUrl path doesn't ends with /, this path will be not prepended to passed pathname for new URL(input, base)
195
196/** @internal */
197
198
199function newBaseUrl(url) {
200 const result = new (_url().URL)(url);
201
202 if (!result.pathname.endsWith("/")) {
203 result.pathname += "/";
204 }
205
206 return result;
207} // addRandomQueryToAvoidCaching is false by default because in most cases URL already contains version number,
208// so, it makes sense only for Generic Provider for channel files
209
210
211function newUrlFromBase(pathname, baseUrl, addRandomQueryToAvoidCaching = false) {
212 const result = new (_url().URL)(pathname, baseUrl); // search is not propagated (search is an empty string if not specified)
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// __ts-babel@6.0.4
225//# sourceMappingURL=main.js.map
\No newline at end of file