@visulima/pail 3.0.3 → 3.2.0
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 +47 -0
- package/LICENSE.md +18 -391
- package/README.md +578 -0
- package/dist/index.browser.d.ts +4 -3
- package/dist/index.browser.js +12 -1
- package/dist/index.server.d.ts +19 -74
- package/dist/index.server.js +535 -5
- package/dist/interactive/index.d.ts +28 -0
- package/dist/interactive/index.js +2 -0
- package/dist/object-tree.d.ts +17 -0
- package/dist/object-tree.js +89 -0
- package/dist/packem_shared/AbstractJsonReporter-intFdT_A.js +204 -0
- package/dist/packem_shared/InteractiveManager-CZ85hGNW.js +172 -0
- package/dist/packem_shared/InteractiveStreamHook-DiSubbJ1.js +21 -0
- package/dist/packem_shared/JsonReporter-BqWsVkHP.js +60 -0
- package/dist/packem_shared/JsonReporter-DcM2LBX9.js +28 -0
- package/dist/packem_shared/PrettyReporter-BFWaYP_J.js +222 -0
- package/dist/packem_shared/PrettyReporter-CuLLKr6-.js +169 -0
- package/dist/packem_shared/{abstract-json-reporter-wUti0B3k.d.ts → abstract-json-reporter-DiyVyU0j.d.ts} +3 -3
- package/dist/packem_shared/{abstract-pretty-reporter-MOYolfGR.d.ts → abstract-pretty-reporter-BbOWXMCs.d.ts} +1 -1
- package/dist/packem_shared/abstract-pretty-reporter-DMPDCslJ.js +50 -0
- package/dist/packem_shared/constants-DfDr4MHC.js +119 -0
- package/dist/packem_shared/format-label-Btft2KGP.js +1194 -0
- package/dist/packem_shared/get-longest-label-C9PWeyKq.js +9 -0
- package/dist/packem_shared/index-BomQ3E6J.js +650 -0
- package/dist/packem_shared/index-DqKWykfa.js +1146 -0
- package/dist/packem_shared/interactive-stream-hook-DG4BtN12.js +141 -0
- package/dist/packem_shared/{pail.browser-Bs2ng_Qj.d.ts → pail.browser-By9KjOH7.d.ts} +8 -3
- package/dist/packem_shared/pail.browser-CPDOE_d1.js +1427 -0
- package/dist/packem_shared/{types-RidvA4RN.d.ts → types-D3ycu8-x.d.ts} +2 -29
- package/dist/packem_shared/write-console-log-based-on-level-DBmRYXpj.js +14 -0
- package/dist/packem_shared/write-stream-BG8fhcs3.js +6 -0
- package/dist/processor/caller/caller-processor.d.ts +2 -1
- package/dist/processor/caller/caller-processor.js +59 -1
- package/dist/processor/message-formatter-processor.d.ts +2 -1
- package/dist/processor/message-formatter-processor.js +67 -1
- package/dist/processor/opentelemetry-processor.d.ts +19 -0
- package/dist/processor/opentelemetry-processor.js +52 -0
- package/dist/processor/redact-processor.d.ts +2 -1
- package/dist/processor/redact-processor.js +30 -1
- package/dist/progress-bar.d.ts +76 -0
- package/dist/progress-bar.js +404 -0
- package/dist/reporter/file/json-file-reporter.d.ts +3 -2
- package/dist/reporter/file/json-file-reporter.js +136 -4
- package/dist/reporter/http/abstract-http-reporter.d.ts +102 -0
- package/dist/reporter/http/abstract-http-reporter.js +435 -0
- package/dist/reporter/http/http-reporter.d.ts +13 -0
- package/dist/reporter/http/http-reporter.edge-light.d.ts +168 -0
- package/dist/reporter/http/http-reporter.edge-light.js +651 -0
- package/dist/reporter/http/http-reporter.js +13 -0
- package/dist/reporter/json/index.browser.d.ts +3 -2
- package/dist/reporter/json/index.browser.js +2 -1
- package/dist/reporter/json/index.d.ts +3 -2
- package/dist/reporter/json/index.js +2 -1
- package/dist/reporter/pretty/index.browser.d.ts +3 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +3 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +3 -2
- package/dist/reporter/simple/simple-reporter.server.js +186 -8
- package/dist/spinner.d.ts +154 -0
- package/dist/spinner.js +2150 -0
- package/package.json +69 -3
- package/dist/packem_shared/AbstractJsonReporter-UftN6CIL.js +0 -1
- package/dist/packem_shared/JsonReporter-DTBtHNaD.js +0 -2
- package/dist/packem_shared/JsonReporter-Dl4m0xZe.js +0 -1
- package/dist/packem_shared/PrettyReporter-APmxUrnh.js +0 -12
- package/dist/packem_shared/PrettyReporter-CGKSTI7X.js +0 -5
- package/dist/packem_shared/abstract-pretty-reporter-CUtSm20r.js +0 -1
- package/dist/packem_shared/constants-DKfCaSUR.js +0 -1
- package/dist/packem_shared/format-label-DqvZRRR6.js +0 -33
- package/dist/packem_shared/get-longest-label-B0NrI-o2.js +0 -1
- package/dist/packem_shared/getBarChar-mKDZW32R.js +0 -1
- package/dist/packem_shared/index-D9hWq9ka.js +0 -1
- package/dist/packem_shared/pail.browser-BmHoDvEA.js +0 -19
- package/dist/packem_shared/write-console-log-based-on-level-BP95fgQZ.js +0 -1
- package/dist/packem_shared/write-stream-CD8XFv1L.js +0 -1
|
@@ -1,32 +1,6 @@
|
|
|
1
1
|
import { AnsiColors } from '@visulima/colorize';
|
|
2
2
|
import { LiteralUnion, Primitive } from 'type-fest';
|
|
3
|
-
|
|
4
|
-
declare class InteractiveStreamHook {
|
|
5
|
-
#private;
|
|
6
|
-
static readonly DRAIN = true;
|
|
7
|
-
constructor(stream: NodeJS.WriteStream);
|
|
8
|
-
active(): void;
|
|
9
|
-
erase(count: number): void;
|
|
10
|
-
inactive(separateHistory?: boolean): void;
|
|
11
|
-
renew(): void;
|
|
12
|
-
write(message: string): void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type StreamType = "stderr" | "stdout";
|
|
16
|
-
declare class InteractiveManager {
|
|
17
|
-
#private;
|
|
18
|
-
constructor(stdout: InteractiveStreamHook, stderr: InteractiveStreamHook);
|
|
19
|
-
get lastLength(): number;
|
|
20
|
-
get outside(): number;
|
|
21
|
-
get isHooked(): boolean;
|
|
22
|
-
get isSuspended(): boolean;
|
|
23
|
-
erase(stream: StreamType, count?: number): void;
|
|
24
|
-
hook(): boolean;
|
|
25
|
-
resume(stream: StreamType, eraseRowCount?: number): void;
|
|
26
|
-
suspend(stream: StreamType, erase?: boolean): void;
|
|
27
|
-
unhook(separateHistory?: boolean): boolean;
|
|
28
|
-
update(stream: StreamType, rows: string[], from?: number): void;
|
|
29
|
-
}
|
|
3
|
+
import { InteractiveManager } from '../interactive/index.js';
|
|
30
4
|
|
|
31
5
|
declare global {
|
|
32
6
|
namespace VisulimaPail {
|
|
@@ -118,5 +92,4 @@ type Message = {
|
|
|
118
92
|
suffix?: string;
|
|
119
93
|
};
|
|
120
94
|
|
|
121
|
-
export {
|
|
122
|
-
export type { ConstructorOptions as C, DefaultLoggerTypes as D, ExtendedRfc5424LogLevels as E, LoggerConfiguration as L, Meta as M, Processor as P, Reporter as R, StreamAwareReporter as S, DefaultLogTypes as a, LoggerFunction as b, LoggerTypesAwareReporter as c, LoggerTypesConfig as d, ServerConstructorOptions as e, StringifyAwareProcessor as f, StringifyAwareReporter as g, ReadonlyMeta as h, InteractiveStreamReporter as i };
|
|
95
|
+
export type { ConstructorOptions as C, DefaultLoggerTypes as D, ExtendedRfc5424LogLevels as E, InteractiveStreamReporter as I, LoggerConfiguration as L, Meta as M, Processor as P, Reporter as R, StreamAwareReporter as S, DefaultLogTypes as a, LoggerFunction as b, LoggerTypesAwareReporter as c, LoggerTypesConfig as d, ReadonlyMeta as e, StringifyAwareReporter as f, ServerConstructorOptions as g, StringifyAwareProcessor as h };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const writeConsoleLogBasedOnLevel = (level) => {
|
|
2
|
+
if (level === "error") {
|
|
3
|
+
return console.__error ?? console.error;
|
|
4
|
+
}
|
|
5
|
+
if (level === "warn") {
|
|
6
|
+
return console.__warn ?? console.warn;
|
|
7
|
+
}
|
|
8
|
+
if (level === "trace") {
|
|
9
|
+
return console.__trace ?? console.trace;
|
|
10
|
+
}
|
|
11
|
+
return console.__log ?? console.log;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { writeConsoleLogBasedOnLevel as w };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { P as Processor, M as Meta } from '../../packem_shared/types-
|
|
1
|
+
import { P as Processor, M as Meta } from '../../packem_shared/types-D3ycu8-x.js';
|
|
2
2
|
import '@visulima/colorize';
|
|
3
3
|
import 'type-fest';
|
|
4
|
+
import '../../interactive/index.js';
|
|
4
5
|
|
|
5
6
|
declare global {
|
|
6
7
|
namespace VisulimaPail {
|
|
@@ -1 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
const getCallerFilename = () => {
|
|
2
|
+
const errorStack = Error.prepareStackTrace;
|
|
3
|
+
try {
|
|
4
|
+
let result = [];
|
|
5
|
+
Error.prepareStackTrace = (_error, stack) => {
|
|
6
|
+
const callSitesWithoutCurrent = stack.slice(1);
|
|
7
|
+
result = callSitesWithoutCurrent;
|
|
8
|
+
return callSitesWithoutCurrent;
|
|
9
|
+
};
|
|
10
|
+
const callers = result.reduce((accumulator, x) => {
|
|
11
|
+
if (x.isNative() || x.getFileName()?.includes("pail/dist")) {
|
|
12
|
+
return accumulator;
|
|
13
|
+
}
|
|
14
|
+
accumulator.push({
|
|
15
|
+
columnNumber: x.getColumnNumber(),
|
|
16
|
+
fileName: x.getFileName() ?? void 0,
|
|
17
|
+
lineNumber: x.getLineNumber()
|
|
18
|
+
});
|
|
19
|
+
return accumulator;
|
|
20
|
+
}, []);
|
|
21
|
+
const firstExternalFilePath = callers[0];
|
|
22
|
+
if (firstExternalFilePath) {
|
|
23
|
+
return {
|
|
24
|
+
columnNumber: firstExternalFilePath.columnNumber ?? void 0,
|
|
25
|
+
fileName: firstExternalFilePath.fileName,
|
|
26
|
+
lineNumber: firstExternalFilePath.lineNumber ?? void 0
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
fileName: "anonymous",
|
|
31
|
+
lineNumber: void 0
|
|
32
|
+
};
|
|
33
|
+
} finally {
|
|
34
|
+
Error.prepareStackTrace = errorStack;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
class CallerProcessor {
|
|
39
|
+
/**
|
|
40
|
+
* Processes log metadata to add caller file information.
|
|
41
|
+
*
|
|
42
|
+
* Analyzes the call stack to determine the file location where the log
|
|
43
|
+
* was called from and adds this information to the metadata.
|
|
44
|
+
* @param meta The log metadata to process
|
|
45
|
+
* @returns The processed metadata with file location information added
|
|
46
|
+
*/
|
|
47
|
+
// eslint-disable-next-line class-methods-use-this
|
|
48
|
+
process(meta) {
|
|
49
|
+
const { columnNumber, fileName, lineNumber } = getCallerFilename();
|
|
50
|
+
meta.file = {
|
|
51
|
+
column: columnNumber,
|
|
52
|
+
line: lineNumber,
|
|
53
|
+
name: fileName
|
|
54
|
+
};
|
|
55
|
+
return meta;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { CallerProcessor as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as StringifyAwareProcessor, M as Meta } from '../packem_shared/types-D3ycu8-x.js';
|
|
2
2
|
import '@visulima/colorize';
|
|
3
3
|
import 'type-fest';
|
|
4
|
+
import '../interactive/index.js';
|
|
4
5
|
|
|
5
6
|
type FormatterFunction = (argument: any) => string;
|
|
6
7
|
|
|
@@ -1 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
import { b as build } from '../packem_shared/index-BomQ3E6J.js';
|
|
2
|
+
|
|
3
|
+
class MessageFormatterProcessor {
|
|
4
|
+
/** Custom stringify function for object serialization */
|
|
5
|
+
#stringify;
|
|
6
|
+
/** Custom formatters for message interpolation */
|
|
7
|
+
#formatters;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new MessageFormatterProcessor instance.
|
|
10
|
+
* @param options Configuration options
|
|
11
|
+
* @param options.formatters Custom formatters for message interpolation
|
|
12
|
+
*/
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.#formatters = options.formatters;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sets the stringify function for object serialization.
|
|
18
|
+
* @param function_ The stringify function to use for serializing objects
|
|
19
|
+
*/
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
21
|
+
setStringify(function_) {
|
|
22
|
+
this.#stringify = function_;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Processes log metadata to format messages.
|
|
26
|
+
*
|
|
27
|
+
* Applies string interpolation and custom formatters to the message
|
|
28
|
+
* and contextual data in the log metadata.
|
|
29
|
+
* @param meta The log metadata to process
|
|
30
|
+
* @returns The processed metadata with formatted messages
|
|
31
|
+
*/
|
|
32
|
+
process(meta) {
|
|
33
|
+
const formatter = build({
|
|
34
|
+
formatters: this.#formatters});
|
|
35
|
+
if (meta.message !== void 0) {
|
|
36
|
+
meta.message = this.#format(formatter, meta.message, meta.context ?? []);
|
|
37
|
+
}
|
|
38
|
+
return meta;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Recursively formats data using the formatter.
|
|
42
|
+
*
|
|
43
|
+
* Applies string interpolation and formatting to strings, arrays, and objects.
|
|
44
|
+
* @param formatter The formatter function to use
|
|
45
|
+
* @param data The data to format (string, array, or object)
|
|
46
|
+
* @param arguments_ Additional arguments for formatting
|
|
47
|
+
* @returns The formatted data
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
#format(formatter, data, arguments_ = []) {
|
|
52
|
+
if (typeof data === "string") {
|
|
53
|
+
return formatter(data, arguments_);
|
|
54
|
+
}
|
|
55
|
+
if (typeof data === "object" && data !== null) {
|
|
56
|
+
for (const index in data) {
|
|
57
|
+
const value = data[index];
|
|
58
|
+
if (typeof value === "string" || Array.isArray(value) || typeof value === "object") {
|
|
59
|
+
data[index] = this.#format(formatter, value, arguments_);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { MessageFormatterProcessor as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { P as Processor, M as Meta } from '../packem_shared/types-D3ycu8-x.js';
|
|
2
|
+
import '@visulima/colorize';
|
|
3
|
+
import 'type-fest';
|
|
4
|
+
import '../interactive/index.js';
|
|
5
|
+
|
|
6
|
+
interface OpenTelemetryProcessorOptions {
|
|
7
|
+
spanIdFieldName?: string;
|
|
8
|
+
traceFieldName?: string;
|
|
9
|
+
traceFlagsFieldName?: string;
|
|
10
|
+
traceIdFieldName?: string;
|
|
11
|
+
}
|
|
12
|
+
declare class OpenTelemetryProcessor<L extends string = string> implements Processor<L> {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(options?: OpenTelemetryProcessorOptions);
|
|
15
|
+
process(meta: Meta<L>): Meta<L>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { OpenTelemetryProcessor };
|
|
19
|
+
export type { OpenTelemetryProcessorOptions };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { trace, context, isSpanContextValid } from '@opentelemetry/api';
|
|
2
|
+
|
|
3
|
+
class OpenTelemetryProcessor {
|
|
4
|
+
/** Field name for trace ID */
|
|
5
|
+
#traceIdField;
|
|
6
|
+
/** Field name for span ID */
|
|
7
|
+
#spanIdField;
|
|
8
|
+
/** Field name for trace flags */
|
|
9
|
+
#traceFlagsField;
|
|
10
|
+
/** Optional field name to nest all trace fields under */
|
|
11
|
+
#traceFieldName;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new OpenTelemetryProcessor instance.
|
|
14
|
+
* @param options Configuration options for field names and nesting
|
|
15
|
+
*/
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.#traceIdField = options.traceIdFieldName || "trace_id";
|
|
18
|
+
this.#spanIdField = options.spanIdFieldName || "span_id";
|
|
19
|
+
this.#traceFlagsField = options.traceFlagsFieldName || "trace_flags";
|
|
20
|
+
this.#traceFieldName = options.traceFieldName;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Processes log metadata to add OpenTelemetry trace context.
|
|
24
|
+
*
|
|
25
|
+
* Extracts trace information from the active OpenTelemetry span and adds it
|
|
26
|
+
* to the log context. If no valid span is found, the metadata is returned unchanged.
|
|
27
|
+
* @param meta The log metadata to process
|
|
28
|
+
* @returns The processed metadata with trace context added
|
|
29
|
+
*/
|
|
30
|
+
process(meta) {
|
|
31
|
+
const span = trace.getSpan(context.active());
|
|
32
|
+
if (!span) {
|
|
33
|
+
return meta;
|
|
34
|
+
}
|
|
35
|
+
const spanContext = span.spanContext();
|
|
36
|
+
if (!isSpanContextValid(spanContext)) {
|
|
37
|
+
return meta;
|
|
38
|
+
}
|
|
39
|
+
const fields = {
|
|
40
|
+
[this.#spanIdField]: spanContext.spanId,
|
|
41
|
+
[this.#traceFlagsField]: `0${spanContext.traceFlags.toString(16)}`,
|
|
42
|
+
[this.#traceIdField]: spanContext.traceId
|
|
43
|
+
};
|
|
44
|
+
const traceData = this.#traceFieldName ? {
|
|
45
|
+
[this.#traceFieldName]: fields
|
|
46
|
+
} : fields;
|
|
47
|
+
meta.context = [...meta.context || [], traceData];
|
|
48
|
+
return meta;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { OpenTelemetryProcessor };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Rules, RedactOptions } from '@visulima/redact';
|
|
2
|
-
import { P as Processor, M as Meta } from '../packem_shared/types-
|
|
2
|
+
import { P as Processor, M as Meta } from '../packem_shared/types-D3ycu8-x.js';
|
|
3
3
|
import '@visulima/colorize';
|
|
4
4
|
import 'type-fest';
|
|
5
|
+
import '../interactive/index.js';
|
|
5
6
|
|
|
6
7
|
declare class RedactProcessor<L extends string = string> implements Processor<L> {
|
|
7
8
|
#private;
|
|
@@ -1 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import { redact, standardRules } from '@visulima/redact';
|
|
2
|
+
|
|
3
|
+
class RedactProcessor {
|
|
4
|
+
/** The redact function configured with custom rules and options */
|
|
5
|
+
#redact;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new RedactProcessor instance.
|
|
8
|
+
* @param rules Custom redaction rules (uses standardRules if not provided)
|
|
9
|
+
* @param options Additional redaction options
|
|
10
|
+
*/
|
|
11
|
+
constructor(rules, options) {
|
|
12
|
+
this.#redact = (input) => redact(input, rules || standardRules, options);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Processes log metadata to redact sensitive information.
|
|
16
|
+
*
|
|
17
|
+
* Applies redaction rules to the message, context, and error properties
|
|
18
|
+
* in the log metadata to prevent sensitive data from being logged.
|
|
19
|
+
* @param meta The log metadata to process
|
|
20
|
+
* @returns The processed metadata with sensitive data redacted
|
|
21
|
+
*/
|
|
22
|
+
process(meta) {
|
|
23
|
+
meta.message = this.#redact(meta.message);
|
|
24
|
+
meta.context = this.#redact(meta.context);
|
|
25
|
+
meta.error = this.#redact(meta.error);
|
|
26
|
+
return meta;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { RedactProcessor as default };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { InteractiveManager } from './interactive/index.js';
|
|
2
|
+
|
|
3
|
+
type ProgressBarStyle = "shades_classic" | "shades_grey" | "rect" | "filled" | "solid" | "ascii" | "custom";
|
|
4
|
+
interface ProgressBarOptions {
|
|
5
|
+
barCompleteChar?: string | string[];
|
|
6
|
+
barGlue?: string;
|
|
7
|
+
barIncompleteChar?: string | string[];
|
|
8
|
+
current?: number;
|
|
9
|
+
format?: string;
|
|
10
|
+
fps?: number;
|
|
11
|
+
style?: ProgressBarStyle;
|
|
12
|
+
total: number;
|
|
13
|
+
width?: number;
|
|
14
|
+
}
|
|
15
|
+
interface SingleBarOptions extends ProgressBarOptions {
|
|
16
|
+
format?: string;
|
|
17
|
+
}
|
|
18
|
+
interface MultiBarOptions {
|
|
19
|
+
barCompleteChar?: string | string[];
|
|
20
|
+
barGlue?: string;
|
|
21
|
+
barIncompleteChar?: string | string[];
|
|
22
|
+
composite?: boolean;
|
|
23
|
+
format?: string;
|
|
24
|
+
fps?: number;
|
|
25
|
+
style?: ProgressBarStyle;
|
|
26
|
+
}
|
|
27
|
+
interface ProgressBarPayload {
|
|
28
|
+
[key: string]: string | number | boolean;
|
|
29
|
+
}
|
|
30
|
+
declare const getBarChar: (char: string | undefined, style: ProgressBarStyle, complete?: boolean) => string;
|
|
31
|
+
declare const applyStyleToOptions: <T extends ProgressBarOptions | MultiBarOptions>(options: T) => T;
|
|
32
|
+
declare class ProgressBar {
|
|
33
|
+
protected options: ProgressBarOptions;
|
|
34
|
+
protected current: number;
|
|
35
|
+
private startTime;
|
|
36
|
+
private interactiveManager?;
|
|
37
|
+
private isActive;
|
|
38
|
+
private payload?;
|
|
39
|
+
constructor(options: ProgressBarOptions, interactiveManager?: InteractiveManager, payload?: ProgressBarPayload);
|
|
40
|
+
update(current: number, payload?: ProgressBarPayload): void;
|
|
41
|
+
increment(step?: number, payload?: ProgressBarPayload): void;
|
|
42
|
+
render(): string;
|
|
43
|
+
start(total?: number, startValue?: number, payload?: ProgressBarPayload): void;
|
|
44
|
+
stop(): void;
|
|
45
|
+
private calculateETA;
|
|
46
|
+
}
|
|
47
|
+
declare class MultiBarInstance extends ProgressBar {
|
|
48
|
+
private multiBar;
|
|
49
|
+
constructor(multiBar: MultiProgressBar, options: ProgressBarOptions, payload?: ProgressBarPayload);
|
|
50
|
+
update(current: number, payload?: ProgressBarPayload): void;
|
|
51
|
+
getBarState(): {
|
|
52
|
+
char: string;
|
|
53
|
+
current: number;
|
|
54
|
+
total: number;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
declare class MultiProgressBar {
|
|
58
|
+
private bars;
|
|
59
|
+
private options;
|
|
60
|
+
private interactiveManager?;
|
|
61
|
+
private isActive;
|
|
62
|
+
private nextBarId;
|
|
63
|
+
private composite;
|
|
64
|
+
private barColors;
|
|
65
|
+
constructor(options?: MultiBarOptions, interactiveManager?: InteractiveManager);
|
|
66
|
+
create(total: number, current?: number, payload?: ProgressBarPayload): ProgressBar;
|
|
67
|
+
remove(bar: ProgressBar): boolean;
|
|
68
|
+
renderAll(): void;
|
|
69
|
+
setBarColor(bar: MultiBarInstance, color: ((text: string) => string) | undefined): void;
|
|
70
|
+
stop(): void;
|
|
71
|
+
private renderComposite;
|
|
72
|
+
private getCompositeChar;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { MultiBarInstance, MultiProgressBar, ProgressBar, applyStyleToOptions, getBarChar };
|
|
76
|
+
export type { MultiBarOptions, ProgressBarOptions, ProgressBarPayload, ProgressBarStyle, SingleBarOptions };
|