electron-incremental-update 0.8.2 → 0.8.4

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
@@ -110,7 +110,7 @@ export default defineConfig(({ command }) => {
110
110
  // ...
111
111
  }
112
112
  ]),
113
- //...
113
+ // ...
114
114
  ],
115
115
  // ...
116
116
  }
@@ -6,15 +6,20 @@ import {
6
6
  import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7
7
  import { dirname, join } from "node:path";
8
8
  import { gunzip, gzip } from "node:zlib";
9
- import { app } from "electron";
9
+ import Electron from "electron";
10
+ var info = {
11
+ dev: !Electron.app?.isPackaged,
12
+ platform: process.platform === "win32" ? "win" : process.platform === "darwin" ? "mac" : "linux",
13
+ appPath: Electron.app?.getAppPath()
14
+ };
10
15
  function getProductAsarPath(name) {
11
- return app.isPackaged ? join(dirname(app.getAppPath()), `${name}.asar`) : "dev.asar";
16
+ return info.dev ? "dev.asar" : join(dirname(info.appPath), `${name}.asar`);
12
17
  }
13
18
  function getEntryVersion() {
14
- return app.getVersion();
19
+ return Electron.app.getVersion();
15
20
  }
16
21
  function getProductVersion(name) {
17
- return app.isPackaged ? readFileSync(join(getProductAsarPath(name), "version"), "utf-8") : getEntryVersion();
22
+ return info.dev ? getEntryVersion() : readFileSync(join(getProductAsarPath(name), "version"), "utf-8");
18
23
  }
19
24
  var NoSuchNativeModuleError = class extends Error {
20
25
  moduleName;
@@ -24,7 +29,7 @@ var NoSuchNativeModuleError = class extends Error {
24
29
  }
25
30
  };
26
31
  function requireNative(packageName) {
27
- const path = app.isPackaged ? join(app.getAppPath(), "node_modules", packageName) : packageName;
32
+ const path = info.dev ? packageName : join(info.appPath, "node_modules", packageName);
28
33
  try {
29
34
  return __require(path);
30
35
  } catch (error) {
@@ -68,15 +73,15 @@ function getGithubReleaseCdnGroup() {
68
73
  ];
69
74
  }
70
75
  function restartApp() {
71
- app.relaunch();
72
- app.quit();
76
+ Electron.app.relaunch();
77
+ Electron.app.quit();
73
78
  }
74
79
  function waitAppReady(duration = 1e3) {
75
80
  return new Promise((resolve, reject) => {
76
81
  const timeout = setTimeout(() => {
77
82
  reject(new Error("app is not ready"));
78
83
  }, duration);
79
- app.whenReady().then(() => {
84
+ Electron.app.whenReady().then(() => {
80
85
  clearTimeout(timeout);
81
86
  resolve();
82
87
  });
@@ -147,6 +152,7 @@ function parseVersion(version) {
147
152
  }
148
153
 
149
154
  export {
155
+ info,
150
156
  getProductAsarPath,
151
157
  getEntryVersion,
152
158
  getProductVersion,
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -27,7 +37,7 @@ __export(src_exports, {
27
37
  module.exports = __toCommonJS(src_exports);
28
38
  var import_node_path2 = require("path");
29
39
  var import_node_fs3 = require("fs");
30
- var import_electron3 = require("electron");
40
+ var import_electron3 = __toESM(require("electron"));
31
41
 
32
42
  // src/updater/index.ts
33
43
  var import_node_fs2 = require("fs");
@@ -37,22 +47,27 @@ var import_promises = require("fs/promises");
37
47
  var import_node_fs = require("fs");
38
48
  var import_node_path = require("path");
39
49
  var import_node_zlib = require("zlib");
40
- var import_electron = require("electron");
50
+ var import_electron = __toESM(require("electron"));
51
+ var info = {
52
+ dev: !import_electron.default.app?.isPackaged,
53
+ platform: process.platform === "win32" ? "win" : process.platform === "darwin" ? "mac" : "linux",
54
+ appPath: import_electron.default.app?.getAppPath()
55
+ };
41
56
  function getProductAsarPath(name) {
42
- return import_electron.app.isPackaged ? (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${name}.asar`) : "dev.asar";
57
+ return info.dev ? "dev.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(info.appPath), `${name}.asar`);
43
58
  }
44
59
  function getEntryVersion() {
45
- return import_electron.app.getVersion();
60
+ return import_electron.default.app.getVersion();
46
61
  }
47
62
  function getProductVersion(name) {
48
- return import_electron.app.isPackaged ? (0, import_node_fs.readFileSync)((0, import_node_path.join)(getProductAsarPath(name), "version"), "utf-8") : getEntryVersion();
63
+ return info.dev ? getEntryVersion() : (0, import_node_fs.readFileSync)((0, import_node_path.join)(getProductAsarPath(name), "version"), "utf-8");
49
64
  }
50
65
  function waitAppReady(duration = 1e3) {
51
66
  return new Promise((resolve2, reject) => {
52
67
  const timeout = setTimeout(() => {
53
68
  reject(new Error("app is not ready"));
54
69
  }, duration);
55
- import_electron.app.whenReady().then(() => {
70
+ import_electron.default.app.whenReady().then(() => {
56
71
  clearTimeout(timeout);
57
72
  resolve2();
58
73
  });
@@ -153,11 +168,11 @@ var DownloadError = class extends Error {
153
168
  };
154
169
 
155
170
  // src/updater/defaultFunctions.ts
156
- var import_electron2 = require("electron");
171
+ var import_electron2 = __toESM(require("electron"));
157
172
  var downloadJSONDefault = async (url, headers) => {
158
173
  await waitAppReady();
159
174
  return new Promise((resolve2, reject) => {
160
- const request = import_electron2.net.request({
175
+ const request = import_electron2.default.net.request({
161
176
  url,
162
177
  method: "GET",
163
178
  redirect: "follow"
@@ -191,7 +206,7 @@ var downloadBufferDefault = async (url, headers, total, onDownloading) => {
191
206
  await waitAppReady();
192
207
  let current = 0;
193
208
  return new Promise((resolve2, reject) => {
194
- const request = import_electron2.net.request({
209
+ const request = import_electron2.default.net.request({
195
210
  url,
196
211
  method: "GET",
197
212
  redirect: "follow"
@@ -406,7 +421,7 @@ function initApp(appOptions) {
406
421
  } = hooks || {};
407
422
  function handleError(msg) {
408
423
  onStartError?.(new Error(msg));
409
- import_electron3.app.quit();
424
+ import_electron3.default.app.quit();
410
425
  }
411
426
  async function startup(updater) {
412
427
  try {
@@ -416,7 +431,7 @@ function initApp(appOptions) {
416
431
  await beforeDoUpdate?.(asarPath, updateAsarPath);
417
432
  (0, import_node_fs3.renameSync)(updateAsarPath, asarPath);
418
433
  }
419
- const mainDir = import_electron3.app.isPackaged ? asarPath : electronDevDistPath;
434
+ const mainDir = import_electron3.default.app.isPackaged ? asarPath : electronDevDistPath;
420
435
  const entry = (0, import_node_path2.resolve)(__dirname, mainDir, mainPath);
421
436
  await beforeStart?.(entry);
422
437
  require(entry)(updater);
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  parseVersion,
9
9
  unzipFile,
10
10
  waitAppReady
11
- } from "./chunk-WM2PHOMB.mjs";
11
+ } from "./chunk-CR6HTU6P.mjs";
12
12
  import {
13
13
  isUpdateJSON
14
14
  } from "./chunk-2JVXVTC5.mjs";
@@ -19,7 +19,7 @@ import {
19
19
  // src/index.ts
20
20
  import { resolve } from "node:path";
21
21
  import { existsSync as existsSync2, renameSync } from "node:fs";
22
- import { app } from "electron";
22
+ import Electron2 from "electron";
23
23
 
24
24
  // src/updater/index.ts
25
25
  import { existsSync } from "node:fs";
@@ -51,11 +51,11 @@ var DownloadError = class extends Error {
51
51
  };
52
52
 
53
53
  // src/updater/defaultFunctions.ts
54
- import { net } from "electron";
54
+ import Electron from "electron";
55
55
  var downloadJSONDefault = async (url, headers) => {
56
56
  await waitAppReady();
57
57
  return new Promise((resolve2, reject) => {
58
- const request = net.request({
58
+ const request = Electron.net.request({
59
59
  url,
60
60
  method: "GET",
61
61
  redirect: "follow"
@@ -89,7 +89,7 @@ var downloadBufferDefault = async (url, headers, total, onDownloading) => {
89
89
  await waitAppReady();
90
90
  let current = 0;
91
91
  return new Promise((resolve2, reject) => {
92
- const request = net.request({
92
+ const request = Electron.net.request({
93
93
  url,
94
94
  method: "GET",
95
95
  redirect: "follow"
@@ -304,7 +304,7 @@ function initApp(appOptions) {
304
304
  } = hooks || {};
305
305
  function handleError(msg) {
306
306
  onStartError?.(new Error(msg));
307
- app.quit();
307
+ Electron2.app.quit();
308
308
  }
309
309
  async function startup(updater) {
310
310
  try {
@@ -314,7 +314,7 @@ function initApp(appOptions) {
314
314
  await beforeDoUpdate?.(asarPath, updateAsarPath);
315
315
  renameSync(updateAsarPath, asarPath);
316
316
  }
317
- const mainDir = app.isPackaged ? asarPath : electronDevDistPath;
317
+ const mainDir = Electron2.app.isPackaged ? asarPath : electronDevDistPath;
318
318
  const entry = resolve(__dirname, mainDir, mainPath);
319
319
  await beforeStart?.(entry);
320
320
  __require(entry)(updater);
package/dist/utils.d.mts CHANGED
@@ -1,3 +1,9 @@
1
+ type Info = {
2
+ dev: boolean;
3
+ platform: 'win' | 'mac' | 'linux';
4
+ appPath: string;
5
+ };
6
+ declare const info: Info;
1
7
  /**
2
8
  * get the application asar absolute path
3
9
  * @param name The name of the application
@@ -63,4 +69,4 @@ interface Version {
63
69
  }
64
70
  declare function parseVersion(version: string): Version;
65
71
 
66
- export { NoSuchNativeModuleError, Version, getEntryVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, getProductVersion, handleUnexpectedErrors, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
72
+ export { NoSuchNativeModuleError, Version, getEntryVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, getProductVersion, handleUnexpectedErrors, info, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ type Info = {
2
+ dev: boolean;
3
+ platform: 'win' | 'mac' | 'linux';
4
+ appPath: string;
5
+ };
6
+ declare const info: Info;
1
7
  /**
2
8
  * get the application asar absolute path
3
9
  * @param name The name of the application
@@ -63,4 +69,4 @@ interface Version {
63
69
  }
64
70
  declare function parseVersion(version: string): Version;
65
71
 
66
- export { NoSuchNativeModuleError, Version, getEntryVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, getProductVersion, handleUnexpectedErrors, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
72
+ export { NoSuchNativeModuleError, Version, getEntryVersion, getGithubFileCdnGroup, getGithubReleaseCdnGroup, getProductAsarPath, getProductVersion, handleUnexpectedErrors, info, parseGithubCdnURL, parseVersion, requireNative, restartApp, unzipFile, waitAppReady, zipFile };
package/dist/utils.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/utils.ts
@@ -27,6 +37,7 @@ __export(utils_exports, {
27
37
  getProductAsarPath: () => getProductAsarPath,
28
38
  getProductVersion: () => getProductVersion,
29
39
  handleUnexpectedErrors: () => handleUnexpectedErrors,
40
+ info: () => info,
30
41
  parseGithubCdnURL: () => parseGithubCdnURL,
31
42
  parseVersion: () => parseVersion,
32
43
  requireNative: () => requireNative,
@@ -39,15 +50,20 @@ module.exports = __toCommonJS(utils_exports);
39
50
  var import_node_fs = require("fs");
40
51
  var import_node_path = require("path");
41
52
  var import_node_zlib = require("zlib");
42
- var import_electron = require("electron");
53
+ var import_electron = __toESM(require("electron"));
54
+ var info = {
55
+ dev: !import_electron.default.app?.isPackaged,
56
+ platform: process.platform === "win32" ? "win" : process.platform === "darwin" ? "mac" : "linux",
57
+ appPath: import_electron.default.app?.getAppPath()
58
+ };
43
59
  function getProductAsarPath(name) {
44
- return import_electron.app.isPackaged ? (0, import_node_path.join)((0, import_node_path.dirname)(import_electron.app.getAppPath()), `${name}.asar`) : "dev.asar";
60
+ return info.dev ? "dev.asar" : (0, import_node_path.join)((0, import_node_path.dirname)(info.appPath), `${name}.asar`);
45
61
  }
46
62
  function getEntryVersion() {
47
- return import_electron.app.getVersion();
63
+ return import_electron.default.app.getVersion();
48
64
  }
49
65
  function getProductVersion(name) {
50
- return import_electron.app.isPackaged ? (0, import_node_fs.readFileSync)((0, import_node_path.join)(getProductAsarPath(name), "version"), "utf-8") : getEntryVersion();
66
+ return info.dev ? getEntryVersion() : (0, import_node_fs.readFileSync)((0, import_node_path.join)(getProductAsarPath(name), "version"), "utf-8");
51
67
  }
52
68
  var NoSuchNativeModuleError = class extends Error {
53
69
  moduleName;
@@ -57,7 +73,7 @@ var NoSuchNativeModuleError = class extends Error {
57
73
  }
58
74
  };
59
75
  function requireNative(packageName) {
60
- const path = import_electron.app.isPackaged ? (0, import_node_path.join)(import_electron.app.getAppPath(), "node_modules", packageName) : packageName;
76
+ const path = info.dev ? packageName : (0, import_node_path.join)(info.appPath, "node_modules", packageName);
61
77
  try {
62
78
  return require(path);
63
79
  } catch (error) {
@@ -101,15 +117,15 @@ function getGithubReleaseCdnGroup() {
101
117
  ];
102
118
  }
103
119
  function restartApp() {
104
- import_electron.app.relaunch();
105
- import_electron.app.quit();
120
+ import_electron.default.app.relaunch();
121
+ import_electron.default.app.quit();
106
122
  }
107
123
  function waitAppReady(duration = 1e3) {
108
124
  return new Promise((resolve, reject) => {
109
125
  const timeout = setTimeout(() => {
110
126
  reject(new Error("app is not ready"));
111
127
  }, duration);
112
- import_electron.app.whenReady().then(() => {
128
+ import_electron.default.app.whenReady().then(() => {
113
129
  clearTimeout(timeout);
114
130
  resolve();
115
131
  });
@@ -187,6 +203,7 @@ function parseVersion(version) {
187
203
  getProductAsarPath,
188
204
  getProductVersion,
189
205
  handleUnexpectedErrors,
206
+ info,
190
207
  parseGithubCdnURL,
191
208
  parseVersion,
192
209
  requireNative,
package/dist/utils.mjs CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  getProductAsarPath,
7
7
  getProductVersion,
8
8
  handleUnexpectedErrors,
9
+ info,
9
10
  parseGithubCdnURL,
10
11
  parseVersion,
11
12
  requireNative,
@@ -13,7 +14,7 @@ import {
13
14
  unzipFile,
14
15
  waitAppReady,
15
16
  zipFile
16
- } from "./chunk-WM2PHOMB.mjs";
17
+ } from "./chunk-CR6HTU6P.mjs";
17
18
  import "./chunk-ZFXKCRJC.mjs";
18
19
  export {
19
20
  NoSuchNativeModuleError,
@@ -23,6 +24,7 @@ export {
23
24
  getProductAsarPath,
24
25
  getProductVersion,
25
26
  handleUnexpectedErrors,
27
+ info,
26
28
  parseGithubCdnURL,
27
29
  parseVersion,
28
30
  requireNative,
package/dist/vite.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/vite.ts
@@ -28,7 +38,7 @@ var import_vite = require("vite");
28
38
  // src/build-plugins/build.ts
29
39
  var import_promises = require("fs/promises");
30
40
  var import_node_fs2 = require("fs");
31
- var import_asar = require("@electron/asar");
41
+ var import_asar = __toESM(require("@electron/asar"));
32
42
  var import_esbuild = require("esbuild");
33
43
 
34
44
  // src/crypto.ts
@@ -52,7 +62,12 @@ var signature = (buffer, privateKey, cert, version) => {
52
62
  var import_node_fs = require("fs");
53
63
  var import_node_path = require("path");
54
64
  var import_node_zlib = require("zlib");
55
- var import_electron = require("electron");
65
+ var import_electron = __toESM(require("electron"));
66
+ var info = {
67
+ dev: !import_electron.default.app?.isPackaged,
68
+ platform: process.platform === "win32" ? "win" : process.platform === "darwin" ? "mac" : "linux",
69
+ appPath: import_electron.default.app?.getAppPath()
70
+ };
56
71
  async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
57
72
  if (!(0, import_node_fs.existsSync)(filePath)) {
58
73
  throw new Error(`path to be zipped not exist: ${filePath}`);
@@ -109,7 +124,7 @@ async function buildAsar({
109
124
  }) {
110
125
  await (0, import_promises.rename)(rendererDistPath, `${electronDistPath}/renderer`);
111
126
  await (0, import_promises.writeFile)(`${electronDistPath}/version`, version);
112
- await (0, import_asar.createPackage)(electronDistPath, asarOutputPath);
127
+ await import_asar.default.createPackage(electronDistPath, asarOutputPath);
113
128
  await zipFile(asarOutputPath, gzipPath);
114
129
  }
115
130
  async function buildVersion({
package/dist/vite.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  parseVersion,
6
6
  zipFile
7
- } from "./chunk-WM2PHOMB.mjs";
7
+ } from "./chunk-CR6HTU6P.mjs";
8
8
  import {
9
9
  isUpdateJSON
10
10
  } from "./chunk-2JVXVTC5.mjs";
@@ -16,7 +16,7 @@ import { createLogger } from "vite";
16
16
  // src/build-plugins/build.ts
17
17
  import { readFile, rename, writeFile } from "node:fs/promises";
18
18
  import { existsSync } from "node:fs";
19
- import { createPackage } from "@electron/asar";
19
+ import Asar from "@electron/asar";
20
20
  import { build } from "esbuild";
21
21
  async function buildAsar({
22
22
  version,
@@ -27,7 +27,7 @@ async function buildAsar({
27
27
  }) {
28
28
  await rename(rendererDistPath, `${electronDistPath}/renderer`);
29
29
  await writeFile(`${electronDistPath}/version`, version);
30
- await createPackage(electronDistPath, asarOutputPath);
30
+ await Asar.createPackage(electronDistPath, asarOutputPath);
31
31
  await zipFile(asarOutputPath, gzipPath);
32
32
  }
33
33
  async function buildVersion({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "author": "subframe7536",
4
- "version": "0.8.2",
4
+ "version": "0.8.4",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "scripts": {
7
7
  "build": "tsup && node fix-module.js",