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

@ -0,0 +1,3 @@
export declare function dynamicImport(path: string): Promise<any>;
/** Like {@link dynamicImport()}, except it tries out {@link require()} first. */
export declare function dynamicImportMaybe(path: string): Promise<any>;

View file

@ -0,0 +1,40 @@
const url = require("url")
const fs = require("fs")
const path = require("path")
// Resolve a module specifier to a file:// URL using CJS resolution, which
// adds .js extensions automatically and follows pnpm's symlinked node_modules.
// Returns null for Node built-ins (require.resolve returns a bare string, not
// an absolute path) and for any specifier that cannot be resolved, so callers
// fall back to importing the raw specifier and get the normal error.
function resolveToFileUrl(modulePath) {
try {
const resolved = require.resolve(modulePath)
// Built-in modules (e.g. "fs", "path") resolve to their bare name, not a
// filesystem path. Passing a bare name to pathToFileURL produces a bogus URL.
return path.isAbsolute(resolved) ? url.pathToFileURL(resolved).href : null
} catch {
return null
}
}
exports.dynamicImport = async function dynamicImport(modulePath) {
if (fs.existsSync(modulePath)) {
return import(url.pathToFileURL(modulePath).href)
}
const fileUrl = resolveToFileUrl(modulePath)
return import(fileUrl !== null ? fileUrl : modulePath)
}
exports.dynamicImportMaybe = async function dynamicImportMaybe(modulePath) {
try {
return require(modulePath)
} catch (e1) {
try {
return await exports.dynamicImport(modulePath)
} catch (e2) {
e1.message = "\n1. " + e1.message + "\n2. " + e2.message
throw e1
}
}
}

View file

@ -0,0 +1,38 @@
if (!process.send) {
console.error("The remote rebuilder expects to be spawned with an IPC channel")
process.exit(1)
}
const rebuilder = rebuilder => {
rebuilder.lifecycle.on("module-found", moduleName => process.send?.({ msg: "module-found", moduleName }))
rebuilder.lifecycle.on("module-done", moduleName => process.send?.({ msg: "module-done", moduleName }))
rebuilder.lifecycle.on("module-skip", moduleName => process.send?.({ msg: "module-skip", moduleName }))
return rebuilder
.then(() => {
process.send?.({ msg: "rebuild-done" })
return process.exit(0)
})
.catch(err => {
process.send?.({
msg: "rebuild-error",
err: {
message: err.message,
stack: err.stack,
},
})
process.exit(0)
})
}
const main = () => {
const options = JSON.parse(process.argv[2])
const dynamicImport = require("./dynamic-import").dynamicImportMaybe
return dynamicImport("@electron/rebuild").then(module => {
const { rebuild } = module
return rebuilder(rebuild(options))
})
}
main()