electron-incremental-update 2.2.5 → 2.3.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/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { b as aesDecrypt, a as aesEncrypt, j as defaultDownloadAsar, f as defaultDownloadJSON, i as defaultDownloadUpdateJSON, d as defaultSignature, l as defaultUnzipFile, c as defaultVerifySignature, k as defaultZipFile, e as downloadUtil, g as getHeader, h as hashBuffer } from './zip-CDmogV-s.js';
1
+ export { b as aesDecrypt, a as aesEncrypt, j as defaultDownloadAsar, f as defaultDownloadText, i as defaultDownloadUpdateJSON, d as defaultSignature, l as defaultUnzipFile, c as defaultVerifySignature, k as defaultZipFile, e as downloadUtil, g as getHeader, h as hashBuffer, r as resolveJson } from './zip-CnSv_Njj.js';
2
2
  import { BrowserWindow } from 'electron';
3
- export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, c as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './types-1T_tRG8a.js';
3
+ export { U as UpdateInfo, a as UpdateJSON, V as Version, d as defaultIsLowerVersion, c as defaultVersionJsonGenerator, i as isUpdateJSON, p as parseVersion } from './types-CU7GyVez.js';
4
4
  import '@subframe7536/type-utils';
5
5
  import 'node:url';
6
6
 
package/dist/utils.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { beautifyDevTools, disableHWAccForWin7, getAppVersion, getEntryVersion, getPathFromAppNameAsar, getPathFromEntryAsar, getPathFromMain, getPathFromPreload, getPathFromPublic, handleUnexpectedErrors, importNative, isDev, isLinux, isMac, isWin, loadPage, reloadOnPreloadScriptChanged, requireNative, restartApp, setAppUserModelId, setPortableAppDataPath, singleInstance } from './chunk-QKKPETVJ.js';
2
- export { aesDecrypt, aesEncrypt, defaultDownloadAsar, defaultDownloadJSON, defaultDownloadUpdateJSON, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, downloadUtil, getHeader, hashBuffer } from './chunk-KLUIYBS4.js';
2
+ export { aesDecrypt, aesEncrypt, defaultDownloadAsar, defaultDownloadText, defaultDownloadUpdateJSON, defaultSignature, defaultUnzipFile, defaultVerifySignature, defaultZipFile, downloadUtil, getHeader, hashBuffer, resolveJson } from './chunk-QPAKJHVM.js';
3
3
  export { defaultIsLowerVersion, defaultVersionJsonGenerator, isUpdateJSON, parseVersion } from './chunk-AAAM44NW.js';
package/dist/vite.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import { Promisable } from '@subframe7536/type-utils';
1
2
  import { InlineConfig, PluginOption } from 'vite';
2
3
  import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
3
- import { Promisable } from '@subframe7536/type-utils';
4
4
  export { isCI } from 'ci-info';
5
5
  export { getPackageInfo, getPackageInfoSync, loadPackageJSON, resolveModule } from 'local-pkg';
6
6
 
