electron-incremental-update 1.2.0 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -17,67 +17,53 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- DownloadError: () => DownloadError,
24
- MinimumVersionError: () => MinimumVersionError,
20
+ // src/entry.ts
21
+ var entry_exports = {};
22
+ __export(entry_exports, {
23
+ ErrorInfo: () => ErrorInfo,
25
24
  Updater: () => Updater,
26
- VerifyFailedError: () => VerifyFailedError,
27
- createUpdater: () => createUpdater,
25
+ UpdaterError: () => UpdaterError,
28
26
  initApp: () => initApp,
29
27
  startupWithUpdater: () => startupWithUpdater
30
28
  });
31
- module.exports = __toCommonJS(src_exports);
29
+ module.exports = __toCommonJS(entry_exports);
32
30
  var import_node_path2 = require("path");
33
- var import_node_fs4 = require("fs");
31
+ var import_node_fs5 = require("fs");
34
32
  var import_electron4 = require("electron");
35
33
 
36
34
  // src/updater/core.ts
37
35
  var import_node_fs3 = require("fs");
38
- var import_electron3 = require("electron");
36
+ var import_electron2 = require("electron");
37
+
38
+ // src/utils/version.ts
39
+ function isUpdateJSON(json) {
40
+ const is = (j) => !!(j && j.minimumVersion && j.signature && j.size && j.version);
41
+ return is(json) && is(json?.beta);
42
+ }
39
43
 
40
44
  // src/utils/electron.ts
41
45
  var import_node_fs = require("fs");
42
46
  var import_node_path = require("path");
43
- var import_node_os = require("os");
44
47
  var import_electron = require("electron");
45
- var is = {
46
- dev: !import_electron.app.isPackaged,
47
- win: process.platform === "win32",
48
- mac: process.platform === "darwin",
49
- linux: process.platform === "linux"
50
- };
48
+ var isDev = __EIU_IS_DEV__;
49
+ var isWin = process.platform === "win32";
50
+ var isMac = process.platform === "darwin";
51
+ var isLinux = process.platform === "linux";
51
52
  function getPathFromAppNameAsar(...path) {
52
- return is.dev ? "DEV.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${import_electron.app.name}.asar`, ...path);
53
+ return isDev ? "DEV.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${import_electron.app.name}.asar`, ...path);
53
54
  }
54
- function getVersions() {
55
- const platform = is.win ? "Windows" : is.mac ? "MacOS" : process.platform.toUpperCase();
56
- return {
57
- appVersion: is.dev ? import_electron.app.getVersion() : (0, import_node_fs.readFileSync)(getPathFromAppNameAsar("version"), "utf-8"),
58
- entryVersion: import_electron.app.getVersion(),
59
- electronVersion: process.versions.electron,
60
- nodeVersion: process.versions.node,
61
- systemVersion: `${platform} ${(0, import_node_os.release)()}`
62
- };
55
+ function getAppVersion() {
56
+ return isDev ? getEntryVersion() : (0, import_node_fs.readFileSync)(getPathFromAppNameAsar("version"), "utf-8");
57
+ }
58
+ function getEntryVersion() {
59
+ return import_electron.app.getVersion();
63
60
  }
64
61
  function restartApp() {
65
62
  import_electron.app.relaunch();
66
63
  import_electron.app.quit();
67
64
  }
68
- function waitAppReady(timeout = 1e3) {
69
- return import_electron.app.isReady() ? Promise.resolve() : new Promise((resolve2, reject) => {
70
- const _ = setTimeout(() => {
71
- reject(new Error("app is not ready"));
72
- }, timeout);
73
- import_electron.app.whenReady().then(() => {
74
- clearTimeout(_);
75
- resolve2();
76
- });
77
- });
78
- }
79
65
 
80
- // src/utils/zip.ts
66
+ // src/utils/unzip.ts
81
67
  var import_node_fs2 = require("fs");
82
68
  var import_node_zlib = require("zlib");
83
69
  async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
@@ -85,201 +71,40 @@ async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
85
71
  throw new Error(`path to zipped file not exist: ${gzipPath}`);
86
72
  }
87
73
  const compressedBuffer = (0, import_node_fs2.readFileSync)(gzipPath);
