First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

29
node_modules/stdout-update/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,29 @@
# Important Changes
## Dependencies
<details>
<summary>Dependencies</summary>
- Bumped **[string-width](https://www.npmjs.com/package/string-width)** from `^6.1.0` to `^7.1.0`
</details>
<details>
<summary>Dev Dependencies</summary>
- Changed **[@tagproject/ts-package-shared-config](https://www.npmjs.com/package/@tagproject/ts-package-shared-config)** from `^11.0.1` to `^11.0.4`
- Changed **[ts-node](https://www.npmjs.com/package/ts-node)** from `^10.9.1` to `^10.9.2`
</details>
# :memo: Internal changes
- Fix lint warnings [`c92ead9`](https://github.com/keindev/stdout-update/commit/c92ead99cf92088a41b7ec8478475f074abd9f89)
- Fix build badge [`8b9e543`](https://github.com/keindev/stdout-update/commit/8b9e54357ab92cf55aefdd8cb816e5e59e64eaa1)
---
# Contributors
[![@keindev](https://avatars.githubusercontent.com/u/4527292?v=4&s=40)](https://github.com/keindev) [![@github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4&s=40)](https://github.com/github-actions%5Bbot%5D)

21
node_modules/stdout-update/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Daniil Ryazanov <kein@tagproject.ru>
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.

66
node_modules/stdout-update/README.md generated vendored Normal file
View File

@@ -0,0 +1,66 @@
<p align="center"><img src="https://cdn.jsdelivr.net/gh/tagproject/art/packages/stdout-update/banner.svg" alt="Package logo"></p>
<p align="center">
<a href="https://github.com/keindev/stdout-update/actions"><img src="https://github.com/keindev/stdout-update/actions/workflows/build.yml/badge.svg" alt="Build Status"></a>
<a href="https://codecov.io/gh/keindev/stdout-update"><img src="https://codecov.io/gh/keindev/stdout-update/branch/master/graph/badge.svg" /></a>
<a href="https://www.npmjs.com/package/stdout-update"><img alt="npm" src="https://img.shields.io/npm/v/stdout-update.svg"></a>
<a href="https://github.com/tagproject/ts-package-shared-config"><img src="https://img.shields.io/badge/standard--shared--config-nodejs%2Bts-green?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAfCAYAAACh+E5kAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJQSURBVHgB1VftUcMwDFU4/tMNyAZ0A7IBbBA2CExAmIBjApcJChO0TFA2SJkgMIGRyDNV3TSt26RN353OX/LHUyTZIdoB1tqMZcaS0imBDzxkeWaJWR51SX0HrJ6pdsJyifpdb4loq3v9A+1CaBuWMR0Q502DzuJRFD34Y9z3DXIRNy/QPWKZY27COlM6BtZZHWMJ3CkVa28KZMTJkDpCVLOhs/oL2gMuEhYpxeenPPah9EdczLkvpwZgnQHWnlNLiNQGYiWx5gu6Ehz4m+WNN/2i9Yd75CJmeRDXogbIFxECrqQ2wIvlLBOXaViuYbGQNSQLFSGZyOnulb2wadaGnyoSSeC8GBJkNDf5kloESAhy2gFIIPG2+ufUMtivn/gAEi+Gy4u6FLxh/qer8/xbLq7QlNh6X4mbtr+A3pylDI0Lb43YrmLmXP5v3a4I4ABDRSI4xjB/ghveoj4BCVm37JQADhGDgOA+YJ48TSaoOwKpt27aOQG1WRES3La65WPU3dysTjE8de0Aj8SsKS5sdS9lqCeYI08bU6d8EALYS5OoDW4c3qi2gf7f+4yODfj2DIcqdVzYKnMtEUO7RP2gT/W1AImxXSC3i7R7rfRuMT5G2xzSYzaCDzOyyzDeuNHZx1a3fOdJJwh28fRwwT1QY6Xzf7TvWG6ob/BIGPQ59ymUngRyRn2El6Fy5T7G0zl+JmoC3KRQXyT1xpfiJKIeAemzqBl6U3V5ocZNf4hHg61u223wn4nOqF8IzvF9IxCMkyfQ+i/lnnhlmW6h9+Mqv1SmQhehji4JAAAAAElFTkSuQmCC" alt="Standard Shared Config"></a>
</p>
Purely and accurately overwrites the previous output in the terminal, while maintaining the history of third-party logs.
<p align="center">
<img src="media/demo.gif">
</p>
## Install
```
npm install stdout-update
```
## Usage
```typescript
import UpdateManager from 'stdout-update';
const TICKS = 60;
const TIMEOUT = 80;
const manager = UpdateManager.getInstance();
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
const messages = ['Swapping time and space...', 'Have a good day.', "Don't panic...", 'Updating Updater...', '42'];
let ticks = TICKS;
let i = 0;
manager.hook();
// eslint-disable-next-line no-console
console.log(' - log message');
// eslint-disable-next-line no-console
console.error(' - error message');
// eslint-disable-next-line no-console
console.warn(' - warn message');
const id = setInterval(() => {
if (--ticks < 0) {
clearInterval(id);
manager.update(['✔ Success', '', 'Messages:', 'this line is be deleted!!!']);
manager.erase(1);
manager.unhook(false);
} else {
const frame = frames[(i = ++i % frames.length)];
const index = Math.round(ticks / 10) % messages.length;
const message = messages[index];
if (message) manager.update([`${frame} Some process...`, message]);
}
}, TIMEOUT);
```
## Examples
[tasktree-cli](https://github.com/keindev/tasktree) - simple terminal task tree, helps you keep track of your tasks in a tree structure.
## API
Read the [API documentation](docs/api/index.md) for more information.

11
node_modules/stdout-update/lib/Hook.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
/// <reference types="node" resolution-mode="require"/>
export declare class Hook {
#private;
static readonly DRAIN = true;
constructor(stream: NodeJS.WriteStream);
active(): void;
erase(count: number): void;
inactive(separateHistory?: boolean): void;
renew(): void;
write(msg: string): void;
}

59
node_modules/stdout-update/lib/Hook.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Hook_decoder, _Hook_history, _Hook_method, _Hook_stream;
import ansiEscapes from 'ansi-escapes';
import { StringDecoder } from 'string_decoder';
import { Terminal } from './Terminal.js';
export class Hook {
constructor(stream) {
_Hook_decoder.set(this, new StringDecoder());
_Hook_history.set(this, []);
_Hook_method.set(this, void 0);
_Hook_stream.set(this, void 0);
__classPrivateFieldSet(this, _Hook_method, stream.write, "f");
__classPrivateFieldSet(this, _Hook_stream, stream, "f");
}
active() {
this.write(ansiEscapes.cursorHide);
__classPrivateFieldGet(this, _Hook_stream, "f").write = (data, ...args) => {
const callback = args[args.length - 1];
__classPrivateFieldGet(this, _Hook_history, "f").push(__classPrivateFieldGet(this, _Hook_decoder, "f").write(typeof data === 'string'
? Buffer.from(data, typeof args[0] === 'string' ? args[0] : undefined)
: Buffer.from(data)));
if (typeof callback === 'function')
callback();
return Hook.DRAIN;
};
}
erase(count) {
if (count > 0)
this.write(ansiEscapes.eraseLines(count + 1));
}
inactive(separateHistory = false) {
if (__classPrivateFieldGet(this, _Hook_history, "f").length) {
if (separateHistory)
this.write(Terminal.EOL);
__classPrivateFieldGet(this, _Hook_history, "f").forEach(this.write, this);
__classPrivateFieldSet(this, _Hook_history, [], "f");
}
this.renew();
}
renew() {
__classPrivateFieldGet(this, _Hook_stream, "f").write = __classPrivateFieldGet(this, _Hook_method, "f");
this.write(ansiEscapes.cursorShow);
}
write(msg) {
__classPrivateFieldGet(this, _Hook_method, "f").apply(__classPrivateFieldGet(this, _Hook_stream, "f"), [msg]);
}
}
_Hook_decoder = new WeakMap(), _Hook_history = new WeakMap(), _Hook_method = new WeakMap(), _Hook_stream = new WeakMap();
Hook.DRAIN = true;

11
node_modules/stdout-update/lib/Terminal.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
/// <reference types="node" resolution-mode="require"/>
export declare class Terminal {
#private;
static readonly COLUMNS = 80;
static readonly EOL = "\n";
static readonly ROWS = 24;
constructor(stdout: NodeJS.WriteStream);
get width(): number;
get height(): number;
adapt(value: number): number;
}

32
node_modules/stdout-update/lib/Terminal.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Terminal_isWin32, _Terminal_stdout;
export class Terminal {
constructor(stdout) {
_Terminal_isWin32.set(this, process.platform === 'win32');
_Terminal_stdout.set(this, void 0);
__classPrivateFieldSet(this, _Terminal_stdout, stdout, "f");
}
get width() {
return __classPrivateFieldGet(this, _Terminal_stdout, "f").columns ? this.adapt(__classPrivateFieldGet(this, _Terminal_stdout, "f").columns) : Terminal.COLUMNS;
}
get height() {
return __classPrivateFieldGet(this, _Terminal_stdout, "f").rows ? this.adapt(__classPrivateFieldGet(this, _Terminal_stdout, "f").rows) : Terminal.ROWS;
}
adapt(value) {
return __classPrivateFieldGet(this, _Terminal_isWin32, "f") ? value - 1 : value;
}
}
_Terminal_isWin32 = new WeakMap(), _Terminal_stdout = new WeakMap();
Terminal.COLUMNS = 80;
Terminal.EOL = '\n';
Terminal.ROWS = 24;

19
node_modules/stdout-update/lib/UpdateManager.d.ts generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/// <reference types="node" resolution-mode="require"/>
export declare class UpdateManager {
#private;
private static instance?;
private constructor();
static getInstance(stdout?: NodeJS.WriteStream, stderr?: NodeJS.WriteStream): UpdateManager;
get lastLength(): number;
get outside(): number;
get isHooked(): boolean;
get isSuspended(): boolean;
erase(count?: number): void;
hook(): boolean;
resume(eraseRowCount?: number): void;
suspend(erase?: boolean): void;
unhook(separateHistory?: boolean): boolean;
update(rows: string[], from?: number): void;
private clear;
}
export default UpdateManager;

112
node_modules/stdout-update/lib/UpdateManager.js generated vendored Normal file
View File

@@ -0,0 +1,112 @@
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _UpdateManager_hooks, _UpdateManager_isActive, _UpdateManager_isSuspended, _UpdateManager_lastLength, _UpdateManager_outside, _UpdateManager_terminal, _UpdateManager_wrapper;
import { Hook } from './Hook.js';
import { Terminal } from './Terminal.js';
import { Wrapper } from './Wrapper.js';
export class UpdateManager {
constructor(stdout, stderr) {
_UpdateManager_hooks.set(this, void 0);
_UpdateManager_isActive.set(this, false);
_UpdateManager_isSuspended.set(this, false);
_UpdateManager_lastLength.set(this, 0);
_UpdateManager_outside.set(this, 0);
_UpdateManager_terminal.set(this, void 0);
_UpdateManager_wrapper.set(this, void 0);
__classPrivateFieldSet(this, _UpdateManager_hooks, [stdout, stderr].map((stream) => new Hook(stream)), "f");
__classPrivateFieldSet(this, _UpdateManager_terminal, new Terminal(stdout), "f");
__classPrivateFieldSet(this, _UpdateManager_wrapper, new Wrapper(), "f");
}
static getInstance(stdout = process.stdout, stderr = process.stderr) {
if (!UpdateManager.instance)
UpdateManager.instance = new UpdateManager(stdout, stderr);
return UpdateManager.instance;
}
get lastLength() {
return __classPrivateFieldGet(this, _UpdateManager_lastLength, "f");
}
get outside() {
return __classPrivateFieldGet(this, _UpdateManager_outside, "f");
}
get isHooked() {
return __classPrivateFieldGet(this, _UpdateManager_isActive, "f");
}
get isSuspended() {
return __classPrivateFieldGet(this, _UpdateManager_isSuspended, "f");
}
erase(count = __classPrivateFieldGet(this, _UpdateManager_lastLength, "f")) {
const [hook] = __classPrivateFieldGet(this, _UpdateManager_hooks, "f");
if (hook)
hook.erase(count);
}
hook() {
if (!__classPrivateFieldGet(this, _UpdateManager_isActive, "f")) {
__classPrivateFieldGet(this, _UpdateManager_hooks, "f").forEach(hook => hook.active());
this.clear(true);
}
return __classPrivateFieldGet(this, _UpdateManager_isActive, "f");
}
resume(eraseRowCount) {
if (__classPrivateFieldGet(this, _UpdateManager_isSuspended, "f")) {
__classPrivateFieldSet(this, _UpdateManager_isSuspended, false, "f");
if (eraseRowCount)
this.erase(eraseRowCount);
__classPrivateFieldSet(this, _UpdateManager_lastLength, 0, "f");
__classPrivateFieldGet(this, _UpdateManager_hooks, "f").forEach(hook => hook.active());
}
}
suspend(erase = true) {
if (!__classPrivateFieldGet(this, _UpdateManager_isSuspended, "f")) {
__classPrivateFieldSet(this, _UpdateManager_isSuspended, true, "f");
if (erase)
this.erase();
__classPrivateFieldGet(this, _UpdateManager_hooks, "f").forEach(hook => hook.renew());
}
}
unhook(separateHistory = true) {
if (__classPrivateFieldGet(this, _UpdateManager_isActive, "f")) {
__classPrivateFieldGet(this, _UpdateManager_hooks, "f").forEach(hook => hook.inactive(separateHistory));
this.clear();
}
return !__classPrivateFieldGet(this, _UpdateManager_isActive, "f");
}
update(rows, from = 0) {
if (rows.length) {
const [hook] = __classPrivateFieldGet(this, _UpdateManager_hooks, "f");
if (hook) {
const { width, height } = __classPrivateFieldGet(this, _UpdateManager_terminal, "f");
const position = from > height ? height - 1 : Math.max(0, Math.min(height - 1, from));
const actualLength = this.lastLength - position;
const outside = Math.max(actualLength - height, this.outside);
let output = rows.reduce((acc, row) => acc.concat(__classPrivateFieldGet(this, _UpdateManager_wrapper, "f").wrap(row, width)), []);
if (height <= actualLength) {
hook.erase(height);
if (position < outside)
output = output.slice(outside - position + 1);
}
else if (actualLength) {
hook.erase(actualLength);
}
hook.write(output.join(Terminal.EOL) + Terminal.EOL);
__classPrivateFieldSet(this, _UpdateManager_lastLength, outside ? outside + output.length + 1 : output.length, "f");
__classPrivateFieldSet(this, _UpdateManager_outside, Math.max(this.lastLength - height, this.outside), "f");
}
}
}
clear(status = false) {
__classPrivateFieldSet(this, _UpdateManager_isActive, status, "f");
__classPrivateFieldSet(this, _UpdateManager_lastLength, 0, "f");
__classPrivateFieldSet(this, _UpdateManager_outside, 0, "f");
}
}
_UpdateManager_hooks = new WeakMap(), _UpdateManager_isActive = new WeakMap(), _UpdateManager_isSuspended = new WeakMap(), _UpdateManager_lastLength = new WeakMap(), _UpdateManager_outside = new WeakMap(), _UpdateManager_terminal = new WeakMap(), _UpdateManager_wrapper = new WeakMap();
export default UpdateManager;

7
node_modules/stdout-update/lib/Wrapper.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export declare class Wrapper {
#private;
constructor();
wrap(str: string, limit: number): string[];
private wrapEscapes;
private wrapWord;
}

115
node_modules/stdout-update/lib/Wrapper.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Wrapper_rows;
import ansiStyles from 'ansi-styles';
import stringWidth from 'string-width';
import stripAnsi from 'strip-ansi';
import { Terminal } from './Terminal.js';
const ESCAPES = new Set(['\u001B', '\u009B']);
const DEFAULT_COLOR_CODE = 39;
const INDENT = 4;
export class Wrapper {
constructor() {
_Wrapper_rows.set(this, void 0);
__classPrivateFieldSet(this, _Wrapper_rows, [''], "f");
}
wrap(str, limit) {
if (!str.trim().length)
return [''];
__classPrivateFieldSet(this, _Wrapper_rows, [''], "f");
const rows = __classPrivateFieldGet(this, _Wrapper_rows, "f");
let rowLength;
let wordLength;
str
.normalize()
.split(' ')
.forEach((word, index) => {
rowLength = stringWidth(rows[rows.length - 1] ?? '');
wordLength = stringWidth(word);
if (index !== 0) {
rows[rows.length - 1] += ' ';
rowLength++;
}
if (wordLength > limit) {
const remainingColumns = limit - rowLength;
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / limit);
const breaksStartingNextLine = Math.floor((wordLength - 1) / limit);
if (breaksStartingNextLine < breaksStartingThisLine)
rows.push('');
this.wrapWord(word, limit);
}
else {
if (rowLength && wordLength && rowLength + wordLength > limit)
rows.push('');
rows[rows.length - 1] += word;
}
});
return this.wrapEscapes(rows.map(value => value.trimRight()).join(Terminal.EOL)).split(Terminal.EOL);
}
wrapEscapes(characters) {
const slice = (index) => /\d[^m]*/.exec(characters.slice(index, index + INDENT));
const wrap = (code) => `${ESCAPES.values().next().value}[${code}m`;
let result = '';
let match;
let code;
let escapeCode;
[...characters].forEach((character, index) => {
result += character;
if (ESCAPES.has(character)) {
match = slice(index);
if (match && match[0]) {
code = parseFloat(match[0]);
escapeCode = code === DEFAULT_COLOR_CODE ? undefined : code;
}
}
if (escapeCode) {
code = ansiStyles.codes.get(escapeCode);
if (code) {
if (characters[index + 1] === Terminal.EOL)
result += wrap(code);
if (character === Terminal.EOL)
result += wrap(escapeCode);
}
}
});
return result;
}
wrapWord(word, limit) {
const rows = __classPrivateFieldGet(this, _Wrapper_rows, "f");
let isInsideEscape = false;
let visible = stringWidth(stripAnsi(rows[rows.length - 1] ?? ''));
[...word].forEach((character, index, characters) => {
const characterLength = stringWidth(character);
if (visible + characterLength <= limit) {
rows[rows.length - 1] += character;
}
else {
rows.push(character);
visible = 0;
}
if (ESCAPES.has(character))
isInsideEscape = true;
else if (isInsideEscape && character === 'm')
isInsideEscape = false;
else if (!isInsideEscape) {
visible += characterLength;
if (visible === limit && 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();
}
}
_Wrapper_rows = new WeakMap();

1
node_modules/stdout-update/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export { default } from './UpdateManager.js';

1
node_modules/stdout-update/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export { default } from './UpdateManager.js';

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.6.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-17.0.0": "^1.6.10",
"emoji-test-regex-pattern": "^2.4.0",
"mocha": "^11.7.2"
}
}

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

71
node_modules/stdout-update/package.json generated vendored Normal file
View File

@@ -0,0 +1,71 @@
{
"name": "stdout-update",
"version": "4.0.1",
"description": "Updates the previous output in the terminal. Useful for correct rendering progress bars, animations, etc.",
"license": "MIT",
"homepage": "https://github.com/keindev/stdout-update#readme",
"author": "Daniil Ryazanov <kein@tagproject.ru>",
"keywords": [
"cli",
"console",
"indicator",
"log",
"logger",
"logging",
"output",
"overwrite",
"progress",
"refresh",
"shell",
"stdout",
"term",
"terminal",
"update"
],
"bugs": "https://github.com/keindev/stdout-update/issues",
"types": "./lib/index.d.ts",
"type": "module",
"exports": {
".": "./lib/index.js",
"./lib/types": "./lib/types.js",
"./lib/Hook": "./lib/Hook.js",
"./lib/Terminal": "./lib/Terminal.js",
"./lib/Wrapper": "./lib/Wrapper.js"
},
"repository": {
"type": "git",
"url": "https://github.com/keindev/stdout-update.git"
},
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"build": "run-s build:*",
"build:ts": "rimraf lib && tsc --extendedDiagnostics",
"generate": "run-s generate:*",
"generate:changelog": "changelog generate --bump",
"generate:ghinfo": "ghinfo generate -d media -t utils",
"lint": "run-s lint:*",
"lint:eslint": "rimraf coverage && eslint src --ext .ts",
"lint:spell": "cspell -c .vscode/cspell.json --no-summary \"**/*.{js,ts,tsx,md,yml,json}\"",
"prepare": "run-s prepare:*",
"prepare:config": "ts-package-shared-config",
"prepare:docs": "docs-shared-config",
"prepare:husky": "husky install",
"prepare:vscode": "vscode-shared-config",
"release": "run-s prepare lint test build generate",
"test": "run-s test:*",
"test:jest": "node --experimental-vm-modules node_modules/.bin/jest"
},
"dependencies": {
"ansi-escapes": "^6.2.0",
"ansi-styles": "^6.2.1",
"string-width": "^7.1.0",
"strip-ansi": "^7.1.0"
},
"devDependencies": {
"@tagproject/ts-package-shared-config": "^11.0.4",
"@types/ansi-styles": "^4.2.0",
"ts-node": "^10.9.2"
}
}