update electron to v43
All checks were successful
Android Build / publish (push) Successful in 55s
Linux Build / publish (push) Successful in 1m6s

This commit is contained in:
olcxja 2026-07-09 22:38:33 +02:00
commit fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions

View file

@ -1,39 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const bluebird_lst_1 = require("bluebird-lst");
const builder_util_1 = require("builder-util");
const builder_util_runtime_1 = require("builder-util-runtime");
const binDownload_1 = require("../binDownload");
const fs_1 = require("builder-util/out/fs");
const crypto_1 = require("crypto");
const ejs = require("ejs");
const promises_1 = require("fs/promises");
const lazy_val_1 = require("lazy-val");
const path = require("path");
const binDownload_1 = require("../binDownload");
const core_1 = require("../core");
const CommonWindowsInstallerConfiguration_1 = require("../options/CommonWindowsInstallerConfiguration");
const platformPackager_1 = require("../platformPackager");
const pathManager_1 = require("../util/pathManager");
const vm_1 = require("../vm/vm");
const WineVm_1 = require("../vm/WineVm");
const toolsetLock_1 = require("../util/toolsetLock");
const targetUtil_1 = require("./targetUtil");
const ELECTRON_BUILDER_UPGRADE_CODE_NS_UUID = builder_util_runtime_1.UUID.parse("d752fe43-5d44-44d5-9fc9-6dd1bf19d5cc");
const ROOT_DIR_ID = "APPLICATIONFOLDER";
const projectTemplate = new lazy_val_1.Lazy(async () => {
const template = (await promises_1.readFile(path.join(pathManager_1.getTemplatePath("msi"), "template.xml"), "utf8"))
.replace(/{{/g, "<%")
.replace(/}}/g, "%>")
.replace(/\${([^}]+)}/g, "<%=$1%>");
return ejs.compile(template);
});
// WiX doesn't support Mono, so, dontnet462 is required to be installed for wine (preinstalled in our bundled wine)
class MsiTarget extends core_1.Target {
constructor(packager, outDir) {
super("msi");
constructor(packager, outDir, name = "msi", isAsyncSupported = true) {
var _a;
super(name, isAsyncSupported);
this.packager = packager;
this.outDir = outDir;
this.vm = process.platform === "win32" ? new vm_1.VmManager() : new WineVm_1.WineVmManager();
this.options = builder_util_1.deepAssign(this.packager.platformSpecificBuildOptions, this.packager.config.msi);
this.vm = process.platform === "win32" ? new vm_1.VmManager() : new WineVm_1.WineVmManager((_a = this.packager.config.toolsets) === null || _a === void 0 ? void 0 : _a.wine);
this.options = (0, builder_util_runtime_1.deepAssign)(this.packager.platformSpecificBuildOptions, this.packager.config.msi);
this.projectTemplate = new lazy_val_1.Lazy(async () => {
const template = (await (0, promises_1.readFile)(path.join((0, pathManager_1.getTemplatePath)(this.name), "template.xml"), "utf8"))
.replace(/{{/g, "<%")
.replace(/}}/g, "%>")
.replace(/\${([^}]+)}/g, "<%=$1%>");
return ejs.compile(template);
});
}
/**
* A product-specific string that can be used in an [MSI Identifier](https://docs.microsoft.com/en-us/windows/win32/msi/identifier).
@ -52,30 +52,37 @@ class MsiTarget extends core_1.Target {
const packager = this.packager;
const artifactName = packager.expandArtifactBeautyNamePattern(this.options, "msi", arch);
const artifactPath = path.join(this.outDir, artifactName);
await packager.info.callArtifactBuildStarted({
await packager.info.emitArtifactBuildStarted({
targetPresentableName: "MSI",
file: artifactPath,
arch,
});
const stageDir = await targetUtil_1.createStageDir(this, packager, arch);
const stageDir = await (0, targetUtil_1.createStageDir)(this, packager, arch);
const vm = this.vm;
const commonOptions = CommonWindowsInstallerConfiguration_1.getEffectiveOptions(this.options, this.packager);
const commonOptions = (0, CommonWindowsInstallerConfiguration_1.getEffectiveOptions)(this.options, this.packager);
// wix 4.0.0.5512.2 doesn't support the arm64 architecture so default to x64 when building for arm64.
// This will result in an x64 MSI installer that installs an arm64 version of the application. This is a
// stopgap until the electron-builder-binaries wix version is upgraded to a version that supports arm64:
// https://github.com/electron-userland/electron-builder/issues/6077
const wixArch = arch == builder_util_1.Arch.arm64 ? builder_util_1.Arch.x64 : arch;
const projectFile = stageDir.getTempFile("project.wxs");
const objectFiles = ["project.wixobj"];
await promises_1.writeFile(projectFile, await this.writeManifest(appOutDir, arch, commonOptions));
await packager.info.callMsiProjectCreated(projectFile);
await (0, promises_1.writeFile)(projectFile, await this.writeManifest(appOutDir, wixArch, commonOptions));
await packager.info.emitMsiProjectCreated(projectFile);
// noinspection SpellCheckingInspection
const vendorPath = await binDownload_1.getBinFromUrl("wix", "4.0.0.5512.2", "/X5poahdCc3199Vt6AP7gluTlT1nxi9cbbHhZhCMEu+ngyP1LiBMn+oZX7QAZVaKeBMc2SjVp7fJqNLqsUnPNQ==");
const vendorPath = await (0, binDownload_1.getBinFromUrl)("wix-4.0.0.5512.2", "wix-4.0.0.5512.2.7z", "fe677fcd837b18c9b912985d91636bbd8a1e800c3b3a6a841b6f96e89624e839");
// noinspection SpellCheckingInspection
const candleArgs = ["-arch", arch === builder_util_1.Arch.ia32 ? "x86" : arch === builder_util_1.Arch.arm64 ? "arm64" : "x64", `-dappDir=${vm.toVmFile(appOutDir)}`].concat(this.getCommonWixArgs());
const candleArgs = ["-arch", wixArch === builder_util_1.Arch.ia32 ? "x86" : "x64", `-dappDir=${vm.toVmFile(appOutDir)}`].concat(this.getCommonWixArgs());
candleArgs.push("project.wxs");
await vm.exec(vm.toVmFile(path.join(vendorPath, "candle.exe")), candleArgs, {
cwd: stageDir.dir,
await (0, toolsetLock_1.withToolsetLock)(async () => {
await vm.exec(vm.toVmFile(path.join(vendorPath, "candle.exe")), candleArgs, {
cwd: stageDir.dir,
});
await this.light(objectFiles, vm, artifactPath, appOutDir, vendorPath, stageDir.dir);
});
await this.light(objectFiles, vm, artifactPath, appOutDir, vendorPath, stageDir.dir);
await stageDir.cleanup();
await packager.sign(artifactPath);
await packager.info.callArtifactBuildCompleted({
await packager.signIf(artifactPath);
await packager.info.emitArtifactBuildCompleted({
file: artifactPath,
packager,
arch,
@ -97,7 +104,9 @@ class MsiTarget extends core_1.Target {
"-sw1076",
`-dappDir=${vm.toVmFile(appOutDir)}`,
// "-dcl:high",
].concat(this.getCommonWixArgs());
]
.concat(this.getCommonWixArgs())
.concat(this.getAdditionalLightArgs());
// http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Build-3-5-2229-0-give-me-the-following-error-error-LGHT0216-An-unexpected-Win32-exception-with-errorn-td5707443.html
if (process.platform !== "win32") {
// noinspection SpellCheckingInspection
@ -112,6 +121,13 @@ class MsiTarget extends core_1.Target {
cwd: tempDir,
});
}
getAdditionalLightArgs() {
const args = [];
if (this.options.additionalLightArgs != null) {
args.push(...this.options.additionalLightArgs);
}
return args;
}
getCommonWixArgs() {
const args = ["-pedantic"];
if (this.options.warningsAsErrors !== false) {
@ -122,20 +138,32 @@ class MsiTarget extends core_1.Target {
}
return args;
}
async writeManifest(appOutDir, arch, commonOptions) {
async writeManifest(appOutDir, wixArch, commonOptions) {
const appInfo = this.packager.appInfo;
const { files, dirs } = await this.computeFileDeclaration(appOutDir);
const options = this.options;
return (await this.projectTemplate.value)({
...(await this.getBaseOptions(commonOptions)),
isCreateDesktopShortcut: commonOptions.isCreateDesktopShortcut !== CommonWindowsInstallerConfiguration_1.DesktopShortcutCreationPolicy.NEVER,
isRunAfterFinish: options.runAfterFinish !== false,
// https://stackoverflow.com/questions/1929038/compilation-error-ice80-the-64bitcomponent-uses-32bitdirectory
programFilesId: wixArch === builder_util_1.Arch.x64 ? "ProgramFiles64Folder" : "ProgramFilesFolder",
// wix in the name because special wix format can be used in the name
installationDirectoryWixName: (0, targetUtil_1.getWindowsInstallationDirName)(appInfo, commonOptions.isAssisted || commonOptions.isPerMachine === true),
dirs,
files,
});
}
async getBaseOptions(commonOptions) {
const appInfo = this.packager.appInfo;
const iconPath = await this.packager.getIconPath();
const compression = this.packager.compression;
const companyName = appInfo.companyName;
if (!companyName) {
builder_util_1.log.warn(`Manufacturer is not set for MSI — please set "author" in the package.json`);
}
const compression = this.packager.compression;
const options = this.options;
const iconPath = await this.packager.getIconPath();
return (await projectTemplate.value)({
return {
...commonOptions,
isCreateDesktopShortcut: commonOptions.isCreateDesktopShortcut !== CommonWindowsInstallerConfiguration_1.DesktopShortcutCreationPolicy.NEVER,
isRunAfterFinish: options.runAfterFinish !== false,
iconPath: iconPath == null ? null : this.vm.toVmFile(iconPath),
iconId: this.iconId,
compressionLevel: compression === "store" ? "none" : "high",
@ -144,13 +172,7 @@ class MsiTarget extends core_1.Target {
upgradeCode: this.upgradeCode,
manufacturer: companyName || appInfo.productName,
appDescription: appInfo.description,
// https://stackoverflow.com/questions/1929038/compilation-error-ice80-the-64bitcomponent-uses-32bitdirectory
programFilesId: arch === builder_util_1.Arch.x64 ? "ProgramFiles64Folder" : "ProgramFilesFolder",
// wix in the name because special wix format can be used in the name
installationDirectoryWixName: targetUtil_1.getWindowsInstallationDirName(appInfo, commonOptions.isAssisted || commonOptions.isPerMachine === true),
dirs,
files,
});
};
}
async computeFileDeclaration(appOutDir) {
const appInfo = this.packager.appInfo;
@ -158,8 +180,8 @@ class MsiTarget extends core_1.Target {
const dirNames = new Set();
const dirs = [];
const fileSpace = " ".repeat(6);
const commonOptions = CommonWindowsInstallerConfiguration_1.getEffectiveOptions(this.options, this.packager);
const files = await bluebird_lst_1.default.map(fs_1.walk(appOutDir), file => {
const commonOptions = (0, CommonWindowsInstallerConfiguration_1.getEffectiveOptions)(this.options, this.packager);
const files = (await (0, builder_util_1.walk)(appOutDir)).map(file => {
const packagePath = file.substring(appOutDir.length + 1);
const lastSlash = packagePath.lastIndexOf(path.sep);
const fileName = lastSlash > 0 ? packagePath.substring(lastSlash + 1) : packagePath;
@ -172,7 +194,7 @@ class MsiTarget extends core_1.Target {
// This syntax is a shortcut to defining each directory in an individual Directory element.
dirName = packagePath.substring(0, lastSlash);
// https://github.com/electron-userland/electron-builder/issues/3027
directoryId = "d" + crypto_1.createHash("md5").update(dirName).digest("base64").replace(/\//g, "_").replace(/\+/g, ".").replace(/=+$/, "");
directoryId = "d" + (0, crypto_1.createHash)("md5").update(dirName).digest("base64").replace(/\//g, "_").replace(/\+/g, ".").replace(/=+$/, "");
if (!dirNames.has(dirName)) {
dirNames.add(dirName);
dirs.push(`<Directory Id="${directoryId}" Name="${ROOT_DIR_ID}:\\${dirName.replace(/\//g, "\\")}\\"/>`);
@ -220,7 +242,7 @@ class MsiTarget extends core_1.Target {
const fileAssociations = this.packager.fileAssociations;
if (isMainExecutable && fileAssociations.length !== 0) {
for (const item of fileAssociations) {
const extensions = builder_util_1.asArray(item.ext).map(platformPackager_1.normalizeExt);
const extensions = (0, builder_util_1.asArray)(item.ext).map(platformPackager_1.normalizeExt);
for (const ext of extensions) {
result += `${fileSpace} <ProgId Id="${this.productMsiIdPrefix}.${ext}" Advertise="yes" Icon="${this.iconId}" ${item.description ? `Description="${item.description}"` : ""}>\n`;
result += `${fileSpace} <Extension Id="${ext}" Advertise="yes">\n`;