import * as dntShim from "../../../../../_dnt.shims.js"; /** * This is a hack to allow us to use the same type for both the color name and * an ANSI escape code. * * @see {@link https://github.com/microsoft/TypeScript/issues/29729#issuecomment-460346421} * * @internal */ export type Ansi = string & {}; /** * Color options for {@linkcode SpinnerOptions.color}. * * @experimental **UNSTABLE**: New API, yet to be vetted. */ export type Color = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | Ansi; /** * Options for {@linkcode Spinner}. * * @experimental **UNSTABLE**: New API, yet to be vetted. */ export interface SpinnerOptions { /** * The sequence of characters to be iterated through for animation. * * @default {["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]} */ spinner?: string[]; /** * The message to display next to the spinner. This can be changed while the * spinner is active. */ message?: string; /** * The time between each frame of the spinner in milliseconds. * * @default {75} */ interval?: number; /** * The color of the spinner. Defaults to the default terminal color. * This can be changed while the spinner is active. */ color?: Color; /** * The stream to write the spinner to. * * @default {Deno.stdout} */ output?: typeof dntShim.Deno.stderr | typeof dntShim.Deno.stdout; } /** * A spinner that can be used to indicate that something is loading. * * @experimental **UNSTABLE**: New API, yet to be vetted. * * @example Usage * ```ts ignore * import { Spinner } from "@std/cli/unstable-spinner"; * * const spinner = new Spinner({ message: "Loading...", color: "yellow" }); * spinner.start(); * * setTimeout(() => { * spinner.stop(); * console.log("Finished loading!"); * }, 3_000); * * // You can also use the spinner with `Deno.stderr` * const spinner2 = new Spinner({ message: "Loading...", color: "yellow", output: Deno.stderr }); * spinner2.start(); * * setTimeout(() => { * spinner2.stop(); * console.error("Finished loading!"); * }, 3_000); * ``` */ export declare class Spinner { #private; /** * The message to display next to the spinner. * This can be changed while the spinner is active. * * @example Usage * ```ts ignore * import { Spinner } from "@std/cli/unstable-spinner"; * * const spinner = new Spinner({ message: "Working..." }); * spinner.start(); * * for (let step = 0; step < 5; step++) { * // do some work * await new Promise((resolve) => setTimeout(resolve, 1000)); * * spinner.message = `Finished Step #${step}`; * } * * spinner.stop(); * console.log("Done!"); * ``` */ message: string; /** * Creates a new spinner. * * @param options Options for the spinner. */ constructor(options?: SpinnerOptions); /** * Set the color of the spinner. This defaults to the default terminal color. * This can be changed while the spinner is active. * * Providing `undefined` will use the default terminal color. * * @param value Color to set. * * @example Usage * ```ts ignore * import { Spinner } from "@std/cli/unstable-spinner"; * * const spinner = new Spinner({ message: "Loading...", color: "yellow" }); * spinner.start(); * * // do some work * await new Promise((resolve) => setTimeout(resolve, 1000)); * * spinner.color = "magenta"; * ``` */ set color(value: Color | undefined); /** * Get the current color of the spinner. * * @example Usage * ```ts no-assert * import { Spinner } from "@std/cli/unstable-spinner"; * * const spinner = new Spinner({ message: "Loading", color: "blue" }); * * spinner.color; // Blue ANSI escape sequence * ``` * @returns The color of the spinner or `undefined` if it's using the terminal default. */ get color(): Color | undefined; /** * Starts the spinner. * * @example Usage * ```ts ignore * import { Spinner } from "@std/cli/unstable-spinner"; * * const spinner = new Spinner({ message: "Loading..." }); * spinner.start(); * ``` */ start(): void; /** * Stops the spinner. * * @example Usage * ```ts ignore * import { Spinner } from "@std/cli/unstable-spinner"; * * const spinner = new Spinner({ message: "Loading..." }); * spinner.start(); * * setTimeout(() => { * spinner.stop(); * console.log("Finished loading!"); * }, 3_000); * ``` */ stop(): void; } //# sourceMappingURL=unstable_spinner.d.ts.map