Deployed the page to Github Pages.

This commit is contained in:
Batuhan Berk Başoğlu 2024-11-03 21:30:09 -05:00
parent 1d79754e93
commit 2c89899458
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
62797 changed files with 6551425 additions and 15279 deletions

104
node_modules/log-update/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,104 @@
export type Options = {
/**
Show the cursor. This can be useful when a CLI accepts input from a user.
@example
```
import {createLogUpdate} from 'log-update';
// Write output but don't hide the cursor
const log = createLogUpdate(process.stdout, {
showCursor: true
});
```
*/
readonly showCursor?: boolean;
};
type LogUpdateMethods = {
/**
Clear the logged output.
*/
clear(): void;
/**
Persist the logged output. Useful if you want to start a new log session below the current one.
*/
done(): void;
};
/**
Log to `stdout` by overwriting the previous output in the terminal.
@param text - The text to log to `stdout`.
@example
```
import logUpdate from 'log-update';
const frames = ['-', '\\', '|', '/'];
let index = 0;
setInterval(() => {
const frame = frames[index = ++index % frames.length];
logUpdate(
`
${frame} unicorns ${frame}
`
);
}, 80);
```
*/
declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
export default logUpdate;
/**
Log to `stderr` by overwriting the previous output in the terminal.
@param text - The text to log to `stderr`.
@example
```
import {logUpdateStderr} from 'log-update';
const frames = ['-', '\\', '|', '/'];
let index = 0;
setInterval(() => {
const frame = frames[index = ++index % frames.length];
logUpdateStderr(
`
${frame} unicorns ${frame}
`
);
}, 80);
```
*/
declare const logUpdateStderr: ((...text: string[]) => void) & LogUpdateMethods;
export {logUpdateStderr};
/**
Get a `logUpdate` method that logs to the specified stream.
@param stream - The stream to log to.
@example
```
import {createLogUpdate} from 'log-update';
// Write output but don't hide the cursor
const log = createLogUpdate(process.stdout);
```
*/
export function createLogUpdate(
stream: NodeJS.WritableStream,
options?: Options
): typeof logUpdate;

68
node_modules/log-update/index.js generated vendored Normal file
View file

@ -0,0 +1,68 @@
import process from 'node:process';
import ansiEscapes from 'ansi-escapes';
import cliCursor from 'cli-cursor';
import wrapAnsi from 'wrap-ansi';
import sliceAnsi from 'slice-ansi';
import stripAnsi from 'strip-ansi';
const defaultTerminalHeight = 24;
const getWidth = ({columns = 80}) => columns;
const fitToTerminalHeight = (stream, text) => {
const terminalHeight = stream.rows ?? defaultTerminalHeight;
const lines = text.split('\n');
const toRemove = Math.max(0, lines.length - terminalHeight);
return toRemove ? sliceAnsi(text, stripAnsi(lines.slice(0, toRemove).join('\n')).length + 1) : text;
};
export function createLogUpdate(stream, {showCursor = false} = {}) {
let previousLineCount = 0;
let previousWidth = getWidth(stream);
let previousOutput = '';
const reset = () => {
previousOutput = '';
previousWidth = getWidth(stream);
previousLineCount = 0;
};
const render = (...arguments_) => {
if (!showCursor) {
cliCursor.hide();
}
let output = fitToTerminalHeight(stream, arguments_.join(' ') + '\n');
const width = getWidth(stream);
if (output === previousOutput && previousWidth === width) {
return;
}
previousOutput = output;
previousWidth = width;
output = wrapAnsi(output, width, {trim: false, hard: true, wordWrap: false});
stream.write(ansiEscapes.eraseLines(previousLineCount) + output);
previousLineCount = output.split('\n').length;
};
render.clear = () => {
stream.write(ansiEscapes.eraseLines(previousLineCount));
reset();
};
render.done = () => {
reset();
if (!showCursor) {
cliCursor.show();
}
};
return render;
}
const logUpdate = createLogUpdate(process.stdout);
export default logUpdate;
export const logUpdateStderr = createLogUpdate(process.stderr);

9
node_modules/log-update/license generated vendored Normal file
View 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.

View file

@ -0,0 +1,262 @@
// From https://github.com/sindresorhus/type-fest
type Primitive =
| null // eslint-disable-line @typescript-eslint/ban-types
| undefined
| string
| number
| boolean
| symbol
| bigint;
type LiteralUnion<LiteralType, BaseType extends Primitive> =
| LiteralType
| (BaseType & Record<never, never>);
// -
export type ImageOptions = {
/**
The width is given as a number followed by a unit, or the word `'auto'`.
- `N`: N character cells.
- `Npx`: N pixels.
- `N%`: N percent of the session's width or height.
- `auto`: The image's inherent size will be used to determine an appropriate dimension.
*/
readonly width?: LiteralUnion<'auto', number | string>;
/**
The height is given as a number followed by a unit, or the word `'auto'`.
- `N`: N character cells.
- `Npx`: N pixels.
- `N%`: N percent of the session's width or height.
- `auto`: The image's inherent size will be used to determine an appropriate dimension.
*/
readonly height?: LiteralUnion<'auto', number | string>;
/**
@default true
*/
readonly preserveAspectRatio?: boolean;
};
export type AnnotationOptions = {
/**
Nonzero number of columns to annotate.
Default: The remainder of the line.
*/
readonly length?: number;
/**
Starting X coordinate.
Must be used with `y` and `length`.
Default: The cursor position
*/
readonly x?: number;
/**
Starting Y coordinate.
Must be used with `x` and `length`.
Default: Cursor position.
*/
readonly y?: number;
/**
Create a "hidden" annotation.
Annotations created this way can be shown using the "Show Annotations" iTerm command.
*/
readonly isHidden?: boolean;
};
/**
Set the absolute position of the cursor. `x0` `y0` is the top left of the screen.
*/
export function cursorTo(x: number, y?: number): string;
/**
Set the position of the cursor relative to its current position.
*/
export function cursorMove(x: number, y?: number): string;
/**
Move cursor up a specific amount of rows.
@param count - Count of rows to move up. Default is `1`.
*/
export function cursorUp(count?: number): string;
/**
Move cursor down a specific amount of rows.
@param count - Count of rows to move down. Default is `1`.
*/
export function cursorDown(count?: number): string;
/**
Move cursor forward a specific amount of rows.
@param count - Count of rows to move forward. Default is `1`.
*/
export function cursorForward(count?: number): string;
/**
Move cursor backward a specific amount of rows.
@param count - Count of rows to move backward. Default is `1`.
*/
export function cursorBackward(count?: number): string;
/**
Move cursor to the left side.
*/
export const cursorLeft: string;
/**
Save cursor position.
*/
export const cursorSavePosition: string;
/**
Restore saved cursor position.
*/
export const cursorRestorePosition: string;
/**
Get cursor position.
*/
export const cursorGetPosition: string;
/**
Move cursor to the next line.
*/
export const cursorNextLine: string;
/**
Move cursor to the previous line.
*/
export const cursorPrevLine: string;
/**
Hide cursor.
*/
export const cursorHide: string;
/**
Show cursor.
*/
export const cursorShow: string;
/**
Erase from the current cursor position up the specified amount of rows.
@param count - Count of rows to erase.
*/
export function eraseLines(count: number): string;
/**
Erase from the current cursor position to the end of the current line.
*/
export const eraseEndLine: string;
/**
Erase from the current cursor position to the start of the current line.
*/
export const eraseStartLine: string;
/**
Erase the entire current line.
*/
export const eraseLine: string;
/**
Erase the screen from the current line down to the bottom of the screen.
*/
export const eraseDown: string;
/**
Erase the screen from the current line up to the top of the screen.
*/
export const eraseUp: string;
/**
Erase the screen and move the cursor the top left position.
*/
export const eraseScreen: string;
/**
Scroll display up one line.
*/
export const scrollUp: string;
/**
Scroll display down one line.
*/
export const scrollDown: string;
/**
Clear the terminal screen. (Viewport)
*/
export const clearScreen: string;
/**
Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)
*/
export const clearTerminal: string;
/**
Enter the [alternative screen](https://terminalguide.namepad.de/mode/p47/).
*/
export const enterAlternativeScreen: string;
/**
Exit the [alternative screen](https://terminalguide.namepad.de/mode/p47/), assuming `enterAlternativeScreen` was called before.
*/
export const exitAlternativeScreen: string;
/**
Output a beeping sound.
*/
export const beep: string;
/**
Create a clickable link.
[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) Use [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks) to detect link support.
*/
export function link(text: string, url: string): string;
/**
Display an image.
See [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.
@param data - Image data. Usually read in with `fs.readFile()`.
*/
export function image(data: Uint8Array, options?: ImageOptions): string;
export const iTerm: {
/**
[Inform iTerm2](https://www.iterm2.com/documentation-escape-codes.html) of the current directory to help semantic history and enable [Cmd-clicking relative paths](https://coderwall.com/p/b7e82q/quickly-open-files-in-iterm-with-cmd-click).
@param cwd - Current directory. Default: `process.cwd()`.
*/
setCwd(cwd?: string): string,
/**
An annotation looks like this when shown:
![screenshot of iTerm annotation](https://user-images.githubusercontent.com/924465/64382136-b60ac700-cfe9-11e9-8a35-9682e8dc4b72.png)
See the [iTerm Proprietary Escape Codes documentation](https://iterm2.com/documentation-escape-codes.html) for more information.
@param message - The message to display within the annotation. The `|` character is disallowed and will be stripped.
@returns An escape code which will create an annotation when printed in iTerm2.
*/
annotation(message: string, options?: AnnotationOptions): string
};