88
- return new Promise((resolve2, reject) => {
74
+ return new Promise((resolve, reject) => {
89
75
  (0, import_node_zlib.brotliDecompress)(compressedBuffer, (err, buffer) => {
90
76
  (0, import_node_fs2.rmSync)(gzipPath);
91
77
  if (err) {
92
78
  reject(err);
93
79
  }
94
80
  (0, import_node_fs2.writeFileSync)(targetFilePath, buffer);
95
- resolve2(null);
81
+ resolve(null);
96
82
  });
97
83
  });
98
84
  }
99
85
 
100
- // src/utils/pure.ts
101
- function parseVersion(version) {
102
- const semver = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i;
103
- const match = semver.exec(version);
104
- if (!match) {
105
- throw new TypeError(`invalid version: ${version}`);
106
- }
107
- const [major, minor, patch] = match.slice(1, 4).map(Number);
108
- const ret = {
109
- major,
110
- minor,
111
- patch,
112
- stage: "",
113
- stageVersion: -1
114
- };
115
- if (match[4]) {
116
- let [stage, _v] = match[4].split(".");
117
- ret.stage = stage;
118
- ret.stageVersion = Number(_v) || -1;
119
- }
120
- if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) {
121
- throw new TypeError(`invalid version: ${version}`);
122
- }
123
- return ret;
124
- }
125
- function isUpdateJSON(json) {
126
- const is2 = (j) => !!(j && j.minimumVersion && j.signature && j.size && j.version);
127
- return is2(json) && is2(json?.beta);
128
- }
129
-
130
- // src/crypto/dec.ts
131
- var import_node_crypto2 = require("crypto");
132
-
133
- // src/crypto/utils.ts
134
- var import_node_crypto = require("crypto");
135
- function hashString(data, length) {
136
- const hash = (0, import_node_crypto.createHash)("SHA256").update(data).digest("binary");
137
- return Buffer.from(hash).subarray(0, length);
138
- }
139
-
140
- // src/crypto/dec.ts
141
- function decrypt(encryptedText, key, iv) {
142
- const decipher = (0, import_node_crypto2.createDecipheriv)("aes-256-cbc", key, iv);
143
- let decrypted = decipher.update(encryptedText, "base64url", "utf8");
144
- decrypted += decipher.final("utf8");
145
- return decrypted;
146
- }
147
- var verify = (buffer, signature, cert) => {
148
- try {
149
- const [sig, version] = decrypt(signature, hashString(cert, 32), hashString(buffer, 16)).split("%");
150
- const result = (0, import_node_crypto2.createVerify)("RSA-SHA256").update(buffer).verify(cert, sig, "base64");
151
- return result ? version : false;
152
- } catch (error) {
153
- return false;
154
- }
155
- };
156
-
157
- // src/crypto/enc.ts
158
- var import_node_crypto3 = require("crypto");
159
-
160
86
  // src/updater/types.ts
