electron-incremental-update 1.3.0 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.js CHANGED
@@ -1,38 +1,62 @@
1
1
  import {
2
+ decrypt,
2
3
  disableHWAccForWin7,
4
+ encrypt,
5
+ getAppVersion,
6
+ getEntryVersion,
3
7
  getPathFromAppNameAsar,
4
- getPaths,
5
- getVersions,
8
+ getPathFromEntryAsar,
9
+ getPathFromPreload,
10
+ getPathFromPublic,
6
11
  handleUnexpectedErrors,
7
- is,
12
+ hashString,
13
+ isDev,
14
+ isLinux,
15
+ isLowerVersionDefault,
16
+ isMac,
8
17
  isUpdateJSON,
9
- loadNativeModuleFromEntry,
10
- parseGithubCdnURL,
18
+ isWin,
19
+ loadPage,
11
20
  parseVersion,
21
+ requireNative,
12
22
  restartApp,
13
23
  setAppUserModelId,
14
24
  setPortableAppDataPath,
25
+ signature,
15
26
  singleInstance,
16
27
  unzipFile,
28
+ verifySignatureDefault,
17
29
  waitAppReady,
18
30
  zipFile
19
- } from "./chunk-SBPTSLG7.js";
31
+ } from "./chunk-BG22XZAB.js";
20
32
  export {
33
+ decrypt,
21
34
  disableHWAccForWin7,
35
+ encrypt,
36
+ getAppVersion,
37
+ getEntryVersion,
22
38
  getPathFromAppNameAsar,
23
- getPaths,
24
- getVersions,
39
+ getPathFromEntryAsar,
40
+ getPathFromPreload,
41
+ getPathFromPublic,
25
42
  handleUnexpectedErrors,
26
- is,
43
+ hashString,
44
+ isDev,
45
+ isLinux,
46
+ isLowerVersionDefault,
47
+ isMac,
27
48
  isUpdateJSON,
28
- loadNativeModuleFromEntry,
29
- parseGithubCdnURL,
49
+ isWin,
50
+ loadPage,
30
51
  parseVersion,
52
+ requireNative,
31
53
  restartApp,
32
54
  setAppUserModelId,
33
55
  setPortableAppDataPath,
56
+ signature,
34
57
  singleInstance,
35
58
  unzipFile,
59
+ verifySignatureDefault,
36
60
  waitAppReady,
37
61
  zipFile
38
62
  };
@@ -1,9 +1,3 @@
1
- /**
2
- * parse Github CDN URL for accelerating the speed of downloading
3
- *
4
- * {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 some public CDN links}
5
- */
6
- declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, relativeFilePath: string): string;
7
1
  /**
8
2
  * handle all unhandled error
9
3
  * @param callback callback function
@@ -17,15 +11,22 @@ interface Version {
17
11
  stageVersion: number;
18
12
  }
19
13
  declare function parseVersion(version: string): Version;
14
+ declare function isLowerVersionDefault(oldVer: string, newVer: string): boolean;
15
+ /**
16
+ * update info json
17
+ */
20
18
  type UpdateInfo = {
21
19
  signature: string;
22
20
  minimumVersion: string;
23
21
  version: string;
24
22
  size: number;
25
23
  };
24
+ /**
25
+ * {@link UpdateInfo} with beta
26
+ */
26
27
  type UpdateJSON = UpdateInfo & {
27
28
  beta: UpdateInfo;
28
29
  };
29
30
  declare function isUpdateJSON(json: any): json is UpdateJSON;
30
31
 
31
- export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, parseVersion as b, handleUnexpectedErrors as h, isUpdateJSON as i, parseGithubCdnURL as p };
32
+ export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, isUpdateJSON as b, handleUnexpectedErrors as h, isLowerVersionDefault as i, parseVersion as p };
@@ -1,9 +1,3 @@
1
- /**
2
- * parse Github CDN URL for accelerating the speed of downloading
3
- *
4
- * {@link https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L34 some public CDN links}
5
- */
6
- declare function parseGithubCdnURL(originRepoURL: string, cdnPrefix: string, relativeFilePath: string): string;
7
1
  /**
8
2
  * handle all unhandled error
9
3
  * @param callback callback function
@@ -17,15 +11,22 @@ interface Version {
17
11
  stageVersion: number;
18
12
  }
19
13
  declare function parseVersion(version: string): Version;
14
+ declare function isLowerVersionDefault(oldVer: string, newVer: string): boolean;
15
+ /**
16
+ * update info json
17
+ */
20
18
  type UpdateInfo = {
21
19
  signature: string;
22
20
  minimumVersion: string;
23
21
  version: string;
24
22
  size: number;
25
23
  };