View file

@ -0,0 +1,163 @@
import process from 'node:process';
import {isBrowser} from 'environment';
const ESC = '\u001B[';
const OSC = '\u001B]';
const BEL = '\u0007';
const SEP = ';';
const isTerminalApp = !isBrowser && process.env.TERM_PROGRAM === 'Apple_Terminal';
const isWindows = !isBrowser && process.platform === 'win32';
const cwdFunction = isBrowser ? () => {
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
} : process.cwd;
export const cursorTo = (x, y) => {
if (typeof x !== 'number') {
throw new TypeError('The `x` argument is required');
}
if (typeof y !== 'number') {
return ESC + (x + 1) + 'G';
}
return ESC + (y + 1) + SEP + (x + 1) + 'H';
};
export const cursorMove = (x, y) => {
if (typeof x !== 'number') {
throw new TypeError('The `x` argument is required');
}
let returnValue = '';
if (x < 0) {
returnValue += ESC + (-x) + 'D';
} else if (x > 0) {
returnValue += ESC + x + 'C';
}
if (y < 0) {
returnValue += ESC + (-y) + 'A';
} else if (y > 0) {
returnValue += ESC + y + 'B';
}
return returnValue;
};
export const cursorUp = (count = 1) => ESC + count + 'A';
export const cursorDown = (count = 1) => ESC + count + 'B';
export const cursorForward = (count = 1) => ESC + count + 'C';
export const cursorBackward = (count = 1) => ESC + count + 'D';
export const cursorLeft = ESC + 'G';
export const cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
export const cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
export const cursorGetPosition = ESC + '6n';
export const cursorNextLine = ESC + 'E';
export const cursorPrevLine = ESC + 'F';
export const cursorHide = ESC + '?25l';
export const cursorShow = ESC + '?25h';
export const eraseLines = count => {
let clear = '';
for (let i = 0; i < count; i++) {
clear += eraseLine + (i < count - 1 ? cursorUp() : '');
}
if (count) {
clear += cursorLeft;
}
return clear;
};
export const eraseEndLine = ESC + 'K';
export const eraseStartLine = ESC + '1K';
export const eraseLine = ESC + '2K';
export const eraseDown = ESC + 'J';
export const eraseUp = ESC + '1J';
export const eraseScreen = ESC + '2J';
export const scrollUp = ESC + 'S';
export const scrollDown = ESC + 'T';
export const clearScreen = '\u001Bc';
export const clearTerminal = isWindows
? `${eraseScreen}${ESC}0f`
// 1. Erases the screen (Only done in case `2` is not supported)
// 2. Erases the whole screen including scrollback buffer
// 3. Moves cursor to the top-left position
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
: `${eraseScreen}${ESC}3J${ESC}H`;
export const enterAlternativeScreen = ESC + '?1049h';
export const exitAlternativeScreen = ESC + '?1049l';
export const beep = BEL;
export const link = (text, url) => [
OSC,
'8',
SEP,
SEP,
url,
BEL,
text,
OSC,
'8',
SEP,
SEP,
BEL,
].join('');
export const image = (data, options = {}) => {
let returnValue = `${OSC}1337;File=inline=1`;
if (options.width) {
returnValue += `;width=${options.width}`;
}
if (options.height) {
returnValue += `;height=${options.height}`;
}
if (options.preserveAspectRatio === false) {
returnValue += ';preserveAspectRatio=0';
}
return returnValue + ':' + Buffer.from(data).toString('base64') + BEL;
};
export const iTerm = {
setCwd: (cwd = cwdFunction()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
annotation(message, options = {}) {
let returnValue = `${OSC}1337;`;
const hasX = options.x !== undefined;
const hasY = options.y !== undefined;
if ((hasX || hasY) && !(hasX && hasY && options.length !== undefined)) {
throw new Error('`x`, `y` and `length` must be defined when `x` or `y` is defined');
}
message = message.replaceAll('|', '');
returnValue += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation=';
if (options.length > 0) {
returnValue += (
hasX
? [message, options.length, options.x, options.y]
: [options.length, message]
).join('|');
} else {
returnValue += message;
}
return returnValue + BEL;
},
};

View file

@ -0,0 +1,2 @@
export * from './base.js';
export * as default from './base.js';

View file

@ -0,0 +1,2 @@
export * from './base.js';
export * as default from './base.js';

View 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.

View file

@ -0,0 +1,70 @@
{
"name": "ansi-escapes",
"version": "7.0.0",
"description": "ANSI escape codes for manipulating the terminal",
"license": "MIT",
"repository": "sindresorhus/ansi-escapes",
"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"
},
"scripts": {
"test": "ava && tsd",
"//test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts",
"base.js",
"base.d.ts"
],
"keywords": [
"ansi",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"escapes",
"formatting",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text",
"vt100",
"sequence",
"control",
"code",
"codes",
"cursor",
"iterm",
"iterm2",
"clear",
"screen",
"erase",
"scrollback"
],
"dependencies": {
"environment": "^1.0.0"
},
"devDependencies": {
"@types/node": "20.12.8",
"ava": "^6.1.2",
"tsd": "0.31.0",
"xo": "^0.58.0"
}
}

View file