@@ -90,7 +90,7 @@ interface BuildEntryOption {
90
90
  */
91
91
  appEntryPath?: string;
92
92
  /**
93
- * Esbuild path map of native modules in entry directory
93
+ * Vite input options of native modules in entry directory
94
94
  *
95
95
  * @default {}
96
96
  * @example
@@ -288,14 +288,14 @@ declare function convertLiteral(code: string, sourcemap?: boolean, offset?: numb
288
288
  map?: any;
289
289
  };
290
290
 
291
- type MakeRequired<T, K extends keyof T> = Exclude<T, undefined> & {
291
+ type MakeRequired<T, K extends keyof T> = NonNullable<T> & {
292
292
  [P in K]-?: T[P];
293
293
  };
294
294
  type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> & {
295
295
  [P in NewKey]: T[Key];
296
296
  };
297
297
  type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
298
- type StartupFn = Exclude<Exclude<ElectronSimpleOptions['preload'], undefined>['onstart'], undefined>;
298
+ type StartupFn = NonNullable<NonNullable<ElectronSimpleOptions['preload']>['onstart']>;
299
299
  /**
300
300
  * Startup function for debug (see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template})
301
301
  * @example
package/dist/vite.js CHANGED
@@ -88,8 +88,8 @@ async function buildEntry({
88
88
  },
89
89
  vite: mergeConfig({
90
90
  plugins: [
91
- isESM && await import('./esm-4S4XCVEW.js').then((m) => m.esm()),
92
- bytecodeOptions && await import('./bytecode-R2B4KTMV.js').then((m) => m.bytecodePlugin("main", bytecodeOptions))
91
+ isESM && import('./esm-4S4XCVEW.js').then((m) => m.esm()),
92
+ bytecodeOptions && import('./bytecode-7J2ZQDDO.js').then((m) => m.bytecodePlugin("main", bytecodeOptions))
93
93
  ],
94
94
  build: {
95
95
  sourcemap,
@@ -226,7 +226,7 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
226
226
  return false;
227
227
  }
228
228
  if (!external) {
229
- return undefined;
229
+ return void 0;
230
230
  }
231
231
  if (typeof external === "string") {
232
232
  return source === external;
@@ -255,6 +255,7 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
255
255
  };
256
256
  return { buildAsarOption, buildEntryOption, buildVersionOption, postBuild, cert };
257
257
  }
258
+ var vite_default = electronWithUpdater;
258
259
  var debugStartup = (args) => {
259
260
  if (process.env.VSCODE_DEBUG) {
260
261
  console.log("[startup] Electron App");
@@ -309,16 +310,16 @@ async function electronWithUpdater(options) {
309
310
  } = options;
310
311
  if (!pkg || !pkg.version || !pkg.name || !pkg.main) {
311
312
  log.error("package.json not found or invalid", { timestamp: true });
312
- return undefined;
313
+ return void 0;
313
314
  }
314
315
  const isESM = pkg.type === "module";
315
- let bytecodeOptions = typeof bytecode === "object" ? bytecode : bytecode === true ? { enable: true } : undefined;
316
+ let bytecodeOptions = typeof bytecode === "object" ? bytecode : bytecode === true ? { enable: true } : void 0;
316
317
  if (isESM && bytecodeOptions?.enable) {
317
318
  (await import('./constant-ME27JB5D.js')).bytecodeLog.warn(
318
319
  '`bytecodePlugin` does not support ES module, please remove "type": "module" in package.json',
319
320
  { timestamp: true }
320
321
  );
321
- bytecodeOptions = undefined;
322
+ bytecodeOptions = void 0;
322
323
  }
323
324
  const {
324
325
  buildAsarOption,
@@ -349,7 +350,7 @@ async function electronWithUpdater(options) {
349
350
  __EIU_SIGNATURE_CERT__: JSON.stringify(cert),
350
351
  __EIU_VERSION_PATH__: JSON.stringify(parseVersionPath(normalizePath(buildVersionOption.versionPath)))
351
352
  };
352
- const _buildEntry = async () => {
353
+ async function _buildEntry() {
353
354
  await buildEntry(
354
355
  buildEntryOption,
355
356
  isESM,
@@ -357,38 +358,39 @@ async function electronWithUpdater(options) {
357
358
  bytecodeOptions
358
359
  );
359
360
  log.info(`Build entry to '${entryOutputDirPath}'`, { timestamp: true });
360
- };
361
- const _postBuild = postBuild ? async () => await postBuild({
362
- getPathFromEntryOutputDir(...paths) {
363
- return path3.join(entryOutputDirPath, ...paths);
364
- },
365
- copyToEntryOutputDir({ from, to, skipIfExist = true }) {
366
- if (!fs2.existsSync(from)) {
367
- log.warn(`${from} not found`, { timestamp: true });
368
- return;
369
- }
370
- const target = path3.join(entryOutputDirPath, to ?? path3.basename(from));
371
- copyAndSkipIfExist(from, target, skipIfExist);
372
- },
373
- copyModules({ modules, skipIfExist = true }) {
374
- const nodeModulesPath = path3.join(entryOutputDirPath, "node_modules");
375
- for (const m of modules) {
376
- const { rootPath } = getPackageInfoSync(m) || {};
377
- if (!rootPath) {
378
- log.warn(`Package '${m}' not found`, { timestamp: true });
379
- continue;
361
+ }
362
+ async function _postBuild() {
363
+ return await postBuild?.({
364
+ getPathFromEntryOutputDir(...paths) {
365
+ return path3.join(entryOutputDirPath, ...paths);
366
+ },
367
+ copyToEntryOutputDir({ from, to, skipIfExist = true }) {
368
+ if (!fs2.existsSync(from)) {
369
+ log.warn(`${from} not found`, { timestamp: true });
370
+ return;
371
+ }
372
+ const target = path3.join(entryOutputDirPath, to ?? path3.basename(from));
373
+ copyAndSkipIfExist(from, target, skipIfExist);
374
+ },
375
+ copyModules({ modules, skipIfExist = true }) {
376
+ const nodeModulesPath = path3.join(entryOutputDirPath, "node_modules");
377
+ for (const m of modules) {
378
+ const { rootPath } = getPackageInfoSync(m) || {};
379
+ if (!rootPath) {
380
+ log.warn(`Package '${m}' not found`, { timestamp: true });
381
+ continue;
382
+ }
383
+ copyAndSkipIfExist(rootPath, path3.join(nodeModulesPath, m), skipIfExist);
380
384
  }
381
- copyAndSkipIfExist(rootPath, path3.join(nodeModulesPath, m), skipIfExist);
382
385
  }
383
- }
384
- }) : async () => {
385
- };
386
+ });
387
+ }
386
388
  let isInit = false;
387
389
  const rollupOptions = {
388
390
  external: (src) => src.startsWith("node:") || Object.keys("dependencies" in pkg ? pkg.dependencies : {}).includes(src) || src === "original-fs",
389
391
  treeshake: true
390
392
  };
391
- const esmShimPlugin = isESM ? (await import('./esm-4S4XCVEW.js')).esm() : undefined;
393
+ const esmShimPlugin = isESM ? import('./esm-4S4XCVEW.js').then((m) => m.esm()) : void 0;
392
394
  const electronPluginOptions = {
393
395
  main: {
394
396
  entry: _main.files,
@@ -407,8 +409,8 @@ async function electronWithUpdater(options) {
407
409
  vite: mergeConfig(
408
410
  {
409
411
  plugins: [
410
- !isBuild && useNotBundle ? notBundle() : undefined,
411
- bytecodeOptions && await import('./bytecode-R2B4KTMV.js').then((m) => m.bytecodePlugin("main", bytecodeOptions)),
412
+ !isBuild && useNotBundle ? notBundle() : void 0,
413
+ bytecodeOptions && import('./bytecode-7J2ZQDDO.js').then((m) => m.bytecodePlugin("main", bytecodeOptions)),
412
414
  esmShimPlugin
413
415
  ],
414
416
  build: {
@@ -428,7 +430,7 @@ async function electronWithUpdater(options) {
428
430
  vite: mergeConfig(
429
431
  {
430
432
  plugins: [
431
- bytecodeOptions && (await import('./bytecode-R2B4KTMV.js')).bytecodePlugin("preload", bytecodeOptions),
433
+ bytecodeOptions && import('./bytecode-7J2ZQDDO.js').then((m) => m.bytecodePlugin("preload", bytecodeOptions)),
432
434
  esmShimPlugin,
433
435
  {
434
436
  name: `${id}-build`,
@@ -449,7 +451,7 @@ async function electronWithUpdater(options) {
449
451
  }
450
452
  ],
451
453
  build: {
452
- sourcemap: sourcemap ? "inline" : undefined,
454
+ sourcemap: sourcemap ? "inline" : void 0,
453
455
  minify,
454
456
  outDir: `${buildAsarOption.electronDistPath}/preload`,
455
457
  rollupOptions
@@ -484,7 +486,7 @@ async function electronWithUpdater(options) {
484
486
  apply() {
485
487
  return !isBuild;
486
488
  },
487
- configureServer: (server) => {
489
+ configureServer(server) {
488
490
  server.watcher.add(files).on(
489
491
  "change",
490
492
  (p) => files.includes(p) && _buildEntry().then(async () => {
@@ -498,6 +500,5 @@ async function electronWithUpdater(options) {
498
500
  }
499
501
  return [ElectronSimple(electronPluginOptions), extraHmrPlugin];
500
502
  }
501
- var vite_default = electronWithUpdater;
502
503
 
503
504
  export { debugStartup, vite_default as default, electronWithUpdater, fixWinCharEncoding };
@@ -1,5 +1,5 @@
1
+ import { a as UpdateJSON, D as DownloadingInfo } from './types-CU7GyVez.cjs';
1
2
  import { Arrayable } from '@subframe7536/type-utils';
2
- import { a as UpdateJSON, D as DownloadingInfo } from './types-1T_tRG8a.cjs';
3
3
  import { IncomingMessage } from 'electron';
4
4
 
5
5
  declare function hashBuffer(data: string | Buffer, length: number): Buffer;
@@ -31,6 +31,7 @@ declare function defaultVerifySignature(buffer: Buffer, version: string, signatu
31
31
  declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
32
32
  declare function downloadUtil<T>(url: string, headers: Record<string, any>, onResponse: (req: Electron.ClientRequest, resp: IncomingMessage, resolve: (data: T) => void, reject: (e: any) => void) => void): Promise<T>;
33
33
  type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
34
+ declare const resolveJson: ResolveDataFn;
34
35
  /**
35
36
  * Default function to download json and parse to UpdateJson
36
37
  * @param url target url
@@ -38,7 +39,7 @@ type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: an
38
39
  * @param signal abort signal
39
40
  * @param resolveData on resolve
40
41
  */
41
- declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
42
+ declare function defaultDownloadText<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData: ResolveDataFn): Promise<T>;
42
43
  /**
43
44
  * Default function to download json and parse to UpdateJson
44
45
  * @param url target url
@@ -67,4 +68,4 @@ declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
67
68
  */