24
+ /**
25
+ * {@link UpdateInfo} with beta
26
+ */
26
27
  type UpdateJSON = UpdateInfo & {
27
28
  beta: UpdateInfo;
28
29
  };
29
30
  declare function isUpdateJSON(json: any): json is UpdateJSON;
30
31
 
31
- export { type UpdateInfo as U, type Version as V, type UpdateJSON as a, parseVersion as b, handleUnexpectedErrors as h, isUpdateJSON as i, parseGithubCdnURL as p };
32
+ export { type UpdateJSON as U, type Version as V, type UpdateInfo as a, isUpdateJSON as b, handleUnexpectedErrors as h, isLowerVersionDefault as i, parseVersion as p };
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/vite.ts
2
2
  import { basename as basename2, join as join2, resolve } from "node:path";
3
- import { cpSync, existsSync as existsSync4, rmSync as rmSync2 } from "node:fs";
3
+ import { cpSync, existsSync as existsSync4, rmSync } from "node:fs";
4
4
  import { mergeConfig as mergeConfig2, normalizePath as normalizePath2 } from "vite";
5
5
  import ElectronSimple from "vite-plugin-electron/simple";
6
6
  import { startup } from "vite-plugin-electron";
@@ -14,27 +14,7 @@ import Asar from "@electron/asar";
14
14
  import { build } from "esbuild";
15
15
  import { mergeConfig } from "vite";
16
16
 
17
- // src/crypto/utils.ts
18
- import { createHash } from "node:crypto";
19
- function hashString(data, length) {
20
- const hash = createHash("SHA256").update(data).digest("binary");
21
- return Buffer.from(hash).subarray(0, length);
22
- }
23
-
24
- // src/crypto/enc.ts
25
- import { createCipheriv, createPrivateKey, createSign } from "node:crypto";
26
- function encrypt(plainText, key, iv) {
27
- const cipher = createCipheriv("aes-256-cbc", key, iv);
28
- let encrypted = cipher.update(plainText, "utf8", "base64url");
29
- encrypted += cipher.final("base64url");
30
- return encrypted;
31
- }
32
- var signature = (buffer, privateKey, cert, version) => {
33
- const sig = createSign("RSA-SHA256").update(buffer).sign(createPrivateKey(privateKey), "base64");
34
- return encrypt(`${sig}%${version}`, hashString(cert, 32), hashString(buffer, 16));
35
- };
36
-
37
- // src/utils/pure.ts
17
+ // src/utils/version.ts
38
18
  function parseVersion(version) {
39
19
  const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-z0-9.-]+))?/i.exec(version);
40
20
  if (!match) {
@@ -64,8 +44,8 @@ function isUpdateJSON(json) {
64
44
  }
65
45
 
66
46
  // src/utils/zip.ts
67
- import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
68
- import { brotliCompress, brotliDecompress } from "node:zlib";
47
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
48
+ import { brotliCompress } from "node:zlib";
69
49
  async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
70
50
  if (!existsSync(filePath)) {
71
51
  throw new Error(`path to be zipped not exist: ${filePath}`);
@@ -77,99 +57,41 @@ async function zipFile(filePath, targetFilePath = `${filePath}.gz`) {
77
57
  reject(err);
78
58
  }
79
59
  writeFileSync(targetFilePath, buffer2);
80
- resolve2(null);
60
+ resolve2();
81
61
  });
82
62
  });
83
63
  }
84
64
 