@ -0,0 +1,261 @@
# ansi-escapes
> [ANSI escape codes](https://www2.ccs.neu.edu/research/gpc/VonaUtils/vona/terminal/vtansi.htm) for manipulating the terminal
## Install
```sh
npm install ansi-escapes
```
## Usage
```js
import ansiEscapes from 'ansi-escapes';
// Moves the cursor two rows up and to the left
process.stdout.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);
//=> '\u001B[2A\u001B[1000D'
```
Or use named exports...
```js
import {cursorUp, cursorLeft} from 'ansi-escapes';
// etc, as above...
```
**You can also use it in the browser with Xterm.js:**
```js
import ansiEscapes from 'ansi-escapes';
import {Terminal} from 'xterm';
import 'xterm/css/xterm.css';
const terminal = new Terminal({…});
// Moves the cursor two rows up and to the left
terminal.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);
//=> '\u001B[2A\u001B[1000D'
```
## API
### cursorTo(x, y?)
Set the absolute position of the cursor. `x0` `y0` is the top left of the screen.
### cursorMove(x, y?)
Set the position of the cursor relative to its current position.
### cursorUp(count)
Move cursor up a specific amount of rows. Default is `1`.
### cursorDown(count)
Move cursor down a specific amount of rows. Default is `1`.
### cursorForward(count)
Move cursor forward a specific amount of columns. Default is `1`.
### cursorBackward(count)
Move cursor backward a specific amount of columns. Default is `1`.
### cursorLeft
Move cursor to the left side.
### cursorSavePosition
Save cursor position.
### cursorRestorePosition
Restore saved cursor position.
### cursorGetPosition
Get cursor position.
### cursorNextLine
Move cursor to the next line.
### cursorPrevLine
Move cursor to the previous line.
### cursorHide
Hide cursor.
### cursorShow
Show cursor.
### eraseLines(count)
Erase from the current cursor position up the specified amount of rows.
### eraseEndLine
Erase from the current cursor position to the end of the current line.
### eraseStartLine
Erase from the current cursor position to the start of the current line.
### eraseLine
Erase the entire current line.
### eraseDown
Erase the screen from the current line down to the bottom of the screen.
### eraseUp
Erase the screen from the current line up to the top of the screen.
### eraseScreen
Erase the screen and move the cursor the top left position.
### scrollUp
Scroll display up one line.
### scrollDown
Scroll display down one line.
### clearScreen
Clear the terminal screen. (Viewport)
### clearTerminal
Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)
### enterAlternativeScreen
Enter the [alternative screen](https://terminalguide.namepad.de/mode/p47/).
### exitAlternativeScreen
Exit the [alternative screen](https://terminalguide.namepad.de/mode/p47/), assuming `enterAlternativeScreen` was called before.
### beep
Output a beeping sound.
### link(text, url)
Create a clickable link.
[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) Use [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks) to detect link support.
### image(filePath, options?)
Display an image.
See [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.
#### input
Type: `Buffer`
Buffer of an image. Usually read in with `fs.readFile()`.
#### options
Type: `object`
##### width
##### height
Type: `string | number`
The width and height are given as a number followed by a unit, or the word "auto".
- `N`: N character cells.
- `Npx`: N pixels.
- `N%`: N percent of the session's width or height.
- `auto`: The image's inherent size will be used to determine an appropriate dimension.
##### preserveAspectRatio
Type: `boolean`\
Default: `true`
### iTerm.setCwd(path?)
Type: `string`\
Default: `process.cwd()`
[Inform iTerm2](https://www.iterm2.com/documentation-escape-codes.html) of the current directory to help semantic history and enable [Cmd-clicking relative paths](https://coderwall.com/p/b7e82q/quickly-open-files-in-iterm-with-cmd-click).
### iTerm.annotation(message, options?)
Creates an escape code to display an "annotation" in iTerm2.
An annotation looks like this when shown:
<img src="https://user-images.githubusercontent.com/924465/64382136-b60ac700-cfe9-11e9-8a35-9682e8dc4b72.png" width="500">
See the [iTerm Proprietary Escape Codes documentation](https://iterm2.com/documentation-escape-codes.html) for more information.
#### message
Type: `string`
The message to display within the annotation.
The `|` character is disallowed and will be stripped.
#### options
Type: `object`
##### length
Type: `number`\
Default: The remainder of the line
Nonzero number of columns to annotate.
##### x
Type: `number`\
Default: Cursor position
Starting X coordinate.
Must be used with `y` and `length`.
##### y
Type: `number`\
Default: Cursor position
Starting Y coordinate.
Must be used with `x` and `length`.
##### isHidden
Type: `boolean`\
Default: `false`
Create a "hidden" annotation.
Annotations created this way can be shown using the "Show Annotations" iTerm command.
## Related
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal

View 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;

View 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;

View 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.

View file

@ -0,0 +1,54 @@
{
"name": "ansi-styles",
"version": "6.2.1",
"description": "ANSI escape codes for styling strings in the terminal",
"license": "MIT",
"repository": "chalk/ansi-styles",
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd",
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"devDependencies": {
"ava": "^3.15.0",
"svg-term-cli": "^2.1.1",
"tsd": "^0.19.0",
"xo": "^0.47.0"
}
}

View file

@ -0,0 +1,173 @@
# ansi-styles
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
![](screenshot.png)
## Install
```sh
npm install ansi-styles
```
## Usage
```js
import styles from 'ansi-styles';
console.log(`${styles.green.open}Hello world!${styles.green.close}`);
// Color conversion between 256/truecolor
// NOTE: When converting from truecolor to 256 colors, the original color
// may be degraded to fit the new color palette. This means terminals
// that do not support 16 million colors will best-match the
// original color.
console.log(`${styles.color.ansi(styles.rgbToAnsi(199, 20, 250))}Hello World${styles.color.close}`)
console.log(`${styles.color.ansi256(styles.rgbToAnsi256(199, 20, 250))}Hello World${styles.color.close}`)
console.log(`${styles.color.ansi16m(...styles.hexToRgb('#abcdef'))}Hello World${styles.color.close}`)
```
## API
### `open` and `close`
Each style has an `open` and `close` property.
### `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 need to validate input:
```js
import {modifierNames, foregroundColorNames} from 'ansi-styles';
console.log(modifierNames.includes('bold'));
//=> true
console.log(foregroundColorNames.includes('pink'));
//=> false
```
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(Not widely supported)*
- `underline`
- `overline` *Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.*
- `inverse`
- `hidden`
- `strikethrough` *(Not widely supported)*
### 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`
## Advanced usage
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
- `styles.modifier`
- `styles.color`
- `styles.bgColor`
###### Example
```js
import styles from 'ansi-styles';
console.log(styles.color.green.open);
```
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `styles.codes`, which returns a `Map` with the open codes as keys and close codes as values.
###### Example
```js
import styles from 'ansi-styles';
console.log(styles.codes.get(36));
//=> 39
```
## 16 / 256 / 16 million (TrueColor) support
`ansi-styles` allows converting between various color formats and ANSI escapes, with support for 16, 256 and [16 million colors](https://gist.github.com/XVilka/8346728).
The following color spaces are supported:
- `rgb`
- `hex`
- `ansi256`
- `ansi`
To use these, call the associated conversion function with the intended output, for example:
```js
import styles from 'ansi-styles';
styles.color.ansi(styles.rgbToAnsi(100, 200, 15)); // RGB to 16 color ansi foreground code
styles.bgColor.ansi(styles.hexToAnsi('#C0FFEE')); // HEX to 16 color ansi foreground code
styles.color.ansi256(styles.rgbToAnsi256(100, 200, 15)); // RGB to 256 color ansi foreground code
styles.bgColor.ansi256(styles.hexToAnsi256('#C0FFEE')); // HEX to 256 color ansi foreground code
styles.color.ansi16m(100, 200, 15); // RGB to 16 million color foreground code
styles.bgColor.ansi16m(...styles.hexToRgb('#C0FFEE')); // Hex (RGB) to 16 million color foreground code
```
## Related
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)
## For enterprise
Available as part of the Tidelift Subscription.
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

View file

@ -0,0 +1,47 @@
declare const cliCursor: {
/**
Show cursor.
@param stream - Default: `process.stderr`.
@example
```
import cliCursor from 'cli-cursor';
cliCursor.show();
```
*/
show(stream?: NodeJS.WritableStream): void;
/**
Hide cursor.
@param stream - Default: `process.stderr`.
@example
```
import cliCursor from 'cli-cursor';
cliCursor.hide();
```
*/
hide(stream?: NodeJS.WritableStream): void;
/**
Toggle cursor visibility.
@param force - Is useful to show or hide the cursor based on a boolean.
@param stream - Default: `process.stderr`.
@example
```
import cliCursor from 'cli-cursor';
const unicornsAreAwesome = true;
cliCursor.toggle(unicornsAreAwesome);
```
*/
toggle(force?: boolean, stream?: NodeJS.WritableStream): void;
};
export default cliCursor;

View file

@ -0,0 +1,39 @@
import process from 'node:process';
import restoreCursor from 'restore-cursor';
let isHidden = false;
const cliCursor = {};
cliCursor.show = (writableStream = process.stderr) => {
if (!writableStream.isTTY) {
return;
}
isHidden = false;
writableStream.write('\u001B[?25h');
};
cliCursor.hide = (writableStream = process.stderr) => {
if (!writableStream.isTTY) {
return;
}
restoreCursor();
isHidden = true;
writableStream.write('\u001B[?25l');
};
cliCursor.toggle = (force, writableStream) => {
if (force !== undefined) {
isHidden = force;
}
if (isHidden) {
cliCursor.show(writableStream);
} else {
cliCursor.hide(writableStream);
}
};
export default cliCursor;

View 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.

View file

@ -0,0 +1,56 @@
{
"name": "cli-cursor",
"version": "5.0.0",
"description": "Toggle the CLI cursor",
"license": "MIT",
"repository": "sindresorhus/cli-cursor",
"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"
},
"scripts": {
"test": "xo && ava && tsc index.d.ts"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"cli",
"cursor",
"ansi",
"toggle",
"display",
"show",
"hide",
"term",
"terminal",
"console",
"tty",
"shell",
"command-line"
],
"dependencies": {
"restore-cursor": "^5.0.0"
},
"devDependencies": {
"@types/node": "^20.14.12",
"ava": "^6.1.3",
"typescript": "^5.5.4",
"xo": "^0.59.2"
},
"ava": {
"workerThreads": false
}
}

View file

@ -0,0 +1,39 @@
# cli-cursor
> Toggle the CLI cursor
The cursor is [gracefully restored](https://github.com/sindresorhus/restore-cursor) if the process exits.
## Install
```sh
npm install cli-cursor
```
## Usage
```js
import cliCursor from 'cli-cursor';
cliCursor.hide();
const unicornsAreAwesome = true;
cliCursor.toggle(unicornsAreAwesome);
```
## API
### .show(stream?)
### .hide(stream?)
### .toggle(force?, stream?)
#### force
Useful for showing or hiding the cursor based on a boolean.
#### stream
Type: `stream.Writable`\
Default: `process.stderr`

View file

@ -0,0 +1,20 @@
Copyright Mathias Bynens <https://mathiasbynens.be/>
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.

View file

@ -0,0 +1,107 @@
# emoji-regex [![Build status](https://github.com/mathiasbynens/emoji-regex/actions/workflows/main.yml/badge.svg)](https://github.com/mathiasbynens/emoji-regex/actions/workflows/main.yml) [![emoji-regex on npm](https://img.shields.io/npm/v/emoji-regex)](https://www.npmjs.com/package/emoji-regex)
_emoji-regex_ offers a regular expression to match all emoji symbols and sequences (including textual representations of emoji) as per the Unicode Standard. Its based on [_emoji-test-regex-pattern_](https://github.com/mathiasbynens/emoji-test-regex-pattern), which generates (at build time) the regular expression pattern based on the Unicode Standard. As a result, _emoji-regex_ can easily be updated whenever new emoji are added to Unicode.
Since each version of _emoji-regex_ is tied to the latest Unicode version at the time of release, results are deterministic. This is important for use cases like image replacement, where you want to guarantee that an image asset is available for every possibly matched emoji. If you dont need a deterministic regex, a lighter-weight, general emoji pattern is available via the [_emoji-regex-xs_](https://github.com/slevithan/emoji-regex-xs) package that follows the same API.
## Installation
Via [npm](https://www.npmjs.com/):
```bash
npm install emoji-regex
```
In [Node.js](https://nodejs.org/):
```js
const emojiRegex = require('emoji-regex');
// Note: because the regular expression has the global flag set, this module
// exports a function that returns the regex rather than exporting the regular
// expression itself, to make it impossible to (accidentally) mutate the
// original regular expression.
const text = `
\u{231A}: ⌚ default emoji presentation character (Emoji_Presentation)
\u{2194}\u{FE0F}: ↔️ default text presentation character rendered as emoji
\u{1F469}: 👩 emoji modifier base (Emoji_Modifier_Base)
\u{1F469}\u{1F3FF}: 👩🏿 emoji modifier base followed by a modifier
`;
const regex = emojiRegex();
for (const match of text.matchAll(regex)) {
const emoji = match[0];
console.log(`Matched sequence ${ emoji } — code points: ${ [...emoji].length }`);
}
```
Console output:
```
Matched sequence ⌚ — code points: 1
Matched sequence ⌚ — code points: 1
Matched sequence ↔️ — code points: 2
Matched sequence ↔️ — code points: 2
Matched sequence 👩 — code points: 1
Matched sequence 👩 — code points: 1
Matched sequence 👩🏿 — code points: 2
Matched sequence 👩🏿 — code points: 2
```
## For maintainers
### How to update emoji-regex after new Unicode Standard releases
1. [Update _emoji-test-regex-pattern_ as described in its repository](https://github.com/mathiasbynens/emoji-test-regex-pattern#how-to-update-emoji-test-regex-pattern-after-new-uts51-releases).
1. Bump the _emoji-test-regex-pattern_ dependency to the latest version.
1. Update the Unicode data dependency in `package.json` by running the following commands:
```sh
# Example: updating from Unicode v13 to Unicode v14.
npm uninstall @unicode/unicode-13.0.0
npm install @unicode/unicode-14.0.0 --save-dev
````
1. Generate the new output:
```sh
npm run build
```
1. Verify that tests still pass:
```sh
npm test
```
### How to publish a new release
1. On the `main` branch, bump the emoji-regex version number in `package.json`:
```sh
npm version patch -m 'Release v%s'
```
Instead of `patch`, use `minor` or `major` [as needed](https://semver.org/).
Note that this produces a Git commit + tag.
1. Push the release commit and tag:
```sh
git push && git push --tags
```
Our CI then automatically publishes the new release to npm.
## Author
| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
|---|
| [Mathias Bynens](https://mathiasbynens.be/) |
## License
_emoji-regex_ is available under the [MIT](https://mths.be/mit) license.

View file

@ -0,0 +1,3 @@
declare module 'emoji-regex' {
export default function emojiRegex(): RegExp;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,45 @@
{
"name": "emoji-regex",
"version": "10.4.0",
"description": "A regular expression to match all Emoji-only symbols as per the Unicode Standard.",
"homepage": "https://mths.be/emoji-regex",
"main": "index.js",
"module": "index.mjs",
"types": "index.d.ts",
"keywords": [
"unicode",
"regex",
"regexp",
"regular expressions",
"code points",
"symbols",
"characters",
"emoji"
],
"license": "MIT",
"author": {
"name": "Mathias Bynens",
"url": "https://mathiasbynens.be/"
},
"repository": {
"type": "git",
"url": "https://github.com/mathiasbynens/emoji-regex.git"
},
"bugs": "https://github.com/mathiasbynens/emoji-regex/issues",
"files": [
"LICENSE-MIT.txt",
"index.js",
"index.d.ts",
"index.mjs"
],
"scripts": {
"build": "node script/build.js",
"test": "mocha",
"test:watch": "npm run test -- --watch"
},
"devDependencies": {
"@unicode/unicode-16.0.0": "^1.0.0",
"emoji-test-regex-pattern": "^2.2.0",
"mocha": "^10.7.3"
}
}

View file

@ -0,0 +1,17 @@
/**
Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms).
@param codePoint - The [code point](https://en.wikipedia.org/wiki/Code_point) of a character.
@example
```
import isFullwidthCodePoint from 'is-fullwidth-code-point';
isFullwidthCodePoint('谢'.codePointAt(0));
//=> true
isFullwidthCodePoint('a'.codePointAt(0));
//=> false
```
*/
export default function isFullwidthCodePoint(codePoint: number): boolean;

View file

@ -0,0 +1,9 @@
import {eastAsianWidth} from 'get-east-asian-width';
export default function isFullwidthCodePoint(codePoint) {
if (!Number.isInteger(codePoint)) {
return false;
}
return eastAsianWidth(codePoint) === 2;
}

View 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.

View file

@ -0,0 +1,52 @@
{
"name": "is-fullwidth-code-point",
"version": "5.0.0",
"description": "Check if the character represented by a given Unicode code point is fullwidth",
"license": "MIT",
"repository": "sindresorhus/is-fullwidth-code-point",
"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"
},
"engines": {
"node": ">=18"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"fullwidth",
"full-width",
"full",
"width",
"unicode",
"character",
"string",
"codepoint",
"code",
"point",
"is",
"detect",
"check",
"east-asian-width"
],
"devDependencies": {
"ava": "^5.3.1",
"tsd": "^0.29.0",
"xo": "^0.56.0"
},
"dependencies": {
"get-east-asian-width": "^1.0.0"
}
}

View file

@ -0,0 +1,31 @@
# is-fullwidth-code-point
> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms)
## Install
```sh
npm install is-fullwidth-code-point
```
## Usage
```js
import isFullwidthCodePoint from 'is-fullwidth-code-point';
isFullwidthCodePoint('谢'.codePointAt(0));
//=> true
isFullwidthCodePoint('a'.codePointAt(0));
//=> false
```
## API
### isFullwidthCodePoint(codePoint)
#### codePoint
Type: `number`
The [code point](https://en.wikipedia.org/wiki/Code_point) of a character.

View file

@ -0,0 +1,59 @@
export type Options = {
/**
Throw an error when called more than once.
@default false
*/
readonly throw?: boolean;
};
declare const onetime: {
/**
Ensure a function is only called once. When called multiple times it will return the return value from the first call.
@param fn - The function that should only be called once.
@returns A function that only calls `fn` once.
@example
```
import onetime from 'onetime';
let index = 0;
const foo = onetime(() => ++index);
foo(); //=> 1
foo(); //=> 1
foo(); //=> 1
onetime.callCount(foo); //=> 3
```
*/
<ArgumentsType extends unknown[], ReturnType>(
fn: (...arguments_: ArgumentsType) => ReturnType,
options?: Options
): (...arguments_: ArgumentsType) => ReturnType;
/**
Get the number of times `fn` has been called.
@param fn - The function to get call count from.
@returns A number representing how many times `fn` has been called.
@example
```
import onetime from 'onetime';
const foo = onetime(() => {});
foo();
foo();
foo();
console.log(onetime.callCount(foo));
//=> 3
```
*/
callCount(fn: (...arguments_: any[]) => unknown): number;
};
export default onetime;

41
node_modules/log-update/node_modules/onetime/index.js generated vendored Normal file
View file

@ -0,0 +1,41 @@
import mimicFunction from 'mimic-function';
const calledFunctions = new WeakMap();
const onetime = (function_, options = {}) => {
if (typeof function_ !== 'function') {
throw new TypeError('Expected a function');
}
let returnValue;
let callCount = 0;
const functionName = function_.displayName || function_.name || '<anonymous>';
const onetime = function (...arguments_) {
calledFunctions.set(onetime, ++callCount);
if (callCount === 1) {
returnValue = function_.apply(this, arguments_);
function_ = undefined;
} else if (options.throw === true) {
throw new Error(`Function \`${functionName}\` can only be called once`);
}
return returnValue;
};
mimicFunction(onetime, function_);
calledFunctions.set(onetime, callCount);
return onetime;
};
onetime.callCount = function_ => {
if (!calledFunctions.has(function_)) {
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
}
return calledFunctions.get(function_);
};
export default onetime;

9
node_modules/log-update/node_modules/onetime/license generated vendored Normal file
View 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.

View file

@ -0,0 +1,49 @@
{
"name": "onetime",
"version": "7.0.0",
"description": "Ensure a function is only called once",
"license": "MIT",
"repository": "sindresorhus/onetime",
"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"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"once",
"function",
"one",
"onetime",
"func",
"fn",
"single",
"call",
"called",
"prevent"
],
"dependencies": {
"mimic-function": "^5.0.0"
},
"devDependencies": {
"ava": "^5.3.1",
"tsd": "^0.29.0",
"xo": "^0.56.0"
}
}

88
node_modules/log-update/node_modules/onetime/readme.md generated vendored Normal file
View file

@ -0,0 +1,88 @@
# onetime
> Ensure a function is only called once
When called multiple times it will return the return value from the first call.
*Unlike the module [once](https://github.com/isaacs/once), this one isn't naughty and extending `Function.prototype`.*
## Install
```sh
npm install onetime
```
## Usage
```js
import onetime from 'onetime';
let index = 0;
const foo = onetime(() => ++index);
foo(); //=> 1
foo(); //=> 1
foo(); //=> 1
onetime.callCount(foo); //=> 3
```
```js
import onetime from 'onetime';
const foo = onetime(() => {}, {throw: true});
foo();
foo();
//=> Error: Function `foo` can only be called once
```
## API
### onetime(fn, options?)
Returns a function that only calls `fn` once.
#### fn
Type: `Function`
The function that should only be called once.
#### options
Type: `object`
##### throw
Type: `boolean`\
Default: `false`
Throw an error when called more than once.
### onetime.callCount(fn)
Returns a number representing how many times `fn` has been called.
Note: It throws an error if you pass in a function that is not wrapped by `onetime`.
```js
import onetime from 'onetime';
const foo = onetime(() => {});
foo();
foo();
foo();
console.log(onetime.callCount(foo));
//=> 3
```
#### fn
Type: `Function`
The function to get call count from.

View file

@ -0,0 +1,15 @@
/**
Gracefully restore the CLI cursor on exit.
Prevent the cursor you have hidden interactively from remaining hidden if the process crashes.
It does nothing if run in a non-TTY context.
@example
```
import restoreCursor from 'restore-cursor';
restoreCursor();
```
*/
export default function restoreCursor(): void;

View file

@ -0,0 +1,15 @@
import process from 'node:process';
import onetime from 'onetime';
import {onExit} from 'signal-exit';
const terminal = process.stderr.isTTY
? process.stderr
: (process.stdout.isTTY ? process.stdout : undefined);
const restoreCursor = terminal ? onetime(() => {
onExit(() => {
terminal.write('\u001B[?25h');
}, {alwaysLast: true});
}) : () => {};
export default restoreCursor;

View 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.

View file

@ -0,0 +1,57 @@
{
"name": "restore-cursor",
"version": "5.1.0",
"description": "Gracefully restore the CLI cursor on exit",
"license": "MIT",
"repository": "sindresorhus/restore-cursor",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"types": "./index.d.ts",
"sideEffects": false,
"engines": {
"node": ">=18"
},
"scripts": {
"test": "xo && tsd && node --test"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"exit",
"quit",
"process",
"graceful",
"shutdown",
"sigterm",
"sigint",
"terminate",
"kill",
"stop",
"cli",
"cursor",
"ansi",
"show",
"term",
"terminal",
"console",
"tty",
"shell",
"command-line"
],
"dependencies": {
"onetime": "^7.0.0",
"signal-exit": "^4.1.0"
},
"devDependencies": {
"tsd": "^0.31.1",
"xo": "^0.59.2"
}
}

View file

@ -0,0 +1,21 @@
# restore-cursor
> Gracefully restore the CLI cursor on exit
Prevent the cursor you have hidden interactively from remaining hidden if the process crashes.
It does nothing if run in a non-TTY context.
## Install
```sh
npm install restore-cursor
```
## Usage
```js
import restoreCursor from 'restore-cursor';
restoreCursor();
```

View file

@ -0,0 +1,19 @@
/**
Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
@param string - A string with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
@param startSlice - Zero-based index at which to start the slice.
@param endSlice - Zero-based index at which to end the slice.
@example
```
import chalk from 'chalk';
import sliceAnsi from 'slice-ansi';
const string = 'The quick brown ' + chalk.red('fox jumped over ') +
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
console.log(sliceAnsi(string, 20, 30));
```
*/
export default function sliceAnsi(string: string, startSlice: number, endSlice?: number): string;

167
node_modules/log-update/node_modules/slice-ansi/index.js generated vendored Executable file
View file

@ -0,0 +1,167 @@
import ansiStyles from 'ansi-styles';
import isFullwidthCodePoint from 'is-fullwidth-code-point';
// \x1b and \x9b
const ESCAPES = new Set([27, 155]);
const CODE_POINT_0 = '0'.codePointAt(0);
const CODE_POINT_9 = '9'.codePointAt(0);
const endCodesSet = new Set();
const endCodesMap = new Map();
for (const [start, end] of ansiStyles.codes) {
endCodesSet.add(ansiStyles.color.ansi(end));
endCodesMap.set(ansiStyles.color.ansi(start), ansiStyles.color.ansi(end));
}
function getEndCode(code) {
if (endCodesSet.has(code)) {
return code;
}
if (endCodesMap.has(code)) {
return endCodesMap.get(code);
}
code = code.slice(2);
if (code.includes(';')) {
code = code[0] + '0';
}
const returnValue = ansiStyles.codes.get(Number.parseInt(code, 10));
if (returnValue) {
return ansiStyles.color.ansi(returnValue);
}
return ansiStyles.reset.open;
}
function findNumberIndex(string) {
for (let index = 0; index < string.length; index++) {
const codePoint = string.codePointAt(index);
if (codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9) {
return index;
}
}
return -1;
}
function parseAnsiCode(string, offset) {
string = string.slice(offset, offset + 19);
const startIndex = findNumberIndex(string);
if (startIndex !== -1) {
let endIndex = string.indexOf('m', startIndex);
if (endIndex === -1) {
endIndex = string.length;
}
return string.slice(0, endIndex + 1);
}
}
function tokenize(string, endCharacter = Number.POSITIVE_INFINITY) {
const returnValue = [];
let index = 0;
let visibleCount = 0;
while (index < string.length) {
const codePoint = string.codePointAt(index);
if (ESCAPES.has(codePoint)) {
const code = parseAnsiCode(string, index);
if (code) {
returnValue.push({
type: 'ansi',
code,
endCode: getEndCode(code),
});
index += code.length;
continue;
}
}
const isFullWidth = isFullwidthCodePoint(codePoint);
const character = String.fromCodePoint(codePoint);
returnValue.push({
type: 'character',
value: character,
isFullWidth,
});
index += character.length;
visibleCount += isFullWidth ? 2 : character.length;
if (visibleCount >= endCharacter) {
break;
}
}
return returnValue;
}
function reduceAnsiCodes(codes) {
let returnValue = [];
for (const code of codes) {
if (code.code === ansiStyles.reset.open) {
// Reset code, disable all codes
returnValue = [];
} else if (endCodesSet.has(code.code)) {
// This is an end code, disable all matching start codes
returnValue = returnValue.filter(returnValueCode => returnValueCode.endCode !== code.code);
} else {
// This is a start code. Disable all styles this "overrides", then enable it
returnValue = returnValue.filter(returnValueCode => returnValueCode.endCode !== code.endCode);
returnValue.push(code);
}
}
return returnValue;
}
function undoAnsiCodes(codes) {
const reduced = reduceAnsiCodes(codes);
const endCodes = reduced.map(({endCode}) => endCode);
return endCodes.reverse().join('');
}
export default function sliceAnsi(string, start, end) {
const tokens = tokenize(string, end);
let activeCodes = [];
let position = 0;
let returnValue = '';
let include = false;
for (const token of tokens) {
if (end !== undefined && position >= end) {
break;
}
if (token.type === 'ansi') {
activeCodes.push(token);
if (include) {
returnValue += token.code;
}
} else {
// Character
if (!include && position >= start) {
include = true;
// Simplify active codes
activeCodes = reduceAnsiCodes(activeCodes);
returnValue = activeCodes.map(({code}) => code).join('');
}
if (include) {
returnValue += token.value;
}
position += token.isFullWidth ? 2 : token.value.length;
}
}
// Disable active codes at the end
returnValue += undoAnsiCodes(activeCodes);
return returnValue;
}

View file

@ -0,0 +1,10 @@
MIT License
Copyright (c) DC <threedeecee@gmail.com>
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.

View file

@ -0,0 +1,57 @@
{
"name": "slice-ansi",
"version": "7.1.0",
"description": "Slice a string with ANSI escape codes",
"license": "MIT",
"repository": "chalk/slice-ansi",
"funding": "https://github.com/chalk/slice-ansi?sponsor=1",
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"engines": {
"node": ">=18"
},
"scripts": {
"test": "xo && ava && tsc index.d.ts"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"slice",
"string",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^6.2.1",
"is-fullwidth-code-point": "^5.0.0"
},
"devDependencies": {
"ava": "^5.3.1",
"chalk": "^5.3.0",
"random-item": "^4.0.1",
"strip-ansi": "^7.1.0",
"xo": "^0.56.0"
}
}

View file

@ -0,0 +1,54 @@
# slice-ansi [![XO: Linted](https://img.shields.io/badge/xo-linted-blue.svg)](https://github.com/xojs/xo)
> Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
## Install
```sh
npm install slice-ansi
```
## Usage
```js
import chalk from 'chalk';
import sliceAnsi from 'slice-ansi';
const string = 'The quick brown ' + chalk.red('fox jumped over ') +
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
console.log(sliceAnsi(string, 20, 30));
```
## API
### sliceAnsi(string, startSlice, endSlice?)
#### string
Type: `string`
String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
#### startSlice
Type: `number`
Zero-based index at which to start the slice.
#### endSlice
Type: `number`
Zero-based index at which to end the slice.
## Related
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)

View 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;

View file

@ -0,0 +1,82 @@
import stripAnsi from 'strip-ansi';
import {eastAsianWidth} from 'get-east-asian-width';
import emojiRegex from 'emoji-regex';
const segmenter = new Intl.Segmenter();
const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
export default function stringWidth(string, options = {}) {
if (typeof string !== 'string' || string.length === 0) {
return 0;
}
const {
ambiguousIsNarrow = true,
countAnsiEscapeCodes = false,
} = options;
if (!countAnsiEscapeCodes) {
string = stripAnsi(string);
}
if (string.length === 0) {
return 0;
}
let width = 0;
const eastAsianWidthOptions = {ambiguousAsWide: !ambiguousIsNarrow};
for (const {segment: character} of segmenter.segment(string)) {
const codePoint = character.codePointAt(0);
// Ignore control characters
if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
continue;
}
// Ignore zero-width characters
if (
(codePoint >= 0x20_0B && codePoint <= 0x20_0F) // Zero-width space, non-joiner, joiner, left-to-right mark, right-to-left mark
|| codePoint === 0xFE_FF // Zero-width no-break space
) {
continue;
}
// Ignore combining characters
if (
(codePoint >= 0x3_00 && codePoint <= 0x3_6F) // Combining diacritical marks
|| (codePoint >= 0x1A_B0 && codePoint <= 0x1A_FF) // Combining diacritical marks extended
|| (codePoint >= 0x1D_C0 && codePoint <= 0x1D_FF) // Combining diacritical marks supplement
|| (codePoint >= 0x20_D0 && codePoint <= 0x20_FF) // Combining diacritical marks for symbols
|| (codePoint >= 0xFE_20 && codePoint <= 0xFE_2F) // Combining half marks
) {
continue;
}
// Ignore surrogate pairs
if (codePoint >= 0xD8_00 && codePoint <= 0xDF_FF) {
continue;
}
// Ignore variation selectors
if (codePoint >= 0xFE_00 && codePoint <= 0xFE_0F) {
continue;
}
// This covers some of the above cases, but we still keep them for performance reasons.
if (defaultIgnorableCodePointRegex.test(character)) {
continue;
}
// TODO: Use `/\p{RGI_Emoji}/v` when targeting Node.js 20.
if (emojiRegex().test(character)) {
width += 2;
continue;
}
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
}
return width;
}

View 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.

View file

@ -0,0 +1,64 @@
{
"name": "string-width",
"version": "7.2.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": ">=18"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"string",
"character",
"unicode",
"width",
"visual",
"column",
"columns",
"fullwidth",
"full-width",
"full",
"ansi",
"escape",
"codes",
"cli",
"command-line",
"terminal",
"console",
"cjk",
"chinese",
"japanese",
"korean",
"fixed-width",
"east-asian-width"
],
"dependencies": {
"emoji-regex": "^10.3.0",
"get-east-asian-width": "^1.0.0",
"strip-ansi": "^7.1.0"
},
"devDependencies": {
"ava": "^5.3.1",
"tsd": "^0.29.0",
"xo": "^0.56.0"
}
}

View 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

View file

@ -0,0 +1,15 @@
/**
Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string.
@example
```
import stripAnsi from 'strip-ansi';
stripAnsi('\u001B[4mUnicorn\u001B[0m');
//=> 'Unicorn'
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
//=> 'Click'
```
*/
export default function stripAnsi(string: string): string;

View file

@ -0,0 +1,14 @@
import ansiRegex from 'ansi-regex';
const regex = ansiRegex();
export default function stripAnsi(string) {
if (typeof string !== 'string') {
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
}
// Even though the regex is global, we don't need to reset the `.lastIndex`
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
// and doing it manually has a performance penalty.
return string.replace(regex, '');
}

View 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.

View file

@ -0,0 +1,57 @@
{
"name": "strip-ansi",
"version": "7.1.0",
"description": "Strip ANSI escape codes from a string",
"license": "MIT",
"repository": "chalk/strip-ansi",
"funding": "https://github.com/chalk/strip-ansi?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"strip",
"trim",
"remove",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-regex": "^6.0.1"
},
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.44.0"
}
}

View file

@ -0,0 +1,41 @@
# strip-ansi
> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string
## Install
```
$ npm install strip-ansi
```
## Usage
```js
import stripAnsi from 'strip-ansi';
stripAnsi('\u001B[4mUnicorn\u001B[0m');
//=> 'Unicorn'
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
//=> 'Click'
```
## strip-ansi for enterprise
Available as part of the Tidelift Subscription.
The maintainers of strip-ansi and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-strip-ansi?utm_source=npm-strip-ansi&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Related
- [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module
- [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
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)

View file

@ -0,0 +1,41 @@
export type Options = {
/**
By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
@default false
*/
readonly hard?: boolean;
/**
By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
@default true
*/
readonly wordWrap?: boolean;
/**
Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
@default true
*/
readonly trim?: boolean;
};
/**
Wrap words to the specified column width.
@param string - A string with ANSI escape codes, like one styled by [`chalk`](https://github.com/chalk/chalk). Newline characters will be normalized to `\n`.
@param columns - The number of columns to wrap the text to.
@example
```
import chalk from 'chalk';
import wrapAnsi from 'wrap-ansi';
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
console.log(wrapAnsi(input, 20));
```
*/
export default function wrapAnsi(string: string, columns: number, options?: Options): string;

222
node_modules/log-update/node_modules/wrap-ansi/index.js generated vendored Executable file
View file

@ -0,0 +1,222 @@
import stringWidth from 'string-width';
import stripAnsi from 'strip-ansi';
import ansiStyles from 'ansi-styles';
const ESCAPES = new Set([
'\u001B',
'\u009B',
]);
const END_CODE = 39;
const ANSI_ESCAPE_BELL = '\u0007';
const ANSI_CSI = '[';
const ANSI_OSC = ']';
const ANSI_SGR_TERMINATOR = 'm';
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
const wrapAnsiCode = code => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
const wrapAnsiHyperlink = url => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
// Calculate the length of words split on ' ', ignoring
// the extra characters added by ansi escape codes
const wordLengths = string => string.split(' ').map(character => stringWidth(character));
// Wrap a long word across multiple rows
// Ansi escape codes do not count towards length
const wrapWord = (rows, word, columns) => {
const characters = [...word];
let isInsideEscape = false;
let isInsideLinkEscape = false;
let visible = stringWidth(stripAnsi(rows.at(-1)));
for (const [index, character] of characters.entries()) {
const characterLength = stringWidth(character);
if (visible + characterLength <= columns) {
rows[rows.length - 1] += character;
} else {
rows.push(character);
visible = 0;
}
if (ESCAPES.has(character)) {
isInsideEscape = true;
const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join('');
isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
}
if (isInsideEscape) {
if (isInsideLinkEscape) {
if (character === ANSI_ESCAPE_BELL) {
isInsideEscape = false;
isInsideLinkEscape = false;
}
} else if (character === ANSI_SGR_TERMINATOR) {
isInsideEscape = false;
}
continue;
}
visible += characterLength;
if (visible === columns && index < characters.length - 1) {
rows.push('');
visible = 0;
}
}
// It's possible that the last row we copy over is only
// ansi escape characters, handle this edge-case
if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
rows[rows.length - 2] += rows.pop();
}
};
// Trims spaces from a string ignoring invisible sequences
const stringVisibleTrimSpacesRight = string => {
const words = string.split(' ');
let last = words.length;
while (last > 0) {
if (stringWidth(words[last - 1]) > 0) {
break;
}
last--;
}
if (last === words.length) {
return string;
}
return words.slice(0, last).join(' ') + words.slice(last).join('');
};
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode.
//
// 'hard' will never allow a string to take up more than columns characters.
//
// 'soft' allows long words to expand past the column length.
const exec = (string, columns, options = {}) => {
if (options.trim !== false && string.trim() === '') {
return '';
}
let returnValue = '';
let escapeCode;
let escapeUrl;
const lengths = wordLengths(string);
let rows = [''];
for (const [index, word] of string.split(' ').entries()) {
if (options.trim !== false) {
rows[rows.length - 1] = rows.at(-1).trimStart();
}
let rowLength = stringWidth(rows.at(-1));
if (index !== 0) {
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
// If we start with a new word but the current row length equals the length of the columns, add a new row
rows.push('');
rowLength = 0;
}
if (rowLength > 0 || options.trim === false) {
rows[rows.length - 1] += ' ';
rowLength++;
}
}
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
if (options.hard && lengths[index] > columns) {
const remainingColumns = (columns - rowLength);
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
if (breaksStartingNextLine < breaksStartingThisLine) {
rows.push('');
}
wrapWord(rows, word, columns);
continue;
}
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
if (options.wordWrap === false && rowLength < columns) {
wrapWord(rows, word, columns);
continue;
}
rows.push('');
}
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
wrapWord(rows, word, columns);
continue;
}
rows[rows.length - 1] += word;
}
if (options.trim !== false) {
rows = rows.map(row => stringVisibleTrimSpacesRight(row));
}
const preString = rows.join('\n');
const pre = [...preString];
// We need to keep a separate index as `String#slice()` works on Unicode code units, while `pre` is an array of codepoints.
let preStringIndex = 0;
for (const [index, character] of pre.entries()) {
returnValue += character;
if (ESCAPES.has(character)) {
const {groups} = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || {groups: {}};
if (groups.code !== undefined) {
const code = Number.parseFloat(groups.code);
escapeCode = code === END_CODE ? undefined : code;
} else if (groups.uri !== undefined) {
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
}
}
const code = ansiStyles.codes.get(Number(escapeCode));
if (pre[index + 1] === '\n') {
if (escapeUrl) {
returnValue += wrapAnsiHyperlink('');
}
if (escapeCode && code) {
returnValue += wrapAnsiCode(code);
}
} else if (character === '\n') {
if (escapeCode && code) {
returnValue += wrapAnsiCode(escapeCode);
}
if (escapeUrl) {
returnValue += wrapAnsiHyperlink(escapeUrl);
}
}
preStringIndex += character.length;
}
return returnValue;
};
// For each newline, invoke the method separately
export default function wrapAnsi(string, columns, options) {
return String(string)
.normalize()
.replaceAll('\r\n', '\n')
.split('\n')
.map(line => exec(line, columns, options))
.join('\n');
}

