app-builder-lib 27.0.0-alpha.12 → 27.0.0-alpha.14
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/asar/asarUtil.js +1 -1
- package/dist/asar/asarUtil.js.map +1 -1
- package/dist/codeSign/certInfo.d.ts +4 -1
- package/dist/codeSign/certInfo.d.ts.map +1 -1
- package/dist/codeSign/certInfo.js +5 -3
- package/dist/codeSign/certInfo.js.map +1 -1
- package/dist/codeSign/forceCodeSigning.d.ts +22 -0
- package/dist/codeSign/forceCodeSigning.d.ts.map +1 -0
- package/dist/codeSign/forceCodeSigning.js +18 -0
- package/dist/codeSign/forceCodeSigning.js.map +1 -0
- package/dist/codeSign/mac/macCodeSign.d.ts +13 -1
- package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
- package/dist/codeSign/mac/macCodeSign.js +29 -2
- package/dist/codeSign/mac/macCodeSign.js.map +1 -1
- package/dist/codeSign/mac/macSignatureVerifier.d.ts +23 -0
- package/dist/codeSign/mac/macSignatureVerifier.d.ts.map +1 -0
- package/dist/codeSign/mac/macSignatureVerifier.js +96 -0
- package/dist/codeSign/mac/macSignatureVerifier.js.map +1 -0
- package/dist/codeSign/win/authenticodeSignature.d.ts +14 -2
- package/dist/codeSign/win/authenticodeSignature.d.ts.map +1 -1
- package/dist/codeSign/win/authenticodeSignature.js +78 -30
- package/dist/codeSign/win/authenticodeSignature.js.map +1 -1
- package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -1
- package/dist/codeSign/win/pkcs11SignManager.js +4 -3
- package/dist/codeSign/win/pkcs11SignManager.js.map +1 -1
- package/dist/codeSign/win/publisherName.d.ts +31 -0
- package/dist/codeSign/win/publisherName.d.ts.map +1 -0
- package/dist/codeSign/win/publisherName.js +78 -0
- package/dist/codeSign/win/publisherName.js.map +1 -0
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts +16 -9
- package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
- package/dist/codeSign/win/signtoolBaseSignManager.js +46 -35
- package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
- package/dist/codeSign/win/verifyUpdatePublisher.d.ts.map +1 -1
- package/dist/codeSign/win/verifyUpdatePublisher.js +7 -4
- package/dist/codeSign/win/verifyUpdatePublisher.js.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.d.ts +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
- package/dist/codeSign/win/windowsSignAzureManager.js +24 -6
- package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
- package/dist/configuration.d.ts +93 -4
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/electron/mac/asarIntegrityDigest.js +2 -2
- package/dist/electron/mac/asarIntegrityDigest.js.map +1 -1
- package/dist/electron/mac/electronMacUtils.d.ts +3 -2
- package/dist/electron/mac/electronMacUtils.d.ts.map +1 -1
- package/dist/electron/mac/electronMacUtils.js +3 -2
- package/dist/electron/mac/electronMacUtils.js.map +1 -1
- package/dist/fileMatcher.d.ts.map +1 -1
- package/dist/fileMatcher.js +4 -2
- package/dist/fileMatcher.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/indexInternal.d.ts +7 -2
- package/dist/indexInternal.d.ts.map +1 -1
- package/dist/indexInternal.js +6 -2
- package/dist/indexInternal.js.map +1 -1
- package/dist/linuxPackager.js +1 -1
- package/dist/linuxPackager.js.map +1 -1
- package/dist/macPackager.d.ts +26 -0
- package/dist/macPackager.d.ts.map +1 -1
- package/dist/macPackager.js +168 -12
- package/dist/macPackager.js.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.d.ts +19 -13
- package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
- package/dist/options/SquirrelWindowsOptions.d.ts +3 -0
- package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
- package/dist/options/SquirrelWindowsOptions.js.map +1 -1
- package/dist/options/macOptions.d.ts +7 -2
- package/dist/options/macOptions.d.ts.map +1 -1
- package/dist/options/macOptions.js.map +1 -1
- package/dist/options/winOptions.d.ts +61 -15
- package/dist/options/winOptions.d.ts.map +1 -1
- package/dist/options/winOptions.js +20 -0
- package/dist/options/winOptions.js.map +1 -1
- package/dist/packager.d.ts +7 -0
- package/dist/packager.d.ts.map +1 -1
- package/dist/packager.js +21 -5
- package/dist/packager.js.map +1 -1
- package/dist/platformPackager.d.ts +14 -5
- package/dist/platformPackager.d.ts.map +1 -1
- package/dist/platformPackager.js +44 -13
- package/dist/platformPackager.js.map +1 -1
- package/dist/publish/PublishManager.d.ts +3 -0
- package/dist/publish/PublishManager.d.ts.map +1 -1
- package/dist/publish/PublishManager.js +50 -16
- package/dist/publish/PublishManager.js.map +1 -1
- package/dist/publish/manifestUploadCheck.d.ts +10 -0
- package/dist/publish/manifestUploadCheck.d.ts.map +1 -0
- package/dist/publish/manifestUploadCheck.js +75 -0
- package/dist/publish/manifestUploadCheck.js.map +1 -0
- package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
- package/dist/publish/updateInfoBuilder.js +58 -22
- package/dist/publish/updateInfoBuilder.js.map +1 -1
- package/dist/publish/updateManifestVerifier.d.ts +22 -0
- package/dist/publish/updateManifestVerifier.d.ts.map +1 -0
- package/dist/publish/updateManifestVerifier.js +65 -0
- package/dist/publish/updateManifestVerifier.js.map +1 -0
- package/dist/targets/ArchiveTarget.d.ts.map +1 -1
- package/dist/targets/ArchiveTarget.js +6 -2
- package/dist/targets/ArchiveTarget.js.map +1 -1
- package/dist/targets/archive.d.ts.map +1 -1
- package/dist/targets/archive.js +3 -3
- package/dist/targets/archive.js.map +1 -1
- package/dist/targets/blockmap/blockmap.d.ts +30 -0
- package/dist/targets/blockmap/blockmap.d.ts.map +1 -1
- package/dist/targets/blockmap/blockmap.js +99 -31
- package/dist/targets/blockmap/blockmap.js.map +1 -1
- package/dist/targets/blockmap/blockmapV3.d.ts +36 -0
- package/dist/targets/blockmap/blockmapV3.d.ts.map +1 -0
- package/dist/targets/blockmap/blockmapV3.js +41 -0
- package/dist/targets/blockmap/blockmapV3.js.map +1 -0
- package/dist/targets/blockmap/verbatimRange.d.ts +6 -0
- package/dist/targets/blockmap/verbatimRange.d.ts.map +1 -1
- package/dist/targets/blockmap/verbatimRange.js +11 -0
- package/dist/targets/blockmap/verbatimRange.js.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.d.ts +92 -4
- package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.js +266 -10
- package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
- package/dist/targets/linux/FlatpakTarget.js +5 -5
- package/dist/targets/linux/FlatpakTarget.js.map +1 -1
- package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
- package/dist/targets/linux/FpmTarget.js +25 -8
- package/dist/targets/linux/FpmTarget.js.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
- package/dist/targets/linux/appimage/AppImageTarget.js +6 -1
- package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
- package/dist/targets/linux/appimage/appImageUtil.js +9 -9
- package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
- package/dist/targets/linux/flatpakBundle.d.ts.map +1 -1
- package/dist/targets/linux/flatpakBundle.js +25 -20
- package/dist/targets/linux/flatpakBundle.js.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.js +22 -6
- package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
- package/dist/targets/linux/snap/snapPlugs.d.ts +2 -2
- package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -1
- package/dist/targets/linux/snap/snapPlugs.js +1 -1
- package/dist/targets/linux/snap/snapPlugs.js.map +1 -1
- package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
- package/dist/targets/linux/snap/snapcraftBuilder.js +19 -17
- package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
- package/dist/targets/mac/MacTargetHelper.d.ts +15 -3
- package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
- package/dist/targets/mac/MacTargetHelper.js +96 -13
- package/dist/targets/mac/MacTargetHelper.js.map +1 -1
- package/dist/targets/mac/pkg.d.ts.map +1 -1
- package/dist/targets/mac/pkg.js +7 -5
- package/dist/targets/mac/pkg.js.map +1 -1
- package/dist/targets/targetFactory.d.ts +1 -1
- package/dist/targets/targetFactory.d.ts.map +1 -1
- package/dist/targets/targetFactory.js +22 -0
- package/dist/targets/targetFactory.js.map +1 -1
- package/dist/targets/win/MsiTarget.d.ts +7 -0
- package/dist/targets/win/MsiTarget.d.ts.map +1 -1
- package/dist/targets/win/MsiTarget.js +140 -21
- package/dist/targets/win/MsiTarget.js.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.js +22 -8
- package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.d.ts +1 -1
- package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
- package/dist/toolsets/appimage.d.ts +3 -0
- package/dist/toolsets/appimage.d.ts.map +1 -1
- package/dist/toolsets/appimage.js +4 -1
- package/dist/toolsets/appimage.js.map +1 -1
- package/dist/toolsets/nsis.js +1 -1
- package/dist/toolsets/nsis.js.map +1 -1
- package/dist/toolsets/wine.d.ts +3 -0
- package/dist/toolsets/wine.d.ts.map +1 -1
- package/dist/toolsets/wine.js +14 -5
- package/dist/toolsets/wine.js.map +1 -1
- package/dist/toolsets/wix.d.ts +44 -0
- package/dist/toolsets/wix.d.ts.map +1 -0
- package/dist/toolsets/wix.js +91 -0
- package/dist/toolsets/wix.js.map +1 -0
- package/dist/util/appFileCopier.d.ts.map +1 -1
- package/dist/util/appFileCopier.js +9 -3
- package/dist/util/appFileCopier.js.map +1 -1
- package/dist/util/buildOutputVerifier.d.ts +40 -0
- package/dist/util/buildOutputVerifier.d.ts.map +1 -0
- package/dist/util/buildOutputVerifier.js +420 -0
- package/dist/util/buildOutputVerifier.js.map +1 -0
- package/dist/util/config/fileOptions.js +2 -2
- package/dist/util/config/fileOptions.js.map +1 -1
- package/dist/util/config/legacyConfigGuard.d.ts.map +1 -1
- package/dist/util/config/legacyConfigGuard.js +2 -2
- package/dist/util/config/legacyConfigGuard.js.map +1 -1
- package/dist/util/config/legacyOptions.d.ts +9 -2
- package/dist/util/config/legacyOptions.d.ts.map +1 -1
- package/dist/util/config/legacyOptions.js +8 -2
- package/dist/util/config/legacyOptions.js.map +1 -1
- package/dist/util/electronGet.d.ts.map +1 -1
- package/dist/util/electronGet.js +3 -1
- package/dist/util/electronGet.js.map +1 -1
- package/dist/util/electronUpdaterCompatibility.d.ts +43 -0
- package/dist/util/electronUpdaterCompatibility.d.ts.map +1 -0
- package/dist/util/electronUpdaterCompatibility.js +53 -0
- package/dist/util/electronUpdaterCompatibility.js.map +1 -0
- package/dist/util/flags.d.ts.map +1 -1
- package/dist/util/flags.js +3 -9
- package/dist/util/flags.js.map +1 -1
- package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
- package/dist/util/mac/macosIconComposer.js +6 -5
- package/dist/util/mac/macosIconComposer.js.map +1 -1
- package/dist/util/macroExpander.js +1 -1
- package/dist/util/macroExpander.js.map +1 -1
- package/dist/util/nativeBinaryVerifier.d.ts.map +1 -1
- package/dist/util/nativeBinaryVerifier.js +3 -1
- package/dist/util/nativeBinaryVerifier.js.map +1 -1
- package/dist/util/packageMetadata.js +116 -52
- package/dist/util/packageMetadata.js.map +1 -1
- package/dist/util/removedEnvVars.d.ts +2 -0
- package/dist/util/removedEnvVars.d.ts.map +1 -1
- package/dist/util/removedEnvVars.js +15 -1
- package/dist/util/removedEnvVars.js.map +1 -1
- package/dist/util/streamSpawnToFile.d.ts +3 -1
- package/dist/util/streamSpawnToFile.d.ts.map +1 -1
- package/dist/util/streamSpawnToFile.js +6 -2
- package/dist/util/streamSpawnToFile.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/vm/ParallelsVm.d.ts +10 -0
- package/dist/vm/ParallelsVm.d.ts.map +1 -1
- package/dist/vm/ParallelsVm.js +22 -8
- package/dist/vm/ParallelsVm.js.map +1 -1
- package/dist/vm/PwshVm.d.ts +0 -1
- package/dist/vm/PwshVm.d.ts.map +1 -1
- package/dist/vm/PwshVm.js +10 -15
- package/dist/vm/PwshVm.js.map +1 -1
- package/dist/vm/WineVm.d.ts.map +1 -1
- package/dist/vm/WineVm.js +4 -4
- package/dist/vm/WineVm.js.map +1 -1
- package/dist/vm/vm.d.ts +9 -3
- package/dist/vm/vm.d.ts.map +1 -1
- package/dist/vm/vm.js +40 -32
- package/dist/vm/vm.js.map +1 -1
- package/dist/winPackager.d.ts +16 -1
- package/dist/winPackager.d.ts.map +1 -1
- package/dist/winPackager.js +77 -19
- package/dist/winPackager.js.map +1 -1
- package/package.json +9 -9
- package/scheme.json +542 -29
- package/templates/msi/template.xml +5 -5
- package/templates/msiWrapped/template.xml +1 -1
- package/templates/nsis/assistedInstaller.nsh +32 -1
- package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +14 -9
- package/dist/vm/MonoVm.d.ts +0 -9
- package/dist/vm/MonoVm.d.ts.map +0 -1
- package/dist/vm/MonoVm.js +0 -16
- package/dist/vm/MonoVm.js.map +0 -1
|
@@ -1,8 +1,61 @@
|
|
|
1
|
-
import { exists, log } from "builder-util";
|
|
1
|
+
import { exists, InvalidConfigurationError, log } from "builder-util";
|
|
2
|
+
import { open, stat } from "fs/promises";
|
|
2
3
|
import * as path from "path";
|
|
4
|
+
import * as zlib from "zlib";
|
|
5
|
+
import { readAsarHeader } from "../asar/asar.js";
|
|
6
|
+
import { BINARY_BLOCK_MAP_MIN_UPDATER, BLOCK_MAP_FORMAT_DOCS_URL, isBinaryBlockMapSupported, resolveElectronUpdaterCompatibility } from "../util/electronUpdaterCompatibility.js";
|
|
3
7
|
import { buildBlockMap } from "./blockmap/blockmap.js";
|
|
4
|
-
import {
|
|
8
|
+
import { buildBlockMapV3 } from "./blockmap/blockmapV3.js";
|
|
9
|
+
import { findPreparedVerbatimRange, prepareVerbatimNeedle, prepareVerbatimNeedleFromBuffer } from "./blockmap/verbatimRange.js";
|
|
5
10
|
export const BLOCK_MAP_FILE_SUFFIX = ".blockmap";
|
|
11
|
+
/** The binary format: the default when `electronUpdaterCompatibility` allows it. */
|
|
12
|
+
export const BINARY_BLOCK_MAP_FORMAT = "v3";
|
|
13
|
+
/** The newest format electron-builder writes, what `blockmap: "latest"` selects when `electronUpdaterCompatibility` allows it. */
|
|
14
|
+
export const LATEST_BLOCK_MAP_FORMAT = "v3";
|
|
15
|
+
/**
|
|
16
|
+
* The format of the `.blockmap` files of a build. The map is read by the updater already installed in the users' apps, which
|
|
17
|
+
* `electronUpdaterCompatibility` describes, so:
|
|
18
|
+
*
|
|
19
|
+
* - unset: the binary format when the range allows only electron-updater 7 and later, else the JSON format (with a warning);
|
|
20
|
+
* - `"latest"`: the newest format the range allows (today the same; unlike unset, it follows future formats);
|
|
21
|
+
* - `"v2"`: the JSON format;
|
|
22
|
+
* - `"v3"`: the binary format, which fails the build when the range includes electron-updater versions that cannot read it.
|
|
23
|
+
*/
|
|
24
|
+
export function resolveBlockMapFormat(value, electronUpdaterCompatibility) {
|
|
25
|
+
if (value != null && value !== "latest" && value !== "v2" && value !== "v3") {
|
|
26
|
+
throw new InvalidConfigurationError(`"blockmap" must be "v2", "v3" or "latest", got ${JSON.stringify(value)}`);
|
|
27
|
+
}
|
|
28
|
+
const binarySupported = isBinaryBlockMapSupported(electronUpdaterCompatibility);
|
|
29
|
+
if (value === "v2") {
|
|
30
|
+
return "v2";
|
|
31
|
+
}
|
|
32
|
+
if (value === "v3") {
|
|
33
|
+
if (!binarySupported) {
|
|
34
|
+
throw new InvalidConfigurationError(`blockmap "v3" (the binary block map) needs electron-updater ${BINARY_BLOCK_MAP_MIN_UPDATER} or later in the installed apps, but electronUpdaterCompatibility ` +
|
|
35
|
+
`"${electronUpdaterCompatibility}" includes earlier versions. Raise electronUpdaterCompatibility to ">=7" once your installed apps ship electron-updater 7, ` +
|
|
36
|
+
`or set blockmap to "v2". See ${BLOCK_MAP_FORMAT_DOCS_URL}`);
|
|
37
|
+
}
|
|
38
|
+
return "v3";
|
|
39
|
+
}
|
|
40
|
+
if (!binarySupported) {
|
|
41
|
+
warnAboutJsonBlockMap(electronUpdaterCompatibility);
|
|
42
|
+
return "v2";
|
|
43
|
+
}
|
|
44
|
+
return value === "latest" ? LATEST_BLOCK_MAP_FORMAT : BINARY_BLOCK_MAP_FORMAT;
|
|
45
|
+
}
|
|
46
|
+
/** The format of the `.blockmap` files `packager` writes. */
|
|
47
|
+
export function getBlockMapFormat(packager) {
|
|
48
|
+
return resolveBlockMapFormat(packager.config.blockmap, resolveElectronUpdaterCompatibility(packager.platformOptions, packager.config));
|
|
49
|
+
}
|
|
50
|
+
function warnAboutJsonBlockMap(electronUpdaterCompatibility) {
|
|
51
|
+
// once per process — a build resolves the format per artifact
|
|
52
|
+
log.once("json-block-map").warn({
|
|
53
|
+
electronUpdaterCompatibility,
|
|
54
|
+
solution: `raise electronUpdaterCompatibility to ">=7" once your installed apps ship electron-updater ${BINARY_BLOCK_MAP_MIN_UPDATER}`,
|
|
55
|
+
docs: BLOCK_MAP_FORMAT_DOCS_URL,
|
|
56
|
+
}, `electron-builder v27 writes binary block maps, which electron-updater fetches in parts, but electronUpdaterCompatibility includes electron-updater ` +
|
|
57
|
+
`versions before ${BINARY_BLOCK_MAP_MIN_UPDATER}, which cannot read them: this build writes JSON block maps, downloaded in full on every update`);
|
|
58
|
+
}
|
|
6
59
|
/**
|
|
7
60
|
* Chunker parameters for a stored (`Copy`) archive member — e.g. `resources/app.asar` when
|
|
8
61
|
* `nsis.differentialPackage` is `"store-asar"` — whose bytes sit verbatim in the artifact. Such a member
|
|
@@ -15,6 +68,149 @@ export const BLOCK_MAP_FILE_SUFFIX = ".blockmap";
|
|
|
15
68
|
* in full on every update) grows faster than the block savings. `avg` must stay a power of two.
|
|
16
69
|
*/
|
|
17
70
|
export const STORED_MEMBER_CHUNKER = { min: 4096, avg: 8192, max: 16384 };
|
|
71
|
+
/**
|
|
72
|
+
* `STORED_MEMBER_CHUNKER` counterpart for the `blockmap: "v3"` format (the v3 map of `blockMapV3.ts`). A v3 map costs
|
|
73
|
+
* ~10 B per block in the file but an updater fetches only the super-groups, groups and records that
|
|
74
|
+
* changed, so the v2 trade-off (a finer chunker inflating a map that is re-downloaded in full) no longer
|
|
75
|
+
* applies and the stored member can be chunked at 512 B / 1 KiB / 2 KiB: a one-line change then costs
|
|
76
|
+
* one or two small blocks plus a few KB of map. `max` must fit a v3 record's 16-bit block size.
|
|
77
|
+
*/
|
|
78
|
+
export const STORED_MEMBER_CHUNKER_V3 = { min: 512, avg: 1024, max: 2048 };
|
|
79
|
+
/**
|
|
80
|
+
* Chunker of the 7z archive header region (`locateArchiveHeaderRegions`). The header of a differential
|
|
81
|
+
* package is stored uncompressed (`configureDifferentialAwareArchiveOptions`) and is a few hundred bytes
|
|
82
|
+
* to a few KB: file names, sizes and CRCs. Between two releases only the CRCs and sizes of the changed
|
|
83
|
+
* members differ, but a compressed header re-encodes entirely and the trailing block of the package
|
|
84
|
+
* (up to 32 KiB with the default chunker) was re-downloaded on every update. Cutting the header into
|
|
85
|
+
* its own small blocks makes that cost the header's few hundred bytes.
|
|
86
|
+
*/
|
|
87
|
+
export const ARCHIVE_HEADER_CHUNKER = { min: 256, avg: 512, max: 1024 };
|
|
88
|
+
const SEVEN_ZIP_SIGNATURE = Buffer.from([0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c]);
|
|
89
|
+
const SEVEN_ZIP_SIGNATURE_HEADER_SIZE = 32;
|
|
90
|
+
/** First byte of a 7z header stored as is (`kHeader`); a compressed header starts with `kEncodedHeader` (0x17). */
|
|
91
|
+
const SEVEN_ZIP_HEADER_ID = 0x01;
|
|
92
|
+
async function readBytes(file, position, length) {
|
|
93
|
+
const handle = await open(file, "r");
|
|
94
|
+
try {
|
|
95
|
+
const buffer = Buffer.alloc(length);
|
|
96
|
+
const { bytesRead } = await handle.read(buffer, 0, length, position);
|
|
97
|
+
return bytesRead === length ? buffer : null;
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
await handle.close();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Locates the header of each 7z `archiveFiles` inside `artifact` (the archive itself, or an installer
|
|
105
|
+
* that embeds it verbatim) and returns an `ARCHIVE_HEADER_CHUNKER` region per located header, sorted by
|
|
106
|
+
* offset. The 32-byte 7z signature header names the header's offset and size; the signature header is
|
|
107
|
+
* found verbatim in the artifact (its CRCs make it unique, and byte-identical archives are matched to
|
|
108
|
+
* their own copies). An archive whose header is compressed, or that cannot be found, yields no region
|
|
109
|
+
* and is logged at debug/warn — the block map then falls back to the default chunker for those bytes.
|
|
110
|
+
*/
|
|
111
|
+
export async function locateArchiveHeaderRegions(artifact, archiveFiles) {
|
|
112
|
+
const regions = [];
|
|
113
|
+
const claimed = [];
|
|
114
|
+
const resumeOffsetByHash = new Map();
|
|
115
|
+
for (const archiveFile of archiveFiles) {
|
|
116
|
+
const signature = (await exists(archiveFile)) ? await readBytes(archiveFile, 0, SEVEN_ZIP_SIGNATURE_HEADER_SIZE) : null;
|
|
117
|
+
if (signature == null || !signature.subarray(0, SEVEN_ZIP_SIGNATURE.length).equals(SEVEN_ZIP_SIGNATURE)) {
|
|
118
|
+
log.debug({ artifact: log.filePath(artifact), archive: log.filePath(archiveFile) }, "not a 7z archive; no block map region for its header");
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
// StartHeaderCRC (bytes 8-11) covers the next header's offset, size and CRC (bytes 12-31): an archive that fails it is not
|
|
122
|
+
// what 7-Zip wrote, and its offset and size must not become a block map region
|
|
123
|
+
if (zlib.crc32(signature.subarray(12, SEVEN_ZIP_SIGNATURE_HEADER_SIZE)) !== signature.readUInt32LE(8)) {
|
|
124
|
+
log.warn({
|
|
125
|
+
artifact: log.filePath(artifact),
|
|
126
|
+
archive: log.filePath(archiveFile),
|
|
127
|
+
}, "7z start header CRC mismatch; no block map region for the archive header");
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const headerOffset = SEVEN_ZIP_SIGNATURE_HEADER_SIZE + Number(signature.readBigUInt64LE(12));
|
|
131
|
+
const headerSize = Number(signature.readBigUInt64LE(20));
|
|
132
|
+
if (headerSize === 0) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
let start = 0;
|
|
136
|
+
if (path.resolve(artifact) !== path.resolve(archiveFile)) {
|
|
137
|
+
const needle = prepareVerbatimNeedleFromBuffer(signature, `${path.basename(archiveFile)} signature header`);
|
|
138
|
+
const range = await findUnclaimedVerbatimRange(artifact, needle, claimed, resumeOffsetByHash.get(needle.hash) ?? 0);
|
|
139
|
+
if (range == null) {
|
|
140
|
+
log.warn({ artifact: log.filePath(artifact), archive: log.filePath(archiveFile) }, "archive not found verbatim in artifact; no block map region for its header");
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
resumeOffsetByHash.set(needle.hash, range.offset + range.size);
|
|
144
|
+
claimed.push({ ...range, chunker: ARCHIVE_HEADER_CHUNKER });
|
|
145
|
+
start = range.offset;
|
|
146
|
+
}
|
|
147
|
+
// a region past the end of the artifact would fail the whole block map; without it, only the header's finer chunking is lost
|
|
148
|
+
if (start + headerOffset + headerSize > (await stat(artifact)).size) {
|
|
149
|
+
log.warn({
|
|
150
|
+
artifact: log.filePath(artifact),
|
|
151
|
+
archive: log.filePath(archiveFile),
|
|
152
|
+
offset: start + headerOffset,
|
|
153
|
+
size: headerSize,
|
|
154
|
+
}, "7z header extends past the end of the artifact; no block map region for it");
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const first = await readBytes(artifact, start + headerOffset, 1);
|
|
158
|
+
if (first == null || first[0] !== SEVEN_ZIP_HEADER_ID) {
|
|
159
|
+
log.debug({ artifact: log.filePath(artifact), archive: log.filePath(archiveFile) }, "archive header is compressed; no block map region for it");
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
log.info({ artifact: log.filePath(artifact), archive: log.filePath(archiveFile), offset: start + headerOffset, size: headerSize }, "located archive header region for block map");
|
|
163
|
+
regions.push({ offset: start + headerOffset, size: headerSize, chunker: ARCHIVE_HEADER_CHUNKER });
|
|
164
|
+
}
|
|
165
|
+
return regions.sort((a, b) => a.offset - b.offset);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Forced v3 block boundaries for the stored members that are asar archives: the start of the content
|
|
169
|
+
* region and of every packed file in it (from the asar header's offsets), as absolute artifact offsets.
|
|
170
|
+
* With these cuts a change inside one file never alters a block that also covers its neighbour, so an
|
|
171
|
+
* in-place edit costs its own blocks only. Members that are not asars contribute nothing.
|
|
172
|
+
*/
|
|
173
|
+
export async function asarContentBoundaries(members) {
|
|
174
|
+
const boundaries = new Set();
|
|
175
|
+
for (const { file, region } of members) {
|
|
176
|
+
let header;
|
|
177
|
+
let headerSize;
|
|
178
|
+
try {
|
|
179
|
+
;
|
|
180
|
+
({ header, size: headerSize } = await readAsarHeader(file));
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
log.debug({ member: log.filePath(file), reason: e.message }, "stored member is not an asar; no forced block boundaries for it");
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const contentStart = region.offset + 8 + headerSize;
|
|
187
|
+
const regionEnd = region.offset + region.size;
|
|
188
|
+
const collect = (node) => {
|
|
189
|
+
for (const child of Object.values(node.files ?? {})) {
|
|
190
|
+
if (child.files != null) {
|
|
191
|
+
collect(child);
|
|
192
|
+
}
|
|
193
|
+
else if (child.offset != null && !child.unpacked && child.link == null) {
|
|
194
|
+
const boundary = contentStart + parseInt(child.offset, 10);
|
|
195
|
+
if (boundary > region.offset && boundary < regionEnd) {
|
|
196
|
+
boundaries.add(boundary);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
try {
|
|
202
|
+
collect(JSON.parse(header));
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
log.debug({ member: log.filePath(file), reason: e.message }, "stored member has no parsable asar header; no forced block boundaries for it");
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (contentStart < regionEnd) {
|
|
209
|
+
boundaries.add(contentStart);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return [...boundaries].sort((a, b) => a - b);
|
|
213
|
+
}
|
|
18
214
|
/**
|
|
19
215
|
* Locates each of `memberFiles` (absolute paths of files stored verbatim inside `artifact`) and returns
|
|
20
216
|
* a `STORED_MEMBER_CHUNKER` blockmap region per located file, sorted by offset. The regions never
|
|
@@ -23,8 +219,16 @@ export const STORED_MEMBER_CHUNKER = { min: 4096, avg: 8192, max: 16384 };
|
|
|
23
219
|
* earlier member is skipped. A member file that does not exist, or that cannot be found verbatim, is
|
|
24
220
|
* logged at warn and skipped — the blockmap then falls back to the default chunker for those bytes;
|
|
25
221
|
* it never fails the build.
|
|
222
|
+
*
|
|
223
|
+
* The returned regions are the v2 regions; `toV3Regions` derives the v3 regions (same byte ranges,
|
|
224
|
+
* `STORED_MEMBER_CHUNKER_V3`) from them, so both maps are built from the same located ranges.
|
|
26
225
|
*/
|
|
27
226
|
export async function locateStoredMemberRegions(artifact, memberFiles) {
|
|
227
|
+
return (await locateStoredMembers(artifact, memberFiles)).map(it => it.region);
|
|
228
|
+
}
|
|
229
|
+
/** `locateStoredMemberRegions` keeping which member each region belongs to (for `asarContentBoundaries`). */
|
|
230
|
+
export async function locateStoredMembers(artifact, memberFiles) {
|
|
231
|
+
const members = [];
|
|
28
232
|
const regions = [];
|
|
29
233
|
// Byte-identical members have identical occurrences, and the copies are claimed in ascending order,
|
|
30
234
|
// so the scan for the next member with the same content resumes where its previous copy ended instead
|
|
@@ -43,9 +247,11 @@ export async function locateStoredMemberRegions(artifact, memberFiles) {
|
|
|
43
247
|
}
|
|
44
248
|
resumeOffsetByHash.set(needle.hash, range.offset + range.size);
|
|
45
249
|
log.info({ artifact: log.filePath(artifact), member: log.filePath(memberFile), offset: range.offset, size: range.size }, "located stored member region for block map");
|
|
46
|
-
|
|
250
|
+
const region = { ...range, chunker: STORED_MEMBER_CHUNKER };
|
|
251
|
+
regions.push(region);
|
|
252
|
+
members.push({ file: memberFile, region });
|
|
47
253
|
}
|
|
48
|
-
return
|
|
254
|
+
return members.sort((a, b) => a.region.offset - b.region.offset);
|
|
49
255
|
}
|
|
50
256
|
/**
|
|
51
257
|
* The first occurrence of `needle` in `artifact` at or after `startOffset` that does not overlap a
|
|
@@ -67,9 +273,39 @@ async function findUnclaimedVerbatimRange(artifact, needle, claimed, startOffset
|
|
|
67
273
|
startOffset = clash.offset + clash.size;
|
|
68
274
|
}
|
|
69
275
|
}
|
|
70
|
-
/**
|
|
71
|
-
export function toBlockMapOptions(regions) {
|
|
72
|
-
|
|
276
|
+
/** Options for `appendBlockmap` / `createBlockmap` from located regions (any order) and optional v3 boundaries. */
|
|
277
|
+
export function toBlockMapOptions(regions, v3Boundaries) {
|
|
278
|
+
if (regions.length === 0 && (v3Boundaries == null || v3Boundaries.length === 0)) {
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
const options = { regions: [...regions].sort((a, b) => a.offset - b.offset) };
|
|
282
|
+
if (v3Boundaries != null && v3Boundaries.length > 0) {
|
|
283
|
+
options.v3Boundaries = v3Boundaries;
|
|
284
|
+
}
|
|
285
|
+
return options;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Block map options of an installer that embeds its app packages verbatim: the regions of their stored `members` and, for the
|
|
289
|
+
* binary format only, those of the 7z headers of `archiveFiles` and a block boundary at every packed file of a stored asar. The
|
|
290
|
+
* JSON format uses neither, so its build does not read them.
|
|
291
|
+
*/
|
|
292
|
+
export async function installerBlockMapOptions(installerPath, members, archiveFiles, format) {
|
|
293
|
+
const regions = members.map(it => it.region);
|
|
294
|
+
if (format !== BINARY_BLOCK_MAP_FORMAT) {
|
|
295
|
+
return toBlockMapOptions(regions);
|
|
296
|
+
}
|
|
297
|
+
return toBlockMapOptions([...regions, ...(await locateArchiveHeaderRegions(installerPath, archiveFiles))], await asarContentBoundaries(members));
|
|
298
|
+
}
|
|
299
|
+
function isSameChunker(a, b) {
|
|
300
|
+
return a.min === b.min && a.avg === b.avg && a.max === b.max;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The v3 block map regions for the v2 `regions` (as returned by `locateStoredMemberRegions`): the same
|
|
304
|
+
* byte ranges, with `STORED_MEMBER_CHUNKER` swapped for `STORED_MEMBER_CHUNKER_V3`. Regions with any
|
|
305
|
+
* other chunker are kept as they are (a caller that chose its own parameters gets them in both maps).
|
|
306
|
+
*/
|
|
307
|
+
export function toV3Regions(regions) {
|
|
308
|
+
return (regions ?? []).map(region => (isSameChunker(region.chunker, STORED_MEMBER_CHUNKER) ? { ...region, chunker: STORED_MEMBER_CHUNKER_V3 } : region));
|
|
73
309
|
}
|
|
74
310
|
export function createNsisWebDifferentialUpdateInfo(artifactPath, packageFiles) {
|
|
75
311
|
if (packageFiles == null) {
|
|
@@ -92,7 +328,11 @@ export function createNsisWebDifferentialUpdateInfo(artifactPath, packageFiles)
|
|
|
92
328
|
}
|
|
93
329
|
return { packages };
|
|
94
330
|
}
|
|
95
|
-
|
|
331
|
+
/**
|
|
332
|
+
* `storeArchiveHeader`: whether the 7z header is stored as is, for a build whose block map chunks it finely (the binary format,
|
|
333
|
+
* see `locateArchiveHeaderRegions`). With the JSON format the package stays byte-for-byte what earlier versions wrote.
|
|
334
|
+
*/
|
|
335
|
+
export function configureDifferentialAwareArchiveOptions(archiveOptions, storeArchiveHeader) {
|
|
96
336
|
/*
|
|
97
337
|
* dict size 64 MB: Full: 33,744.88 KB, To download: 17,630.3 KB (52%)
|
|
98
338
|
* dict size 16 MB: Full: 33,936.84 KB, To download: 16,175.9 KB (48%)
|
|
@@ -123,6 +363,12 @@ export function configureDifferentialAwareArchiveOptions(archiveOptions) {
|
|
|
123
363
|
archiveOptions.solid = false;
|
|
124
364
|
// do not allow to change compression level to avoid different packages
|
|
125
365
|
archiveOptions.compression = "normal";
|
|
366
|
+
// store the archive header as is: a compressed header re-encodes entirely when a single CRC changes,
|
|
367
|
+
// so every update re-downloaded the trailing block of the package; stored, only the changed CRCs and
|
|
368
|
+
// sizes differ and `locateArchiveHeaderRegions` chunks the header finely (ARCHIVE_HEADER_CHUNKER)
|
|
369
|
+
if (storeArchiveHeader) {
|
|
370
|
+
archiveOptions.isArchiveHeaderCompressed = false;
|
|
371
|
+
}
|
|
126
372
|
return archiveOptions;
|
|
127
373
|
}
|
|
128
374
|
export async function appendBlockmap(file, options) {
|
|
@@ -130,9 +376,19 @@ export async function appendBlockmap(file, options) {
|
|
|
130
376
|
return buildBlockMap(file, "deflate", undefined, options);
|
|
131
377
|
}
|
|
132
378
|
export async function createBlockmap(file, target, packager, safeArtifactName, arch = null, options) {
|
|
379
|
+
const format = getBlockMapFormat(packager);
|
|
133
380
|
const blockMapFile = `${file}${BLOCK_MAP_FILE_SUFFIX}`;
|
|
134
|
-
log.info({ blockMapFile: log.filePath(blockMapFile) }, "building block map");
|
|
135
|
-
|
|
381
|
+
log.info({ blockMapFile: log.filePath(blockMapFile), format }, "building block map");
|
|
382
|
+
let updateInfo;
|
|
383
|
+
if (format === "v2") {
|
|
384
|
+
updateInfo = await buildBlockMap(file, "gzip", blockMapFile, options == null ? undefined : { regions: options.regions });
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
// the stored members get the finer v2 chunker, and a stored asar a block boundary at every packed file
|
|
388
|
+
const built = await buildBlockMapV3(file, blockMapFile, { regions: toV3Regions(options?.regions), boundaries: options?.v3Boundaries });
|
|
389
|
+
log.debug({ blockMapFile: log.filePath(blockMapFile), blocks: built.blockCount, groups: built.groupCount }, "built block map");
|
|
390
|
+
updateInfo = { size: built.size, sha512: built.sha512 };
|
|
391
|
+
}
|
|
136
392
|
await packager.emitArtifactBuildCompleted({
|
|
137
393
|
file: blockMapFile,
|
|
138
394
|
safeArtifactName: safeArtifactName == null ? null : `${safeArtifactName}${BLOCK_MAP_FILE_SUFFIX}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"differentialUpdateInfoBuilder.js","sourceRoot":"","sources":["../../src/targets/differentialUpdateInfoBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAI5B,OAAO,EAAkB,aAAa,EAAuC,MAAM,wBAAwB,CAAA;AAC3G,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAiC,MAAM,6BAA6B,CAAA;AAE7H,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAA;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAkB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AAExF;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,QAAgB,EAAE,WAA0B;IAC1F,MAAM,OAAO,GAA0B,EAAE,CAAA;IACzC,oGAAoG;IACpG,sGAAsG;IACtG,uFAAuF;IACvF,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAA;IACpD,KAAK,MAAM,UAAU,IAAI,WAAW,E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qBAAqB,EAAE,CAAA;IACtD,GAAG,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAA;IAC5E,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;IAC3E,MAAM,QAAQ,CAAC,0BAA0B,CAAC;QACxC,IAAI,EAAE,YAAY;QAClB,gBAAgB,EAAE,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,gBAAgB,GAAG,qBAAqB,EAAE;QACjG,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,UAAU;KACX,CAAC,CAAA;IACF,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { Arch, exists, log } from \"builder-util\"\nimport { BlockMapDataHolder, PackageFileInfo } from \"builder-util-runtime\"\nimport * as path from \"path\"\nimport { Target } from \"../core.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { ArchiveOptions } from \"./archive.js\"\nimport { BlockMapRegion, buildBlockMap, BuildBlockMapOptions, ChunkerParams } from \"./blockmap/blockmap.js\"\nimport { findPreparedVerbatimRange, prepareVerbatimNeedle, VerbatimNeedle, VerbatimRange } from \"./blockmap/verbatimRange.js\"\n\nexport const BLOCK_MAP_FILE_SUFFIX = \".blockmap\"\n\n/**\n * Chunker parameters for a stored (`Copy`) archive member — e.g. `resources/app.asar` when\n * `nsis.differentialPackage` is `\"store-asar\"` — whose bytes sit verbatim in the artifact. Such a member\n * changes in small, localized ways between releases, so it is chunked finer than the surrounding\n * compressed streams to keep the differential download proportional to the change.\n *\n * Set by benchmark (`test/src/differentialOneLineBenchTest.ts`, 32 MB asar / 3,001 files): 4/8/16 KiB\n * minimizes download bytes + new-blockmap bytes for a one-line edit (−5 % same-length, −17 % length-changing\n * vs. the 8/16/32 default); anything finer is a net loss because the v2 blockmap (~22 B per block, re-downloaded\n * in full on every update) grows faster than the block savings. `avg` must stay a power of two.\n */\nexport const STORED_MEMBER_CHUNKER: ChunkerParams = { min: 4096, avg: 8192, max: 16384 }\n\n/**\n * Locates each of `memberFiles` (absolute paths of files stored verbatim inside `artifact`) and returns\n * a `STORED_MEMBER_CHUNKER` blockmap region per located file, sorted by offset. The regions never\n * overlap: byte-identical members (a pure-JS app packaged for x64 + arm64 has the same asar twice in\n * the universal installer) are each matched to their own copy, and a copy already claimed by an\n * earlier member is skipped. A member file that does not exist, or that cannot be found verbatim, is\n * logged at warn and skipped — the blockmap then falls back to the default chunker for those bytes;\n * it never fails the build.\n */\nexport async function locateStoredMemberRegions(artifact: string, memberFiles: Array<string>): Promise<Array<BlockMapRegion>> {\n const regions: Array<BlockMapRegion> = []\n // Byte-identical members have identical occurrences, and the copies are claimed in ascending order,\n // so the scan for the next member with the same content resumes where its previous copy ended instead\n // of rescanning (and re-confirming every earlier copy) from the start of the artifact.\n const resumeOffsetByHash = new Map<string, number>()\n for (const memberFile of memberFiles) {\n if (!(await exists(memberFile))) {\n log.warn({ artifact: log.filePath(artifact), member: log.filePath(memberFile) }, \"stored member file does not exist; no block map region for it\")\n continue\n }\n const needle = await prepareVerbatimNeedle(memberFile)\n const range = await findUnclaimedVerbatimRange(artifact, needle, regions, resumeOffsetByHash.get(needle.hash) ?? 0)\n if (range == null) {\n log.warn(\n { artifact: log.filePath(artifact), member: log.filePath(memberFile) },\n \"stored member not found verbatim in artifact; its bytes will be chunked with the default block map parameters\"\n )\n continue\n }\n resumeOffsetByHash.set(needle.hash, range.offset + range.size)\n log.info({ artifact: log.filePath(artifact), member: log.filePath(memberFile), offset: range.offset, size: range.size }, \"located stored member region for block map\")\n regions.push({ ...range, chunker: STORED_MEMBER_CHUNKER })\n }\n return regions.sort((a, b) => a.offset - b.offset)\n}\n\n/**\n * The first occurrence of `needle` in `artifact` at or after `startOffset` that does not overlap a\n * range in `claimed`. An occurrence that overlaps a claimed range is another member's copy (or part of\n * one), so the scan resumes right after that range — every candidate start before its end would\n * overlap it too.\n */\nasync function findUnclaimedVerbatimRange(artifact: string, needle: VerbatimNeedle, claimed: Array<BlockMapRegion>, startOffset: number): Promise<VerbatimRange | null> {\n for (;;) {\n const range = await findPreparedVerbatimRange(artifact, needle, startOffset)\n if (range == null) {\n return null\n }\n const rangeEnd = range.offset + range.size\n const clash = claimed.find(it => range.offset < it.offset + it.size && it.offset < rangeEnd)\n if (clash == null) {\n return range\n }\n startOffset = clash.offset + clash.size\n }\n}\n\n/** `BuildBlockMapOptions` for `regions`, or `undefined` when there are none so the default chunker path is taken unchanged. */\nexport function toBlockMapOptions(regions: Array<BlockMapRegion>): BuildBlockMapOptions | undefined {\n return regions.length === 0 ? undefined : { regions }\n}\n\nexport function createNsisWebDifferentialUpdateInfo(artifactPath: string, packageFiles: { [arch: string]: PackageFileInfo }) {\n if (packageFiles == null) {\n return null\n }\n\n const keys = Object.keys(packageFiles)\n if (keys.length <= 0) {\n return null\n }\n\n const packages: { [arch: string]: PackageFileInfo } = {}\n for (const arch of keys) {\n const packageFileInfo = packageFiles[arch]\n const file = path.basename(packageFileInfo.path)\n packages[arch] = {\n ...packageFileInfo,\n path: file,\n // https://github.com/electron-userland/electron-builder/issues/2583\n file,\n } as any\n }\n return { packages }\n}\n\nexport function configureDifferentialAwareArchiveOptions(archiveOptions: ArchiveOptions): ArchiveOptions {\n /*\n * dict size 64 MB: Full: 33,744.88 KB, To download: 17,630.3 KB (52%)\n * dict size 16 MB: Full: 33,936.84 KB, To download: 16,175.9 KB (48%)\n * dict size 8 MB: Full: 34,187.59 KB, To download: 8,229.9 KB (24%)\n * dict size 4 MB: Full: 34,628.73 KB, To download: 3,782.97 KB (11%)\n\n as we can see, if file changed in one place, all block is invalidated (and update size approximately equals to dict size)\n\n 1 MB is used:\n\n 1MB:\n\n 2018/01/11 11:54:41:0045 File has 59 changed blocks\n 2018/01/11 11:54:41:0050 Full: 71,588.59 KB, To download: 1,243.39 KB (2%)\n\n 4MB:\n\n 2018/01/11 11:31:43:0440 Full: 70,303.55 KB, To download: 4,843.27 KB (7%)\n 2018/01/11 11:31:43:0435 File has 234 changed blocks\n\n */\n archiveOptions.dictSize = 1\n // At these settings 7-Zip splits LZMA2 into 4 MB blocks only with 4+ threads and writes one solid stream with fewer,\n // where any change rewrites everything after it (measured: a 6.7 MB update became 74 MB on a 2-thread host).\n // Pinning the size it picks with 4+ threads keeps the bytes identical on every host.\n archiveOptions.blockSize = 4\n // solid compression leads to a lot of changed blocks\n archiveOptions.solid = false\n // do not allow to change compression level to avoid different packages\n archiveOptions.compression = \"normal\"\n return archiveOptions\n}\n\nexport async function appendBlockmap(file: string, options?: BuildBlockMapOptions): Promise<BlockMapDataHolder> {\n log.info({ file: log.filePath(file) }, \"building embedded block map\")\n return buildBlockMap(file, \"deflate\", undefined, options)\n}\n\nexport async function createBlockmap(\n file: string,\n target: Target,\n packager: PlatformPackager<any>,\n safeArtifactName: string | null,\n arch: Arch | null = null,\n options?: BuildBlockMapOptions\n): Promise<BlockMapDataHolder> {\n const blockMapFile = `${file}${BLOCK_MAP_FILE_SUFFIX}`\n log.info({ blockMapFile: log.filePath(blockMapFile) }, \"building block map\")\n const updateInfo = await buildBlockMap(file, \"gzip\", blockMapFile, options)\n await packager.emitArtifactBuildCompleted({\n file: blockMapFile,\n safeArtifactName: safeArtifactName == null ? null : `${safeArtifactName}${BLOCK_MAP_FILE_SUFFIX}`,\n target,\n arch,\n packager,\n updateInfo,\n })\n return updateInfo\n}\n"]}
|
|
1
|
+
{"version":3,"file":"differentialUpdateInfoBuilder.js","sourceRoot":"","sources":["../../src/targets/differentialUpdateInfoBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAE3E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,IAAI,MAAM,MAAM,CAA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,EAAE,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,oBAAoB,CAAC,CAAA;IACpF,IAAI,UAA8B,CAAA;IAClC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,UAAU,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1H,CAAC;SAAM,CAAC;QACN,uGAAuG;QACvG,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAA;QACtI,GAAG,CAAC,KAAK,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,iBAAiB,CAAC,CAAA;QAC9H,UAAU,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAA;IACzD,CAAC;IACD,MAAM,QAAQ,CAAC,0BAA0B,CAAC;QACxC,IAAI,EAAE,YAAY;QAClB,gBAAgB,EAAE,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,gBAAgB,GAAG,qBAAqB,EAAE;QACjG,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,UAAU;KACX,CAAC,CAAA;IACF,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { Arch, exists, InvalidConfigurationError, log } from \"builder-util\"\nimport { BlockMapDataHolder, PackageFileInfo } from \"builder-util-runtime\"\nimport { open, stat } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as zlib from \"zlib\"\nimport { Node, readAsarHeader } from \"../asar/asar.js\"\nimport { Target } from \"../core.js\"\nimport { PlatformPackager } from \"../platformPackager.js\"\nimport { BINARY_BLOCK_MAP_MIN_UPDATER, BLOCK_MAP_FORMAT_DOCS_URL, isBinaryBlockMapSupported, resolveElectronUpdaterCompatibility } from \"../util/electronUpdaterCompatibility.js\"\nimport { ArchiveOptions } from \"./archive.js\"\nimport { BlockMapRegion, buildBlockMap, BuildBlockMapOptions, ChunkerParams } from \"./blockmap/blockmap.js\"\nimport { buildBlockMapV3 } from \"./blockmap/blockmapV3.js\"\nimport { findPreparedVerbatimRange, prepareVerbatimNeedle, prepareVerbatimNeedleFromBuffer, VerbatimNeedle, VerbatimRange } from \"./blockmap/verbatimRange.js\"\n\nexport const BLOCK_MAP_FILE_SUFFIX = \".blockmap\"\n\n/**\n * The `.blockmap` formats electron-builder writes (the `blockmap` option), named after the format version they carry: `\"v2\"`\n * is the gzipped JSON map (`\"version\": \"2\"`), `\"v3\"` the binary range-fetchable map (`EBB3` magic).\n */\nexport type BlockMapFormat = \"v2\" | \"v3\"\n\n/** The binary format: the default when `electronUpdaterCompatibility` allows it. */\nexport const BINARY_BLOCK_MAP_FORMAT: BlockMapFormat = \"v3\"\n\n/** The newest format electron-builder writes, what `blockmap: \"latest\"` selects when `electronUpdaterCompatibility` allows it. */\nexport const LATEST_BLOCK_MAP_FORMAT: BlockMapFormat = \"v3\"\n\n/**\n * The format of the `.blockmap` files of a build. The map is read by the updater already installed in the users' apps, which\n * `electronUpdaterCompatibility` describes, so:\n *\n * - unset: the binary format when the range allows only electron-updater 7 and later, else the JSON format (with a warning);\n * - `\"latest\"`: the newest format the range allows (today the same; unlike unset, it follows future formats);\n * - `\"v2\"`: the JSON format;\n * - `\"v3\"`: the binary format, which fails the build when the range includes electron-updater versions that cannot read it.\n */\nexport function resolveBlockMapFormat(value: unknown, electronUpdaterCompatibility: string): BlockMapFormat {\n if (value != null && value !== \"latest\" && value !== \"v2\" && value !== \"v3\") {\n throw new InvalidConfigurationError(`\"blockmap\" must be \"v2\", \"v3\" or \"latest\", got ${JSON.stringify(value)}`)\n }\n const binarySupported = isBinaryBlockMapSupported(electronUpdaterCompatibility)\n if (value === \"v2\") {\n return \"v2\"\n }\n if (value === \"v3\") {\n if (!binarySupported) {\n throw new InvalidConfigurationError(\n `blockmap \"v3\" (the binary block map) needs electron-updater ${BINARY_BLOCK_MAP_MIN_UPDATER} or later in the installed apps, but electronUpdaterCompatibility ` +\n `\"${electronUpdaterCompatibility}\" includes earlier versions. Raise electronUpdaterCompatibility to \">=7\" once your installed apps ship electron-updater 7, ` +\n `or set blockmap to \"v2\". See ${BLOCK_MAP_FORMAT_DOCS_URL}`\n )\n }\n return \"v3\"\n }\n if (!binarySupported) {\n warnAboutJsonBlockMap(electronUpdaterCompatibility)\n return \"v2\"\n }\n return value === \"latest\" ? LATEST_BLOCK_MAP_FORMAT : BINARY_BLOCK_MAP_FORMAT\n}\n\n/** The format of the `.blockmap` files `packager` writes. */\nexport function getBlockMapFormat(packager: PlatformPackager<any>): BlockMapFormat {\n return resolveBlockMapFormat(packager.config.blockmap, resolveElectronUpdaterCompatibility(packager.platformOptions, packager.config))\n}\n\nfunction warnAboutJsonBlockMap(electronUpdaterCompatibility: string): void {\n // once per process — a build resolves the format per artifact\n log.once(\"json-block-map\").warn(\n {\n electronUpdaterCompatibility,\n solution: `raise electronUpdaterCompatibility to \">=7\" once your installed apps ship electron-updater ${BINARY_BLOCK_MAP_MIN_UPDATER}`,\n docs: BLOCK_MAP_FORMAT_DOCS_URL,\n },\n `electron-builder v27 writes binary block maps, which electron-updater fetches in parts, but electronUpdaterCompatibility includes electron-updater ` +\n `versions before ${BINARY_BLOCK_MAP_MIN_UPDATER}, which cannot read them: this build writes JSON block maps, downloaded in full on every update`\n )\n}\n\n/**\n * Chunker parameters for a stored (`Copy`) archive member — e.g. `resources/app.asar` when\n * `nsis.differentialPackage` is `\"store-asar\"` — whose bytes sit verbatim in the artifact. Such a member\n * changes in small, localized ways between releases, so it is chunked finer than the surrounding\n * compressed streams to keep the differential download proportional to the change.\n *\n * Set by benchmark (`test/src/differentialOneLineBenchTest.ts`, 32 MB asar / 3,001 files): 4/8/16 KiB\n * minimizes download bytes + new-blockmap bytes for a one-line edit (−5 % same-length, −17 % length-changing\n * vs. the 8/16/32 default); anything finer is a net loss because the v2 blockmap (~22 B per block, re-downloaded\n * in full on every update) grows faster than the block savings. `avg` must stay a power of two.\n */\nexport const STORED_MEMBER_CHUNKER: ChunkerParams = { min: 4096, avg: 8192, max: 16384 }\n\n/**\n * `STORED_MEMBER_CHUNKER` counterpart for the `blockmap: \"v3\"` format (the v3 map of `blockMapV3.ts`). A v3 map costs\n * ~10 B per block in the file but an updater fetches only the super-groups, groups and records that\n * changed, so the v2 trade-off (a finer chunker inflating a map that is re-downloaded in full) no longer\n * applies and the stored member can be chunked at 512 B / 1 KiB / 2 KiB: a one-line change then costs\n * one or two small blocks plus a few KB of map. `max` must fit a v3 record's 16-bit block size.\n */\nexport const STORED_MEMBER_CHUNKER_V3: ChunkerParams = { min: 512, avg: 1024, max: 2048 }\n\n/**\n * Chunker of the 7z archive header region (`locateArchiveHeaderRegions`). The header of a differential\n * package is stored uncompressed (`configureDifferentialAwareArchiveOptions`) and is a few hundred bytes\n * to a few KB: file names, sizes and CRCs. Between two releases only the CRCs and sizes of the changed\n * members differ, but a compressed header re-encodes entirely and the trailing block of the package\n * (up to 32 KiB with the default chunker) was re-downloaded on every update. Cutting the header into\n * its own small blocks makes that cost the header's few hundred bytes.\n */\nexport const ARCHIVE_HEADER_CHUNKER: ChunkerParams = { min: 256, avg: 512, max: 1024 }\n\nconst SEVEN_ZIP_SIGNATURE = Buffer.from([0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c])\nconst SEVEN_ZIP_SIGNATURE_HEADER_SIZE = 32\n/** First byte of a 7z header stored as is (`kHeader`); a compressed header starts with `kEncodedHeader` (0x17). */\nconst SEVEN_ZIP_HEADER_ID = 0x01\n\nasync function readBytes(file: string, position: number, length: number): Promise<Buffer | null> {\n const handle = await open(file, \"r\")\n try {\n const buffer = Buffer.alloc(length)\n const { bytesRead } = await handle.read(buffer, 0, length, position)\n return bytesRead === length ? buffer : null\n } finally {\n await handle.close()\n }\n}\n\n/**\n * Locates the header of each 7z `archiveFiles` inside `artifact` (the archive itself, or an installer\n * that embeds it verbatim) and returns an `ARCHIVE_HEADER_CHUNKER` region per located header, sorted by\n * offset. The 32-byte 7z signature header names the header's offset and size; the signature header is\n * found verbatim in the artifact (its CRCs make it unique, and byte-identical archives are matched to\n * their own copies). An archive whose header is compressed, or that cannot be found, yields no region\n * and is logged at debug/warn — the block map then falls back to the default chunker for those bytes.\n */\nexport async function locateArchiveHeaderRegions(artifact: string, archiveFiles: Array<string>): Promise<Array<BlockMapRegion>> {\n const regions: Array<BlockMapRegion> = []\n const claimed: Array<BlockMapRegion> = []\n const resumeOffsetByHash = new Map<string, number>()\n for (const archiveFile of archiveFiles) {\n const signature = (await exists(archiveFile)) ? await readBytes(archiveFile, 0, SEVEN_ZIP_SIGNATURE_HEADER_SIZE) : null\n if (signature == null || !signature.subarray(0, SEVEN_ZIP_SIGNATURE.length).equals(SEVEN_ZIP_SIGNATURE)) {\n log.debug({ artifact: log.filePath(artifact), archive: log.filePath(archiveFile) }, \"not a 7z archive; no block map region for its header\")\n continue\n }\n // StartHeaderCRC (bytes 8-11) covers the next header's offset, size and CRC (bytes 12-31): an archive that fails it is not\n // what 7-Zip wrote, and its offset and size must not become a block map region\n if (zlib.crc32(signature.subarray(12, SEVEN_ZIP_SIGNATURE_HEADER_SIZE)) !== signature.readUInt32LE(8)) {\n log.warn(\n {\n artifact: log.filePath(artifact),\n archive: log.filePath(archiveFile),\n },\n \"7z start header CRC mismatch; no block map region for the archive header\"\n )\n continue\n }\n const headerOffset = SEVEN_ZIP_SIGNATURE_HEADER_SIZE + Number(signature.readBigUInt64LE(12))\n const headerSize = Number(signature.readBigUInt64LE(20))\n if (headerSize === 0) {\n continue\n }\n\n let start = 0\n if (path.resolve(artifact) !== path.resolve(archiveFile)) {\n const needle = prepareVerbatimNeedleFromBuffer(signature, `${path.basename(archiveFile)} signature header`)\n const range = await findUnclaimedVerbatimRange(artifact, needle, claimed, resumeOffsetByHash.get(needle.hash) ?? 0)\n if (range == null) {\n log.warn({ artifact: log.filePath(artifact), archive: log.filePath(archiveFile) }, \"archive not found verbatim in artifact; no block map region for its header\")\n continue\n }\n resumeOffsetByHash.set(needle.hash, range.offset + range.size)\n claimed.push({ ...range, chunker: ARCHIVE_HEADER_CHUNKER })\n start = range.offset\n }\n\n // a region past the end of the artifact would fail the whole block map; without it, only the header's finer chunking is lost\n if (start + headerOffset + headerSize > (await stat(artifact)).size) {\n log.warn(\n {\n artifact: log.filePath(artifact),\n archive: log.filePath(archiveFile),\n offset: start + headerOffset,\n size: headerSize,\n },\n \"7z header extends past the end of the artifact; no block map region for it\"\n )\n continue\n }\n const first = await readBytes(artifact, start + headerOffset, 1)\n if (first == null || first[0] !== SEVEN_ZIP_HEADER_ID) {\n log.debug({ artifact: log.filePath(artifact), archive: log.filePath(archiveFile) }, \"archive header is compressed; no block map region for it\")\n continue\n }\n log.info(\n { artifact: log.filePath(artifact), archive: log.filePath(archiveFile), offset: start + headerOffset, size: headerSize },\n \"located archive header region for block map\"\n )\n regions.push({ offset: start + headerOffset, size: headerSize, chunker: ARCHIVE_HEADER_CHUNKER })\n }\n return regions.sort((a, b) => a.offset - b.offset)\n}\n\n/** A stored member located verbatim in an artifact: the member file and its block map region there. */\nexport interface StoredMember {\n file: string\n region: BlockMapRegion\n}\n\n/**\n * Forced v3 block boundaries for the stored members that are asar archives: the start of the content\n * region and of every packed file in it (from the asar header's offsets), as absolute artifact offsets.\n * With these cuts a change inside one file never alters a block that also covers its neighbour, so an\n * in-place edit costs its own blocks only. Members that are not asars contribute nothing.\n */\nexport async function asarContentBoundaries(members: Array<StoredMember>): Promise<Array<number>> {\n const boundaries = new Set<number>()\n for (const { file, region } of members) {\n let header: string\n let headerSize: number\n try {\n ;({ header, size: headerSize } = await readAsarHeader(file))\n } catch (e: any) {\n log.debug({ member: log.filePath(file), reason: e.message }, \"stored member is not an asar; no forced block boundaries for it\")\n continue\n }\n const contentStart = region.offset + 8 + headerSize\n const regionEnd = region.offset + region.size\n const collect = (node: Node) => {\n for (const child of Object.values(node.files ?? {})) {\n if (child.files != null) {\n collect(child)\n } else if (child.offset != null && !child.unpacked && child.link == null) {\n const boundary = contentStart + parseInt(child.offset, 10)\n if (boundary > region.offset && boundary < regionEnd) {\n boundaries.add(boundary)\n }\n }\n }\n }\n try {\n collect(JSON.parse(header) as Node)\n } catch (e: any) {\n log.debug({ member: log.filePath(file), reason: e.message }, \"stored member has no parsable asar header; no forced block boundaries for it\")\n continue\n }\n if (contentStart < regionEnd) {\n boundaries.add(contentStart)\n }\n }\n return [...boundaries].sort((a, b) => a - b)\n}\n\n/**\n * Locates each of `memberFiles` (absolute paths of files stored verbatim inside `artifact`) and returns\n * a `STORED_MEMBER_CHUNKER` blockmap region per located file, sorted by offset. The regions never\n * overlap: byte-identical members (a pure-JS app packaged for x64 + arm64 has the same asar twice in\n * the universal installer) are each matched to their own copy, and a copy already claimed by an\n * earlier member is skipped. A member file that does not exist, or that cannot be found verbatim, is\n * logged at warn and skipped — the blockmap then falls back to the default chunker for those bytes;\n * it never fails the build.\n *\n * The returned regions are the v2 regions; `toV3Regions` derives the v3 regions (same byte ranges,\n * `STORED_MEMBER_CHUNKER_V3`) from them, so both maps are built from the same located ranges.\n */\nexport async function locateStoredMemberRegions(artifact: string, memberFiles: Array<string>): Promise<Array<BlockMapRegion>> {\n return (await locateStoredMembers(artifact, memberFiles)).map(it => it.region)\n}\n\n/** `locateStoredMemberRegions` keeping which member each region belongs to (for `asarContentBoundaries`). */\nexport async function locateStoredMembers(artifact: string, memberFiles: Array<string>): Promise<Array<StoredMember>> {\n const members: Array<StoredMember> = []\n const regions: Array<BlockMapRegion> = []\n // Byte-identical members have identical occurrences, and the copies are claimed in ascending order,\n // so the scan for the next member with the same content resumes where its previous copy ended instead\n // of rescanning (and re-confirming every earlier copy) from the start of the artifact.\n const resumeOffsetByHash = new Map<string, number>()\n for (const memberFile of memberFiles) {\n if (!(await exists(memberFile))) {\n log.warn({ artifact: log.filePath(artifact), member: log.filePath(memberFile) }, \"stored member file does not exist; no block map region for it\")\n continue\n }\n const needle = await prepareVerbatimNeedle(memberFile)\n const range = await findUnclaimedVerbatimRange(artifact, needle, regions, resumeOffsetByHash.get(needle.hash) ?? 0)\n if (range == null) {\n log.warn(\n { artifact: log.filePath(artifact), member: log.filePath(memberFile) },\n \"stored member not found verbatim in artifact; its bytes will be chunked with the default block map parameters\"\n )\n continue\n }\n resumeOffsetByHash.set(needle.hash, range.offset + range.size)\n log.info({ artifact: log.filePath(artifact), member: log.filePath(memberFile), offset: range.offset, size: range.size }, \"located stored member region for block map\")\n const region = { ...range, chunker: STORED_MEMBER_CHUNKER }\n regions.push(region)\n members.push({ file: memberFile, region })\n }\n return members.sort((a, b) => a.region.offset - b.region.offset)\n}\n\n/**\n * The first occurrence of `needle` in `artifact` at or after `startOffset` that does not overlap a\n * range in `claimed`. An occurrence that overlaps a claimed range is another member's copy (or part of\n * one), so the scan resumes right after that range — every candidate start before its end would\n * overlap it too.\n */\nasync function findUnclaimedVerbatimRange(artifact: string, needle: VerbatimNeedle, claimed: Array<BlockMapRegion>, startOffset: number): Promise<VerbatimRange | null> {\n for (;;) {\n const range = await findPreparedVerbatimRange(artifact, needle, startOffset)\n if (range == null) {\n return null\n }\n const rangeEnd = range.offset + range.size\n const clash = claimed.find(it => range.offset < it.offset + it.size && it.offset < rangeEnd)\n if (clash == null) {\n return range\n }\n startOffset = clash.offset + clash.size\n }\n}\n\n/** `BuildBlockMapOptions` for the `blockmap: \"v2\"` format, plus what only the `\"v3\"` format uses. */\nexport interface DifferentialBlockMapOptions extends BuildBlockMapOptions {\n /**\n * Forced block boundaries for the `\"v3\"` format only (`BuildBlockMapV3Options.boundaries`); a `\"v2\"` map keeps\n * its chunking byte-for-byte, since every updater downloads it in full.\n */\n v3Boundaries?: Array<number> | null\n}\n\n/** Options for `appendBlockmap` / `createBlockmap` from located regions (any order) and optional v3 boundaries. */\nexport function toBlockMapOptions(regions: Array<BlockMapRegion>, v3Boundaries?: Array<number> | null): DifferentialBlockMapOptions | undefined {\n if (regions.length === 0 && (v3Boundaries == null || v3Boundaries.length === 0)) {\n return undefined\n }\n const options: DifferentialBlockMapOptions = { regions: [...regions].sort((a, b) => a.offset - b.offset) }\n if (v3Boundaries != null && v3Boundaries.length > 0) {\n options.v3Boundaries = v3Boundaries\n }\n return options\n}\n\n/**\n * Block map options of an installer that embeds its app packages verbatim: the regions of their stored `members` and, for the\n * binary format only, those of the 7z headers of `archiveFiles` and a block boundary at every packed file of a stored asar. The\n * JSON format uses neither, so its build does not read them.\n */\nexport async function installerBlockMapOptions(\n installerPath: string,\n members: Array<StoredMember>,\n archiveFiles: Array<string>,\n format: BlockMapFormat\n): Promise<DifferentialBlockMapOptions | undefined> {\n const regions = members.map(it => it.region)\n if (format !== BINARY_BLOCK_MAP_FORMAT) {\n return toBlockMapOptions(regions)\n }\n return toBlockMapOptions([...regions, ...(await locateArchiveHeaderRegions(installerPath, archiveFiles))], await asarContentBoundaries(members))\n}\n\nfunction isSameChunker(a: ChunkerParams, b: ChunkerParams): boolean {\n return a.min === b.min && a.avg === b.avg && a.max === b.max\n}\n\n/**\n * The v3 block map regions for the v2 `regions` (as returned by `locateStoredMemberRegions`): the same\n * byte ranges, with `STORED_MEMBER_CHUNKER` swapped for `STORED_MEMBER_CHUNKER_V3`. Regions with any\n * other chunker are kept as they are (a caller that chose its own parameters gets them in both maps).\n */\nexport function toV3Regions(regions: Array<BlockMapRegion> | null | undefined): Array<BlockMapRegion> {\n return (regions ?? []).map(region => (isSameChunker(region.chunker, STORED_MEMBER_CHUNKER) ? { ...region, chunker: STORED_MEMBER_CHUNKER_V3 } : region))\n}\n\nexport function createNsisWebDifferentialUpdateInfo(artifactPath: string, packageFiles: { [arch: string]: PackageFileInfo }) {\n if (packageFiles == null) {\n return null\n }\n\n const keys = Object.keys(packageFiles)\n if (keys.length <= 0) {\n return null\n }\n\n const packages: { [arch: string]: PackageFileInfo } = {}\n for (const arch of keys) {\n const packageFileInfo = packageFiles[arch]\n const file = path.basename(packageFileInfo.path)\n packages[arch] = {\n ...packageFileInfo,\n path: file,\n // https://github.com/electron-userland/electron-builder/issues/2583\n file,\n } as any\n }\n return { packages }\n}\n\n/**\n * `storeArchiveHeader`: whether the 7z header is stored as is, for a build whose block map chunks it finely (the binary format,\n * see `locateArchiveHeaderRegions`). With the JSON format the package stays byte-for-byte what earlier versions wrote.\n */\nexport function configureDifferentialAwareArchiveOptions(archiveOptions: ArchiveOptions, storeArchiveHeader: boolean): ArchiveOptions {\n /*\n * dict size 64 MB: Full: 33,744.88 KB, To download: 17,630.3 KB (52%)\n * dict size 16 MB: Full: 33,936.84 KB, To download: 16,175.9 KB (48%)\n * dict size 8 MB: Full: 34,187.59 KB, To download: 8,229.9 KB (24%)\n * dict size 4 MB: Full: 34,628.73 KB, To download: 3,782.97 KB (11%)\n\n as we can see, if file changed in one place, all block is invalidated (and update size approximately equals to dict size)\n\n 1 MB is used:\n\n 1MB:\n\n 2018/01/11 11:54:41:0045 File has 59 changed blocks\n 2018/01/11 11:54:41:0050 Full: 71,588.59 KB, To download: 1,243.39 KB (2%)\n\n 4MB:\n\n 2018/01/11 11:31:43:0440 Full: 70,303.55 KB, To download: 4,843.27 KB (7%)\n 2018/01/11 11:31:43:0435 File has 234 changed blocks\n\n */\n archiveOptions.dictSize = 1\n // At these settings 7-Zip splits LZMA2 into 4 MB blocks only with 4+ threads and writes one solid stream with fewer,\n // where any change rewrites everything after it (measured: a 6.7 MB update became 74 MB on a 2-thread host).\n // Pinning the size it picks with 4+ threads keeps the bytes identical on every host.\n archiveOptions.blockSize = 4\n // solid compression leads to a lot of changed blocks\n archiveOptions.solid = false\n // do not allow to change compression level to avoid different packages\n archiveOptions.compression = \"normal\"\n // store the archive header as is: a compressed header re-encodes entirely when a single CRC changes,\n // so every update re-downloaded the trailing block of the package; stored, only the changed CRCs and\n // sizes differ and `locateArchiveHeaderRegions` chunks the header finely (ARCHIVE_HEADER_CHUNKER)\n if (storeArchiveHeader) {\n archiveOptions.isArchiveHeaderCompressed = false\n }\n return archiveOptions\n}\n\nexport async function appendBlockmap(file: string, options?: BuildBlockMapOptions): Promise<BlockMapDataHolder> {\n log.info({ file: log.filePath(file) }, \"building embedded block map\")\n return buildBlockMap(file, \"deflate\", undefined, options)\n}\n\nexport async function createBlockmap(\n file: string,\n target: Target,\n packager: PlatformPackager<any>,\n safeArtifactName: string | null,\n arch: Arch | null = null,\n options?: DifferentialBlockMapOptions\n): Promise<BlockMapDataHolder> {\n const format = getBlockMapFormat(packager)\n const blockMapFile = `${file}${BLOCK_MAP_FILE_SUFFIX}`\n log.info({ blockMapFile: log.filePath(blockMapFile), format }, \"building block map\")\n let updateInfo: BlockMapDataHolder\n if (format === \"v2\") {\n updateInfo = await buildBlockMap(file, \"gzip\", blockMapFile, options == null ? undefined : { regions: options.regions })\n } else {\n // the stored members get the finer v2 chunker, and a stored asar a block boundary at every packed file\n const built = await buildBlockMapV3(file, blockMapFile, { regions: toV3Regions(options?.regions), boundaries: options?.v3Boundaries })\n log.debug({ blockMapFile: log.filePath(blockMapFile), blocks: built.blockCount, groups: built.groupCount }, \"built block map\")\n updateInfo = { size: built.size, sha512: built.sha512 }\n }\n await packager.emitArtifactBuildCompleted({\n file: blockMapFile,\n safeArtifactName: safeArtifactName == null ? null : `${safeArtifactName}${BLOCK_MAP_FILE_SUFFIX}`,\n target,\n arch,\n packager,\n updateInfo,\n })\n return updateInfo\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { rm } from "fs/promises";
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import * as semver from "semver";
|
|
5
5
|
import { Target } from "../../core.js";
|
|
6
|
-
import {
|
|
6
|
+
import { BUILD_CHANGES_URL, RUNTIME_CHANGES_URL } from "../../util/config/legacyOptions.js";
|
|
7
7
|
import { getNotLocalizedLicenseFile } from "../../util/license.js";
|
|
8
8
|
import { buildFlatpakBundle } from "./flatpakBundle.js";
|
|
9
9
|
import { generateMimeTypeXml } from "./appimage/appLauncher.js";
|
|
@@ -134,7 +134,7 @@ export default class FlatpakTarget extends Target {
|
|
|
134
134
|
log
|
|
135
135
|
.once("flatpak-wayland-ozone-flag", this)
|
|
136
136
|
.warn({ electronVersion, docs: WAYLAND_DOCS }, `electron-builder v27 no longer adds ${USE_OZONE_PLATFORM_FLAG} with flatpak.useWaylandFlags for Electron 16 and later, where Ozone is on by default: in a Wayland session the wrapper now passes only --ozone-platform=wayland. ` +
|
|
137
|
-
`If the app needs the flag, add it to flatpak.executableArgs. See ${
|
|
137
|
+
`If the app needs the flag, add it to flatpak.executableArgs. See ${RUNTIME_CHANGES_URL}#flatpak-wayland-flags`);
|
|
138
138
|
}
|
|
139
139
|
const electronWrapperPath = stageDir.getTempFile(path.join("bin", "electron-wrapper"));
|
|
140
140
|
await outputFile(electronWrapperPath, getElectronWrapperScript(this.packager.executableName, this.options.executableArgs, waylandFlags));
|
|
@@ -187,13 +187,13 @@ export default class FlatpakTarget extends Target {
|
|
|
187
187
|
.once("flatpak-default-finish-args", this)
|
|
188
188
|
.warn({ reason: "flatpak.finishArgs is not set", docs: "https://www.electron.build/docs/flatpak#finish-args-permissions" }, "electron-builder v27 narrowed the default flatpak.finishArgs: --filesystem=home -> --filesystem=xdg-download, and --talk-name=org.freedesktop.Notifications only for the base app org.electronjs.Electron2.BaseApp before 23.08. " +
|
|
189
189
|
"The app can no longer reach the home directory outside Downloads. Set flatpak.finishArgs to grant more (the v26 list is in the migration guide). " +
|
|
190
|
-
`See ${
|
|
190
|
+
`See ${RUNTIME_CHANGES_URL}#flatpak-default-permissions`);
|
|
191
191
|
}
|
|
192
192
|
if (!this.options.runtimeVersion || !this.options.baseVersion) {
|
|
193
193
|
log
|
|
194
194
|
.once("flatpak-default-runtime-version", this)
|
|
195
195
|
.warn({ runtimeVersion, baseVersion }, `electron-builder v27 changed the default flatpak.runtimeVersion and flatpak.baseVersion from 20.08 to 26.08: each of them that is not set is now 26.08, and the 26.08 runtime, SDK and base app are installed if they are missing. ` +
|
|
196
|
-
`Set both to "20.08" to keep the previous runtime, or both to the version to build for. See ${
|
|
196
|
+
`Set both to "20.08" to keep the previous runtime, or both to the version to build for. See ${BUILD_CHANGES_URL}#flatpak-tooling-requirements`);
|
|
197
197
|
}
|
|
198
198
|
const manifest = {
|
|
199
199
|
id: appIdentifier,
|
|
@@ -335,7 +335,7 @@ function warnAboutFlatpakBundlerDebug() {
|
|
|
335
335
|
log
|
|
336
336
|
.once("flatpak-bundler-debug")
|
|
337
337
|
.warn({ envVar: "DEBUG" }, `electron-builder v27 no longer uses @malept/flatpak-bundler, so DEBUG=@malept/flatpak-bundler has no effect: a failed flatpak or flatpak-builder command prints its own output in the build error. ` +
|
|
338
|
-
`Set DEBUG=electron-builder to log every command that is run. See ${
|
|
338
|
+
`Set DEBUG=electron-builder to log every command that is run. See ${BUILD_CHANGES_URL}#flatpak-tooling-requirements`);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
/**
|