export type DebuggerConstructor = { /** * - A custom logger (must implement Console methods). */ logger: Partial; /** * - The unique identifier for this debugger instance. */ id: string; /** * - Whether to hide the instance id whenever a sub id is set. */ autoHideId?: boolean; /** * - Whether to enable internal debug logging. */ debugMode: boolean; /** * - Whether to emit debug events to listeners. */ canEmitLogs?: boolean; /** * - Whether to enable log color support. */ useLogColors?: boolean; }; export type ConsoleFacade = { /** * - Writes a log message. */ log: (...data: any[]) => void; /** * - Writes an informational message. */ info: (...data: any[]) => void; /** * - Writes a warning message. */ warn: (...data: any[]) => void; /** * - Writes an error message. */ error: (...data: any[]) => void; /** * - Writes a debug message. */ debug: (...data: any[]) => void; /** * - Writes an XML representation. */ dirxml: (...data: any[]) => void; /** * - Starts a log group. */ group: (...data: any[]) => void; /** * - Starts a collapsed log group. */ groupCollapsed: (...data: any[]) => void; /** * - Writes a stack trace. */ trace: (...data: any[]) => void; /** * - Logs when the condition is false. */ assert: (condition: boolean, ...data: any[]) => void; /** * - Logs an object. */ dir: (item: any, options?: import('util').InspectOptions) => void; /** * - Logs a table. */ table: (tabularData: any, properties?: string[]) => void; /** * - Clears the console. */ clear: () => void; /** * - Ends the current log group. */ groupEnd: () => void; /** * - Logs the call count for a label. */ count: (label?: string) => void; /** * - Resets the counter for a label. */ countReset: (label?: string) => void; /** * - Starts a timer. */ time: (label?: string) => void; /** * - Stops a timer. */ timeEnd: (label?: string) => void; /** * - Logs the current timer value. */ timeLog: (label?: string, ...data: any[]) => void; /** * - Adds a timestamp marker. */ timeStamp: (label?: string) => void; /** * - Starts a profiler. */ profile: (label?: string) => void; /** * - Stops a profiler. */ profileEnd: (label?: string) => void; }; export type TinyDebuggerEvents = { setLogSubId: (value: string) => void; setUseLogColors: (value: boolean) => void; setDebugMode: (value: boolean) => void; * 'debug:clear': () => void; * 'debug:groupEnd': () => void; * 'debug:logLabel': (logType: string, label?: string) => void; * 'debug:timeLog': (label?: string, ...args: any[]) => void; * 'debug:assert': (condition?: boolean, ...args: any[]) => void; * 'debug:dir': (item?: any, options?: any) => void; * 'debug:table': (tabularData?: any, properties?: string[]) => void; * 'debug:log': (prefix: string, message: string, ...args: any[]) => void; } & Record void>; /** * @typedef {Object} DebuggerConstructor * @property {Partial} logger - A custom logger (must implement Console methods). * @property {string} id - The unique identifier for this debugger instance. * @property {boolean} [autoHideId=false] - Whether to hide the instance id whenever a sub id is set. * @property {boolean} debugMode - Whether to enable internal debug logging. * @property {boolean} [canEmitLogs=false] - Whether to emit debug events to listeners. * @property {boolean} [useLogColors=false] - Whether to enable log color support. */ /** * A `console`-compatible facade. Every method delegates to a TinyDebugger instance. * @typedef {Object} ConsoleFacade * @property {(...data: any[]) => void} log - Writes a log message. * @property {(...data: any[]) => void} info - Writes an informational message. * @property {(...data: any[]) => void} warn - Writes a warning message. * @property {(...data: any[]) => void} error - Writes an error message. * @property {(...data: any[]) => void} debug - Writes a debug message. * @property {(...data: any[]) => void} dirxml - Writes an XML representation. * @property {(...data: any[]) => void} group - Starts a log group. * @property {(...data: any[]) => void} groupCollapsed - Starts a collapsed log group. * @property {(...data: any[]) => void} trace - Writes a stack trace. * @property {(condition: boolean, ...data: any[]) => void} assert - Logs when the condition is false. * @property {(item: any, options?: import('util').InspectOptions) => void} dir - Logs an object. * @property {(tabularData: any, properties?: string[]) => void} table - Logs a table. * @property {() => void} clear - Clears the console. * @property {() => void} groupEnd - Ends the current log group. * @property {(label?: string) => void} count - Logs the call count for a label. * @property {(label?: string) => void} countReset - Resets the counter for a label. * @property {(label?: string) => void} time - Starts a timer. * @property {(label?: string) => void} timeEnd - Stops a timer. * @property {(label?: string, ...data: any[]) => void} timeLog - Logs the current timer value. * @property {(label?: string) => void} timeStamp - Adds a timestamp marker. * @property {(label?: string) => void} profile - Starts a profiler. * @property {(label?: string) => void} profileEnd - Stops a profiler. */ /** * Event map for {@link TinyDebugger}. * * `TinyDebugger` is a base class that is widely extended, so the event map is kept * open (`Record`) to allow subclasses to emit their own events while * still providing autocomplete for the well-known debug events. * * @typedef {{ * setLogSubId: (value: string) => void, * setUseLogColors: (value: boolean) => void, * setDebugMode: (value: boolean) => void, * 'debug:clear': () => void, * 'debug:groupEnd': () => void, * 'debug:logLabel': (logType: string, label?: string) => void, * 'debug:timeLog': (label?: string, ...args: any[]) => void, * 'debug:assert': (condition?: boolean, ...args: any[]) => void, * 'debug:dir': (item?: any, options?: any) => void, * 'debug:table': (tabularData?: any, properties?: string[]) => void, * 'debug:log': (prefix: string, message: string, ...args: any[]) => void, * } & Record void>} TinyDebuggerEvents */ /** @type {new () => import('../../jsdoc/EventEmitter.mjs').ICustomEventEmitter} */ declare const TypedEventEmitter: new () => import('../../jsdoc/EventEmitter.mjs').ICustomEventEmitter; /** * A lightweight debugging utility that wraps console methods and provides event emission. */ declare class TinyDebugger extends TypedEventEmitter { #private; /** * Creates an instance of TinyDebugger. * @param {DebuggerConstructor} config - The configuration object. * @throws {TypeError} If parameters do not match the required types. */ constructor({ logger, id, debugMode, canEmitLogs, useLogColors, autoHideId, }: DebuggerConstructor); /** * @returns {string} The instance debug id. */ get logId(): string; /** * @returns {string} The instance debug sub id. */ get logSubId(): string; /** * @param {string} value - The new instance debug sub id. * @throws {Error} If the sub id has not been set yet. */ set logSubId(value: string); /** * @returns {boolean} Whether event emission is enabled. */ get canEmitLogs(): boolean; /** * @returns {boolean} True if log colors mode is enabled. */ get useLogColors(): boolean; /** * @param {boolean} value - Enables or disables log colors mode. * @throws {TypeError} If the value is not a boolean. */ set useLogColors(value: boolean); /** * @returns {boolean} True if debug mode is enabled. */ get debugMode(): boolean; /** * @param {boolean} value - Enables or disables debug mode. * @throws {TypeError} If the value is not a boolean. */ set debugMode(value: boolean); /** * Adds a new color shortcut. * @param {string} id - The shortcut ID (e.g., 'red'). * @param {string} code - The replacement string (e.g., ANSI code). */ _addLogColor(id: string, code: string): void; /** * Removes a color shortcut. * @param {string} id - The shortcut ID to remove. */ _removeLogColor(id: string): void; /** * Adds a new prefix shortcut. * @param {string} id - The shortcut ID (e.g., 'info'). * @param {string} text - The text to insert (e.g., '[INFO]'). */ _addLogPrefix(id: string, text: string): void; /** * Removes a prefix shortcut. * @param {string} id - The shortcut ID to remove. */ _removeLogPrefix(id: string): void; /** * Internal method to apply prefix and color replacements. * @param {string} text - The text to format. * @returns {string} The formatted text. */ _applyLogFormatting(text: string): string; /** * Clears the console. * @returns {void|undefined} */ logClear(): void | undefined; /** * Ends the current console group. * @returns {void|undefined} */ logGroupEnd(): void | undefined; /** * Logs a specific console type with an optional label. * @param {'count' | 'countReset' | 'time' | 'timeEnd' | 'profile' | 'profileEnd' | 'timeStamp'} logType - The console method to use. * @param {string} [label] - The label to associate with the log. * @throws {TypeError} If the specified logType is not supported or label is not a string. * @returns {void} */ logLabel(logType: 'count' | 'countReset' | 'time' | 'timeEnd' | 'profile' | 'profileEnd' | 'timeStamp', label?: string): void; /** * Starts a timer with a label. * @param {string} [label] - The label for the timer. * @param {...any} args - Additional arguments for the timer. * @throws {TypeError} If label is not a string. * @returns {void} */ logTimeLabel(label?: string, ...args: any[]): void; /** * Asserts a condition and logs a message if the condition is false. * @param {boolean} [condition] - The condition to evaluate. * @param {...any} args - Arguments to log if the condition is false. * @returns {void} */ logAssert(condition?: boolean, ...args: any[]): void; /** * Logs an element as a JavaScript object. * @param {any} [item] - The object to inspect. * @param {import('util').InspectOptions} [options] - Inspection options. * @returns {void} */ logDir(item?: any, options?: import('util').InspectOptions): void; /** * Displays a table of objects. * @param {any} [tabularData] - The data to be displayed in a table. * @param {string[]} [properties] - The properties (columns) to display. * @throws {TypeError} If properties is provided but is not an array of strings. * @returns {void} */ logTable(tabularData?: any, properties?: string[]): void; /** * Internal helper to handle debug logging. * @param {'log' | 'info' | 'warn' | 'error' | 'debug' | 'dirxml' | 'group' | 'groupCollapsed' | 'trace'} logType - The console method to use. * @param {string} message - The message to log. * @param {...any} args - Additional arguments to pass to the logger. * @throws {TypeError} If logType is invalid or message is not a string. * @returns {void} */ log(logType: 'log' | 'info' | 'warn' | 'error' | 'debug' | 'dirxml' | 'group' | 'groupCollapsed' | 'trace', message: string, ...args: any[]): void; /** * Builds a `console`-compatible facade bound to this instance. * Every call is routed through the existing logging methods, so formatting, * debug mode and event emission keep working without extra code. * @returns {ConsoleFacade} A `console`-compatible object bound to this instance. */ toConsole(): ConsoleFacade; } export default TinyDebugger; //# sourceMappingURL=TinyDebugger.d.mts.map