node-notifier
Version:
A Node.js module for sending notifications on native Mac, Windows (post and pre 8) and Linux (or Growl as fallback)
61 lines • 2.82 kB
TypeScript
import { NotificationCallback } from "../types.js";
import cp from "node:child_process";
import net from "node:net";
import { EventEmitter } from "node:events";
/** Notification options while they are mapped to a notifier's flags. */
export type OptionBag = Record<string, any>;
/** Called by the notifier binaries with stderr or an error, and stdout. */
export type CommandCallback = (err: Error | string | null | undefined, stdout?: string) => void;
declare function clone<T>(obj: T): T;
declare function commandWithoutShell(notifier: string, options: string[], cb: CommandCallback): cp.ChildProcess;
declare function fileCommand(notifier: string, options: string[], cb: CommandCallback): cp.ChildProcess;
declare function immediateFileCommand(notifier: string, options: string[], cb: (err?: Error) => void): void;
declare function mapToNotifySend(options: OptionBag): OptionBag;
declare function mapToGrowl(options: OptionBag): OptionBag;
declare function mapToMac(options: OptionBag): OptionBag;
declare function actionJackerDecorator(emitter: EventEmitter, options: OptionBag, fn: NotificationCallback | undefined, mapper?: (data: string) => string | false): (err?: Error | string | null, data?: unknown) => void;
interface ArgumentListOptions {
initial?: unknown[];
keyExtra?: string;
allowedArguments?: string[];
noEscape?: boolean;
explicitTrue?: boolean;
keepNewlines?: boolean;
wrapper?: string;
}
declare function constructArgumentList(options: OptionBag, extra?: ArgumentListOptions): string[];
declare function mapToWin8(options: OptionBag): OptionBag;
declare function mapToNotifu(options: OptionBag): OptionBag;
declare function isMac(): boolean;
declare function isMojaveOrLater(): boolean;
declare function isWin8(): boolean;
declare function isWSL(): boolean;
declare function isLessThanWin8(): boolean;
/** Where the named pipe server for SnoreToast's results is kept. */
export interface PipeServer {
namedPipe: string;
instance?: net.Server;
}
declare function createNamedPipe(server: PipeServer): Promise<Buffer[]>;
declare const utils: {
clone: typeof clone;
commandWithoutShell: typeof commandWithoutShell;
fileCommand: typeof fileCommand;
immediateFileCommand: typeof immediateFileCommand;
mapToNotifySend: typeof mapToNotifySend;
mapToGrowl: typeof mapToGrowl;
mapToMac: typeof mapToMac;
isArray: typeof Array.isArray;
actionJackerDecorator: typeof actionJackerDecorator;
constructArgumentList: typeof constructArgumentList;
mapToWin8: typeof mapToWin8;
mapToNotifu: typeof mapToNotifu;
isMac: typeof isMac;
isMojaveOrLater: typeof isMojaveOrLater;
isWin8: typeof isWin8;
isWSL: typeof isWSL;
isLessThanWin8: typeof isLessThanWin8;
createNamedPipe: typeof createNamedPipe;
};
export { utils as default };
//# sourceMappingURL=utils.d.ts.map