UNPKG

tiny-electron-essentials

Version:

A lightweight and modular utility library for Electron apps, offering simplified window management, tray support, IPC channels, and custom frameless window styling.

83 lines 2.98 kB
/** * An extended error object that may contain additional metadata. * * @typedef {Error & { * code?: any, // Optional error code, any type. * data?: any // Optional additional error data. * }} ErrorParsed */ /** * Converts an `Error` object into a plain JSON-serializable object. * Useful for sending errors between processes or over the network. * * @param {ErrorParsed} error - The error object to serialize. * @returns {{ * name: string, // Error name (e.g., 'TypeError') * message: string, // Error message * stack?: string, // Optional stack trace * code?: any, // Optional error code * data?: any // Optional additional error data * }} * @throws {Error} Throws if the input is not a valid error object. */ export function serializeError(error: ErrorParsed): { name: string; message: string; stack?: string; code?: any; data?: any; }; /** * Converts a plain JSON object back into an `Error` instance. * Useful for reconstructing errors received over IPC or network. * * @param {{ * name?: string, // Optional error name (defaults to 'Error') * message: string, // Error message * stack?: string, // Optional stack trace * code?: any, // Optional error code * data?: any // Optional additional error data * }} json - The JSON object representing the error. * @returns {ErrorParsed} The reconstructed error object. * @throws {Error} Throws if the input JSON does not match the expected structure. */ export function deserializeError(json: { name?: string; message: string; stack?: string; code?: any; data?: any; }): ErrorParsed; /** * Performs a deep clone of an object, array, or date. * Useful for creating fully independent copies of nested structures. * * @param {*} obj - The object to clone. Supports plain objects, arrays, and Date instances. * @returns {*} A deep-cloned copy of the input. * @throws {Error} Throws if the input type is not supported (e.g., functions, Map, Set). */ export function deepClone(obj: any): any; /** * Move all elements from document.body into a target container, * except for <style> and <script> tags. * * @param {HTMLElement} targetElement - The destination container. */ export function moveBodyContentTo(targetElement: HTMLElement): void; /** * Checks if two DOM elements are colliding on the screen. * * @param {Element} elem1 - First DOM element. * @param {Element} elem2 - Second DOM element. * @returns {boolean} - Returns true if the elements are colliding. */ export function areElementsColliding(elem1: Element, elem2: Element): boolean; export function checkEventsList(eventNames: Record<string, string>, list: Record<string, string>): void; /** * An extended error object that may contain additional metadata. */ export type ErrorParsed = Error & { code?: any; data?: any; }; //# sourceMappingURL=Utils.d.mts.map