This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 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,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,12 @@
import {
_isFullWidth as isFullWidth,
_isWide as isWide,
} from 'get-east-asian-width';
export default function isFullwidthCodePoint(codePoint) {
if (!Number.isInteger(codePoint)) {
return false;
}
return isFullWidth(codePoint) || isWide(codePoint);
}

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,53 @@
{
"name": "is-fullwidth-code-point",
"version": "5.1.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"
},
"sideEffects": false,
"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.3.1"
}
}

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

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

@@ -0,0 +1,169 @@
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 MAX_ANSI_SEQUENCE_LENGTH = 19;
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 + 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);
}
}
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,58 @@
{
"name": "slice-ansi",
"version": "7.1.2",
"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"
},
"sideEffects": false,
"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-)

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)