electron-incremental-update 2.3.1 → 2.3.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.
- package/README.md +2 -2
- package/dist/vite.d.ts +25 -6
- package/dist/vite.js +47 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -920,9 +920,9 @@ export interface BuildEntryOption {
|
|
|
920
920
|
*/
|
|
921
921
|
ignoreDynamicRequires?: boolean
|
|
922
922
|
/**
|
|
923
|
-
* `external` option in `build.rollupOptions`,
|
|
923
|
+
* `external` option in `build.rollupOptions`, default is node built-in modules or native modules
|
|
924
924
|
*/
|
|
925
|
-
external?:
|
|
925
|
+
external?: NonNullable<NonNullable<InlineConfig['build']>['rollupOptions']>['external']
|
|
926
926
|
/**
|
|
927
927
|
* Custom options for `vite` build
|
|
928
928
|
* ```ts
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Promisable } from '@subframe7536/type-utils';
|
|
1
|
+
import { Promisable, AnyFunction } from '@subframe7536/type-utils';
|
|
2
2
|
import { InlineConfig, PluginOption } from 'vite';
|
|
3
3
|
import { ElectronSimpleOptions } from 'vite-plugin-electron/simple';
|
|
4
4
|
export { isCI } from 'ci-info';
|
|
@@ -104,9 +104,9 @@ interface BuildEntryOption {
|
|
|
104
104
|
*/
|
|
105
105
|
ignoreDynamicRequires?: boolean;
|
|
106
106
|
/**
|
|
107
|
-
* `external` option in `build.rollupOptions`,
|
|
107
|
+
* `external` option in `build.rollupOptions`, default is node built-in modules or native modules
|
|
108
108
|
*/
|
|
109
|
-
external?:
|
|
109
|
+
external?: NonNullable<NonNullable<InlineConfig['build']>['rollupOptions']>['external'];
|
|
110
110
|
/**
|
|
111
111
|
* Custom options for `vite` build
|
|
112
112
|
* ```ts
|
|
@@ -297,7 +297,8 @@ type ReplaceKey<T, Key extends keyof T, NewKey extends string> = Omit<T, Key> &
|
|
|
297
297
|
type MakeRequiredAndReplaceKey<T, K extends keyof T, NewKey extends string> = MakeRequired<ReplaceKey<T, K, NewKey>, NewKey>;
|
|
298
298
|
type StartupFn = NonNullable<NonNullable<ElectronSimpleOptions['main']>['onstart']>;
|
|
299
299
|
/**
|
|
300
|
-
* Startup function for debug
|
|
300
|
+
* Startup function for debug
|
|
301
|
+
* @see {@link https://github.com/electron-vite/electron-vite-vue/blob/main/vite.config.ts electron-vite-vue template}
|
|
301
302
|
* @example
|
|
302
303
|
* import { debugStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
303
304
|
* const options = buildElectronPluginOptions({
|
|
@@ -309,6 +310,24 @@ type StartupFn = NonNullable<NonNullable<ElectronSimpleOptions['main']>['onstart
|
|
|
309
310
|
* })
|
|
310
311
|
*/
|
|
311
312
|
declare const debugStartup: StartupFn;
|
|
313
|
+
/**
|
|
314
|
+
* Startup function to filter unwanted error message
|
|
315
|
+
* @see {@link https://github.com/electron/electron/issues/46903#issuecomment-2848483520 reference}
|
|
316
|
+
* @example
|
|
317
|
+
* import { filterErrorMessageStartup, buildElectronPluginOptions } from 'electron-incremental-update/vite'
|
|
318
|
+
* const options = buildElectronPluginOptions({
|
|
319
|
+
* // ...
|
|
320
|
+
* main: {
|
|
321
|
+
* // ...
|
|
322
|
+
* startup: args => filterErrorMessageStartup(
|
|
323
|
+
* args,
|
|
324
|
+
* // ignore error message when function returns false
|
|
325
|
+
* msg => !/"code":-32601/.test(message)
|
|
326
|
+
* )
|
|
327
|
+
* },
|
|
328
|
+
* })
|
|
329
|
+
*/
|
|
330
|
+
declare function filterErrorMessageStartup(args: Parameters<StartupFn>[0], filter: (msg: string) => boolean): Promise<void>;
|
|
312
331
|
/**
|
|
313
332
|
* Startup function util to fix Windows terminal charset
|
|
314
333
|
* @example
|
|
@@ -321,7 +340,7 @@ declare const debugStartup: StartupFn;
|
|
|
321
340
|
* },
|
|
322
341
|
* })
|
|
323
342
|
*/
|
|
324
|
-
declare function fixWinCharEncoding(fn:
|
|
343
|
+
declare function fixWinCharEncoding<T extends AnyFunction>(fn: T): T;
|
|
325
344
|
type ExcludeOutputDirOptions = {
|
|
326
345
|
vite?: {
|
|
327
346
|
build?: {
|
|
@@ -454,4 +473,4 @@ interface ElectronWithUpdaterOptions {
|
|
|
454
473
|
*/
|
|
455
474
|
declare function electronWithUpdater(options: ElectronWithUpdaterOptions): Promise<PluginOption[] | undefined>;
|
|
456
475
|
|
|
457
|
-
export { type ElectronWithUpdaterOptions, convertLiteral, debugStartup, electronWithUpdater as default, electronWithUpdater, fixWinCharEncoding };
|
|
476
|
+
export { type ElectronWithUpdaterOptions, convertLiteral, debugStartup, electronWithUpdater as default, electronWithUpdater, filterErrorMessageStartup, fixWinCharEncoding };
|
package/dist/vite.js
CHANGED
|
@@ -13,6 +13,7 @@ import { startup, build } from 'vite-plugin-electron';
|
|
|
13
13
|
import { notBundle } from 'vite-plugin-electron/plugin';
|
|
14
14
|
import ElectronSimple from 'vite-plugin-electron/simple';
|
|
15
15
|
import Asar from '@electron/asar';
|
|
16
|
+
import { builtinModules } from 'node:module';
|
|
16
17
|
import crypto from 'node:crypto';
|
|
17
18
|
import zlib from 'node:zlib';
|
|
18
19
|
import { generate } from 'selfsigned';
|
|
@@ -177,7 +178,12 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
|
|
|
177
178
|
nativeModuleEntryMap = {},
|
|
178
179
|
postBuild,
|
|
179
180
|
ignoreDynamicRequires = false,
|
|
180
|
-
external
|
|
181
|
+
external = [
|
|
182
|
+
/^node:.*/,
|
|
183
|
+
/.*\.(node|dll|dylib|so)$/,
|
|
184
|
+
"original-fs",
|
|
185
|
+
...builtinModules
|
|
186
|
+
],
|
|
181
187
|
overrideViteOptions = {}
|
|
182
188
|
} = {},
|
|
183
189
|
paths: {
|
|
@@ -221,21 +227,7 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
|
|
|
221
227
|
nativeModuleEntryMap,
|
|
222
228
|
overrideViteOptions,
|
|
223
229
|
ignoreDynamicRequires,
|
|
224
|
-
external
|
|
225
|
-
if (source.endsWith(".node") || source.startsWith("node:")) {
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
if (!external) {
|
|
229
|
-
return void 0;
|
|
230
|
-
}
|
|
231
|
-
if (typeof external === "string") {
|
|
232
|
-
return source === external;
|
|
233
|
-
}
|
|
234
|
-
if (Array.isArray(external)) {
|
|
235
|
-
return external.includes(source);
|
|
236
|
-
}
|
|
237
|
-
return external(source, importer, isResolved);
|
|
238
|
-
}
|
|
230
|
+
external
|
|
239
231
|
};
|
|
240
232
|
const { privateKey, cert } = parseKeys({
|
|
241
233
|
keyLength,
|
|
@@ -256,13 +248,23 @@ function parseOptions(pkg, sourcemap = false, minify = false, options = {}) {
|
|
|
256
248
|
return { buildAsarOption, buildEntryOption, buildVersionOption, postBuild, cert };
|
|
257
249
|
}
|
|
258
250
|
var vite_default = electronWithUpdater;
|
|
259
|
-
var debugStartup = (args) => {
|
|
251
|
+
var debugStartup = async (args) => {
|
|
260
252
|
if (process.env.VSCODE_DEBUG) {
|
|
261
253
|
console.log("[startup] Electron App");
|
|
262
254
|
} else {
|
|
263
|
-
args.startup();
|
|
255
|
+
await args.startup();
|
|
264
256
|
}
|
|
265
257
|
};
|
|
258
|
+
async function filterErrorMessageStartup(args, filter) {
|
|
259
|
+
await args.startup(void 0, { stdio: ["inherit", "inherit", "pipe", "ipc"] });
|
|
260
|
+
const elec = process.electronApp;
|
|
261
|
+
elec.stderr.addListener("data", (data) => {
|
|
262
|
+
const message = data.toString();
|
|
263
|
+
if (filter(message)) {
|
|
264
|
+
console.error(message);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
266
268
|
function fixWinCharEncoding(fn) {
|
|
267
269
|
return async (...args) => {
|
|
268
270
|
if (process.platform === "win32") {
|
|
@@ -294,9 +296,6 @@ function parseVersionPath(versionPath) {
|
|
|
294
296
|
}
|
|
295
297
|
return new URL(versionPath, "file://").pathname.slice(1);
|
|
296
298
|
}
|
|
297
|
-
var ex = startup.exit;
|
|
298
|
-
startup.exit = () => ex().catch(() => {
|
|
299
|
-
});
|
|
300
299
|
async function electronWithUpdater(options) {
|
|
301
300
|
let {
|
|
302
301
|
isBuild,
|
|
@@ -331,7 +330,7 @@ async function electronWithUpdater(options) {
|
|
|
331
330
|
postBuild,
|
|
332
331
|
cert
|
|
333
332
|
} = parseOptions(pkg, sourcemap, minify, updater);
|
|
334
|
-
const { entryOutputDirPath, nativeModuleEntryMap, appEntryPath } = buildEntryOption;
|
|
333
|
+
const { entryOutputDirPath, nativeModuleEntryMap, appEntryPath, external } = buildEntryOption;
|
|
335
334
|
try {
|
|
336
335
|
fs2.rmSync(buildAsarOption.electronDistPath, { recursive: true, force: true });
|
|
337
336
|
fs2.rmSync(entryOutputDirPath, { recursive: true, force: true });
|
|
@@ -361,9 +360,7 @@ async function electronWithUpdater(options) {
|
|
|
361
360
|
bytecodeOptions
|
|
362
361
|
);
|
|
363
362
|
log.info(`Build entry to '${entryOutputDirPath}'`, { timestamp: true });
|
|
364
|
-
|
|
365
|
-
async function _postBuild() {
|
|
366
|
-
return await postBuild?.({
|
|
363
|
+
await postBuild?.({
|
|
367
364
|
getPathFromEntryOutputDir(...paths) {
|
|
368
365
|
return path3.join(entryOutputDirPath, ...paths);
|
|
369
366
|
},
|
|
@@ -390,7 +387,7 @@ async function electronWithUpdater(options) {
|
|
|
390
387
|
}
|
|
391
388
|
let isInit = false;
|
|
392
389
|
const rollupOptions = {
|
|
393
|
-
external
|
|
390
|
+
external,
|
|
394
391
|
treeshake: true
|
|
395
392
|
};
|
|
396
393
|
const esmShimPlugin = isESM ? import('./esm-4S4XCVEW.js').then((m) => m.esm()) : void 0;
|
|
@@ -401,12 +398,11 @@ async function electronWithUpdater(options) {
|
|
|
401
398
|
if (!isInit) {
|
|
402
399
|
isInit = true;
|
|
403
400
|
await _buildEntry();
|
|
404
|
-
await _postBuild();
|
|
405
401
|
}
|
|
406
402
|
if (_main.onstart) {
|
|
407
|
-
_main.onstart(args);
|
|
403
|
+
await _main.onstart(args);
|
|
408
404
|
} else {
|
|
409
|
-
args.startup();
|
|
405
|
+
await args.startup();
|
|
410
406
|
}
|
|
411
407
|
},
|
|
412
408
|
vite: mergeConfig(
|
|
@@ -443,7 +439,6 @@ async function electronWithUpdater(options) {
|
|
|
443
439
|
},
|
|
444
440
|
async closeBundle() {
|
|
445
441
|
await _buildEntry();
|
|
446
|
-
await _postBuild();
|
|
447
442
|
const buffer = await buildAsar(buildAsarOption);
|
|
448
443
|
if (!buildVersionJson && !isCI) {
|
|
449
444
|
log.warn("No `buildVersionJson` option setup, skip build version json. Only build in CI by default", { timestamp: true });
|
|
@@ -492,11 +487,27 @@ async function electronWithUpdater(options) {
|
|
|
492
487
|
configureServer(server) {
|
|
493
488
|
server.watcher.add(files).on(
|
|
494
489
|
"change",
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
490
|
+
async (p) => {
|
|
491
|
+
if (!files.includes(p)) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
await _buildEntry();
|
|
495
|
+
if (_main.onstart) {
|
|
496
|
+
await _main.onstart({
|
|
497
|
+
startup,
|
|
498
|
+
reload: () => {
|
|
499
|
+
if (process.electronApp) {
|
|
500
|
+
(server.hot || server.ws).send({ type: "full-reload" });
|
|
501
|
+
startup.send("electron-vite&type=hot-reload");
|
|
502
|
+
} else {
|
|
503
|
+
startup();
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
} else {
|
|
508
|
+
await startup();
|
|
509
|
+
}
|
|
510
|
+
}
|
|
500
511
|
);
|
|
501
512
|
}
|
|
502
513
|
};
|
|
@@ -504,4 +515,4 @@ async function electronWithUpdater(options) {
|
|
|
504
515
|
return [ElectronSimple(electronPluginOptions), extraHmrPlugin];
|
|
505
516
|
}
|
|
506
517
|
|
|
507
|
-
export { debugStartup, vite_default as default, electronWithUpdater, fixWinCharEncoding };
|
|
518
|
+
export { debugStartup, vite_default as default, electronWithUpdater, filterErrorMessageStartup, fixWinCharEncoding };
|
package/package.json
CHANGED