161
- var MinimumVersionError = class extends Error {
162
- currentVersion;
163
- minVersion;
164
- constructor(version, minimumVersion) {
165
- super(`current entry version is ${version}, less than the minimumVersion ${minimumVersion}`);
166
- this.currentVersion = version;
167
- this.minVersion = minimumVersion;
168
- }
169
- };
170
- var VerifyFailedError = class extends Error {
171
- signature;
172
- cert;
173
- constructor(signature, cert) {
174
- super("verify failed, invalid signature or certificate");
175
- this.signature = signature;
176
- this.cert = cert;
177
- }
178
- };
179
- var DownloadError = class extends Error {
180
- constructor(msg) {
181
- super(`download update error, ${msg}`);
182
- }
183
- };
184
-
185
- // src/updater/defaultFunctions/download.ts
186
- var import_electron2 = require("electron");
187
- var downloadJSONDefault = async (url, headers) => {
188
- await waitAppReady();
189
- return new Promise((resolve2, reject) => {
190
- const request = import_electron2.net.request({
191
- url,
192
- method: "GET",
193
- redirect: "follow"
194
- });
195
- Object.keys(headers).forEach((key) => {
196
- request.setHeader(key, headers[key]);
197
- });
198
- request.on("response", (res) => {
199
- let data = "";
200
- res.on("data", (chunk) => data += chunk);
201
- res.on("end", () => {
202
- try {
203
- const json = JSON.parse(data);
204
- if (isUpdateJSON(json)) {
205
- resolve2(json);
206
- } else {
207
- throw Error;
208
- }
209
- } catch (e) {
210
- reject(new Error("invalid json"));
211
- }
212
- });
213
- });
214
- request.on("error", (e) => {
215
- reject(e);
216
- });
217
- request.end();
218
- });
87
+ var ErrorInfo = {
88
+ download: "Download failed",
89
+ validate: "Validate failed",
90
+ param: "Missing params",
91
+ version: "Unsatisfied version"
219
92
  };
220
- var downloadBufferDefault = async (url, headers, total, onDownloading) => {
221
- await waitAppReady();
222
- let current = 0;
223
- return new Promise((resolve2, reject) => {
224
- const request = import_electron2.net.request({
225
- url,
226
- method: "GET",
227
- redirect: "follow"
228
- });
229
- Object.keys(headers).forEach((key) => {
230
- request.setHeader(key, headers[key]);
231
- });
232
- request.on("response", (res) => {
233
- let data = [];
234
- res.on("data", (chunk) => {
235
- current += chunk.length;
236
- onDownloading?.({
237
- percent: `${+(current / total).toFixed(2) * 100}%`,
238
- total,
239
- current
240
- });
241
- data.push(chunk);
242
- });
243
- res.on("end", () => {
244
- resolve2(Buffer.concat(data));
245
- });
246
- }).on("error", (e) => {
247
- reject(e);
248
- });
249
- request.end();
250
- });
251
- };
252
-
253
- // src/updater/defaultFunctions/compareVersion.ts
254
- var compareVersionDefault = (version1, version2) => {
255
- const oldV = parseVersion(version1);
256
- const newV = parseVersion(version2);
257
- function compareStrings(str1, str2) {
258
- if (str1 === "") {
259
- return str2 !== "";
260
- } else if (str2 === "") {
261
- return true;
262
- }
263
- return str1 < str2;
93
+ var UpdaterError = class extends Error {
94
+ constructor(msg, info) {
95
+ super(msg + ": " + info);
264
96
  }
265
- for (let key of Object.keys(oldV)) {
266
- if (key === "stage" && compareStrings(oldV[key], newV[key])) {
267
- return true;
268
- } else if (oldV[key] !== newV[key]) {
269
- return oldV[key] < newV[key];
270
- }
271
- }
272
- return false;
273
97
  };
274
98
 
275
99
  // src/updater/core.ts
276
100
  var Updater = class {
277
- CERT = __SIGNATURE_CERT__;
101
+ CERT = __EIU_SIGNATURE_CERT__;
278
102
  info;
279
- option;
103
+ options;
280
104
  asarPath;
281
105
  gzipPath;
282
106
  tmpFilePath;
107
+ provider;
283
108
  /**
284
109
  * updater logger
285
110
  */
@@ -293,36 +118,54 @@ var Updater = class {
293
118
  * }
294
119
  */
295
120
  onDownloading;
121
+ /**
122
+ * URL handler hook
123
+ *
124
+ * for Github, there are some {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 public CDN links}
125
+ * @param url source url
126
+ * @param isDownloadAsar whether is download asar
127
+ */
128
+ handleURL;
296
129
  /**
297
130
  * whether receive beta version
298
131
  */
299
132
  get receiveBeta() {
300
- return !!this.option.receiveBeta;
133
+ return !!this.options.receiveBeta;
301
134
  }
302
135
  set receiveBeta(receiveBeta) {
303
- this.option.receiveBeta = receiveBeta;
136
+ this.options.receiveBeta = receiveBeta;
304
137
  }
305
138
  /**
306
139
  * initialize incremental updater
140
+ * @param provider update provider
307
141
  * @param option UpdaterOption
308
142
  */
309
- constructor(option = {}) {
310
- this.option = option;
143
+ constructor(provider, option = {}) {
144
+ this.provider = provider;
145
+ this.options = option;
311
146
  if (option.SIGNATURE_CERT) {
312
147
  this.CERT = option.SIGNATURE_CERT;
313
148
  }
149
+ if (option.logger) {
150
+ this.logger = option.logger;
151
+ }
314
152
  this.asarPath = getPathFromAppNameAsar();
315
153
  this.gzipPath = `${this.asarPath}.gz`;
316
154
  this.tmpFilePath = `${this.asarPath}.tmp`;
317
155
  }
318
156
  async needUpdate(version, minVersion) {
319
- const compare = this.option.overrideFunctions?.compareVersion ?? compareVersionDefault;
320
- const { appVersion, entryVersion } = getVersions();
321
- if (await compare(entryVersion, minVersion)) {
322
- throw new MinimumVersionError(entryVersion, minVersion);
157
+ if (isDev) {
158
+ this.logger?.warn(`in dev mode, skip check update`);
159
+ return false;
160
+ }
161
+ const isLowerVersion = this.provider.isLowerVersion;
162
+ const entryVersion = getEntryVersion();
163
+ const appVersion = getAppVersion();
164
+ if (await isLowerVersion(entryVersion, minVersion)) {
165
+ throw new UpdaterError(ErrorInfo.version, `entry version (${entryVersion}) < minimumVersion (${minVersion})`);
323
166
  }
324
167
  this.logger?.info(`check update: current version is ${appVersion}, new version is ${version}`);
325
- return await compare(appVersion, version);
168
+ return await isLowerVersion(appVersion, version);
326
169
  }
327
170
  async parseData(format, data) {
328
171
  if ((0, import_node_fs3.existsSync)(this.tmpFilePath)) {
@@ -333,63 +176,23 @@ var Updater = class {
333
176
  this.logger?.warn(`remove .gz file: ${this.gzipPath}`);
334
177
  (0, import_node_fs3.rmSync)(this.gzipPath);
335
178
  }
336
- if (!["string", "object", "undefined"].includes(typeof data)) {
337
- throw new TypeError(`invalid type at format '${format}': ${data}`);
338
- }
339
- if (typeof data === "object" && (format === "json" && isUpdateJSON(data) || format === "buffer" && Buffer.isBuffer(data))) {
340
- return data;
341
- }
342
179
  if (typeof data === "object") {
343
- throw new TypeError(`invalid type at format '${format}': ${data}`);
344
- }
345
- const ua = this.option.downloadConfig?.userAgent || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36";
346
- const headers = {
347
- Accept: `application/${format === "json" ? "json" : "octet-stream"}`,
348
- UserAgent: ua,
349
- ...this.option.downloadConfig?.extraHeader
350
- };
351
- this.logger?.info(`download headers: ${JSON.stringify(headers, null, 2)}`);
352
- const config = format === "json" ? {
353
- name: "updateJsonURL",
354
- url: this.option.updateJsonURL,
355
- repoFallback: `${this.option.repository.replace("github.com", "raw.githubusercontent.com")}/master/version.json`,
356
- fn: this.option.overrideFunctions?.downloadJSON ?? downloadJSONDefault
357
- } : {
358
- name: "releaseAsarURL",
359
- url: this.option.releaseAsarURL,
360
- repoFallback: `${this.option.repository}/releases/download/v${this.info?.version}/${import_electron3.app.name}-${this.info?.version}.asar.gz`,
361
- fn: this.option.overrideFunctions?.downloadBuffer ?? downloadBufferDefault
362
- };
363
- data ??= config.url;
364
- if (!data) {
365
- this.logger?.debug(`no ${config.name}, fallback to use repository`);
366
- if (!this.option.repository) {
367
- throw new Error(`${config.name} or repository are not set`);
368
- }
369
- if (format === "buffer" && !this.info?.version) {
370
- throw new Error("version are not set");
180
+ if (format === "json" && isUpdateJSON(data) || format === "buffer" && Buffer.isBuffer(data)) {
181
+ return data;
182
+ } else {
183
+ throw new UpdaterError(ErrorInfo.param, `invalid type at format '${format}': ${JSON.stringify(data)}`);
371
184
  }
372
- data = config.repoFallback;
373
185
  }
374
- this.logger?.info(`download ${format} from ${data}`);
186
+ this.logger?.debug(`download from ${this.provider.name}`);
375
187
  try {
376
- const ret = format === "json" ? await config.fn(data, headers) : await config.fn(data, headers, this.info.size, this.onDownloading);
377
- this.logger?.info(`download ${format} success${format === "buffer" ? `, file size: ${ret.length}` : ""}`);
378
- return ret;
188
+ const result = format === "json" ? await this.provider.downloadJSON(data ?? __EIU_VERSION_PATH__) : await this.provider.downloadBuffer(import_electron2.app.name, this.info, this.onDownloading);
189
+ this.logger?.debug(`download ${format} success${format === "buffer" ? `, file size: ${result.length}` : ""}`);
190
+ return result;
379
191
  } catch (e) {
380
- throw new DownloadError(e.toString());
192
+ this.logger?.warn(`download ${format} failed: ${e}`);
193
+ throw new UpdaterError(ErrorInfo.download, `download ${format} failed: ${e}`);
381
194
  }
382
195
  }
383
- /**
384
- * check update info
385
- *
386
- * if you want to update **offline**, you can set `data` and `sig` add update info
387
- * @param data custom download URL of `updatejson` or existing update json
388
- * @returns
389
- * - Available:`{size: number, version: string}`
390
- * - Unavailable: `undefined`
391
- * - Fail: `CheckResultError`
392
- */
393
196
  async checkUpdate(data) {
394
197
  try {
395
198
  let { signature, size, version, minimumVersion, beta } = await this.parseData("json", data);
@@ -399,59 +202,49 @@ var Updater = class {
399
202
  minimumVersion = beta.minimumVersion;
400
203
  size = beta.size;
401
204
  }
402
- this.logger?.info(`checked version: ${version}, size: ${size}, signature: ${signature}`);
205
+ this.logger?.debug(`checked update, version: ${version}, size: ${size}, signature: ${signature}`);
403
206
  if (!await this.needUpdate(version, minimumVersion)) {
404
207
  this.logger?.info(`update unavailable: ${version} is the latest version`);
405
- return void 0;
208
+ return { success: false, data: version };
406
209
  } else {
407
210
  this.logger?.info(`update available: ${version}`);
408
- this.info = {
409
- signature,
410
- minimumVersion,
411
- version,
412
- size
413
- };
414
- return this.info;
211
+ this.info = { signature, minimumVersion, version, size };
212
+ return { success: true, data: this.info };
415
213
  }
416
214
  } catch (error) {
417
215
  this.logger?.error("check update failed", error);
418
- return error;
216
+ return {
217
+ success: false,
218
+ data: error instanceof UpdaterError ? error : new UpdaterError(ErrorInfo.download, error.toString())
219
+ };
419
220
  }
420
221
  }
421
- /**
422
- * download update
423
- *
424
- * if you want to update **offline**, you can set both `data` and `sig` to verify and install
425
- * @param data custom download URL of `asar.gz` or existing `asar.gz` buffer
426
- * @param sig signature
427
- * @returns
428
- * - `true`: success
429
- * - `DownloadResultError`: fail
430
- */
431
222
  async download(data, sig) {
432
223
  try {
433
- const _sig = sig ?? this.info?.signature;
434
- if (!_sig) {
435
- throw new Error("signature are not set, please checkUpdate first or set the second parameter");
224
+ if (!this.info) {
225
+ throw new UpdaterError(ErrorInfo.param, "no update info");
436
226
  }
227
+ const _sig = sig ?? this.info.signature;
437
228
  const buffer = await this.parseData("buffer", data);
438
- this.logger?.info("verify start");
439
- const _verify = this.option.overrideFunctions?.verifySignaure ?? verify;
440
- const _ver = await _verify(buffer, _sig, this.CERT);
229
+ this.logger?.debug("verify start");
230
+ const _ver = await this.provider.verifySignaure(buffer, _sig, this.CERT);
441
231
  if (!_ver) {
442
- throw new VerifyFailedError(_sig, this.CERT);
232
+ throw new UpdaterError(ErrorInfo.validate, "invalid signature or certificate");
443
233
  }
444
- this.logger?.info("verify success");
445
- this.logger?.info(`write to ${this.gzipPath}`);
234
+ this.logger?.debug("verify success");
235
+ this.logger?.debug(`write to ${this.gzipPath}`);
446
236
  (0, import_node_fs3.writeFileSync)(this.gzipPath, buffer);
447
- this.logger?.info(`extract to ${this.tmpFilePath}`);
237
+ this.logger?.debug(`extract to ${this.tmpFilePath}`);
448
238
  await unzipFile(this.gzipPath, this.tmpFilePath);
449
239
  this.logger?.info(`download success, version: ${_ver}`);
450
240
  this.info = void 0;
451
- return true;
241
+ return { success: true };
452
242
  } catch (error) {
453
243
  this.logger?.error("download asar failed", error);
454
- return error;
244
+ return {
245
+ success: false,
246
+ data: error instanceof UpdaterError ? error : new UpdaterError(ErrorInfo.download, error.toString())
247
+ };
455
248
  }
456
249
  }
457
250
  /**
@@ -463,65 +256,67 @@ var Updater = class {
463
256
  }
464
257
  };
465
258
 
466
- // src/updater/index.ts
467
- function createUpdater(option) {
468
- return new Updater(option);
469
- }
259
+ // src/utils/zip.ts
260
+ var import_node_fs4 = require("fs");
261
+ var import_node_zlib2 = require("zlib");
470
262
 
471
- // src/index.ts
263
+ // src/utils/crypto/decrypt.ts
264
+ var import_node_crypto2 = require("crypto");
265
+
266
+ // src/utils/crypto/utils.ts
267
+ var import_node_crypto = require("crypto");
268
+
269
+ // src/utils/crypto/encrypt.ts
270
+ var import_node_crypto3 = require("crypto");
271
+
272
+ // src/entry.ts
472
273
  function startupWithUpdater(fn) {
473
274
  return fn;
474
275
  }
475
276
  var defaultOnInstall = (install, _, __, logger) => {
476
277
  install();
477
- logger?.info(`update success!`);
278
+ logger.info(`update success!`);
478
279
  };
479
- async function initApp(appOptions = {}) {
280
+ async function initApp(appOptions) {
480
281
  const {
282
+ provider,
481
283
  updater,
482
- electronDevDistPath = "../dist-electron",
483
- mainPath = "main/index.js",
484
- hooks
485
- } = appOptions || {};
486
- const {
487
284
  onInstall = defaultOnInstall,
488
285
  beforeStart,
489
286
  onStartError
490
- } = hooks || {};
491
- function handleError(err, logger2) {
492
- console.error(err);
493
- onStartError?.(err, logger2);
494
- import_electron4.app.quit();
495
- }
287
+ } = appOptions;
496
288
  let updaterInstance;
497
289
  if (typeof updater === "object" || !updater) {
498
- updaterInstance = createUpdater(updater);
290
+ updaterInstance = new Updater(provider, updater);
499
291
  } else {
500
292
  updaterInstance = await updater();
501
293
  }
502
- const logger = updaterInstance.logger;
294
+ const logger = updaterInstance.logger || console;
503
295
  try {
504
296
  const appNameAsarPath = getPathFromAppNameAsar();
505
297
  const tempAsarPath = `${appNameAsarPath}.tmp`;
506
- if ((0, import_node_fs4.existsSync)(tempAsarPath)) {
507
- logger?.info(`installing new asar: ${tempAsarPath}`);
508
- await onInstall(() => (0, import_node_fs4.renameSync)(tempAsarPath, appNameAsarPath), tempAsarPath, appNameAsarPath, logger);
298
+ if ((0, import_node_fs5.existsSync)(tempAsarPath)) {
299
+ logger.info(`installing new asar: ${tempAsarPath}`);
300
+ await onInstall(() => (0, import_node_fs5.renameSync)(tempAsarPath, appNameAsarPath), tempAsarPath, appNameAsarPath, logger);
509
301
  }
510
- const mainDir = is.dev ? electronDevDistPath : appNameAsarPath;
511
- const entry = (0, import_node_path2.resolve)(__dirname, mainDir, mainPath);
512
- await beforeStart?.(entry, logger);
513
- require(entry)(updaterInstance);
302
+ const mainFilePath = (0, import_node_path2.join)(
303
+ isDev ? (0, import_node_path2.join)(import_electron4.app.getAppPath(), __EIU_MAIN_DEV_DIR__) : appNameAsarPath,
304
+ "main",
305
+ __EIU_MAIN_FILE__
306
+ );
307
+ await beforeStart?.(mainFilePath, logger);
308
+ require(mainFilePath)(updaterInstance);
514
309
  } catch (error) {
515
- handleError(error, logger);
310
+ logger.error("startup error", error);
311
+ onStartError?.(error, logger);
312
+ import_electron4.app.quit();
516
313
  }
517
314
  }
518
315
  // Annotate the CommonJS export names for ESM import in node:
519
316
  0 && (module.exports = {
520
- DownloadError,
521
- MinimumVersionError,
317
+ ErrorInfo,
522
318
  Updater,
523
- VerifyFailedError,
524
- createUpdater,
319
+ UpdaterError,
525
320
  initApp,
526
321
  startupWithUpdater
527
322
  });