import { sharpLoadState } from "./image-encode.js"; import type { EncodedImage, EncodeJob } from "./image-encode.js"; import { ImageWorker } from "./image-worker-client.js"; /** * Physical sibling of one archived path. * * A packaged Electron host reads its own files from `app.asar` through the ASAR * layer, which no other process can use; packagers unpack the files a plain * Node child opens into `app.asar.unpacked` beside the archive. * @param resolved - absolute path that may contain an `app.asar` segment. * @returns the `app.asar.unpacked` sibling path, or undefined for a real path. */ export declare function unpackedSibling(resolved: string): string | undefined; /** * Absolute worker entry a plain Node child can open. * @param moduleUrl - `import.meta.url` of the built module that needs the entry. * @param exists - existence probe for candidate paths. * @returns absolute path of the worker entry. * @throws when the built entry, or the unpacked copy a packaged host needs, is missing. */ export declare function workerEntryPath(moduleUrl?: string, exists?: (path: string) => boolean): string; /** * Whether this process must run Sharp work elsewhere. * * Only Electron on Linux links the conflicting GLib, so every other runtime * keeps the in-process path. * @param versions - runtime version facts; defaults to this process. * @param platform - runtime platform; defaults to this process. * @returns whether the encode ladder needs a separate plain-Node process. */ export declare function rasterWorkerRequired(versions?: Readonly>, platform?: NodeJS.Platform): boolean; /** * Plain Node executable that runs the worker on this host. * * Candidates are tried in order: an explicit `DSH_BROWSER_NODE`, then the Node * bundled in a DSH primary runtime. Electron's own binary is never a candidate — * it is the process that must not load Sharp. * @param environment - environment the candidates are read from. * @param exists - existence probe for candidates. * @returns absolute path of the first existing candidate, or undefined when none does. */ export declare function resolveWorkerNode(environment?: NodeJS.ProcessEnv, exists?: (path: string) => boolean): string | undefined; /** * Run the encode ladder in a plain Node worker. * @param node - absolute plain Node executable. * @param environment - host environment the worker's own variables are selected from. * @param script - absolute worker entry; defaults to the built entry beside this module. * @returns the worker later dispatches stay routed to. */ export declare function installImageWorker(node: string, environment?: NodeJS.ProcessEnv, script?: string): ImageWorker; /** * Stop the worker and return this process to the in-process path. * @returns completion once the worker process has exited. */ export declare function disposeImageWorker(): Promise; /** * Encode one image wherever this host allows Sharp to run. * * Delegated failures never fail a screenshot: the caller receives `null` and * hands back the original bytes, exactly as when Sharp is missing altogether. * @param job - resolved source bytes and ladder knobs. * @returns the smallest encoded candidate, or null when this host has no encoder. */ export declare function encodeWithSharp(job: EncodeJob): Promise; /** Read-only dispatch facts for tests and the regression check. */ export declare function _rasterStateForTest(): { mode: "in-process" | "worker"; node?: string; refused?: string; }; /** Re-exported so callers need one import for the whole encoder surface. */ export { sharpLoadState };