@reliverse/relinka 1.4.5 → 1.4.7
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/bin/impl.d.ts +1 -1
- package/bin/impl.js +8 -2
- package/bin/mod.d.ts +0 -22
- package/bin/mod.js +0 -50
- package/package.json +17 -17
- package/bin/deprecated/components/levels/levels.d.ts +0 -13
- package/bin/deprecated/components/levels/levels.js +0 -68
- package/bin/deprecated/components/modes/basic.d.ts +0 -19
- package/bin/deprecated/components/modes/basic.js +0 -20
- package/bin/deprecated/components/modes/browser.d.ts +0 -19
- package/bin/deprecated/components/modes/browser.js +0 -13
- package/bin/deprecated/components/modes/shared.d.ts +0 -2
- package/bin/deprecated/components/modes/shared.js +0 -1
- package/bin/deprecated/components/relinka-deprecated/logger.d.ts +0 -5
- package/bin/deprecated/components/relinka-deprecated/logger.js +0 -5
- package/bin/deprecated/components/relinka-deprecated/mod.d.ts +0 -20
- package/bin/deprecated/components/relinka-deprecated/mod.js +0 -33
- package/bin/deprecated/components/relinka-deprecated/relinka.d.ts +0 -140
- package/bin/deprecated/components/relinka-deprecated/relinka.js +0 -381
- package/bin/deprecated/components/reporters/basic.d.ts +0 -11
- package/bin/deprecated/components/reporters/basic.js +0 -53
- package/bin/deprecated/components/reporters/browser.d.ts +0 -10
- package/bin/deprecated/components/reporters/browser.js +0 -56
- package/bin/deprecated/components/reporters/fancy.d.ts +0 -10
- package/bin/deprecated/components/reporters/fancy.js +0 -104
- package/bin/deprecated/impl-old.d.ts +0 -0
- package/bin/deprecated/impl-old.js +0 -0
- package/bin/deprecated/types.d.ts +0 -161
- package/bin/deprecated/types.js +0 -0
- package/bin/deprecated/utils/box.d.ts +0 -114
- package/bin/deprecated/utils/box.js +0 -145
- package/bin/deprecated/utils/deprecatedColors.d.ts +0 -69
- package/bin/deprecated/utils/deprecatedColors.js +0 -78
- package/bin/deprecated/utils/error.d.ts +0 -6
- package/bin/deprecated/utils/error.js +0 -6
- package/bin/deprecated/utils/format-new.d.ts +0 -15
- package/bin/deprecated/utils/format-new.js +0 -13
- package/bin/deprecated/utils/format.d.ts +0 -14
- package/bin/deprecated/utils/format.js +0 -26
- package/bin/deprecated/utils/log.d.ts +0 -13
- package/bin/deprecated/utils/log.js +0 -15
- package/bin/deprecated/utils/stream.d.ts +0 -14
- package/bin/deprecated/utils/stream.js +0 -4
- package/bin/deprecated/utils/string.d.ts +0 -50
- package/bin/deprecated/utils/string.js +0 -53
- package/bin/deprecated/utils/tree.d.ts +0 -41
- package/bin/deprecated/utils/tree.js +0 -37
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines the level of logs as specific numbers or special number types.
|
|
3
|
-
*
|
|
4
|
-
* @type {0 | 1 | 2 | 3 | 4 | 5 | (number & {})} LogLevelDeprecated - Represents the log level.
|
|
5
|
-
* @default 0 - Represents the default log level.
|
|
6
|
-
*/
|
|
7
|
-
export type LogLevelDeprecated = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
|
|
8
|
-
/**
|
|
9
|
-
* Lists the types of log messages supported by the system.
|
|
10
|
-
*
|
|
11
|
-
* @type {"silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose"} LogTypeDeprecated - Represents the specific type of log message.
|
|
12
|
-
*/
|
|
13
|
-
export type LogTypeDeprecated = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
|
|
14
|
-
export type RelinkaOptionsDeprecated = {
|
|
15
|
-
/**
|
|
16
|
-
* An array of RelinkaReporterDeprecated instances used to handle and output log messages.
|
|
17
|
-
*/
|
|
18
|
-
reporters: RelinkaReporterDeprecated[];
|
|
19
|
-
/**
|
|
20
|
-
* A record mapping LogTypeDeprecated to InputLogObject, defining the log configuration for each log type.
|
|
21
|
-
* See {@link LogTypeDeprecated} and {@link InputLogObject}.
|
|
22
|
-
*/
|
|
23
|
-
types: Record<LogTypeDeprecated, InputLogObject>;
|
|
24
|
-
/**
|
|
25
|
-
* The minimum log level to output. See {@link LogLevelDeprecated}.
|
|
26
|
-
*/
|
|
27
|
-
level: LogLevelDeprecated;
|
|
28
|
-
/**
|
|
29
|
-
* Default properties applied to all log messages unless overridden. See {@link InputLogObject}.
|
|
30
|
-
*/
|
|
31
|
-
defaults: InputLogObject;
|
|
32
|
-
/**
|
|
33
|
-
* The maximum number of times a log message can be repeated within a given timeframe.
|
|
34
|
-
*/
|
|
35
|
-
throttle: number;
|
|
36
|
-
/**
|
|
37
|
-
* The minimum time in milliseconds that must elapse before a throttled log message can be logged again.
|
|
38
|
-
*/
|
|
39
|
-
throttleMin: number;
|
|
40
|
-
/**
|
|
41
|
-
* The Node.js writable stream for standard output. See {@link NodeJS.WriteStream}.
|
|
42
|
-
* @optional
|
|
43
|
-
*/
|
|
44
|
-
stdout?: NodeJS.WriteStream;
|
|
45
|
-
/**
|
|
46
|
-
* The Node.js writeable stream for standard error output. See {@link NodeJS.WriteStream}.
|
|
47
|
-
* @optional
|
|
48
|
-
*/
|
|
49
|
-
stderr?: NodeJS.WriteStream;
|
|
50
|
-
/**
|
|
51
|
-
* A function that allows you to mock log messages for testing purposes.
|
|
52
|
-
* @optional
|
|
53
|
-
*/
|
|
54
|
-
mockFn?: (type: LogTypeDeprecated, defaults: InputLogObject) => (...args: any) => void;
|
|
55
|
-
/**
|
|
56
|
-
* Configuration options for formatting log messages. See {@link FormatOptions}.
|
|
57
|
-
*/
|
|
58
|
-
formatOptions: FormatOptions;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* @see https://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors
|
|
62
|
-
*/
|
|
63
|
-
export type FormatOptions = {
|
|
64
|
-
/**
|
|
65
|
-
* The maximum number of columns to output, affects formatting.
|
|
66
|
-
* @optional
|
|
67
|
-
*/
|
|
68
|
-
columns?: number;
|
|
69
|
-
/**
|
|
70
|
-
* Whether to include timestamp information in log messages.
|
|
71
|
-
* @optional
|
|
72
|
-
*/
|
|
73
|
-
date?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Whether to use colors in the output.
|
|
76
|
-
* @optional
|
|
77
|
-
*/
|
|
78
|
-
colors?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Specifies whether or not the output should be compact. Accepts a boolean or numeric level of compactness.
|
|
81
|
-
* @optional
|
|
82
|
-
*/
|
|
83
|
-
compact?: boolean | number;
|
|
84
|
-
/**
|
|
85
|
-
* Allows additional custom formatting options.
|
|
86
|
-
*/
|
|
87
|
-
[key: string]: unknown;
|
|
88
|
-
};
|
|
89
|
-
export type InputLogObject = {
|
|
90
|
-
/**
|
|
91
|
-
* The logging level of the message. See {@link LogLevelDeprecated}.
|
|
92
|
-
* @optional
|
|
93
|
-
*/
|
|
94
|
-
level?: LogLevelDeprecated;
|
|
95
|
-
/**
|
|
96
|
-
* A string tag to categorize or identify the log message.
|
|
97
|
-
* @optional
|
|
98
|
-
*/
|
|
99
|
-
tag?: string;
|
|
100
|
-
/**
|
|
101
|
-
* The type of log message, which affects how it's processed and displayed. See {@link LogTypeDeprecated}.
|
|
102
|
-
* @optional
|
|
103
|
-
*/
|
|
104
|
-
type?: LogTypeDeprecated;
|
|
105
|
-
/**
|
|
106
|
-
* The main log message text.
|
|
107
|
-
* @optional
|
|
108
|
-
*/
|
|
109
|
-
message?: string;
|
|
110
|
-
/**
|
|
111
|
-
* Additional text or texts to be logged with the message.
|
|
112
|
-
* @optional
|
|
113
|
-
*/
|
|
114
|
-
additional?: string | string[];
|
|
115
|
-
/**
|
|
116
|
-
* Additional arguments to be logged with the message.
|
|
117
|
-
* @optional
|
|
118
|
-
*/
|
|
119
|
-
args?: any[];
|
|
120
|
-
/**
|
|
121
|
-
* The date and time when the log message was created.
|
|
122
|
-
* @optional
|
|
123
|
-
*/
|
|
124
|
-
date?: Date;
|
|
125
|
-
};
|
|
126
|
-
export type LogObject = {
|
|
127
|
-
/**
|
|
128
|
-
* The logging level of the message, overridden if required. See {@link LogLevelDeprecated}.
|
|
129
|
-
*/
|
|
130
|
-
level: LogLevelDeprecated;
|
|
131
|
-
/**
|
|
132
|
-
* The type of log message, overridden if required. See {@link LogTypeDeprecated}.
|
|
133
|
-
*/
|
|
134
|
-
type: LogTypeDeprecated;
|
|
135
|
-
/**
|
|
136
|
-
* A string tag to categorize or identify the log message, overridden if necessary.
|
|
137
|
-
*/
|
|
138
|
-
tag: string;
|
|
139
|
-
/**
|
|
140
|
-
* Additional arguments to be logged with the message, overridden if necessary.
|
|
141
|
-
*/
|
|
142
|
-
args: any[];
|
|
143
|
-
/**
|
|
144
|
-
* The date and time the log message was created, overridden if necessary.
|
|
145
|
-
*/
|
|
146
|
-
date: Date;
|
|
147
|
-
/**
|
|
148
|
-
* Allows additional custom properties to be set on the log object.
|
|
149
|
-
*/
|
|
150
|
-
[key: string]: unknown;
|
|
151
|
-
} & InputLogObject;
|
|
152
|
-
export type RelinkaReporterDeprecated = {
|
|
153
|
-
/**
|
|
154
|
-
* Defines how a log message is processed and displayed by this reporter.
|
|
155
|
-
* @param logObj The LogObject containing the log information to process. See {@link LogObject}.
|
|
156
|
-
* @param ctx An object containing context information such as options. See {@link RelinkaOptionsDeprecated}.
|
|
157
|
-
*/
|
|
158
|
-
log: (logObj: LogObject, ctx: {
|
|
159
|
-
options: RelinkaOptionsDeprecated;
|
|
160
|
-
}) => void;
|
|
161
|
-
};
|
package/bin/deprecated/types.js
DELETED
|
File without changes
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
export type BoxBorderStyle = {
|
|
2
|
-
/**
|
|
3
|
-
* Top left corner
|
|
4
|
-
* @example `┌`
|
|
5
|
-
* @example `╔`
|
|
6
|
-
* @example `╓`
|
|
7
|
-
*/
|
|
8
|
-
tl: string;
|
|
9
|
-
/**
|
|
10
|
-
* Top right corner
|
|
11
|
-
* @example `┐`
|
|
12
|
-
* @example `╗`
|
|
13
|
-
* @example `╖`
|
|
14
|
-
*/
|
|
15
|
-
tr: string;
|
|
16
|
-
/**
|
|
17
|
-
* Bottom left corner
|
|
18
|
-
* @example `└`
|
|
19
|
-
* @example `╚`
|
|
20
|
-
* @example `╙`
|
|
21
|
-
*/
|
|
22
|
-
bl: string;
|
|
23
|
-
/**
|
|
24
|
-
* Bottom right corner
|
|
25
|
-
* @example `┘`
|
|
26
|
-
* @example `╝`
|
|
27
|
-
* @example `╜`
|
|
28
|
-
*/
|
|
29
|
-
br: string;
|
|
30
|
-
/**
|
|
31
|
-
* Horizontal line
|
|
32
|
-
* @example `─`
|
|
33
|
-
* @example `═`
|
|
34
|
-
* @example `─`
|
|
35
|
-
*/
|
|
36
|
-
h: string;
|
|
37
|
-
/**
|
|
38
|
-
* Vertical line
|
|
39
|
-
* @example `│`
|
|
40
|
-
* @example `║`
|
|
41
|
-
* @example `║`
|
|
42
|
-
*/
|
|
43
|
-
v: string;
|
|
44
|
-
};
|
|
45
|
-
declare const boxStylePresets: Record<string, BoxBorderStyle>;
|
|
46
|
-
export type BoxStyle = {
|
|
47
|
-
/**
|
|
48
|
-
* The border color
|
|
49
|
-
* @default 'white'
|
|
50
|
-
*/
|
|
51
|
-
borderColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
|
|
52
|
-
/**
|
|
53
|
-
* The border style
|
|
54
|
-
* @default 'solid'
|
|
55
|
-
* @example 'single-double-rounded'
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* {
|
|
59
|
-
* tl: '┌',
|
|
60
|
-
* tr: '┐',
|
|
61
|
-
* bl: '└',
|
|
62
|
-
* br: '┘',
|
|
63
|
-
* h: '─',
|
|
64
|
-
* v: '│',
|
|
65
|
-
* }
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
borderStyle: BoxBorderStyle | keyof typeof boxStylePresets;
|
|
69
|
-
/**
|
|
70
|
-
* The vertical alignment of the text
|
|
71
|
-
* @default 'center'
|
|
72
|
-
*/
|
|
73
|
-
valign: "top" | "center" | "bottom";
|
|
74
|
-
/**
|
|
75
|
-
* The padding of the box
|
|
76
|
-
* @default 2
|
|
77
|
-
*/
|
|
78
|
-
padding: number;
|
|
79
|
-
/**
|
|
80
|
-
* The left margin of the box
|
|
81
|
-
* @default 1
|
|
82
|
-
*/
|
|
83
|
-
marginLeft: number;
|
|
84
|
-
/**
|
|
85
|
-
* The top margin of the box
|
|
86
|
-
* @default 1
|
|
87
|
-
*/
|
|
88
|
-
marginTop: number;
|
|
89
|
-
/**
|
|
90
|
-
* The top margin of the box
|
|
91
|
-
* @default 1
|
|
92
|
-
*/
|
|
93
|
-
marginBottom: number;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* The border options of the box
|
|
97
|
-
*/
|
|
98
|
-
export type BoxOpts = {
|
|
99
|
-
/**
|
|
100
|
-
* Title that will be displayed on top of the box
|
|
101
|
-
* @example 'Hello World'
|
|
102
|
-
* @example 'Hello {name}'
|
|
103
|
-
*/
|
|
104
|
-
title?: string;
|
|
105
|
-
style?: Partial<BoxStyle>;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Creates a styled box with text content, customizable via options.
|
|
109
|
-
* @param {string} text - The text to display in the box.
|
|
110
|
-
* @param {BoxOpts} [_opts={}] - Optional settings for the appearance and behavior of the box. See {@link BoxOpts}.
|
|
111
|
-
* @returns {string} The formatted box as a string, ready for printing or logging.
|
|
112
|
-
*/
|
|
113
|
-
export declare function box(text: string, _opts?: BoxOpts): string;
|
|
114
|
-
export {};
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { getColor } from "./deprecatedColors.js";
|
|
2
|
-
import { stripAnsi } from "./string.js";
|
|
3
|
-
const boxStylePresets = {
|
|
4
|
-
solid: {
|
|
5
|
-
tl: "\u250C",
|
|
6
|
-
tr: "\u2510",
|
|
7
|
-
bl: "\u2514",
|
|
8
|
-
br: "\u2518",
|
|
9
|
-
h: "\u2500",
|
|
10
|
-
v: "\u2502"
|
|
11
|
-
},
|
|
12
|
-
double: {
|
|
13
|
-
tl: "\u2554",
|
|
14
|
-
tr: "\u2557",
|
|
15
|
-
bl: "\u255A",
|
|
16
|
-
br: "\u255D",
|
|
17
|
-
h: "\u2550",
|
|
18
|
-
v: "\u2551"
|
|
19
|
-
},
|
|
20
|
-
doubleSingle: {
|
|
21
|
-
tl: "\u2553",
|
|
22
|
-
tr: "\u2556",
|
|
23
|
-
bl: "\u2559",
|
|
24
|
-
br: "\u255C",
|
|
25
|
-
h: "\u2500",
|
|
26
|
-
v: "\u2551"
|
|
27
|
-
},
|
|
28
|
-
doubleSingleRounded: {
|
|
29
|
-
tl: "\u256D",
|
|
30
|
-
tr: "\u256E",
|
|
31
|
-
bl: "\u2570",
|
|
32
|
-
br: "\u256F",
|
|
33
|
-
h: "\u2500",
|
|
34
|
-
v: "\u2551"
|
|
35
|
-
},
|
|
36
|
-
singleThick: {
|
|
37
|
-
tl: "\u250F",
|
|
38
|
-
tr: "\u2513",
|
|
39
|
-
bl: "\u2517",
|
|
40
|
-
br: "\u251B",
|
|
41
|
-
h: "\u2501",
|
|
42
|
-
v: "\u2503"
|
|
43
|
-
},
|
|
44
|
-
singleDouble: {
|
|
45
|
-
tl: "\u2552",
|
|
46
|
-
tr: "\u2555",
|
|
47
|
-
bl: "\u2558",
|
|
48
|
-
br: "\u255B",
|
|
49
|
-
h: "\u2550",
|
|
50
|
-
v: "\u2502"
|
|
51
|
-
},
|
|
52
|
-
singleDoubleRounded: {
|
|
53
|
-
tl: "\u256D",
|
|
54
|
-
tr: "\u256E",
|
|
55
|
-
bl: "\u2570",
|
|
56
|
-
br: "\u256F",
|
|
57
|
-
h: "\u2550",
|
|
58
|
-
v: "\u2502"
|
|
59
|
-
},
|
|
60
|
-
rounded: {
|
|
61
|
-
tl: "\u256D",
|
|
62
|
-
tr: "\u256E",
|
|
63
|
-
bl: "\u2570",
|
|
64
|
-
br: "\u256F",
|
|
65
|
-
h: "\u2500",
|
|
66
|
-
v: "\u2502"
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const defaultStyle = {
|
|
70
|
-
borderColor: "white",
|
|
71
|
-
borderStyle: "rounded",
|
|
72
|
-
valign: "center",
|
|
73
|
-
padding: 2,
|
|
74
|
-
marginLeft: 1,
|
|
75
|
-
marginTop: 1,
|
|
76
|
-
marginBottom: 1
|
|
77
|
-
};
|
|
78
|
-
export function box(text, _opts = {}) {
|
|
79
|
-
const opts = {
|
|
80
|
-
..._opts,
|
|
81
|
-
style: {
|
|
82
|
-
...defaultStyle,
|
|
83
|
-
..._opts.style
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const textLines = text.split("\n");
|
|
87
|
-
const boxLines = [];
|
|
88
|
-
const _color = getColor(opts.style.borderColor);
|
|
89
|
-
const borderStyle = {
|
|
90
|
-
...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
|
|
91
|
-
};
|
|
92
|
-
if (_color) {
|
|
93
|
-
for (const key in borderStyle) {
|
|
94
|
-
borderStyle[key] = _color(
|
|
95
|
-
borderStyle[key]
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
|
100
|
-
const height = textLines.length + paddingOffset;
|
|
101
|
-
const width = Math.max(...textLines.map((line) => line.length)) + paddingOffset;
|
|
102
|
-
const widthOffset = width + paddingOffset;
|
|
103
|
-
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
|
104
|
-
if (opts.style.marginTop > 0) {
|
|
105
|
-
boxLines.push("".repeat(opts.style.marginTop));
|
|
106
|
-
}
|
|
107
|
-
if (opts.title) {
|
|
108
|
-
const title = _color ? _color(opts.title) : opts.title;
|
|
109
|
-
const left = borderStyle.h.repeat(
|
|
110
|
-
Math.floor((width - stripAnsi(opts.title).length) / 2)
|
|
111
|
-
);
|
|
112
|
-
const right = borderStyle.h.repeat(
|
|
113
|
-
width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
|
|
114
|
-
);
|
|
115
|
-
boxLines.push(
|
|
116
|
-
`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`
|
|
117
|
-
);
|
|
118
|
-
} else {
|
|
119
|
-
boxLines.push(
|
|
120
|
-
`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
|
124
|
-
for (let i = 0; i < height; i++) {
|
|
125
|
-
if (i < valignOffset || i >= valignOffset + textLines.length) {
|
|
126
|
-
boxLines.push(
|
|
127
|
-
`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
|
|
128
|
-
);
|
|
129
|
-
} else {
|
|
130
|
-
const line = textLines[i - valignOffset];
|
|
131
|
-
const left = " ".repeat(paddingOffset);
|
|
132
|
-
const right = " ".repeat(width - stripAnsi(line).length);
|
|
133
|
-
boxLines.push(
|
|
134
|
-
`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
boxLines.push(
|
|
139
|
-
`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
|
|
140
|
-
);
|
|
141
|
-
if (opts.style.marginBottom > 0) {
|
|
142
|
-
boxLines.push("".repeat(opts.style.marginBottom));
|
|
143
|
-
}
|
|
144
|
-
return boxLines.join("\n");
|
|
145
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on https://github.com/jorgebucaran/colorette
|
|
3
|
-
* Read LICENSE file for more information
|
|
4
|
-
* https://github.com/jorgebucaran/colorette/blob/20fc196d07d0f87c61e0256eadd7831c79b24108/index.js
|
|
5
|
-
*/
|
|
6
|
-
declare const colorDefs: {
|
|
7
|
-
reset: (string: string) => string;
|
|
8
|
-
bold: (string: string) => string;
|
|
9
|
-
dim: (string: string) => string;
|
|
10
|
-
italic: (string: string) => string;
|
|
11
|
-
underline: (string: string) => string;
|
|
12
|
-
inverse: (string: string) => string;
|
|
13
|
-
hidden: (string: string) => string;
|
|
14
|
-
strikethrough: (string: string) => string;
|
|
15
|
-
black: (string: string) => string;
|
|
16
|
-
red: (string: string) => string;
|
|
17
|
-
green: (string: string) => string;
|
|
18
|
-
yellow: (string: string) => string;
|
|
19
|
-
blue: (string: string) => string;
|
|
20
|
-
magenta: (string: string) => string;
|
|
21
|
-
cyan: (string: string) => string;
|
|
22
|
-
white: (string: string) => string;
|
|
23
|
-
gray: (string: string) => string;
|
|
24
|
-
bgBlack: (string: string) => string;
|
|
25
|
-
bgRed: (string: string) => string;
|
|
26
|
-
bgGreen: (string: string) => string;
|
|
27
|
-
bgYellow: (string: string) => string;
|
|
28
|
-
bgBlue: (string: string) => string;
|
|
29
|
-
bgMagenta: (string: string) => string;
|
|
30
|
-
bgCyan: (string: string) => string;
|
|
31
|
-
bgWhite: (string: string) => string;
|
|
32
|
-
blackBright: (string: string) => string;
|
|
33
|
-
redBright: (string: string) => string;
|
|
34
|
-
greenBright: (string: string) => string;
|
|
35
|
-
yellowBright: (string: string) => string;
|
|
36
|
-
blueBright: (string: string) => string;
|
|
37
|
-
magentaBright: (string: string) => string;
|
|
38
|
-
cyanBright: (string: string) => string;
|
|
39
|
-
whiteBright: (string: string) => string;
|
|
40
|
-
bgBlackBright: (string: string) => string;
|
|
41
|
-
bgRedBright: (string: string) => string;
|
|
42
|
-
bgGreenBright: (string: string) => string;
|
|
43
|
-
bgYellowBright: (string: string) => string;
|
|
44
|
-
bgBlueBright: (string: string) => string;
|
|
45
|
-
bgMagentaBright: (string: string) => string;
|
|
46
|
-
bgCyanBright: (string: string) => string;
|
|
47
|
-
bgWhiteBright: (string: string) => string;
|
|
48
|
-
};
|
|
49
|
-
export type ColorName = keyof typeof colorDefs;
|
|
50
|
-
export type ColorFunction = (text: string | number) => string;
|
|
51
|
-
/**
|
|
52
|
-
* An object containing functions for coloring text. Each function corresponds to a terminal color. See {@link ColorName} for available colors.
|
|
53
|
-
*/
|
|
54
|
-
export declare const colors: Record<ColorName, ColorFunction>;
|
|
55
|
-
/**
|
|
56
|
-
* Gets a color function by name, with an option for a fallback color if the requested color is not found.
|
|
57
|
-
* @param {ColorName} color - The name of the color function to get. See {@link ColorName}.
|
|
58
|
-
* @param {ColorName} [fallback="reset"] - The name of the fallback color function if the requested color is not found. See {@link ColorName}.
|
|
59
|
-
* @returns {ColorFunction} The color function that corresponds to the requested color, or the fallback color function. See {@link ColorFunction}.
|
|
60
|
-
*/
|
|
61
|
-
export declare function getColor(color: ColorName, fallback?: ColorName): ColorFunction;
|
|
62
|
-
/**
|
|
63
|
-
* Applies a specified color to a given text string or number.
|
|
64
|
-
* @param {ColorName} color - The color to apply. See {@link ColorName}.
|
|
65
|
-
* @param {string | number} text - The text to color.
|
|
66
|
-
* @returns {string} The colored text.
|
|
67
|
-
*/
|
|
68
|
-
export declare function colorize(color: ColorName, text: string | number): string;
|
|
69
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import * as tty from "node:tty";
|
|
2
|
-
const {
|
|
3
|
-
env = {},
|
|
4
|
-
argv = [],
|
|
5
|
-
platform = ""
|
|
6
|
-
} = typeof process === "undefined" ? {} : process;
|
|
7
|
-
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
8
|
-
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
9
|
-
const isWindows = platform === "win32";
|
|
10
|
-
const isDumbTerminal = env.TERM === "dumb";
|
|
11
|
-
const isCompatibleTerminal = tty?.isatty?.(1) && env.TERM && !isDumbTerminal;
|
|
12
|
-
const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
13
|
-
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
14
|
-
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
|
15
|
-
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
16
|
-
}
|
|
17
|
-
function clearBleed(index, string, open, close, replace) {
|
|
18
|
-
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
19
|
-
}
|
|
20
|
-
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
|
21
|
-
return (string) => string || !(string === "" || string === void 0) ? clearBleed(string.indexOf(close, at), string, open, close, replace) : "";
|
|
22
|
-
}
|
|
23
|
-
function init(open, close, replace) {
|
|
24
|
-
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
|
25
|
-
}
|
|
26
|
-
const colorDefs = {
|
|
27
|
-
reset: init(0, 0),
|
|
28
|
-
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
29
|
-
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
30
|
-
italic: init(3, 23),
|
|
31
|
-
underline: init(4, 24),
|
|
32
|
-
inverse: init(7, 27),
|
|
33
|
-
hidden: init(8, 28),
|
|
34
|
-
strikethrough: init(9, 29),
|
|
35
|
-
black: init(30, 39),
|
|
36
|
-
red: init(31, 39),
|
|
37
|
-
green: init(32, 39),
|
|
38
|
-
yellow: init(33, 39),
|
|
39
|
-
blue: init(34, 39),
|
|
40
|
-
magenta: init(35, 39),
|
|
41
|
-
cyan: init(36, 39),
|
|
42
|
-
white: init(37, 39),
|
|
43
|
-
gray: init(90, 39),
|
|
44
|
-
bgBlack: init(40, 49),
|
|
45
|
-
bgRed: init(41, 49),
|
|
46
|
-
bgGreen: init(42, 49),
|
|
47
|
-
bgYellow: init(43, 49),
|
|
48
|
-
bgBlue: init(44, 49),
|
|
49
|
-
bgMagenta: init(45, 49),
|
|
50
|
-
bgCyan: init(46, 49),
|
|
51
|
-
bgWhite: init(47, 49),
|
|
52
|
-
blackBright: init(90, 39),
|
|
53
|
-
redBright: init(91, 39),
|
|
54
|
-
greenBright: init(92, 39),
|
|
55
|
-
yellowBright: init(93, 39),
|
|
56
|
-
blueBright: init(94, 39),
|
|
57
|
-
magentaBright: init(95, 39),
|
|
58
|
-
cyanBright: init(96, 39),
|
|
59
|
-
whiteBright: init(97, 39),
|
|
60
|
-
bgBlackBright: init(100, 49),
|
|
61
|
-
bgRedBright: init(101, 49),
|
|
62
|
-
bgGreenBright: init(102, 49),
|
|
63
|
-
bgYellowBright: init(103, 49),
|
|
64
|
-
bgBlueBright: init(104, 49),
|
|
65
|
-
bgMagentaBright: init(105, 49),
|
|
66
|
-
bgCyanBright: init(106, 49),
|
|
67
|
-
bgWhiteBright: init(107, 49)
|
|
68
|
-
};
|
|
69
|
-
function createColors(useColor = isColorSupported) {
|
|
70
|
-
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
|
71
|
-
}
|
|
72
|
-
export const colors = createColors();
|
|
73
|
-
export function getColor(color, fallback = "reset") {
|
|
74
|
-
return colors[color] || colors[fallback];
|
|
75
|
-
}
|
|
76
|
-
export function colorize(color, text) {
|
|
77
|
-
return getColor(color)(text);
|
|
78
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses a stack trace string and normalizes its paths by removing the current working directory and the "file://" protocol.
|
|
3
|
-
* @param {string} stack - The stack trace string.
|
|
4
|
-
* @returns {string[]} An array of stack trace lines with normalized paths.
|
|
5
|
-
*/
|
|
6
|
-
export declare function parseStack(stack: string): string[];
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compiles a format string with named or positional arguments to a standard format string.
|
|
3
|
-
* Uses @reliverse/repris's built-in compileFormat.
|
|
4
|
-
* @param {string} format - The format string containing named placeholders.
|
|
5
|
-
* @returns {string} The compiled format string with positional indices.
|
|
6
|
-
*/
|
|
7
|
-
export declare function compile(format: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Formats a string using either an array or an object of arguments.
|
|
10
|
-
* Uses @reliverse/repris's built-in formatString.
|
|
11
|
-
* @param {string} format - The format string (named or positional).
|
|
12
|
-
* @param {any[] | Record<string, unknown>} args - Arguments to format into the string.
|
|
13
|
-
* @returns {string} The formatted string.
|
|
14
|
-
*/
|
|
15
|
-
export declare function formatStr(format: string, args: any[] | Record<string, unknown>): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { compileFormat, formatString } from "@reliverse/repris";
|
|
2
|
-
const _compileCache = {};
|
|
3
|
-
export function compile(format) {
|
|
4
|
-
if (_compileCache[format]) {
|
|
5
|
-
return _compileCache[format];
|
|
6
|
-
}
|
|
7
|
-
const compiled = compileFormat(format);
|
|
8
|
-
_compileCache[format] = compiled;
|
|
9
|
-
return compiled;
|
|
10
|
-
}
|
|
11
|
-
export function formatStr(format, args) {
|
|
12
|
-
return formatString(format, args);
|
|
13
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compiles a format string by replacing placeholders with appropriate position indices.
|
|
3
|
-
* Caches compiled formats for efficiency.
|
|
4
|
-
* @param {string} format - The format string containing the placeholders to replace.
|
|
5
|
-
* @returns {string} The compiled format string with placeholders replaced by positional indices.
|
|
6
|
-
*/
|
|
7
|
-
export declare function compileFormatCompat(format: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Formats a string according to a custom format, using vsprintf for string formatting.
|
|
10
|
-
* @param {string} format - The custom format string.
|
|
11
|
-
* @param {any[]} argv - The arguments to format into the string.
|
|
12
|
-
* @returns {string} The formatted string.
|
|
13
|
-
*/
|
|
14
|
-
export declare function formatStringCompat(format: string, argv: any): string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { vsprintf } from "@reliverse/repris";
|
|
2
|
-
const FORMAT_ARGS = [
|
|
3
|
-
["additional", 5],
|
|
4
|
-
["message", 4],
|
|
5
|
-
["type", 2],
|
|
6
|
-
["date", 1],
|
|
7
|
-
["tag", 3]
|
|
8
|
-
];
|
|
9
|
-
const _compileCache = {};
|
|
10
|
-
export function compileFormatCompat(format) {
|
|
11
|
-
if (_compileCache[format]) {
|
|
12
|
-
return _compileCache[format];
|
|
13
|
-
}
|
|
14
|
-
let _format = format;
|
|
15
|
-
for (const arg of FORMAT_ARGS) {
|
|
16
|
-
_format = _format.replace(
|
|
17
|
-
new RegExp(`([%-])${arg[0]}`, "g"),
|
|
18
|
-
`$1${arg[1]}`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
_compileCache[format] = _format;
|
|
22
|
-
return _format;
|
|
23
|
-
}
|
|
24
|
-
export function formatStringCompat(format, argv) {
|
|
25
|
-
return vsprintf(compileFormatCompat(format), argv);
|
|
26
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the given argument is a simple JavaScript object.
|
|
3
|
-
* @param {any} obj - The object to test.
|
|
4
|
-
* @returns {boolean} `true` if the argument is a plain object, otherwise `false`.
|
|
5
|
-
*/
|
|
6
|
-
export declare function isPlainObject(obj: any): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Determines whether the given argument is a protocol object. A log object must be a simple object and
|
|
9
|
-
* must contain either a 'message' or 'args' field, but not a 'stack' field.
|
|
10
|
-
* @param {any} arg - The argument to check.
|
|
11
|
-
* @returns {boolean} `true` if the argument is a log object according to the specified criteria, otherwise `false`.
|
|
12
|
-
*/
|
|
13
|
-
export declare function isLogObj(arg: any): boolean;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function isPlainObject(obj) {
|
|
2
|
-
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
3
|
-
}
|
|
4
|
-
export function isLogObj(arg) {
|
|
5
|
-
if (!isPlainObject(arg)) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (!arg.message && !arg.args) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
if (arg.stack) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|