UNPKG

@reforged/maker-appimage

Version:

An AppImage maker implementation for the Electron Forge.

123 lines 4.67 kB
import EventEmitter from "events"; import type { MakerOptions } from "@electron-forge/maker-base"; import type { SemVer } from "semver"; type AppImageArch = "x86_64" | "aarch64" | "armhf" | "i686"; export type ForgeArch = "x64" | "arm64" | "armv7l" | "ia32" | "mips64el" | "universal"; export interface MakerMeta extends MakerOptions { targetArch: ForgeArch; } interface ImageMetadata { type: "PNG" | "SVG" | "XPM3" | "XPM2"; width: number | null; height: number | null; } /** Function argument definitions for {@linkcode mkSqFsEvt}. */ interface mkSqFSListenerArgs { close: [ /** A returned code when process normally exits. */ code: number | null, /** A signal which closed the process. */ signal: NodeJS.Signals | null, /** A message printed to STDERR, if available. */ msg?: string ]; progress: [ /** A number from range 0-100 indicating the current progress made on creating the image. */ percent: number ]; error: [ error: Error ]; } type mkSqFSEvtListen<T extends keyof mkSqFSListenerArgs> = [ eventName: T, listener: (..._: mkSqFSListenerArgs[T]) => void ]; /** An `EventListener` interface with parsed events from mksquashfs child process. */ interface mkSqFsEvt extends EventEmitter { /** * Emitted when `mksquashfs` process has been closed. */ on(..._: mkSqFSEvtListen<"close">): this; /** * Emitted once `mksquashfs` process has been closed. */ once(..._: mkSqFSEvtListen<"close">): this; /** * Emitted when `mksquashfs` process has been closed. */ addListener(..._: mkSqFSEvtListen<"close">): this; /** * Emitted when `mksquashfs` process has been closed. */ removeListener(..._: mkSqFSEvtListen<"close">): this; /** * Emitted whenever a progress has been made on SquashFS image generation. */ on(..._: mkSqFSEvtListen<"progress">): this; /** * Emitted whenever a progress has been made on SquashFS image generation. */ once(..._: mkSqFSEvtListen<"progress">): this; /** * Emitted whenever a progress has been made on SquashFS image generation. */ addListener(..._: mkSqFSEvtListen<"progress">): this; /** * Emitted whenever a progress has been made on SquashFS image generation. */ removeListener(..._: mkSqFSEvtListen<"progress">): this; /** Emitted whenever process has threw an error. */ on(..._: mkSqFSEvtListen<"error">): this; /** Emitted whenever process has threw an error. */ once(..._: mkSqFSEvtListen<"error">): this; /** Emitted whenever process has threw an error. */ addListener(..._: mkSqFSEvtListen<"error">): this; /** Emitted whenever process has threw an error. */ removeListener(..._: mkSqFSEvtListen<"error">): this; } export declare function generateDesktop(desktopEntry: Partial<Record<string, string | null>>, actions?: Record<string, Partial<Record<string, string | null>> & { Name: string; }>): string; /** * A wrapper for `mksquashfs` binary. * * @returns An event used to watch for `mksquashfs` changes, including the job progress (in percent – as float number). */ export declare function mkSquashFs(...argv: string[]): mkSqFsEvt; /** * Returns the version of `mksquashfs` binary, as `SemVer` value. * * Under the hood, it executes `mksquashfs` with `-version`, parses * the `stdout` and tries to coerce it to `SemVer`. */ export declare function getSquashFsVer(): SemVer; /** * Concatenates files and/or buffers into a new buffer. */ export declare function joinFiles(...filesAndBuffers: readonly (string | ArrayBufferLike | Uint8Array)[]): Promise<Uint8Array<ArrayBuffer>>; /** * Maps Node.js architecture to the AppImage-friendly format. */ export declare const mapArch: Readonly<Partial<Record<ForgeArch, AppImageArch>>>; /** * A function to fetch metadata from buffer in PNG or SVG format. * * @remarks * * For PNGs, it gets required information (like image width or height) * from IHDR header (if it is correct according to spec), otherwise it sets * dimension values to `null`. * * For SVGs, it gets information about the dimensions from `<svg>` tag. If it is * missing, this function will return `null` for `width` and/or `height`. * * This function will also recognize file formats based on *MAGIC* headers – for * SVGs, it looks for existence of `<svg>` tag, for PNGs it looks if file starts * from the specific bytes. * * @param image PNG/SVG/XPM image buffer. */ export declare function getImageMetadata(image: Buffer): ImageMetadata; export {}; //# sourceMappingURL=utils.d.ts.map