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

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