// Generated by dts-bundle-generator v7.2.0 /** * A Log Widget is a piece of log content that is held at the bottom of the console log, and can be * animated/dynamically updated. It is used to create spinners, progress bars, and other rich visuals. */ export declare abstract class LogWidget { #private; constructor(); /** * Returns a string of what the widget looks like. Called 15 times per second to allow for smooth * animation. The value passed to now is the result of `performance.now`. */ protected abstract format(now: number): string; /** * The current FPS of the widget. If this is set to 0, the widget will not automatically update, * and you must call `update`. */ protected abstract fps: number; /** Removes this widget from the log. */ stop(finalMessage?: string): void; /** Forces a redraw to happen immediately. */ protected redraw(): void; /** @internal */ private __internalUpdate; /** @interal */ private __internalGetText; /** * Runs the given function without redrawing anything, then runs a redraws. This is used to batch * some updates together without having to redraw the current widgets more than once per frame. */ static batchRedraw(fn: () => void): void; /** Remove this widget with a success message. */ success(message: string): void; /** Remove this widget with a failure message. */ error(message: string | Error): void; get active(): boolean; } /** * A PrintableError is an error that defines some extra fields. `@paperdave/logger` handles these * objects within logs which allows customizing their appearance. It can be useful when building * CLIs to throw formatted error objects that instruct the user what they did wrong, without * printing a huge piece of text with a useless stack trace. * * @see {CLIError} an easy class to construct these objects. */ export interface PrintableError extends Error { description: string; hideStack?: boolean; hideName?: boolean; } /** * When this error is passed to `log.error`, it will be printed with a custom long-description. This * is useful to give users a better description on what the error actually is. Does not show a stack * trace by default. * * For example, in Purplet we throw this error if the `$DISCORD_BOT_TOKEN` environment variable is missing. * * ```ts * new CLIError( * 'Missing DISCORD_BOT_TOKEN environment variable!', * dedent` * Please create an ${chalk.cyan('.env')} file with the following contents: * * ${chalk.cyanBright('DISCORD_BOT_TOKEN')}=${chalk.grey('')} * * You can create or reset your bot token at ${devPortalLink} * ` * ); * ``` */ export declare class CLIError extends Error implements PrintableError { message: string; description: string; constructor(message: string, description: string); get hideStack(): boolean; get hideName(): boolean; } export declare function setLogFilter(...newFilters: Array): void; export interface InjectOptions { console?: typeof console; process?: typeof process; uncaughtExceptions?: boolean; unhandledRejections?: boolean; exitOnError?: boolean; } /** * Injects the logger into `globalThis.console`, or whatever is given. Only fills the following * functions: `log`, `info`, `warn`, `error`, `debug`. * * For accessing some special functions, use the `log` object directly. */ export declare function injectLogger(opts?: InjectOptions): void; export type CustomLoggerColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright" | `#${string}` | number | [ number, number, number ]; export type LogType = "info" | "warn" | "debug" | "error"; export interface CustomLoggerOptions { id?: string; color?: CustomLoggerColor; coloredText?: boolean; boldText?: boolean; level?: number; type?: LogType; debug?: boolean; } /** Matches `string`, `number`, and other objects with a `.toString()` method. */ export interface StringLike { toString(): string; } export interface FormatStringArgs { "%s": StringLike | null | undefined; "%d": number | null | undefined; "%i": number | null | undefined; "%f": number | null | undefined; "%x": number | null | undefined; "%X": number | null | undefined; "%o": any; "%O": any; "%c": string | null | undefined; "%j": any; } export type ProcessFormatString = S extends `${string}%${infer K}${infer B}` ? `%${K}` extends keyof FormatStringArgs ? [ FormatStringArgs[`%${K}`], ...ProcessFormatString ] : ProcessFormatString : [ ]; export type LogData = string | number | boolean | object | null | undefined; export interface LogFunction { /** * Writes data to the log. The first argument can be a printf-style format string, or usage * similar to `console.log`. Handles formatting objects including `Error` objects with pretty * colorized stack traces. * * List of formatters: * * - %s - String. * - %d, %f - Number. * - %i - Integer. * - %x - Hex. * - %X - Hex (uppercase) * - %o - Object. * - %O - Object (pretty printed). * - %j - JSON. */ (data?: S, ...a: ProcessFormatString): void; /** Calling a logger function with no arguments prints a blank line. */ (): void; visible: boolean; name: string; } /** Built in blue "info" logger. */ export declare const info: LogFunction; /** Built in yellow "warn" logger. */ export declare const warn: LogFunction; /** Built in orange "trace" logger. Prints a stack trace after the message. */ export declare const trace: LogFunction; /** Built in red "error" logger, uses a unicode X instead of the word Error. */ export declare const error: LogFunction; /** Built in cyan "debug" logger. */ export declare const debug: LogFunction; /** Built in green "success" logger, uses a unicode Check instead of the word Success. */ export declare const success: LogFunction; /** Writes raw line of text without a prefix or filtering. Does NOT support formatting features. */ export declare function writeLine(message?: string): void; /** Shorthand notation for a dictionary object, aka Record */ export type Dict = Record; /** Represents an empty object. */ export type EmptyObject = Dict; declare enum Color { Black = "black", Red = "red", Green = "green", Yellow = "yellow", Blue = "blue", Magenta = "magenta", Cyan = "cyan", White = "white", BlackBright = "blackBright", RedBright = "redBright", GreenBright = "greenBright", YellowBright = "yellowBright", BlueBright = "blueBright", MagentaBright = "magentaBright", CyanBright = "cyanBright", WhiteBright = "whiteBright" } /** A Progress Bar Style. Ascii is forced in non-unicode terminals. */ export declare enum BarStyle { Unicode = "unicode", Ascii = "ascii" } /** Options to be passed to `new Progress` */ export interface ProgressOptions = EmptyObject> { /** Text displayed to the right of the bar. */ text: string | ((props: ExtendedProps) => string); /** Text displayed to the left of the bar, if specified. */ beforeText?: string | ((props: ExtendedProps) => string); /** Properties to be passed to `text` and `beforeText` formatting functions. */ props?: Props; /** Width of the progress bar itself. Default: 35. */ barWidth?: number; /** Progress bar style, default `BarStyle.Unicode` */ barStyle?: BarStyle | `${BarStyle}`; /** Spinner settings. Set to `null` to disable the spinner. */ spinner?: Partial | null; /** Starting value. Default: 0. */ value?: number; /** Ending value. Default: 100. */ total?: number; } export interface BarSpinnerOptions { /** Frames per second of the Spinner. */ fps: number; /** Sequence of frames for the spinner. */ frames: string[]; /** Color of the spinner. If set to `match` it will match the bar. */ color: Color | `${Color}` | "match"; } export type ExtendedProps = T & { value: number; total: number; /** Number 0-1, inclusive. */ progress: number; }; export declare class Progress> extends LogWidget { #private; protected fps: number; constructor(options: ProgressOptions | string); /** Properties to be passed to `text` and `beforeText` formatting functions. */ set props(value: Partial); get props(): ExtendedProps; /** Text displayed to the right of the bar. */ get text(): string; set text(value: string | (() => string)); /** Text displayed to the left of the bar, if specified. */ get beforeText(): string; set beforeText(value: string | (() => string)); /** Current value of progress bar. */ get value(): number; set value(value: number); /** Total value of progress bar. When value === total, the bar is full. */ get total(): number; set total(value: number); /** Updates the progress bar with a new value and props. */ update(value: number, props?: Partial): void; protected format(now: number): string; success(message?: string): void; error(message?: string | Error): void; } export interface WithProgressOptions, T> extends ProgressOptions { /** Message to print on success. If a function, the result is passed. */ successText?: string | ((result: T) => string); /** Message to print on fail. If a function, the error is passed. */ failureText?: string | ((error: Error) => string); } /** Calls a function with a progress bar. */ export declare function withProgress, T>(opts: WithProgressOptions | string, fn: (bar: Progress) => Promise): Promise; export interface SpinnerOptions> { /** Text displayed to the right of the spinner. */ text: string | ((props: Props) => string); /** Color of the spinner. */ color?: Color | `${Color}` | false; /** Sequence of frames for the spinner. */ frames?: string[]; /** Frames per second of the Spinner. */ fps?: number; /** Properties to be passed to the `text` formatting function. */ props?: Props; } export declare class Spinner = EmptyObject> extends LogWidget { #private; protected fps: number; constructor(options: SpinnerOptions | string); /** Text displayed to the right of the spinner. */ get text(): string; set text(value: string | (() => string)); /** Properties to be passed to `text` and `beforeText` formatting functions. */ set props(value: Partial); get props(): Props; /** * Updates the spinner by supplying either a new `message` string or a partial object of props to * be used by the custom message function. */ update(newProps: Partial): void; update(newMessage: string): void; protected format(now: number): string; success(message?: string): void; error(message?: string | Error): void; } export interface WithSpinnerOptions, T> extends SpinnerOptions { successText?: string | ((result: T) => string); failureText?: string | ((error: Error) => string); } /** Calls a function with a spinner. */ export declare function withSpinner, T>(spinnerOptions: WithSpinnerOptions | string, fn: (spinner: Spinner) => Promise): Promise; /** * Boolean if the current environment supports unicode. Functions identically to the * `is-unicode-supported` package. */ export declare const isUnicodeSupported: boolean; /** * Contains unicode symbols for various log symbols, falling to non-unicode characters if needed. * Does not have colors, unlike the `log-symbols` package this is based off of. */ export declare const logSymbols: { error: string; success: string; info: string; warning: string; }; export type LogConstructor = { /** * Creates a logger function with a psuedo-random color based off the namespace. * * A custom color can be assigned by doing any of the following: * * - Passing a color argument with a color name "blue" * - Passing a color argument with a hex value "#0000FF" * - Passing a color argument with an ANSI 256 palette value (0-255) * - Passing a color argument with a RGB value [0, 0, 255] * - Using chalk or another formatter on the namespace name. */ new (name: string, options?: CustomLoggerOptions): LogFunction; /** * Creates a logger function with a psuedo-random color based off the namespace. * * A custom color can be assigned by doing any of the following: * * - Passing a color argument with a color name "blue" * - Passing a color argument with a hex value "#0000FF" * - Passing a color argument with an ANSI 256 palette value (0-255) * - Passing a color argument with a RGB value [0, 0, 255] * - Using chalk or another formatter on the namespace name. */ (name: string, options?: CustomLoggerOptions): LogFunction; info: typeof info; warn: typeof warn; debug: typeof debug; error: typeof error; success: typeof success; trace: typeof trace; writeLine: typeof writeLine; }; declare const _default: LogConstructor; export { default as chalk } from "chalk"; export * as ansiEscapes from "ansi-escapes"; export { _default as Logger, _default as default, }; export {};