85
- // src/build-plugins/log.ts
86
- import { createLogger } from "vite";
65
+ // src/utils/crypto/utils.ts
66
+ import { createHash } from "node:crypto";
67
+ function hashString(data, length) {
68
+ const hash = createHash("SHA256").update(data).digest("binary");
69
+ return Buffer.from(hash).subarray(0, length);
70
+ }
71
+
72
+ // src/utils/crypto/encrypt.ts
73
+ import { createCipheriv, createPrivateKey, createSign } from "node:crypto";
74
+ function encrypt(plainText, key, iv) {
75
+ const cipher = createCipheriv("aes-256-cbc", key, iv);
76
+ let encrypted = cipher.update(plainText, "utf8", "base64url");
77
+ encrypted += cipher.final("base64url");
78
+ return encrypted;
79
+ }
80
+ function signature(buffer, privateKey, cert, version) {
81
+ const sig = createSign("RSA-SHA256").update(buffer).sign(createPrivateKey(privateKey), "base64");
82
+ return encrypt(`${sig}%${version}`, hashString(cert, 32), hashString(buffer, 16));
83
+ }
87
84
 
88
85
  // src/build-plugins/constant.ts
86
+ import { createLogger } from "vite";
89
87
  var id = "electron-incremental-updater";
90
88
  var bytecodeId = `${id}-bytecode`;
91
- var loaderId = `${id}-loader`;
92
-
93
- // src/build-plugins/log.ts
94
89
  var log = createLogger("info", { prefix: `[${id}]` });
95
90
  var bytecodeLog = createLogger("info", { prefix: `[${bytecodeId}]` });
96
91
 
97
92
  // src/build-plugins/bytecode/code.ts
98
93
  var bytecodeGeneratorScript = "const vm = require('vm')\nconst v8 = require('v8')\nconst wrap = require('module').wrap\nv8.setFlagsFromString('--no-lazy')\nv8.setFlagsFromString('--no-flush-bytecode')\nlet code = ''\nprocess.stdin.setEncoding('utf-8')\nprocess.stdin.on('readable', () => {\n const data = process.stdin.read()\n if (data !== null) {\n code += data\n }\n})\nprocess.stdin.on('end', () => {\n try {\n if (typeof code !== 'string') {\n throw new Error('javascript code must be string.')\n }\n const script = new vm.Script(wrap(code), { produceCachedData: true })\n const bytecodeBuffer = script.createCachedData()\n process.stdout.write(bytecodeBuffer)\n } catch (error) {\n console.error(error)\n }\n})\n";
