electron-incremental-update 0.8.6 → 0.8.8

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/README.md CHANGED
@@ -51,30 +51,32 @@ src
51
51
 
52
52
  ```ts
53
53
  // electron/app.ts
54
- import { getGithubReleaseCdnGroup, initApp, parseGithubCdnURL } from 'electron-incremental-update'
54
+ import { initApp, parseGithubCdnURL } from 'electron-incremental-update'
55
55
  import { name, repository } from '../package.json'
56
56
 
57
57
  const SIGNATURE_CERT = '' // auto generate certificate when start app
58
58
 
59
- const { cdnPrefix: asarPrefix } = getGithubReleaseCdnGroup()[0]
60
- const { cdnPrefix: jsonPrefix } = getGithubFileCdnGroup()[0]
61
59
  initApp({ onStart: console.log })
62
60
  // can be updater option or function that return updater
63
61
  .setUpdater({
64
62
  SIGNATURE_CERT,
65
63
  productName: name,
66
64
  repository,
67
- updateJsonURL: parseGithubCdnURL(repository, jsonPrefix, 'version.json'),
68
- releaseAsarURL: parseGithubCdnURL(repository, asarPrefix, `download/latest/${name}.asar.gz`),
65
+ updateJsonURL: parseGithubCdnURL(repository, '...', 'version.json'),
66
+ releaseAsarURL: parseGithubCdnURL(repository, '...', `download/latest/${name}.asar.gz`),
69
67
  receiveBeta: true
70
68
  })
71
69
  ```
72
70
 
71
+ - [some cdn resources](https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34):
72
+
73
73
  ### setup vite.config.ts
74
74
 
75
75
  make sure the plugin is set in the **last** build task
76
76
 
77
77
  - for `vite-plugin-electron`, set it to `preload` (the second object in the plugin option array)
78
+ - cert is read from `process.env.UPDATER_CERT` first, then read config
79
+ - privatekey is read from `process.env.UPDATER_PK` first, then read config
78
80
 
79
81
  ```ts
80
82
  // vite.config.ts
@@ -174,7 +176,7 @@ However, you have the option to customize the download function when creating th
174
176
  ```ts
175
177
  // electron/main/index.ts
176
178
  import type { StartupWithUpdater, Updater } from 'electron-incremental-update'
177
- import { getAppVersion, getElectronVersion, getProductAsarPath } from 'electron-incremental-update/utils'
179
+ import { appInfo, getProductAsarPath } from 'electron-incremental-update/utils'
178
180
  import { app } from 'electron'
179
181
  import { name } from '../../package.json'
180
182
 