68
69
  declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
69
70
 
70
- export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, downloadUtil as e, defaultDownloadJSON as f, getHeader as g, hashBuffer as h, defaultDownloadUpdateJSON as i, defaultDownloadAsar as j, defaultZipFile as k, defaultUnzipFile as l };
71
+ export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, downloadUtil as e, defaultDownloadText as f, getHeader as g, hashBuffer as h, defaultDownloadUpdateJSON as i, defaultDownloadAsar as j, defaultZipFile as k, defaultUnzipFile as l, resolveJson as r };
@@ -1,5 +1,5 @@
1
+ import { a as UpdateJSON, D as DownloadingInfo } from './types-CU7GyVez.js';
1
2
  import { Arrayable } from '@subframe7536/type-utils';
2
- import { a as UpdateJSON, D as DownloadingInfo } from './types-1T_tRG8a.js';
3
3
  import { IncomingMessage } from 'electron';
4
4
 
5
5
  declare function hashBuffer(data: string | Buffer, length: number): Buffer;
@@ -31,6 +31,7 @@ declare function defaultVerifySignature(buffer: Buffer, version: string, signatu
31
31
  declare function getHeader(headers: Record<string, Arrayable<string>>, key: any): any;
32
32
  declare function downloadUtil<T>(url: string, headers: Record<string, any>, onResponse: (req: Electron.ClientRequest, resp: IncomingMessage, resolve: (data: T) => void, reject: (e: any) => void) => void): Promise<T>;
33
33
  type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: any) => void) => void;
