electron-incremental-update 3.1.0 → 3.1.1

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/vite.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Plugin, UserConfig } from "vite";
2
2
  import { MultiEnvElectronOptions } from "vite-plugin-electron/multi-env";
3
+ import { CreateOptions } from "@electron/asar";
3
4
 
4
5
  //#region src/utils/type.d.ts
5
6
  type Promisable<T> = T | Promise<T>;
@@ -174,6 +175,10 @@ interface ElectronWithUpdaterOptions extends Pick<MultiEnvElectronOptions, "bund
174
175
  * To change output directories, use `options.updater.paths.electronDistPath` instead
175
176
  */
176
177
  entry: {
178
+ /**
179
+ * Options passed to `@electron/asar` when creating the app.asar archive
180
+ */
181
+ asarOptions?: CreateOptions;
177
182
  /**
178
183
  * By default, all the unbundled modules will be packaged by packager like `electron-builder`.
179
184
  * If setup, all the `dependencies` in `package.json` will be bundled by default, and you need
package/dist/vite.mjs CHANGED
@@ -11,7 +11,7 @@ import cp from "node:child_process";
11
11
  import * as babel from "@babel/core";
12
12
  import { copyFile, cp as cp$1, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
13
13
  import { tmpdir } from "node:os";
14
- import { createPackage, extractFile } from "@electron/asar";
14
+ import { createPackageWithOptions, extractFile } from "@electron/asar";
15
15
  import { generate } from "selfsigned";
16
16
  //#region src/vite/startup.ts
17
17
  /**
@@ -460,7 +460,7 @@ async function prepareLocalDevUpdateResource({ root, pkg, buildAsarOption, versi
460
460
  await mkdir(path.dirname(resolvedVersionPath), { recursive: true });
461
461
  await cp$1(path.resolve(root, buildAsarOption.electronDistPath), stagedElectronDistPath, { recursive: true });
462
462
  await writeFile(path.join(stagedElectronDistPath, "version"), targetVersion, "utf-8");
463
- await createPackage(stagedElectronDistPath, asarPath);
463
+ await createPackageWithOptions(stagedElectronDistPath, asarPath, buildAsarOption.asarOptions ?? {});
464
464
  await writeFile(compressedPath, await buildAsarOption.generateCompressedFile(await readFile(asarPath)));
465
465
  const updateJSON = defaultVersionJsonGenerator(await readExistingUpdateJSON(resolvedVersionPath, targetVersion), LOCAL_DEV_SIGNATURE, targetVersion, minimumVersion);
466
466
  if (!isUpdateJSON(updateJSON)) throw new Error("Invalid local dev update json");
@@ -573,7 +573,7 @@ function copyAndSkipIfExist(from, to, skipIfExist) {
573
573
  * @param options - Asar build options
574
574
  * @returns Buffer of the built asar file
575
575
  */
576
- async function buildAsar(root, { version, asarOutputPath, electronDistPath, rendererDistPath, compressedPath, generateCompressedFile }) {
576
+ async function buildAsar(root, { version, asarOptions, asarOutputPath, electronDistPath, rendererDistPath, compressedPath, generateCompressedFile }) {
577
577
  electronDistPath = path.resolve(root, electronDistPath);
578
578
  asarOutputPath = path.resolve(root, asarOutputPath);
579
579
  rendererDistPath = path.resolve(root, rendererDistPath);
@@ -582,7 +582,7 @@ async function buildAsar(root, { version, asarOutputPath, electronDistPath, rend
582
582
  await fs.promises.cp(rendererDistPath, rPath, { recursive: true });
583
583
  fs.writeFileSync(path.join(electronDistPath, "version"), version);
584
584
  await fs.promises.mkdir(path.dirname(asarOutputPath), { recursive: true });
585
- await createPackage(electronDistPath, asarOutputPath);
585
+ await createPackageWithOptions(electronDistPath, asarOutputPath, asarOptions ?? {});
586
586
  const buf = await generateCompressedFile(fs.readFileSync(asarOutputPath));
587
587
  await fs.promises.mkdir(path.dirname(compressedPath), { recursive: true });
588
588
  fs.writeFileSync(compressedPath, buf);
@@ -686,7 +686,7 @@ function parseSubjects(subject) {
686
686
  }
687
687
  //#endregion
688
688
  //#region src/vite/core.ts
689
- async function resolveUpdaterOption(root, pkg, options = {}, resolveSignatureKeys = true) {
689
+ async function resolveUpdaterOption(root, pkg, options = {}, resolveSignatureKeys = true, asarOptions) {
690
690
  const { minimumVersion = "0.0.0", paths: { asarOutputPath = `release/${pkg.name}.asar`, compressedPath = `release/${pkg.name}-${pkg.version}.asar.br`, entryOutDir = "dist-entry", electronDistPath = "dist-electron", rendererDistPath = "dist", versionPath = "release/version.json" } = {}, keys: { privateKeyPath = "keys/private.pem", certPath = "keys/cert.pem", keyLength = 2048, certInfo: { subject = {
691
691
  commonName: pkg.name,
692
692
  organizationName: `org.${pkg.name}`
@@ -704,6 +704,7 @@ async function resolveUpdaterOption(root, pkg, options = {}, resolveSignatureKey
704
704
  return {
705
705
  buildAsarOption: {
706
706
  version: pkg.version,
707
+ asarOptions,
707
708
  asarOutputPath,
708
709
  compressedPath,
709
710
  electronDistPath,
@@ -753,7 +754,7 @@ async function createElectronOptions(options, context) {
753
754
  if (isESM && bytecodeOptions?.enable) throw new Error("`bytecodePlugin` does not support ES module, please remove \"type\": \"module\" in package.json");
754
755
  const resolvedLocalDevUpdate = context.isDev ? resolveLocalDevUpdateOptions(context.root, localDevUpdate) : void 0;
755
756
  const updatePkg = await resolveLocalDevUpdatePackage(pkg, resolvedLocalDevUpdate);
756
- const { buildAsarOption, buildVersionOption, entryOutDir } = await resolveUpdaterOption(context.root, updatePkg, updater, !resolvedLocalDevUpdate);
757
+ const { buildAsarOption, buildVersionOption, entryOutDir } = await resolveUpdaterOption(context.root, updatePkg, updater, !resolvedLocalDevUpdate, entry.asarOptions);
757
758
  const mainFileName = `${resolveEntryName(main.files)}.${isESM ? "mjs" : "js"}`;
758
759
  log.info(`Using "${mainFileName}" as main file`, { timestamp: true });
759
760
  log.info(`Clear cache files`, { timestamp: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Electron incremental update tools with Vite plugin, support bytecode protection",
5
5
  "keywords": [
6
6
  "bytecode",