@@ -182,8 +184,8 @@ const startup: StartupWithUpdater = (updater: Updater) => {
182
184
  await app.whenReady()
183
185
  console.log('\ncurrent:')
184
186
  console.log(`\tasar path: ${getProductAsarPath(name)}`)
185
- console.log(`\tapp: ${getAppVersion(name)}`)
186
- console.log(`\telectron: ${getElectronVersion()}`)
187
+ console.log(`\tapp: ${appInfo.appVersion(name)}`)
188
+ console.log(`\telectron: ${appInfo.electronVersion}`)
187
189
  updater.onDownloading = ({ percent }) => {
188
190
  console.log(percent)
189
191
  }
@@ -0,0 +1,99 @@
1
+ import {
2
+ __require
3
+ } from "./chunk-CMBFI77K.mjs";
4
+
5
+ // src/utils/core.ts
6
+ import { readFileSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
8
+ import { release } from "node:os";
9
+ import { app } from "electron";
10
+ var DEFAULT_APP_NAME = "product";
11
+ var appInfo = {
12
+ dev: !app.isPackaged,
13
+ win: process.platform === "win32",
14
+ mac: process.platform === "darwin",
15
+ linux: process.platform === "linux",
16
+ electronVersion: getElectronVersion(),
17
+ appVersion: getAppVersion,
18
+ systemVersion: release()
19
+ };
20
+ function getLocale() {
21
+ return app.isReady() ? app.getLocale() : void 0;
22
+ }
23
+ function getProductAsarPath(name = DEFAULT_APP_NAME) {
24
+ return !app.isPackaged ? "DEV.asar" : join(dirname(app.getAppPath()), `${name}.asar`);
25
+ }
26
+ function getElectronVersion() {
27
+ return app.getVersion();
28
+ }
29
+ function getAppVersion(name = DEFAULT_APP_NAME) {
30
+ return app.isPackaged ? readFileSync(join(getProductAsarPath(name), "version"), "utf-8") : getElectronVersion();
31
+ }
32
+ var NoSuchNativeModuleError = class extends Error {
33
+ moduleName;
34
+ constructor(moduleName) {
35
+ super(`no such native module: ${moduleName}`);
36
+ this.moduleName = moduleName;
37
+ }
38
+ };
39
+ function isNoSuchNativeModuleError(e) {
40
+ return e instanceof NoSuchNativeModuleError;
41
+ }
42
+ function requireNative(packageName) {
43
+ const path = app.isPackaged ? join(app.getAppPath(), "node_modules", packageName) : packageName;
44
+ try {
45
+ return __require(path);
46
+ } catch (error) {
47
+ return new NoSuchNativeModuleError(packageName);
48
+ }
49
+ }
50
+
51
+ // src/utils/utils.ts
52
+ import { app as app2 } from "electron";
53
+ function parseGithubCdnURL(originRepoURL, cdnPrefix, relativeFilePath) {
54
+ if (!originRepoURL.startsWith("https://github.com/")) {
55
+ throw new Error("origin url must start with https://github.com/");
56
+ }
57
+ originRepoURL = originRepoURL.trim().replace(/\/?$/, "/").trim();
58
+ relativeFilePath = relativeFilePath.trim().replace(/^\/|\/?$/g, "").trim();
59
+ cdnPrefix = cdnPrefix.trim().replace(/^\/?|\/?$/g, "").trim();
60
+ return originRepoURL.replace("github.com", cdnPrefix) + relativeFilePath;
61
+ }
62
+ function restartApp() {
63
+ app2.relaunch();
64
+ app2.quit();
65
+ }
66
+ function waitAppReady(duration = 1e3) {
67
+ if (app2.isReady()) {
68
+ return Promise.resolve();
69
+ }
70
+ return new Promise((resolve, reject) => {
71
+ const timeout = setTimeout(() => {
72
+ reject(new Error("app is not ready"));
73
+ }, duration);
74
+ app2.whenReady().then(() => {
75
+ clearTimeout(timeout);
76
+ resolve();
77
+ });
78
+ });
79
+ }
80
+ function handleUnexpectedErrors(callback) {
81
+ process.on("uncaughtException", callback);
82
+ process.on("unhandledRejection", callback);
83
+ }
84
+
85
+ export {
86
+ DEFAULT_APP_NAME,
87
+ appInfo,
88
+ getLocale,
89
+ getProductAsarPath,
90
+ getElectronVersion,
91
+ getAppVersion,
92
+ NoSuchNativeModuleError,
93
+ isNoSuchNativeModuleError,
94
+ requireNative,
95
+ parseGithubCdnURL,
96
+ restartApp,
97
+ waitAppReady,
98
+ handleUnexpectedErrors
99
+ };
package/dist/index.d.mts CHANGED
@@ -141,11 +141,11 @@ interface UpdaterOption {
141
141
  */
142
142
  SIGNATURE_CERT: string;
143
143
  /**
144
- * name of your application
144
+ * name of your application, you can use the `name` in `package.json`
145
145
  *
146
- * you can use the `name` in `package.json`
146
+ * @default DEFAULT_APP_NAME
147
147
  */
148
- productName: string;
148
+ productName?: string;
149
149
  /**
150
150
  * repository url, e.g. `https://github.com/electron/electron`
151
151
  *
@@ -184,7 +184,6 @@ declare class IncrementalUpdater implements Updater {
184
184
  logger?: Logger;
185
185
  onDownloading?: (progress: DownloadingInfo) => void;
186
186
  get productName(): string;
187
- set productName(name: string);
188
187
  get receiveBeta(): boolean;
189
188
  set receiveBeta(receiveBeta: boolean);
190
189
  constructor(option: UpdaterOption);
package/dist/index.d.ts CHANGED
@@ -141,11 +141,11 @@ interface UpdaterOption {
141
141
  */
142
142
  SIGNATURE_CERT: string;
143
143
  /**
144
- * name of your application
144
+ * name of your application, you can use the `name` in `package.json`
145
145
  *
146
- * you can use the `name` in `package.json`
146
+ * @default DEFAULT_APP_NAME
147
147
  */
148
- productName: string;
148
+ productName?: string;
149
149
  /**
150
150
  * repository url, e.g. `https://github.com/electron/electron`
151
151
  *
@@ -184,7 +184,6 @@ declare class IncrementalUpdater implements Updater {
184
184
  logger?: Logger;
185
185
  onDownloading?: (progress: DownloadingInfo) => void;
186
186
  get productName(): string;
187
- set productName(name: string);
188
187
  get receiveBeta(): boolean;
189
188
  set receiveBeta(receiveBeta: boolean);
190
189
  constructor(option: UpdaterOption);
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -37,7 +27,7 @@ __export(src_exports, {
37
27
  module.exports = __toCommonJS(src_exports);
38
28
  var import_node_path2 = require("path");
39
29
  var import_node_fs4 = require("fs");
40
- var import_electron3 = __toESM(require("electron"));
30
+ var import_electron4 = require("electron");
41
31
 
42
32
  // src/updater/index.ts
43
33
  var import_node_fs3 = require("fs");
@@ -48,26 +38,25 @@ var import_node_fs = require("fs");
48
38
  var import_node_path = require("path");
49
39
  var import_node_os = require("os");
50
40
  var import_electron = require("electron");
51
- function getProductAsarPath(name) {
41
+ var DEFAULT_APP_NAME = "product";
42
+ var appInfo = {
43
+ dev: !import_electron.app.isPackaged,
44
+ win: process.platform === "win32",
45
+ mac: process.platform === "darwin",
46
+ linux: process.platform === "linux",
47
+ electronVersion: getElectronVersion(),
48
+ appVersion: getAppVersion,
49
+ systemVersion: (0, import_node_os.release)()
50
+ };
51
+ function getProductAsarPath(name = DEFAULT_APP_NAME) {
52
52
  return !import_electron.app.isPackaged ? "DEV.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${name}.asar`);
53
53
  }
54
54
  function getElectronVersion() {
55
55
  return import_electron.app.getVersion();
56
56
  }
57
- function getAppVersion(name) {
57
+ function getAppVersion(name = DEFAULT_APP_NAME) {
58
58
  return import_electron.app.isPackaged ? (0, import_node_fs.readFileSync)((0, import_node_path.join)(getProductAsarPath(name), "version"), "utf-8") : getElectronVersion();
59
59
  }
60
- function waitAppReady(duration = 1e3) {
61
- return new Promise((resolve2, reject) => {
62
- const timeout = setTimeout(() => {
63
- reject(new Error("app is not ready"));
64
- }, duration);
65
- import_electron.app.whenReady().then(() => {
66
- clearTimeout(timeout);
67
- resolve2();
68
- });
69
- });
70
- }
71
60
 
72
61
  // src/utils/version.ts
73
62
  function parseVersion(version) {
@@ -115,6 +104,23 @@ async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
115
104
  });
116
105
  }
117
106
 
107
+ // src/utils/utils.ts
108
+ var import_electron2 = require("electron");
109
+ function waitAppReady(duration = 1e3) {
110
+ if (import_electron2.app.isReady()) {
111
+ return Promise.resolve();
112
+ }
113
+ return new Promise((resolve2, reject) => {
114
+ const timeout = setTimeout(() => {
115
+ reject(new Error("app is not ready"));
116
+ }, duration);
117
+ import_electron2.app.whenReady().then(() => {
118
+ clearTimeout(timeout);
119
+ resolve2();
120
+ });
121
+ });
122
+ }
123
+
118
124
  // src/crypto.ts
119
125
  var import_node_crypto = require("crypto");
120
126
  function decrypt(encryptedText, key2, iv) {
@@ -169,11 +175,11 @@ var DownloadError = class extends Error {
169
175
  };
170
176
 
171
177
  // src/updater/defaultFunctions.ts
172
- var import_electron2 = require("electron");
178
+ var import_electron3 = require("electron");
173
179
  var downloadJSONDefault = async (url, headers) => {
174
180
  await waitAppReady();
175
181
  return new Promise((resolve2, reject) => {
176
- const request = import_electron2.net.request({
182
+ const request = import_electron3.net.request({
177
183
  url,
178
184
  method: "GET",
179
185
  redirect: "follow"
@@ -207,7 +213,7 @@ var downloadBufferDefault = async (url, headers, total, onDownloading) => {
207
213
  await waitAppReady();
208
214
  let current = 0;
209
215
  return new Promise((resolve2, reject) => {
210
- const request = import_electron2.net.request({
216
+ const request = import_electron3.net.request({
211
217
  url,
212
218
  method: "GET",
213
219
  redirect: "follow"
@@ -268,9 +274,6 @@ var IncrementalUpdater = class {
268
274
  get productName() {
269
275
  return this.option.productName;
270
276
  }
271
- set productName(name) {
272
- this.option.productName = name;
273
- }
274
277
  get receiveBeta() {
275
278
  return !!this.option.receiveBeta;
276
279
  }
@@ -279,6 +282,9 @@ var IncrementalUpdater = class {
279
282
  }
280
283
  constructor(option) {
281
284
  this.option = option;
285
+ if (!option.productName) {
286
+ this.option.productName = DEFAULT_APP_NAME;
287
+ }
282
288
  this.asarPath = getProductAsarPath(this.productName);
283
289
  this.gzipPath = `${this.asarPath}.gz`;
284
290
  this.tmpFilePath = `${this.asarPath}.tmp`;
@@ -422,7 +428,7 @@ function initApp(appOptions) {
422
428
  } = hooks || {};
423
429
  function handleError(msg) {
424
430
  onStartError?.(new Error(msg));
425
- import_electron3.default.app.quit();
431
+ import_electron4.app.quit();
426
432
  }
427
433
  async function startup(updater) {
428
434
  try {
@@ -432,7 +438,7 @@ function initApp(appOptions) {
432
438
  await beforeDoUpdate?.(asarPath, updateAsarPath);
433
439
  (0, import_node_fs4.renameSync)(updateAsarPath, asarPath);
434
440
  }
435
- const mainDir = import_electron3.default.app.isPackaged ? asarPath : electronDevDistPath;
441
+ const mainDir = import_electron4.app.isPackaged ? asarPath : electronDevDistPath;
436
442
  const entry = (0, import_node_path2.resolve)(__dirname, mainDir, mainPath);
437
443
  await beforeStart?.(entry);
438
444
  require(entry)(updater);
package/dist/index.mjs CHANGED
@@ -3,11 +3,12 @@ import {
3
3
  verify
4
4
  } from "./chunk-5BZLJPHJ.mjs";
5
5
  import {
6
+ DEFAULT_APP_NAME,
6
7
  getAppVersion,
7
8
  getElectronVersion,
8
9
  getProductAsarPath,
9
10
  waitAppReady
10
- } from "./chunk-MFFH2NRM.mjs";
11
+ } from "./chunk-OGAOUYV3.mjs";
11
12
  import {
12
13
  __require,
13
14
  parseVersion,
@@ -17,7 +18,7 @@ import {
17
18
  // src/index.ts
18
19
  import { resolve } from "node:path";
19
20
  import { existsSync as existsSync2, renameSync } from "node:fs";
20
- import Electron from "electron";
21
+ import { app } from "electron";
21
22
 
22
23
  // src/updater/index.ts
23
24
  import { existsSync } from "node:fs";
@@ -148,9 +149,6 @@ var IncrementalUpdater = class {
148
149
  get productName() {
149
150
  return this.option.productName;
150
151
  }
151
- set productName(name) {
152
- this.option.productName = name;
153
- }
154
152
  get receiveBeta() {
155
153
  return !!this.option.receiveBeta;
156
154
  }
@@ -159,6 +157,9 @@ var IncrementalUpdater = class {
159
157
  }
160
158
  constructor(option) {
161
159
  this.option = option;
160
+ if (!option.productName) {
161
+ this.option.productName = DEFAULT_APP_NAME;
162
+ }
162
163
  this.asarPath = getProductAsarPath(this.productName);
163
164
  this.gzipPath = `${this.asarPath}.gz`;
164
165
  this.tmpFilePath = `${this.asarPath}.tmp`;
@@ -302,7 +303,7 @@ function initApp(appOptions) {
302
303
  } = hooks || {};
303
304
  function handleError(msg) {
304
305
  onStartError?.(new Error(msg));
305
- Electron.app.quit();
306
+ app.quit();
306
307
  }
307
308
  async function startup(updater) {
308
309
  try {
@@ -312,7 +313,7 @@ function initApp(appOptions) {
312
313
  await beforeDoUpdate?.(asarPath, updateAsarPath);
313
314
  renameSync(updateAsarPath, asarPath);
314
315
  }
315
- const mainDir = Electron.app.isPackaged ? asarPath : electronDevDistPath;
316
+ const mainDir = app.isPackaged ? asarPath : electronDevDistPath;
316
317
  const entry = resolve(__dirname, mainDir, mainPath);
317
318
  await beforeStart?.(entry);
318
319
  __require(entry)(updater);
package/dist/utils.d.mts CHANGED
@@ -1,28 +1,27 @@
1
+ declare const DEFAULT_APP_NAME = "product";
1
2
  type Info = {
2
3
  dev: boolean;
3
4
  win: boolean;
4
5
  mac: boolean;
5
6
  linux: boolean;
6
7
  electronVersion: string;
8
+ appVersion: (name?: string) => string;
7
9
  /**
8
10
  * `os.release()`
9
11
  */
10
- system: string;
11
- /**
12
- * system locale, `undefined` when `!app.isReady()`
13
- */
14
- locale: string | undefined;
12
+ systemVersion: string;
15
13
  };
16
14
  /**
17
15
  * get app info
18
16
  */
19
- declare function getAppInfo(): Info;
17
+ declare const appInfo: Info;
18
+ declare function getLocale(): string | undefined;
20
19
  /**
21
20
  * get the application asar absolute path (not `app.asar`),
22
21
  * if is in dev, return `'DEV.asar'`
23
22
  * @param name The name of the application
24
23
  */
25
- declare function getProductAsarPath(name: string): string;
24
+ declare function getProductAsarPath(name?: string): string;
26
25
  /**
27
26
  * get the version of Electron runtime
28
27
  */
@@ -33,7 +32,7 @@ declare function getElectronVersion(): string;
33
32
  * if is dev, return {@link getElectronVersion}
34
33
  * @param name - The name of the application
35
34
  */
36
- declare function getAppVersion(name: string): string;
35
+ declare function getAppVersion(name?: string): string;
37
36
  declare class NoSuchNativeModuleError extends Error {
38
37
  moduleName: string;
39
38
  constructor(moduleName: string);
@@ -44,33 +43,6 @@ declare function isNoSuchNativeModuleError(e: unknown): e is NoSuchNativeModuleE
44
43
  * @param packageName native package name
45
44
  */
46
45
  declare function requireNative<T = any>(packageName: string): T | NoSuchNativeModuleError;
47
- /**
48
- * parse Github CDN URL for accelerating the speed of downloading
49
- */
50
- declare function parseGithubCdnURL(repository: string, cdnPrefix: string, relativeFilePath: string): string;
51
- /**
52
- * get group of Github file CDN prefix for accelerating the speed of downloading project files
53
- */
54
- declare function getGithubFileCdnGroup(): {
55
- cdnPrefix: string;
56
- source: string;
57
- }[];
58
- /**
59
- * get group of github release CDN prefix for accelerating the speed of downloading release
60
- */
61
- declare function getGithubReleaseCdnGroup(): {
62
- cdnPrefix: string;
63
- source: string;
64
- }[];
65
- /**
66
- * Restarts the Electron app.
67
- */
68
- declare function restartApp(): void;
69
- /**
70
- * ensure app is ready.
71
- */
72
- declare function waitAppReady(duration?: number): Promise<void>;
73
- declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
74
46
 
75
47
  interface Version {
76
48
  major: number;
@@ -84,4 +56,20 @@ declare function parseVersion(version: string): Version;
84
56
  declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
85
57
  declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
86
58
 
87
- export { NoSuchNativeModuleError, Version, getAppInfo, getAppVersion, getElectronVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, handleUnexpectedErrors, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
59
+ /**
60
+ * parse Github CDN URL for accelerating the speed of downloading
61
+ *
62
+ * {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 some public CDN links}
63
+ */
64
+ declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, relativeFilePath: string): string;
65
+ /**
66
+ * Restarts the Electron app.
67
+ */
68
+ declare function restartApp(): void;
69
+ /**
70
+ * ensure app is ready.
71
+ */
72
+ declare function waitAppReady(duration?: number): Promise<void>;
73
+ declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
74
+
75
+ export { DEFAULT_APP_NAME, NoSuchNativeModuleError, Version, appInfo, getAppVersion, getElectronVersion, getLocale, getProductAsarPath, handleUnexpectedErrors, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
package/dist/utils.d.ts CHANGED
@@ -1,28 +1,27 @@
1
+ declare const DEFAULT_APP_NAME = "product";
1
2
  type Info = {
2
3
  dev: boolean;
3
4
  win: boolean;
4
5
  mac: boolean;
5
6
  linux: boolean;
6
7
  electronVersion: string;
8
+ appVersion: (name?: string) => string;
7
9
  /**
8
10
  * `os.release()`
9
11
  */
10
- system: string;
11
- /**
12
- * system locale, `undefined` when `!app.isReady()`
13
- */
14
- locale: string | undefined;
12
+ systemVersion: string;
15
13
  };
16
14
  /**
17
15
  * get app info
18
16
  */
19
- declare function getAppInfo(): Info;
17
+ declare const appInfo: Info;
18
+ declare function getLocale(): string | undefined;
20
19
  /**
21
20
  * get the application asar absolute path (not `app.asar`),
22
21
  * if is in dev, return `'DEV.asar'`
23
22
  * @param name The name of the application
24
23
  */
25
- declare function getProductAsarPath(name: string): string;
24
+ declare function getProductAsarPath(name?: string): string;
26
25
  /**
27
26
  * get the version of Electron runtime
28
27
  */
@@ -33,7 +32,7 @@ declare function getElectronVersion(): string;
33
32
  * if is dev, return {@link getElectronVersion}
34
33
  * @param name - The name of the application
35
34
  */
36
- declare function getAppVersion(name: string): string;
35
+ declare function getAppVersion(name?: string): string;
37
36
  declare class NoSuchNativeModuleError extends Error {
38
37
  moduleName: string;
39
38
  constructor(moduleName: string);
@@ -44,33 +43,6 @@ declare function isNoSuchNativeModuleError(e: unknown): e is NoSuchNativeModuleE
44
43
  * @param packageName native package name
45
44
  */
46
45
  declare function requireNative<T = any>(packageName: string): T | NoSuchNativeModuleError;
47
- /**
48
- * parse Github CDN URL for accelerating the speed of downloading
49
- */
50
- declare function parseGithubCdnURL(repository: string, cdnPrefix: string, relativeFilePath: string): string;
51
- /**
52
- * get group of Github file CDN prefix for accelerating the speed of downloading project files
53
- */
54
- declare function getGithubFileCdnGroup(): {
55
- cdnPrefix: string;
56
- source: string;
57
- }[];
58
- /**
59
- * get group of github release CDN prefix for accelerating the speed of downloading release
60
- */
61
- declare function getGithubReleaseCdnGroup(): {
62
- cdnPrefix: string;
63
- source: string;
64
- }[];
65
- /**
66
- * Restarts the Electron app.
67
- */
68
- declare function restartApp(): void;
69
- /**
70
- * ensure app is ready.
71
- */
72
- declare function waitAppReady(duration?: number): Promise<void>;
73
- declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
74
46
 
75
47
  interface Version {
76
48
  major: number;
@@ -84,4 +56,20 @@ declare function parseVersion(version: string): Version;
84
56
  declare function unzipFile(gzipPath: string, targetFilePath?: string): Promise<unknown>;
85
57
  declare function zipFile(filePath: string, targetFilePath?: string): Promise<unknown>;
86
58
 
87
- export { NoSuchNativeModuleError, Version, getAppInfo, getAppVersion, getElectronVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, handleUnexpectedErrors, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
59
+ /**
60
+ * parse Github CDN URL for accelerating the speed of downloading
61
+ *
62
+ * {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 some public CDN links}
63
+ */
64
+ declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, relativeFilePath: string): string;
65
+ /**
66
+ * Restarts the Electron app.
67
+ */
68
+ declare function restartApp(): void;
69
+ /**
70
+ * ensure app is ready.
71
+ */
72
+ declare function waitAppReady(duration?: number): Promise<void>;
73
+ declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
74
+
75
+ export { DEFAULT_APP_NAME, NoSuchNativeModuleError, Version, appInfo, getAppVersion, getElectronVersion, getLocale, getProductAsarPath, handleUnexpectedErrors, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
package/dist/utils.js CHANGED
@@ -20,12 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/utils/index.ts
21
21
  var utils_exports = {};
22
22
  __export(utils_exports, {
23
+ DEFAULT_APP_NAME: () => DEFAULT_APP_NAME,
23
24
  NoSuchNativeModuleError: () => NoSuchNativeModuleError,
24
- getAppInfo: () => getAppInfo,
25
+ appInfo: () => appInfo,
25
26
  getAppVersion: () => getAppVersion,
26
27
  getElectronVersion: () => getElectronVersion,
27
- getGithubFileCdnGroup: () => getGithubFileCdnGroup,
28
- getGithubReleaseCdnGroup: () => getGithubReleaseCdnGroup,
28
+ getLocale: () => getLocale,
29
29
  getProductAsarPath: () => getProductAsarPath,
30
30
  handleUnexpectedErrors: () => handleUnexpectedErrors,
31
31
  isNoSuchNativeModuleError: () => isNoSuchNativeModuleError,
@@ -44,24 +44,26 @@ var import_node_fs = require("fs");
44
44
  var import_node_path = require("path");
45
45
  var import_node_os = require("os");
46
46
  var import_electron = require("electron");
47
- function getAppInfo() {
48
- return {
49
- dev: !import_electron.app.isPackaged,
50
- win: process.platform === "win32",
51
- mac: process.platform === "darwin",
52
- linux: process.platform === "linux",
53
- electronVersion: getElectronVersion(),
54
- system: (0, import_node_os.release)(),
55
- locale: import_electron.app.isReady() ? import_electron.app.getLocale() : void 0
56
- };
47
+ var DEFAULT_APP_NAME = "product";
48
+ var appInfo = {
49
+ dev: !import_electron.app.isPackaged,
50
+ win: process.platform === "win32",
51
+ mac: process.platform === "darwin",
52
+ linux: process.platform === "linux",
53
+ electronVersion: getElectronVersion(),
54
+ appVersion: getAppVersion,
55
+ systemVersion: (0, import_node_os.release)()
56
+ };
57
+ function getLocale() {
58
+ return import_electron.app.isReady() ? import_electron.app.getLocale() : void 0;
57
59
  }
58
- function getProductAsarPath(name) {
60
+ function getProductAsarPath(name = DEFAULT_APP_NAME) {
59
61
  return !import_electron.app.isPackaged ? "DEV.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${name}.asar`);
60
62
  }
61
63
  function getElectronVersion() {
62
64
  return import_electron.app.getVersion();
63
65
  }
64
- function getAppVersion(name) {
66
+ function getAppVersion(name = DEFAULT_APP_NAME) {
65
67
  return import_electron.app.isPackaged ? (0, import_node_fs.readFileSync)((0, import_node_path.join)(getProductAsarPath(name), "version"), "utf-8") : getElectronVersion();
66
68
  }
67
69
  var NoSuchNativeModuleError = class extends Error {
@@ -82,61 +84,6 @@ function requireNative(packageName) {
82
84
  return new NoSuchNativeModuleError(packageName);
83
85
  }
84
86
  }
85
- function parseGithubCdnURL(repository, cdnPrefix, relativeFilePath) {
86
- if (!repository.startsWith("https://github.com/")) {
87
- throw new Error("url must start with https://github.com/");
88
- }
89
- repository = repository.trim().replace(/\/?$/, "/").trim();
90
- relativeFilePath = relativeFilePath.trim().replace(/^\/|\/?$/g, "").trim();
91
- cdnPrefix = cdnPrefix.trim().replace(/^\/?|\/?$/g, "").trim();
92
- return repository.replace("github.com", cdnPrefix) + relativeFilePath;
93
- }
94
- function getGithubFileCdnGroup() {
95
- return [
96
- { cdnPrefix: "cdn.jsdelivr.net/gh", source: "jsdelivr" },
97
- { cdnPrefix: "fastly.jsdelivr.net/gh", source: "jsdelivr-fastly" },
98
- { cdnPrefix: "cdn.statically.io/gh", source: "statically" },
99
- { cdnPrefix: "rawcdn.githack.com/gh", source: "githack" },
100
- { cdnPrefix: "raw.githack.com/gh", source: "githack-dev" }
101
- ];
102
- }
103
- function getGithubReleaseCdnGroup() {
104
- return [
105
- { cdnPrefix: "gh.gh2233.ml", source: "@X.I.U/XIU2" },
106
- { cdnPrefix: "ghproxy.com", source: "gh-proxy" },
107
- { cdnPrefix: "gh.ddlc.top", source: "@mtr-static-official" },
108
- { cdnPrefix: "ghdl.feizhuqwq.cf", source: "feizhuqwq.com" },
109
- { cdnPrefix: "slink.ltd", source: "\u77E5\u4E86\u5C0F\u7AD9" },
110
- { cdnPrefix: "git.xfj0.cn", source: "anonymous1" },
111
- { cdnPrefix: "gh.con.sh", source: "anonymous2" },
112
- { cdnPrefix: "ghps.cc", source: "anonymous3" },
113
- { cdnPrefix: "cors.isteed.cc/github.com", source: "Lufs's" },
114
- { cdnPrefix: "hub.gitmirror.com", source: "GitMirror" },
115
- { cdnPrefix: "js.xxooo.ml", source: "\u996D\u592A\u786C" },
116
- { cdnPrefix: "download.njuu.cf", source: "LibraryCloud-njuu" },
117
- { cdnPrefix: "download.yzuu.cf", source: "LibraryCloud-yzuu" },
118
- { cdnPrefix: "download.nuaa.cf", source: "LibraryCloud-nuaa" }
119
- ];
120
- }
121
- function restartApp() {
122
- import_electron.app.relaunch();
123
- import_electron.app.quit();
124
- }
125
- function waitAppReady(duration = 1e3) {
126
- return new Promise((resolve, reject) => {
127
- const timeout = setTimeout(() => {
128
- reject(new Error("app is not ready"));
129
- }, duration);
130
- import_electron.app.whenReady().then(() => {
131
- clearTimeout(timeout);
132
- resolve();
133
- });
134
- });
135
- }
136
- function handleUnexpectedErrors(callback) {
137
- process.on("uncaughtException", callback);
138
- process.on("unhandledRejection", callback);
139
- }
140
87
 
141
88
  // src/utils/version.ts
142
89
  function parseVersion(version) {
@@ -198,14 +145,48 @@ async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
198
145
  });
199
146
  });
200
147
  }
148
+
149
+ // src/utils/utils.ts
150
+ var import_electron2 = require("electron");
151
+ function parseGithubCdnURL(originRepoURL, cdnPrefix, relativeFilePath) {
152
+ if (!originRepoURL.startsWith("https://github.com/")) {
153
+ throw new Error("origin url must start with https://github.com/");
154
+ }
155
+ originRepoURL = originRepoURL.trim().replace(/\/?$/, "/").trim();
156
+ relativeFilePath = relativeFilePath.trim().replace(/^\/|\/?$/g, "").trim();
157
+ cdnPrefix = cdnPrefix.trim().replace(/^\/?|\/?$/g, "").trim();
158
+ return originRepoURL.replace("github.com", cdnPrefix) + relativeFilePath;
159
+ }
160
+ function restartApp() {
161
+ import_electron2.app.relaunch();
162
+ import_electron2.app.quit();
163
+ }
164
+ function waitAppReady(duration = 1e3) {
165
+ if (import_electron2.app.isReady()) {
166
+ return Promise.resolve();
167
+ }
168
+ return new Promise((resolve, reject) => {
169
+ const timeout = setTimeout(() => {
170
+ reject(new Error("app is not ready"));
171
+ }, duration);
172
+ import_electron2.app.whenReady().then(() => {
173
+ clearTimeout(timeout);
174
+ resolve();
175
+ });
176
+ });
177
+ }
178
+ function handleUnexpectedErrors(callback) {
179
+ process.on("uncaughtException", callback);
180
+ process.on("unhandledRejection", callback);
181
+ }
201
182
  // Annotate the CommonJS export names for ESM import in node:
202
183
  0 && (module.exports = {
184
+ DEFAULT_APP_NAME,
203
185
  NoSuchNativeModuleError,
204
- getAppInfo,
186
+ appInfo,
205
187
  getAppVersion,
206
188
  getElectronVersion,
207
- getGithubFileCdnGroup,
208
- getGithubReleaseCdnGroup,
189
+ getLocale,
209
190
  getProductAsarPath,
210
191
  handleUnexpectedErrors,
211
192
  isNoSuchNativeModuleError,
package/dist/utils.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
+ DEFAULT_APP_NAME,
2
3
  NoSuchNativeModuleError,
3
- getAppInfo,
4
+ appInfo,
4
5
  getAppVersion,
5
6
  getElectronVersion,
6
- getGithubFileCdnGroup,
7
- getGithubReleaseCdnGroup,
7
+ getLocale,
8
8
  getProductAsarPath,
9
9
  handleUnexpectedErrors,
10
10
  isNoSuchNativeModuleError,
@@ -12,19 +12,19 @@ import {
12
12
  requireNative,
13
13
  restartApp,
14
14
  waitAppReady
15
- } from "./chunk-MFFH2NRM.mjs";
15
+ } from "./chunk-OGAOUYV3.mjs";
16
16
  import {
17
17
  parseVersion,
18
18
  unzipFile,
19
19
  zipFile
20
20
  } from "./chunk-CMBFI77K.mjs";
21
21
  export {
22
+ DEFAULT_APP_NAME,
22
23
  NoSuchNativeModuleError,
23
- getAppInfo,
24
+ appInfo,
24
25
  getAppVersion,
25
26
  getElectronVersion,
26
- getGithubFileCdnGroup,
27
- getGithubReleaseCdnGroup,
27
+ getLocale,
28
28
  getProductAsarPath,
29
29
  handleUnexpectedErrors,
30
30
  isNoSuchNativeModuleError,
package/dist/vite.js CHANGED
@@ -189,9 +189,6 @@ async function buildEntry({
189
189
  });
190
190
  }
191
191
 
192
- // src/build-plugins/option.ts
193
- var import_ci_info = require("ci-info");
194
-
195
192
  // src/build-plugins/key.ts
196
193
  var import_node_fs3 = require("fs");
197
194
  var import_node_path = require("path");
@@ -235,7 +232,6 @@ function writeCertToMain(entryPath, cert) {
235
232
  !isMatched && lines.push(r);
236
233
  replaced = lines.join(eol);
237
234
  }
238
- console.log(JSON.stringify(replaced));
239
235
  (0, import_node_fs3.writeFileSync)(entryPath, replaced);
240
236
  }
241
237
  function parseKeys({
@@ -251,8 +247,8 @@ function parseKeys({
251
247
  if (!(0, import_node_fs3.existsSync)(privateKeyPath) || !(0, import_node_fs3.existsSync)(certPath)) {
252
248
  generateKeyPair(keyLength, parseSubjects(subject), days, privateKeyPath, certPath);
253
249
  }
254
- const privateKey = (0, import_node_fs3.readFileSync)(privateKeyPath, "utf-8");
255
- const cert = (0, import_node_fs3.readFileSync)(certPath, "utf-8");
250
+ const privateKey = process.env.UPDATER_PK || (0, import_node_fs3.readFileSync)(privateKeyPath, "utf-8");
251
+ const cert = process.env.UPDATER_CERT || (0, import_node_fs3.readFileSync)(certPath, "utf-8");
256
252
  writeCertToMain(entryPath, cert);
257
253
  return {
258
254
  privateKey,
@@ -313,27 +309,24 @@ function parseOptions(options) {
313
309
  entryOutputPath,
314
310
  minify
315
311
  };
316
- let buildVersionOption;
317
- if (!import_ci_info.isCI) {
318
- const { privateKey, cert } = parseKeys({
319
- keyLength,
320
- privateKeyPath,
321
- certPath,
322
- entryPath,
323
- subject,
324
- days
325
- });
326
- buildVersionOption = {
327
- version,
328
- minimumVersion,
329
- gzipPath,
330
- privateKey,
331
- cert,
332
- versionPath,
333
- generateSignature,
334
- generateVersionJson
335
- };
336
- }
312
+ const { privateKey, cert } = parseKeys({
313
+ keyLength,
314
+ privateKeyPath,
315
+ certPath,
316
+ entryPath,
317
+ subject,
318
+ days
319
+ });
320
+ const buildVersionOption = {
321
+ version,
322
+ minimumVersion,
323
+ gzipPath,
324
+ privateKey,
325
+ cert,
326
+ versionPath,
327
+ generateSignature,
328
+ generateVersionJson
329
+ };
337
330
  return { isBuild, buildAsarOption, buildEntryOption, buildVersionOption };
338
331
  }
339
332
 
@@ -348,16 +341,16 @@ function ElectronUpdater(options) {
348
341
  name: `vite-plugin-${id}`,
349
342
  enforce: "post",
350
343
  async closeBundle() {
351
- log.info("build entry start");
344
+ log.info("build entry start", { timestamp: true });
352
345
  await buildEntry(buildEntryOption);
353
- log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`);
346
+ log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`, { timestamp: true });
354
347
  if (!isBuild) {
355
348
  return;
356
349
  }
357
- log.info("build asar start");
350
+ log.info("build asar start", { timestamp: true });
358
351
  await buildAsar(buildAsarOption);
359
- buildVersionOption && await buildVersion(buildVersionOption);
360
- log.info(`build asar end, output to ${asarOutputPath}`);
352
+ await buildVersion(buildVersionOption);
353
+ log.info(`build asar end, output to ${asarOutputPath}`, { timestamp: true });
361
354
  }
362
355
  };
363
356
  }
package/dist/vite.mjs CHANGED
@@ -94,9 +94,6 @@ async function buildEntry({
94
94
  });
95
95
  }
96
96
 
97
- // src/build-plugins/option.ts
98
- import { isCI } from "ci-info";
99
-
100
97
  // src/build-plugins/key.ts
101
98
  import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "node:fs";
102
99
  import { dirname } from "node:path";
@@ -140,7 +137,6 @@ function writeCertToMain(entryPath, cert) {
140
137
  !isMatched && lines.push(r);
141
138
  replaced = lines.join(eol);
142
139
  }
143
- console.log(JSON.stringify(replaced));
144
140
  writeFileSync(entryPath, replaced);
145
141
  }
146
142
  function parseKeys({
@@ -156,8 +152,8 @@ function parseKeys({
156
152
  if (!existsSync2(privateKeyPath) || !existsSync2(certPath)) {
157
153
  generateKeyPair(keyLength, parseSubjects(subject), days, privateKeyPath, certPath);
158
154
  }
159
- const privateKey = readFileSync(privateKeyPath, "utf-8");
160
- const cert = readFileSync(certPath, "utf-8");
155
+ const privateKey = process.env.UPDATER_PK || readFileSync(privateKeyPath, "utf-8");
156
+ const cert = process.env.UPDATER_CERT || readFileSync(certPath, "utf-8");
161
157
  writeCertToMain(entryPath, cert);
162
158
  return {
163
159
  privateKey,
@@ -218,27 +214,24 @@ function parseOptions(options) {
218
214
  entryOutputPath,
219
215
  minify
220
216
  };
221
- let buildVersionOption;
222
- if (!isCI) {
223
- const { privateKey, cert } = parseKeys({
224
- keyLength,
225
- privateKeyPath,
226
- certPath,
227
- entryPath,
228
- subject,
229
- days
230
- });
231
- buildVersionOption = {
232
- version,
233
- minimumVersion,
234
- gzipPath,
235
- privateKey,
236
- cert,
237
- versionPath,
238
- generateSignature,
239
- generateVersionJson
240
- };
241
- }
217
+ const { privateKey, cert } = parseKeys({
218
+ keyLength,
219
+ privateKeyPath,
220
+ certPath,
221
+ entryPath,
222
+ subject,
223
+ days
224
+ });
225
+ const buildVersionOption = {
226
+ version,
227
+ minimumVersion,
228
+ gzipPath,
229
+ privateKey,
230
+ cert,
231
+ versionPath,
232
+ generateSignature,
233
+ generateVersionJson
234
+ };
242
235
  return { isBuild, buildAsarOption, buildEntryOption, buildVersionOption };
243
236
  }
244
237
 
@@ -253,16 +246,16 @@ function ElectronUpdater(options) {
253
246
  name: `vite-plugin-${id}`,
254
247
  enforce: "post",
255
248
  async closeBundle() {
256
- log.info("build entry start");
249
+ log.info("build entry start", { timestamp: true });
257
250
  await buildEntry(buildEntryOption);
258
- log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`);
251
+ log.info(`build entry end, ${entryPath} -> ${entryOutputPath}`, { timestamp: true });
259
252
  if (!isBuild) {
260
253
  return;
261
254
  }
262
- log.info("build asar start");
255
+ log.info("build asar start", { timestamp: true });
263
256
  await buildAsar(buildAsarOption);
264
- buildVersionOption && await buildVersion(buildVersionOption);
265
- log.info(`build asar end, output to ${asarOutputPath}`);
257
+ await buildVersion(buildVersionOption);
258
+ log.info(`build asar end, output to ${asarOutputPath}`, { timestamp: true });
266
259
  }
267
260
  };
268
261
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "author": "subframe7536",
4
- "version": "0.8.6",
4
+ "version": "0.8.8",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "scripts": {
7
7
  "build": "tsup && node fix-module.js",
@@ -1,118 +0,0 @@
1
- import {
2
- __require
3
- } from "./chunk-CMBFI77K.mjs";
4
-
5
- // src/utils/core.ts
6
- import { readFileSync } from "node:fs";
7
- import { dirname, join } from "node:path";
8
- import { release } from "node:os";
9
- import { app } from "electron";
10
- function getAppInfo() {
11
- return {
12
- dev: !app.isPackaged,
13
- win: process.platform === "win32",
14
- mac: process.platform === "darwin",
15
- linux: process.platform === "linux",
16
- electronVersion: getElectronVersion(),
17
- system: release(),
18
- locale: app.isReady() ? app.getLocale() : void 0
19
- };
20
- }
21
- function getProductAsarPath(name) {
22
- return !app.isPackaged ? "DEV.asar" : join(dirname(app.getAppPath()), `${name}.asar`);
23
- }
24
- function getElectronVersion() {
25
- return app.getVersion();
26
- }
27
- function getAppVersion(name) {
28
- return app.isPackaged ? readFileSync(join(getProductAsarPath(name), "version"), "utf-8") : getElectronVersion();
29
- }
30
- var NoSuchNativeModuleError = class extends Error {
31
- moduleName;
32
- constructor(moduleName) {
33
- super(`no such native module: ${moduleName}`);
34
- this.moduleName = moduleName;
35
- }
36
- };
37
- function isNoSuchNativeModuleError(e) {
38
- return e instanceof NoSuchNativeModuleError;
39
- }
40
- function requireNative(packageName) {
41
- const path = app.isPackaged ? join(app.getAppPath(), "node_modules", packageName) : packageName;
42
- try {
43
- return __require(path);
44
- } catch (error) {
45
- return new NoSuchNativeModuleError(packageName);
46
- }
47
- }
48
- function parseGithubCdnURL(repository, cdnPrefix, relativeFilePath) {
49
- if (!repository.startsWith("https://github.com/")) {
50
- throw new Error("url must start with https://github.com/");
51
- }
52
- repository = repository.trim().replace(/\/?$/, "/").trim();
53
- relativeFilePath = relativeFilePath.trim().replace(/^\/|\/?$/g, "").trim();
54
- cdnPrefix = cdnPrefix.trim().replace(/^\/?|\/?$/g, "").trim();
55
- return repository.replace("github.com", cdnPrefix) + relativeFilePath;
56
- }
57
- function getGithubFileCdnGroup() {
58
- return [
59
- { cdnPrefix: "cdn.jsdelivr.net/gh", source: "jsdelivr" },
60
- { cdnPrefix: "fastly.jsdelivr.net/gh", source: "jsdelivr-fastly" },
61
- { cdnPrefix: "cdn.statically.io/gh", source: "statically" },
62
- { cdnPrefix: "rawcdn.githack.com/gh", source: "githack" },
63
- { cdnPrefix: "raw.githack.com/gh", source: "githack-dev" }
64
- ];
65
- }
66
- function getGithubReleaseCdnGroup() {
67
- return [
68
- { cdnPrefix: "gh.gh2233.ml", source: "@X.I.U/XIU2" },
69
- { cdnPrefix: "ghproxy.com", source: "gh-proxy" },
70
- { cdnPrefix: "gh.ddlc.top", source: "@mtr-static-official" },
71
- { cdnPrefix: "ghdl.feizhuqwq.cf", source: "feizhuqwq.com" },
72
- { cdnPrefix: "slink.ltd", source: "\u77E5\u4E86\u5C0F\u7AD9" },
73
- { cdnPrefix: "git.xfj0.cn", source: "anonymous1" },
74
- { cdnPrefix: "gh.con.sh", source: "anonymous2" },
75
- { cdnPrefix: "ghps.cc", source: "anonymous3" },
76
- { cdnPrefix: "cors.isteed.cc/github.com", source: "Lufs's" },
77
- { cdnPrefix: "hub.gitmirror.com", source: "GitMirror" },
78
- { cdnPrefix: "js.xxooo.ml", source: "\u996D\u592A\u786C" },
79
- { cdnPrefix: "download.njuu.cf", source: "LibraryCloud-njuu" },
80
- { cdnPrefix: "download.yzuu.cf", source: "LibraryCloud-yzuu" },
81
- { cdnPrefix: "download.nuaa.cf", source: "LibraryCloud-nuaa" }
82
- ];
83
- }
84
- function restartApp() {
85
- app.relaunch();
86
- app.quit();
87
- }
88
- function waitAppReady(duration = 1e3) {
89
- return new Promise((resolve, reject) => {
90
- const timeout = setTimeout(() => {
91
- reject(new Error("app is not ready"));
92
- }, duration);
93
- app.whenReady().then(() => {
94
- clearTimeout(timeout);
95
- resolve();
96
- });
97
- });
98
- }
99
- function handleUnexpectedErrors(callback) {
100
- process.on("uncaughtException", callback);
101
- process.on("unhandledRejection", callback);
102
- }
103
-
104
- export {
105
- getAppInfo,
106
- getProductAsarPath,
107
- getElectronVersion,
108
- getAppVersion,
109
- NoSuchNativeModuleError,
110
- isNoSuchNativeModuleError,
111
- requireNative,
112
- parseGithubCdnURL,
113
- getGithubFileCdnGroup,
114
- getGithubReleaseCdnGroup,
115
- restartApp,
116
- waitAppReady,
117
- handleUnexpectedErrors
118
- };