34
+ declare const resolveJson: ResolveDataFn;
34
35
  /**
35
36
  * Default function to download json and parse to UpdateJson
36
37
  * @param url target url
@@ -38,7 +39,7 @@ type ResolveDataFn = (data: string, resolve: (data: any) => void, reject: (e: an
38
39
  * @param signal abort signal
39
40
  * @param resolveData on resolve
40
41
  */
41
- declare function defaultDownloadJSON<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData?: ResolveDataFn): Promise<T>;
42
+ declare function defaultDownloadText<T>(url: string, headers: Record<string, any>, signal: AbortSignal, resolveData: ResolveDataFn): Promise<T>;
42
43
  /**
43
44
  * Default function to download json and parse to UpdateJson
44
45
  * @param url target url
@@ -67,4 +68,4 @@ declare function defaultZipFile(buffer: Buffer): Promise<Buffer>;
67
68
  */
68
69
  declare function defaultUnzipFile(buffer: Buffer): Promise<Buffer>;
69
70
 
70
- export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, downloadUtil as e, defaultDownloadJSON as f, getHeader as g, hashBuffer as h, defaultDownloadUpdateJSON as i, defaultDownloadAsar as j, defaultZipFile as k, defaultUnzipFile as l };
71
+ export { aesEncrypt as a, aesDecrypt as b, defaultVerifySignature as c, defaultSignature as d, downloadUtil as e, defaultDownloadText as f, getHeader as g, hashBuffer as h, defaultDownloadUpdateJSON as i, defaultDownloadAsar as j, defaultZipFile as k, defaultUnzipFile as l, resolveJson as r };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "2.2.5",
4
+ "version": "2.3.0",
5
5
  "description": "Electron incremental update tools with Vite plugin, support bytecode protection",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",
