electron-incremental-update 3.0.0-beta.3 → 3.0.0-beta.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/dist/{electron-OKQIYbcw.mjs → electron-BJCk7uxG.mjs} +1 -1
- package/dist/{electron-DH-Uyikp.cjs → electron-C-qmVhAt.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.mts +1 -1
- package/dist/utils.mjs +1 -1
- package/dist/vite.d.mts +15 -10
- package/dist/vite.mjs +83 -127
- package/package.json +2 -2
|
@@ -171,7 +171,7 @@ function handleUnexpectedErrors(callback) {
|
|
|
171
171
|
process.on("unhandledRejection", callback);
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
|
-
* @deprecated No longer needed. It is embeded in `startupWithUpdater()
|
|
174
|
+
* @deprecated No longer needed. It is embeded in `startupWithUpdater()`
|
|
175
175
|
*/
|
|
176
176
|
function reloadOnPreloadScriptChanged() {
|
|
177
177
|
console.warn("`reloadOnPreloadScriptChange()` is no longer needed. It is embeded in `startupWithUpdater()`");
|
|
@@ -174,7 +174,7 @@ function handleUnexpectedErrors(callback) {
|
|
|
174
174
|
process.on("unhandledRejection", callback);
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
|
-
* @deprecated No longer needed. It is embeded in `startupWithUpdater()
|
|
177
|
+
* @deprecated No longer needed. It is embeded in `startupWithUpdater()`
|
|
178
178
|
*/
|
|
179
179
|
function reloadOnPreloadScriptChanged() {
|
|
180
180
|
console.warn("`reloadOnPreloadScriptChange()` is no longer needed. It is embeded in `startupWithUpdater()`");
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_version = require('./version-aPrLuz_-.cjs');
|
|
2
|
-
const require_electron = require('./electron-
|
|
2
|
+
const require_electron = require('./electron-C-qmVhAt.cjs');
|
|
3
3
|
let electron = require("electron");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
node_fs = require_version.__toESM(node_fs);
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getPathFromAppNameAsar, f as isDev, i as getEntryVersion, r as getAppVersion, y as restartApp } from "./electron-
|
|
1
|
+
import { a as getPathFromAppNameAsar, f as isDev, i as getEntryVersion, r as getAppVersion, y as restartApp } from "./electron-BJCk7uxG.mjs";
|
|
2
2
|
import { r as isUpdateJSON } from "./version--eVB2A7n.mjs";
|
|
3
3
|
import { BrowserWindow, app } from "electron";
|
|
4
4
|
import fs from "node:fs";
|
package/dist/utils.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_version = require('./version-aPrLuz_-.cjs');
|
|
2
|
-
const require_electron = require('./electron-
|
|
2
|
+
const require_electron = require('./electron-C-qmVhAt.cjs');
|
|
3
3
|
const require_zip = require('./zip-BCC7FAQ_.cjs');
|
|
4
4
|
|
|
5
5
|
exports.aesDecrypt = require_zip.aesDecrypt;
|
package/dist/utils.d.cts
CHANGED
|
@@ -145,7 +145,7 @@ declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
|
145
145
|
*/
|
|
146
146
|
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
147
147
|
/**
|
|
148
|
-
* @deprecated No longer needed. It is embeded in `startupWithUpdater()
|
|
148
|
+
* @deprecated No longer needed. It is embeded in `startupWithUpdater()`
|
|
149
149
|
*/
|
|
150
150
|
declare function reloadOnPreloadScriptChanged(): void;
|
|
151
151
|
//#endregion
|
package/dist/utils.d.mts
CHANGED
|
@@ -145,7 +145,7 @@ declare function getPathFromEntryAsar(...paths: string[]): string;
|
|
|
145
145
|
*/
|
|
146
146
|
declare function handleUnexpectedErrors(callback: (err: unknown) => void): void;
|
|
147
147
|
/**
|
|
148
|
-
* @deprecated No longer needed. It is embeded in `startupWithUpdater()
|
|
148
|
+
* @deprecated No longer needed. It is embeded in `startupWithUpdater()`
|
|
149
149
|
*/
|
|
150
150
|
declare function reloadOnPreloadScriptChanged(): void;
|
|
151
151
|
//#endregion
|
package/dist/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-BJCk7uxG.mjs";
|
|
2
2
|
import { i as parseVersion, n as defaultVersionJsonGenerator, r as isUpdateJSON, t as defaultIsLowerVersion } from "./version--eVB2A7n.mjs";
|
|
3
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
4
|
|
package/dist/vite.d.mts
CHANGED
|
@@ -34,9 +34,9 @@ interface ElectronOptions {
|
|
|
34
34
|
/**
|
|
35
35
|
* Electron App startup function.
|
|
36
36
|
* It will mount the Electron App child-process to `process.electronApp`.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* - argv: electron startup arguments (default `['.', '--no-sandbox']`)
|
|
38
|
+
* - options: options for `child_process.spawn`
|
|
39
|
+
* - customElectronPkg: custom electron package name (default: `'electron'`)
|
|
40
40
|
*/
|
|
41
41
|
startup: (argv?: string[], options?: SpawnOptions, customElectronPkg?: string) => Promise<void>; /** Reload Electron-Renderer */
|
|
42
42
|
reload: () => void;
|
|
@@ -141,8 +141,14 @@ interface ElectronWithUpdaterOptions {
|
|
|
141
141
|
*/
|
|
142
142
|
isBuild: boolean;
|
|
143
143
|
/**
|
|
144
|
+
* Project root directory. Can be an absolute path, or a path relative from
|
|
145
|
+
* the location of the config file itself.
|
|
146
|
+
* @default process.cwd()
|
|
147
|
+
*/
|
|
148
|
+
root?: string;
|
|
149
|
+
/**
|
|
144
150
|
* Whether to generate sourcemap
|
|
145
|
-
* @default !isBuild
|
|
151
|
+
* @default !isBuild || !!process.env.VSCODE_DEBUG
|
|
146
152
|
*/
|
|
147
153
|
sourcemap?: boolean;
|
|
148
154
|
/**
|
|
@@ -169,13 +175,12 @@ interface ElectronWithUpdaterOptions {
|
|
|
169
175
|
*/
|
|
170
176
|
buildVersionJson?: boolean;
|
|
171
177
|
/**
|
|
172
|
-
* `external` option in `build.rolldownOptions`,
|
|
173
|
-
* default is node built-in modules or native modules.
|
|
178
|
+
* Addtional `external` option in `build.rolldownOptions`,
|
|
174
179
|
*
|
|
175
|
-
* If is in dev and `entry.postBuild` is not setup,
|
|
176
|
-
* external `dependencies` in `package.json`
|
|
180
|
+
* If is in dev and `entry.postBuild` is not setup,
|
|
181
|
+
* external `dependencies` in `package.json` by default
|
|
177
182
|
*/
|
|
178
|
-
external?:
|
|
183
|
+
external?: (string | RegExp)[];
|
|
179
184
|
/**
|
|
180
185
|
* Options for entry (app.asar)
|
|
181
186
|
*
|
|
@@ -483,7 +488,7 @@ interface ElectronViteHelperOptions extends MakeOptional<ElectronWithUpdaterOpti
|
|
|
483
488
|
/**
|
|
484
489
|
* Config for renderer process
|
|
485
490
|
*/
|
|
486
|
-
renderer?: UserConfig
|
|
491
|
+
renderer?: Omit<UserConfig, "root">;
|
|
487
492
|
}
|
|
488
493
|
/**
|
|
489
494
|
* Vite config helper
|
package/dist/vite.mjs
CHANGED
|
@@ -404,49 +404,6 @@ function resolveViteConfig(isESM, options) {
|
|
|
404
404
|
define: { "process.env": "process.env" }
|
|
405
405
|
}, options?.vite || {});
|
|
406
406
|
}
|
|
407
|
-
/** @see https://github.com/vitejs/vite/blob/v5.4.9/packages/vite/src/node/build.ts#L489-L504 */
|
|
408
|
-
function resolveInput(config) {
|
|
409
|
-
const options = config.build;
|
|
410
|
-
const { root } = config;
|
|
411
|
-
const libOptions = options.lib;
|
|
412
|
-
const resolve = (p) => path.resolve(root, p);
|
|
413
|
-
const input = libOptions ? options.rolldownOptions?.input || (typeof libOptions.entry === "string" ? resolve(libOptions.entry) : Array.isArray(libOptions.entry) ? libOptions.entry.map(resolve) : Object.fromEntries(Object.entries(libOptions.entry).map(([alias, file]) => [alias, resolve(file)]))) : options.rolldownOptions?.input;
|
|
414
|
-
if (input) return input;
|
|
415
|
-
const indexHtml = resolve("index.html");
|
|
416
|
-
return fs.existsSync(indexHtml) ? indexHtml : void 0;
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* When run the `vite build` command, there must be an entry file.
|
|
420
|
-
* If the user does not need Renderer, we need to create a temporary entry file to avoid Vite throw error.
|
|
421
|
-
* @see https://github.com/vitejs/vite/blob/v5.4.9/packages/vite/src/node/config.ts#L1234-L1236
|
|
422
|
-
*/
|
|
423
|
-
async function mockIndexHtml(config) {
|
|
424
|
-
const { root, build } = config;
|
|
425
|
-
const output = path.resolve(root, build.outDir);
|
|
426
|
-
const content = `
|
|
427
|
-
<!doctype html>
|
|
428
|
-
<html lang="en">
|
|
429
|
-
<head>
|
|
430
|
-
<title>vite-plugin-electron</title>
|
|
431
|
-
</head>
|
|
432
|
-
<body>
|
|
433
|
-
<div>An entry file for electron renderer process.</div>
|
|
434
|
-
</body>
|
|
435
|
-
</html>
|
|
436
|
-
`.trim();
|
|
437
|
-
const index = "index.html";
|
|
438
|
-
const filepath = path.join(root, index);
|
|
439
|
-
const distpath = path.join(output, index);
|
|
440
|
-
await fs.promises.writeFile(filepath, content);
|
|
441
|
-
return {
|
|
442
|
-
async remove() {
|
|
443
|
-
await fs.promises.unlink(filepath);
|
|
444
|
-
await fs.promises.unlink(distpath);
|
|
445
|
-
},
|
|
446
|
-
filepath,
|
|
447
|
-
distpath
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
407
|
/**
|
|
451
408
|
* Inspired `tree-kill`, implemented based on sync-api. #168
|
|
452
409
|
* @see https://github.com/pkrumins/node-tree-kill/blob/v1.2.2/index.js
|
|
@@ -481,26 +438,32 @@ function killTree(tree) {
|
|
|
481
438
|
function build$1(isESM, options) {
|
|
482
439
|
return build(resolveViteConfig(isESM, options));
|
|
483
440
|
}
|
|
484
|
-
function electron(isESM, options) {
|
|
441
|
+
function electron(isESM, root, options) {
|
|
485
442
|
const optionsArray = Array.isArray(options) ? options : [options];
|
|
486
443
|
let userConfig;
|
|
487
444
|
let configEnv;
|
|
488
|
-
let mockdInput;
|
|
489
445
|
if (!version.startsWith("8.")) throw new Error(`[vite-plugin-electron] Vite v${version} does not support \`rolldownOptions\`, please install \`vite@>=8\` or use an earlier version of \`vite-plugin-electron\`.`);
|
|
446
|
+
async function parallelBuild(options) {
|
|
447
|
+
await Promise.all(options.map(build$1.bind(build$1, isESM)));
|
|
448
|
+
}
|
|
490
449
|
return [{
|
|
491
450
|
name: "vite-plugin-electron:dev",
|
|
492
451
|
apply: "serve",
|
|
452
|
+
configResolved(config) {
|
|
453
|
+
if (config.root !== root) throw new Error(`Renderer's root (${config.root}) is not same as electron's root (${root}). Please setup \`root\` in electron plugin`);
|
|
454
|
+
},
|
|
493
455
|
configureServer(server) {
|
|
494
456
|
server.httpServer?.once("listening", () => {
|
|
495
457
|
Object.assign(process.env, { VITE_DEV_SERVER_URL: server.resolvedUrls?.local[0] });
|
|
496
458
|
const entryCount = optionsArray.length;
|
|
497
459
|
let closeBundleCount = 0;
|
|
498
|
-
|
|
460
|
+
parallelBuild(optionsArray.map((options) => {
|
|
499
461
|
options.vite ??= {};
|
|
500
462
|
options.vite.mode ??= server.config.mode;
|
|
501
463
|
options.vite.root ??= server.config.root;
|
|
502
464
|
options.vite.envDir ??= server.config.envDir;
|
|
503
465
|
options.vite.envPrefix ??= server.config.envPrefix;
|
|
466
|
+
const defaultArgs = [options.vite.root || ".", "--no-sandbox"];
|
|
504
467
|
options.vite.build ??= {};
|
|
505
468
|
if (!Object.keys(options.vite.build).includes("watch")) options.vite.build.watch = {};
|
|
506
469
|
options.vite.build.minify ??= false;
|
|
@@ -510,19 +473,21 @@ function electron(isESM, options) {
|
|
|
510
473
|
closeBundle() {
|
|
511
474
|
if (++closeBundleCount < entryCount) return;
|
|
512
475
|
if (options.onstart) options.onstart.call(this, {
|
|
513
|
-
startup,
|
|
476
|
+
async startup(args = defaultArgs, ...opt) {
|
|
477
|
+
await startup(args, ...opt);
|
|
478
|
+
},
|
|
514
479
|
reload() {
|
|
515
480
|
if (process.electronApp) {
|
|
516
481
|
(server.hot || server.ws).send({ type: "full-reload" });
|
|
517
482
|
startup.send("electron-vite&type=hot-reload");
|
|
518
|
-
} else startup();
|
|
483
|
+
} else startup(defaultArgs);
|
|
519
484
|
}
|
|
520
485
|
});
|
|
521
|
-
else startup();
|
|
486
|
+
else startup(defaultArgs);
|
|
522
487
|
}
|
|
523
488
|
});
|
|
524
|
-
|
|
525
|
-
}
|
|
489
|
+
return options;
|
|
490
|
+
}));
|
|
526
491
|
});
|
|
527
492
|
}
|
|
528
493
|
}, {
|
|
@@ -533,19 +498,15 @@ function electron(isESM, options) {
|
|
|
533
498
|
configEnv = env;
|
|
534
499
|
config.base ??= "./";
|
|
535
500
|
},
|
|
536
|
-
async configResolved(config) {
|
|
537
|
-
if (resolveInput(config) == null) mockdInput = await mockIndexHtml(config);
|
|
538
|
-
},
|
|
539
501
|
async closeBundle() {
|
|
540
|
-
|
|
541
|
-
for (const options of optionsArray) {
|
|
502
|
+
await parallelBuild(optionsArray.map((options) => {
|
|
542
503
|
options.vite ??= {};
|
|
543
504
|
options.vite.mode ??= configEnv.mode;
|
|
544
505
|
options.vite.root ??= userConfig.root;
|
|
545
506
|
options.vite.envDir ??= userConfig.envDir;
|
|
546
507
|
options.vite.envPrefix ??= userConfig.envPrefix;
|
|
547
|
-
|
|
548
|
-
}
|
|
508
|
+
return options;
|
|
509
|
+
}));
|
|
549
510
|
}
|
|
550
511
|
}];
|
|
551
512
|
}
|
|
@@ -721,7 +682,7 @@ function parseSubjects(subject) {
|
|
|
721
682
|
|
|
722
683
|
//#endregion
|
|
723
684
|
//#region src/vite/option.ts
|
|
724
|
-
async function
|
|
685
|
+
async function parseUpdaterOption(pkg, options = {}) {
|
|
725
686
|
const { minimumVersion = "0.0.0", paths: { asarOutputPath = `release/${pkg.name}.asar`, gzipPath = `release/${pkg.name}-${pkg.version}.asar.gz`, entryOutDir = "dist-entry", electronDistPath = "dist-electron", rendererDistPath = "dist", versionPath = "version.json" } = {}, keys: { privateKeyPath = "keys/private.pem", certPath = "keys/cert.pem", keyLength = 2048, certInfo: { subject = {
|
|
726
687
|
commonName: pkg.name,
|
|
727
688
|
organizationName: `org.${pkg.name}`
|
|
@@ -850,6 +811,13 @@ function parseVersionPath(versionPath) {
|
|
|
850
811
|
if (!versionPath.startsWith("./")) versionPath = `./${versionPath}`;
|
|
851
812
|
return new URL(versionPath, "file://").pathname.slice(1);
|
|
852
813
|
}
|
|
814
|
+
const defaultExternal = [
|
|
815
|
+
...builtinModules,
|
|
816
|
+
"electron",
|
|
817
|
+
/^node:/,
|
|
818
|
+
/.*\.(node|dll|dylib|so)$/,
|
|
819
|
+
"original-fs"
|
|
820
|
+
];
|
|
853
821
|
/**
|
|
854
822
|
* Base on `./electron/simple`
|
|
855
823
|
* - integrate with updater
|
|
@@ -897,33 +865,22 @@ function parseVersionPath(versionPath) {
|
|
|
897
865
|
* ```
|
|
898
866
|
*/
|
|
899
867
|
async function electronWithUpdater(options) {
|
|
900
|
-
let { isBuild, entry: _entry, main: _main, preload: _preload, sourcemap = !isBuild, minify = isBuild, buildVersionJson, updater, bytecode, useNotBundle = true } = options;
|
|
901
|
-
const pkg = await loadPackageJSON();
|
|
868
|
+
let { isBuild, root = process.cwd(), external, entry: _entry, main: _main, preload: _preload, sourcemap = !isBuild || !!process.env.VSCODE_DEBUG, minify = isBuild, buildVersionJson, updater, bytecode, useNotBundle = true } = options;
|
|
869
|
+
const pkg = await loadPackageJSON(root);
|
|
902
870
|
if (!pkg || !pkg.version || !pkg.name || !pkg.main) throw new Error("package.json not found or invalid, must contains version, name and main field");
|
|
903
|
-
log.info(`Clear cache files`, { timestamp: true });
|
|
904
871
|
const isESM = pkg.type === "module";
|
|
905
|
-
const
|
|
906
|
-
...builtinModules,
|
|
907
|
-
"electron",
|
|
908
|
-
/^node:/,
|
|
909
|
-
/.*\.(node|dll|dylib|so)$/,
|
|
910
|
-
"original-fs",
|
|
911
|
-
...isBuild || _entry.postBuild ? [] : Object.keys(pkg.dependencies || {})
|
|
912
|
-
];
|
|
872
|
+
const finalExternal = [...defaultExternal, ...isBuild || _entry.postBuild ? [] : external || Object.keys(pkg.dependencies || {})];
|
|
913
873
|
let bytecodeOptions = typeof bytecode === "object" ? bytecode : bytecode === true ? { enable: true } : void 0;
|
|
914
874
|
if (isESM && bytecodeOptions?.enable) throw new Error("`bytecodePlugin` does not support ES module, please remove \"type\": \"module\" in package.json");
|
|
915
|
-
const { buildAsarOption, buildVersionOption, cert, entryOutDir } = await
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
force: true
|
|
925
|
-
});
|
|
926
|
-
} catch {}
|
|
875
|
+
const { buildAsarOption, buildVersionOption, cert, entryOutDir } = await parseUpdaterOption(pkg, updater);
|
|
876
|
+
log.info(`Clear cache files`, { timestamp: true });
|
|
877
|
+
await Promise.all([fs.promises.rm(buildAsarOption.electronDistPath, {
|
|
878
|
+
recursive: true,
|
|
879
|
+
force: true
|
|
880
|
+
}), fs.promises.rm(entryOutDir, {
|
|
881
|
+
recursive: true,
|
|
882
|
+
force: true
|
|
883
|
+
})]).catch(() => {});
|
|
927
884
|
const define = {
|
|
928
885
|
__EIU_ASAR_BASE_NAME__: JSON.stringify(path.basename(buildAsarOption.asarOutputPath)),
|
|
929
886
|
__EIU_ELECTRON_DIST_PATH__: JSON.stringify(normalizePath(buildAsarOption.electronDistPath)),
|
|
@@ -936,10 +893,7 @@ async function electronWithUpdater(options) {
|
|
|
936
893
|
};
|
|
937
894
|
const _electronOptions = [{
|
|
938
895
|
entry: _main.files,
|
|
939
|
-
onstart:
|
|
940
|
-
if (_main.onstart) await _main.onstart(args);
|
|
941
|
-
else await args.startup();
|
|
942
|
-
},
|
|
896
|
+
onstart: _main.onstart,
|
|
943
897
|
vite: mergeConfig({
|
|
944
898
|
plugins: [!isBuild && useNotBundle && notBundle(), bytecodeOptions && bytecodePlugin("main", bytecodeOptions)],
|
|
945
899
|
build: {
|
|
@@ -947,12 +901,9 @@ async function electronWithUpdater(options) {
|
|
|
947
901
|
minify,
|
|
948
902
|
outDir: `${buildAsarOption.electronDistPath}/main`,
|
|
949
903
|
rolldownOptions: {
|
|
950
|
-
external,
|
|
904
|
+
external: finalExternal,
|
|
951
905
|
platform: "node",
|
|
952
|
-
output: {
|
|
953
|
-
cleanDir: true,
|
|
954
|
-
polyfillRequire: false
|
|
955
|
-
}
|
|
906
|
+
output: { polyfillRequire: false }
|
|
956
907
|
}
|
|
957
908
|
},
|
|
958
909
|
define
|
|
@@ -969,7 +920,7 @@ async function electronWithUpdater(options) {
|
|
|
969
920
|
minify,
|
|
970
921
|
outDir: `${buildAsarOption.electronDistPath}/preload`,
|
|
971
922
|
rolldownOptions: {
|
|
972
|
-
external,
|
|
923
|
+
external: finalExternal,
|
|
973
924
|
input: _preload.files,
|
|
974
925
|
output: {
|
|
975
926
|
format: "cjs",
|
|
@@ -987,50 +938,54 @@ async function electronWithUpdater(options) {
|
|
|
987
938
|
_electronOptions.push({
|
|
988
939
|
entry: _entry.files,
|
|
989
940
|
vite: mergeConfig({
|
|
990
|
-
plugins: [
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
941
|
+
plugins: [
|
|
942
|
+
bytecodeOptions && bytecodePlugin("main", bytecodeOptions),
|
|
943
|
+
!isBuild && useNotBundle && notBundle(),
|
|
944
|
+
{
|
|
945
|
+
name: `${id}:entry`,
|
|
946
|
+
enforce: "post",
|
|
947
|
+
async closeBundle() {
|
|
948
|
+
log.info(`Build entry to '${entryOutDir}'`, { timestamp: true });
|
|
949
|
+
await _entry.postBuild?.({
|
|
950
|
+
isBuild,
|
|
951
|
+
getPathFromEntryOutputDir(...paths) {
|
|
952
|
+
return path.join(entryOutDir, ...paths);
|
|
953
|
+
},
|
|
954
|
+
copyToEntryOutputDir({ from, to = path.basename(from), skipIfExist = true }) {
|
|
955
|
+
if (!fs.existsSync(from)) {
|
|
956
|
+
log.warn(`${from} not found`, { timestamp: true });
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
copyAndSkipIfExist(from, path.join(entryOutDir, to), skipIfExist);
|
|
960
|
+
},
|
|
961
|
+
copyModules({ modules, skipIfExist = true }) {
|
|
962
|
+
const nodeModulesPath = path.join(entryOutDir, "node_modules");
|
|
963
|
+
for (const m of modules) {
|
|
964
|
+
const { rootPath } = getPackageInfoSync(m) || {};
|
|
965
|
+
if (!rootPath) {
|
|
966
|
+
log.warn(`Package '${m}' not found`, { timestamp: true });
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
copyAndSkipIfExist(rootPath, path.join(nodeModulesPath, m), skipIfExist);
|
|
1014
970
|
}
|
|
1015
|
-
copyAndSkipIfExist(rootPath, path.join(nodeModulesPath, m), skipIfExist);
|
|
1016
971
|
}
|
|
972
|
+
});
|
|
973
|
+
if (isBuild) try {
|
|
974
|
+
const buffer = await buildAsar(buildAsarOption);
|
|
975
|
+
if (!buildVersionJson && !isCI) log.warn("No `buildVersionJson` option setup, skip build version json. Only build in CI by default", { timestamp: true });
|
|
976
|
+
else await buildUpdateJson(buildVersionOption, buffer);
|
|
977
|
+
} catch (error) {
|
|
978
|
+
console.error(error);
|
|
1017
979
|
}
|
|
1018
|
-
});
|
|
1019
|
-
if (isBuild) try {
|
|
1020
|
-
const buffer = await buildAsar(buildAsarOption);
|
|
1021
|
-
if (!buildVersionJson && !isCI) log.warn("No `buildVersionJson` option setup, skip build version json. Only build in CI by default", { timestamp: true });
|
|
1022
|
-
else await buildUpdateJson(buildVersionOption, buffer);
|
|
1023
|
-
} catch (error) {
|
|
1024
|
-
console.error(error);
|
|
1025
980
|
}
|
|
1026
981
|
}
|
|
1027
|
-
|
|
982
|
+
],
|
|
1028
983
|
build: {
|
|
1029
984
|
sourcemap,
|
|
1030
985
|
minify,
|
|
1031
986
|
outDir: entryOutDir,
|
|
1032
987
|
rolldownOptions: {
|
|
1033
|
-
external,
|
|
988
|
+
external: finalExternal,
|
|
1034
989
|
platform: "node",
|
|
1035
990
|
output: { polyfillRequire: false }
|
|
1036
991
|
}
|
|
@@ -1038,7 +993,7 @@ async function electronWithUpdater(options) {
|
|
|
1038
993
|
define
|
|
1039
994
|
}, _entry.vite || {})
|
|
1040
995
|
});
|
|
1041
|
-
return electron(isESM, _electronOptions);
|
|
996
|
+
return electron(isESM, normalizePath(path.resolve(root)), _electronOptions);
|
|
1042
997
|
}
|
|
1043
998
|
|
|
1044
999
|
//#endregion
|
|
@@ -1081,6 +1036,7 @@ function defineElectronConfig(options) {
|
|
|
1081
1036
|
const result = options.renderer ?? {};
|
|
1082
1037
|
result.plugins ??= [];
|
|
1083
1038
|
result.plugins.push(electronPlugin);
|
|
1039
|
+
result.root = options.root;
|
|
1084
1040
|
const rendererDistPath = options.updater?.paths?.rendererDistPath;
|
|
1085
1041
|
if (rendererDistPath) {
|
|
1086
1042
|
result.build ??= {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-incremental-update",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "Electron incremental update tools with Vite plugin, support bytecode protection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bytecode",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"scripts": {
|
|
61
61
|
"dev": "tsdown --watch",
|
|
62
62
|
"build": "tsdown",
|
|
63
|
-
"play": "
|
|
63
|
+
"play": "vite",
|
|
64
64
|
"release": "bun run format && bun run lint && bun run test && bun run build && bumpp --all",
|
|
65
65
|
"test": "bun test",
|
|
66
66
|
"test:dev": "bun test --watch",
|