full site update
This commit is contained in:
153
node_modules/yocto-spinner/index.d.ts
generated
vendored
Normal file
153
node_modules/yocto-spinner/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
import {type Writable} from 'node:stream';
|
||||
|
||||
export type SpinnerStyle = {
|
||||
readonly interval?: number;
|
||||
readonly frames: string[];
|
||||
};
|
||||
|
||||
export type Color =
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'gray';
|
||||
|
||||
export type Options = {
|
||||
/**
|
||||
Text to display next to the spinner.
|
||||
|
||||
@default ''
|
||||
*/
|
||||
readonly text?: string;
|
||||
|
||||
/**
|
||||
Customize the spinner animation with a custom set of frames and interval.
|
||||
|
||||
```
|
||||
{
|
||||
frames: ['-', '\\', '|', '/'],
|
||||
interval: 100,
|
||||
}
|
||||
```
|
||||
|
||||
Pass in any spinner from [`cli-spinners`](https://github.com/sindresorhus/cli-spinners).
|
||||
*/
|
||||
readonly spinner?: SpinnerStyle;
|
||||
|
||||
/**
|
||||
The color of the spinner.
|
||||
|
||||
@default 'cyan'
|
||||
*/
|
||||
readonly color?: Color;
|
||||
|
||||
/**
|
||||
The stream to which the spinner is written.
|
||||
|
||||
@default process.stderr
|
||||
*/
|
||||
readonly stream?: Writable;
|
||||
};
|
||||
|
||||
export type Spinner = {
|
||||
/**
|
||||
Change the text displayed next to the spinner.
|
||||
|
||||
@example
|
||||
```
|
||||
spinner.text = 'New text';
|
||||
```
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
Change the spinner color.
|
||||
*/
|
||||
color: Color;
|
||||
|
||||
/**
|
||||
Starts the spinner.
|
||||
|
||||
Optionally, updates the text.
|
||||
|
||||
@param text - The text to display next to the spinner.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
start(text?: string): Spinner;
|
||||
|
||||
/**
|
||||
Stops the spinner.
|
||||
|
||||
Optionally displays a final message.
|
||||
|
||||
@param finalText - The final text to display after stopping the spinner.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
stop(finalText?: string): Spinner;
|
||||
|
||||
/**
|
||||
Stops the spinner and displays a success symbol with the message.
|
||||
|
||||
@param text - The success message to display.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
success(text?: string): Spinner;
|
||||
|
||||
/**
|
||||
Stops the spinner and displays an error symbol with the message.
|
||||
|
||||
@param text - The error message to display.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
error(text?: string): Spinner;
|
||||
|
||||
/**
|
||||
Stops the spinner and displays a warning symbol with the message.
|
||||
|
||||
@param text - The warning message to display.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
warning(text?: string): Spinner;
|
||||
|
||||
/**
|
||||
Stops the spinner and displays an info symbol with the message.
|
||||
|
||||
@param text - The info message to display.
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
info(text?: string): Spinner;
|
||||
|
||||
/**
|
||||
Clears the spinner.
|
||||
|
||||
@returns The spinner instance.
|
||||
*/
|
||||
clear(): Spinner;
|
||||
|
||||
/**
|
||||
Returns whether the spinner is currently spinning.
|
||||
*/
|
||||
get isSpinning(): boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
Creates a new spinner instance.
|
||||
|
||||
@returns A new spinner instance.
|
||||
|
||||
@example
|
||||
```
|
||||
import yoctoSpinner from 'yocto-spinner';
|
||||
|
||||
const spinner = yoctoSpinner({text: 'Loading…'}).start();
|
||||
|
||||
setTimeout(() => {
|
||||
spinner.success('Success!');
|
||||
}, 2000);
|
||||
```
|
||||
*/
|
||||
export default function yoctoSpinner(options?: Options): Spinner;
|
244
node_modules/yocto-spinner/index.js
generated
vendored
Normal file
244
node_modules/yocto-spinner/index.js
generated
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
import process from 'node:process';
|
||||
import {stripVTControlCharacters} from 'node:util';
|
||||
import yoctocolors from 'yoctocolors';
|
||||
|
||||
const isUnicodeSupported = process.platform !== 'win32'
|
||||
|| Boolean(process.env.WT_SESSION) // Windows Terminal
|
||||
|| process.env.TERM_PROGRAM === 'vscode';
|
||||
|
||||
const isInteractive = stream => Boolean(
|
||||
stream.isTTY
|
||||
&& process.env.TERM !== 'dumb'
|
||||
&& !('CI' in process.env),
|
||||
);
|
||||
|
||||
const infoSymbol = yoctocolors.blue(isUnicodeSupported ? 'ℹ' : 'i');
|
||||
const successSymbol = yoctocolors.green(isUnicodeSupported ? '✔' : '√');
|
||||
const warningSymbol = yoctocolors.yellow(isUnicodeSupported ? '⚠' : '‼');
|
||||
const errorSymbol = yoctocolors.red(isUnicodeSupported ? '✖' : '×');
|
||||
|
||||
const defaultSpinner = {
|
||||
frames: isUnicodeSupported
|
||||
? [
|
||||
'⠋',
|
||||
'⠙',
|
||||
'⠹',
|
||||
'⠸',
|
||||
'⠼',
|
||||
'⠴',
|
||||
'⠦',
|
||||
'⠧',
|
||||
'⠇',
|
||||
'⠏',
|
||||
]
|
||||
: [
|
||||
'-',
|
||||
'\\',
|
||||
'|',
|
||||
'/',
|
||||
],
|
||||
interval: 80,
|
||||
};
|
||||
|
||||
class YoctoSpinner {
|
||||
#frames;
|
||||
#interval;
|
||||
#currentFrame = -1;
|
||||
#timer;
|
||||
#text;
|
||||
#stream;
|
||||
#color;
|
||||
#lines = 0;
|
||||
#exitHandlerBound;
|
||||
#isInteractive;
|
||||
#lastSpinnerFrameTime = 0;
|
||||
|
||||
constructor(options = {}) {
|
||||
const spinner = options.spinner ?? defaultSpinner;
|
||||
this.#frames = spinner.frames;
|
||||
this.#interval = spinner.interval;
|
||||
this.#text = options.text ?? '';
|
||||
this.#stream = options.stream ?? process.stderr;
|
||||
this.#color = options.color ?? 'cyan';
|
||||
this.#isInteractive = isInteractive(this.#stream);
|
||||
this.#exitHandlerBound = this.#exitHandler.bind(this);
|
||||
}
|
||||
|
||||
start(text) {
|
||||
if (text) {
|
||||
this.#text = text;
|
||||
}
|
||||
|
||||
if (this.isSpinning) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.#hideCursor();
|
||||
this.#render();
|
||||
this.#subscribeToProcessEvents();
|
||||
|
||||
this.#timer = setInterval(() => {
|
||||
this.#render();
|
||||
}, this.#interval);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
stop(finalText) {
|
||||
if (!this.isSpinning) {
|
||||
return this;
|
||||
}
|
||||
|
||||
clearInterval(this.#timer);
|
||||
this.#timer = undefined;
|
||||
this.#showCursor();
|
||||
this.clear();
|
||||
this.#unsubscribeFromProcessEvents();
|
||||
|
||||
if (finalText) {
|
||||
this.#stream.write(`${finalText}\n`);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
#symbolStop(symbol, text) {
|
||||
return this.stop(`${symbol} ${text ?? this.#text}`);
|
||||
}
|
||||
|
||||
success(text) {
|
||||
return this.#symbolStop(successSymbol, text);
|
||||
}
|
||||
|
||||
error(text) {
|
||||
return this.#symbolStop(errorSymbol, text);
|
||||
}
|
||||
|
||||
warning(text) {
|
||||
return this.#symbolStop(warningSymbol, text);
|
||||
}
|
||||
|
||||
info(text) {
|
||||
return this.#symbolStop(infoSymbol, text);
|
||||
}
|
||||
|
||||
get isSpinning() {
|
||||
return this.#timer !== undefined;
|
||||
}
|
||||
|
||||
get text() {
|
||||
return this.#text;
|
||||
}
|
||||
|
||||
set text(value) {
|
||||
this.#text = value ?? '';
|
||||
this.#render();
|
||||
}
|
||||
|
||||
get color() {
|
||||
return this.#color;
|
||||
}
|
||||
|
||||
set color(value) {
|
||||
this.#color = value;
|
||||
this.#render();
|
||||
}
|
||||
|
||||
clear() {
|
||||
if (!this.#isInteractive) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.#stream.cursorTo(0);
|
||||
|
||||
for (let index = 0; index < this.#lines; index++) {
|
||||
if (index > 0) {
|
||||
this.#stream.moveCursor(0, -1);
|
||||
}
|
||||
|
||||
this.#stream.clearLine(1);
|
||||
}
|
||||
|
||||
this.#lines = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
#render() {
|
||||
// Ensure we only update the spinner frame at the wanted interval,
|
||||
// even if the frame method is called more often.
|
||||
const now = Date.now();
|
||||
if (this.#currentFrame === -1 || now - this.#lastSpinnerFrameTime >= this.#interval) {
|
||||
this.#currentFrame = ++this.#currentFrame % this.#frames.length;
|
||||
this.#lastSpinnerFrameTime = now;
|
||||
}
|
||||
|
||||
const applyColor = yoctocolors[this.#color] ?? yoctocolors.cyan;
|
||||
const frame = this.#frames[this.#currentFrame];
|
||||
let string = `${applyColor(frame)} ${this.#text}`;
|
||||
|
||||
if (!this.#isInteractive) {
|
||||
string += '\n';
|
||||
}
|
||||
|
||||
this.clear();
|
||||
this.#write(string);
|
||||
|
||||
if (this.#isInteractive) {
|
||||
this.#lines = this.#lineCount(string);
|
||||
}
|
||||
}
|
||||
|
||||
#write(text) {
|
||||
this.#stream.write(text);
|
||||
}
|
||||
|
||||
#lineCount(text) {
|
||||
const width = this.#stream.columns ?? 80;
|
||||
const lines = stripVTControlCharacters(text).split('\n');
|
||||
|
||||
let lineCount = 0;
|
||||
for (const line of lines) {
|
||||
lineCount += Math.max(1, Math.ceil(line.length / width));
|
||||
}
|
||||
|
||||
return lineCount;
|
||||
}
|
||||
|
||||
#hideCursor() {
|
||||
if (this.#isInteractive) {
|
||||
this.#write('\u001B[?25l');
|
||||
}
|
||||
}
|
||||
|
||||
#showCursor() {
|
||||
if (this.#isInteractive) {
|
||||
this.#write('\u001B[?25h');
|
||||
}
|
||||
}
|
||||
|
||||
#subscribeToProcessEvents() {
|
||||
process.once('SIGINT', this.#exitHandlerBound);
|
||||
process.once('SIGTERM', this.#exitHandlerBound);
|
||||
}
|
||||
|
||||
#unsubscribeFromProcessEvents() {
|
||||
process.off('SIGINT', this.#exitHandlerBound);
|
||||
process.off('SIGTERM', this.#exitHandlerBound);
|
||||
}
|
||||
|
||||
#exitHandler(signal) {
|
||||
if (this.isSpinning) {
|
||||
this.stop();
|
||||
}
|
||||
|
||||
// SIGINT: 128 + 2
|
||||
// SIGTERM: 128 + 15
|
||||
const exitCode = signal === 'SIGINT' ? 130 : (signal === 'SIGTERM' ? 143 : 1);
|
||||
process.exit(exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
export default function yoctoSpinner(options) {
|
||||
return new YoctoSpinner(options);
|
||||
}
|
9
node_modules/yocto-spinner/license
generated
vendored
Normal file
9
node_modules/yocto-spinner/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.
|
62
node_modules/yocto-spinner/package.json
generated
vendored
Normal file
62
node_modules/yocto-spinner/package.json
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "yocto-spinner",
|
||||
"version": "0.2.3",
|
||||
"description": "Tiny terminal spinner",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/yocto-spinner",
|
||||
"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.19"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsc index.d.ts"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"cli",
|
||||
"spinner",
|
||||
"spinners",
|
||||
"terminal",
|
||||
"term",
|
||||
"console",
|
||||
"ascii",
|
||||
"unicode",
|
||||
"loading",
|
||||
"indicator",
|
||||
"progress",
|
||||
"busy",
|
||||
"wait",
|
||||
"idle",
|
||||
"tiny",
|
||||
"yocto",
|
||||
"micro",
|
||||
"nano"
|
||||
],
|
||||
"dependencies": {
|
||||
"yoctocolors": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^6.1.3",
|
||||
"typescript": "^5.5.4",
|
||||
"xo": "^0.59.3"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/no-process-exit": "off"
|
||||
}
|
||||
}
|
||||
}
|
212
node_modules/yocto-spinner/readme.md
generated
vendored
Normal file
212
node_modules/yocto-spinner/readme.md
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
<h1 align="center" title="yocto-spinner">
|
||||
<img src="media/logo.jpg" alt="yocto-spinner logo">
|
||||
</h1>
|
||||
|
||||
[](https://packagephobia.com/result?p=yocto-spinner)
|
||||

|
||||
<!-- [](https://npmjs.com/yocto-spinner) -->
|
||||
<!--  -->
|
||||
|
||||
> Tiny terminal spinner
|
||||
|
||||
## Features
|
||||
|
||||
- Tiny and fast
|
||||
- Customizable text and color options
|
||||
- Customizable spinner animations
|
||||
- Only one tiny dependency
|
||||
- Supports both Unicode and non-Unicode environments
|
||||
- Gracefully handles process signals (e.g., `SIGINT`, `SIGTERM`)
|
||||
- Can display different status symbols (info, success, warning, error)
|
||||
- Works well in CI environments
|
||||
|
||||
*Check out [`ora`](https://github.com/sindresorhus/ora) for more features.*
|
||||
|
||||
<br>
|
||||
<p align="center">
|
||||
<br>
|
||||
<img src="https://raw.githubusercontent.com/sindresorhus/ora/3c63d5e8569d94564b5280525350724817e9ac26/screenshot.svg" width="500">
|
||||
<br>
|
||||
</p>
|
||||
<br>
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install yocto-spinner
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import yoctoSpinner from 'yocto-spinner';
|
||||
|
||||
const spinner = yoctoSpinner({text: 'Loading…'}).start();
|
||||
|
||||
setTimeout(() => {
|
||||
spinner.success('Success!');
|
||||
}, 2000);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### yoctoSpinner(options?)
|
||||
|
||||
Creates a new spinner instance.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### text
|
||||
|
||||
Type: `string`\
|
||||
Default: `''`
|
||||
|
||||
The text to display next to the spinner.
|
||||
|
||||
##### spinner
|
||||
|
||||
Type: `object`\
|
||||
Default: <img src="https://github.com/sindresorhus/ora/blob/main/screenshot-spinner.gif?raw=true" width="14">
|
||||
|
||||
Customize the spinner animation with a custom set of frames and interval.
|
||||
|
||||
```js
|
||||
{
|
||||
frames: ['-', '\\', '|', '/'],
|
||||
interval: 100,
|
||||
}
|
||||
```
|
||||
|
||||
Pass in any spinner from [`cli-spinners`](https://github.com/sindresorhus/cli-spinners).
|
||||
|
||||
##### color
|
||||
|
||||
Type: `string`\
|
||||
Default: `'cyan'`\
|
||||
Values: `'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray'`
|
||||
|
||||
The color of the spinner.
|
||||
|
||||
##### stream
|
||||
|
||||
Type: `stream.Writable`\
|
||||
Default: `process.stderr`
|
||||
|
||||
The stream to which the spinner is written.
|
||||
|
||||
### Instance methods
|
||||
|
||||
#### .start(text?)
|
||||
|
||||
Starts the spinner.
|
||||
|
||||
Returns the instance.
|
||||
|
||||
Optionally, updates the text:
|
||||
|
||||
```js
|
||||
spinner.start('Loading…');
|
||||
```
|
||||
|
||||
#### .stop(finalText?)
|
||||
|
||||
Stops the spinner.
|
||||
|
||||
Returns the instance.
|
||||
|
||||
Optionally displays a final message.
|
||||
|
||||
```js
|
||||
spinner.stop('Stopped.');
|
||||
```
|
||||
|
||||
#### .success(text?)
|
||||
|
||||
Stops the spinner and displays a success symbol with the message.
|
||||
|
||||
Returns the instance.
|
||||
|
||||
```js
|
||||
spinner.success('Success!');
|
||||
```
|
||||
|
||||
#### .error(text?)
|
||||
|
||||
Stops the spinner and displays an error symbol with the message.
|
||||
|
||||
Returns the instance.
|
||||
|
||||
```js
|
||||
spinner.error('Error!');
|
||||
```
|
||||
|
||||
#### .warning(text?)
|
||||
|
||||
Stops the spinner and displays a warning symbol with the message.
|
||||
|
||||
Returns the instance.
|
||||
|
||||
```js
|
||||
spinner.warning('Warning!');
|
||||
```
|
||||
|
||||
#### .clear()
|
||||
|
||||
Clears the spinner.
|
||||
|
||||
Returns the instance.
|
||||
|
||||
#### .info(text?)
|
||||
|
||||
Stops the spinner and displays an info symbol with the message.
|
||||
|
||||
Returns the instance.
|
||||
|
||||
```js
|
||||
spinner.info('Info.');
|
||||
```
|
||||
|
||||
#### .text <sup>get/set</sup>
|
||||
|
||||
Change the text displayed next to the spinner.
|
||||
|
||||
```js
|
||||
spinner.text = 'New text';
|
||||
```
|
||||
|
||||
#### .color <sup>get/set</sup>
|
||||
|
||||
Change the spinner color.
|
||||
|
||||
#### .isSpinning <sup>get</sup>
|
||||
|
||||
Returns whether the spinner is currently spinning.
|
||||
|
||||
## FAQ
|
||||
|
||||
### How do I change the color of the text?
|
||||
|
||||
Use [`yoctocolors`](https://github.com/sindresorhus/yoctocolors):
|
||||
|
||||
```js
|
||||
import yoctoSpinner from 'yocto-spinner';
|
||||
import {red} from 'yoctocolors';
|
||||
|
||||
const spinner = yoctoSpinner({text: `Loading ${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.
|
||||
|
||||
## Comparison with [`ora`](https://github.com/sindresorhus/ora)
|
||||
|
||||
Ora offers more options, greater customizability, [promise handling](https://github.com/sindresorhus/ora?tab=readme-ov-file#orapromiseaction-options), and better Unicode detection. It’s a more mature and feature-rich package that handles more edge cases but comes with additional dependencies and a larger size. In contrast, this package is smaller, simpler, and optimized for minimal overhead, making it ideal for lightweight projects where dependency size is important. However, Ora is generally the better choice for most use cases.
|
||||
|
||||
## Related
|
||||
|
||||
- [ora](https://github.com/sindresorhus/ora) - Comprehensive terminal spinner
|
||||
- [yoctocolors](https://github.com/sindresorhus/yoctocolors) - Tiny terminal coloring
|
||||
- [nano-spawn](https://github.com/sindresorhus/nano-spawn) - Tiny process execution for humans
|
Reference in New Issue
Block a user