@@ -56,36 +56,42 @@
56
56
  "registry": "https://registry.npmjs.org/"
57
57
  },
58
58
  "peerDependencies": {
59
- "@electron/asar": "*",
60
- "esbuild": "*"
59
+ "@electron/asar": "*"
61
60
  },
62
61
  "dependencies": {
63
- "@babel/core": "^7.26.7",
64
- "@babel/plugin-transform-arrow-functions": "^7.25.9",
65
- "@babel/plugin-transform-template-literals": "^7.25.9",
66
- "@subframe7536/type-utils": "^0.1.6",
67
- "ci-info": "^4.1.0",
68
- "local-pkg": "^1.0.0",
62
+ "@babel/core": "^7.27.1",
63
+ "@babel/plugin-transform-arrow-functions": "^7.27.1",
64
+ "@babel/plugin-transform-template-literals": "^7.27.1",
65
+ "@subframe7536/type-utils": "^0.2.0",
66
+ "ci-info": "^4.2.0",
67
+ "local-pkg": "^1.1.1",
69
68
  "magic-string": "^0.30.17",
70
69
  "selfsigned": "^2.4.1",
71
70
  "vite-plugin-electron": "^0.29.0"
72
71
  },
73
72
  "devDependencies": {
74
- "@subframe7536/eslint-config": "^1.1.8",
73
+ "@subframe7536/eslint-config": "^1.2.4",
75
74
  "@types/babel__core": "^7.20.5",
76
- "@types/node": "^20.17.17",
77
- "bumpp": "^10.0.1",
78
- "electron": "34.0.2",
79
- "eslint": "^9.19.0",
80
- "tsup": "^8.3.6",
81
- "typescript": "^5.7.3",
82
- "vite": "^6.0.11",
75
+ "@types/node": "^22.15.17",
76
+ "@vitest/eslint-plugin": "^1.1.44",
77
+ "bumpp": "^10.1.0",
78
+ "electron": "36.2.0",
79
+ "esbuild": "^0.25.4",
80
+ "eslint": "^9.26.0",
81
+ "tsup": "^8.4.0",
82
+ "typescript": "^5.8.3",
83
+ "vite": "^6.3.5",
83
84
  "vite-plugin-electron": "^0.29.0",
84
- "vitest": "^3.0.5"
85
+ "vitest": "^3.1.3"
85
86
  },
86
87
  "pnpm": {
87
88
  "overrides": {
88
- "is-core-module": "npm:@nolyfill/is-core-module@^1"
89
- }
89
+ "is-core-module": "npm:@nolyfill/is-core-module@^1.0.39"
90
+ },
91
+ "onlyBuiltDependencies": [
92
+ "electron",
93
+ "esbuild",
94
+ "unrs-resolver"
95
+ ]
90
96
  }
91
97
  }