electron-incremental-update 2.4.3 → 3.0.0-beta.3

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.
Files changed (47) hide show
  1. package/README.md +48 -40
  2. package/dist/download-BN4uMS4_.d.mts +39 -0
  3. package/dist/download-DO7iuxEJ.d.cts +39 -0
  4. package/dist/electron-DH-Uyikp.cjs +321 -0
  5. package/dist/electron-OKQIYbcw.mjs +181 -0
  6. package/dist/index.cjs +261 -331
  7. package/dist/index.d.cts +179 -169
  8. package/dist/index.d.mts +204 -0
  9. package/dist/index.mjs +273 -0
  10. package/dist/provider.cjs +142 -330
  11. package/dist/provider.d.cts +113 -114
  12. package/dist/provider.d.mts +133 -0
  13. package/dist/provider.mjs +152 -0
  14. package/dist/types-BM9Jfu7q.d.cts +154 -0
  15. package/dist/types-DASqEPXE.d.mts +154 -0
  16. package/dist/utils.cjs +43 -381
  17. package/dist/utils.d.cts +120 -85
  18. package/dist/utils.d.mts +164 -0
  19. package/dist/utils.mjs +5 -0
  20. package/dist/version--eVB2A7n.mjs +72 -0
  21. package/dist/version-aPrLuz_-.cjs +129 -0
  22. package/dist/vite.d.mts +521 -0
  23. package/dist/vite.mjs +1094 -0
  24. package/dist/zip-BCC7FAQ_.cjs +264 -0
  25. package/dist/zip-Dwm7s1C9.mjs +185 -0
  26. package/package.json +66 -64
  27. package/dist/chunk-AAAM44NW.js +0 -70
  28. package/dist/chunk-IVHNGRZY.js +0 -122
  29. package/dist/chunk-PD4EV4MM.js +0 -147
  30. package/dist/index.d.ts +0 -194
  31. package/dist/index.js +0 -309
  32. package/dist/provider.d.ts +0 -134
  33. package/dist/provider.js +0 -152
  34. package/dist/types-CU7GyVez.d.cts +0 -151
  35. package/dist/types-CU7GyVez.d.ts +0 -151
  36. package/dist/utils.d.ts +0 -129
  37. package/dist/utils.js +0 -3
  38. package/dist/vite.d.ts +0 -533
  39. package/dist/vite.js +0 -945
  40. package/dist/zip-Blmn2vzE.d.cts +0 -71
  41. package/dist/zip-CnSv_Njj.d.ts +0 -71
  42. package/provider.d.ts +0 -1
  43. package/provider.js +0 -1
  44. package/utils.d.ts +0 -1
  45. package/utils.js +0 -1
  46. package/vite.d.ts +0 -1
  47. package/vite.js +0 -1
