UNPKG

narraleaf

Version:

Create your visual novel with Electron and React

104 lines (103 loc) 4.7 kB
import chalk from "chalk"; import { App } from "./app"; import { PlatformInfo } from "../utils/pure/os"; type LoggerConfig = { debug: boolean; info: boolean; warn: boolean; error: boolean; platform: PlatformInfo; }; type MessageContent = string | number | null | undefined | Array<any> | object; export declare class Logger { private config; static readonly chalk: chalk.Chalk & chalk.ChalkFunction & { supportsColor: chalk.ColorSupport | false; Level: chalk.Level; Color: ("black" | "blue" | "cyan" | "gray" | "green" | "grey" | "magenta" | "red" | "white" | "yellow" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright") | ("bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright"); ForegroundColor: "black" | "blue" | "cyan" | "gray" | "green" | "grey" | "magenta" | "red" | "white" | "yellow" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright"; BackgroundColor: "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright"; Modifiers: "bold" | "reset" | "hidden" | "italic" | "visible" | "underline" | "dim" | "inverse" | "strikethrough"; stderr: chalk.Chalk & { supportsColor: chalk.ColorSupport | false; }; }; static Types: { INFO: string; WARN: string; ERROR: string; DEBUG: string; }; private files; constructor(config: LoggerConfig); addFile(file: string): this; offFile(file: string): this; debug(...content: MessageContent[]): this; info(...content: MessageContent[]): this; warn(...content: MessageContent[]): this; error(...content: MessageContent[]): this; raw(content: string): this; private mkMessage; private messageToString; private appendLog; } declare class LoadingTask { protected app: App; protected fallTask: FallTask; static Frames: { 0: string[]; }; text: string | undefined; frame: keyof typeof LoadingTask.Frames; _tick: number | undefined; _interval: NodeJS.Timeout | undefined; constructor(app: App, fallTask: FallTask, frame?: keyof typeof LoadingTask.Frames); start(str: string): this; clearLine(str?: string): void; end(str?: string): void; tick(): this; setText(str: string): this; getAnimation(tick: number): string; } declare class ProgressTask extends LoadingTask { protected app: App; protected fallTask: FallTask; static MaxLength: number; static ProgressBarFrames: { 0: { active: string; inactive: string; }; }; maxTask: number; currentTask: number; pFrame: keyof typeof ProgressTask.ProgressBarFrames; constructor(app: App, fallTask: FallTask, frame?: keyof typeof LoadingTask.Frames, pFrame?: keyof typeof ProgressTask.ProgressBarFrames); setMaxTask(n: number): this; setCurrentTask(n: number): this; incrementTask(): this; tick(): this; getProgressBar(prefixLength: number): string; getPFrame(active: boolean): string; log(message: string): this; } export declare class FallTask { protected app: App; protected logger: Logger; static LoadingTask: typeof LoadingTask; static fall(app: App, tasks: string[]): void; constructor(app: App, logger: Logger); start(str: string): this; step(str: string, steps?: number, space?: number): this; waitForLoading<T>(handler: (resolve: (value: T) => void, reject: (message: string) => void, setText: (text: string) => void) => Promise<void> | void, str: string, frame?: keyof typeof LoadingTask.Frames): Promise<T>; waitForProgress<T>(str: string, maxTask: number, handler: (resolve: (value: T) => void, reject: (message: string) => void, progress: ProgressTask) => Promise<void> | void, frame?: keyof typeof LoadingTask.Frames, pFrame?: keyof typeof ProgressTask.ProgressBarFrames): Promise<T>; end(str: string): this; error(str: string): this; getPrefix(): string; getEndPrefix(): string; getHeaderPrefix(): string; input(prompt: string): Promise<string>; confirm(prompt: string): Promise<boolean>; resetPrefix(): void; } export {};