View 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.

View file

@ -0,0 +1,69 @@
{
"name": "wrap-ansi",
"version": "9.0.0",
"description": "Wordwrap a string with ANSI escape codes",
"license": "MIT",
"repository": "chalk/wrap-ansi",
"funding": "https://github.com/chalk/wrap-ansi?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"engines": {
"node": ">=18"
},
"scripts": {
"test": "xo && nyc ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"wrap",
"break",
"wordwrap",
"wordbreak",
"linewrap",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^6.2.1",
"string-width": "^7.0.0",
"strip-ansi": "^7.1.0"
},
"devDependencies": {
"ava": "^5.3.1",
"chalk": "^5.3.0",
"coveralls": "^3.1.1",
"has-ansi": "^5.0.1",
"nyc": "^15.1.0",
"tsd": "^0.29.0",
"xo": "^0.56.0"
}
}

View file

@ -0,0 +1,75 @@
# wrap-ansi
> Wordwrap a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
## Install
```sh
npm install wrap-ansi
```
## Usage
```js
import chalk from 'chalk';
import wrapAnsi from 'wrap-ansi';
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
console.log(wrapAnsi(input, 20));
```
<img width="331" src="screenshot.png">
## API
### wrapAnsi(string, columns, options?)
Wrap words to the specified column width.
#### string
Type: `string`
A string with ANSI escape codes, like one styled by [`chalk`](https://github.com/chalk/chalk).
Newline characters will be normalized to `\n`.
#### columns
Type: `number`
The number of columns to wrap the text to.
#### options
Type: `object`
##### hard
Type: `boolean`\
Default: `false`
By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
##### wordWrap
Type: `boolean`\
Default: `true`
By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
##### trim
Type: `boolean`\
Default: `true`
Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
## Related
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures.

67
node_modules/log-update/package.json generated vendored Normal file
View file

@ -0,0 +1,67 @@
{
"name": "log-update",
"version": "6.1.0",
"description": "Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.",
"license": "MIT",
"repository": "sindresorhus/log-update",
"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"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"log",
"logger",
"logging",
"cli",
"terminal",
"term",
"console",
"shell",
"update",
"refresh",
"overwrite",
"output",
"stdout",
"progress",
"bar",
"animation"
],
"dependencies": {
"ansi-escapes": "^7.0.0",
"cli-cursor": "^5.0.0",
"slice-ansi": "^7.1.0",
"strip-ansi": "^7.1.0",
"wrap-ansi": "^9.0.0"
},
"devDependencies": {
"@types/node": "^20.14.12",
"ava": "^6.1.3",
"terminal.js": "^1.0.11",
"tsd": "^0.31.1",
"wcwidth": "^1.0.1",
"xo": "^0.59.2"
},
"xo": {
"rules": {
"@typescript-eslint/no-unsafe-argument": "off"
}
}
}

