first commit
This commit is contained in:
332
node_modules/ora/index.d.ts
generated
vendored
Normal file
332
node_modules/ora/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,332 @@
|
||||
import {type SpinnerName} from 'cli-spinners';
|
||||
|
||||
export type Spinner = {
|
||||
readonly interval?: number;
|
||||
readonly frames: string[];
|
||||
};
|
||||
|
||||
export type Color =
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'gray';
|
||||
|
||||
export type PrefixTextGenerator = () => string;
|
||||
|
||||
export type SuffixTextGenerator = () => string;
|
||||
|
||||
export type Options = {
|
||||
/**
|
||||
The text to display next to the spinner.
|
||||
*/
|
||||
readonly text?: string;
|
||||
|
||||
/**
|
||||
Text or a function that returns text to display before the spinner. No prefix text will be displayed if set to an empty string.
|
||||
*/
|
||||
readonly prefixText?: string | PrefixTextGenerator;
|
||||
|
||||
/**
|
||||
Text or a function that returns text to display after the spinner text. No suffix text will be displayed if set to an empty string.
|
||||
*/
|
||||
readonly suffixText?: string | SuffixTextGenerator;
|
||||
|
||||
/**
|
||||
The name of one of the provided spinners. See `example.js` in this repo if you want to test out different spinners. On Windows (except for Windows Terminal), it will always use the line spinner as the Windows command-line doesn't have proper Unicode support.
|
||||
|
||||
@default 'dots'
|
||||
|
||||
Or an object like:
|
||||
|
||||
@example
|
||||
```
|
||||
{
|
||||
frames: ['-', '+', '-'],
|
||||
interval: 80 // Optional
|
||||
}
|
||||
```
|
||||
*/
|
||||
readonly spinner?: SpinnerName | Spinner;
|
||||
|
||||
/**
|
||||
The color of the spinner.
|
||||
|
||||
@default 'cyan'
|
||||
*/
|
||||
readonly color?: Color | boolean;
|
||||
|
||||
/**
|
||||
Set to `false` to stop Ora from hiding the cursor.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly hideCursor?: boolean;
|
||||
|
||||
/**
|
||||
Indent the spinner with the given number of spaces.
|
||||
|
||||
@default 0
|
||||
*/
|
||||
readonly indent?: number;
|
||||
|
||||
/**
|
||||
Interval between each frame.
|
||||
|
||||
Spinners provide their own recommended interval, so you don't really need to specify this.
|
||||
|
||||
Default: Provided by the spinner or `100`.
|
||||
*/
|
||||
readonly interval?: number;
|
||||
|
||||
/**
|
||||
Stream to write the output.
|
||||
|
||||
You could for example set this to `process.stdout` instead.
|
||||
|
||||
@default process.stderr
|
||||
*/
|
||||
readonly stream?: NodeJS.WritableStream;
|
||||
|
||||
/**
|
||||
Force enable/disable the spinner. If not specified, the spinner will be enabled if the `stream` is being run inside a TTY context (not spawned or piped) and/or not in a CI environment.
|
||||
|
||||
Note that `{isEnabled: false}` doesn't mean it won't output anything. It just means it won't output the spinner, colors, and other ansi escape codes. It will still log text.
|
||||
*/
|
||||
readonly isEnabled?: boolean;
|
||||
|
||||
/**
|
||||
Disable the spinner and all log text. All output is suppressed and `isEnabled` will be considered `false`.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly isSilent?: boolean;
|
||||
|
||||
/**
|
||||
Discard stdin input (except Ctrl+C) while running if it's TTY. This prevents the spinner from twitching on input, outputting broken lines on `Enter` key presses, and prevents buffering of input while the spinner is running.
|
||||
|
||||
This has no effect on Windows as there's no good way to implement discarding stdin properly there.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly discardStdin?: boolean;
|
||||
};
|
||||
|
||||
export type PersistOptions = {
|
||||
/**
|
||||
Symbol to replace the spinner with.
|
||||
|
||||
@default ' '
|
||||
*/
|
||||
readonly symbol?: string;
|
||||
|
||||
/**
|
||||
Text to be persisted after the symbol.
|
||||
|
||||
Default: Current `text`.
|
||||
*/
|
||||
readonly text?: string;
|
||||
|
||||
/**
|
||||
Text or a function that returns text to be persisted before the symbol. No prefix text will be displayed if set to an empty string.
|
||||
|
||||
Default: Current `prefixText`.
|
||||
*/
|
||||
readonly prefixText?: string | PrefixTextGenerator;
|
||||
|
||||
/**
|
||||
Text or a function that returns text to be persisted after the text after the symbol. No suffix text will be displayed if set to an empty string.
|
||||
|
||||
Default: Current `suffixText`.
|
||||
*/
|
||||
readonly suffixText?: string | SuffixTextGenerator;
|
||||
};
|
||||
|
||||
export type PromiseOptions<T> = {
|
||||
/**
|
||||
The new text of the spinner when the promise is resolved.
|
||||
|
||||
Keeps the existing text if `undefined`.
|
||||
*/
|
||||
successText?: string | ((result: T) => string) | undefined;
|
||||
|
||||
/**
|
||||
The new text of the spinner when the promise is rejected.
|
||||
|
||||
Keeps the existing text if `undefined`.
|
||||
*/
|
||||
failText?: string | ((error: Error) => string) | undefined;
|
||||
} & Options;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
export interface Ora {
|
||||
/**
|
||||
Change the text after the spinner.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
Change the text or function that returns text before the spinner.
|
||||
|
||||
No prefix text will be displayed if set to an empty string.
|
||||
*/
|
||||
prefixText: string;
|
||||
|
||||
/**
|
||||
Change the text or function that returns text after the spinner text.
|
||||
|
||||
No suffix text will be displayed if set to an empty string.
|
||||
*/
|
||||
suffixText: string;
|
||||
|
||||
/**
|
||||
Change the spinner color.
|
||||
*/
|
||||
color: Color | boolean;
|
||||
|
||||
/**
|
||||
Change the spinner indent.
|
||||
*/
|
||||
indent: number;
|
||||
|
||||
/**
|
||||
Get the spinner.
|
||||
*/
|
||||
get spinner(): Spinner;
|
||||
|
||||
/**
|
||||
Set the spinner.
|
||||
*/
|
||||
set spinner(spinner: SpinnerName | Spinner);
|
||||
|
||||
/**
|
||||
A boolean indicating whether the instance is currently spinning.
|
||||
*/
|
||||
get isSpinning(): boolean;
|
||||
|
||||
/**
|
||||
The interval between each frame.
|
||||
|
||||
The interval is decided by the chosen spinner.
|
||||
*/
|
||||
get interval(): number;
|
||||
|
||||
/**
|
||||
Start the spinner.
|
||||
|
||||
@param text - Set the current text.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
start(text?: string): this;
|
||||
|
||||
/**
|
||||
Stop and clear the spinner.
|
||||
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
stop(): this;
|
||||
|
||||
/**
|
||||
Stop the spinner, change it to a green `✔` and persist the current text, or `text` if provided.
|
||||
|
||||
@param text - Will persist text if provided.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
succeed(text?: string): this;
|
||||
|
||||
/**
|
||||
Stop the spinner, change it to a red `✖` and persist the current text, or `text` if provided.
|
||||
|
||||
@param text - Will persist text if provided.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
fail(text?: string): this;
|
||||
|
||||
/**
|
||||
Stop the spinner, change it to a yellow `⚠` and persist the current text, or `text` if provided.
|
||||
|
||||
@param text - Will persist text if provided.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
warn(text?: string): this;
|
||||
|
||||
/**
|
||||
Stop the spinner, change it to a blue `ℹ` and persist the current text, or `text` if provided.
|
||||
|
||||
@param text - Will persist text if provided.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
info(text?: string): this;
|
||||
|
||||
/**
|
||||
Stop the spinner and change the symbol or text.
|
||||
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
stopAndPersist(options?: PersistOptions): this;
|
||||
|
||||
/**
|
||||
Clear the spinner.
|
||||
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
clear(): this;
|
||||
|
||||
/**
|
||||
Manually render a new frame.
|
||||
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
render(): this;
|
||||
|
||||
/**
|
||||
Get a new frame.
|
||||
|
||||
@returns The spinner instance text.
|
||||
*/
|
||||
frame(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
Elegant terminal spinner.
|
||||
|
||||
@param options - If a string is provided, it is treated as a shortcut for `options.text`.
|
||||
|
||||
@example
|
||||
```
|
||||
import ora from 'ora';
|
||||
|
||||
const spinner = ora('Loading unicorns').start();
|
||||
|
||||
setTimeout(() => {
|
||||
spinner.color = 'yellow';
|
||||
spinner.text = 'Loading rainbows';
|
||||
}, 1000);
|
||||
```
|
||||
*/
|
||||
export default function ora(options?: string | Options): Ora;
|
||||
|
||||
/**
|
||||
Starts a spinner for a promise or promise-returning function. The spinner is stopped with `.succeed()` if the promise fulfills or with `.fail()` if it rejects.
|
||||
|
||||
@param action - The promise to start the spinner for or a promise-returning function.
|
||||
@param options - If a string is provided, it is treated as a shortcut for `options.text`.
|
||||
@returns The given promise.
|
||||
|
||||
@example
|
||||
```
|
||||
import {oraPromise} from 'ora';
|
||||
|
||||
await oraPromise(somePromise);
|
||||
```
|
||||
*/
|
||||
export function oraPromise<T>(
|
||||
action: PromiseLike<T> | ((spinner: Ora) => PromiseLike<T>),
|
||||
options?: string | PromiseOptions<T>
|
||||
): Promise<T>;
|
||||
|
||||
export {default as spinners} from 'cli-spinners';
|
||||
443
node_modules/ora/index.js
generated
vendored
Normal file
443
node_modules/ora/index.js
generated
vendored
Normal file
@@ -0,0 +1,443 @@
|
||||
import process from 'node:process';
|
||||
import chalk from 'chalk';
|
||||
import cliCursor from 'cli-cursor';
|
||||
import cliSpinners from 'cli-spinners';
|
||||
import logSymbols from 'log-symbols';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import stringWidth from 'string-width';
|
||||
import isInteractive from 'is-interactive';
|
||||
import isUnicodeSupported from 'is-unicode-supported';
|
||||
import stdinDiscarder from 'stdin-discarder';
|
||||
|
||||
class Ora {
|
||||
#linesToClear = 0;
|
||||
#isDiscardingStdin = false;
|
||||
#lineCount = 0;
|
||||
#frameIndex = -1;
|
||||
#lastSpinnerFrameTime = 0;
|
||||
#lastIndent = 0;
|
||||
#options;
|
||||
#spinner;
|
||||
#stream;
|
||||
#id;
|
||||
#initialInterval;
|
||||
#isEnabled;
|
||||
#isSilent;
|
||||
#indent;
|
||||
#text;
|
||||
#prefixText;
|
||||
#suffixText;
|
||||
color;
|
||||
|
||||
constructor(options) {
|
||||
if (typeof options === 'string') {
|
||||
options = {
|
||||
text: options,
|
||||
};
|
||||
}
|
||||
|
||||
this.#options = {
|
||||
color: 'cyan',
|
||||
stream: process.stderr,
|
||||
discardStdin: true,
|
||||
hideCursor: true,
|
||||
...options,
|
||||
};
|
||||
|
||||
// Public
|
||||
this.color = this.#options.color;
|
||||
|
||||
// It's important that these use the public setters.
|
||||
this.spinner = this.#options.spinner;
|
||||
|
||||
this.#initialInterval = this.#options.interval;
|
||||
this.#stream = this.#options.stream;
|
||||
this.#isEnabled = typeof this.#options.isEnabled === 'boolean' ? this.#options.isEnabled : isInteractive({stream: this.#stream});
|
||||
this.#isSilent = typeof this.#options.isSilent === 'boolean' ? this.#options.isSilent : false;
|
||||
|
||||
// Set *after* `this.#stream`.
|
||||
// It's important that these use the public setters.
|
||||
this.text = this.#options.text;
|
||||
this.prefixText = this.#options.prefixText;
|
||||
this.suffixText = this.#options.suffixText;
|
||||
this.indent = this.#options.indent;
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
this._stream = this.#stream;
|
||||
this._isEnabled = this.#isEnabled;
|
||||
|
||||
Object.defineProperty(this, '_linesToClear', {
|
||||
get() {
|
||||
return this.#linesToClear;
|
||||
},
|
||||
set(newValue) {
|
||||
this.#linesToClear = newValue;
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(this, '_frameIndex', {
|
||||
get() {
|
||||
return this.#frameIndex;
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(this, '_lineCount', {
|
||||
get() {
|
||||
return this.#lineCount;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get indent() {
|
||||
return this.#indent;
|
||||
}
|
||||
|
||||
set indent(indent = 0) {
|
||||
if (!(indent >= 0 && Number.isInteger(indent))) {
|
||||
throw new Error('The `indent` option must be an integer from 0 and up');
|
||||
}
|
||||
|
||||
this.#indent = indent;
|
||||
this.#updateLineCount();
|
||||
}
|
||||
|
||||
get interval() {
|
||||
return this.#initialInterval ?? this.#spinner.interval ?? 100;
|
||||
}
|
||||
|
||||
get spinner() {
|
||||
return this.#spinner;
|
||||
}
|
||||
|
||||
set spinner(spinner) {
|
||||
this.#frameIndex = -1;
|
||||
this.#initialInterval = undefined;
|
||||
|
||||
if (typeof spinner === 'object') {
|
||||
if (!Array.isArray(spinner.frames) || spinner.frames.length === 0 || spinner.frames.some(frame => typeof frame !== 'string')) {
|
||||
throw new Error('The given spinner must have a non-empty `frames` array of strings');
|
||||
}
|
||||
|
||||
if (spinner.interval !== undefined && !(Number.isInteger(spinner.interval) && spinner.interval > 0)) {
|
||||
throw new Error('`spinner.interval` must be a positive integer if provided');
|
||||
}
|
||||
|
||||
this.#spinner = spinner;
|
||||
} else if (!isUnicodeSupported()) {
|
||||
this.#spinner = cliSpinners.line;
|
||||
} else if (spinner === undefined) {
|
||||
// Set default spinner
|
||||
this.#spinner = cliSpinners.dots;
|
||||
} else if (spinner !== 'default' && cliSpinners[spinner]) {
|
||||
this.#spinner = cliSpinners[spinner];
|
||||
} else {
|
||||
throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`);
|
||||
}
|
||||
}
|
||||
|
||||
get text() {
|
||||
return this.#text;
|
||||
}
|
||||
|
||||
set text(value = '') {
|
||||
this.#text = value;
|
||||
this.#updateLineCount();
|
||||
}
|
||||
|
||||
get prefixText() {
|
||||
return this.#prefixText;
|
||||
}
|
||||
|
||||
set prefixText(value = '') {
|
||||
this.#prefixText = value;
|
||||
this.#updateLineCount();
|
||||
}
|
||||
|
||||
get suffixText() {
|
||||
return this.#suffixText;
|
||||
}
|
||||
|
||||
set suffixText(value = '') {
|
||||
this.#suffixText = value;
|
||||
this.#updateLineCount();
|
||||
}
|
||||
|
||||
get isSpinning() {
|
||||
return this.#id !== undefined;
|
||||
}
|
||||
|
||||
#formatAffix(value, separator, placeBefore = false) {
|
||||
const resolved = typeof value === 'function' ? value() : value;
|
||||
if (typeof resolved === 'string' && resolved !== '') {
|
||||
return placeBefore ? (separator + resolved) : (resolved + separator);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
#getFullPrefixText(prefixText = this.#prefixText, postfix = ' ') {
|
||||
return this.#formatAffix(prefixText, postfix, false);
|
||||
}
|
||||
|
||||
#getFullSuffixText(suffixText = this.#suffixText, prefix = ' ') {
|
||||
return this.#formatAffix(suffixText, prefix, true);
|
||||
}
|
||||
|
||||
#computeLineCountFrom(text, columns) {
|
||||
let count = 0;
|
||||
for (const line of stripAnsi(text).split('\n')) {
|
||||
count += Math.max(1, Math.ceil(stringWidth(line) / columns));
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#updateLineCount() {
|
||||
const columns = this.#stream.columns ?? 80;
|
||||
|
||||
// Simple side-effect free approximation (do not call functions)
|
||||
const prefixText = typeof this.#prefixText === 'function' ? '' : this.#prefixText;
|
||||
const suffixText = typeof this.#suffixText === 'function' ? '' : this.#suffixText;
|
||||
const fullPrefixText = (typeof prefixText === 'string' && prefixText !== '') ? prefixText + ' ' : '';
|
||||
const fullSuffixText = (typeof suffixText === 'string' && suffixText !== '') ? ' ' + suffixText : '';
|
||||
const spinnerChar = '-';
|
||||
const fullText = ' '.repeat(this.#indent) + fullPrefixText + spinnerChar + (typeof this.#text === 'string' ? ' ' + this.#text : '') + fullSuffixText;
|
||||
|
||||
this.#lineCount = this.#computeLineCountFrom(fullText, columns);
|
||||
}
|
||||
|
||||
get isEnabled() {
|
||||
return this.#isEnabled && !this.#isSilent;
|
||||
}
|
||||
|
||||
set isEnabled(value) {
|
||||
if (typeof value !== 'boolean') {
|
||||
throw new TypeError('The `isEnabled` option must be a boolean');
|
||||
}
|
||||
|
||||
this.#isEnabled = value;
|
||||
}
|
||||
|
||||
get isSilent() {
|
||||
return this.#isSilent;
|
||||
}
|
||||
|
||||
set isSilent(value) {
|
||||
if (typeof value !== 'boolean') {
|
||||
throw new TypeError('The `isSilent` option must be a boolean');
|
||||
}
|
||||
|
||||
this.#isSilent = value;
|
||||
}
|
||||
|
||||
frame() {
|
||||
// Ensure we only update the spinner frame at the wanted interval,
|
||||
// even if the render method is called more often.
|
||||
const now = Date.now();
|
||||
if (this.#frameIndex === -1 || now - this.#lastSpinnerFrameTime >= this.interval) {
|
||||
this.#frameIndex = ++this.#frameIndex % this.#spinner.frames.length;
|
||||
this.#lastSpinnerFrameTime = now;
|
||||
}
|
||||
|
||||
const {frames} = this.#spinner;
|
||||
let frame = frames[this.#frameIndex];
|
||||
|
||||
if (this.color) {
|
||||
frame = chalk[this.color](frame);
|
||||
}
|
||||
|
||||
const fullPrefixText = this.#getFullPrefixText(this.#prefixText, ' ');
|
||||
const fullText = typeof this.text === 'string' ? ' ' + this.text : '';
|
||||
const fullSuffixText = this.#getFullSuffixText(this.#suffixText, ' ');
|
||||
|
||||
return fullPrefixText + frame + fullText + fullSuffixText;
|
||||
}
|
||||
|
||||
clear() {
|
||||
if (!this.#isEnabled || !this.#stream.isTTY) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.#stream.cursorTo(0);
|
||||
|
||||
for (let index = 0; index < this.#linesToClear; index++) {
|
||||
if (index > 0) {
|
||||
this.#stream.moveCursor(0, -1);
|
||||
}
|
||||
|
||||
this.#stream.clearLine(1);
|
||||
}
|
||||
|
||||
if (this.#indent || this.#lastIndent !== this.#indent) {
|
||||
this.#stream.cursorTo(this.#indent);
|
||||
}
|
||||
|
||||
this.#lastIndent = this.#indent;
|
||||
this.#linesToClear = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.#isEnabled || this.#isSilent) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.clear();
|
||||
|
||||
let frameContent = this.frame();
|
||||
const columns = this.#stream.columns ?? 80;
|
||||
const actualLineCount = this.#computeLineCountFrom(frameContent, columns);
|
||||
|
||||
// If content would exceed viewport height, truncate it to prevent garbage
|
||||
const consoleHeight = this.#stream.rows;
|
||||
if (consoleHeight && consoleHeight > 1 && actualLineCount > consoleHeight) {
|
||||
const lines = frameContent.split('\n');
|
||||
const maxLines = consoleHeight - 1; // Reserve one line for truncation message
|
||||
frameContent = [...lines.slice(0, maxLines), '... (content truncated to fit terminal)'].join('\n');
|
||||
}
|
||||
|
||||
this.#stream.write(frameContent);
|
||||
this.#linesToClear = this.#computeLineCountFrom(frameContent, columns);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
start(text) {
|
||||
if (text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
if (this.#isSilent) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!this.#isEnabled) {
|
||||
const line = ' '.repeat(this.#indent) + this.#getFullPrefixText(this.#prefixText, ' ') + (this.text ? `- ${this.text}` : '') + this.#getFullSuffixText(this.#suffixText, ' ');
|
||||
|
||||
if (line.trim() !== '') {
|
||||
this.#stream.write(line + '\n');
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.isSpinning) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.#options.hideCursor) {
|
||||
cliCursor.hide(this.#stream);
|
||||
}
|
||||
|
||||
if (this.#options.discardStdin && process.stdin.isTTY) {
|
||||
this.#isDiscardingStdin = true;
|
||||
stdinDiscarder.start();
|
||||
}
|
||||
|
||||
this.render();
|
||||
this.#id = setInterval(this.render.bind(this), this.interval);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
stop() {
|
||||
clearInterval(this.#id);
|
||||
this.#id = undefined;
|
||||
this.#frameIndex = 0;
|
||||
|
||||
if (this.#isEnabled) {
|
||||
this.clear();
|
||||
if (this.#options.hideCursor) {
|
||||
cliCursor.show(this.#stream);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.#options.discardStdin && process.stdin.isTTY && this.#isDiscardingStdin) {
|
||||
stdinDiscarder.stop();
|
||||
this.#isDiscardingStdin = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
succeed(text) {
|
||||
return this.stopAndPersist({symbol: logSymbols.success, text});
|
||||
}
|
||||
|
||||
fail(text) {
|
||||
return this.stopAndPersist({symbol: logSymbols.error, text});
|
||||
}
|
||||
|
||||
warn(text) {
|
||||
return this.stopAndPersist({symbol: logSymbols.warning, text});
|
||||
}
|
||||
|
||||
info(text) {
|
||||
return this.stopAndPersist({symbol: logSymbols.info, text});
|
||||
}
|
||||
|
||||
stopAndPersist(options = {}) {
|
||||
if (this.#isSilent) {
|
||||
return this;
|
||||
}
|
||||
|
||||
const prefixText = options.prefixText ?? this.#prefixText;
|
||||
const fullPrefixText = this.#getFullPrefixText(prefixText, ' ');
|
||||
|
||||
const symbolText = options.symbol ?? ' ';
|
||||
|
||||
const text = options.text ?? this.text;
|
||||
const separatorText = symbolText ? ' ' : '';
|
||||
const fullText = (typeof text === 'string') ? separatorText + text : '';
|
||||
|
||||
const suffixText = options.suffixText ?? this.#suffixText;
|
||||
const fullSuffixText = this.#getFullSuffixText(suffixText, ' ');
|
||||
|
||||
const textToWrite = fullPrefixText + symbolText + fullText + fullSuffixText + '\n';
|
||||
|
||||
this.stop();
|
||||
this.#stream.write(textToWrite);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
export default function ora(options) {
|
||||
return new Ora(options);
|
||||
}
|
||||
|
||||
export async function oraPromise(action, options) {
|
||||
const actionIsFunction = typeof action === 'function';
|
||||
const actionIsPromise = typeof action.then === 'function';
|
||||
|
||||
if (!actionIsFunction && !actionIsPromise) {
|
||||
throw new TypeError('Parameter `action` must be a Function or a Promise');
|
||||
}
|
||||
|
||||
const {successText, failText} = typeof options === 'object'
|
||||
? options
|
||||
: {successText: undefined, failText: undefined};
|
||||
|
||||
const spinner = ora(options).start();
|
||||
|
||||
try {
|
||||
const promise = actionIsFunction ? action(spinner) : action;
|
||||
const result = await promise;
|
||||
|
||||
spinner.succeed(successText === undefined
|
||||
? undefined
|
||||
: (typeof successText === 'string' ? successText : successText(result)));
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
spinner.fail(failText === undefined
|
||||
? undefined
|
||||
: (typeof failText === 'string' ? failText : failText(error)));
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export {default as spinners} from 'cli-spinners';
|
||||
9
node_modules/ora/license
generated
vendored
Normal file
9
node_modules/ora/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
9
node_modules/ora/node_modules/chalk/license
generated
vendored
Normal file
9
node_modules/ora/node_modules/chalk/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
83
node_modules/ora/node_modules/chalk/package.json
generated
vendored
Normal file
83
node_modules/ora/node_modules/chalk/package.json
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"name": "chalk",
|
||||
"version": "5.6.2",
|
||||
"description": "Terminal string styling done right",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/chalk",
|
||||
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
||||
"type": "module",
|
||||
"main": "./source/index.js",
|
||||
"exports": "./source/index.js",
|
||||
"imports": {
|
||||
"#ansi-styles": "./source/vendor/ansi-styles/index.js",
|
||||
"#supports-color": {
|
||||
"node": "./source/vendor/supports-color/index.js",
|
||||
"default": "./source/vendor/supports-color/browser.js"
|
||||
}
|
||||
},
|
||||
"types": "./source/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && c8 ava && tsd",
|
||||
"bench": "matcha benchmark.js"
|
||||
},
|
||||
"files": [
|
||||
"source",
|
||||
"!source/index.test-d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"ansi",
|
||||
"style",
|
||||
"styles",
|
||||
"tty",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.10",
|
||||
"ava": "^3.15.0",
|
||||
"c8": "^7.10.0",
|
||||
"color-convert": "^2.0.1",
|
||||
"execa": "^6.0.0",
|
||||
"log-update": "^5.0.0",
|
||||
"matcha": "^0.7.0",
|
||||
"tsd": "^0.19.0",
|
||||
"xo": "^0.57.0",
|
||||
"yoctodelay": "^2.0.0"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
"@typescript-eslint/consistent-type-imports": "off",
|
||||
"@typescript-eslint/consistent-type-exports": "off",
|
||||
"@typescript-eslint/consistent-type-definitions": "off",
|
||||
"unicorn/expiring-todo-comments": "off"
|
||||
}
|
||||
},
|
||||
"c8": {
|
||||
"reporter": [
|
||||
"text",
|
||||
"lcov"
|
||||
],
|
||||
"exclude": [
|
||||
"source/vendor"
|
||||
]
|
||||
}
|
||||
}
|
||||
297
node_modules/ora/node_modules/chalk/readme.md
generated
vendored
Normal file
297
node_modules/ora/node_modules/chalk/readme.md
generated
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<br>
|
||||
<img width="320" src="media/logo.svg" alt="Chalk">
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</h1>
|
||||
|
||||
> Terminal string styling done right
|
||||
|
||||
[](https://codecov.io/gh/chalk/chalk)
|
||||
[](https://www.npmjs.com/package/chalk?activeTab=dependents)
|
||||
[](https://www.npmjs.com/package/chalk)
|
||||
|
||||

|
||||
|
||||
## Info
|
||||
|
||||
- [Why not switch to a smaller coloring package?](https://github.com/chalk/chalk?tab=readme-ov-file#why-not-switch-to-a-smaller-coloring-package)
|
||||
- See [yoctocolors](https://github.com/sindresorhus/yoctocolors) for a smaller alternative
|
||||
|
||||
## Highlights
|
||||
|
||||
- Expressive API
|
||||
- Highly performant
|
||||
- No dependencies
|
||||
- Ability to nest styles
|
||||
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
||||
- Auto-detects color support
|
||||
- Doesn't extend `String.prototype`
|
||||
- Clean and focused
|
||||
- Actively maintained
|
||||
- [Used by ~115,000 packages](https://www.npmjs.com/browse/depended/chalk) as of July 4, 2024
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install chalk
|
||||
```
|
||||
|
||||
**IMPORTANT:** Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now. [Read more.](https://github.com/chalk/chalk/releases/tag/v5.0.0)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
|
||||
console.log(chalk.blue('Hello world!'));
|
||||
```
|
||||
|
||||
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
|
||||
const log = console.log;
|
||||
|
||||
// Combine styled and normal strings
|
||||
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
||||
|
||||
// Compose multiple styles using the chainable API
|
||||
log(chalk.blue.bgRed.bold('Hello world!'));
|
||||
|
||||
// Pass in multiple arguments
|
||||
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
|
||||
|
||||
// Nest styles
|
||||
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
|
||||
|
||||
// Nest styles of the same type even (color, underline, background)
|
||||
log(chalk.green(
|
||||
'I am a green line ' +
|
||||
chalk.blue.underline.bold('with a blue substring') +
|
||||
' that becomes green again!'
|
||||
));
|
||||
|
||||
// ES2015 template literal
|
||||
log(`
|
||||
CPU: ${chalk.red('90%')}
|
||||
RAM: ${chalk.green('40%')}
|
||||
DISK: ${chalk.yellow('70%')}
|
||||
`);
|
||||
|
||||
// Use RGB colors in terminal emulators that support it.
|
||||
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
||||
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
||||
```
|
||||
|
||||
Easily define your own themes:
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
|
||||
const error = chalk.bold.red;
|
||||
const warning = chalk.hex('#FFA500'); // Orange color
|
||||
|
||||
console.log(error('Error!'));
|
||||
console.log(warning('Warning!'));
|
||||
```
|
||||
|
||||
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
||||
|
||||
```js
|
||||
import chalk from 'chalk';
|
||||
|
||||
const name = 'Sindre';
|
||||
console.log(chalk.green('Hello %s'), name);
|
||||
//=> 'Hello Sindre'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### chalk.`<style>[.<style>...](string, [string...])`
|
||||
|
||||
Example: `chalk.red.bold.underline('Hello', 'world');`
|
||||
|
||||
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
|
||||
Multiple arguments will be separated by space.
|
||||
|
||||
### chalk.level
|
||||
|
||||
Specifies the level of color support.
|
||||
|
||||
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
|
||||
|
||||
If you need to change this in a reusable module, create a new instance:
|
||||
|
||||
```js
|
||||
import {Chalk} from 'chalk';
|
||||
|
||||
const customChalk = new Chalk({level: 0});
|
||||
```
|
||||
|
||||
| Level | Description |
|
||||
| :---: | :--- |
|
||||
| `0` | All colors disabled |
|
||||
| `1` | Basic color support (16 colors) |
|
||||
| `2` | 256 color support |
|
||||
| `3` | Truecolor support (16 million colors) |
|
||||
|
||||
### supportsColor
|
||||
|
||||
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
||||
|
||||
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
### chalkStderr and supportsColorStderr
|
||||
|
||||
`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.
|
||||
|
||||
### modifierNames, foregroundColorNames, backgroundColorNames, and colorNames
|
||||
|
||||
All supported style strings are exposed as an array of strings for convenience. `colorNames` is the combination of `foregroundColorNames` and `backgroundColorNames`.
|
||||
|
||||
This can be useful if you wrap Chalk and need to validate input:
|
||||
|
||||
```js
|
||||
import {modifierNames, foregroundColorNames} from 'chalk';
|
||||
|
||||
console.log(modifierNames.includes('bold'));
|
||||
//=> true
|
||||
|
||||
console.log(foregroundColorNames.includes('pink'));
|
||||
//=> false
|
||||
```
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset` - Reset the current style.
|
||||
- `bold` - Make the text bold.
|
||||
- `dim` - Make the text have lower opacity.
|
||||
- `italic` - Make the text italic. *(Not widely supported)*
|
||||
- `underline` - Put a horizontal line below the text. *(Not widely supported)*
|
||||
- `overline` - Put a horizontal line above the text. *(Not widely supported)*
|
||||
- `inverse`- Invert background and foreground colors.
|
||||
- `hidden` - Print the text but make it invisible.
|
||||
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
||||
- `visible`- Print the text only when Chalk has a color level above zero. Can be useful for things that are purely cosmetic.
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `blackBright` (alias: `gray`, `grey`)
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
## 256 and Truecolor color support
|
||||
|
||||
Chalk supports 256 colors and [Truecolor](https://github.com/termstandard/colors) (16 million colors) on supported terminal apps.
|
||||
|
||||
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
||||
|
||||
Examples:
|
||||
|
||||
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `hex` for foreground colors and `bgHex` for background colors).
|
||||
|
||||
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
The following color models can be used:
|
||||
|
||||
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
||||
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
||||
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
||||
|
||||
## Browser support
|
||||
|
||||
Since Chrome 69, ANSI escape codes are natively supported in the developer console.
|
||||
|
||||
## Windows
|
||||
|
||||
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
||||
|
||||
## FAQ
|
||||
|
||||
### Why not switch to a smaller coloring package?
|
||||
|
||||
Chalk may be larger, but there is a reason for that. It offers a more user-friendly API, well-documented types, supports millions of colors, and covers edge cases that smaller alternatives miss. Chalk is mature, reliable, and built to last.
|
||||
|
||||
But beyond the technical aspects, there's something more critical: trust and long-term maintenance. I have been active in open source for over a decade, and I'm committed to keeping Chalk maintained. Smaller packages might seem appealing now, but there's no guarantee they will be around for the long term, or that they won't become malicious over time.
|
||||
|
||||
Chalk is also likely already in your dependency tree (since 100K+ packages depend on it), so switching won’t save space—in fact, it might increase it. npm deduplicates dependencies, so multiple Chalk instances turn into one, but adding another package alongside it will increase your overall size.
|
||||
|
||||
If the goal is to clean up the ecosystem, switching away from Chalk won’t even make a dent. The real problem lies with packages that have very deep dependency trees (for example, those including a lot of polyfills). Chalk has no dependencies. It's better to focus on impactful changes rather than minor optimizations.
|
||||
|
||||
If absolute package size is important to you, I also maintain [yoctocolors](https://github.com/sindresorhus/yoctocolors), one of the smallest color packages out there.
|
||||
|
||||
*\- [Sindre](https://github.com/sindresorhus)*
|
||||
|
||||
### But the smaller coloring package has benchmarks showing it is faster
|
||||
|
||||
[Micro-benchmarks are flawed](https://sindresorhus.com/blog/micro-benchmark-fallacy) because they measure performance in unrealistic, isolated scenarios, often giving a distorted view of real-world performance. Don't believe marketing fluff. All the coloring packages are more than fast enough.
|
||||
|
||||
## Related
|
||||
|
||||
- [chalk-template](https://github.com/chalk/chalk-template) - [Tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) support for this module
|
||||
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
||||
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
||||
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
||||
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
|
||||
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
|
||||
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
||||
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
||||
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
|
||||
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
||||
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
||||
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
||||
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
||||
|
||||
*(Not accepting additional entries)*
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
325
node_modules/ora/node_modules/chalk/source/index.d.ts
generated
vendored
Normal file
325
node_modules/ora/node_modules/chalk/source/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
// TODO: Make it this when TS suports that.
|
||||
// import {ModifierName, ForegroundColor, BackgroundColor, ColorName} from '#ansi-styles';
|
||||
// import {ColorInfo, ColorSupportLevel} from '#supports-color';
|
||||
import {
|
||||
ModifierName,
|
||||
ForegroundColorName,
|
||||
BackgroundColorName,
|
||||
ColorName,
|
||||
} from './vendor/ansi-styles/index.js';
|
||||
import {ColorInfo, ColorSupportLevel} from './vendor/supports-color/index.js';
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
Specify the color support for Chalk.
|
||||
|
||||
By default, color support is automatically detected based on the environment.
|
||||
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
readonly level?: ColorSupportLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
Return a new Chalk instance.
|
||||
*/
|
||||
export const Chalk: new (options?: Options) => ChalkInstance; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
|
||||
export interface ChalkInstance {
|
||||
(...text: unknown[]): string;
|
||||
|
||||
/**
|
||||
The color support for Chalk.
|
||||
|
||||
By default, color support is automatically detected based on the environment.
|
||||
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
level: ColorSupportLevel;
|
||||
|
||||
/**
|
||||
Use RGB values to set text color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.rgb(222, 173, 237);
|
||||
```
|
||||
*/
|
||||
rgb: (red: number, green: number, blue: number) => this;
|
||||
|
||||
/**
|
||||
Use HEX value to set text color.
|
||||
|
||||
@param color - Hexadecimal value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.hex('#DEADED');
|
||||
```
|
||||
*/
|
||||
hex: (color: string) => this;
|
||||
|
||||
/**
|
||||
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.ansi256(201);
|
||||
```
|
||||
*/
|
||||
ansi256: (index: number) => this;
|
||||
|
||||
/**
|
||||
Use RGB values to set background color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.bgRgb(222, 173, 237);
|
||||
```
|
||||
*/
|
||||
bgRgb: (red: number, green: number, blue: number) => this;
|
||||
|
||||
/**
|
||||
Use HEX value to set background color.
|
||||
|
||||
@param color - Hexadecimal value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.bgHex('#DEADED');
|
||||
```
|
||||
*/
|
||||
bgHex: (color: string) => this;
|
||||
|
||||
/**
|
||||
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk from 'chalk';
|
||||
|
||||
chalk.bgAnsi256(201);
|
||||
```
|
||||
*/
|
||||
bgAnsi256: (index: number) => this;
|
||||
|
||||
/**
|
||||
Modifier: Reset the current style.
|
||||
*/
|
||||
readonly reset: this;
|
||||
|
||||
/**
|
||||
Modifier: Make the text bold.
|
||||
*/
|
||||
readonly bold: this;
|
||||
|
||||
/**
|
||||
Modifier: Make the text have lower opacity.
|
||||
*/
|
||||
readonly dim: this;
|
||||
|
||||
/**
|
||||
Modifier: Make the text italic. *(Not widely supported)*
|
||||
*/
|
||||
readonly italic: this;
|
||||
|
||||
/**
|
||||
Modifier: Put a horizontal line below the text. *(Not widely supported)*
|
||||
*/
|
||||
readonly underline: this;
|
||||
|
||||
/**
|
||||
Modifier: Put a horizontal line above the text. *(Not widely supported)*
|
||||
*/
|
||||
readonly overline: this;
|
||||
|
||||
/**
|
||||
Modifier: Invert background and foreground colors.
|
||||
*/
|
||||
readonly inverse: this;
|
||||
|
||||
/**
|
||||
Modifier: Print the text but make it invisible.
|
||||
*/
|
||||
readonly hidden: this;
|
||||
|
||||
/**
|
||||
Modifier: Puts a horizontal line through the center of the text. *(Not widely supported)*
|
||||
*/
|
||||
readonly strikethrough: this;
|
||||
|
||||
/**
|
||||
Modifier: Print the text only when Chalk has a color level above zero.
|
||||
|
||||
Can be useful for things that are purely cosmetic.
|
||||
*/
|
||||
readonly visible: this;
|
||||
|
||||
readonly black: this;
|
||||
readonly red: this;
|
||||
readonly green: this;
|
||||
readonly yellow: this;
|
||||
readonly blue: this;
|
||||
readonly magenta: this;
|
||||
readonly cyan: this;
|
||||
readonly white: this;
|
||||
|
||||
/*
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: this;
|
||||
|
||||
/*
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: this;
|
||||
|
||||
readonly blackBright: this;
|
||||
readonly redBright: this;
|
||||
readonly greenBright: this;
|
||||
readonly yellowBright: this;
|
||||
readonly blueBright: this;
|
||||
readonly magentaBright: this;
|
||||
readonly cyanBright: this;
|
||||
readonly whiteBright: this;
|
||||
|
||||
readonly bgBlack: this;
|
||||
readonly bgRed: this;
|
||||
readonly bgGreen: this;
|
||||
readonly bgYellow: this;
|
||||
readonly bgBlue: this;
|
||||
readonly bgMagenta: this;
|
||||
readonly bgCyan: this;
|
||||
readonly bgWhite: this;
|
||||
|
||||
/*
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: this;
|
||||
|
||||
/*
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: this;
|
||||
|
||||
readonly bgBlackBright: this;
|
||||
readonly bgRedBright: this;
|
||||
readonly bgGreenBright: this;
|
||||
readonly bgYellowBright: this;
|
||||
readonly bgBlueBright: this;
|
||||
readonly bgMagentaBright: this;
|
||||
readonly bgCyanBright: this;
|
||||
readonly bgWhiteBright: this;
|
||||
}
|
||||
|
||||
/**
|
||||
Main Chalk object that allows to chain styles together.
|
||||
|
||||
Call the last one as a method with a string argument.
|
||||
|
||||
Order doesn't matter, and later styles take precedent in case of a conflict.
|
||||
|
||||
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
*/
|
||||
declare const chalk: ChalkInstance;
|
||||
|
||||
export const supportsColor: ColorInfo;
|
||||
|
||||
export const chalkStderr: typeof chalk;
|
||||
export const supportsColorStderr: typeof supportsColor;
|
||||
|
||||
export {
|
||||
ModifierName, ForegroundColorName, BackgroundColorName, ColorName,
|
||||
modifierNames, foregroundColorNames, backgroundColorNames, colorNames,
|
||||
// } from '#ansi-styles';
|
||||
} from './vendor/ansi-styles/index.js';
|
||||
|
||||
export {
|
||||
ColorInfo,
|
||||
ColorSupport,
|
||||
ColorSupportLevel,
|
||||
// } from '#supports-color';
|
||||
} from './vendor/supports-color/index.js';
|
||||
|
||||
// TODO: Remove these aliases in the next major version
|
||||
/**
|
||||
@deprecated Use `ModifierName` instead.
|
||||
|
||||
Basic modifier names.
|
||||
*/
|
||||
export type Modifiers = ModifierName;
|
||||
|
||||
/**
|
||||
@deprecated Use `ForegroundColorName` instead.
|
||||
|
||||
Basic foreground color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ForegroundColor = ForegroundColorName;
|
||||
|
||||
/**
|
||||
@deprecated Use `BackgroundColorName` instead.
|
||||
|
||||
Basic background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type BackgroundColor = BackgroundColorName;
|
||||
|
||||
/**
|
||||
@deprecated Use `ColorName` instead.
|
||||
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type Color = ColorName;
|
||||
|
||||
/**
|
||||
@deprecated Use `modifierNames` instead.
|
||||
|
||||
Basic modifier names.
|
||||
*/
|
||||
export const modifiers: readonly Modifiers[];
|
||||
|
||||
/**
|
||||
@deprecated Use `foregroundColorNames` instead.
|
||||
|
||||
Basic foreground color names.
|
||||
*/
|
||||
export const foregroundColors: readonly ForegroundColor[];
|
||||
|
||||
/**
|
||||
@deprecated Use `backgroundColorNames` instead.
|
||||
|
||||
Basic background color names.
|
||||
*/
|
||||
export const backgroundColors: readonly BackgroundColor[];
|
||||
|
||||
/**
|
||||
@deprecated Use `colorNames` instead.
|
||||
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
*/
|
||||
export const colors: readonly Color[];
|
||||
|
||||
export default chalk;
|
||||
225
node_modules/ora/node_modules/chalk/source/index.js
generated
vendored
Normal file
225
node_modules/ora/node_modules/chalk/source/index.js
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
import ansiStyles from '#ansi-styles';
|
||||
import supportsColor from '#supports-color';
|
||||
import { // eslint-disable-line import/order
|
||||
stringReplaceAll,
|
||||
stringEncaseCRLFWithFirstIndex,
|
||||
} from './utilities.js';
|
||||
|
||||
const {stdout: stdoutColor, stderr: stderrColor} = supportsColor;
|
||||
|
||||
const GENERATOR = Symbol('GENERATOR');
|
||||
const STYLER = Symbol('STYLER');
|
||||
const IS_EMPTY = Symbol('IS_EMPTY');
|
||||
|
||||
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
||||
const levelMapping = [
|
||||
'ansi',
|
||||
'ansi',
|
||||
'ansi256',
|
||||
'ansi16m',
|
||||
];
|
||||
|
||||
const styles = Object.create(null);
|
||||
|
||||
const applyOptions = (object, options = {}) => {
|
||||
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
||||
throw new Error('The `level` option should be an integer from 0 to 3');
|
||||
}
|
||||
|
||||
// Detect level if not set manually
|
||||
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
||||
object.level = options.level === undefined ? colorLevel : options.level;
|
||||
};
|
||||
|
||||
export class Chalk {
|
||||
constructor(options) {
|
||||
// eslint-disable-next-line no-constructor-return
|
||||
return chalkFactory(options);
|
||||
}
|
||||
}
|
||||
|
||||
const chalkFactory = options => {
|
||||
const chalk = (...strings) => strings.join(' ');
|
||||
applyOptions(chalk, options);
|
||||
|
||||
Object.setPrototypeOf(chalk, createChalk.prototype);
|
||||
|
||||
return chalk;
|
||||
};
|
||||
|
||||
function createChalk(options) {
|
||||
return chalkFactory(options);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
||||
|
||||
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
||||
styles[styleName] = {
|
||||
get() {
|
||||
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
||||
Object.defineProperty(this, styleName, {value: builder});
|
||||
return builder;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
styles.visible = {
|
||||
get() {
|
||||
const builder = createBuilder(this, this[STYLER], true);
|
||||
Object.defineProperty(this, 'visible', {value: builder});
|
||||
return builder;
|
||||
},
|
||||
};
|
||||
|
||||
const getModelAnsi = (model, level, type, ...arguments_) => {
|
||||
if (model === 'rgb') {
|
||||
if (level === 'ansi16m') {
|
||||
return ansiStyles[type].ansi16m(...arguments_);
|
||||
}
|
||||
|
||||
if (level === 'ansi256') {
|
||||
return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
|
||||
}
|
||||
|
||||
return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
|
||||
}
|
||||
|
||||
if (model === 'hex') {
|
||||
return getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));
|
||||
}
|
||||
|
||||
return ansiStyles[type][model](...arguments_);
|
||||
};
|
||||
|
||||
const usedModels = ['rgb', 'hex', 'ansi256'];
|
||||
|
||||
for (const model of usedModels) {
|
||||
styles[model] = {
|
||||
get() {
|
||||
const {level} = this;
|
||||
return function (...arguments_) {
|
||||
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);
|
||||
return createBuilder(this, styler, this[IS_EMPTY]);
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
||||
styles[bgModel] = {
|
||||
get() {
|
||||
const {level} = this;
|
||||
return function (...arguments_) {
|
||||
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
|
||||
return createBuilder(this, styler, this[IS_EMPTY]);
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const proto = Object.defineProperties(() => {}, {
|
||||
...styles,
|
||||
level: {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this[GENERATOR].level;
|
||||
},
|
||||
set(level) {
|
||||
this[GENERATOR].level = level;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const createStyler = (open, close, parent) => {
|
||||
let openAll;
|
||||
let closeAll;
|
||||
if (parent === undefined) {
|
||||
openAll = open;
|
||||
closeAll = close;
|
||||
} else {
|
||||
openAll = parent.openAll + open;
|
||||
closeAll = close + parent.closeAll;
|
||||
}
|
||||
|
||||
return {
|
||||
open,
|
||||
close,
|
||||
openAll,
|
||||
closeAll,
|
||||
parent,
|
||||
};
|
||||
};
|
||||
|
||||
const createBuilder = (self, _styler, _isEmpty) => {
|
||||
// Single argument is hot path, implicit coercion is faster than anything
|
||||
// eslint-disable-next-line no-implicit-coercion
|
||||
const builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
||||
|
||||
// We alter the prototype because we must return a function, but there is
|
||||
// no way to create a function with a different prototype
|
||||
Object.setPrototypeOf(builder, proto);
|
||||
|
||||
builder[GENERATOR] = self;
|
||||
builder[STYLER] = _styler;
|
||||
builder[IS_EMPTY] = _isEmpty;
|
||||
|
||||
return builder;
|
||||
};
|
||||
|
||||
const applyStyle = (self, string) => {
|
||||
if (self.level <= 0 || !string) {
|
||||
return self[IS_EMPTY] ? '' : string;
|
||||
}
|
||||
|
||||
let styler = self[STYLER];
|
||||
|
||||
if (styler === undefined) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const {openAll, closeAll} = styler;
|
||||
if (string.includes('\u001B')) {
|
||||
while (styler !== undefined) {
|
||||
// Replace any instances already present with a re-opening code
|
||||
// otherwise only the part of the string until said closing code
|
||||
// will be colored, and the rest will simply be 'plain'.
|
||||
string = stringReplaceAll(string, styler.close, styler.open);
|
||||
|
||||
styler = styler.parent;
|
||||
}
|
||||
}
|
||||
|
||||
// We can move both next actions out of loop, because remaining actions in loop won't have
|
||||
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
||||
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
||||
const lfIndex = string.indexOf('\n');
|
||||
if (lfIndex !== -1) {
|
||||
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
||||
}
|
||||
|
||||
return openAll + string + closeAll;
|
||||
};
|
||||
|
||||
Object.defineProperties(createChalk.prototype, styles);
|
||||
|
||||
const chalk = createChalk();
|
||||
export const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});
|
||||
|
||||
export {
|
||||
modifierNames,
|
||||
foregroundColorNames,
|
||||
backgroundColorNames,
|
||||
colorNames,
|
||||
|
||||
// TODO: Remove these aliases in the next major version
|
||||
modifierNames as modifiers,
|
||||
foregroundColorNames as foregroundColors,
|
||||
backgroundColorNames as backgroundColors,
|
||||
colorNames as colors,
|
||||
} from './vendor/ansi-styles/index.js';
|
||||
|
||||
export {
|
||||
stdoutColor as supportsColor,
|
||||
stderrColor as supportsColorStderr,
|
||||
};
|
||||
|
||||
export default chalk;
|
||||
33
node_modules/ora/node_modules/chalk/source/utilities.js
generated
vendored
Normal file
33
node_modules/ora/node_modules/chalk/source/utilities.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
|
||||
export function stringReplaceAll(string, substring, replacer) {
|
||||
let index = string.indexOf(substring);
|
||||
if (index === -1) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const substringLength = substring.length;
|
||||
let endIndex = 0;
|
||||
let returnValue = '';
|
||||
do {
|
||||
returnValue += string.slice(endIndex, index) + substring + replacer;
|
||||
endIndex = index + substringLength;
|
||||
index = string.indexOf(substring, endIndex);
|
||||
} while (index !== -1);
|
||||
|
||||
returnValue += string.slice(endIndex);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
export function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
||||
let endIndex = 0;
|
||||
let returnValue = '';
|
||||
do {
|
||||
const gotCR = string[index - 1] === '\r';
|
||||
returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
||||
endIndex = index + 1;
|
||||
index = string.indexOf('\n', endIndex);
|
||||
} while (index !== -1);
|
||||
|
||||
returnValue += string.slice(endIndex);
|
||||
return returnValue;
|
||||
}
|
||||
236
node_modules/ora/node_modules/chalk/source/vendor/ansi-styles/index.d.ts
generated
vendored
Normal file
236
node_modules/ora/node_modules/chalk/source/vendor/ansi-styles/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
export interface CSPair { // eslint-disable-line @typescript-eslint/naming-convention
|
||||
/**
|
||||
The ANSI terminal control sequence for starting this style.
|
||||
*/
|
||||
readonly open: string;
|
||||
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this style.
|
||||
*/
|
||||
readonly close: string;
|
||||
}
|
||||
|
||||
export interface ColorBase {
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this color.
|
||||
*/
|
||||
readonly close: string;
|
||||
|
||||
ansi(code: number): string;
|
||||
|
||||
ansi256(code: number): string;
|
||||
|
||||
ansi16m(red: number, green: number, blue: number): string;
|
||||
}
|
||||
|
||||
export interface Modifier {
|
||||
/**
|
||||
Resets the current color chain.
|
||||
*/
|
||||
readonly reset: CSPair;
|
||||
|
||||
/**
|
||||
Make text bold.
|
||||
*/
|
||||
readonly bold: CSPair;
|
||||
|
||||
/**
|
||||
Emitting only a small amount of light.
|
||||
*/
|
||||
readonly dim: CSPair;
|
||||
|
||||
/**
|
||||
Make text italic. (Not widely supported)
|
||||
*/
|
||||
readonly italic: CSPair;
|
||||
|
||||
/**
|
||||
Make text underline. (Not widely supported)
|
||||
*/
|
||||
readonly underline: CSPair;
|
||||
|
||||
/**
|
||||
Make text overline.
|
||||
|
||||
Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.
|
||||
*/
|
||||
readonly overline: CSPair;
|
||||
|
||||
/**
|
||||
Inverse background and foreground colors.
|
||||
*/
|
||||
readonly inverse: CSPair;
|
||||
|
||||
/**
|
||||
Prints the text, but makes it invisible.
|
||||
*/
|
||||
readonly hidden: CSPair;
|
||||
|
||||
/**
|
||||
Puts a horizontal line through the center of the text. (Not widely supported)
|
||||
*/
|
||||
readonly strikethrough: CSPair;
|
||||
}
|
||||
|
||||
export interface ForegroundColor {
|
||||
readonly black: CSPair;
|
||||
readonly red: CSPair;
|
||||
readonly green: CSPair;
|
||||
readonly yellow: CSPair;
|
||||
readonly blue: CSPair;
|
||||
readonly cyan: CSPair;
|
||||
readonly magenta: CSPair;
|
||||
readonly white: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: CSPair;
|
||||
|
||||
readonly blackBright: CSPair;
|
||||
readonly redBright: CSPair;
|
||||
readonly greenBright: CSPair;
|
||||
readonly yellowBright: CSPair;
|
||||
readonly blueBright: CSPair;
|
||||
readonly cyanBright: CSPair;
|
||||
readonly magentaBright: CSPair;
|
||||
readonly whiteBright: CSPair;
|
||||
}
|
||||
|
||||
export interface BackgroundColor {
|
||||
readonly bgBlack: CSPair;
|
||||
readonly bgRed: CSPair;
|
||||
readonly bgGreen: CSPair;
|
||||
readonly bgYellow: CSPair;
|
||||
readonly bgBlue: CSPair;
|
||||
readonly bgCyan: CSPair;
|
||||
readonly bgMagenta: CSPair;
|
||||
readonly bgWhite: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: CSPair;
|
||||
|
||||
readonly bgBlackBright: CSPair;
|
||||
readonly bgRedBright: CSPair;
|
||||
readonly bgGreenBright: CSPair;
|
||||
readonly bgYellowBright: CSPair;
|
||||
readonly bgBlueBright: CSPair;
|
||||
readonly bgCyanBright: CSPair;
|
||||
readonly bgMagentaBright: CSPair;
|
||||
readonly bgWhiteBright: CSPair;
|
||||
}
|
||||
|
||||
export interface ConvertColor {
|
||||
/**
|
||||
Convert from the RGB color space to the ANSI 256 color space.
|
||||
|
||||
@param red - (`0...255`)
|
||||
@param green - (`0...255`)
|
||||
@param blue - (`0...255`)
|
||||
*/
|
||||
rgbToAnsi256(red: number, green: number, blue: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the RGB color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToRgb(hex: string): [red: number, green: number, blue: number];
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the ANSI 256 color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToAnsi256(hex: string): number;
|
||||
|
||||
/**
|
||||
Convert from the ANSI 256 color space to the ANSI 16 color space.
|
||||
|
||||
@param code - A number representing the ANSI 256 color.
|
||||
*/
|
||||
ansi256ToAnsi(code: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB color space to the ANSI 16 color space.
|
||||
|
||||
@param red - (`0...255`)
|
||||
@param green - (`0...255`)
|
||||
@param blue - (`0...255`)
|
||||
*/
|
||||
rgbToAnsi(red: number, green: number, blue: number): number;
|
||||
|
||||
/**
|
||||
Convert from the RGB HEX color space to the ANSI 16 color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hexToAnsi(hex: string): number;
|
||||
}
|
||||
|
||||
/**
|
||||
Basic modifier names.
|
||||
*/
|
||||
export type ModifierName = keyof Modifier;
|
||||
|
||||
/**
|
||||
Basic foreground color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ForegroundColorName = keyof ForegroundColor;
|
||||
|
||||
/**
|
||||
Basic background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type BackgroundColorName = keyof BackgroundColor;
|
||||
|
||||
/**
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
export type ColorName = ForegroundColorName | BackgroundColorName;
|
||||
|
||||
/**
|
||||
Basic modifier names.
|
||||
*/
|
||||
export const modifierNames: readonly ModifierName[];
|
||||
|
||||
/**
|
||||
Basic foreground color names.
|
||||
*/
|
||||
export const foregroundColorNames: readonly ForegroundColorName[];
|
||||
|
||||
/**
|
||||
Basic background color names.
|
||||
*/
|
||||
export const backgroundColorNames: readonly BackgroundColorName[];
|
||||
|
||||
/*
|
||||
Basic color names. The combination of foreground and background color names.
|
||||
*/
|
||||
export const colorNames: readonly ColorName[];
|
||||
|
||||
declare const ansiStyles: {
|
||||
readonly modifier: Modifier;
|
||||
readonly color: ColorBase & ForegroundColor;
|
||||
readonly bgColor: ColorBase & BackgroundColor;
|
||||
readonly codes: ReadonlyMap<number, number>;
|
||||
} & ForegroundColor & BackgroundColor & Modifier & ConvertColor;
|
||||
|
||||
export default ansiStyles;
|
||||
223
node_modules/ora/node_modules/chalk/source/vendor/ansi-styles/index.js
generated
vendored
Normal file
223
node_modules/ora/node_modules/chalk/source/vendor/ansi-styles/index.js
generated
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
const ANSI_BACKGROUND_OFFSET = 10;
|
||||
|
||||
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
||||
|
||||
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
||||
|
||||
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
||||
|
||||
const styles = {
|
||||
modifier: {
|
||||
reset: [0, 0],
|
||||
// 21 isn't widely supported and 22 does the same thing
|
||||
bold: [1, 22],
|
||||
dim: [2, 22],
|
||||
italic: [3, 23],
|
||||
underline: [4, 24],
|
||||
overline: [53, 55],
|
||||
inverse: [7, 27],
|
||||
hidden: [8, 28],
|
||||
strikethrough: [9, 29],
|
||||
},
|
||||
color: {
|
||||
black: [30, 39],
|
||||
red: [31, 39],
|
||||
green: [32, 39],
|
||||
yellow: [33, 39],
|
||||
blue: [34, 39],
|
||||
magenta: [35, 39],
|
||||
cyan: [36, 39],
|
||||
white: [37, 39],
|
||||
|
||||
// Bright color
|
||||
blackBright: [90, 39],
|
||||
gray: [90, 39], // Alias of `blackBright`
|
||||
grey: [90, 39], // Alias of `blackBright`
|
||||
redBright: [91, 39],
|
||||
greenBright: [92, 39],
|
||||
yellowBright: [93, 39],
|
||||
blueBright: [94, 39],
|
||||
magentaBright: [95, 39],
|
||||
cyanBright: [96, 39],
|
||||
whiteBright: [97, 39],
|
||||
},
|
||||
bgColor: {
|
||||
bgBlack: [40, 49],
|
||||
bgRed: [41, 49],
|
||||
bgGreen: [42, 49],
|
||||
bgYellow: [43, 49],
|
||||
bgBlue: [44, 49],
|
||||
bgMagenta: [45, 49],
|
||||
bgCyan: [46, 49],
|
||||
bgWhite: [47, 49],
|
||||
|
||||
// Bright color
|
||||
bgBlackBright: [100, 49],
|
||||
bgGray: [100, 49], // Alias of `bgBlackBright`
|
||||
bgGrey: [100, 49], // Alias of `bgBlackBright`
|
||||
bgRedBright: [101, 49],
|
||||
bgGreenBright: [102, 49],
|
||||
bgYellowBright: [103, 49],
|
||||
bgBlueBright: [104, 49],
|
||||
bgMagentaBright: [105, 49],
|
||||
bgCyanBright: [106, 49],
|
||||
bgWhiteBright: [107, 49],
|
||||
},
|
||||
};
|
||||
|
||||
export const modifierNames = Object.keys(styles.modifier);
|
||||
export const foregroundColorNames = Object.keys(styles.color);
|
||||
export const backgroundColorNames = Object.keys(styles.bgColor);
|
||||
export const colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
||||
|
||||
function assembleStyles() {
|
||||
const codes = new Map();
|
||||
|
||||
for (const [groupName, group] of Object.entries(styles)) {
|
||||
for (const [styleName, style] of Object.entries(group)) {
|
||||
styles[styleName] = {
|
||||
open: `\u001B[${style[0]}m`,
|
||||
close: `\u001B[${style[1]}m`,
|
||||
};
|
||||
|
||||
group[styleName] = styles[styleName];
|
||||
|
||||
codes.set(style[0], style[1]);
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, groupName, {
|
||||
value: group,
|
||||
enumerable: false,
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, 'codes', {
|
||||
value: codes,
|
||||
enumerable: false,
|
||||
});
|
||||
|
||||
styles.color.close = '\u001B[39m';
|
||||
styles.bgColor.close = '\u001B[49m';
|
||||
|
||||
styles.color.ansi = wrapAnsi16();
|
||||
styles.color.ansi256 = wrapAnsi256();
|
||||
styles.color.ansi16m = wrapAnsi16m();
|
||||
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
||||
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
||||
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
||||
|
||||
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
||||
Object.defineProperties(styles, {
|
||||
rgbToAnsi256: {
|
||||
value(red, green, blue) {
|
||||
// We use the extended greyscale palette here, with the exception of
|
||||
// black and white. normal palette only has 4 greyscale shades.
|
||||
if (red === green && green === blue) {
|
||||
if (red < 8) {
|
||||
return 16;
|
||||
}
|
||||
|
||||
if (red > 248) {
|
||||
return 231;
|
||||
}
|
||||
|
||||
return Math.round(((red - 8) / 247) * 24) + 232;
|
||||
}
|
||||
|
||||
return 16
|
||||
+ (36 * Math.round(red / 255 * 5))
|
||||
+ (6 * Math.round(green / 255 * 5))
|
||||
+ Math.round(blue / 255 * 5);
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
hexToRgb: {
|
||||
value(hex) {
|
||||
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
||||
if (!matches) {
|
||||
return [0, 0, 0];
|
||||
}
|
||||
|
||||
let [colorString] = matches;
|
||||
|
||||
if (colorString.length === 3) {
|
||||
colorString = [...colorString].map(character => character + character).join('');
|
||||
}
|
||||
|
||||
const integer = Number.parseInt(colorString, 16);
|
||||
|
||||
return [
|
||||
/* eslint-disable no-bitwise */
|
||||
(integer >> 16) & 0xFF,
|
||||
(integer >> 8) & 0xFF,
|
||||
integer & 0xFF,
|
||||
/* eslint-enable no-bitwise */
|
||||
];
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
hexToAnsi256: {
|
||||
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
||||
enumerable: false,
|
||||
},
|
||||
ansi256ToAnsi: {
|
||||
value(code) {
|
||||
if (code < 8) {
|
||||
return 30 + code;
|
||||
}
|
||||
|
||||
if (code < 16) {
|
||||
return 90 + (code - 8);
|
||||
}
|
||||
|
||||
let red;
|
||||
let green;
|
||||
let blue;
|
||||
|
||||
if (code >= 232) {
|
||||
red = (((code - 232) * 10) + 8) / 255;
|
||||
green = red;
|
||||
blue = red;
|
||||
} else {
|
||||
code -= 16;
|
||||
|
||||
const remainder = code % 36;
|
||||
|
||||
red = Math.floor(code / 36) / 5;
|
||||
green = Math.floor(remainder / 6) / 5;
|
||||
blue = (remainder % 6) / 5;
|
||||
}
|
||||
|
||||
const value = Math.max(red, green, blue) * 2;
|
||||
|
||||
if (value === 0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-bitwise
|
||||
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
||||
|
||||
if (value === 2) {
|
||||
result += 60;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
enumerable: false,
|
||||
},
|
||||
rgbToAnsi: {
|
||||
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
||||
enumerable: false,
|
||||
},
|
||||
hexToAnsi: {
|
||||
value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
||||
enumerable: false,
|
||||
},
|
||||
});
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
const ansiStyles = assembleStyles();
|
||||
|
||||
export default ansiStyles;
|
||||
1
node_modules/ora/node_modules/chalk/source/vendor/supports-color/browser.d.ts
generated
vendored
Normal file
1
node_modules/ora/node_modules/chalk/source/vendor/supports-color/browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {default} from './index.js';
|
||||
34
node_modules/ora/node_modules/chalk/source/vendor/supports-color/browser.js
generated
vendored
Normal file
34
node_modules/ora/node_modules/chalk/source/vendor/supports-color/browser.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
const level = (() => {
|
||||
if (!('navigator' in globalThis)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (globalThis.navigator.userAgentData) {
|
||||
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
||||
if (brand && brand.version > 93) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
})();
|
||||
|
||||
const colorSupport = level !== 0 && {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3,
|
||||
};
|
||||
|
||||
const supportsColor = {
|
||||
stdout: colorSupport,
|
||||
stderr: colorSupport,
|
||||
};
|
||||
|
||||
export default supportsColor;
|
||||
55
node_modules/ora/node_modules/chalk/source/vendor/supports-color/index.d.ts
generated
vendored
Normal file
55
node_modules/ora/node_modules/chalk/source/vendor/supports-color/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import type {WriteStream} from 'node:tty';
|
||||
|
||||
export type Options = {
|
||||
/**
|
||||
Whether `process.argv` should be sniffed for `--color` and `--no-color` flags.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly sniffFlags?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
Levels:
|
||||
- `0` - All colors disabled.
|
||||
- `1` - Basic 16 colors support.
|
||||
- `2` - ANSI 256 colors support.
|
||||
- `3` - Truecolor 16 million colors support.
|
||||
*/
|
||||
export type ColorSupportLevel = 0 | 1 | 2 | 3;
|
||||
|
||||
/**
|
||||
Detect whether the terminal supports color.
|
||||
*/
|
||||
export type ColorSupport = {
|
||||
/**
|
||||
The color level.
|
||||
*/
|
||||
level: ColorSupportLevel;
|
||||
|
||||
/**
|
||||
Whether basic 16 colors are supported.
|
||||
*/
|
||||
hasBasic: boolean;
|
||||
|
||||
/**
|
||||
Whether ANSI 256 colors are supported.
|
||||
*/
|
||||
has256: boolean;
|
||||
|
||||
/**
|
||||
Whether Truecolor 16 million colors are supported.
|
||||
*/
|
||||
has16m: boolean;
|
||||
};
|
||||
|
||||
export type ColorInfo = ColorSupport | false;
|
||||
|
||||
export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo;
|
||||
|
||||
declare const supportsColor: {
|
||||
stdout: ColorInfo;
|
||||
stderr: ColorInfo;
|
||||
};
|
||||
|
||||
export default supportsColor;
|
||||
190
node_modules/ora/node_modules/chalk/source/vendor/supports-color/index.js
generated
vendored
Normal file
190
node_modules/ora/node_modules/chalk/source/vendor/supports-color/index.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
import process from 'node:process';
|
||||
import os from 'node:os';
|
||||
import tty from 'node:tty';
|
||||
|
||||
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
||||
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
||||
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
||||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
||||
const position = argv.indexOf(prefix + flag);
|
||||
const terminatorPosition = argv.indexOf('--');
|
||||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
||||
}
|
||||
|
||||
const {env} = process;
|
||||
|
||||
let flagForceColor;
|
||||
if (
|
||||
hasFlag('no-color')
|
||||
|| hasFlag('no-colors')
|
||||
|| hasFlag('color=false')
|
||||
|| hasFlag('color=never')
|
||||
) {
|
||||
flagForceColor = 0;
|
||||
} else if (
|
||||
hasFlag('color')
|
||||
|| hasFlag('colors')
|
||||
|| hasFlag('color=true')
|
||||
|| hasFlag('color=always')
|
||||
) {
|
||||
flagForceColor = 1;
|
||||
}
|
||||
|
||||
function envForceColor() {
|
||||
if ('FORCE_COLOR' in env) {
|
||||
if (env.FORCE_COLOR === 'true') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (env.FORCE_COLOR === 'false') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
||||
}
|
||||
}
|
||||
|
||||
function translateLevel(level) {
|
||||
if (level === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3,
|
||||
};
|
||||
}
|
||||
|
||||
function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
||||
const noFlagForceColor = envForceColor();
|
||||
if (noFlagForceColor !== undefined) {
|
||||
flagForceColor = noFlagForceColor;
|
||||
}
|
||||
|
||||
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
||||
|
||||
if (forceColor === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sniffFlags) {
|
||||
if (hasFlag('color=16m')
|
||||
|| hasFlag('color=full')
|
||||
|| hasFlag('color=truecolor')) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (hasFlag('color=256')) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Azure DevOps pipelines.
|
||||
// Has to be above the `!streamIsTTY` check.
|
||||
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const min = forceColor || 0;
|
||||
|
||||
if (env.TERM === 'dumb') {
|
||||
return min;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
||||
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
||||
const osRelease = os.release().split('.');
|
||||
if (
|
||||
Number(osRelease[0]) >= 10
|
||||
&& Number(osRelease[2]) >= 10_586
|
||||
) {
|
||||
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
if (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (env.COLORTERM === 'truecolor') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (env.TERM === 'xterm-kitty') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (env.TERM === 'xterm-ghostty') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (env.TERM === 'wezterm') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app': {
|
||||
return version >= 3 ? 3 : 2;
|
||||
}
|
||||
|
||||
case 'Apple_Terminal': {
|
||||
return 2;
|
||||
}
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if (/-256(color)?$/i.test(env.TERM)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
export function createSupportsColor(stream, options = {}) {
|
||||
const level = _supportsColor(stream, {
|
||||
streamIsTTY: stream && stream.isTTY,
|
||||
...options,
|
||||
});
|
||||
|
||||
return translateLevel(level);
|
||||
}
|
||||
|
||||
const supportsColor = {
|
||||
stdout: createSupportsColor({isTTY: tty.isatty(1)}),
|
||||
stderr: createSupportsColor({isTTY: tty.isatty(2)}),
|
||||
};
|
||||
|
||||
export default supportsColor;
|
||||
139
node_modules/ora/node_modules/cli-spinners/index.d.ts
generated
vendored
Normal file
139
node_modules/ora/node_modules/cli-spinners/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
// TODO: Load the spinner names from the JSON file.
|
||||
export type SpinnerName =
|
||||
| 'dots'
|
||||
| 'dots2'
|
||||
| 'dots3'
|
||||
| 'dots4'
|
||||
| 'dots5'
|
||||
| 'dots6'
|
||||
| 'dots7'
|
||||
| 'dots8'
|
||||
| 'dots9'
|
||||
| 'dots10'
|
||||
| 'dots11'
|
||||
| 'dots12'
|
||||
| 'dots13'
|
||||
| 'dots14'
|
||||
| 'dots8Bit'
|
||||
| 'dotsCircle'
|
||||
| 'sand'
|
||||
| 'line'
|
||||
| 'line2'
|
||||
| 'rollingLine'
|
||||
| 'pipe'
|
||||
| 'simpleDots'
|
||||
| 'simpleDotsScrolling'
|
||||
| 'star'
|
||||
| 'star2'
|
||||
| 'flip'
|
||||
| 'hamburger'
|
||||
| 'growVertical'
|
||||
| 'growHorizontal'
|
||||
| 'balloon'
|
||||
| 'balloon2'
|
||||
| 'noise'
|
||||
| 'bounce'
|
||||
| 'boxBounce'
|
||||
| 'boxBounce2'
|
||||
| 'binary'
|
||||
| 'triangle'
|
||||
| 'arc'
|
||||
| 'circle'
|
||||
| 'squareCorners'
|
||||
| 'circleQuarters'
|
||||
| 'circleHalves'
|
||||
| 'squish'
|
||||
| 'toggle'
|
||||
| 'toggle2'
|
||||
| 'toggle3'
|
||||
| 'toggle4'
|
||||
| 'toggle5'
|
||||
| 'toggle6'
|
||||
| 'toggle7'
|
||||
| 'toggle8'
|
||||
| 'toggle9'
|
||||
| 'toggle10'
|
||||
| 'toggle11'
|
||||
| 'toggle12'
|
||||
| 'toggle13'
|
||||
| 'arrow'
|
||||
| 'arrow2'
|
||||
| 'arrow3'
|
||||
| 'bouncingBar'
|
||||
| 'bouncingBall'
|
||||
| 'smiley'
|
||||
| 'monkey'
|
||||
| 'hearts'
|
||||
| 'clock'
|
||||
| 'earth'
|
||||
| 'material'
|
||||
| 'moon'
|
||||
| 'runner'
|
||||
| 'pong'
|
||||
| 'shark'
|
||||
| 'dqpb'
|
||||
| 'weather'
|
||||
| 'christmas'
|
||||
| 'grenade'
|
||||
| 'point'
|
||||
| 'layer'
|
||||
| 'betaWave'
|
||||
| 'fingerDance'
|
||||
| 'fistBump'
|
||||
| 'soccerHeader'
|
||||
| 'mindblown'
|
||||
| 'speaker'
|
||||
| 'orangePulse'
|
||||
| 'bluePulse'
|
||||
| 'orangeBluePulse'
|
||||
| 'timeTravel'
|
||||
| 'aesthetic'
|
||||
| 'dwarfFortress';
|
||||
|
||||
export type Spinner = {
|
||||
/**
|
||||
The intended time per frame, in milliseconds.
|
||||
*/
|
||||
readonly interval: number;
|
||||
|
||||
/**
|
||||
An array of frames to show for the spinner.
|
||||
*/
|
||||
readonly frames: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
70+ spinners for use in the terminal.
|
||||
|
||||
@example
|
||||
```
|
||||
import cliSpinners from 'cli-spinners';
|
||||
|
||||
console.log(cliSpinners.dots);
|
||||
// {
|
||||
// interval: 80,
|
||||
// frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
||||
// }
|
||||
```
|
||||
*/
|
||||
declare const cliSpinners: {
|
||||
readonly [spinnerName in SpinnerName]: Spinner;
|
||||
};
|
||||
|
||||
export default cliSpinners;
|
||||
|
||||
/**
|
||||
Get a random spinner.
|
||||
|
||||
@example
|
||||
```
|
||||
import {randomSpinner} from 'cli-spinners';
|
||||
|
||||
console.log(randomSpinner());
|
||||
// {
|
||||
// interval: 80,
|
||||
// frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
||||
// }
|
||||
```
|
||||
*/
|
||||
export function randomSpinner(): Spinner;
|
||||
11
node_modules/ora/node_modules/cli-spinners/index.js
generated
vendored
Normal file
11
node_modules/ora/node_modules/cli-spinners/index.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import spinners from './spinners.json' with {type: 'json'};
|
||||
|
||||
export default spinners;
|
||||
|
||||
const spinnersList = Object.keys(spinners);
|
||||
|
||||
export function randomSpinner() {
|
||||
const randomIndex = Math.floor(Math.random() * spinnersList.length);
|
||||
const spinnerName = spinnersList[randomIndex];
|
||||
return spinners[spinnerName];
|
||||
}
|
||||
9
node_modules/ora/node_modules/cli-spinners/license
generated
vendored
Normal file
9
node_modules/ora/node_modules/cli-spinners/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
56
node_modules/ora/node_modules/cli-spinners/package.json
generated
vendored
Normal file
56
node_modules/ora/node_modules/cli-spinners/package.json
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "cli-spinners",
|
||||
"version": "3.3.0",
|
||||
"description": "Spinners for use in the terminal",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/cli-spinners",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=18.20"
|
||||
},
|
||||
"scripts": {
|
||||
"//test": "xo && ava && tsc --noEmit index.d.ts",
|
||||
"test": "ava && tsc --noEmit index.d.ts",
|
||||
"asciicast": "asciinema rec --command='node example-all.js' --title='cli-spinner' --quiet"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"spinners.json"
|
||||
],
|
||||
"keywords": [
|
||||
"cli",
|
||||
"spinner",
|
||||
"spinners",
|
||||
"terminal",
|
||||
"term",
|
||||
"console",
|
||||
"ascii",
|
||||
"unicode",
|
||||
"loading",
|
||||
"indicator",
|
||||
"progress",
|
||||
"busy",
|
||||
"wait",
|
||||
"idle",
|
||||
"json"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^6.1.2",
|
||||
"log-update": "^6.0.0",
|
||||
"string-length": "^6.0.0",
|
||||
"typescript": "^5.4.5",
|
||||
"xo": "^0.58.0"
|
||||
}
|
||||
}
|
||||
74
node_modules/ora/node_modules/cli-spinners/readme.md
generated
vendored
Normal file
74
node_modules/ora/node_modules/cli-spinners/readme.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
# cli-spinners
|
||||
|
||||
> 70+ spinners for use in the terminal
|
||||
|
||||
<p align="center">
|
||||
<br>
|
||||
<img width="700" src="screenshot.svg">
|
||||
<br>
|
||||
<br>
|
||||
</p>
|
||||
|
||||
The list of spinners is just a [JSON file](spinners.json) and can be used wherever.
|
||||
|
||||
You probably want to use one of these spinners through the [`ora`](https://github.com/sindresorhus/ora) package.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install cli-spinners
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import cliSpinners from 'cli-spinners';
|
||||
|
||||
console.log(cliSpinners.dots);
|
||||
/*
|
||||
{
|
||||
interval: 80,
|
||||
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
- `interval` is the intended time per frame, in milliseconds.
|
||||
- `frames` is an array of frames to show for the spinner.
|
||||
|
||||
## Preview
|
||||
|
||||
The header GIF is outdated. See all the [spinner at once](https://jsfiddle.net/sindresorhus/2eLtsbey/embedded/result/) or [one at the time](https://asciinema.org/a/95348?size=big).
|
||||
|
||||
## API
|
||||
|
||||
### cliSpinners
|
||||
|
||||
Each spinner comes with a recommended `interval` and an array of `frames`.
|
||||
|
||||
[See the spinners.](spinners.json)
|
||||
|
||||
### randomSpinner()
|
||||
|
||||
Get a random spinner.
|
||||
|
||||
```js
|
||||
import {randomSpinner} from 'cli-spinners';
|
||||
|
||||
console.log(randomSpinner());
|
||||
/*
|
||||
{
|
||||
interval: 80,
|
||||
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [ora](https://github.com/sindresorhus/ora) - Elegant terminal spinner
|
||||
- [CLISpinner](https://github.com/kiliankoe/CLISpinner) - Terminal spinners for Swift
|
||||
- [py-spinners](https://github.com/ManrajGrover/py-spinners) - Python port
|
||||
- [spinners](https://github.com/FGRibreau/spinners) - Terminal spinners for Rust
|
||||
- [go-spinners](https://github.com/gabe565/go-spinners) - Go port
|
||||
- [bash-cli-spinners](https://github.com/simeg/bash-cli-spinners) - Terminal spinners in Bash
|
||||
1665
node_modules/ora/node_modules/cli-spinners/spinners.json
generated
vendored
Normal file
1665
node_modules/ora/node_modules/cli-spinners/spinners.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
39
node_modules/ora/node_modules/string-width/index.d.ts
generated
vendored
Normal file
39
node_modules/ora/node_modules/string-width/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
export type Options = {
|
||||
/**
|
||||
Count [ambiguous width characters](https://www.unicode.org/reports/tr11/#Ambiguous) as having narrow width (count of 1) instead of wide width (count of 2).
|
||||
|
||||
@default true
|
||||
|
||||
> Ambiguous characters behave like wide or narrow characters depending on the context (language tag, script identification, associated font, source of data, or explicit markup; all can provide the context). __If the context cannot be established reliably, they should be treated as narrow characters by default.__
|
||||
> - http://www.unicode.org/reports/tr11/
|
||||
*/
|
||||
readonly ambiguousIsNarrow?: boolean;
|
||||
|
||||
/**
|
||||
Whether [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) should be counted.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly countAnsiEscapeCodes?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
Get the visual width of a string - the number of columns required to display it.
|
||||
|
||||
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
||||
|
||||
@example
|
||||
```
|
||||
import stringWidth from 'string-width';
|
||||
|
||||
stringWidth('a');
|
||||
//=> 1
|
||||
|
||||
stringWidth('古');
|
||||
//=> 2
|
||||
|
||||
stringWidth('\u001B[1m古\u001B[22m');
|
||||
//=> 2
|
||||
```
|
||||
*/
|
||||
export default function stringWidth(string: string, options?: Options): number;
|
||||
89
node_modules/ora/node_modules/string-width/index.js
generated
vendored
Normal file
89
node_modules/ora/node_modules/string-width/index.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import {eastAsianWidth} from 'get-east-asian-width';
|
||||
|
||||
/**
|
||||
Logic:
|
||||
- Segment graphemes to match how terminals render clusters.
|
||||
- Width rules:
|
||||
1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates). Tabs are ignored by design.
|
||||
2. RGI emoji clusters (\p{RGI_Emoji}) are double-width.
|
||||
3. Otherwise use East Asian Width of the cluster’s first visible code point, and add widths for trailing Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark).
|
||||
*/
|
||||
|
||||
const segmenter = new Intl.Segmenter();
|
||||
|
||||
// Whole-cluster zero-width
|
||||
const zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Mark}|\p{Surrogate})+$/v;
|
||||
|
||||
// Pick the base scalar if the cluster starts with Prepend/Format/Marks
|
||||
const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
|
||||
|
||||
// RGI emoji sequences
|
||||
const rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
|
||||
|
||||
function baseVisible(segment) {
|
||||
return segment.replace(leadingNonPrintingRegex, '');
|
||||
}
|
||||
|
||||
function isZeroWidthCluster(segment) {
|
||||
return zeroWidthClusterRegex.test(segment);
|
||||
}
|
||||
|
||||
function trailingHalfwidthWidth(segment, eastAsianWidthOptions) {
|
||||
let extra = 0;
|
||||
if (segment.length > 1) {
|
||||
for (const char of segment.slice(1)) {
|
||||
if (char >= '\uFF00' && char <= '\uFFEF') {
|
||||
extra += eastAsianWidth(char.codePointAt(0), eastAsianWidthOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return extra;
|
||||
}
|
||||
|
||||
export default function stringWidth(input, options = {}) {
|
||||
if (typeof input !== 'string' || input.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const {
|
||||
ambiguousIsNarrow = true,
|
||||
countAnsiEscapeCodes = false,
|
||||
} = options;
|
||||
|
||||
let string = input;
|
||||
|
||||
if (!countAnsiEscapeCodes) {
|
||||
string = stripAnsi(string);
|
||||
}
|
||||
|
||||
if (string.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let width = 0;
|
||||
const eastAsianWidthOptions = {ambiguousAsWide: !ambiguousIsNarrow};
|
||||
|
||||
for (const {segment} of segmenter.segment(string)) {
|
||||
// Zero-width / non-printing clusters
|
||||
if (isZeroWidthCluster(segment)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Emoji width logic
|
||||
if (rgiEmojiRegex.test(segment)) {
|
||||
width += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Everything else: EAW of the cluster’s first visible scalar
|
||||
const codePoint = baseVisible(segment).codePointAt(0);
|
||||
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
||||
|
||||
// Add width for trailing Halfwidth and Fullwidth Forms (e.g., ゙, ゚, ー)
|
||||
width += trailingHalfwidthWidth(segment, eastAsianWidthOptions);
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
9
node_modules/ora/node_modules/string-width/license
generated
vendored
Normal file
9
node_modules/ora/node_modules/string-width/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
65
node_modules/ora/node_modules/string-width/package.json
generated
vendored
Normal file
65
node_modules/ora/node_modules/string-width/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "string-width",
|
||||
"version": "8.1.0",
|
||||
"description": "Get the visual width of a string - the number of columns required to display it",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/string-width",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"string",
|
||||
"character",
|
||||
"unicode",
|
||||
"width",
|
||||
"visual",
|
||||
"column",
|
||||
"columns",
|
||||
"fullwidth",
|
||||
"full-width",
|
||||
"wcwidth",
|
||||
"wcswidth",
|
||||
"full",
|
||||
"ansi",
|
||||
"escape",
|
||||
"codes",
|
||||
"cli",
|
||||
"command-line",
|
||||
"terminal",
|
||||
"console",
|
||||
"cjk",
|
||||
"chinese",
|
||||
"japanese",
|
||||
"korean",
|
||||
"fixed-width",
|
||||
"east-asian-width"
|
||||
],
|
||||
"dependencies": {
|
||||
"get-east-asian-width": "^1.3.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^6.4.1",
|
||||
"tsd": "^0.33.0",
|
||||
"xo": "^1.2.2"
|
||||
}
|
||||
}
|
||||
66
node_modules/ora/node_modules/string-width/readme.md
generated
vendored
Normal file
66
node_modules/ora/node_modules/string-width/readme.md
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
# string-width
|
||||
|
||||
> Get the visual width of a string - the number of columns required to display it
|
||||
|
||||
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
||||
|
||||
Useful to be able to measure the actual width of command-line output.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install string-width
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import stringWidth from 'string-width';
|
||||
|
||||
stringWidth('a');
|
||||
//=> 1
|
||||
|
||||
stringWidth('古');
|
||||
//=> 2
|
||||
|
||||
stringWidth('\u001B[1m古\u001B[22m');
|
||||
//=> 2
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### stringWidth(string, options?)
|
||||
|
||||
#### string
|
||||
|
||||
Type: `string`
|
||||
|
||||
The string to be counted.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### ambiguousIsNarrow
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Count [ambiguous width characters](https://www.unicode.org/reports/tr11/#Ambiguous) as having narrow width (count of 1) instead of wide width (count of 2).
|
||||
|
||||
> Ambiguous characters behave like wide or narrow characters depending on the context (language tag, script identification, associated font, source of data, or explicit markup; all can provide the context). **If the context cannot be established reliably, they should be treated as narrow characters by default.**
|
||||
> - http://www.unicode.org/reports/tr11/
|
||||
|
||||
##### countAnsiEscapeCodes
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Whether [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) should be counted.
|
||||
|
||||
## Related
|
||||
|
||||
- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
|
||||
- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
|
||||
- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
|
||||
- [get-east-asian-width](https://github.com/sindresorhus/get-east-asian-width) - Determine the East Asian Width of a Unicode character
|
||||
64
node_modules/ora/package.json
generated
vendored
Normal file
64
node_modules/ora/package.json
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "ora",
|
||||
"version": "9.0.0",
|
||||
"description": "Elegant terminal spinner",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/ora",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && NODE_ENV=test node --test test.js && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"cli",
|
||||
"spinner",
|
||||
"spinners",
|
||||
"terminal",
|
||||
"term",
|
||||
"console",
|
||||
"ascii",
|
||||
"unicode",
|
||||
"loading",
|
||||
"indicator",
|
||||
"progress",
|
||||
"busy",
|
||||
"wait",
|
||||
"idle"
|
||||
],
|
||||
"dependencies": {
|
||||
"chalk": "^5.6.2",
|
||||
"cli-cursor": "^5.0.0",
|
||||
"cli-spinners": "^3.2.0",
|
||||
"is-interactive": "^2.0.0",
|
||||
"is-unicode-supported": "^2.1.0",
|
||||
"log-symbols": "^7.0.1",
|
||||
"stdin-discarder": "^0.2.2",
|
||||
"string-width": "^8.1.0",
|
||||
"strip-ansi": "^7.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.5.0",
|
||||
"ava": "^6.4.1",
|
||||
"get-stream": "^9.0.1",
|
||||
"transform-tty": "^1.0.11",
|
||||
"tsd": "^0.33.0",
|
||||
"xo": "^1.2.2"
|
||||
}
|
||||
}
|
||||
375
node_modules/ora/readme.md
generated
vendored
Normal file
375
node_modules/ora/readme.md
generated
vendored
Normal file
@@ -0,0 +1,375 @@
|
||||
# ora
|
||||
|
||||
> Elegant terminal spinner
|
||||
|
||||
<p align="center">
|
||||
<br>
|
||||
<img src="screenshot.svg" width="500">
|
||||
<br>
|
||||
</p>
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install ora
|
||||
```
|
||||
|
||||
*Check out [`yocto-spinner`](https://github.com/sindresorhus/yocto-spinner) for a smaller alternative.*
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import ora from 'ora';
|
||||
|
||||
const spinner = ora('Loading unicorns').start();
|
||||
|
||||
setTimeout(() => {
|
||||
spinner.color = 'yellow';
|
||||
spinner.text = 'Loading rainbows';
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### ora(text)
|
||||
### ora(options)
|
||||
|
||||
If a string is provided, it is treated as a shortcut for [`options.text`](#text).
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### text
|
||||
|
||||
Type: `string`
|
||||
|
||||
The text to display next to the spinner.
|
||||
|
||||
##### prefixText
|
||||
|
||||
Type: `string | () => string`
|
||||
|
||||
Text or a function that returns text to display before the spinner. No prefix text will be displayed if set to an empty string.
|
||||
|
||||
##### suffixText
|
||||
|
||||
Type: `string | () => string`
|
||||
|
||||
Text or a function that returns text to display after the spinner text. No suffix text will be displayed if set to an empty string.
|
||||
|
||||
##### spinner
|
||||
|
||||
Type: `string | object`\
|
||||
Default: `'dots'` <img src="screenshot-spinner.gif" width="14">
|
||||
|
||||
The name of one of the [provided spinners](#spinners). See `example.js` in this repo if you want to test out different spinners. On Windows (except for Windows Terminal), it will always use the `line` spinner as the Windows command-line doesn't have proper Unicode support.
|
||||
|
||||
Or an object like:
|
||||
|
||||
```js
|
||||
{
|
||||
frames: ['-', '+', '-'],
|
||||
interval: 80 // Optional
|
||||
}
|
||||
```
|
||||
|
||||
##### color
|
||||
|
||||
Type: `string | boolean`\
|
||||
Default: `'cyan'`\
|
||||
Values: `'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray' | boolean`
|
||||
|
||||
The color of the spinner. Set to `false` to disable coloring.
|
||||
|
||||
##### hideCursor
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Set to `false` to stop Ora from hiding the cursor.
|
||||
|
||||
##### indent
|
||||
|
||||
Type: `number`\
|
||||
Default: `0`
|
||||
|
||||
Indent the spinner with the given number of spaces.
|
||||
|
||||
##### interval
|
||||
|
||||
Type: `number`\
|
||||
Default: Provided by the spinner or `100`
|
||||
|
||||
Interval between each frame.
|
||||
|
||||
Spinners provide their own recommended interval, so you don't really need to specify this.
|
||||
|
||||
##### stream
|
||||
|
||||
Type: `stream.Writable`\
|
||||
Default: `process.stderr`
|
||||
|
||||
Stream to write the output.
|
||||
|
||||
You could for example set this to `process.stdout` instead.
|
||||
|
||||
##### isEnabled
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Force enable/disable the spinner. If not specified, the spinner will be enabled if the `stream` is being run inside a TTY context (not spawned or piped) and/or not in a CI environment.
|
||||
|
||||
Note that `{isEnabled: false}` doesn't mean it won't output anything. It just means it won't output the spinner, colors, and other ansi escape codes. It will still log text.
|
||||
|
||||
##### isSilent
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Disable the spinner and all log text. All output is suppressed and `isEnabled` will be considered `false`.
|
||||
|
||||
##### discardStdin
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Discard stdin input (except Ctrl+C) while running if it's TTY. This prevents the spinner from twitching on input, outputting broken lines on <kbd>Enter</kbd> key presses, and prevents buffering of input while the spinner is running.
|
||||
|
||||
This has no effect on Windows as there is no good way to implement discarding stdin properly there.
|
||||
|
||||
### Instance
|
||||
|
||||
#### .text <sup>get/set</sup>
|
||||
|
||||
Change the text displayed after the spinner.
|
||||
|
||||
#### .prefixText <sup>get/set</sup>
|
||||
|
||||
Change the text before the spinner.
|
||||
|
||||
No prefix text will be displayed if set to an empty string.
|
||||
|
||||
#### .suffixText <sup>get/set</sup>
|
||||
|
||||
Change the text after the spinner text.
|
||||
|
||||
No suffix text will be displayed if set to an empty string.
|
||||
|
||||
#### .color <sup>get/set</sup>
|
||||
|
||||
Change the spinner color.
|
||||
|
||||
#### .spinner <sup>get/set</sup>
|
||||
|
||||
Change the spinner.
|
||||
|
||||
#### .indent <sup>get/set</sup>
|
||||
|
||||
Change the spinner indent.
|
||||
|
||||
#### .isSpinning <sup>get</sup>
|
||||
|
||||
A boolean indicating whether the instance is currently spinning.
|
||||
|
||||
#### .interval <sup>get</sup>
|
||||
|
||||
The interval between each frame.
|
||||
|
||||
The interval is decided by the chosen spinner.
|
||||
|
||||
#### .start(text?)
|
||||
|
||||
Start the spinner. Returns the instance. Set the current text if `text` is provided.
|
||||
|
||||
#### .stop()
|
||||
|
||||
Stop and clear the spinner. Returns the instance.
|
||||
|
||||
#### .succeed(text?)
|
||||
|
||||
Stop the spinner, change it to a green `✔` and persist the current text, or `text` if provided. Returns the instance. See the GIF below.
|
||||
|
||||
#### .fail(text?)
|
||||
|
||||
Stop the spinner, change it to a red `✖` and persist the current text, or `text` if provided. Returns the instance. See the GIF below.
|
||||
|
||||
#### .warn(text?)
|
||||
|
||||
Stop the spinner, change it to a yellow `⚠` and persist the current text, or `text` if provided. Returns the instance.
|
||||
|
||||
#### .info(text?)
|
||||
|
||||
Stop the spinner, change it to a blue `ℹ` and persist the current text, or `text` if provided. Returns the instance.
|
||||
|
||||
#### .stopAndPersist(options?)
|
||||
|
||||
Stop the spinner and change the symbol or text. Returns the instance. See the GIF below.
|
||||
|
||||
##### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
###### symbol
|
||||
|
||||
Type: `string`\
|
||||
Default: `' '`
|
||||
|
||||
Symbol to replace the spinner with.
|
||||
|
||||
###### text
|
||||
|
||||
Type: `string`\
|
||||
Default: Current `'text'`
|
||||
|
||||
Text to be persisted after the symbol.
|
||||
|
||||
###### prefixText
|
||||
|
||||
Type: `string | () => string`\
|
||||
Default: Current `prefixText`
|
||||
|
||||
Text or a function that returns text to be persisted before the symbol. No prefix text will be displayed if set to an empty string.
|
||||
|
||||
###### suffixText
|
||||
|
||||
Type: `string | () => string`\
|
||||
Default: Current `suffixText`
|
||||
|
||||
Text or a function that returns text to be persisted after the text after the symbol. No suffix text will be displayed if set to an empty string.
|
||||
|
||||
<img src="screenshot-2.gif" width="480">
|
||||
|
||||
#### .clear()
|
||||
|
||||
Clear the spinner. Returns the instance.
|
||||
|
||||
#### .render()
|
||||
|
||||
Manually render a new frame. Returns the instance.
|
||||
|
||||
#### .frame()
|
||||
|
||||
Get a new frame.
|
||||
|
||||
### oraPromise(action, text)
|
||||
### oraPromise(action, options)
|
||||
|
||||
Starts a spinner for a promise or promise-returning function. The spinner is stopped with `.succeed()` if the promise fulfills or with `.fail()` if it rejects. Returns the promise.
|
||||
|
||||
```js
|
||||
import {oraPromise} from 'ora';
|
||||
|
||||
await oraPromise(somePromise);
|
||||
```
|
||||
|
||||
#### action
|
||||
|
||||
Type: `Promise | ((spinner: ora.Ora) => Promise)`
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
All of the [options](#options) plus the following:
|
||||
|
||||
##### successText
|
||||
|
||||
Type: `string | ((result: T) => string) | undefined`
|
||||
|
||||
The new text of the spinner when the promise is resolved.
|
||||
|
||||
Keeps the existing text if `undefined`.
|
||||
|
||||
##### failText
|
||||
|
||||
Type: `string | ((error: Error) => string) | undefined`
|
||||
|
||||
The new text of the spinner when the promise is rejected.
|
||||
|
||||
Keeps the existing text if `undefined`.
|
||||
|
||||
### spinners
|
||||
|
||||
Type: `Record<string, Spinner>`
|
||||
|
||||
All [provided spinners](https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json).
|
||||
|
||||
## FAQ
|
||||
|
||||
### How do I change the color of the text?
|
||||
|
||||
Use [`chalk`](https://github.com/chalk/chalk) or [`yoctocolors`](https://github.com/sindresorhus/yoctocolors):
|
||||
|
||||
```js
|
||||
import ora from 'ora';
|
||||
import chalk from 'chalk';
|
||||
|
||||
const spinner = ora(`Loading ${chalk.red('unicorns')}`).start();
|
||||
```
|
||||
|
||||
### Why does the spinner freeze?
|
||||
|
||||
JavaScript is single-threaded, so any synchronous operations will block the spinner's animation. To avoid this, prefer using asynchronous operations.
|
||||
|
||||
### Can I display multiple spinners simultaneously?
|
||||
|
||||
No. Ora is designed to display a single spinner at a time. For multiple concurrent progress indicators, consider alternatives like [listr2](https://github.com/listr2/listr2) or [spinnies](https://github.com/jcarpanelli/spinnies).
|
||||
|
||||
### Can I use Ora with [log-update](https://github.com/sindresorhus/log-update)?
|
||||
|
||||
Yes, use the `.frame()` method to get the current spinner frame and include it in your log-update output.
|
||||
|
||||
### Does Ora work in Node.js Worker threads?
|
||||
|
||||
No. Ora requires an interactive terminal environment and Worker threads are not considered interactive, so the spinner will not animate. Run the spinner in the main thread and control it via worker messages:
|
||||
|
||||
```js
|
||||
// main.js
|
||||
import {Worker} from 'node:worker_threads';
|
||||
import ora from 'ora';
|
||||
|
||||
const spinner = ora().start();
|
||||
const worker = new Worker('./worker.js');
|
||||
|
||||
worker.on('message', message => {
|
||||
switch (message.type) {
|
||||
case 'ora:text':
|
||||
spinner.text = message.text;
|
||||
break;
|
||||
case 'ora:succeed':
|
||||
spinner.succeed(message.text);
|
||||
break;
|
||||
case 'ora:fail':
|
||||
spinner.fail(message.text);
|
||||
break;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
// worker.js
|
||||
import {parentPort} from 'node:worker_threads';
|
||||
|
||||
parentPort.postMessage({type: 'ora:text', text: 'Working...'});
|
||||
|
||||
// Do work...
|
||||
|
||||
parentPort.postMessage({type: 'ora:succeed', text: 'Done!'});
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [yocto-spinner](https://github.com/sindresorhus/yocto-spinner) - Tiny terminal spinner
|
||||
- [cli-spinners](https://github.com/sindresorhus/cli-spinners) - Spinners for use in the terminal
|
||||
|
||||
**Ports**
|
||||
|
||||
- [CLISpinner](https://github.com/kiliankoe/CLISpinner) - Terminal spinner library for Swift
|
||||
- [halo](https://github.com/ManrajGrover/halo) - Python port
|
||||
- [spinners](https://github.com/FGRibreau/spinners) - Terminal spinners for Rust
|
||||
- [marquee-ora](https://github.com/joeycozza/marquee-ora) - Scrolling marquee spinner for Ora
|
||||
- [briandowns/spinner](https://github.com/briandowns/spinner) - Terminal spinner/progress indicator for Go
|
||||
- [tj/go-spin](https://github.com/tj/go-spin) - Terminal spinner package for Go
|
||||
- [observablehq.com/@victordidenko/ora](https://observablehq.com/@victordidenko/ora) - Ora port to Observable notebooks
|
||||
- [kia](https://github.com/HarryPeach/kia) - Simple terminal spinners for Deno 🦕
|
||||
Reference in New Issue
Block a user