update electron to v43

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,10 +1,10 @@
import * as asar from 'asar';
import asar from '@electron/asar';
import { execFileSync } from 'child_process';
import * as crypto from 'crypto';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as minimatch from 'minimatch';
import * as os from 'os';
import crypto from 'crypto';
import fs from 'fs-extra';
import path from 'path';
import { minimatch } from 'minimatch';
import os from 'os';
import { d } from './debug';
const LIPO = 'lipo';
export var AsarMode;
@ -15,11 +15,13 @@ export var AsarMode;
// See: https://github.com/apple-opensource-mirror/llvmCore/blob/0c60489d96c87140db9a6a14c6e82b15f5e5d252/include/llvm/Object/MachOFormat.h#L108-L112
const MACHO_MAGIC = new Set([
// 32-bit Mach-O
0xfeedface,
0xcefaedfe,
0xfeedface, 0xcefaedfe,
// 64-bit Mach-O
0xfeedfacf,
0xcffaedfe,
0xfeedfacf, 0xcffaedfe,
]);
const MACHO_UNIVERSAL_MAGIC = new Set([
// universal
0xcafebabe, 0xbebafeca,
]);
export const detectAsarMode = async (appPath) => {
d('checking asar mode of', appPath);
@ -54,8 +56,8 @@ function checkSingleArch(archive, file, allowList) {
}
export const mergeASARs = async ({ x64AsarPath, arm64AsarPath, outputAsarPath, singleArchFiles, }) => {
d(`merging ${x64AsarPath} and ${arm64AsarPath}`);
const x64Files = new Set(asar.listPackage(x64AsarPath).map(toRelativePath));
const arm64Files = new Set(asar.listPackage(arm64AsarPath).map(toRelativePath));
const x64Files = new Set(asar.listPackage(x64AsarPath, { isPack: false }).map(toRelativePath));
const arm64Files = new Set(asar.listPackage(arm64AsarPath, { isPack: false }).map(toRelativePath));
//
// Build set of unpacked directories and files
//
@ -103,9 +105,14 @@ export const mergeASARs = async ({ x64AsarPath, arm64AsarPath, outputAsarPath, s
}
const x64Content = asar.extractFile(x64AsarPath, file);
const arm64Content = asar.extractFile(arm64AsarPath, file);
// Skip file if the same content
if (x64Content.compare(arm64Content) === 0) {
continue;
}
// Skip universal Mach-O files.
if (isUniversalMachO(x64Content)) {
continue;
}
if (!MACHO_MAGIC.has(x64Content.readUInt32LE(0))) {
throw new Error(`Can't reconcile two non-macho files ${file}`);
}
@ -141,8 +148,15 @@ export const mergeASARs = async ({ x64AsarPath, arm64AsarPath, outputAsarPath, s
}
d(`creating archive at ${outputAsarPath}`);
const resolvedUnpack = Array.from(unpackedFiles).map((file) => path.join(x64Dir, file));
let unpack;
if (resolvedUnpack.length > 1) {
unpack = `{${resolvedUnpack.join(',')}}`;
}
else if (resolvedUnpack.length === 1) {
unpack = resolvedUnpack[0];
}
await asar.createPackageWithOptions(x64Dir, outputAsarPath, {
unpack: `{${resolvedUnpack.join(',')}}`,
unpack,
});
d('done merging');
}
@ -150,4 +164,7 @@ export const mergeASARs = async ({ x64AsarPath, arm64AsarPath, outputAsarPath, s
await Promise.all([fs.remove(x64Dir), fs.remove(arm64Dir)]);
}
};
export const isUniversalMachO = (fileContent) => {
return MACHO_UNIVERSAL_MAGIC.has(fileContent.readUInt32LE(0));
};
//# sourceMappingURL=asar-utils.js.map