app-builder-lib 26.17.0 → 26.18.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/out/asar/asarUtil.js +7 -2
- package/out/asar/asarUtil.js.map +1 -1
- package/out/forge-maker.d.ts +64 -0
- package/out/forge-maker.js +108 -2
- package/out/forge-maker.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/node-module-collector/pnpmNodeModulesCollector.d.ts +37 -0
- package/out/node-module-collector/pnpmNodeModulesCollector.js +102 -24
- package/out/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/out/targets/blockmap/blockmap.d.ts +43 -3
- package/out/targets/blockmap/blockmap.js +143 -16
- package/out/targets/blockmap/blockmap.js.map +1 -1
- package/out/targets/blockmap/verbatimRange.d.ts +43 -0
- package/out/targets/blockmap/verbatimRange.js +122 -0
- package/out/targets/blockmap/verbatimRange.js.map +1 -0
- package/out/targets/differentialUpdateInfoBuilder.d.ts +27 -2
- package/out/targets/differentialUpdateInfoBuilder.js +77 -5
- package/out/targets/differentialUpdateInfoBuilder.js.map +1 -1
- package/out/targets/nsis/NsisTarget.d.ts +35 -2
- package/out/targets/nsis/NsisTarget.js +121 -29
- package/out/targets/nsis/NsisTarget.js.map +1 -1
- package/out/targets/nsis/nsisOptions.d.ts +8 -3
- package/out/targets/nsis/nsisOptions.js.map +1 -1
- package/out/targets/nsis/nsisUtil.d.ts +7 -0
- package/out/targets/nsis/nsisUtil.js +14 -3
- package/out/targets/nsis/nsisUtil.js.map +1 -1
- package/out/targets/snap/core24.d.ts +2 -0
- package/out/targets/snap/core24.js +30 -7
- package/out/targets/snap/core24.js.map +1 -1
- package/out/targets/snap/coreLegacy.js +1 -2
- package/out/targets/snap/coreLegacy.js.map +1 -1
- package/out/util/appFileCopier.js +1 -1
- package/out/util/appFileCopier.js.map +1 -1
- package/out/version.d.ts +1 -1
- package/out/version.js +1 -1
- package/out/version.js.map +1 -1
- package/package.json +10 -8
- package/scheme.json +5 -5
|
@@ -2,9 +2,18 @@ import { Arch } from "builder-util";
|
|
|
2
2
|
import { PackageFileInfo } from "builder-util-runtime";
|
|
3
3
|
import { Target } from "../../core";
|
|
4
4
|
import { WinPackager } from "../../winPackager";
|
|
5
|
+
import { ArchiveOptions } from "../archive";
|
|
5
6
|
import { Defines } from "./Defines";
|
|
6
7
|
import { NsisOptions } from "./nsisOptions";
|
|
7
8
|
import { AppPackageHelper, CopyElevateHelper } from "./nsisUtil";
|
|
9
|
+
/** The member `differentialPackage: "store-asar"` keeps uncompressed in the app package, relative to the unpacked app dir. */
|
|
10
|
+
export declare const STORED_ASAR_PATH = "resources/app.asar";
|
|
11
|
+
/**
|
|
12
|
+
* The `archive()` options `buildAppPackage` packages the unpacked app with, before the differential-aware
|
|
13
|
+
* adjustments of `configureDifferentialAwareArchiveOptions`. Exported so the benchmark
|
|
14
|
+
* (`test/src/differentialOneLineBenchTest.ts`) packages exactly like a real build instead of copying these.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createAppPackageArchiveOptions(compression: ArchiveOptions["compression"], excluded: Array<string> | null, storedPaths: Array<string> | null): ArchiveOptions;
|
|
8
17
|
export declare class NsisTarget extends Target {
|
|
9
18
|
readonly packager: WinPackager;
|
|
10
19
|
readonly outDir: string;
|
|
@@ -17,9 +26,33 @@ export declare class NsisTarget extends Target {
|
|
|
17
26
|
get shouldBuildUniversalInstaller(): boolean;
|
|
18
27
|
build(appOutDir: string, arch: Arch): Promise<any>;
|
|
19
28
|
get isBuildDifferentialAware(): boolean;
|
|
29
|
+
private get isZipPayload();
|
|
30
|
+
private get isStoreAsar();
|
|
31
|
+
/**
|
|
32
|
+
* Everything that makes buildAppPackage's archive differ between targets. Targets sharing an
|
|
33
|
+
* AppPackageHelper (nsis + portable) reuse one app package per arch only when this key matches,
|
|
34
|
+
* so a target never embeds an archive whose format or layout was chosen by another target.
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
get appPackageCacheKey(): string;
|
|
20
38
|
private getPreCompressedFileExtensions;
|
|
21
|
-
/**
|
|
22
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @private
|
|
41
|
+
* @returns the package file info plus the absolute source paths of the members stored verbatim in it
|
|
42
|
+
* (`storedMemberFiles`, empty unless `differentialPackage` is `"store-asar"`).
|
|
43
|
+
*/
|
|
44
|
+
buildAppPackage(appOutDir: string, arch: Arch, elevateHelper?: CopyElevateHelper | null, fileNameSuffix?: string): Promise<{
|
|
45
|
+
fileInfo: PackageFileInfo;
|
|
46
|
+
storedMemberFiles: Array<string>;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* `archive()` silently skips stored paths that don't exist, so without an asar (e.g. `asar: false`)
|
|
50
|
+
* "store-asar" would do nothing unnoticed. The fallback is harmless — the differential package is
|
|
51
|
+
* non-solid, so each unpacked file is already its own block — but say so once per target.
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
warnIfStoreAsarHasNoAsar(appOutDir: string): Promise<void>;
|
|
55
|
+
private storeAsarChecked;
|
|
23
56
|
protected installerFilenamePattern(primaryArch?: Arch | null, defaultArch?: string): string;
|
|
24
57
|
private get isPortable();
|
|
25
58
|
finishBuild(): Promise<any>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NsisTarget = void 0;
|
|
3
|
+
exports.NsisTarget = exports.STORED_ASAR_PATH = void 0;
|
|
4
|
+
exports.createAppPackageArchiveOptions = createAppPackageArchiveOptions;
|
|
4
5
|
const builder_util_1 = require("builder-util");
|
|
5
6
|
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
6
7
|
const debug_1 = require("debug");
|
|
@@ -24,6 +25,26 @@ const nsisUtil_1 = require("./nsisUtil");
|
|
|
24
25
|
const nsisValidation_1 = require("./nsisValidation");
|
|
25
26
|
const WineVm_1 = require("../../vm/WineVm");
|
|
26
27
|
const debug = (0, debug_1.default)("electron-builder:nsis");
|
|
28
|
+
/** The member `differentialPackage: "store-asar"` keeps uncompressed in the app package, relative to the unpacked app dir. */
|
|
29
|
+
exports.STORED_ASAR_PATH = "resources/app.asar";
|
|
30
|
+
/**
|
|
31
|
+
* The `archive()` options `buildAppPackage` packages the unpacked app with, before the differential-aware
|
|
32
|
+
* adjustments of `configureDifferentialAwareArchiveOptions`. Exported so the benchmark
|
|
33
|
+
* (`test/src/differentialOneLineBenchTest.ts`) packages exactly like a real build instead of copying these.
|
|
34
|
+
*/
|
|
35
|
+
function createAppPackageArchiveOptions(compression, excluded, storedPaths) {
|
|
36
|
+
return {
|
|
37
|
+
withoutDir: true,
|
|
38
|
+
compression,
|
|
39
|
+
// The install-time Nsis7z extractor only decodes plain LZMA2/Copy and single-stream BCJ — not
|
|
40
|
+
// the CPU branch converters modern 7za applies to executables (BCJ2 on x86/x64, ARM64 on
|
|
41
|
+
// arm64), which it silently skips, dropping the main exe and every native binary from the
|
|
42
|
+
// install. Pin the payload to a filter it can decode. See #9983.
|
|
43
|
+
installTimeDecodable: true,
|
|
44
|
+
excluded,
|
|
45
|
+
storedPaths,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
27
48
|
// noinspection SpellCheckingInspection
|
|
28
49
|
const ELECTRON_BUILDER_NS_UUID = builder_util_runtime_1.UUID.parse("50e065bc-3134-11e6-9bab-38c9862bdaf3");
|
|
29
50
|
const USE_NSIS_BUILT_IN_COMPRESSOR = false;
|
|
@@ -36,6 +57,7 @@ class NsisTarget extends core_1.Target {
|
|
|
36
57
|
/** @private */
|
|
37
58
|
this.archs = new Map();
|
|
38
59
|
this.isAsyncSupported = false;
|
|
60
|
+
this.storeAsarChecked = false;
|
|
39
61
|
this.packageHelper.refCount++;
|
|
40
62
|
this.options =
|
|
41
63
|
targetName === "portable"
|
|
@@ -51,6 +73,14 @@ class NsisTarget extends core_1.Target {
|
|
|
51
73
|
if (deps != null && deps["electron-squirrel-startup"] != null) {
|
|
52
74
|
builder_util_1.log.warn('"electron-squirrel-startup" dependency is not required for NSIS');
|
|
53
75
|
}
|
|
76
|
+
if (this.options.useZip === true && !this.isZipPayload) {
|
|
77
|
+
if (this.isWebInstaller) {
|
|
78
|
+
builder_util_1.log.warn({ target: this.name, solution: "useZip only applies to the nsis and portable targets" }, "useZip is ignored because the web installer always uses a 7z package");
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
builder_util_1.log.warn({ target: this.name, solution: "set differentialPackage: false to get a zip payload" }, "useZip is ignored because differential-aware builds always use a 7z payload");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
54
84
|
}
|
|
55
85
|
get shouldBuildUniversalInstaller() {
|
|
56
86
|
const buildSeparateInstallers = this.options.buildUniversalInstaller === false;
|
|
@@ -66,32 +96,66 @@ class NsisTarget extends core_1.Target {
|
|
|
66
96
|
get isBuildDifferentialAware() {
|
|
67
97
|
return !this.isPortable && this.options.differentialPackage !== false;
|
|
68
98
|
}
|
|
99
|
+
// Single source of truth for the payload format: the archive written in buildAppPackage and the
|
|
100
|
+
// extractor selected by the ZIP_COMPRESSION / COMPRESSION_METHOD defines must never disagree.
|
|
101
|
+
// The web installer's download/extract path only handles 7z, so it never gets a zip package.
|
|
102
|
+
get isZipPayload() {
|
|
103
|
+
return !this.isWebInstaller && !this.isBuildDifferentialAware && this.options.useZip === true;
|
|
104
|
+
}
|
|
105
|
+
get isStoreAsar() {
|
|
106
|
+
return this.isBuildDifferentialAware && this.options.differentialPackage === "store-asar";
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Everything that makes buildAppPackage's archive differ between targets. Targets sharing an
|
|
110
|
+
* AppPackageHelper (nsis + portable) reuse one app package per arch only when this key matches,
|
|
111
|
+
* so a target never embeds an archive whose format or layout was chosen by another target.
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
get appPackageCacheKey() {
|
|
115
|
+
const options = this.options;
|
|
116
|
+
return JSON.stringify({
|
|
117
|
+
format: this.isZipPayload ? "zip" : "7z",
|
|
118
|
+
differentialAware: this.isBuildDifferentialAware,
|
|
119
|
+
storeAsar: this.isStoreAsar,
|
|
120
|
+
excluded: this.getPreCompressedFileExtensions(),
|
|
121
|
+
// mirrors CopyElevateHelper's per-target packElevateHelper / perMachine resolution
|
|
122
|
+
elevate: options.packElevateHelper !== false || options.perMachine === true,
|
|
123
|
+
blockmap: this.isBuildDifferentialAware && this.isWebInstaller,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
69
126
|
getPreCompressedFileExtensions() {
|
|
70
127
|
const result = this.isWebInstaller ? null : this.options.preCompressedFileExtensions;
|
|
71
128
|
return result == null ? null : (0, builder_util_1.asArray)(result).map(it => (it.startsWith(".") ? it : `.${it}`));
|
|
72
129
|
}
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
130
|
+
/**
|
|
131
|
+
* @private
|
|
132
|
+
* @returns the package file info plus the absolute source paths of the members stored verbatim in it
|
|
133
|
+
* (`storedMemberFiles`, empty unless `differentialPackage` is `"store-asar"`).
|
|
134
|
+
*/
|
|
135
|
+
async buildAppPackage(appOutDir, arch, elevateHelper, fileNameSuffix = "") {
|
|
76
136
|
const packager = this.packager;
|
|
77
137
|
const isBuildDifferentialAware = this.isBuildDifferentialAware;
|
|
78
|
-
const format =
|
|
79
|
-
const archiveFile = path.join(this.outDir, `${packager.appInfo.sanitizedName}-${packager.appInfo.version}-${builder_util_1.Arch[arch]}.nsis.${format}`);
|
|
138
|
+
const format = this.isZipPayload ? "zip" : "7z";
|
|
139
|
+
const archiveFile = path.join(this.outDir, `${packager.appInfo.sanitizedName}-${packager.appInfo.version}-${builder_util_1.Arch[arch]}${fileNameSuffix}.nsis.${format}`);
|
|
80
140
|
const preCompressedFileExtensions = this.getPreCompressedFileExtensions();
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
141
|
+
const isStoreAsar = this.isStoreAsar;
|
|
142
|
+
if (isStoreAsar) {
|
|
143
|
+
await this.warnIfStoreAsarHasNoAsar(appOutDir);
|
|
144
|
+
}
|
|
145
|
+
// Opt-in via differentialPackage: "store-asar" — keep the asar a byte-stable Copy member so a
|
|
146
|
+
// differential update pays only for its changed blocks instead of re-downloading the whole
|
|
147
|
+
// recompressed asar (see nsisOptions docs). The blockmap chunks these verbatim bytes finer.
|
|
148
|
+
const storedPaths = isStoreAsar ? [exports.STORED_ASAR_PATH] : null;
|
|
149
|
+
// archive() skips a stored path that does not exist (e.g. `asar: false`, warned about above), so
|
|
150
|
+
// only the members that really end up in the package are located in it for the block map.
|
|
151
|
+
const storedMemberFiles = [];
|
|
152
|
+
for (const storedPath of storedPaths !== null && storedPaths !== void 0 ? storedPaths : []) {
|
|
153
|
+
const memberFile = path.join(appOutDir, storedPath);
|
|
154
|
+
if (await (0, builder_util_1.exists)(memberFile)) {
|
|
155
|
+
storedMemberFiles.push(memberFile);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const archiveOptions = createAppPackageArchiveOptions(packager.compression, preCompressedFileExtensions == null ? null : preCompressedFileExtensions.map(it => `*${it}`), storedPaths);
|
|
95
159
|
const timer = (0, timer_1.time)(`nsis package, ${builder_util_1.Arch[arch]}`);
|
|
96
160
|
await (0, archive_1.archive)(format, archiveFile, appOutDir, isBuildDifferentialAware ? (0, differentialUpdateInfoBuilder_1.configureDifferentialAwareArchiveOptions)(archiveOptions) : archiveOptions);
|
|
97
161
|
timer.end();
|
|
@@ -104,15 +168,38 @@ class NsisTarget extends core_1.Target {
|
|
|
104
168
|
await elevateHelper.addToArchive(archiveFile, this, format, archiveOptions, appOutDir);
|
|
105
169
|
}
|
|
106
170
|
if (isBuildDifferentialAware && this.isWebInstaller) {
|
|
107
|
-
const
|
|
171
|
+
const regions = await (0, differentialUpdateInfoBuilder_1.locateStoredMemberRegions)(archiveFile, storedMemberFiles);
|
|
172
|
+
const data = await (0, differentialUpdateInfoBuilder_1.appendBlockmap)(archiveFile, (0, differentialUpdateInfoBuilder_1.toBlockMapOptions)(regions));
|
|
108
173
|
return {
|
|
109
|
-
|
|
110
|
-
|
|
174
|
+
fileInfo: {
|
|
175
|
+
...data,
|
|
176
|
+
path: archiveFile,
|
|
177
|
+
},
|
|
178
|
+
storedMemberFiles,
|
|
111
179
|
};
|
|
112
180
|
}
|
|
113
181
|
else {
|
|
114
|
-
return await createPackageFileInfo(archiveFile);
|
|
182
|
+
return { fileInfo: await createPackageFileInfo(archiveFile), storedMemberFiles };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* `archive()` silently skips stored paths that don't exist, so without an asar (e.g. `asar: false`)
|
|
187
|
+
* "store-asar" would do nothing unnoticed. The fallback is harmless — the differential package is
|
|
188
|
+
* non-solid, so each unpacked file is already its own block — but say so once per target.
|
|
189
|
+
* @private
|
|
190
|
+
*/
|
|
191
|
+
async warnIfStoreAsarHasNoAsar(appOutDir) {
|
|
192
|
+
// every arch is packaged with the same asar setting, so checking the first one is enough (and
|
|
193
|
+
// flagging before the await keeps concurrent per-arch packaging from warning twice)
|
|
194
|
+
if (this.storeAsarChecked) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
this.storeAsarChecked = true;
|
|
198
|
+
const asarFile = path.join(appOutDir, exports.STORED_ASAR_PATH);
|
|
199
|
+
if (await (0, builder_util_1.exists)(asarFile)) {
|
|
200
|
+
return;
|
|
115
201
|
}
|
|
202
|
+
builder_util_1.log.warn({ reason: `${exports.STORED_ASAR_PATH} not found (e.g. asar is disabled)`, file: builder_util_1.log.filePath(asarFile) }, 'differentialPackage "store-asar" has no effect, the app package is compressed normally');
|
|
116
203
|
}
|
|
117
204
|
installerFilenamePattern(primaryArch, defaultArch) {
|
|
118
205
|
const setupText = this.isPortable ? "" : "Setup ";
|
|
@@ -216,6 +303,8 @@ class NsisTarget extends core_1.Target {
|
|
|
216
303
|
}
|
|
217
304
|
}
|
|
218
305
|
const packageFiles = {};
|
|
306
|
+
// stored (Copy) members of every arch package, to be located in the installer for its block map
|
|
307
|
+
const storedMemberFiles = [];
|
|
219
308
|
let estimatedSize = 0;
|
|
220
309
|
if (this.isPortable && options.useZip) {
|
|
221
310
|
for (const [arch, dir] of archs.entries()) {
|
|
@@ -228,7 +317,8 @@ class NsisTarget extends core_1.Target {
|
|
|
228
317
|
}
|
|
229
318
|
else {
|
|
230
319
|
await Promise.all(Array.from(archs.keys()).map(async (arch) => {
|
|
231
|
-
const { fileInfo, unpackedSize } = await this.packageHelper.packArch(arch, this);
|
|
320
|
+
const { fileInfo, unpackedSize, storedMemberFiles: archStoredMemberFiles } = await this.packageHelper.packArch(arch, this);
|
|
321
|
+
storedMemberFiles.push(...archStoredMemberFiles);
|
|
232
322
|
const file = fileInfo.path;
|
|
233
323
|
const defineKey = arch === builder_util_1.Arch.x64 ? "APP_64" : arch === builder_util_1.Arch.arm64 ? "APP_ARM64" : "APP_32";
|
|
234
324
|
defines[defineKey] = file;
|
|
@@ -323,7 +413,10 @@ class NsisTarget extends core_1.Target {
|
|
|
323
413
|
updateInfo = (0, differentialUpdateInfoBuilder_1.createNsisWebDifferentialUpdateInfo)(installerPath, packageFiles);
|
|
324
414
|
}
|
|
325
415
|
else if (this.isBuildDifferentialAware) {
|
|
326
|
-
|
|
416
|
+
// Every arch package is embedded verbatim in the installer (SetCompress off), so the stored
|
|
417
|
+
// members of all of them sit verbatim in the signed installer too; locate them there.
|
|
418
|
+
const regions = await (0, differentialUpdateInfoBuilder_1.locateStoredMemberRegions)(installerPath, storedMemberFiles);
|
|
419
|
+
updateInfo = await (0, differentialUpdateInfoBuilder_1.createBlockmap)(installerPath, this, packager, safeArtifactName, (0, differentialUpdateInfoBuilder_1.toBlockMapOptions)(regions));
|
|
327
420
|
}
|
|
328
421
|
if (updateInfo != null && isPerMachine && (oneClick || options.packElevateHelper)) {
|
|
329
422
|
updateInfo.isAdminRightsRequired = true;
|
|
@@ -519,11 +612,10 @@ class NsisTarget extends core_1.Target {
|
|
|
519
612
|
defines.APP_INSTALLER_STORE_FILE = `${appInfo.updaterCacheDirName}\\${builder_util_runtime_1.CURRENT_APP_INSTALLER_FILE_NAME}`;
|
|
520
613
|
}
|
|
521
614
|
if (!this.isWebInstaller && defines.APP_BUILD_DIR == null) {
|
|
522
|
-
|
|
523
|
-
if (options.useZip) {
|
|
615
|
+
if (this.isZipPayload) {
|
|
524
616
|
defines.ZIP_COMPRESSION = null;
|
|
525
617
|
}
|
|
526
|
-
defines.COMPRESSION_METHOD =
|
|
618
|
+
defines.COMPRESSION_METHOD = this.isZipPayload ? "zip" : "7z";
|
|
527
619
|
}
|
|
528
620
|
}
|
|
529
621
|
async executeMakensis(defines, commands, script, opts = {}) {
|