electron-incremental-update 0.8.8 → 0.9.0
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 +3 -4
- package/dist/{chunk-OGAOUYV3.mjs → chunk-6UZHBPFT.mjs} +29 -15
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -25
- package/dist/index.mjs +1 -1
- package/dist/{updateJson-7e45d9e1.d.ts → updateJson-synsK-Pt.d.mts} +1 -1
- package/dist/updateJson-synsK-Pt.d.ts +11 -0
- package/dist/utils.d.mts +18 -10
- package/dist/utils.d.ts +18 -10
- package/dist/utils.js +32 -16
- package/dist/utils.mjs +7 -3
- package/dist/vite.d.mts +3 -3
- package/dist/vite.d.ts +3 -3
- package/package.json +38 -38
package/README.md
CHANGED
|
@@ -81,7 +81,6 @@ make sure the plugin is set in the **last** build task
|
|
|
81
81
|
```ts
|
|
82
82
|
// vite.config.ts
|
|
83
83
|
export default defineConfig(({ command }) => {
|
|
84
|
-
|
|
85
84
|
const isBuild = command === 'build'
|
|
86
85
|
// ...
|
|
87
86
|
|
|
@@ -176,7 +175,7 @@ However, you have the option to customize the download function when creating th
|
|
|
176
175
|
```ts
|
|
177
176
|
// electron/main/index.ts
|
|
178
177
|
import type { StartupWithUpdater, Updater } from 'electron-incremental-update'
|
|
179
|
-
import { appInfo, getProductAsarPath } from 'electron-incremental-update/utils'
|
|
178
|
+
import { appInfo, getAppVersion, getElectronVersion, getProductAsarPath } from 'electron-incremental-update/utils'
|
|
180
179
|
import { app } from 'electron'
|
|
181
180
|
import { name } from '../../package.json'
|
|
182
181
|
|
|
@@ -184,8 +183,8 @@ const startup: StartupWithUpdater = (updater: Updater) => {
|
|
|
184
183
|
await app.whenReady()
|
|
185
184
|
console.log('\ncurrent:')
|
|
186
185
|
console.log(`\tasar path: ${getProductAsarPath(name)}`)
|
|
187
|
-
console.log(`\tapp: ${
|
|
188
|
-
console.log(`\telectron: ${
|
|
186
|
+
console.log(`\tapp: ${getAppVersion(name)}`)
|
|
187
|
+
console.log(`\telectron: ${getElectronVersion()}`)
|
|
189
188
|
updater.onDownloading = ({ percent }) => {
|
|
190
189
|
console.log(percent)
|
|
191
190
|
}
|
|
@@ -5,23 +5,19 @@ import {
|
|
|
5
5
|
// src/utils/core.ts
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import { dirname, join } from "node:path";
|
|
8
|
-
import { release } from "node:os";
|
|
9
8
|
import { app } from "electron";
|
|
10
9
|
var DEFAULT_APP_NAME = "product";
|
|
11
|
-
var
|
|
10
|
+
var is = {
|
|
12
11
|
dev: !app.isPackaged,
|
|
13
12
|
win: process.platform === "win32",
|
|
14
13
|
mac: process.platform === "darwin",
|
|
15
|
-
linux: process.platform === "linux"
|
|
16
|
-
electronVersion: getElectronVersion(),
|
|
17
|
-
appVersion: getAppVersion,
|
|
18
|
-
systemVersion: release()
|
|
14
|
+
linux: process.platform === "linux"
|
|
19
15
|
};
|
|
20
16
|
function getLocale() {
|
|
21
17
|
return app.isReady() ? app.getLocale() : void 0;
|
|
22
18
|
}
|
|
23
19
|
function getProductAsarPath(name = DEFAULT_APP_NAME) {
|
|
24
|
-
return !app.isPackaged ?
|
|
20
|
+
return !app.isPackaged ? join(dirname(app.getAppPath()), `${name}.asar`) : "DEV.asar";
|
|
25
21
|
}
|
|
26
22
|
function getElectronVersion() {
|
|
27
23
|
return app.getVersion();
|
|
@@ -49,6 +45,8 @@ function requireNative(packageName) {
|
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
// src/utils/utils.ts
|
|
48
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
49
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
52
50
|
import { app as app2 } from "electron";
|
|
53
51
|
function parseGithubCdnURL(originRepoURL, cdnPrefix, relativeFilePath) {
|
|
54
52
|
if (!originRepoURL.startsWith("https://github.com/")) {
|
|
@@ -63,16 +61,30 @@ function restartApp() {
|
|
|
63
61
|
app2.relaunch();
|
|
64
62
|
app2.quit();
|
|
65
63
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
function setAppUserModelId(id) {
|
|
65
|
+
is.win && app2.setAppUserModelId(is.dev ? process.execPath : id);
|
|
66
|
+
}
|
|
67
|
+
function setPortableAppDataPath(dirName = "data", create) {
|
|
68
|
+
if (!is.win) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const portablePath = join2(dirname2(app2.getPath("exe")), dirName);
|
|
72
|
+
let exists = existsSync(portablePath);
|
|
73
|
+
if (create && !exists) {
|
|
74
|
+
mkdirSync(portablePath);
|
|
75
|
+
exists = true;
|
|
69
76
|
}
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
if (exists) {
|
|
78
|
+
app2.setPath("appData", portablePath);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function waitAppReady(timeout = 1e3) {
|
|
82
|
+
return app2.isReady() ? Promise.resolve() : new Promise((resolve, reject) => {
|
|
83
|
+
const _ = setTimeout(() => {
|
|
72
84
|
reject(new Error("app is not ready"));
|
|
73
|
-
},
|
|
85
|
+
}, timeout);
|
|
74
86
|
app2.whenReady().then(() => {
|
|
75
|
-
clearTimeout(
|
|
87
|
+
clearTimeout(_);
|
|
76
88
|
resolve();
|
|
77
89
|
});
|
|
78
90
|
});
|
|
@@ -84,7 +96,7 @@ function handleUnexpectedErrors(callback) {
|
|
|
84
96
|
|
|
85
97
|
export {
|
|
86
98
|
DEFAULT_APP_NAME,
|
|
87
|
-
|
|
99
|
+
is,
|
|
88
100
|
getLocale,
|
|
89
101
|
getProductAsarPath,
|
|
90
102
|
getElectronVersion,
|
|
@@ -94,6 +106,8 @@ export {
|
|
|
94
106
|
requireNative,
|
|
95
107
|
parseGithubCdnURL,
|
|
96
108
|
restartApp,
|
|
109
|
+
setAppUserModelId,
|
|
110
|
+
setPortableAppDataPath,
|
|
97
111
|
waitAppReady,
|
|
98
112
|
handleUnexpectedErrors
|
|
99
113
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as UpdateJSON } from './updateJson-
|
|
1
|
+
import { U as UpdateJSON } from './updateJson-synsK-Pt.mjs';
|
|
2
2
|
|
|
3
3
|
declare class MinimumVersionError extends Error {
|
|
4
4
|
currentVersion: string;
|
|
@@ -260,4 +260,4 @@ type SetUpdater = {
|
|
|
260
260
|
*/
|
|
261
261
|
declare function initApp(appOptions?: AppOption): SetUpdater;
|
|
262
262
|
|
|
263
|
-
export { AppOption, IncrementalUpdater, StartupWithUpdater, Updater, UpdaterOption, createUpdater, initApp };
|
|
263
|
+
export { type AppOption, IncrementalUpdater, type StartupWithUpdater, type Updater, type UpdaterOption, createUpdater, initApp };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as UpdateJSON } from './updateJson-
|
|
1
|
+
import { U as UpdateJSON } from './updateJson-synsK-Pt.js';
|
|
2
2
|
|
|
3
3
|
declare class MinimumVersionError extends Error {
|
|
4
4
|
currentVersion: string;
|
|
@@ -260,4 +260,4 @@ type SetUpdater = {
|
|
|
260
260
|
*/
|
|
261
261
|
declare function initApp(appOptions?: AppOption): SetUpdater;
|
|
262
262
|
|
|
263
|
-
export { AppOption, IncrementalUpdater, StartupWithUpdater, Updater, UpdaterOption, createUpdater, initApp };
|
|
263
|
+
export { type AppOption, IncrementalUpdater, type StartupWithUpdater, type Updater, type UpdaterOption, createUpdater, initApp };
|
package/dist/index.js
CHANGED
|
@@ -25,31 +25,27 @@ __export(src_exports, {
|
|
|
25
25
|
initApp: () => initApp
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(src_exports);
|
|
28
|
-
var
|
|
29
|
-
var
|
|
28
|
+
var import_node_path3 = require("path");
|
|
29
|
+
var import_node_fs5 = require("fs");
|
|
30
30
|
var import_electron4 = require("electron");
|
|
31
31
|
|
|
32
32
|
// src/updater/index.ts
|
|
33
|
-
var
|
|
33
|
+
var import_node_fs4 = require("fs");
|
|
34
34
|
var import_promises = require("fs/promises");
|
|
35
35
|
|
|
36
36
|
// src/utils/core.ts
|
|
37
37
|
var import_node_fs = require("fs");
|
|
38
38
|
var import_node_path = require("path");
|
|
39
|
-
var import_node_os = require("os");
|
|
40
39
|
var import_electron = require("electron");
|
|
41
40
|
var DEFAULT_APP_NAME = "product";
|
|
42
|
-
var
|
|
41
|
+
var is = {
|
|
43
42
|
dev: !import_electron.app.isPackaged,
|
|
44
43
|
win: process.platform === "win32",
|
|
45
44
|
mac: process.platform === "darwin",
|
|
46
|
-
linux: process.platform === "linux"
|
|
47
|
-
electronVersion: getElectronVersion(),
|
|
48
|
-
appVersion: getAppVersion,
|
|
49
|
-
systemVersion: (0, import_node_os.release)()
|
|
45
|
+
linux: process.platform === "linux"
|
|
50
46
|
};
|
|
51
47
|
function getProductAsarPath(name = DEFAULT_APP_NAME) {
|
|
52
|
-
return !import_electron.app.isPackaged ?
|
|
48
|
+
return !import_electron.app.isPackaged ? (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${name}.asar`) : "DEV.asar";
|
|
53
49
|
}
|
|
54
50
|
function getElectronVersion() {
|
|
55
51
|
return import_electron.app.getVersion();
|
|
@@ -105,17 +101,16 @@ async function unzipFile(gzipPath, targetFilePath = gzipPath.slice(0, -3)) {
|
|
|
105
101
|
}
|
|
106
102
|
|
|
107
103
|
// src/utils/utils.ts
|
|
104
|
+
var import_node_path2 = require("path");
|
|
105
|
+
var import_node_fs3 = require("fs");
|
|
108
106
|
var import_electron2 = require("electron");
|
|
109
|
-
function waitAppReady(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
return new Promise((resolve2, reject) => {
|
|
114
|
-
const timeout = setTimeout(() => {
|
|
107
|
+
function waitAppReady(timeout = 1e3) {
|
|
108
|
+
return import_electron2.app.isReady() ? Promise.resolve() : new Promise((resolve2, reject) => {
|
|
109
|
+
const _ = setTimeout(() => {
|
|
115
110
|
reject(new Error("app is not ready"));
|
|
116
|
-
},
|
|
111
|
+
}, timeout);
|
|
117
112
|
import_electron2.app.whenReady().then(() => {
|
|
118
|
-
clearTimeout(
|
|
113
|
+
clearTimeout(_);
|
|
119
114
|
resolve2();
|
|
120
115
|
});
|
|
121
116
|
});
|
|
@@ -145,8 +140,8 @@ var verify = (buffer, signature, cert) => {
|
|
|
145
140
|
|
|
146
141
|
// src/updateJson.ts
|
|
147
142
|
function isUpdateJSON(json) {
|
|
148
|
-
const
|
|
149
|
-
return
|
|
143
|
+
const is2 = (j) => "signature" in j && "version" in j && "size" in j && "minimumVersion" in j;
|
|
144
|
+
return is2(json) && "beta" in json && is2(json.beta);
|
|
150
145
|
}
|
|
151
146
|
|
|
152
147
|
// src/updater/types.ts
|
|
@@ -300,11 +295,11 @@ var IncrementalUpdater = class {
|
|
|
300
295
|
return await compare(productVersion, version);
|
|
301
296
|
}
|
|
302
297
|
async parseData(format, data) {
|
|
303
|
-
if ((0,
|
|
298
|
+
if ((0, import_node_fs4.existsSync)(this.tmpFilePath)) {
|
|
304
299
|
this.logger?.warn(`remove tmp file: ${this.tmpFilePath}`);
|
|
305
300
|
await (0, import_promises.rm)(this.tmpFilePath);
|
|
306
301
|
}
|
|
307
|
-
if ((0,
|
|
302
|
+
if ((0, import_node_fs4.existsSync)(this.gzipPath)) {
|
|
308
303
|
this.logger?.warn(`remove .gz file: ${this.gzipPath}`);
|
|
309
304
|
await (0, import_promises.rm)(this.gzipPath);
|
|
310
305
|
}
|
|
@@ -434,12 +429,12 @@ function initApp(appOptions) {
|
|
|
434
429
|
try {
|
|
435
430
|
const asarPath = getProductAsarPath(updater.productName);
|
|
436
431
|
const updateAsarPath = `${asarPath}.tmp`;
|
|
437
|
-
if ((0,
|
|
432
|
+
if ((0, import_node_fs5.existsSync)(updateAsarPath)) {
|
|
438
433
|
await beforeDoUpdate?.(asarPath, updateAsarPath);
|
|
439
|
-
(0,
|
|
434
|
+
(0, import_node_fs5.renameSync)(updateAsarPath, asarPath);
|
|
440
435
|
}
|
|
441
436
|
const mainDir = import_electron4.app.isPackaged ? asarPath : electronDevDistPath;
|
|
442
|
-
const entry = (0,
|
|
437
|
+
const entry = (0, import_node_path3.resolve)(__dirname, mainDir, mainPath);
|
|
443
438
|
await beforeStart?.(entry);
|
|
444
439
|
require(entry)(updater);
|
|
445
440
|
} catch (error) {
|
package/dist/index.mjs
CHANGED
package/dist/utils.d.mts
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
declare const DEFAULT_APP_NAME = "product";
|
|
2
|
-
type
|
|
2
|
+
type Is = {
|
|
3
3
|
dev: boolean;
|
|
4
4
|
win: boolean;
|
|
5
5
|
mac: boolean;
|
|
6
6
|
linux: boolean;
|
|
7
|
-
electronVersion: string;
|
|
8
|
-
appVersion: (name?: string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* `os.release()`
|
|
11
|
-
*/
|
|
12
|
-
systemVersion: string;
|
|
13
7
|
};
|
|
14
8
|
/**
|
|
15
9
|
* get app info
|
|
16
10
|
*/
|
|
17
|
-
declare const
|
|
11
|
+
declare const is: Is;
|
|
18
12
|
declare function getLocale(): string | undefined;
|
|
19
13
|
/**
|
|
20
14
|
* get the application asar absolute path (not `app.asar`),
|
|
@@ -66,10 +60,24 @@ declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, rel
|
|
|
66
60
|
* Restarts the Electron app.
|
|
67
61
|
*/
|
|
68
62
|
declare function restartApp(): void;
|
|
63
|
+
/**
|
|
64
|
+
* fix app use model id, only for Windows
|
|
65
|
+
* @param id app id
|
|
66
|
+
*/
|
|
67
|
+
declare function setAppUserModelId(id: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* set AppData dir for portable Windows app
|
|
70
|
+
*/
|
|
71
|
+
declare function setPortableAppDataPath(dirName?: string, create?: boolean): void;
|
|
69
72
|
/**
|
|
70
73
|
* ensure app is ready.
|
|
74
|
+
* @param timeout wait timeout, @default 1000
|
|
75
|
+
*/
|
|
76
|
+
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* handle all unhandled error
|
|
79
|
+
* @param callback callback function
|
|
71
80
|
*/
|
|
72
|
-
declare function waitAppReady(duration?: number): Promise<void>;
|
|
73
81
|
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
74
82
|
|
|
75
|
-
export { DEFAULT_APP_NAME, NoSuchNativeModuleError, Version,
|
|
83
|
+
export { DEFAULT_APP_NAME, NoSuchNativeModuleError, type Version, getAppVersion, getElectronVersion, getLocale, getProductAsarPath, handleUnexpectedErrors, is, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, unzipFile, waitAppReady, zipFile };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
declare const DEFAULT_APP_NAME = "product";
|
|
2
|
-
type
|
|
2
|
+
type Is = {
|
|
3
3
|
dev: boolean;
|
|
4
4
|
win: boolean;
|
|
5
5
|
mac: boolean;
|
|
6
6
|
linux: boolean;
|
|
7
|
-
electronVersion: string;
|
|
8
|
-
appVersion: (name?: string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* `os.release()`
|
|
11
|
-
*/
|
|
12
|
-
systemVersion: string;
|
|
13
7
|
};
|
|
14
8
|
/**
|
|
15
9
|
* get app info
|
|
16
10
|
*/
|
|
17
|
-
declare const
|
|
11
|
+
declare const is: Is;
|
|
18
12
|
declare function getLocale(): string | undefined;
|
|
19
13
|
/**
|
|
20
14
|
* get the application asar absolute path (not `app.asar`),
|
|
@@ -66,10 +60,24 @@ declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, rel
|
|
|
66
60
|
* Restarts the Electron app.
|
|
67
61
|
*/
|
|
68
62
|
declare function restartApp(): void;
|
|
63
|
+
/**
|
|
64
|
+
* fix app use model id, only for Windows
|
|
65
|
+
* @param id app id
|
|
66
|
+
*/
|
|
67
|
+
declare function setAppUserModelId(id: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* set AppData dir for portable Windows app
|
|
70
|
+
*/
|
|
71
|
+
declare function setPortableAppDataPath(dirName?: string, create?: boolean): void;
|
|
69
72
|
/**
|
|
70
73
|
* ensure app is ready.
|
|
74
|
+
* @param timeout wait timeout, @default 1000
|
|
75
|
+
*/
|
|
76
|
+
declare function waitAppReady(timeout?: number): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* handle all unhandled error
|
|
79
|
+
* @param callback callback function
|
|
71
80
|
*/
|
|
72
|
-
declare function waitAppReady(duration?: number): Promise<void>;
|
|
73
81
|
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
74
82
|
|
|
75
|
-
export { DEFAULT_APP_NAME, NoSuchNativeModuleError, Version,
|
|
83
|
+
export { DEFAULT_APP_NAME, NoSuchNativeModuleError, type Version, getAppVersion, getElectronVersion, getLocale, getProductAsarPath, handleUnexpectedErrors, is, isNoSuchNativeModuleError, parseGithubCdnURL, parseVersion, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, unzipFile, waitAppReady, zipFile };
|
package/dist/utils.js
CHANGED
|
@@ -22,17 +22,19 @@ var utils_exports = {};
|
|
|
22
22
|
__export(utils_exports, {
|
|
23
23
|
DEFAULT_APP_NAME: () => DEFAULT_APP_NAME,
|
|
24
24
|
NoSuchNativeModuleError: () => NoSuchNativeModuleError,
|
|
25
|
-
appInfo: () => appInfo,
|
|
26
25
|
getAppVersion: () => getAppVersion,
|
|
27
26
|
getElectronVersion: () => getElectronVersion,
|
|
28
27
|
getLocale: () => getLocale,
|
|
29
28
|
getProductAsarPath: () => getProductAsarPath,
|
|
30
29
|
handleUnexpectedErrors: () => handleUnexpectedErrors,
|
|
30
|
+
is: () => is,
|
|
31
31
|
isNoSuchNativeModuleError: () => isNoSuchNativeModuleError,
|
|
32
32
|
parseGithubCdnURL: () => parseGithubCdnURL,
|
|
33
33
|
parseVersion: () => parseVersion,
|
|
34
34
|
requireNative: () => requireNative,
|
|
35
35
|
restartApp: () => restartApp,
|
|
36
|
+
setAppUserModelId: () => setAppUserModelId,
|
|
37
|
+
setPortableAppDataPath: () => setPortableAppDataPath,
|
|
36
38
|
unzipFile: () => unzipFile,
|
|
37
39
|
waitAppReady: () => waitAppReady,
|
|
38
40
|
zipFile: () => zipFile
|
|
@@ -42,23 +44,19 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
42
44
|
// src/utils/core.ts
|
|
43
45
|
var import_node_fs = require("fs");
|
|
44
46
|
var import_node_path = require("path");
|
|
45
|
-
var import_node_os = require("os");
|
|
46
47
|
var import_electron = require("electron");
|
|
47
48
|
var DEFAULT_APP_NAME = "product";
|
|
48
|
-
var
|
|
49
|
+
var is = {
|
|
49
50
|
dev: !import_electron.app.isPackaged,
|
|
50
51
|
win: process.platform === "win32",
|
|
51
52
|
mac: process.platform === "darwin",
|
|
52
|
-
linux: process.platform === "linux"
|
|
53
|
-
electronVersion: getElectronVersion(),
|
|
54
|
-
appVersion: getAppVersion,
|
|
55
|
-
systemVersion: (0, import_node_os.release)()
|
|
53
|
+
linux: process.platform === "linux"
|
|
56
54
|
};
|
|
57
55
|
function getLocale() {
|
|
58
56
|
return import_electron.app.isReady() ? import_electron.app.getLocale() : void 0;
|
|
59
57
|
}
|
|
60
58
|
function getProductAsarPath(name = DEFAULT_APP_NAME) {
|
|
61
|
-
return !import_electron.app.isPackaged ?
|
|
59
|
+
return !import_electron.app.isPackaged ? (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${name}.asar`) : "DEV.asar";
|
|
62
60
|
}
|
|
63
61
|
function getElectronVersion() {
|
|
64
62
|
return import_electron.app.getVersion();
|
|
@@ -147,6 +145,8 @@ async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
|
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
// src/utils/utils.ts
|
|
148
|
+
var import_node_path2 = require("path");
|
|
149
|
+
var import_node_fs3 = require("fs");
|
|
150
150
|
var import_electron2 = require("electron");
|
|
151
151
|
function parseGithubCdnURL(originRepoURL, cdnPrefix, relativeFilePath) {
|
|
152
152
|
if (!originRepoURL.startsWith("https://github.com/")) {
|
|
@@ -161,16 +161,30 @@ function restartApp() {
|
|
|
161
161
|
import_electron2.app.relaunch();
|
|
162
162
|
import_electron2.app.quit();
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
function setAppUserModelId(id) {
|
|
165
|
+
is.win && import_electron2.app.setAppUserModelId(is.dev ? process.execPath : id);
|
|
166
|
+
}
|
|
167
|
+
function setPortableAppDataPath(dirName = "data", create) {
|
|
168
|
+
if (!is.win) {
|
|
169
|
+
return;
|
|
167
170
|
}
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
const portablePath = (0, import_node_path2.join)((0, import_node_path2.dirname)(import_electron2.app.getPath("exe")), dirName);
|
|
172
|
+
let exists = (0, import_node_fs3.existsSync)(portablePath);
|
|
173
|
+
if (create && !exists) {
|
|
174
|
+
(0, import_node_fs3.mkdirSync)(portablePath);
|
|
175
|
+
exists = true;
|
|
176
|
+
}
|
|
177
|
+
if (exists) {
|
|
178
|
+
import_electron2.app.setPath("appData", portablePath);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function waitAppReady(timeout = 1e3) {
|
|
182
|
+
return import_electron2.app.isReady() ? Promise.resolve() : new Promise((resolve, reject) => {
|
|
183
|
+
const _ = setTimeout(() => {
|
|
170
184
|
reject(new Error("app is not ready"));
|
|
171
|
-
},
|
|
185
|
+
}, timeout);
|
|
172
186
|
import_electron2.app.whenReady().then(() => {
|
|
173
|
-
clearTimeout(
|
|
187
|
+
clearTimeout(_);
|
|
174
188
|
resolve();
|
|
175
189
|
});
|
|
176
190
|
});
|
|
@@ -183,17 +197,19 @@ function handleUnexpectedErrors(callback) {
|
|
|
183
197
|
0 && (module.exports = {
|
|
184
198
|
DEFAULT_APP_NAME,
|
|
185
199
|
NoSuchNativeModuleError,
|
|
186
|
-
appInfo,
|
|
187
200
|
getAppVersion,
|
|
188
201
|
getElectronVersion,
|
|
189
202
|
getLocale,
|
|
190
203
|
getProductAsarPath,
|
|
191
204
|
handleUnexpectedErrors,
|
|
205
|
+
is,
|
|
192
206
|
isNoSuchNativeModuleError,
|
|
193
207
|
parseGithubCdnURL,
|
|
194
208
|
parseVersion,
|
|
195
209
|
requireNative,
|
|
196
210
|
restartApp,
|
|
211
|
+
setAppUserModelId,
|
|
212
|
+
setPortableAppDataPath,
|
|
197
213
|
unzipFile,
|
|
198
214
|
waitAppReady,
|
|
199
215
|
zipFile
|
package/dist/utils.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_APP_NAME,
|
|
3
3
|
NoSuchNativeModuleError,
|
|
4
|
-
appInfo,
|
|
5
4
|
getAppVersion,
|
|
6
5
|
getElectronVersion,
|
|
7
6
|
getLocale,
|
|
8
7
|
getProductAsarPath,
|
|
9
8
|
handleUnexpectedErrors,
|
|
9
|
+
is,
|
|
10
10
|
isNoSuchNativeModuleError,
|
|
11
11
|
parseGithubCdnURL,
|
|
12
12
|
requireNative,
|
|
13
13
|
restartApp,
|
|
14
|
+
setAppUserModelId,
|
|
15
|
+
setPortableAppDataPath,
|
|
14
16
|
waitAppReady
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6UZHBPFT.mjs";
|
|
16
18
|
import {
|
|
17
19
|
parseVersion,
|
|
18
20
|
unzipFile,
|
|
@@ -21,17 +23,19 @@ import {
|
|
|
21
23
|
export {
|
|
22
24
|
DEFAULT_APP_NAME,
|
|
23
25
|
NoSuchNativeModuleError,
|
|
24
|
-
appInfo,
|
|
25
26
|
getAppVersion,
|
|
26
27
|
getElectronVersion,
|
|
27
28
|
getLocale,
|
|
28
29
|
getProductAsarPath,
|
|
29
30
|
handleUnexpectedErrors,
|
|
31
|
+
is,
|
|
30
32
|
isNoSuchNativeModuleError,
|
|
31
33
|
parseGithubCdnURL,
|
|
32
34
|
parseVersion,
|
|
33
35
|
requireNative,
|
|
34
36
|
restartApp,
|
|
37
|
+
setAppUserModelId,
|
|
38
|
+
setPortableAppDataPath,
|
|
35
39
|
unzipFile,
|
|
36
40
|
waitAppReady,
|
|
37
41
|
zipFile
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
-
import { U as UpdateJSON } from './updateJson-
|
|
2
|
+
import { U as UpdateJSON } from './updateJson-synsK-Pt.mjs';
|
|
3
3
|
|
|
4
4
|
type DistinguishedName = {
|
|
5
5
|
countryName?: string;
|
|
@@ -43,7 +43,7 @@ type Options = {
|
|
|
43
43
|
* the name of you application
|
|
44
44
|
*
|
|
45
45
|
* you can set as 'name' in `package.json`
|
|
46
|
-
|
|
46
|
+
*/
|
|
47
47
|
productName: string;
|
|
48
48
|
/**
|
|
49
49
|
* the version of you application
|
|
@@ -146,4 +146,4 @@ type Options = {
|
|
|
146
146
|
|
|
147
147
|
declare function ElectronUpdater(options: Options): Plugin;
|
|
148
148
|
|
|
149
|
-
export { ElectronUpdater, Options };
|
|
149
|
+
export { ElectronUpdater, type Options };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
-
import { U as UpdateJSON } from './updateJson-
|
|
2
|
+
import { U as UpdateJSON } from './updateJson-synsK-Pt.js';
|
|
3
3
|
|
|
4
4
|
type DistinguishedName = {
|
|
5
5
|
countryName?: string;
|
|
@@ -43,7 +43,7 @@ type Options = {
|
|
|
43
43
|
* the name of you application
|
|
44
44
|
*
|
|
45
45
|
* you can set as 'name' in `package.json`
|
|
46
|
-
|
|
46
|
+
*/
|
|
47
47
|
productName: string;
|
|
48
48
|
/**
|
|
49
49
|
* the version of you application
|
|
@@ -146,4 +146,4 @@ type Options = {
|
|
|
146
146
|
|
|
147
147
|
declare function ElectronUpdater(options: Options): Plugin;
|
|
148
148
|
|
|
149
|
-
export { ElectronUpdater, Options };
|
|
149
|
+
export { ElectronUpdater, type Options };
|
package/package.json
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-incremental-update",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.8.8",
|
|
3
|
+
"version": "0.9.0",
|
|
5
4
|
"description": "electron incremental update tools, powered by vite",
|
|
6
|
-
"
|
|
7
|
-
"build": "tsup && node fix-module.js",
|
|
8
|
-
"release": "pnpm test && pnpm run build && bumpp --all && npm publish",
|
|
9
|
-
"test": "vitest --run",
|
|
10
|
-
"lint": "eslint . --fix"
|
|
11
|
-
},
|
|
12
|
-
"publishConfig": {
|
|
13
|
-
"access": "public",
|
|
14
|
-
"registry": "https://registry.npmjs.org/"
|
|
15
|
-
},
|
|
16
|
-
"repository": "https://github.com/subframe7536/electron-incremental-update",
|
|
5
|
+
"author": "subframe7536",
|
|
17
6
|
"license": "MIT",
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"utils.d.ts"
|
|
7
|
+
"repository": "https://github.com/subframe7536/electron-incremental-update",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"electron",
|
|
10
|
+
"incremental update",
|
|
11
|
+
"updater"
|
|
24
12
|
],
|
|
25
|
-
"main": "dist/index.js",
|
|
26
|
-
"module": "dist/index.mjs",
|
|
27
13
|
"exports": {
|
|
28
14
|
".": {
|
|
29
15
|
"import": "./dist/index.mjs",
|
|
@@ -38,25 +24,39 @@
|
|
|
38
24
|
"require": "./dist/utils.js"
|
|
39
25
|
}
|
|
40
26
|
},
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"module": "dist/index.mjs",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"utils.d.ts",
|
|
32
|
+
"utils.js",
|
|
33
|
+
"vite.d.ts",
|
|
34
|
+
"vite.js"
|
|
45
35
|
],
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup && node fix-module.js",
|
|
38
|
+
"release": "pnpm test && pnpm run build && bumpp --all && npm publish",
|
|
39
|
+
"test": "vitest --run",
|
|
40
|
+
"lint": "eslint . --fix"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
45
|
},
|
|
56
46
|
"dependencies": {
|
|
57
|
-
"@electron/asar": "^3.2.
|
|
58
|
-
"ci-info": "^
|
|
59
|
-
"selfsigned": "^2.
|
|
60
|
-
|
|
47
|
+
"@electron/asar": "^3.2.8",
|
|
48
|
+
"ci-info": "^4.0.0",
|
|
49
|
+
"selfsigned": "^2.4.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@subframe7536/eslint-config": "^0.5.0",
|
|
53
|
+
"@types/node": "^20.9.4",
|
|
54
|
+
"bumpp": "^9.2.0",
|
|
55
|
+
"electron": "^27.1.0",
|
|
56
|
+
"eslint": "^8.54.0",
|
|
57
|
+
"tsup": "^8.0.1",
|
|
58
|
+
"typescript": "^5.3.2",
|
|
59
|
+
"vite": "^5.0.2",
|
|
60
|
+
"vitest": "^0.34.6"
|
|
61
61
|
}
|
|
62
62
|
}
|