99
- var bytecodeModuleLoaderCode = [
100
- `"use strict";`,
101
- `const fs = require("fs");`,
102
- `const path = require("path");`,
103
- `const vm = require("vm");`,
104
- `const v8 = require("v8");`,
105
- `const Module = require("module");`,
106
- `v8.setFlagsFromString("--no-lazy");`,
107
- `v8.setFlagsFromString("--no-flush-bytecode");`,
108
- `const FLAG_HASH_OFFSET = 12;`,
109
- `const SOURCE_HASH_OFFSET = 8;`,
110
- `let dummyBytecode;`,
111
- `function setFlagHashHeader(bytecodeBuffer) {`,
112
- ` if (!dummyBytecode) {`,
113
- ` const script = new vm.Script("", {`,
114
- ` produceCachedData: true`,
115
- ` });`,
116
- ` dummyBytecode = script.createCachedData();`,
117
- ` }`,
118
- ` dummyBytecode.slice(FLAG_HASH_OFFSET, FLAG_HASH_OFFSET + 4).copy(bytecodeBuffer, FLAG_HASH_OFFSET);`,
119
- `};`,
120
- `function getSourceHashHeader(bytecodeBuffer) {`,
121
- ` return bytecodeBuffer.slice(SOURCE_HASH_OFFSET, SOURCE_HASH_OFFSET + 4);`,
122
- `};`,
123
- `function buffer2Number(buffer) {`,
124
- ` let ret = 0;`,
125
- ` ret |= buffer[3] << 24;`,
126
- ` ret |= buffer[2] << 16;`,
127
- ` ret |= buffer[1] << 8;`,
128
- ` ret |= buffer[0];`,
129
- ` return ret;`,
130
- `};`,
131
- `Module._extensions[".jsc"] = Module._extensions[".cjsc"] = function (module, filename) {`,
132
- ` const bytecodeBuffer = fs.readFileSync(filename);`,
133
- ` if (!Buffer.isBuffer(bytecodeBuffer)) {`,
134
- ` throw new Error("BytecodeBuffer must be a buffer object.");`,
135
- ` }`,
136
- ` setFlagHashHeader(bytecodeBuffer);`,
137
- ` const length = buffer2Number(getSourceHashHeader(bytecodeBuffer));`,
138
- ` let dummyCode = "";`,
139
- ` if (length > 1) {`,
140
- ` dummyCode = "\\"" + "\\u200b".repeat(length - 2) + "\\"";`,
141
- ` }`,
142
- ` const script = new vm.Script(dummyCode, {`,
143
- ` filename: filename,`,
144
- ` lineOffset: 0,`,
145
- ` displayErrors: true,`,
146
- ` cachedData: bytecodeBuffer`,
147
- ` });`,
148
- ` if (script.cachedDataRejected) {`,
149
- ` throw new Error("Invalid or incompatible cached data (cachedDataRejected)");`,
150
- ` }`,
151
- ` const require = function (id) {`,
152
- ` return module.require(id);`,
153
- ` };`,
154
- ` require.resolve = function (request, options) {`,
155
- ` return Module._resolveFilename(request, module, false, options);`,
156
- ` };`,
157
- ` if (process.mainModule) {`,
158
- ` require.main = process.mainModule;`,
159
- ` }`,
160
- ` require.extensions = Module._extensions;`,
161
- ` require.cache = Module._cache;`,
162
- ` const compiledWrapper = script.runInThisContext({`,
163
- ` filename: filename,`,
164
- ` lineOffset: 0,`,
165
- ` columnOffset: 0,`,
166
- ` displayErrors: true`,
167
- ` });`,
168
- ` const dirname = path.dirname(filename);`,
169
- ` const args = [module.exports, require, module, filename, dirname, process, global];`,
170
- ` return compiledWrapper.apply(module.exports, args);`,
171
- `};`
172
- ].join("\n");
94
+ var bytecodeModuleLoaderCode = '"use strict";\nconst fs = require("fs");\nconst path = require("path");\nconst vm = require("vm");\nconst v8 = require("v8");\nconst Module = require("module");\nv8.setFlagsFromString("--no-lazy");\nv8.setFlagsFromString("--no-flush-bytecode");\nconst FLAG_HASH_OFFSET = 12;\nconst SOURCE_HASH_OFFSET = 8;\nlet dummyBytecode;\nfunction setFlagHashHeader(bytecodeBuffer) {\n if (!dummyBytecode) {\n const script = new vm.Script("", {\n produceCachedData: true\n });\n dummyBytecode = script.createCachedData();\n }\n dummyBytecode.slice(FLAG_HASH_OFFSET, FLAG_HASH_OFFSET + 4).copy(bytecodeBuffer, FLAG_HASH_OFFSET);\n};\nfunction getSourceHashHeader(bytecodeBuffer) {\n return bytecodeBuffer.slice(SOURCE_HASH_OFFSET, SOURCE_HASH_OFFSET + 4);\n};\nfunction buffer2Number(buffer) {\n let ret = 0;\n ret |= buffer[3] << 24;\n ret |= buffer[2] << 16;\n ret |= buffer[1] << 8;\n ret |= buffer[0];\n return ret;\n};\nModule._extensions[".jsc"] = Module._extensions[".cjsc"] = function (module, filename) {\n const bytecodeBuffer = fs.readFileSync(filename);\n if (!Buffer.isBuffer(bytecodeBuffer)) {\n throw new Error("BytecodeBuffer must be a buffer object.");\n }\n setFlagHashHeader(bytecodeBuffer);\n const length = buffer2Number(getSourceHashHeader(bytecodeBuffer));\n let dummyCode = "";\n if (length > 1) {\n dummyCode = "\\"" + "\\u200b".repeat(length - 2) + "\\"";\n }\n const script = new vm.Script(dummyCode, {\n filename: filename,\n lineOffset: 0,\n displayErrors: true,\n cachedData: bytecodeBuffer\n });\n if (script.cachedDataRejected) {\n throw new Error("Invalid or incompatible cached data (cachedDataRejected)");\n }\n const require = function (id) {\n return module.require(id);\n };\n require.resolve = function (request, options) {\n return Module._resolveFilename(request, module, false, options);\n };\n if (process.mainModule) {\n require.main = process.mainModule;\n }\n require.extensions = Module._extensions;\n require.cache = Module._cache;\n const compiledWrapper = script.runInThisContext({\n filename: filename,\n lineOffset: 0,\n columnOffset: 0,\n displayErrors: true\n });\n const dirname = path.dirname(filename);\n const args = [module.exports, require, module, filename, dirname, process, global];\n return compiledWrapper.apply(module.exports, args);\n};\n';
173
95
 