@@ -0,0 +1,164 @@
1
+ import { c as Version, d as isUpdateJSON, f as parseVersion, l as defaultIsLowerVersion, o as UpdateInfo, s as UpdateJSON, u as defaultVersionJsonGenerator } from "./types-DASqEPXE.mjs";
2
+ import { a as getHeader, i as downloadUtil, n as defaultDownloadText, o as resolveJson, r as defaultDownloadUpdateJSON, t as defaultDownloadAsar } from "./download-BN4uMS4_.mjs";
3
+ import { BrowserWindow } from "electron";
4
+
5
+ //#region src/utils/crypto.d.ts
6
+ declare function hashBuffer(data: string | Buffer, length: number): Buffer;
7
+ declare function aesEncrypt(plainText: string, key: Buffer, iv: Buffer): string;
8
+ /**
9
+ * Default function to generate asar signature, returns generated signature
10
+ * @param buffer file buffer
11
+ * @param privateKey primary key
12
+ * @param cert certificate
13
+ * @param version target version
14
+ */
15
+ declare function defaultSignature(buffer: Buffer, privateKey: string, cert: string, version: string): string;
16
+ declare function aesDecrypt(encryptedText: string, key: Buffer, iv: Buffer): string;
17
+ /**
18
+ * Default function to verify asar signature,
19
+ * if signature is valid, returns the version, otherwise returns `undefined`
20
+ * @param buffer file buffer
21
+ * @param version target version
22
+ * @param signature signature
23
+ * @param cert certificate
24
+ */
25
+ declare function defaultVerifySignature(buffer: Buffer, version: string, signature: string, cert: string): boolean;
26
+ //#endregion
27
+ //#region src/utils/electron.d.ts
28
+ /**
29
+ * Compile time dev check
30
+ */
31
+ declare const isDev: boolean;
32
+ declare const isWin: boolean;
33
+ declare const isMac: boolean;
34
+ declare const isLinux: boolean;
35
+ /**
36
+ * Get joined path of `${electron.app.name}.asar` (not `app.asar`)
37
+ *
38
+ * If is in dev, **always** return `'DEV.asar'`
39
+ */
40
+ declare function getPathFromAppNameAsar(...paths: string[]): string;
41
+ /**
42
+ * Get app version, if is in dev, return `getEntryVersion()`
43
+ */
44
+ declare function getAppVersion(): string;
45
+ /**
46
+ * Get entry version
47
+ */
48
+ declare function getEntryVersion(): string;
49
+ /**
50
+ * Use `require` to load native module from entry asar
51
+ * @param moduleName file name in entry
52
+ * @example
53
+ * requireNative<typeof import('../native/db')>('db')
54
+ */
55
+ declare function requireNative<T = any>(moduleName: string): T;
56
+ /**
57
+ * Use `import` to load native module from entry asar
58
+ * @param moduleName file name in entry
59
+ * @example
60
+ * await importNative<typeof import('../native/db')>('db')
61
+ */
62
+ declare function importNative<T = any>(moduleName: string): Promise<T>;
63
+ /**
64
+ * Restarts the Electron app.
65
+ */
66
+ declare function restartApp(): void;
67
+ /**
68
+ * Fix app use model id, only for Windows
69
+ * @param id app id, default is `org.${electron.app.name}`
70
+ */
71
+ declare function setAppUserModelId(id?: string): void;
72
+ /**
73
+ * Disable hardware acceleration for Windows 7
74
+ *
75
+ * Only support CommonJS
76
+ */
77
+ declare function disableHWAccForWin7(): void;
78
+ /**
79
+ * Keep single electron instance and auto restore window on `second-instance` event
80
+ * @param window brwoser window to show
81
+ */
82
+ declare function singleInstance(window?: BrowserWindow): void;
83
+ /**
84
+ * Set `userData` dir to the dir of .exe file
85
+ *
86
+ * Useful for portable Windows app
87
+ * @param dirName dir name, default to `data`
88
+ * @param create whether to create dir, default to `true`
89
+ */
90
+ declare function setPortableDataPath(dirName?: string, create?: boolean): void;
91
+ /**
92
+ * @deprecated Use {@link setPortableDataPath} instead
93
+ */
94
+ declare const setPortableAppDataPath: typeof setPortableDataPath;
95
+ /**
96
+ * Load `process.env.VITE_DEV_SERVER_URL` when dev, else load html file
97
+ * @param win window
98
+ * @param htmlFilePath html file path, default is `index.html`
99
+ */
100
+ declare function loadPage(win: BrowserWindow, htmlFilePath?: string): void;
101
+ interface BeautifyDevToolsOptions {
102
+ /**
103
+ * Sans-serif font family
104
+ */
105
+ sans: string;
106
+ /**
107
+ * Monospace font family
108
+ */
109
+ mono: string;
110
+ /**
111
+ * Whether to round scrollbar
112
+ */
113
+ scrollbar?: boolean;
114
+ }
115
+ /**
116
+ * Beautify devtools' font and scrollbar
117
+ * @param win target window
118
+ * @param options sans font family, mono font family and scrollbar
119
+ * @see https://github.com/electron/electron/issues/42055
120
+ */
121
+ declare function beautifyDevTools(win: BrowserWindow, options: BeautifyDevToolsOptions): void;
122
+ /**
123
+ * Get joined path from main dir
124
+ * @param paths rest paths
125
+ */
126
+ declare function getPathFromMain(...paths: string[]): string;
127
+ /**
128
+ * Get joined path from preload dir
129
+ * @param paths rest paths
130
+ */
131
+ declare function getPathFromPreload(...paths: string[]): string;
132
+ /**
133
+ * Get joined path from publich dir
134
+ * @param paths rest paths
135
+ */
136
+ declare function getPathFromPublic(...paths: string[]): string;
137
+ /**
138
+ * Get joined path from entry asar
139
+ * @param paths rest paths
140
+ */
141
+ declare function getPathFromEntryAsar(...paths: string[]): string;
142
+ /**
143
+ * Handle all unhandled error
144
+ * @param callback callback function
145
+ */
146
+ declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
147
+ /**
148
+ * @deprecated No longer needed. It is embeded in `startupWithUpdater()
149
+ */
150
+ declare function reloadOnPreloadScriptChanged(): void;
151
+ //#endregion
152
+ //#region src/utils/zip.d.ts
153
+ /**
154
+ * Default function to compress file using brotli
155
+ * @param buffer uncompressed file buffer
156
+ */
157
+ declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
158
+ /**
159
+ * Default function to decompress file using brotli
160
+ * @param buffer compressed file buffer
161
+ */
162
+ declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
163
+ //#endregion
164
+ export { UpdateInfo, UpdateJSON, Version, aesDecrypt, aesEncrypt, beautifyDevTools, defaultDownloadAsar, defaultDownloadText, defaultDownloadUpdateJSON, defaultIsLowerVersion, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultVersionJsonGenerator, defaultZipFile, disableHWAccForWin7, downloadUtil, getAppVersion, getEntryVersion, getHeader, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, hashBuffer, importNative, isDev, isLinux, isMac, isUpdateJSON, isWin, loadPage, parseVersion, reloadOnPreloadScriptChanged, requireNative, resolveJson, restartApp, setAppUserModelId, setPortableAppDataPath, setPortableDataPath, singleInstance };
package/dist/utils.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { C as singleInstance, S as setPortableDataPath, _ as reloadOnPreloadScriptChanged, a as getPathFromAppNameAsar, b as setAppUserModelId, c as getPathFromPreload, d as importNative, f as isDev, g as loadPage, h as isWin, i as getEntryVersion, l as getPathFromPublic, m as isMac, n as disableHWAccForWin7, o as getPathFromEntryAsar, p as isLinux, r as getAppVersion, s as getPathFromMain, t as beautifyDevTools, u as handleUnexpectedErrors, v as requireNative, x as setPortableAppDataPath, y as restartApp } from "./electron-OKQIYbcw.mjs";
2
+ import { i as parseVersion, n as defaultVersionJsonGenerator, r as isUpdateJSON, t as defaultIsLowerVersion } from "./version--eVB2A7n.mjs";
3
+ import { a as defaultDownloadUpdateJSON, c as resolveJson, d as defaultSignature, f as defaultVerifySignature, i as defaultDownloadText, l as aesDecrypt, n as defaultZipFile, o as downloadUtil, p as hashBuffer, r as defaultDownloadAsar, s as getHeader, t as defaultUnzipFile, u as aesEncrypt } from "./zip-Dwm7s1C9.mjs";
4
+
5
+ export { aesDecrypt, aesEncrypt, beautifyDevTools, defaultDownloadAsar, defaultDownloadText, defaultDownloadUpdateJSON, defaultIsLowerVersion, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultVersionJsonGenerator, defaultZipFile, disableHWAccForWin7, downloadUtil, getAppVersion, getEntryVersion, getHeader, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, hashBuffer, importNative, isDev, isLinux, isMac, isUpdateJSON, isWin, loadPage, parseVersion, reloadOnPreloadScriptChanged, requireNative, resolveJson, restartApp, setAppUserModelId, setPortableAppDataPath, setPortableDataPath, singleInstance };
@@ -0,0 +1,72 @@
1
+ //#region src/utils/version.ts
2
+ /**
3
+ * Parse version string to {@link Version}, like `0.2.0-beta.1`
4
+ * @param version version string
5
+ */
6
+ function parseVersion(version) {
7
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
8
+ if (!match) throw new TypeError(`invalid version: ${version}`);
9
+ const [major, minor, patch] = match.slice(1, 4).map(Number);
10
+ const ret = {
11
+ major,
12
+ minor,
13
+ patch,
14
+ stage: "",
15
+ stageVersion: -1
16
+ };
17
+ if (match[4]) {
18
+ let [stage, _v] = match[4].split(".");
19
+ ret.stage = stage;
20
+ ret.stageVersion = Number(_v) || -1;
21
+ }
22
+ if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) throw new TypeError(`Invalid version: ${version}`);
23
+ return ret;
24
+ }
25
+ function compareStrings(str1, str2) {
26
+ if (str1 === "") return str2 !== "";
27
+ else if (str2 === "") return true;
28
+ return str1 < str2;
29
+ }
30
+ /**
31
+ * Default function to check the old version is less than new version
32
+ * @param oldVer old version string
33
+ * @param newVer new version string
34
+ */
35
+ function defaultIsLowerVersion(oldVer, newVer) {
36
+ const oldV = parseVersion(oldVer);
37
+ const newV = parseVersion(newVer);
38
+ for (let key of Object.keys(oldV)) if (key === "stage" && compareStrings(oldV[key], newV[key])) return true;
39
+ else if (oldV[key] !== newV[key]) return oldV[key] < newV[key];
40
+ return false;
41
+ }
42
+ const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
43
+ /**
44
+ * Check is `UpdateJSON`
45
+ * @param json any variable
46
+ */
47
+ function isUpdateJSON(json) {
48
+ return is(json) && is(json?.beta);
49
+ }
50
+ /**
51
+ * Default function to generate `UpdateJSON`
52
+ * @param existingJson exising update json
53
+ * @param signature sigature
54
+ * @param version target version
55
+ * @param minimumVersion minimum version
56
+ */
57
+ function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
58
+ existingJson.beta = {
59
+ version,
60
+ minimumVersion,
61
+ signature
62
+ };
63
+ if (!parseVersion(version).stage) {
64
+ existingJson.version = version;
65
+ existingJson.minimumVersion = minimumVersion;
66
+ existingJson.signature = signature;
67
+ }
68
+ return existingJson;
69
+ }
70
+
71
+ //#endregion
72
+ export { parseVersion as i, defaultVersionJsonGenerator as n, isUpdateJSON as r, defaultIsLowerVersion as t };
@@ -0,0 +1,129 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ //#region src/utils/version.ts
30
+ /**
31
+ * Parse version string to {@link Version}, like `0.2.0-beta.1`
32
+ * @param version version string
33
+ */
34
+ function parseVersion(version) {
35
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
36
+ if (!match) throw new TypeError(`invalid version: ${version}`);
37
+ const [major, minor, patch] = match.slice(1, 4).map(Number);
38
+ const ret = {
39
+ major,
40
+ minor,
41
+ patch,
42
+ stage: "",
43
+ stageVersion: -1
44
+ };
45
+ if (match[4]) {
46
+ let [stage, _v] = match[4].split(".");
47
+ ret.stage = stage;
48
+ ret.stageVersion = Number(_v) || -1;
49
+ }
50
+ if (Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) || Number.isNaN(ret.stageVersion)) throw new TypeError(`Invalid version: ${version}`);
51
+ return ret;
52
+ }
53
+ function compareStrings(str1, str2) {
54
+ if (str1 === "") return str2 !== "";
55
+ else if (str2 === "") return true;
56
+ return str1 < str2;
57
+ }
58
+ /**
59
+ * Default function to check the old version is less than new version
60
+ * @param oldVer old version string
61
+ * @param newVer new version string
62
+ */
63
+ function defaultIsLowerVersion(oldVer, newVer) {
64
+ const oldV = parseVersion(oldVer);
65
+ const newV = parseVersion(newVer);
66
+ for (let key of Object.keys(oldV)) if (key === "stage" && compareStrings(oldV[key], newV[key])) return true;
67
+ else if (oldV[key] !== newV[key]) return oldV[key] < newV[key];
68
+ return false;
69
+ }
70
+ const is = (j) => !!(j && j.minimumVersion && j.signature && j.version);
71
+ /**
72
+ * Check is `UpdateJSON`
73
+ * @param json any variable
74
+ */
75
+ function isUpdateJSON(json) {
76
+ return is(json) && is(json?.beta);
77
+ }
78
+ /**
79
+ * Default function to generate `UpdateJSON`
80
+ * @param existingJson exising update json
81
+ * @param signature sigature
82
+ * @param version target version
83
+ * @param minimumVersion minimum version
84
+ */
85
+ function defaultVersionJsonGenerator(existingJson, signature, version, minimumVersion) {
86
+ existingJson.beta = {
87
+ version,
88
+ minimumVersion,
89
+ signature
90
+ };
91
+ if (!parseVersion(version).stage) {
92
+ existingJson.version = version;
93
+ existingJson.minimumVersion = minimumVersion;
94
+ existingJson.signature = signature;
95
+ }
96
+ return existingJson;
97
+ }
98
+
99
+ //#endregion
100
+ Object.defineProperty(exports, '__toESM', {
101
+ enumerable: true,
102
+ get: function () {
103
+ return __toESM;
104
+ }
105
+ });
106
+ Object.defineProperty(exports, 'defaultIsLowerVersion', {
107
+ enumerable: true,
108
+ get: function () {
109
+ return defaultIsLowerVersion;
110
+ }
111
+ });
112
+ Object.defineProperty(exports, 'defaultVersionJsonGenerator', {
113
+ enumerable: true,
114
+ get: function () {
115
+ return defaultVersionJsonGenerator;
116
+ }
117
+ });
118
+ Object.defineProperty(exports, 'isUpdateJSON', {
119
+ enumerable: true,
120
+ get: function () {
121
+ return isUpdateJSON;
122
+ }
123
+ });
124
+ Object.defineProperty(exports, 'parseVersion', {
125
+ enumerable: true,
126
+ get: function () {
127
+ return parseVersion;
128
+ }
129
+ });