86
node_modules/log-update/readme.md generated vendored Normal file
View file

@ -0,0 +1,86 @@
# log-update
> Log by overwriting the previous output in the terminal.\
> Useful for rendering progress bars, animations, etc.
![](screenshot.gif)
## Install
```sh
npm install log-update
```
## Usage
```js
import logUpdate from 'log-update';
const frames = ['-', '\\', '|', '/'];
let index = 0;
setInterval(() => {
const frame = frames[index = ++index % frames.length];
logUpdate(
`
♥♥
${frame} unicorns ${frame}
♥♥
`
);
}, 80);
```
## API
### logUpdate(text…)
Log to stdout.
### logUpdate.clear()
Clear the logged output.
### logUpdate.done()
Persist the logged output.
Useful if you want to start a new log session below the current one.
### logUpdateStderr(text…)
Log to stderr.
### logUpdateStderr.clear()
### logUpdateStderr.done()
### createLogUpdate(stream, options?)
Get a `logUpdate` method that logs to the specified stream.
#### options
Type: `object`
##### showCursor
Type: `boolean`\
Default: `false`
Show the cursor. This can be useful when a CLI accepts input from a user.
```js
import {createLogUpdate} from 'log-update';
// Write output but don't hide the cursor
const log = createLogUpdate(process.stdout, {
showCursor: true
});
```
## Examples
- [listr](https://github.com/SamVerschueren/listr) - Uses this module to render an interactive task list
- [ora](https://github.com/sindresorhus/ora) - Uses this module to render awesome spinners
- [speed-test](https://github.com/sindresorhus/speed-test) - Uses this module to render a [spinner](https://github.com/sindresorhus/elegant-spinner)