@visulima/pail 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/LICENSE.md +3 -0
- package/dist/constants.d.ts +37 -0
- package/dist/index.browser.d.ts +47 -12
- package/dist/index.browser.js +1 -1
- package/dist/index.server.d.ts +65 -43
- package/dist/index.server.js +1 -3
- package/dist/interactive/index.d.ts +2 -28
- package/dist/interactive/interactive-manager.d.ts +108 -0
- package/dist/interactive/interactive-stream-hook.d.ts +68 -0
- package/dist/object-tree.d.ts +65 -7
- package/dist/packem_shared/{JsonReporter-BqWsVkHP.js → JsonReporter-C0AXk99i.js} +0 -2
- package/dist/packem_shared/{pail.browser-CPDOE_d1.js → pail.browser-CPjQrsyy.js} +3 -3
- package/dist/pail.browser.d.ts +412 -0
- package/dist/pail.server.d.ts +233 -0
- package/dist/processor/caller/caller-processor.d.ts +40 -7
- package/dist/processor/caller/get-caller-filename.d.ts +23 -0
- package/dist/processor/message-formatter-processor.d.ts +44 -9
- package/dist/processor/message-formatter-processor.js +1 -1
- package/dist/processor/opentelemetry-processor.d.ts +61 -10
- package/dist/processor/redact-processor.d.ts +39 -8
- package/dist/progress-bar.d.ts +75 -15
- package/dist/reporter/file/json-file-reporter.d.ts +39 -20
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +48 -0
- package/dist/reporter/http/abstract-http-reporter.d.ts +125 -12
- package/dist/reporter/http/http-reporter.d.ts +36 -10
- package/dist/reporter/http/http-reporter.edge-light.d.ts +37 -165
- package/dist/reporter/http/utils/compression.d.ts +7 -0
- package/dist/reporter/http/utils/log-size-error.d.ts +30 -0
- package/dist/reporter/http/utils/retry.d.ts +27 -0
- package/dist/reporter/json/abstract-json-reporter.d.ts +61 -0
- package/dist/reporter/json/index.browser.d.ts +3 -13
- package/dist/reporter/json/index.d.ts +3 -16
- package/dist/reporter/json/index.js +1 -1
- package/dist/reporter/json/json-reporter.browser.d.ts +40 -0
- package/dist/reporter/json/json-reporter.server.d.ts +50 -0
- package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +83 -0
- package/dist/reporter/pretty/index.browser.d.ts +2 -13
- package/dist/reporter/pretty/index.d.ts +2 -25
- package/dist/reporter/pretty/pretty-reporter.browser.d.ts +36 -0
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +70 -0
- package/dist/reporter/raw/raw-reporter.browser.d.ts +5 -0
- package/dist/reporter/raw/raw-reporter.server.d.ts +13 -0
- package/dist/reporter/simple/simple-reporter.server.d.ts +10 -14
- package/dist/reporter/utils/default-inspector-config.d.ts +3 -0
- package/dist/reporter/utils/format-label.d.ts +3 -0
- package/dist/spinner.d.ts +170 -104
- package/dist/spinner.js +89 -89
- package/dist/types.d.ts +241 -0
- package/dist/utils/ansi-escapes.d.ts +4 -0
- package/dist/utils/arrayify.d.ts +2 -0
- package/dist/utils/get-longest-badge.d.ts +4 -0
- package/dist/utils/get-longest-label.d.ts +4 -0
- package/dist/utils/merge-types.d.ts +4 -0
- package/dist/utils/stream/safe-stream-handler.d.ts +21 -0
- package/dist/utils/write-console-log-based-on-level.d.ts +4 -0
- package/dist/utils/write-stream.d.ts +2 -0
- package/package.json +3 -4
- package/dist/packem_shared/abstract-json-reporter-DiyVyU0j.d.ts +0 -22
- package/dist/packem_shared/abstract-pretty-reporter-BbOWXMCs.d.ts +0 -28
- package/dist/packem_shared/index.d-BR1GjZri.d.ts +0 -53
- package/dist/packem_shared/index.d-oxZvg_y7.d.ts +0 -20
- package/dist/packem_shared/pail.browser-By9KjOH7.d.ts +0 -69
- package/dist/packem_shared/types-D3ycu8-x.d.ts +0 -95
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
## @visulima/pail [3.2.2](https://github.com/visulima/visulima/compare/@visulima/pail@3.2.1...@visulima/pail@3.2.2) (2025-11-13)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* bump packem, to fix minified version of the code ([2a36ceb](https://github.com/visulima/visulima/commit/2a36ceb09251b0ca1178701a26547a871ed717a7))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* **@visulima/colorize:** upgraded to 1.4.29
|
|
11
|
+
* **@visulima/error:** upgraded to 5.0.6
|
|
12
|
+
* **@visulima/fmt:** upgraded to 1.1.21
|
|
13
|
+
* **@visulima/inspector:** upgraded to 1.0.30
|
|
14
|
+
* **@visulima/redact:** upgraded to 2.0.5
|
|
15
|
+
* **@visulima/string:** upgraded to 2.0.6
|
|
16
|
+
|
|
17
|
+
## @visulima/pail [3.2.1](https://github.com/visulima/visulima/compare/@visulima/pail@3.2.0...@visulima/pail@3.2.1) (2025-11-12)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **deps:** update type-fest dependency across multiple packages ([93e13be](https://github.com/visulima/visulima/commit/93e13be5248207968a96303710db2a0604d16b9b))
|
|
22
|
+
* update package configurations and TypeScript definitions ([b59aa59](https://github.com/visulima/visulima/commit/b59aa59dac1508216b944f4b917fb4a7ab1f70a4))
|
|
23
|
+
|
|
24
|
+
### Miscellaneous Chores
|
|
25
|
+
|
|
26
|
+
* Add jsr file to all packages for release ([#565](https://github.com/visulima/visulima/issues/565)) ([ec91652](https://github.com/visulima/visulima/commit/ec91652b4e4112adf14ba152c1239a7703ba425a))
|
|
27
|
+
* **pail:** add rslog logging to benchmarks ([c5675c8](https://github.com/visulima/visulima/commit/c5675c880a81a979a713771d6c82f6d2682daaaa))
|
|
28
|
+
* **pail:** integrate roarr logging into benchmarks ([563bb52](https://github.com/visulima/visulima/commit/563bb52b7311ad9a3bfc4de6a2ff0593b2cfcc44))
|
|
29
|
+
* **pail:** update benchmark results and add rslog performance metrics ([123e2b5](https://github.com/visulima/visulima/commit/123e2b533dc3a75e6bab45055a4055897824630b))
|
|
30
|
+
* update license files and clean up TypeScript definitions ([fe668cc](https://github.com/visulima/visulima/commit/fe668cc26de23591d4df54a0954455ebbe31b22d))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Dependencies
|
|
34
|
+
|
|
35
|
+
* **@visulima/colorize:** upgraded to 1.4.28
|
|
36
|
+
* **@visulima/error:** upgraded to 5.0.5
|
|
37
|
+
* **@visulima/fmt:** upgraded to 1.1.20
|
|
38
|
+
* **@visulima/inspector:** upgraded to 1.0.29
|
|
39
|
+
* **@visulima/redact:** upgraded to 2.0.4
|
|
40
|
+
* **@visulima/string:** upgraded to 2.0.5
|
|
41
|
+
|
|
1
42
|
## @visulima/pail [3.2.0](https://github.com/visulima/visulima/compare/@visulima/pail@3.1.0...@visulima/pail@3.2.0) (2025-11-07)
|
|
2
43
|
|
|
3
44
|
### Features
|
package/LICENSE.md
CHANGED
|
@@ -623,11 +623,14 @@ Repository: sindresorhus/terminal-size
|
|
|
623
623
|
<!-- TYPE_DEPENDENCIES -->
|
|
624
624
|
|
|
625
625
|
# Licenses of bundled types
|
|
626
|
+
|
|
626
627
|
The published @visulima/pail artifact additionally contains code with the following licenses:
|
|
627
628
|
MIT
|
|
628
629
|
|
|
629
630
|
# Bundled types:
|
|
631
|
+
|
|
630
632
|
## safe-stable-stringify
|
|
633
|
+
|
|
631
634
|
License: MIT
|
|
632
635
|
By: Ruben Bridgewater
|
|
633
636
|
Repository: git+https://github.com/BridgeAR/safe-stable-stringify.git
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DefaultLoggerTypes } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Extended RFC 5424 Log Levels
|
|
4
|
+
*
|
|
5
|
+
* The log levels pail uses are those defined in the syslog protocol.
|
|
6
|
+
* Each level is assigned a numeric priority where lower numbers indicate higher priority.
|
|
7
|
+
* @see https://datatracker.ietf.org/doc/html/rfc5424#page-36
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { EXTENDED_RFC_5424_LOG_LEVELS } from "@visulima/pail";
|
|
11
|
+
*
|
|
12
|
+
* console.log(EXTENDED_RFC_5424_LOG_LEVELS.error); // 5
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const EXTENDED_RFC_5424_LOG_LEVELS: Record<string, number>;
|
|
16
|
+
/**
|
|
17
|
+
* Default Logger Types Configuration
|
|
18
|
+
*
|
|
19
|
+
* Predefined logger types with their associated colors, labels, and log levels.
|
|
20
|
+
* These types provide semantic meaning to different kinds of log messages.
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { LOG_TYPES } from "@visulima/pail";
|
|
24
|
+
*
|
|
25
|
+
* console.log(LOG_TYPES.error.color); // "red"
|
|
26
|
+
* console.log(LOG_TYPES.success.label); // "success"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const LOG_TYPES: DefaultLoggerTypes;
|
|
30
|
+
/**
|
|
31
|
+
* Empty Symbol
|
|
32
|
+
*
|
|
33
|
+
* A unique symbol used internally to represent empty or undefined message values.
|
|
34
|
+
* This helps distinguish between intentional empty messages and undefined values.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare const EMPTY_SYMBOL: symbol;
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,12 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import type { PailBrowserType } from "./pail.d.ts";
|
|
2
|
+
import type { ConstructorOptions } from "./types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new Pail logger instance configured for browser environments.
|
|
5
|
+
*
|
|
6
|
+
* This factory function creates a browser-compatible logger with default processors
|
|
7
|
+
* and reporters suitable for client-side logging.
|
|
8
|
+
* @template T - Custom logger types
|
|
9
|
+
* @template L - Log level types
|
|
10
|
+
* @param options Configuration options for the logger
|
|
11
|
+
* @returns A new PailBrowser instance
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createPail } from "@visulima/pail";
|
|
15
|
+
*
|
|
16
|
+
* const logger = createPail({
|
|
17
|
+
* logLevel: "debug",
|
|
18
|
+
* types: {
|
|
19
|
+
* custom: {
|
|
20
|
+
* color: "blue",
|
|
21
|
+
* label: "CUSTOM",
|
|
22
|
+
* logLevel: "info"
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* logger.info("Hello world!");
|
|
28
|
+
* logger.custom("Custom message");
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const createPail: <T extends string = string, L extends string = string>(options?: ConstructorOptions<T, L>) => PailBrowserType<T, L>;
|
|
32
|
+
/**
|
|
33
|
+
* Default Pail logger instance for browser environments.
|
|
34
|
+
*
|
|
35
|
+
* A pre-configured logger instance ready for immediate use in browser environments.
|
|
36
|
+
* Uses default configuration with JSON reporter and message formatter processor.
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { pail } from "@visulima/pail";
|
|
40
|
+
*
|
|
41
|
+
* pail.info("Application started");
|
|
42
|
+
* pail.error("Something went wrong", new Error("Test error"));
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const pail: PailBrowserType<string, string>;
|
|
46
|
+
export type { PailBrowserType as Pail } from "./pail.d.ts";
|
|
47
|
+
export type { ConstructorOptions, DefaultLoggerTypes, DefaultLogTypes, ExtendedRfc5424LogLevels, LoggerConfiguration, LoggerFunction, LoggerTypesAwareReporter, LoggerTypesConfig, Processor, Reporter, StreamAwareReporter, } from "./types.d.ts";
|
package/dist/index.browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PailBrowser } from './packem_shared/pail.browser-
|
|
1
|
+
import { P as PailBrowser } from './packem_shared/pail.browser-CPjQrsyy.js';
|
|
2
2
|
import MessageFormatterProcessor from './processor/message-formatter-processor.js';
|
|
3
3
|
import JsonReporter from './packem_shared/JsonReporter-DcM2LBX9.js';
|
|
4
4
|
|
package/dist/index.server.d.ts
CHANGED
|
@@ -1,43 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
import type { PailServerType } from "./pail.d.ts";
|
|
2
|
+
import type { ServerConstructorOptions } from "./types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new Pail logger instance configured for server environments.
|
|
5
|
+
*
|
|
6
|
+
* This factory function creates a server-compatible logger with default processors
|
|
7
|
+
* and reporters suitable for Node.js environments. It automatically configures
|
|
8
|
+
* log levels based on environment variables and sets up pretty printing.
|
|
9
|
+
* @template T - Custom logger types
|
|
10
|
+
* @template L - Log level types
|
|
11
|
+
* @param options Configuration options for the logger
|
|
12
|
+
* @returns A new PailServer instance
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { createPail } from "@visulima/pail";
|
|
16
|
+
*
|
|
17
|
+
* const logger = createPail({
|
|
18
|
+
* logLevel: "debug",
|
|
19
|
+
* types: {
|
|
20
|
+
* http: {
|
|
21
|
+
* color: "blue",
|
|
22
|
+
* label: "HTTP",
|
|
23
|
+
* logLevel: "info"
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* logger.info("Server started on port 3000");
|
|
29
|
+
* logger.http("GET /api/users 200");
|
|
30
|
+
* ```
|
|
31
|
+
* @example
|
|
32
|
+
* ```bash
|
|
33
|
+
* # Control log level via environment variable
|
|
34
|
+
* PAIL_LOG_LEVEL=debug node app.js
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const createPail: <T extends string = string, L extends string = string>(options?: ServerConstructorOptions<T, L>) => PailServerType<T, L>;
|
|
38
|
+
/**
|
|
39
|
+
* Default Pail logger instance for server environments.
|
|
40
|
+
*
|
|
41
|
+
* A pre-configured logger instance ready for immediate use in Node.js environments.
|
|
42
|
+
* Uses default configuration with pretty reporter, message formatter processor,
|
|
43
|
+
* and automatic log level detection based on environment variables.
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { pail } from "@visulima/pail";
|
|
47
|
+
*
|
|
48
|
+
* pail.info("Server listening on port 3000");
|
|
49
|
+
* pail.error("Database connection failed", error);
|
|
50
|
+
* pail.success("Migration completed successfully");
|
|
51
|
+
* ```
|
|
52
|
+
* @example
|
|
53
|
+
* ```bash
|
|
54
|
+
* # Set log level via environment
|
|
55
|
+
* NODE_ENV=production node app.js
|
|
56
|
+
* PAIL_LOG_LEVEL=debug node app.js
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const pail: PailServerType<string, string>;
|
|
60
|
+
export type { PailServerType as Pail } from "./pail.d.ts";
|
|
61
|
+
export type { MultiBarOptions, ProgressBarOptions, ProgressBarPayload, ProgressBarStyle, SingleBarOptions } from "./progress-bar.d.ts";
|
|
62
|
+
export { getBarChar, MultiProgressBar, ProgressBar } from "./progress-bar.d.ts";
|
|
63
|
+
export type { SpinnerIcons, SpinnerOptions, SpinnerStartOptions, SpinnerStyle } from "./spinner.d.ts";
|
|
64
|
+
export { MultiSpinner, Spinner } from "./spinner.d.ts";
|
|
65
|
+
export type { ConstructorOptions, DefaultLoggerTypes, DefaultLogTypes, ExtendedRfc5424LogLevels, LoggerConfiguration, LoggerFunction, LoggerTypesAwareReporter, LoggerTypesConfig, Processor, Reporter, StreamAwareReporter, } from "./types.d.ts";
|
package/dist/index.server.js
CHANGED
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
} = __cjs_getProcess;
|
|
12
12
|
import InteractiveManager from './packem_shared/InteractiveManager-CZ85hGNW.js';
|
|
13
13
|
import { I as InteractiveStreamHook, c as clearTerminal } from './packem_shared/interactive-stream-hook-DG4BtN12.js';
|
|
14
|
-
import { a as PailBrowserImpl, m as mergeTypes, b as arrayify } from './packem_shared/pail.browser-
|
|
14
|
+
import { a as PailBrowserImpl, m as mergeTypes, b as arrayify } from './packem_shared/pail.browser-CPjQrsyy.js';
|
|
15
15
|
import { ProgressBar, applyStyleToOptions, MultiProgressBar } from './progress-bar.js';
|
|
16
16
|
export { getBarChar } from './progress-bar.js';
|
|
17
17
|
import { i as inspect } from './packem_shared/format-label-Btft2KGP.js';
|
|
@@ -33,11 +33,9 @@ class RawReporter {
|
|
|
33
33
|
this.#stderr = stderr;
|
|
34
34
|
this.#inspectOptions = inspectOptions;
|
|
35
35
|
}
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
37
36
|
setStdout(stdout_) {
|
|
38
37
|
this.#stdout = stdout_;
|
|
39
38
|
}
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
41
39
|
setStderr(stderr_) {
|
|
42
40
|
this.#stderr = stderr_;
|
|
43
41
|
}
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
static readonly DRAIN = true;
|
|
4
|
-
constructor(stream: NodeJS.WriteStream);
|
|
5
|
-
active(): void;
|
|
6
|
-
erase(count: number): void;
|
|
7
|
-
inactive(separateHistory?: boolean): void;
|
|
8
|
-
renew(): void;
|
|
9
|
-
write(message: string): void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type StreamType = "stderr" | "stdout";
|
|
13
|
-
declare class InteractiveManager {
|
|
14
|
-
#private;
|
|
15
|
-
constructor(stdout: InteractiveStreamHook, stderr: InteractiveStreamHook);
|
|
16
|
-
get lastLength(): number;
|
|
17
|
-
get outside(): number;
|
|
18
|
-
get isHooked(): boolean;
|
|
19
|
-
get isSuspended(): boolean;
|
|
20
|
-
erase(stream: StreamType, count?: number): void;
|
|
21
|
-
hook(): boolean;
|
|
22
|
-
resume(stream: StreamType, eraseRowCount?: number): void;
|
|
23
|
-
suspend(stream: StreamType, erase?: boolean): void;
|
|
24
|
-
unhook(separateHistory?: boolean): boolean;
|
|
25
|
-
update(stream: StreamType, rows: string[], from?: number): void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { InteractiveManager, InteractiveStreamHook };
|
|
1
|
+
export { default as InteractiveManager } from "./interactive-manager.d.ts";
|
|
2
|
+
export { default as InteractiveStreamHook } from "./interactive-stream-hook.d.ts";
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type InteractiveStreamHook from "./interactive-stream-hook.d.ts";
|
|
2
|
+
/** Supported stream types for interactive output */
|
|
3
|
+
type StreamType = "stderr" | "stdout";
|
|
4
|
+
/**
|
|
5
|
+
* Interactive Manager.
|
|
6
|
+
*
|
|
7
|
+
* Manages interactive terminal output by coordinating stdout and stderr streams.
|
|
8
|
+
* Enables features like progress bars, spinners, and dynamic updates by temporarily
|
|
9
|
+
* capturing and controlling terminal output. Supports suspending and resuming
|
|
10
|
+
* interactive mode for external output.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const manager = new InteractiveManager(stdoutHook, stderrHook);
|
|
14
|
+
*
|
|
15
|
+
* // Start interactive mode
|
|
16
|
+
* manager.hook();
|
|
17
|
+
*
|
|
18
|
+
* // Update output dynamically
|
|
19
|
+
* manager.update("stdout", ["Processing...", "50% complete"]);
|
|
20
|
+
*
|
|
21
|
+
* // Temporarily suspend for external output
|
|
22
|
+
* manager.suspend("stdout");
|
|
23
|
+
* console.log("External message");
|
|
24
|
+
* manager.resume("stdout");
|
|
25
|
+
*
|
|
26
|
+
* // End interactive mode and show final output
|
|
27
|
+
* manager.unhook();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare class InteractiveManager {
|
|
31
|
+
#private;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new InteractiveManager with the given stream hooks.
|
|
34
|
+
* @param stdout Hook for stdout stream
|
|
35
|
+
* @param stderr Hook for stderr stream
|
|
36
|
+
*/
|
|
37
|
+
constructor(stdout: InteractiveStreamHook, stderr: InteractiveStreamHook);
|
|
38
|
+
/**
|
|
39
|
+
* Last printed rows count.
|
|
40
|
+
*
|
|
41
|
+
* Tracks the number of rows that were last written to the terminal.
|
|
42
|
+
* Used internally for managing cursor positioning and output updates.
|
|
43
|
+
*/
|
|
44
|
+
get lastLength(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Rows count outside editable area.
|
|
47
|
+
*
|
|
48
|
+
* Tracks the number of rows that extend beyond the current terminal height.
|
|
49
|
+
* Used for managing scrolling and ensuring all output remains visible.
|
|
50
|
+
*/
|
|
51
|
+
get outside(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Hook activity status.
|
|
54
|
+
*
|
|
55
|
+
* Indicates whether the interactive hooks are currently active.
|
|
56
|
+
* When true, streams are being intercepted for interactive output.
|
|
57
|
+
*/
|
|
58
|
+
get isHooked(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Suspend status for active hooks.
|
|
61
|
+
*
|
|
62
|
+
* Indicates whether interactive mode is temporarily suspended.
|
|
63
|
+
* When suspended, external output can be written without interference.
|
|
64
|
+
*/
|
|
65
|
+
get isSuspended(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Removes lines from the terminal output.
|
|
68
|
+
*
|
|
69
|
+
* Erases the specified number of lines from the bottom of the output,
|
|
70
|
+
* moving the cursor up and clearing the lines. Useful for removing
|
|
71
|
+
* previous interactive output before displaying new content.
|
|
72
|
+
* @param stream The stream to erase lines from ("stdout" or "stderr")
|
|
73
|
+
* @param count Number of lines to remove (defaults to lastLength)
|
|
74
|
+
* @throws {TypeError} If the specified stream is not available
|
|
75
|
+
*/
|
|
76
|
+
erase(stream: StreamType, count?: number): void;
|
|
77
|
+
/**
|
|
78
|
+
* Hook stdout and stderr streams.
|
|
79
|
+
* @returns Success status
|
|
80
|
+
*/
|
|
81
|
+
hook(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Resume suspend hooks.
|
|
84
|
+
* @param stream Stream to resume
|
|
85
|
+
* @param eraseRowCount erase output rows count
|
|
86
|
+
*/
|
|
87
|
+
resume(stream: StreamType, eraseRowCount?: number): void;
|
|
88
|
+
/**
|
|
89
|
+
* Suspend active hooks for external output.
|
|
90
|
+
* @param stream Stream to suspend
|
|
91
|
+
* @param erase erase output
|
|
92
|
+
*/
|
|
93
|
+
suspend(stream: StreamType, erase?: boolean): void;
|
|
94
|
+
/**
|
|
95
|
+
* Unhooks both stdout and stderr streams and print their story of logs.
|
|
96
|
+
* @param separateHistory If `true`, will add an empty line to the history output for individual recorded lines and console logs
|
|
97
|
+
* @returns Success status
|
|
98
|
+
*/
|
|
99
|
+
unhook(separateHistory?: boolean): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Update output.
|
|
102
|
+
* @param stream Stream to write to
|
|
103
|
+
* @param rows Text lines to write to standard output
|
|
104
|
+
* @param from Index of the line starting from which the contents of the terminal are being overwritten
|
|
105
|
+
*/
|
|
106
|
+
update(stream: StreamType, rows: string[], from?: number): void;
|
|
107
|
+
}
|
|
108
|
+
export default InteractiveManager;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive Stream Hook.
|
|
3
|
+
*
|
|
4
|
+
* A utility class that hooks into Node.js WriteStreams to capture output
|
|
5
|
+
* for interactive terminal applications. It allows temporarily intercepting
|
|
6
|
+
* stream writes to enable features like progress bars and dynamic updates.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const hook = new InteractiveStreamHook(process.stdout);
|
|
10
|
+
* hook.active(); // Start capturing output
|
|
11
|
+
*
|
|
12
|
+
* // Output will be stored in history instead of being written to stdout
|
|
13
|
+
* console.log("This won't appear immediately");
|
|
14
|
+
*
|
|
15
|
+
* hook.inactive(); // Stop capturing and replay stored output
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare class InteractiveStreamHook {
|
|
19
|
+
#private;
|
|
20
|
+
/** Constant indicating the stream write operation was successful */
|
|
21
|
+
static readonly DRAIN = true;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new InteractiveStreamHook for the given stream.
|
|
24
|
+
* @param stream The Node.js WriteStream to hook into (usually stdout or stderr)
|
|
25
|
+
*/
|
|
26
|
+
constructor(stream: NodeJS.WriteStream);
|
|
27
|
+
/**
|
|
28
|
+
* Activates the stream hook.
|
|
29
|
+
*
|
|
30
|
+
* When active, all writes to the stream are captured in history instead of
|
|
31
|
+
* being written immediately. This allows for interactive features like
|
|
32
|
+
* progress bars that can update dynamically.
|
|
33
|
+
*/
|
|
34
|
+
active(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Erases the specified number of lines from the terminal.
|
|
37
|
+
*
|
|
38
|
+
* Uses ANSI escape sequences to remove lines from the current cursor position
|
|
39
|
+
* upwards, which is useful for clearing previous output in interactive applications.
|
|
40
|
+
* @param count Number of lines to erase (including the current line)
|
|
41
|
+
*/
|
|
42
|
+
erase(count: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Deactivates the stream hook and replays captured output.
|
|
45
|
+
*
|
|
46
|
+
* Restores normal stream operation and outputs all captured history.
|
|
47
|
+
* Optionally adds a newline separator before replaying the history.
|
|
48
|
+
* @param separateHistory Whether to add a newline before replaying history
|
|
49
|
+
*/
|
|
50
|
+
inactive(separateHistory?: boolean): void;
|
|
51
|
+
/**
|
|
52
|
+
* Renews the stream hook state.
|
|
53
|
+
*
|
|
54
|
+
* Restores the original stream write method and shows the cursor.
|
|
55
|
+
* This is typically called when temporarily suspending interactive mode.
|
|
56
|
+
*/
|
|
57
|
+
renew(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Writes a message directly to the underlying stream.
|
|
60
|
+
*
|
|
61
|
+
* Bypasses the hook mechanism and writes directly using the original
|
|
62
|
+
* stream write method. Useful for writing control sequences or
|
|
63
|
+
* messages that should not be captured in history.
|
|
64
|
+
* @param message The message to write to the stream
|
|
65
|
+
*/
|
|
66
|
+
write(message: string): void;
|
|
67
|
+
}
|
|
68
|
+
export default InteractiveStreamHook;
|
package/dist/object-tree.d.ts
CHANGED
|
@@ -1,17 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Function to render a node value for display
|
|
3
|
+
* @param node The node to render
|
|
4
|
+
* @returns A string representation or undefined if should not render
|
|
5
|
+
*/
|
|
6
|
+
export type TreeRenderFunction = (node: unknown) => string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Function to sort keys during tree traversal
|
|
9
|
+
* @param a First key for comparison
|
|
10
|
+
* @param b Second key for comparison
|
|
11
|
+
* @returns Negative if a < b, positive if a > b, 0 if equal
|
|
12
|
+
*/
|
|
13
|
+
export type TreeSortFunction = (a: string, b: string) => number;
|
|
14
|
+
/**
|
|
15
|
+
* Configuration options for object tree rendering
|
|
16
|
+
*/
|
|
17
|
+
export interface ObjectTreeOptions {
|
|
18
|
+
/** Text to display for circular references (default: " (circular ref.)") */
|
|
4
19
|
breakCircularWith?: string | null | undefined;
|
|
20
|
+
/** Whether to return as single string or array of lines (default: true) */
|
|
5
21
|
joined?: boolean;
|
|
22
|
+
/** Connector for neighbor keys (default: "├─ ") */
|
|
6
23
|
keyNeighbour?: string;
|
|
24
|
+
/** Connector for non-neighbor keys (default: "└─ ") */
|
|
7
25
|
keyNoNeighbour?: string;
|
|
26
|
+
/** Function to render node values (default: renders primitives) */
|
|
8
27
|
renderFn?: TreeRenderFunction;
|
|
28
|
+
/** Separator between key and value (default: ": ") */
|
|
9
29
|
separator?: string;
|
|
30
|
+
/** Function to sort object keys (default: natural order) */
|
|
10
31
|
sortFn?: TreeSortFunction | undefined;
|
|
32
|
+
/** Spacer for neighbor branches (default: "│ ") */
|
|
11
33
|
spacerNeighbour?: string;
|
|
34
|
+
/** Spacer for non-neighbor branches (default: " ") */
|
|
12
35
|
spacerNoNeighbour?: string;
|
|
13
36
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Renders an object as an ASCII tree structure.
|
|
39
|
+
* @param tree The object to render as a tree
|
|
40
|
+
* @param options Configuration options for tree rendering
|
|
41
|
+
* @returns Formatted tree as string or array of lines
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const obj = {
|
|
45
|
+
* name: "John",
|
|
46
|
+
* age: 30,
|
|
47
|
+
* address: {
|
|
48
|
+
* street: "Main St",
|
|
49
|
+
* city: "New York"
|
|
50
|
+
* }
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* // Default output as string
|
|
54
|
+
* console.log(renderObjectTree(obj));
|
|
55
|
+
*
|
|
56
|
+
* // Custom rendering
|
|
57
|
+
* console.log(renderObjectTree(obj, {
|
|
58
|
+
* sortFn: (a, b) => a.localeCompare(b),
|
|
59
|
+
* renderFn: (node) => {
|
|
60
|
+
* if (typeof node === 'string') return node.toUpperCase();
|
|
61
|
+
* return ['boolean', 'string', 'number'].includes(typeof node)
|
|
62
|
+
* ? String(node)
|
|
63
|
+
* : undefined;
|
|
64
|
+
* }
|
|
65
|
+
* }));
|
|
66
|
+
*
|
|
67
|
+
* // Get as array of lines
|
|
68
|
+
* const lines = renderObjectTree(obj, { joined: false });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const renderObjectTree: (tree: Record<string, unknown> | unknown[], options?: ObjectTreeOptions) => string | string[];
|
|
72
|
+
/**
|
|
73
|
+
* Default export for CommonJS compatibility
|
|
74
|
+
*/
|
|
75
|
+
export default renderObjectTree;
|
|
@@ -29,7 +29,6 @@ class JsonReporter extends AbstractJsonReporter {
|
|
|
29
29
|
* Sets the stdout stream for the reporter.
|
|
30
30
|
* @param stdout_ The writable stream to use for stdout output
|
|
31
31
|
*/
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
33
32
|
setStdout(stdout_) {
|
|
34
33
|
this.#stdout = stdout_;
|
|
35
34
|
}
|
|
@@ -37,7 +36,6 @@ class JsonReporter extends AbstractJsonReporter {
|
|
|
37
36
|
* Sets the stderr stream for the reporter.
|
|
38
37
|
* @param stderr_ The writable stream to use for stderr output
|
|
39
38
|
*/
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
41
39
|
setStderr(stderr_) {
|
|
42
40
|
this.#stderr = stderr_;
|
|
43
41
|
}
|
|
@@ -13,14 +13,14 @@ var hasRequiredSafeStableStringify;
|
|
|
13
13
|
function requireSafeStableStringify () {
|
|
14
14
|
if (hasRequiredSafeStableStringify) return safeStableStringify.exports;
|
|
15
15
|
hasRequiredSafeStableStringify = 1;
|
|
16
|
-
(function (module, exports) {
|
|
16
|
+
(function (module, exports$1) {
|
|
17
17
|
const { hasOwnProperty } = Object.prototype;
|
|
18
18
|
const stringify = configure();
|
|
19
19
|
stringify.configure = configure;
|
|
20
20
|
stringify.stringify = stringify;
|
|
21
21
|
stringify.default = stringify;
|
|
22
|
-
exports.stringify = stringify;
|
|
23
|
-
exports.configure = configure;
|
|
22
|
+
exports$1.stringify = stringify;
|
|
23
|
+
exports$1.configure = configure;
|
|
24
24
|
module.exports = stringify;
|
|
25
25
|
const strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
|
|
26
26
|
function strEscape(str) {
|