174
96
  // src/build-plugins/bytecode/utils.ts
175
97
  import path from "node:path";
@@ -313,7 +235,7 @@ async function buildVersion({
313
235
  } else {
314
236
  log.warn("old version json is invalid, ignore it");
315
237
  }
316
- } catch (error) {
238
+ } catch {
317
239
  }
318
240
  }
319
241
  const buffer = readFileSync2(gzipPath);
@@ -346,7 +268,7 @@ async function buildEntry({
346
268
  entryOutputDirPath,
347
269
  nativeModuleEntryMap,
348
270
  overrideEsbuildOptions
349
- }, cert, protectedStrings) {
271
+ }, define, protectedStrings) {
350
272
  const option = mergeConfig(
351
273
  {
352
274
  entryPoints: {
@@ -365,9 +287,7 @@ async function buildEntry({
365
287
  loader: {
366
288
  ".node": "empty"
367
289
  },
368
- define: {
369
- __SIGNATURE_CERT__: JSON.stringify(cert)
370
- }
290
+ define
371
291
  },
372
292
  overrideEsbuildOptions ?? {}
373
293
  );
@@ -383,7 +303,7 @@ async function buildEntry({
383
303
  if (isEntry) {
384
304
  code = code.replace(
385
305
  /(`-----BEGIN CERTIFICATE-----[\s\S]*-----END CERTIFICATE-----\n`)/,
386
- (_, cert2) => `"${cert2.slice(1, -1).replace(/\n/g, "\\n")}"`
306
+ (_, cert) => `"${cert.slice(1, -1).replace(/\n/g, "\\n")}"`
387
307
  );
388
308
  }
389
309
  const transformedCode = convertString(
@@ -437,7 +357,9 @@ function parseKeys({
437
357
  days
438
358
  }) {
439
359
  const keysDir = dirname(privateKeyPath);
440
- !existsSync3(keysDir) && mkdirSync(keysDir);
360
+ if (!existsSync3(keysDir)) {
361
+ mkdirSync(keysDir);
362
+ }
441
363
  if (!existsSync3(privateKeyPath) || !existsSync3(certPath)) {
442
364
  log.warn("no key pair found, generate new key pair");
443
365
  generateKeyPair(keyLength, parseSubjects(subject), days, privateKeyPath, certPath);
@@ -676,7 +598,33 @@ ${bytecodeLoaderBlock}`) : _code;
676
598
 
677
599
  // src/vite.ts
678
600
  function debugStartup(args) {
679
- process.env.VSCODE_DEBUG ? console.log("[startup] Electron App") : args.startup();
601
+ if (process.env.VSCODE_DEBUG) {
602
+ console.log("[startup] Electron App");
603
+ } else {
604
+ args.startup();
605
+ }
606
+ }
607
+ function getMainFilePath(options) {
608
+ let mainFilePath;
609
+ if (typeof options === "string") {
610
+ mainFilePath = basename2(options);
611
+ } else if (Array.isArray(options)) {
612
+ mainFilePath = basename2(options[0]);
613
+ } else {
614
+ const name = options?.index ?? options?.main;
615
+ if (!name) {
616
+ throw new Error(`\`options.main.files\` (${options}) must have "index" or "main" key, like \`{ index: "..." }\``);
617
+ }
618
+ mainFilePath = options?.index ? "index.js" : "main.js";
619
+ }
620
+ return mainFilePath.replace(/\.[cm]?ts$/, ".js");
621
+ }
622
+ function parseVersionPath(versionPath) {
623
+ versionPath = normalizePath2(versionPath);
624
+ if (!versionPath.startsWith("./")) {
625
+ versionPath = "./" + versionPath;
626
+ }
627
+ return new URL(versionPath, "file://").pathname.slice(1);
680
628
  }
681
629
  async function electronWithUpdater(options) {
682
630
  let {
@@ -693,11 +641,11 @@ async function electronWithUpdater(options) {
693
641
  } = options;
694
642
  if (!pkg) {
695
643
  log.error(`package.json not found`, { timestamp: true });
696
- return null;
644
+ return void 0;
697
645
  }
698
646
  if (!pkg.version || !pkg.name || !pkg.main) {
699
647
  log.error(`package.json not valid`, { timestamp: true });
700
- return null;
648
+ return void 0;
701
649
  }
702
650
  const _options = parseOptions(pkg, sourcemap, minify, updater);
703
651
  const bytecodeOptions = typeof bytecode === "object" ? bytecode : bytecode === true ? { protectedStrings: [] } : void 0;
@@ -705,9 +653,9 @@ async function electronWithUpdater(options) {
705
653
  minify = false;
706
654
  }
707
655
  try {
708
- rmSync2(_options.buildAsarOption.electronDistPath, { recursive: true, force: true });
709
- rmSync2(_options.buildEntryOption.entryOutputDirPath, { recursive: true, force: true });
710
- } catch (ignore) {
656
+ rmSync(_options.buildAsarOption.electronDistPath, { recursive: true, force: true });
657
+ rmSync(_options.buildEntryOption.entryOutputDirPath, { recursive: true, force: true });
658
+ } catch {
711
659
  }
712
660
  log.info(`remove old files`, { timestamp: true });
713
661
  const { buildAsarOption, buildEntryOption, buildVersionOption, postBuild, cert } = _options;
@@ -717,8 +665,21 @@ async function electronWithUpdater(options) {
717
665
  if (resolve(normalizePath2(pkg.main)) !== resolve(_appPath)) {
718
666
  throw new Error(`wrong "main" field in package.json: "${pkg.main}", it should be "${_appPath}"`);
719
667
  }
668
+ const define = {
669
+ __EIU_ELECTRON_DIST_PATH__: JSON.stringify(buildAsarOption.electronDistPath),
670
+ __EIU_ENTRY_DIST_PATH__: JSON.stringify(buildEntryOption.entryOutputDirPath),
671
+ __EIU_IS_DEV__: JSON.stringify(!isBuild),
672
+ __EIU_MAIN_DEV_DIR__: JSON.stringify(buildAsarOption.electronDistPath),
673
+ __EIU_MAIN_FILE__: JSON.stringify(getMainFilePath(_main.files)),
674
+ __EIU_SIGNATURE_CERT__: JSON.stringify(cert),
675
+ __EUI_VERSION_PATH__: JSON.stringify(parseVersionPath(buildVersionOption.versionPath))
676
+ };
720
677
  const _buildEntry = async () => {
721
- await buildEntry(buildEntryOption, cert, isBuild ? bytecodeOptions?.protectedStrings : void 0);
678
+ await buildEntry(
679
+ buildEntryOption,
680
+ define,
681
+ isBuild ? bytecodeOptions?.protectedStrings : void 0
682
+ );
722
683
  log.info(`vite build entry to '${entryOutputDirPath}'`, { timestamp: true });
723
684
  };
724
685
  const _postBuild = postBuild ? async () => await postBuild({
@@ -741,10 +702,6 @@ async function electronWithUpdater(options) {
741
702
  };
742
703
  let isInit = false;
743
704
  const rollupOptions = {
744
- // external: [
745
- // /^node:/,
746
- // ...Object.keys('dependencies' in pkg ? pkg.dependencies as object : {}),
747
- // ],
748
705
  external: (src) => src.startsWith("node:") || Object.keys("dependencies" in pkg ? pkg.dependencies : {}).includes(src)
749
706
  };
750
707
  const electronPluginOptions = {
@@ -756,7 +713,11 @@ async function electronWithUpdater(options) {
756
713
  await _buildEntry();
757
714
  await _postBuild();
758
715
  }
759
- _main.onstart ? _main.onstart(args) : args.startup();
716
+ if (_main.onstart) {
717
+ _main.onstart(args);
718
+ } else {
719
+ args.startup();
720
+ }
760
721
  },
761
722
  vite: mergeConfig2(
762
723
  {
@@ -769,7 +730,8 @@ async function electronWithUpdater(options) {
769
730
  minify,
770
731
  outDir: `${buildAsarOption.electronDistPath}/main`,
771
732
  rollupOptions
772
- }
733
+ },
734
+ define
773
735
  },
774
736
  _main.vite ?? {}
775
737
  )
@@ -802,23 +764,26 @@ async function electronWithUpdater(options) {
802
764
  minify,
803
765
  outDir: `${buildAsarOption.electronDistPath}/preload`,
804
766
  rollupOptions
805
- }
767
+ },
768
+ define
806
769
  },
807
770
  _preload.vite ?? {}
808
771
  )
809
772
  }
810
773
  };
811
- logParsedOptions && log.info(
812
- JSON.stringify(
813
- {
814
- ...electronPluginOptions,
815
- updater: { buildAsarOption, buildEntryOption, buildVersionOption }
816
- },
817
- (key, value) => (key === "privateKey" || key === "cert") && !(typeof logParsedOptions === "object" && logParsedOptions.showKeys === true) ? "***" : value,
818
- 2
819
- ),
820
- { timestamp: true }
821
- );
774
+ if (logParsedOptions) {
775
+ log.info(
776
+ JSON.stringify(
777
+ {
778
+ ...electronPluginOptions,
779
+ updater: { buildAsarOption, buildEntryOption, buildVersionOption }
780
+ },
781
+ (key, value) => (key === "privateKey" || key === "cert") && !(typeof logParsedOptions === "object" && logParsedOptions.showKeys === true) ? "***" : value,
782
+ 2
783
+ ),
784
+ { timestamp: true }
785
+ );
786
+ }
822
787
  let extraHmrPlugin;
823
788
  if (nativeModuleEntryMap) {
824
789
  const files = [...Object.values(nativeModuleEntryMap), appEntryPath].map((file) => resolve(normalizePath2(file)));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "1.3.0",
4
+ "version": "2.0.0-beta.2",
5
5
  "description": "electron incremental update tools, powered by vite",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",
@@ -23,12 +23,18 @@
23
23
  "./utils": {
24
24
  "import": "./dist/utils.js",
25
25
  "require": "./dist/utils.cjs"
26
+ },
27
+ "./provider": {
28
+ "import": "./dist/provider.js",
29
+ "require": "./dist/provider.cjs"
26
30
  }
27
31
  },
28
32
  "main": "dist/index.cjs",
29
33
  "module": "dist/index.js",
30
34
  "files": [
31
35
  "dist",
36
+ "provider.d.ts",
37
+ "provider.js",
32
38
  "utils.d.ts",
33
39
  "utils.js",
34
40
  "vite.d.ts",
@@ -59,17 +65,17 @@
59
65
  "selfsigned": "^2.4.1"
60
66
  },
61
67
  "devDependencies": {
62
- "@subframe7536/eslint-config": "^0.6.6",
68
+ "@subframe7536/eslint-config": "^0.7.2",
63
69
  "@types/babel__core": "^7.20.5",
64
- "@types/node": "^20.14.7",
70
+ "@types/node": "^20.14.11",
65
71
  "bumpp": "^9.4.1",
66
72
  "electron": "28.2.10",
67
- "eslint": "^9.5.0",
73
+ "eslint": "^9.7.0",
68
74
  "esno": "^4.7.0",
69
75
  "tsup": "^8.1.0",
70
- "typescript": "^5.5.2",
71
- "vite": "^5.3.1",
76
+ "typescript": "^5.5.3",
77
+ "vite": "^5.3.4",
72
78
  "vite-plugin-electron": "^0.28.7",
73
- "vitest": "^1.6.0"
79
+ "vitest": "^2.0.3"
74
80
  }
75
81
  }
package/provider.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/provider'
package/provider.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/provider.cjs')