New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-cli-loader

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cli-loader - npm Package Compare versions

Comparing version
1.1.1
to
1.1.2
+13
dist/index.min.js
"use strict";var __importDefault=(this&&this.__importDefault)||function(mod){return(mod&&mod.__esModule)?mod:{"default":mod};};Object.defineProperty(exports,"__esModule",{value:true});const kleur_1=require("kleur");const log_update_1=__importDefault(require("./resources/log-update"));const spinners_json_1=__importDefault(require("./spinners.json"));const sringIcons={main:{tick:'✔',cross:'✖',},win:{tick:'√',cross:'×',}};const icons=process.platform==='win32'?sringIcons.win:sringIcons.main;class Loader{static appLoaders=new Set();timer=null;logUpdate;doneMessage=undefined;loaderMessage=undefined;renderSpinner(spinner,index,description){const{frames}=spinner;const message=`${description}...`;this.logUpdate=(0,log_update_1.default)(frames[(index=++index%frames.length)]+' '+`${message}`);this.loaderMessage=message;return index;}
stopLastLoader(){const lastSpinner=Array.from(Loader.appLoaders).pop();lastSpinner?.done();}
start(description='',spinname,doneMessage){this.stopLastLoader();const name=spinname??'dots';const spinner=spinners_json_1.default[name];let index=0;index=this.renderSpinner(spinner,index,description);this.timer=setInterval(()=>{index=this.renderSpinner(spinner,index,description);},spinner.interval);if(doneMessage){this.doneMessage=doneMessage;}
Loader.appLoaders.add(this);return this;}
finishLoader(loaderDone=true){if(this.logUpdate){const finalMessage=this.doneMessage&&loaderDone?this.doneMessage:this.loaderMessage;const icon=loaderDone?(0,kleur_1.green)(icons.tick):(0,kleur_1.red)(icons.cross);this.logUpdate=(0,log_update_1.default)(icon+' '+finalMessage);this.logUpdate?.done();}
if(this.timer){clearInterval(this.timer);this.timer=null;}
Loader.appLoaders.delete(this);}
done(){this.finishLoader();}
stop(){this.finishLoader(false);}
static stopAll(){Loader.appLoaders.forEach((spinner)=>{spinner.done();});}
static interrupt(){Loader.appLoaders.forEach((spinner)=>{spinner.stop();});}
static create(description='',options){return new Loader().start(description,options?.spinname,options?.doneMessage);}}
exports.default=Loader;
+2
-1
{
"name": "node-cli-loader",
"version": "1.1.1",
"version": "1.1.2",
"description": "Plugin to create animated loaders in the terminal",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"engines": {

@@ -7,0 +8,0 @@ "node": ">= 18.20.3",

import { green, red } from 'kleur';
import logUpdate, { LogUpdateRender } from './resources/log-update';
import { Spinner, Spinners } from './types';
import spinners from './spinners.json';
const sringIcons = {
main: {
tick: '✔',
cross: '✖',
},
win: {
tick: '√',
cross: '×',
}
};
const icons = process.platform === 'win32' ? sringIcons.win : sringIcons.main;
export default class Loader {
private static appLoaders: Set<Loader> = new Set();
private timer: NodeJS.Timeout | null = null;
private logUpdate: LogUpdateRender | undefined;
private doneMessage: string | undefined = undefined;
private loaderMessage: string | undefined = undefined;
/**
* Renders the spinner
* @param spinner The spinner to render
* @param index Variable to control the frames iteration
* @param description The description to show next to the spinner
*/
private renderSpinner(spinner: Spinner, index: number, description: string) {
const { frames } = spinner;
const message = `${description}...`;
this.logUpdate = logUpdate(frames[(index = ++index % frames.length)] + ' ' +`${message}`);
this.loaderMessage = message;
return index;
}
/**
* Stops last loader in the list of loaders
*/
private stopLastLoader(){
const lastSpinner = Array.from(Loader.appLoaders).pop();
lastSpinner?.done();
}
/**
* Starts loader with a spinner and a description
* @param [description] The description to show next to the spinner
* @param [spinname] Spinner name
* @param [doneMessage] The message to show when the loader is done
*/
private start(description: string = '', spinname?: Spinners, doneMessage?: string): Loader {
this.stopLastLoader();
const name = spinname ?? 'dots';
const spinner = spinners[name];
let index = 0;
index = this.renderSpinner(spinner, index, description);
this.timer = setInterval(() => {
index = this.renderSpinner(spinner, index, description);
}, spinner.interval);
if (doneMessage) {
this.doneMessage = doneMessage;
}
Loader.appLoaders.add(this);
return this;
}
private finishLoader(loaderDone: boolean = true) {
if (this.logUpdate) {
const finalMessage = this.doneMessage && loaderDone ? this.doneMessage : this.loaderMessage;
const icon = loaderDone ? green(icons.tick) : red(icons.cross);
this.logUpdate = logUpdate(icon + ' ' + finalMessage);
this.logUpdate?.done();
}
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
Loader.appLoaders.delete(this);
}
/**
* Persist the loader and mark it as done
*/
private done() {
this.finishLoader();
}
/**
* Persist the loader and marks it as failed
*/
private stop(){
this.finishLoader(false);
}
/**
* Stops all pending loaders that are not set to stayLoading
*/
public static stopAll() {
Loader.appLoaders.forEach((spinner) => {
spinner.done();
});
}
/**
* Interrupts all pending loaders marking as failed
*/
public static interrupt(){
Loader.appLoaders.forEach((spinner) => {
spinner.stop();
});
}
/**
* Creates a new loader and adds it to the list of loaders
* @param description The description to show next to the spinner
* @param [options] Options for the loader
* @param [options].[spinname] The name of the spinner to use
* @param [options].[doneMessage] The message to show when the loader is done
*/
public static create(
description: string = '',
options?: { spinname?: Spinners, doneMessage?: string }
) {
return new Loader().start(description, options?.spinname, options?.doneMessage);
}
}
import process from 'node:process';
export const isBrowser = globalThis.window?.document !== undefined;
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';
type CwdFunction = () => string;
const cwdFunction: CwdFunction = isBrowser ? () => {
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
} : process.cwd;
export const cursorTo = (x: number, y?: number): string => {
if (typeof x !== 'number') {
throw new TypeError('The `x` argument is required');
}
return ESC + (y ? (y + 1) + SEP + (x + 1) + 'H' : (x + 1) + 'G');
};
export const cursorMove = (x: number, y?: number): string => {
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 !== undefined) {
if (y < 0) {
returnValue += ESC + (-y) + 'A';
} else if (y > 0) {
returnValue += ESC + y + 'B';
}
}
return returnValue;
};
export const cursorUp = (count = 1): string => ESC + count + 'A';
export const cursorDown = (count = 1): string => ESC + count + 'B';
export const cursorForward = (count = 1): string => ESC + count + 'C';
export const cursorBackward = (count = 1): string => 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: number): string => {
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
? '<span class="math-inline">{eraseScreen}</span>{ESC}0f'
: `<span class="math-inline">{eraseScreen}</span>{ESC}3J${ESC}H`;
export const enterAlternativeScreen = ESC + '?1049h';
export const exitAlternativeScreen = ESC + '?1049l';
export const beep = BEL;
export const link = (text: string, url: string): string => [
OSC,
'8',
SEP,
SEP,
url,
BEL,
text,
OSC,
'8',
SEP,
SEP,
BEL,
].join('');
export const image = (data: string | Buffer, options: { width?: number, height?: number, preserveAspectRatio?: boolean} = {}): string => {
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: string = cwdFunction()): string => `${OSC}50;CurrentDir=${cwd}${BEL}`,
annotation(message: string, options: { x?: number, y?: number, isHidden?: boolean } = {}): string {
let returnValue = `${OSC}1337;`;
const hasX = options.x !== undefined;
const hasY = options.y !== undefined;
if ((hasX || hasY) && !(hasX && hasY && Object.keys(options).length !== undefined)) {
throw new Error('`x`, `y` and `length` must be defined when `x` or `y` is defined');
}
message = message.replace('|', '');
returnValue += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation=';
if (Object.keys(options).length > 0) {
returnValue += (
hasX
? [message, Object.keys(options).length, options.x, options.y]
: [Object.keys(options).length, message]
).join('|');
} else {
returnValue += message;
}
return returnValue + BEL;
},
};
export default function ansiRegex({onlyFirst = false} = {}) {
const pattern = [
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
].join('|');
return new RegExp(pattern, onlyFirst ? undefined : 'g');
}
const ANSI_BACKGROUND_OFFSET = 10;
const wrapAnsi16 =
(offset = 0) =>
(code: number): string =>
`\u001B[${code + offset}m`;
const wrapAnsi256 =
(offset = 0) =>
(code: number): string =>
`\u001B[${38 + offset};5;${code}m`;
const wrapAnsi16m =
(offset = 0) =>
(red: number, green: number, blue: number): string =>
`\u001B[${38 + offset};2;${red};${green};${blue}m`;
interface AnsiStyleCode {
[key: string]: number[];
}
interface AnsiOpenClose {
open: string;
close: string;
}
interface AnsiStyles {
modifier: AnsiStyleCode | AnsiOpenClose;
color: {
black: number[];
red: number[];
green: number[];
yellow: number[];
blue: number[];
magenta: number[];
cyan: number[];
white: number[];
blackBright: number[];
gray: number[];
grey: number[];
redBright: number[];
greenBright: number[];
yellowBright: number[];
blueBright: number[];
magentaBright: number[];
cyanBright: number[];
whiteBright: number[];
open: string;
close: string;
ansi: (code: number) => string;
ansi256: (code: number) => string;
ansi16m: (red: number, green: number, blue: number) => string;
};
bgColor: {
bgBlack: number[];
bgRed: number[];
bgGreen: number[];
bgYellow: number[];
bgBlue: number[];
bgMagenta: number[];
bgCyan: number[];
bgWhite: number[];
bgBlackBright: number[];
bgGray: number[];
bgGrey: number[];
bgRedBright: number[];
bgGreenBright: number[];
bgYellowBright: number[];
bgBlueBright: number[];
bgMagentaBright: number[];
bgCyanBright: number[];
bgWhiteBright: number[];
open: string;
close: string;
ansi: (code: number) => string;
ansi256: (code: number) => string;
ansi16m: (red: number, green: number, blue: number) => string;
};
rgbToAnsi256: (...args: number[]) => number;
hexToRgb: (hex: number) => number[];
ansi256ToAnsi: (code: number) => number;
hexToAnsi256: (hex: number) => number;
codes: Map<number, number>;
reset: {
open: string;
close: string;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
}
const styles: AnsiStyles = {
modifier: {
reset: [0, 0],
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],
blackBright: [90, 39],
gray: [90, 39],
grey: [90, 39],
redBright: [91, 39],
greenBright: [92, 39],
yellowBright: [93, 39],
blueBright: [94, 39],
magentaBright: [95, 39],
cyanBright: [96, 39],
whiteBright: [97, 39],
open: '\u001B[38;2;',
close: '\u001B[39m',
ansi: wrapAnsi16(),
ansi256: wrapAnsi256(),
ansi16m: wrapAnsi16m(),
},
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],
bgBlackBright: [100, 49],
bgGray: [100, 49],
bgGrey: [100, 49],
bgRedBright: [101, 49],
bgGreenBright: [102, 49],
bgYellowBright: [103, 49],
bgBlueBright: [104, 49],
bgMagentaBright: [105, 49],
bgCyanBright: [106, 49],
bgWhiteBright: [107, 49],
open: '\u001B[48;2;',
close: '\u001B[49m',
ansi: wrapAnsi16(ANSI_BACKGROUND_OFFSET),
ansi256: wrapAnsi256(ANSI_BACKGROUND_OFFSET),
ansi16m: wrapAnsi16m(ANSI_BACKGROUND_OFFSET),
},
rgbToAnsi256: (): number => 0,
hexToRgb: (): number[] => [],
ansi256ToAnsi: (): number => 0,
hexToAnsi256: (): number => 0,
codes: new Map(),
reset: {
open: '\u001B[0m',
close: '\u001B[0m',
},
};
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<number, number>();
for (const [groupName, group] of Object.entries(styles)) {
for (const [styleName, style] of Object.entries(group)) {
if (styles[styleName]) {
styles[styleName].open = `\u001B[${(style as number[])[0]}m`;
styles[styleName].close = `\u001B[${(style as number[])[1]}m`;
} else {
styles[styleName] = {
open: `\u001B[${(style as number[])[0]}m`,
close: `\u001B[${(style as number[])[1]}m`,
};
}
group[styleName] = styles[styleName as keyof AnsiStyles];
codes.set((style as number[])[0], (style as number[])[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);
Object.defineProperties(styles, {
rgbToAnsi256: {
value: (red: number, green: number, blue: number) => {
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: number) => {
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: number) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
enumerable: false,
},
ansi256ToAnsi: {
value: (code: number): number => {
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: number, green: number, blue: number): number =>
styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
enumerable: false,
},
hexToAnsi: {
value: (hex: number): number =>
styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
enumerable: false,
},
});
return styles;
}
const ansiStyles = assembleStyles();
export default ansiStyles;
import process from 'node:process';
import restoreCursor from './restore-cursor';
interface CliCursorState {
isHidden: boolean;
show(writableStream?: NodeJS.WriteStream): void;
hide(writableStream?: NodeJS.WriteStream): void;
toggle(force?: boolean, writableStream?: NodeJS.WriteStream): void;
}
const cliCursor: CliCursorState = {
isHidden: false,
show: (writableStream = process.stderr): void => {
if (!writableStream.isTTY) {
return;
}
cliCursor.isHidden = false;
writableStream.write('\u001B[?25h');
},
hide: (writableStream = process.stderr): void => {
if (!writableStream.isTTY) {
return;
}
restoreCursor();
cliCursor.isHidden = true;
writableStream.write('\u001B[?25l');
},
toggle: (force?: boolean, writableStream = process.stderr): void => {
if (force !== undefined) {
cliCursor.isHidden = force;
}
if (cliCursor.isHidden) {
cliCursor.show(writableStream);
} else {
cliCursor.hide(writableStream);
}
},
};
export default cliCursor;
export default new RegExp(/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g);
import {isAmbiguous, isFullWidth, isWide} from './lookup.js';
function validate(codePoint: number) {
if (!Number.isSafeInteger(codePoint)) {
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
}
}
export function eastAsianWidth(codePoint: number, {ambiguousAsWide = false} = {}) {
validate(codePoint);
if (
isFullWidth(codePoint)
|| isWide(codePoint)
|| (ambiguousAsWide && isAmbiguous(codePoint))
) {
return 2;
}
return 1;
}
import {eastAsianWidth} from './get-east-asian-width';
export default function isFullwidthCodePoint(codePoint: number) {
if (!Number.isInteger(codePoint)) {
return false;
}
return eastAsianWidth(codePoint) === 2;
}
import process from 'node:process';
import * as 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?: number }) => columns;
const fitToTerminalHeight = (
stream: NodeJS.WriteStream,
text: string
): string => {
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;
};
interface LogUpdateOptions {
showCursor?: boolean;
}
export type LogUpdateRender = {
(...arguments_: string[]): void;
clear(): void;
done(): void;
};
export type LogUpdate = (...args: string[]) => LogUpdateRender;
export function createLogUpdate(stream: NodeJS.WriteStream,options: LogUpdateOptions = {}): LogUpdate {
let previousLineCount = 0;
let previousWidth = getWidth(stream);
let previousOutput = '';
const reset = () => {
previousOutput = '';
previousWidth = getWidth(stream);
previousLineCount = 0;
};
const render = (...arguments_: string[]): LogUpdateRender => {
if (!options.showCursor) {
cliCursor.hide();
}
let output = fitToTerminalHeight(stream, arguments_.join(' ') + '\n');
const width = getWidth(stream);
if (output === previousOutput && previousWidth === width) {
return render;
}
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;
return render;
};
render.message = '';
render.clear = () => {
stream.write(ansiEscapes.eraseLines(previousLineCount));
reset();
};
render.previousOutput = previousOutput;
render.done = () => {
reset();
if (!options.showCursor) {
cliCursor.show();
}
};
return render;
}
const logUpdate = createLogUpdate(process.stdout, { showCursor: false });
export default logUpdate;
export const logUpdateStderr = createLogUpdate(process.stderr);
// Generated code.
function isAmbiguous(x: number) {
return x === 0xA1
|| x === 0xA4
|| x === 0xA7
|| x === 0xA8
|| x === 0xAA
|| x === 0xAD
|| x === 0xAE
|| x >= 0xB0 && x <= 0xB4
|| x >= 0xB6 && x <= 0xBA
|| x >= 0xBC && x <= 0xBF
|| x === 0xC6
|| x === 0xD0
|| x === 0xD7
|| x === 0xD8
|| x >= 0xDE && x <= 0xE1
|| x === 0xE6
|| x >= 0xE8 && x <= 0xEA
|| x === 0xEC
|| x === 0xED
|| x === 0xF0
|| x === 0xF2
|| x === 0xF3
|| x >= 0xF7 && x <= 0xFA
|| x === 0xFC
|| x === 0xFE
|| x === 0x101
|| x === 0x111
|| x === 0x113
|| x === 0x11B
|| x === 0x126
|| x === 0x127
|| x === 0x12B
|| x >= 0x131 && x <= 0x133
|| x === 0x138
|| x >= 0x13F && x <= 0x142
|| x === 0x144
|| x >= 0x148 && x <= 0x14B
|| x === 0x14D
|| x === 0x152
|| x === 0x153
|| x === 0x166
|| x === 0x167
|| x === 0x16B
|| x === 0x1CE
|| x === 0x1D0
|| x === 0x1D2
|| x === 0x1D4
|| x === 0x1D6
|| x === 0x1D8
|| x === 0x1DA
|| x === 0x1DC
|| x === 0x251
|| x === 0x261
|| x === 0x2C4
|| x === 0x2C7
|| x >= 0x2C9 && x <= 0x2CB
|| x === 0x2CD
|| x === 0x2D0
|| x >= 0x2D8 && x <= 0x2DB
|| x === 0x2DD
|| x === 0x2DF
|| x >= 0x300 && x <= 0x36F
|| x >= 0x391 && x <= 0x3A1
|| x >= 0x3A3 && x <= 0x3A9
|| x >= 0x3B1 && x <= 0x3C1
|| x >= 0x3C3 && x <= 0x3C9
|| x === 0x401
|| x >= 0x410 && x <= 0x44F
|| x === 0x451
|| x === 0x2010
|| x >= 0x2013 && x <= 0x2016
|| x === 0x2018
|| x === 0x2019
|| x === 0x201C
|| x === 0x201D
|| x >= 0x2020 && x <= 0x2022
|| x >= 0x2024 && x <= 0x2027
|| x === 0x2030
|| x === 0x2032
|| x === 0x2033
|| x === 0x2035
|| x === 0x203B
|| x === 0x203E
|| x === 0x2074
|| x === 0x207F
|| x >= 0x2081 && x <= 0x2084
|| x === 0x20AC
|| x === 0x2103
|| x === 0x2105
|| x === 0x2109
|| x === 0x2113
|| x === 0x2116
|| x === 0x2121
|| x === 0x2122
|| x === 0x2126
|| x === 0x212B
|| x === 0x2153
|| x === 0x2154
|| x >= 0x215B && x <= 0x215E
|| x >= 0x2160 && x <= 0x216B
|| x >= 0x2170 && x <= 0x2179
|| x === 0x2189
|| x >= 0x2190 && x <= 0x2199
|| x === 0x21B8
|| x === 0x21B9
|| x === 0x21D2
|| x === 0x21D4
|| x === 0x21E7
|| x === 0x2200
|| x === 0x2202
|| x === 0x2203
|| x === 0x2207
|| x === 0x2208
|| x === 0x220B
|| x === 0x220F
|| x === 0x2211
|| x === 0x2215
|| x === 0x221A
|| x >= 0x221D && x <= 0x2220
|| x === 0x2223
|| x === 0x2225
|| x >= 0x2227 && x <= 0x222C
|| x === 0x222E
|| x >= 0x2234 && x <= 0x2237
|| x === 0x223C
|| x === 0x223D
|| x === 0x2248
|| x === 0x224C
|| x === 0x2252
|| x === 0x2260
|| x === 0x2261
|| x >= 0x2264 && x <= 0x2267
|| x === 0x226A
|| x === 0x226B
|| x === 0x226E
|| x === 0x226F
|| x === 0x2282
|| x === 0x2283
|| x === 0x2286
|| x === 0x2287
|| x === 0x2295
|| x === 0x2299
|| x === 0x22A5
|| x === 0x22BF
|| x === 0x2312
|| x >= 0x2460 && x <= 0x24E9
|| x >= 0x24EB && x <= 0x254B
|| x >= 0x2550 && x <= 0x2573
|| x >= 0x2580 && x <= 0x258F
|| x >= 0x2592 && x <= 0x2595
|| x === 0x25A0
|| x === 0x25A1
|| x >= 0x25A3 && x <= 0x25A9
|| x === 0x25B2
|| x === 0x25B3
|| x === 0x25B6
|| x === 0x25B7
|| x === 0x25BC
|| x === 0x25BD
|| x === 0x25C0
|| x === 0x25C1
|| x >= 0x25C6 && x <= 0x25C8
|| x === 0x25CB
|| x >= 0x25CE && x <= 0x25D1
|| x >= 0x25E2 && x <= 0x25E5
|| x === 0x25EF
|| x === 0x2605
|| x === 0x2606
|| x === 0x2609
|| x === 0x260E
|| x === 0x260F
|| x === 0x261C
|| x === 0x261E
|| x === 0x2640
|| x === 0x2642
|| x === 0x2660
|| x === 0x2661
|| x >= 0x2663 && x <= 0x2665
|| x >= 0x2667 && x <= 0x266A
|| x === 0x266C
|| x === 0x266D
|| x === 0x266F
|| x === 0x269E
|| x === 0x269F
|| x === 0x26BF
|| x >= 0x26C6 && x <= 0x26CD
|| x >= 0x26CF && x <= 0x26D3
|| x >= 0x26D5 && x <= 0x26E1
|| x === 0x26E3
|| x === 0x26E8
|| x === 0x26E9
|| x >= 0x26EB && x <= 0x26F1
|| x === 0x26F4
|| x >= 0x26F6 && x <= 0x26F9
|| x === 0x26FB
|| x === 0x26FC
|| x === 0x26FE
|| x === 0x26FF
|| x === 0x273D
|| x >= 0x2776 && x <= 0x277F
|| x >= 0x2B56 && x <= 0x2B59
|| x >= 0x3248 && x <= 0x324F
|| x >= 0xE000 && x <= 0xF8FF
|| x >= 0xFE00 && x <= 0xFE0F
|| x === 0xFFFD
|| x >= 0x1F100 && x <= 0x1F10A
|| x >= 0x1F110 && x <= 0x1F12D
|| x >= 0x1F130 && x <= 0x1F169
|| x >= 0x1F170 && x <= 0x1F18D
|| x === 0x1F18F
|| x === 0x1F190
|| x >= 0x1F19B && x <= 0x1F1AC
|| x >= 0xE0100 && x <= 0xE01EF
|| x >= 0xF0000 && x <= 0xFFFFD
|| x >= 0x100000 && x <= 0x10FFFD;
}
function isFullWidth(x: number) {
return x === 0x3000
|| x >= 0xFF01 && x <= 0xFF60
|| x >= 0xFFE0 && x <= 0xFFE6;
}
function isWide(x: number) {
return x >= 0x1100 && x <= 0x115F
|| x === 0x231A
|| x === 0x231B
|| x === 0x2329
|| x === 0x232A
|| x >= 0x23E9 && x <= 0x23EC
|| x === 0x23F0
|| x === 0x23F3
|| x === 0x25FD
|| x === 0x25FE
|| x === 0x2614
|| x === 0x2615
|| x >= 0x2648 && x <= 0x2653
|| x === 0x267F
|| x === 0x2693
|| x === 0x26A1
|| x === 0x26AA
|| x === 0x26AB
|| x === 0x26BD
|| x === 0x26BE
|| x === 0x26C4
|| x === 0x26C5
|| x === 0x26CE
|| x === 0x26D4
|| x === 0x26EA
|| x === 0x26F2
|| x === 0x26F3
|| x === 0x26F5
|| x === 0x26FA
|| x === 0x26FD
|| x === 0x2705
|| x === 0x270A
|| x === 0x270B
|| x === 0x2728
|| x === 0x274C
|| x === 0x274E
|| x >= 0x2753 && x <= 0x2755
|| x === 0x2757
|| x >= 0x2795 && x <= 0x2797
|| x === 0x27B0
|| x === 0x27BF
|| x === 0x2B1B
|| x === 0x2B1C
|| x === 0x2B50
|| x === 0x2B55
|| x >= 0x2E80 && x <= 0x2E99
|| x >= 0x2E9B && x <= 0x2EF3
|| x >= 0x2F00 && x <= 0x2FD5
|| x >= 0x2FF0 && x <= 0x2FFF
|| x >= 0x3001 && x <= 0x303E
|| x >= 0x3041 && x <= 0x3096
|| x >= 0x3099 && x <= 0x30FF
|| x >= 0x3105 && x <= 0x312F
|| x >= 0x3131 && x <= 0x318E
|| x >= 0x3190 && x <= 0x31E3
|| x >= 0x31EF && x <= 0x321E
|| x >= 0x3220 && x <= 0x3247
|| x >= 0x3250 && x <= 0x4DBF
|| x >= 0x4E00 && x <= 0xA48C
|| x >= 0xA490 && x <= 0xA4C6
|| x >= 0xA960 && x <= 0xA97C
|| x >= 0xAC00 && x <= 0xD7A3
|| x >= 0xF900 && x <= 0xFAFF
|| x >= 0xFE10 && x <= 0xFE19
|| x >= 0xFE30 && x <= 0xFE52
|| x >= 0xFE54 && x <= 0xFE66
|| x >= 0xFE68 && x <= 0xFE6B
|| x >= 0x16FE0 && x <= 0x16FE4
|| x === 0x16FF0
|| x === 0x16FF1
|| x >= 0x17000 && x <= 0x187F7
|| x >= 0x18800 && x <= 0x18CD5
|| x >= 0x18D00 && x <= 0x18D08
|| x >= 0x1AFF0 && x <= 0x1AFF3
|| x >= 0x1AFF5 && x <= 0x1AFFB
|| x === 0x1AFFD
|| x === 0x1AFFE
|| x >= 0x1B000 && x <= 0x1B122
|| x === 0x1B132
|| x >= 0x1B150 && x <= 0x1B152
|| x === 0x1B155
|| x >= 0x1B164 && x <= 0x1B167
|| x >= 0x1B170 && x <= 0x1B2FB
|| x === 0x1F004
|| x === 0x1F0CF
|| x === 0x1F18E
|| x >= 0x1F191 && x <= 0x1F19A
|| x >= 0x1F200 && x <= 0x1F202
|| x >= 0x1F210 && x <= 0x1F23B
|| x >= 0x1F240 && x <= 0x1F248
|| x === 0x1F250
|| x === 0x1F251
|| x >= 0x1F260 && x <= 0x1F265
|| x >= 0x1F300 && x <= 0x1F320
|| x >= 0x1F32D && x <= 0x1F335
|| x >= 0x1F337 && x <= 0x1F37C
|| x >= 0x1F37E && x <= 0x1F393
|| x >= 0x1F3A0 && x <= 0x1F3CA
|| x >= 0x1F3CF && x <= 0x1F3D3
|| x >= 0x1F3E0 && x <= 0x1F3F0
|| x === 0x1F3F4
|| x >= 0x1F3F8 && x <= 0x1F43E
|| x === 0x1F440
|| x >= 0x1F442 && x <= 0x1F4FC
|| x >= 0x1F4FF && x <= 0x1F53D
|| x >= 0x1F54B && x <= 0x1F54E
|| x >= 0x1F550 && x <= 0x1F567
|| x === 0x1F57A
|| x === 0x1F595
|| x === 0x1F596
|| x === 0x1F5A4
|| x >= 0x1F5FB && x <= 0x1F64F
|| x >= 0x1F680 && x <= 0x1F6C5
|| x === 0x1F6CC
|| x >= 0x1F6D0 && x <= 0x1F6D2
|| x >= 0x1F6D5 && x <= 0x1F6D7
|| x >= 0x1F6DC && x <= 0x1F6DF
|| x === 0x1F6EB
|| x === 0x1F6EC
|| x >= 0x1F6F4 && x <= 0x1F6FC
|| x >= 0x1F7E0 && x <= 0x1F7EB
|| x === 0x1F7F0
|| x >= 0x1F90C && x <= 0x1F93A
|| x >= 0x1F93C && x <= 0x1F945
|| x >= 0x1F947 && x <= 0x1F9FF
|| x >= 0x1FA70 && x <= 0x1FA7C
|| x >= 0x1FA80 && x <= 0x1FA88
|| x >= 0x1FA90 && x <= 0x1FABD
|| x >= 0x1FABF && x <= 0x1FAC5
|| x >= 0x1FACE && x <= 0x1FADB
|| x >= 0x1FAE0 && x <= 0x1FAE8
|| x >= 0x1FAF0 && x <= 0x1FAF8
|| x >= 0x20000 && x <= 0x2FFFD
|| x >= 0x30000 && x <= 0x3FFFD;
}
function getCategory(x: number) {
if (isAmbiguous(x)) return 'ambiguous';
if (isFullWidth(x)) return 'fullwidth';
if (
x === 0x20A9
|| x >= 0xFF61 && x <= 0xFFBE
|| x >= 0xFFC2 && x <= 0xFFC7
|| x >= 0xFFCA && x <= 0xFFCF
|| x >= 0xFFD2 && x <= 0xFFD7
|| x >= 0xFFDA && x <= 0xFFDC
|| x >= 0xFFE8 && x <= 0xFFEE
) {
return 'halfwidth';
}
if (
x >= 0x20 && x <= 0x7E
|| x === 0xA2
|| x === 0xA3
|| x === 0xA5
|| x === 0xA6
|| x === 0xAC
|| x === 0xAF
|| x >= 0x27E6 && x <= 0x27ED
|| x === 0x2985
|| x === 0x2986
) {
return 'narrow';
}
if (isWide(x)) return 'wide';
return 'neutral';
}
export {isAmbiguous, isFullWidth, isWide, getCategory};
interface MimicFunctionOptions {
ignoreNonConfigurable?: boolean;
}
function canCopyProperty(
toDescriptor?: PropertyDescriptor,
fromDescriptor?: PropertyDescriptor
): boolean {
return (
toDescriptor === undefined ||
toDescriptor.configurable ||
(toDescriptor.writable === fromDescriptor?.writable &&
toDescriptor.enumerable === fromDescriptor?.enumerable &&
toDescriptor.configurable === fromDescriptor?.configurable &&
(toDescriptor.writable || toDescriptor?.value === fromDescriptor?.value))
);
}
function copyProperty(
to: object,
from: object,
property: string,
ignoreNonConfigurable: boolean = false
) {
// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
// `Function#prototype` is non-writable and non-configurable so can never be modified.
if (property === 'length' || property === 'prototype') return;
// `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
if (property === 'arguments' || property === 'caller') return;
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
return;
}
Object.defineProperty(to, property, fromDescriptor!);
}
function changePrototype(to: object, from: object) {
const fromPrototype = Object.getPrototypeOf(from);
if (fromPrototype === Object.getPrototypeOf(to)) return;
Object.setPrototypeOf(to, fromPrototype);
}
const wrappedToString = (withName: string, fromBody: string) =>
`/* Wrapped ${withName}*/\n${fromBody}`;
const toStringDescriptor = Object.getOwnPropertyDescriptor(
Function.prototype,
'toString'
);
const toStringName = Object.getOwnPropertyDescriptor(
Function.prototype.toString,
'name'
);
function changeToString(to: Function, from: Function, name: string) {
const withName = name === '' ? '' : `with ${name.trim()}() `;
const newToString = wrappedToString.bind(null, withName, from.toString());
// Ensure `to.toString.toString` is non-enumerable and has the same `same`
Object.defineProperty(newToString, 'name', toStringName!);
const { writable, enumerable, configurable } = toStringDescriptor!; // We use ! because we know the descriptor exists from initial check
Object.defineProperty(to, 'toString', {
value: newToString,
writable,
enumerable,
configurable,
});
}
export default function mimicFunction(
to: Function,
from: Function,
options: MimicFunctionOptions = {}
): Function {
const { name } = to;
for (const property of Reflect.ownKeys(from)) {
copyProperty(to, from, property as string, options.ignoreNonConfigurable);
}
changePrototype(to, from);
changeToString(to, from, name);
return to;
}
import mimicFunction from './mimic-function';
interface OneTimeOptions {
throw?: boolean;
}
type CustomFunction = Function & {
displayName?: string;
}
const calledFunctions = new Map<Function, number>();
const onetime = (function_: CustomFunction | undefined, options: OneTimeOptions = {}): CustomFunction => {
if (typeof function_ !== 'function' || !function_) {
throw new TypeError('Expected a function');
}
let returnValue: any;
let callCount = 0;
const functionName = function_.displayName || function_.name || '<anonymous>';
const onetime = (...arguments_: any[]) => {
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;
};
// Mimic function is assumed to exist and take Function types
mimicFunction(onetime, function_);
calledFunctions.set(onetime, callCount);
return onetime;
};
onetime.callCount = (function_: Function) => {
if (!calledFunctions.has(function_)) {
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
}
return calledFunctions.get(function_)!; // Safe to use ! because of the check in the if statement
};
export default onetime;
import process from 'node:process';
import onetime from './onetime';
import { onExit } from 'signal-exit';
type WritableStream = NodeJS.WritableStream;
const getTerminal = (): WritableStream | undefined => {
if (process.stderr.isTTY) {
return process.stderr;
} else if (process.stdout.isTTY) {
return process.stdout;
}
return undefined;
};
const restoreCursor = (): void => {
const terminal = getTerminal();
if (!terminal) return;
onetime(() => {
onExit(
() => {
terminal.write('\u001B[?25h');
},
{ alwaysLast: true }
);
})();
};
export default restoreCursor;
import isFullwidthCodePoint from './is-fullwidth-code-point';
import ansiStyles from './ansi-styles';
const ESCAPES = new Set([27, 155]);
const CODE_POINT_0 = '0'.codePointAt(0)!;
const CODE_POINT_9 = '9'.codePointAt(0)!;
const MAX_ANSI_SEQUENCE_LENGTH = 19;
const endCodesSet = new Set<string>();
const endCodesMap = new Map<string, string>();
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: string): string {
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: string): number {
for (let index = 0; index < string.length; index++) {
const codePoint = string.codePointAt(index);
if (codePoint) {
if (codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9) {
return index;
}
}
}
return -1;
}
function parseAnsiCode(string: string, offset: number): string {
string = string.slice(offset, offset + MAX_ANSI_SEQUENCE_LENGTH);
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);
}
return '';
}
interface Token {
type: 'ansi' | 'character';
value?: string;
code?: string;
endCode?: string;
isFullWidth?: boolean;
}
function tokenize(
string: string,
endCharacter = Number.POSITIVE_INFINITY
): Token[] {
const returnValue: Token[] = [];
let index = 0;
let visibleCount = 0;
while (index < string.length) {
const codePoint = string.codePointAt(index);
if (!codePoint) {
break;
}
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 += isFullwidthCodePoint(codePoint) ? 2 : character.length;
if (visibleCount >= endCharacter) {
break;
}
}
return returnValue;
}
function reduceAnsiCodes(codes: Token[]): Token[] {
let returnValue: Token[] = [];
for (const code of codes) {
if (code.code === ansiStyles.reset.open) {
returnValue = [];
} else if (endCodesSet.has(code.code!)) {
returnValue = returnValue.filter(
(returnValueCode) => returnValueCode.endCode !== code.code
);
} else {
returnValue = returnValue.filter(
(returnValueCode) => returnValueCode.endCode !== code.code
);
returnValue.push(code);
}
}
return returnValue;
}
function undoAnsiCodes(codes: Token[]): string {
const reduced = reduceAnsiCodes(codes);
const endCodes = reduced.map(({ endCode }) => endCode!).reverse();
return endCodes.join('');
}
export default function sliceAnsi(
string: string,
start = 0,
end?: number
): string {
const tokens: Token[] = tokenize(string, end);
let activeCodes: Token[] = [];
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 {
if (!include && position >= start) {
include = true;
activeCodes = reduceAnsiCodes(activeCodes);
returnValue = activeCodes.map(({ code }) => code!).join('');
}
if (include) {
returnValue += token.value!;
}
position += token.isFullWidth ? 2 : token.value!.length;
}
}
returnValue += undoAnsiCodes(activeCodes);
return returnValue;
}
import stripAnsi from './strip-ansi';
import {eastAsianWidth} from './get-east-asian-width';
import emojiRegex from './emoji-regex';
const segmenter = new Intl.Segmenter();
export default function stringWidth(string: string, options: { ambiguousIsNarrow?: boolean, countAnsiEscapeCodes?: boolean } = {}) {
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 combining characters
if (codePoint >= 0x3_00 && codePoint <= 0x3_6F) {
continue;
}
if (emojiRegex.test(character)) {
width += 2;
continue;
}
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
}
return width;
}
import ansiRegex from './ansi-regex';
const regex = ansiRegex();
export default function stripAnsi(string: unknown): string {
if (typeof string !== 'string') {
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
}
return string.replace(regex, '');
}
import stringWidth from './string-width';
import stripAnsi from './strip-ansi';
import ansiStyles from './ansi-styles';
const ESCAPES: Set<string> = 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: number) =>
`${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
const wrapAnsiHyperlink = (url: string) =>
`${
ESCAPES.values().next().value
}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
const wordLengths = (string: string): number[] =>
string.split(' ').map((character) => stringWidth(character));
const wrapWord = (rows: string[], word: string, columns: number): void => {
const characters: string[] = [...word];
let isInsideEscape = false;
let isInsideLinkEscape = false;
let visible = stringWidth(stripAnsi(rows[rows.length - 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;
}
}
if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
rows[rows.length - 2] += rows.pop();
}
};
const stringVisibleTrimSpacesRight = (string: string): 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('');
};
interface WrapOptions {
trim?: boolean;
wordWrap?: boolean;
hard?: boolean;
}
const exec = (
string: string,
columns: number,
options: WrapOptions = {}
): string => {
if (options.trim !== false && string.trim() === '') {
return '';
}
let returnValue = '';
let escapeCode;
let escapeUrl;
const lengths = wordLengths(string);
let rows: string[] = [''];
for (const [index, word] of string.split(' ').entries()) {
if (options.trim !== false) {
rows[rows.length - 1] = rows[rows.length - 1].trimStart();
}
let rowLength = stringWidth(stripAnsi(rows[rows.length - 1]));
if (index !== 0) {
if (
rowLength >= columns &&
(options.wordWrap === false || options.trim === false)
) {
rows.push('');
rowLength = 0;
}
if (rowLength > 0 || options.trim === false) {
rows[rows.length - 1] += ' ';
rowLength++;
}
}
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];
let preStringIndex = 0;
for (const [index, character] of pre.entries()) {
returnValue += character;
if (ESCAPES.has(character)) {
type Groups = {
code?: string;
uri?: string;
};
const { groups }: { groups?: Groups } = new RegExp(
`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`
).exec(preString.slice(preStringIndex)) || { groups: {} };
if (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;
};
export default function wrapAnsi(
string: string,
columns: number,
options: WrapOptions = {}
): string {
return String(string)
.normalize()
.replace('\r\n', '\n')
.split('\n')
.map((line) => exec(line, columns, options))
.join('\n');
}
import { Spinner } from 'utils/loader/types';
declare module './spinners.json' {
const value: Record<string, Spinner>;
export default value;
}
{
"dots": {
"interval": 80,
"frames": [
"⠋",
"⠙",
"⠹",
"⠸",
"⠼",
"⠴",
"⠦",
"⠧",
"⠇",
"⠏"
]
},
"dots2": {
"interval": 80,
"frames": [
"⣾",
"⣽",
"⣻",
"⢿",
"⡿",
"⣟",
"⣯",
"⣷"
]
},
"dots3": {
"interval": 80,
"frames": [
"⠋",
"⠙",
"⠚",
"⠞",
"⠖",
"⠦",
"⠴",
"⠲",
"⠳",
"⠓"
]
},
"dots4": {
"interval": 80,
"frames": [
"⠄",
"⠆",
"⠇",
"⠋",
"⠙",
"⠸",
"⠰",
"⠠",
"⠰",
"⠸",
"⠙",
"⠋",
"⠇",
"⠆"
]
},
"dots5": {
"interval": 80,
"frames": [
"⠋",
"⠙",
"⠚",
"⠒",
"⠂",
"⠂",
"⠒",
"⠲",
"⠴",
"⠦",
"⠖",
"⠒",
"⠐",
"⠐",
"⠒",
"⠓",
"⠋"
]
},
"dots6": {
"interval": 80,
"frames": [
"⠁",
"⠉",
"⠙",
"⠚",
"⠒",
"⠂",
"⠂",
"⠒",
"⠲",
"⠴",
"⠤",
"⠄",
"⠄",
"⠤",
"⠴",
"⠲",
"⠒",
"⠂",
"⠂",
"⠒",
"⠚",
"⠙",
"⠉",
"⠁"
]
},
"dots7": {
"interval": 80,
"frames": [
"⠈",
"⠉",
"⠋",
"⠓",
"⠒",
"⠐",
"⠐",
"⠒",
"⠖",
"⠦",
"⠤",
"⠠",
"⠠",
"⠤",
"⠦",
"⠖",
"⠒",
"⠐",
"⠐",
"⠒",
"⠓",
"⠋",
"⠉",
"⠈"
]
},
"dots8": {
"interval": 80,
"frames": [
"⠁",
"⠁",
"⠉",
"⠙",
"⠚",
"⠒",
"⠂",
"⠂",
"⠒",
"⠲",
"⠴",
"⠤",
"⠄",
"⠄",
"⠤",
"⠠",
"⠠",
"⠤",
"⠦",
"⠖",
"⠒",
"⠐",
"⠐",
"⠒",
"⠓",
"⠋",
"⠉",
"⠈",
"⠈"
]
},
"dots9": {
"interval": 80,
"frames": [
"⢹",
"⢺",
"⢼",
"⣸",
"⣇",
"⡧",
"⡗",
"⡏"
]
},
"dots10": {
"interval": 80,
"frames": [
"⢄",
"⢂",
"⢁",
"⡁",
"⡈",
"⡐",
"⡠"
]
},
"dots11": {
"interval": 100,
"frames": [
"⠁",
"⠂",
"⠄",
"⡀",
"⢀",
"⠠",
"⠐",
"⠈"
]
},
"dots12": {
"interval": 80,
"frames": [
"⢀⠀",
"⡀⠀",
"⠄⠀",
"⢂⠀",
"⡂⠀",
"⠅⠀",
"⢃⠀",
"⡃⠀",
"⠍⠀",
"⢋⠀",
"⡋⠀",
"⠍⠁",
"⢋⠁",
"⡋⠁",
"⠍⠉",
"⠋⠉",
"⠋⠉",
"⠉⠙",
"⠉⠙",
"⠉⠩",
"⠈⢙",
"⠈⡙",
"⢈⠩",
"⡀⢙",
"⠄⡙",
"⢂⠩",
"⡂⢘",
"⠅⡘",
"⢃⠨",
"⡃⢐",
"⠍⡐",
"⢋⠠",
"⡋⢀",
"⠍⡁",
"⢋⠁",
"⡋⠁",
"⠍⠉",
"⠋⠉",
"⠋⠉",
"⠉⠙",
"⠉⠙",
"⠉⠩",
"⠈⢙",
"⠈⡙",
"⠈⠩",
"⠀⢙",
"⠀⡙",
"⠀⠩",
"⠀⢘",
"⠀⡘",
"⠀⠨",
"⠀⢐",
"⠀⡐",
"⠀⠠",
"⠀⢀",
"⠀⡀"
]
},
"dots13": {
"interval": 80,
"frames": [
"⣼",
"⣹",
"⢻",
"⠿",
"⡟",
"⣏",
"⣧",
"⣶"
]
},
"dots8Bit": {
"interval": 80,
"frames": [
"⠀",
"⠁",
"⠂",
"⠃",
"⠄",
"⠅",
"⠆",
"⠇",
"⡀",
"⡁",
"⡂",
"⡃",
"⡄",
"⡅",
"⡆",
"⡇",
"⠈",
"⠉",
"⠊",
"⠋",
"⠌",
"⠍",
"⠎",
"⠏",
"⡈",
"⡉",
"⡊",
"⡋",
"⡌",
"⡍",
"⡎",
"⡏",
"⠐",
"⠑",
"⠒",
"⠓",
"⠔",
"⠕",
"⠖",
"⠗",
"⡐",
"⡑",
"⡒",
"⡓",
"⡔",
"⡕",
"⡖",
"⡗",
"⠘",
"⠙",
"⠚",
"⠛",
"⠜",
"⠝",
"⠞",
"⠟",
"⡘",
"⡙",
"⡚",
"⡛",
"⡜",
"⡝",
"⡞",
"⡟",
"⠠",
"⠡",
"⠢",
"⠣",
"⠤",
"⠥",
"⠦",
"⠧",
"⡠",
"⡡",
"⡢",
"⡣",
"⡤",
"⡥",
"⡦",
"⡧",
"⠨",
"⠩",
"⠪",
"⠫",
"⠬",
"⠭",
"⠮",
"⠯",
"⡨",
"⡩",
"⡪",
"⡫",
"⡬",
"⡭",
"⡮",
"⡯",
"⠰",
"⠱",
"⠲",
"⠳",
"⠴",
"⠵",
"⠶",
"⠷",
"⡰",
"⡱",
"⡲",
"⡳",
"⡴",
"⡵",
"⡶",
"⡷",
"⠸",
"⠹",
"⠺",
"⠻",
"⠼",
"⠽",
"⠾",
"⠿",
"⡸",
"⡹",
"⡺",
"⡻",
"⡼",
"⡽",
"⡾",
"⡿",
"⢀",
"⢁",
"⢂",
"⢃",
"⢄",
"⢅",
"⢆",
"⢇",
"⣀",
"⣁",
"⣂",
"⣃",
"⣄",
"⣅",
"⣆",
"⣇",
"⢈",
"⢉",
"⢊",
"⢋",
"⢌",
"⢍",
"⢎",
"⢏",
"⣈",
"⣉",
"⣊",
"⣋",
"⣌",
"⣍",
"⣎",
"⣏",
"⢐",
"⢑",
"⢒",
"⢓",
"⢔",
"⢕",
"⢖",
"⢗",
"⣐",
"⣑",
"⣒",
"⣓",
"⣔",
"⣕",
"⣖",
"⣗",
"⢘",
"⢙",
"⢚",
"⢛",
"⢜",
"⢝",
"⢞",
"⢟",
"⣘",
"⣙",
"⣚",
"⣛",
"⣜",
"⣝",
"⣞",
"⣟",
"⢠",
"⢡",
"⢢",
"⢣",
"⢤",
"⢥",
"⢦",
"⢧",
"⣠",
"⣡",
"⣢",
"⣣",
"⣤",
"⣥",
"⣦",
"⣧",
"⢨",
"⢩",
"⢪",
"⢫",
"⢬",
"⢭",
"⢮",
"⢯",
"⣨",
"⣩",
"⣪",
"⣫",
"⣬",
"⣭",
"⣮",
"⣯",
"⢰",
"⢱",
"⢲",
"⢳",
"⢴",
"⢵",
"⢶",
"⢷",
"⣰",
"⣱",
"⣲",
"⣳",
"⣴",
"⣵",
"⣶",
"⣷",
"⢸",
"⢹",
"⢺",
"⢻",
"⢼",
"⢽",
"⢾",
"⢿",
"⣸",
"⣹",
"⣺",
"⣻",
"⣼",
"⣽",
"⣾",
"⣿"
]
},
"sand": {
"interval": 80,
"frames": [
"⠁",
"⠂",
"⠄",
"⡀",
"⡈",
"⡐",
"⡠",
"⣀",
"⣁",
"⣂",
"⣄",
"⣌",
"⣔",
"⣤",
"⣥",
"⣦",
"⣮",
"⣶",
"⣷",
"⣿",
"⡿",
"⠿",
"⢟",
"⠟",
"⡛",
"⠛",
"⠫",
"⢋",
"⠋",
"⠍",
"⡉",
"⠉",
"⠑",
"⠡",
"⢁"
]
},
"line": {
"interval": 130,
"frames": [
"-",
"\\",
"|",
"/"
]
},
"line2": {
"interval": 100,
"frames": [
"⠂",
"-",
"–",
"—",
"–",
"-"
]
},
"pipe": {
"interval": 100,
"frames": [
"┤",
"┘",
"┴",
"└",
"├",
"┌",
"┬",
"┐"
]
},
"simpleDots": {
"interval": 400,
"frames": [
". ",
".. ",
"...",
" "
]
},
"simpleDotsScrolling": {
"interval": 200,
"frames": [
". ",
".. ",
"...",
" ..",
" .",
" "
]
},
"star": {
"interval": 70,
"frames": [
"✶",
"✸",
"✹",
"✺",
"✹",
"✷"
]
},
"star2": {
"interval": 80,
"frames": [
"+",
"x",
"*"
]
},
"flip": {
"interval": 70,
"frames": [
"_",
"_",
"_",
"-",
"`",
"`",
"'",
"´",
"-",
"_",
"_",
"_"
]
},
"hamburger": {
"interval": 100,
"frames": [
"☱",
"☲",
"☴"
]
},
"growVertical": {
"interval": 120,
"frames": [
"▁",
"▃",
"▄",
"▅",
"▆",
"▇",
"▆",
"▅",
"▄",
"▃"
]
},
"growHorizontal": {
"interval": 120,
"frames": [
"▏",
"▎",
"▍",
"▌",
"▋",
"▊",
"▉",
"▊",
"▋",
"▌",
"▍",
"▎"
]
},
"balloon": {
"interval": 140,
"frames": [
" ",
".",
"o",
"O",
"@",
"*",
" "
]
},
"balloon2": {
"interval": 120,
"frames": [
".",
"o",
"O",
"°",
"O",
"o",
"."
]
},
"noise": {
"interval": 100,
"frames": [
"▓",
"▒",
"░"
]
},
"bounce": {
"interval": 120,
"frames": [
"⠁",
"⠂",
"⠄",
"⠂"
]
},
"boxBounce": {
"interval": 120,
"frames": [
"▖",
"▘",
"▝",
"▗"
]
},
"boxBounce2": {
"interval": 100,
"frames": [
"▌",
"▀",
"▐",
"▄"
]
},
"triangle": {
"interval": 50,
"frames": [
"◢",
"◣",
"◤",
"◥"
]
},
"binary": {
"interval": 80,
"frames": [
"010010",
"001100",
"100101",
"111010",
"111101",
"010111",
"101011",
"111000",
"110011",
"110101"
]
},
"arc": {
"interval": 100,
"frames": [
"◜",
"◠",
"◝",
"◞",
"◡",
"◟"
]
},
"circle": {
"interval": 120,
"frames": [
"◡",
"⊙",
"◠"
]
},
"squareCorners": {
"interval": 180,
"frames": [
"◰",
"◳",
"◲",
"◱"
]
},
"circleQuarters": {
"interval": 120,
"frames": [
"◴",
"◷",
"◶",
"◵"
]
},
"circleHalves": {
"interval": 50,
"frames": [
"◐",
"◓",
"◑",
"◒"
]
},
"squish": {
"interval": 100,
"frames": [
"╫",
"╪"
]
},
"toggle": {
"interval": 250,
"frames": [
"⊶",
"⊷"
]
},
"toggle2": {
"interval": 80,
"frames": [
"▫",
"▪"
]
},
"toggle3": {
"interval": 120,
"frames": [
"□",
"■"
]
},
"toggle4": {
"interval": 100,
"frames": [
"■",
"□",
"▪",
"▫"
]
},
"toggle5": {
"interval": 100,
"frames": [
"▮",
"▯"
]
},
"toggle6": {
"interval": 300,
"frames": [
"ဝ",
"၀"
]
},
"toggle7": {
"interval": 80,
"frames": [
"⦾",
"⦿"
]
},
"toggle8": {
"interval": 100,
"frames": [
"◍",
"◌"
]
},
"toggle9": {
"interval": 100,
"frames": [
"◉",
"◎"
]
},
"toggle10": {
"interval": 100,
"frames": [
"㊂",
"㊀",
"㊁"
]
},
"toggle11": {
"interval": 50,
"frames": [
"⧇",
"⧆"
]
},
"toggle12": {
"interval": 120,
"frames": [
"☗",
"☖"
]
},
"toggle13": {
"interval": 80,
"frames": [
"=",
"*",
"-"
]
},
"arrow": {
"interval": 100,
"frames": [
"←",
"↖",
"↑",
"↗",
"→",
"↘",
"↓",
"↙"
]
},
"arrow2": {
"interval": 80,
"frames": [
"⬆️ ",
"↗️ ",
"➡️ ",
"↘️ ",
"⬇️ ",
"↙️ ",
"⬅️ ",
"↖️ "
]
},
"arrow3": {
"interval": 120,
"frames": [
"▹▹▹▹▹",
"▸▹▹▹▹",
"▹▸▹▹▹",
"▹▹▸▹▹",
"▹▹▹▸▹",
"▹▹▹▹▸"
]
},
"bouncingBar": {
"interval": 80,
"frames": [
"[ ]",
"[= ]",
"[== ]",
"[=== ]",
"[====]",
"[ ===]",
"[ ==]",
"[ =]",
"[ ]",
"[ =]",
"[ ==]",
"[ ===]",
"[====]",
"[=== ]",
"[== ]",
"[= ]"
]
},
"bouncingBall": {
"interval": 80,
"frames": [
"( ● )",
"( ● )",
"( ● )",
"( ● )",
"( ●)",
"( ● )",
"( ● )",
"( ● )",
"( ● )",
"(● )"
]
},
"smiley": {
"interval": 200,
"frames": [
"😄 ",
"😝 "
]
},
"monkey": {
"interval": 300,
"frames": [
"🙈 ",
"🙈 ",
"🙉 ",
"🙊 "
]
},
"hearts": {
"interval": 100,
"frames": [
"💛 ",
"💙 ",
"💜 ",
"💚 ",
"❤️ "
]
},
"clock": {
"interval": 100,
"frames": [
"🕛 ",
"🕐 ",
"🕑 ",
"🕒 ",
"🕓 ",
"🕔 ",
"🕕 ",
"🕖 ",
"🕗 ",
"🕘 ",
"🕙 ",
"🕚 "
]
},
"earth": {
"interval": 180,
"frames": [
"🌍 ",
"🌎 ",
"🌏 "
]
},
"material": {
"interval": 17,
"frames": [
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"███████▁▁▁▁▁▁▁▁▁▁▁▁▁",
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
"█████████▁▁▁▁▁▁▁▁▁▁▁",
"█████████▁▁▁▁▁▁▁▁▁▁▁",
"██████████▁▁▁▁▁▁▁▁▁▁",
"███████████▁▁▁▁▁▁▁▁▁",
"█████████████▁▁▁▁▁▁▁",
"██████████████▁▁▁▁▁▁",
"██████████████▁▁▁▁▁▁",
"▁██████████████▁▁▁▁▁",
"▁██████████████▁▁▁▁▁",
"▁██████████████▁▁▁▁▁",
"▁▁██████████████▁▁▁▁",
"▁▁▁██████████████▁▁▁",
"▁▁▁▁█████████████▁▁▁",
"▁▁▁▁██████████████▁▁",
"▁▁▁▁██████████████▁▁",
"▁▁▁▁▁██████████████▁",
"▁▁▁▁▁██████████████▁",
"▁▁▁▁▁██████████████▁",
"▁▁▁▁▁▁██████████████",
"▁▁▁▁▁▁██████████████",
"▁▁▁▁▁▁▁█████████████",
"▁▁▁▁▁▁▁█████████████",
"▁▁▁▁▁▁▁▁████████████",
"▁▁▁▁▁▁▁▁████████████",
"▁▁▁▁▁▁▁▁▁███████████",
"▁▁▁▁▁▁▁▁▁███████████",
"▁▁▁▁▁▁▁▁▁▁██████████",
"▁▁▁▁▁▁▁▁▁▁██████████",
"▁▁▁▁▁▁▁▁▁▁▁▁████████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁█",
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
"█████████▁▁▁▁▁▁▁▁▁▁▁",
"█████████▁▁▁▁▁▁▁▁▁▁▁",
"█████████▁▁▁▁▁▁▁▁▁▁▁",
"█████████▁▁▁▁▁▁▁▁▁▁▁",
"███████████▁▁▁▁▁▁▁▁▁",
"████████████▁▁▁▁▁▁▁▁",
"████████████▁▁▁▁▁▁▁▁",
"██████████████▁▁▁▁▁▁",
"██████████████▁▁▁▁▁▁",
"▁██████████████▁▁▁▁▁",
"▁██████████████▁▁▁▁▁",
"▁▁▁█████████████▁▁▁▁",
"▁▁▁▁▁████████████▁▁▁",
"▁▁▁▁▁████████████▁▁▁",
"▁▁▁▁▁▁███████████▁▁▁",
"▁▁▁▁▁▁▁▁█████████▁▁▁",
"▁▁▁▁▁▁▁▁█████████▁▁▁",
"▁▁▁▁▁▁▁▁▁█████████▁▁",
"▁▁▁▁▁▁▁▁▁█████████▁▁",
"▁▁▁▁▁▁▁▁▁▁█████████▁",
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁"
]
},
"moon": {
"interval": 80,
"frames": [
"🌑 ",
"🌒 ",
"🌓 ",
"🌔 ",
"🌕 ",
"🌖 ",
"🌗 ",
"🌘 "
]
},
"runner": {
"interval": 140,
"frames": [
"🚶 ",
"🏃 "
]
},
"pong": {
"interval": 80,
"frames": [
"▐⠂ ▌",
"▐⠈ ▌",
"▐ ⠂ ▌",
"▐ ⠠ ▌",
"▐ ⡀ ▌",
"▐ ⠠ ▌",
"▐ ⠂ ▌",
"▐ ⠈ ▌",
"▐ ⠂ ▌",
"▐ ⠠ ▌",
"▐ ⡀ ▌",
"▐ ⠠ ▌",
"▐ ⠂ ▌",
"▐ ⠈ ▌",
"▐ ⠂▌",
"▐ ⠠▌",
"▐ ⡀▌",
"▐ ⠠ ▌",
"▐ ⠂ ▌",
"▐ ⠈ ▌",
"▐ ⠂ ▌",
"▐ ⠠ ▌",
"▐ ⡀ ▌",
"▐ ⠠ ▌",
"▐ ⠂ ▌",
"▐ ⠈ ▌",
"▐ ⠂ ▌",
"▐ ⠠ ▌",
"▐ ⡀ ▌",
"▐⠠ ▌"
]
},
"shark": {
"interval": 120,
"frames": [
"▐|\\____________▌",
"▐_|\\___________▌",
"▐__|\\__________▌",
"▐___|\\_________▌",
"▐____|\\________▌",
"▐_____|\\_______▌",
"▐______|\\______▌",
"▐_______|\\_____▌",
"▐________|\\____▌",
"▐_________|\\___▌",
"▐__________|\\__▌",
"▐___________|\\_▌",
"▐____________|\\▌",
"▐____________/|▌",
"▐___________/|_▌",
"▐__________/|__▌",
"▐_________/|___▌",
"▐________/|____▌",
"▐_______/|_____▌",
"▐______/|______▌",
"▐_____/|_______▌",
"▐____/|________▌",
"▐___/|_________▌",
"▐__/|__________▌",
"▐_/|___________▌",
"▐/|____________▌"
]
},
"dqpb": {
"interval": 100,
"frames": [
"d",
"q",
"p",
"b"
]
},
"weather": {
"interval": 100,
"frames": [
"☀️ ",
"☀️ ",
"☀️ ",
"🌤 ",
"⛅️ ",
"🌥 ",
"☁️ ",
"🌧 ",
"🌨 ",
"🌧 ",
"🌨 ",
"🌧 ",
"🌨 ",
"⛈ ",
"🌨 ",
"🌧 ",
"🌨 ",
"☁️ ",
"🌥 ",
"⛅️ ",
"🌤 ",
"☀️ ",
"☀️ "
]
},
"christmas": {
"interval": 400,
"frames": [
"🌲",
"🎄"
]
},
"grenade": {
"interval": 80,
"frames": [
"، ",
"′ ",
" ´ ",
" ‾ ",
" ⸌",
" ⸊",
" |",
" ⁎",
" ⁕",
" ෴ ",
" ⁓",
" ",
" ",
" "
]
},
"point": {
"interval": 125,
"frames": [
"∙∙∙",
"●∙∙",
"∙●∙",
"∙∙●",
"∙∙∙"
]
},
"layer": {
"interval": 150,
"frames": [
"-",
"=",
"≡"
]
},
"betaWave": {
"interval": 80,
"frames": [
"ρββββββ",
"βρβββββ",
"ββρββββ",
"βββρβββ",
"ββββρββ",
"βββββρβ",
"ββββββρ"
]
},
"fingerDance": {
"interval": 160,
"frames": [
"🤘 ",
"🤟 ",
"🖖 ",
"✋ ",
"🤚 ",
"👆 "
]
},
"fistBump": {
"interval": 80,
"frames": [
"🤜\u3000\u3000\u3000\u3000🤛 ",
"🤜\u3000\u3000\u3000\u3000🤛 ",
"🤜\u3000\u3000\u3000\u3000🤛 ",
"\u3000🤜\u3000\u3000🤛\u3000 ",
"\u3000\u3000🤜🤛\u3000\u3000 ",
"\u3000🤜✨🤛\u3000\u3000 ",
"🤜\u3000✨\u3000🤛\u3000 "
]
},
"soccerHeader": {
"interval": 80,
"frames": [
" 🧑⚽️ 🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️ 🧑 ",
"🧑 ⚽️ 🧑 "
]
},
"mindblown": {
"interval": 160,
"frames": [
"😐 ",
"😐 ",
"😮 ",
"😮 ",
"😦 ",
"😦 ",
"😧 ",
"😧 ",
"🤯 ",
"💥 ",
"✨ ",
"\u3000 ",
"\u3000 ",
"\u3000 "
]
},
"speaker": {
"interval": 160,
"frames": [
"🔈 ",
"🔉 ",
"🔊 ",
"🔉 "
]
},
"orangePulse": {
"interval": 100,
"frames": [
"🔸 ",
"🔶 ",
"🟠 ",
"🟠 ",
"🔶 "
]
},
"bluePulse": {
"interval": 100,
"frames": [
"🔹 ",
"🔷 ",
"🔵 ",
"🔵 ",
"🔷 "
]
},
"orangeBluePulse": {
"interval": 100,
"frames": [
"🔸 ",
"🔶 ",
"🟠 ",
"🟠 ",
"🔶 ",
"🔹 ",
"🔷 ",
"🔵 ",
"🔵 ",
"🔷 "
]
},
"timeTravel": {
"interval": 100,
"frames": [
"🕛 ",
"🕚 ",
"🕙 ",
"🕘 ",
"🕗 ",
"🕖 ",
"🕕 ",
"🕔 ",
"🕓 ",
"🕒 ",
"🕑 ",
"🕐 "
]
},
"aesthetic": {
"interval": 80,
"frames": [
"▰▱▱▱▱▱▱",
"▰▰▱▱▱▱▱",
"▰▰▰▱▱▱▱",
"▰▰▰▰▱▱▱",
"▰▰▰▰▰▱▱",
"▰▰▰▰▰▰▱",
"▰▰▰▰▰▰▰",
"▰▱▱▱▱▱▱"
]
},
"dwarfFortress": {
"interval": 80,
"frames": [
" ██████£££ ",
"☺██████£££ ",
"☺██████£££ ",
"☺▓█████£££ ",
"☺▓█████£££ ",
"☺▒█████£££ ",
"☺▒█████£££ ",
"☺░█████£££ ",
"☺░█████£££ ",
"☺ █████£££ ",
" ☺█████£££ ",
" ☺█████£££ ",
" ☺▓████£££ ",
" ☺▓████£££ ",
" ☺▒████£££ ",
" ☺▒████£££ ",
" ☺░████£££ ",
" ☺░████£££ ",
" ☺ ████£££ ",
" ☺████£££ ",
" ☺████£££ ",
" ☺▓███£££ ",
" ☺▓███£££ ",
" ☺▒███£££ ",
" ☺▒███£££ ",
" ☺░███£££ ",
" ☺░███£££ ",
" ☺ ███£££ ",
" ☺███£££ ",
" ☺███£££ ",
" ☺▓██£££ ",
" ☺▓██£££ ",
" ☺▒██£££ ",
" ☺▒██£££ ",
" ☺░██£££ ",
" ☺░██£££ ",
" ☺ ██£££ ",
" ☺██£££ ",
" ☺██£££ ",
" ☺▓█£££ ",
" ☺▓█£££ ",
" ☺▒█£££ ",
" ☺▒█£££ ",
" ☺░█£££ ",
" ☺░█£££ ",
" ☺ █£££ ",
" ☺█£££ ",
" ☺█£££ ",
" ☺▓£££ ",
" ☺▓£££ ",
" ☺▒£££ ",
" ☺▒£££ ",
" ☺░£££ ",
" ☺░£££ ",
" ☺ £££ ",
" ☺£££ ",
" ☺£££ ",
" ☺▓££ ",
" ☺▓££ ",
" ☺▒££ ",
" ☺▒££ ",
" ☺░££ ",
" ☺░££ ",
" ☺ ££ ",
" ☺££ ",
" ☺££ ",
" ☺▓£ ",
" ☺▓£ ",
" ☺▒£ ",
" ☺▒£ ",
" ☺░£ ",
" ☺░£ ",
" ☺ £ ",
" ☺£ ",
" ☺£ ",
" ☺▓ ",
" ☺▓ ",
" ☺▒ ",
" ☺▒ ",
" ☺░ ",
" ☺░ ",
" ☺ ",
" ☺ &",
" ☺ ☼&",
" ☺ ☼ &",
" ☺☼ &",
" ☺☼ & ",
" ‼ & ",
" ☺ & ",
" ‼ & ",
" ☺ & ",
" ‼ & ",
" ☺ & ",
"‼ & ",
" & ",
" & ",
" & ░ ",
" & ▒ ",
" & ▓ ",
" & £ ",
" & ░£ ",
" & ▒£ ",
" & ▓£ ",
" & ££ ",
" & ░££ ",
" & ▒££ ",
"& ▓££ ",
"& £££ ",
" ░£££ ",
" ▒£££ ",
" ▓£££ ",
" █£££ ",
" ░█£££ ",
" ▒█£££ ",
" ▓█£££ ",
" ██£££ ",
" ░██£££ ",
" ▒██£££ ",
" ▓██£££ ",
" ███£££ ",
" ░███£££ ",
" ▒███£££ ",
" ▓███£££ ",
" ████£££ ",
" ░████£££ ",
" ▒████£££ ",
" ▓████£££ ",
" █████£££ ",
" ░█████£££ ",
" ▒█████£££ ",
" ▓█████£££ ",
" ██████£££ ",
" ██████£££ "
]
}
}
export type Spinners =
| 'dots'
| 'dots2'
| 'dots3'
| 'dots4'
| 'dots5'
| 'dots6'
| 'dots7'
| 'dots8'
| 'dots9'
| 'dots10'
| 'dots11'
| 'dots12'
| 'dots13'
| 'dots8Bit'
| 'sand'
| 'line'
| 'line2'
| 'pipe'
| 'simpleDots'
| 'simpleDotsScrolling'
| 'star'
| 'star2'
| 'flip'
| 'hamburger'
| 'growVertical'
| 'growHorizontal'
| 'balloon'
| 'balloon2'
| 'noise'
| 'bounce'
| 'boxBounce'
| 'boxBounce2'
| 'triangle'
| 'binary'
| 'arc'
| 'circle'
| 'squareCorners'
| 'circleQuarters'
| 'circleHalves'
| 'squish'
| 'toggle'
| 'toggle2'
| 'toggle3'
| 'toggle4'
| 'toggle5'
| 'toggle6'
| 'toggle7'
| 'toggle8'
| 'toggle9'
| 'toggle10'
| 'toggle11'
| 'toggle12'
| 'toggle13'
| 'arrow'
| 'arrow2'
| 'arrow3'
| 'bouncingBar'
| 'bouncingBall'
| 'smiley'
| 'monkey'
| 'hearts'
| 'clock'
| 'earth'
| 'material'
| 'moon'
| 'runner'
| 'pong'
| 'shark'
| 'dqpb'
| 'weather'
| 'christmas'
| 'grenade'
| 'point'
| 'layer'
| 'betaWave'
| 'fingerDance'
| 'fistBump'
| 'soccerHeader'
| 'mindblown'
| 'speaker'
| 'orangePulse'
| 'bluePulse'
| 'orangeBluePulse'
| 'timeTravel'
| 'aesthetic'
| 'dwarfFortress';
export type Spinner = {
frames: string[];
interval: number;
};