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,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.rebuild = exports.nodeGypRebuild = exports.getGypEnv = exports.installOrRebuild = void 0;
exports.installOrRebuild = installOrRebuild;
exports.getGypEnv = getGypEnv;
exports.installDependencies = installDependencies;
exports.nodeGypRebuild = nodeGypRebuild;
exports.rebuild = rebuild;
const builder_util_1 = require("builder-util");
const fs_extra_1 = require("fs-extra");
const os_1 = require("os");
const path = require("path");
const appBuilder_1 = require("./appBuilder");
async function installOrRebuild(config, appDir, options, forceInstall = false) {
const node_module_collector_1 = require("../node-module-collector");
const packageManager_1 = require("../node-module-collector/packageManager");
const rebuild_1 = require("./rebuild");
const which = require("which");
async function installOrRebuild(config, { appDir, projectDir, workspaceRoot }, options, forceInstall = false, env) {
const effectiveOptions = {
buildFromSource: config.buildDependenciesFromSource === true,
additionalArgs: builder_util_1.asArray(config.npmArgs),
additionalArgs: (0, builder_util_1.asArray)(config.npmArgs),
...options,
};
let isDependenciesInstalled = false;
const dirsToCheck = [...new Set([projectDir, appDir, workspaceRoot].filter((d) => !!d))];
for (const fileOrDir of ["node_modules", ".pnp.js"]) {
if (await fs_extra_1.pathExists(path.join(appDir, fileOrDir))) {
if ((await Promise.all(dirsToCheck.map(d => (0, fs_extra_1.pathExists)(path.join(d, fileOrDir))))).some(Boolean)) {
isDependenciesInstalled = true;
break;
}
}
if (forceInstall || !isDependenciesInstalled) {
await installDependencies(appDir, effectiveOptions);
await installDependencies(config, { appDir, projectDir, workspaceRoot }, effectiveOptions, env);
}
else {
await rebuild(appDir, effectiveOptions);
await rebuild(config, { appDir, projectDir, workspaceRoot }, effectiveOptions);
}
}
exports.installOrRebuild = installOrRebuild;
function getElectronGypCacheDir() {
return path.join(os_1.homedir(), ".electron-gyp");
return path.join((0, os_1.homedir)(), ".electron-gyp");
}
function getGypEnv(frameworkInfo, platform, arch, buildFromSource) {
const npmConfigArch = arch === "armv7l" ? "arm" : arch;
const common = {
...process.env,
...(0, builder_util_1.stripSensitiveEnvVars)(process.env),
npm_config_arch: npmConfigArch,
npm_config_target_arch: npmConfigArch,
npm_config_platform: platform,
@ -55,57 +62,57 @@ function getGypEnv(frameworkInfo, platform, arch, buildFromSource) {
// https://github.com/nodejs/node-gyp/issues/21
return {
...common,
npm_config_disturl: "https://electronjs.org/headers",
npm_config_disturl: common.npm_config_electron_mirror || "https://electronjs.org/headers",
npm_config_target: frameworkInfo.version,
npm_config_runtime: "electron",
npm_config_devdir: getElectronGypCacheDir(),
};
}
exports.getGypEnv = getGypEnv;
function checkYarnBerry() {
var _a;
const npmUserAgent = process.env["npm_config_user_agent"] || "";
const regex = /yarn\/(\d+)\./gm;
const yarnVersionMatch = regex.exec(npmUserAgent);
const yarnMajorVersion = Number((_a = yarnVersionMatch === null || yarnVersionMatch === void 0 ? void 0 : yarnVersionMatch[1]) !== null && _a !== void 0 ? _a : 0);
return yarnMajorVersion >= 2;
}
function installDependencies(appDir, options) {
async function installDependencies(config, { appDir, projectDir, workspaceRoot }, options, env) {
const platform = options.platform || process.platform;
const arch = options.arch || process.arch;
const additionalArgs = options.additionalArgs;
builder_util_1.log.info({ platform, arch, appDir }, `installing production dependencies`);
let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS;
const searchPaths = [projectDir, appDir].concat(workspaceRoot ? [workspaceRoot] : []);
const { pm, resolvedDirectory: _resolvedWorkspaceDir } = await (0, packageManager_1.detectPackageManager)(searchPaths);
builder_util_1.log.info({ pm, platform, arch, projectDir, appDir, workspaceRoot: _resolvedWorkspaceDir }, "installing dependencies");
const execArgs = ["install"];
const isYarnBerry = checkYarnBerry();
if (!isYarnBerry) {
if (pm === node_module_collector_1.PM.YARN) {
execArgs.push("--prefer-offline");
}
else if (pm === node_module_collector_1.PM.YARN_BERRY) {
if (process.env.NPM_NO_BIN_LINKS === "true") {
execArgs.push("--no-bin-links");
}
execArgs.push("--production");
}
if (!isRunningYarn(execPath)) {
execArgs.push("--prefer-offline");
}
if (execPath == null) {
execPath = getPackageToolPath();
}
else if (!isYarnBerry) {
execArgs.unshift(execPath);
execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node";
}
const execPath = (0, node_module_collector_1.getPackageManagerCommand)(pm);
if (additionalArgs != null) {
execArgs.push(...additionalArgs);
}
return builder_util_1.spawn(execPath, execArgs, {
cwd: appDir,
env: getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true),
const spawnEnv = {
...getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true),
...env,
};
await (0, builder_util_1.retry)(() => (0, builder_util_1.spawn)(execPath, execArgs, { cwd: appDir, env: spawnEnv }), {
retries: 3,
interval: 1000,
backoff: 2000,
shouldRetry: (e) => {
var _a;
const isTransient = /ENOTFOUND|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ECONNREFUSED/.test((_a = e === null || e === void 0 ? void 0 : e.message) !== null && _a !== void 0 ? _a : "");
if (isTransient) {
builder_util_1.log.warn({ error: String(e === null || e === void 0 ? void 0 : e.message).split("\n")[0] }, "transient network error during package install, retrying");
}
return isTransient;
},
});
// Some native dependencies no longer use `install` hook for building their native module, (yarn 3+ removed implicit link of `install` and `rebuild` steps)
// https://github.com/electron-userland/electron-builder/issues/8024
return rebuild(config, { appDir, projectDir, workspaceRoot }, options);
}
async function nodeGypRebuild(platform, arch, frameworkInfo) {
builder_util_1.log.info({ platform, arch }, "executing node-gyp rebuild");
// this script must be used only for electron
const nodeGyp = `node-gyp${process.platform === "win32" ? ".cmd" : ""}`;
const nodeGyp = process.platform === "win32" ? which.sync("node-gyp") : "node-gyp";
const args = ["rebuild"];
// headers of old Electron versions do not have a valid config.gypi file
// and --force-process-config must be passed to node-gyp >= 8.4.0 to
@ -118,34 +125,36 @@ async function nodeGypRebuild(platform, arch, frameworkInfo) {
if (major <= 13 || (major == 14 && minor <= 1) || (major == 15 && minor <= 2)) {
args.push("--force-process-config");
}
await builder_util_1.spawn(nodeGyp, args, { env: getGypEnv(frameworkInfo, platform, arch, true) });
}
exports.nodeGypRebuild = nodeGypRebuild;
function getPackageToolPath() {
if (process.env.FORCE_YARN === "true") {
return process.platform === "win32" ? "yarn.cmd" : "yarn";
}
else {
return process.platform === "win32" ? "npm.cmd" : "npm";
}
}
function isRunningYarn(execPath) {
const userAgent = process.env.npm_config_user_agent;
return process.env.FORCE_YARN === "true" || (execPath != null && path.basename(execPath).startsWith("yarn")) || (userAgent != null && /\byarn\b/.test(userAgent));
await (0, builder_util_1.spawn)(nodeGyp, args, { env: getGypEnv(frameworkInfo, platform, arch, true) });
}
/** @internal */
async function rebuild(appDir, options) {
const configuration = {
dependencies: await options.productionDeps.value,
nodeExecPath: process.execPath,
platform: options.platform || process.platform,
arch: options.arch || process.arch,
additionalArgs: options.additionalArgs,
execPath: process.env.npm_execpath || process.env.NPM_CLI_JS,
buildFromSource: options.buildFromSource === true,
async function rebuild(config, { appDir, projectDir, workspaceRoot }, options) {
const buildFromSource = options.buildFromSource === true;
const platform = options.platform || process.platform;
const arch = options.arch || process.arch;
const { frameworkInfo: { version: electronVersion }, } = options;
const projectRootPath = workspaceRoot || projectDir || appDir;
const logInfo = {
electronVersion,
arch,
buildFromSource,
workspaceRoot,
projectDir: builder_util_1.log.filePath(projectDir) || "./",
appDir: builder_util_1.log.filePath(appDir) || "./",
};
const env = getGypEnv(options.frameworkInfo, configuration.platform, configuration.arch, options.buildFromSource === true);
await appBuilder_1.executeAppBuilderAndWriteJson(["rebuild-node-modules"], configuration, { env, cwd: appDir });
builder_util_1.log.info(logInfo, "executing @electron/rebuild");
// "legacy" previously used the app-builder-bin Go binary; it now maps to sequential @electron/rebuild.
const mode = config.nativeRebuilder === "legacy" || !config.nativeRebuilder ? "sequential" : config.nativeRebuilder;
const rebuildOptions = {
buildPath: appDir,
electronVersion,
arch,
platform,
buildFromSource,
projectRootPath,
mode,
disablePreGypCopy: true,
};
return (0, rebuild_1.rebuild)(rebuildOptions);
}
exports.rebuild = rebuild;
//# sourceMappingURL=yarn.js.map