@visulima/pail 3.1.0 → 3.2.1
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 +59 -0
- package/LICENSE.md +3 -407
- package/README.md +298 -0
- package/dist/constants.d.ts +37 -0
- package/dist/index.browser.d.ts +47 -12
- package/dist/index.browser.js +12 -1
- package/dist/index.server.d.ts +65 -40
- package/dist/index.server.js +533 -2
- package/dist/interactive/index.d.ts +2 -28
- package/dist/interactive/index.js +2 -1
- 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/object-tree.js +89 -2
- 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-C0AXk99i.js +58 -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-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-CPjQrsyy.js +1427 -0
- 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/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/caller-processor.js +59 -1
- 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 +67 -1
- package/dist/processor/opentelemetry-processor.d.ts +70 -0
- package/dist/processor/opentelemetry-processor.js +52 -0
- package/dist/processor/redact-processor.d.ts +39 -8
- package/dist/processor/redact-processor.js +30 -1
- package/dist/progress-bar.d.ts +75 -15
- package/dist/progress-bar.js +404 -1
- package/dist/reporter/file/json-file-reporter.d.ts +39 -20
- package/dist/reporter/file/json-file-reporter.js +136 -4
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +48 -0
- package/dist/reporter/http/abstract-http-reporter.d.ts +215 -0
- package/dist/reporter/http/abstract-http-reporter.js +435 -0
- package/dist/reporter/http/http-reporter.d.ts +39 -0
- package/dist/reporter/http/http-reporter.edge-light.d.ts +40 -0
- package/dist/reporter/http/http-reporter.edge-light.js +651 -0
- package/dist/reporter/http/http-reporter.js +13 -0
- 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.browser.js +2 -1
- package/dist/reporter/json/index.d.ts +3 -16
- package/dist/reporter/json/index.js +2 -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.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +2 -25
- package/dist/reporter/pretty/index.js +1 -1
- 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/simple/simple-reporter.server.js +186 -8
- 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 +2150 -1
- 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 +53 -4
- package/dist/packem_shared/AbstractJsonReporter-UftN6CIL.js +0 -1
- package/dist/packem_shared/InteractiveManager-CgmJyW9x.js +0 -3
- package/dist/packem_shared/InteractiveStreamHook-NtJu71aN.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-Bns0ZWLy.js +0 -12
- package/dist/packem_shared/PrettyReporter-CGKSTI7X.js +0 -5
- package/dist/packem_shared/abstract-json-reporter-CPsNkpz8.d.ts +0 -22
- package/dist/packem_shared/abstract-pretty-reporter-CUtSm20r.js +0 -1
- package/dist/packem_shared/abstract-pretty-reporter-DB2G-qlI.d.ts +0 -28
- package/dist/packem_shared/constants-DKfCaSUR.js +0 -1
- package/dist/packem_shared/format-label-CpyyTBom.js +0 -26
- package/dist/packem_shared/get-longest-label-B0NrI-o2.js +0 -1
- package/dist/packem_shared/index-CysYvHXs.js +0 -8
- package/dist/packem_shared/index-D9hWq9ka.js +0 -1
- 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/interactive-stream-hook-CeVo4Kth.js +0 -2
- package/dist/packem_shared/pail.browser-BmHoDvEA.js +0 -19
- package/dist/packem_shared/pail.browser-CmWcqnn9.d.ts +0 -64
- package/dist/packem_shared/types-DVzG8TWL.d.ts +0 -95
- 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,11 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
`),0):ie(`${n}
|
|
3
|
-
`,h)}formatMessage(e){const{columns:n}=U();let p=n;typeof this.styles.messageLength=="number"&&(p=this.styles.messageLength);const{badge:i,context:h,date:c,error:S,file:u,groups:m,label:g,message:f,prefix:y,repeated:v,scope:$,suffix:b,traceError:w,type:L}=e,{color:E}=this.loggerTypes[L.name],M=E?G[E]:J,l=m.map(()=>" ").join(""),t=[];if(m.length>0&&t.push(`${l+o(`[${m.at(-1)}]`)} `),c&&t.push(`${o(this.styles.dateFormatter(typeof c=="string"?new Date(c):c))} `),i)t.push(R(M(i)));else{const r=re(this.loggerTypes);r.length>0&&t.push(o(" ".repeat(r.length)))}const A=se(this.loggerTypes),C=d(A);if(g){const r=d(g),s=Math.max(0,C-r);t.push(`${R(M(Q(g,this.styles)))} `," ".repeat(s))}else t.push(" ".repeat(C+1));v&&t.push(`${K.white(`[${v}x]`)} `),Array.isArray($)&&$.length>0&&t.push(`${o(`[${$.join(" > ")}]`)} `),y&&t.push(`${o(`[${this.styles.underline.prefix?I(y):y}]`)} `);const O=d(t.join(""));if(f!==ee){const r=typeof f=="string"?f:k(f,this.#i);t.push(l+X(r,{trim:!1,width:p-3,wrapMode:Z.STRICT_WIDTH}))}if(h){let r=!1;t.push(...h.map(s=>{if(s instanceof Error)return r=!0,`
|
|
1
|
+
import { createRequire as __cjs_createRequire } from "node:module";
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const {
|
|
8
|
+
stdout,
|
|
9
|
+
stderr
|
|
10
|
+
} = __cjs_getProcess;
|
|
11
|
+
import colorize, { red, greenBright, cyan, green, grey, bold, white, bgGrey, underline } from '@visulima/colorize';
|
|
12
|
+
import { d as defaultInspectorConfig, f as formatLabel, i as inspect, r as renderError } from '../../packem_shared/format-label-Btft2KGP.js';
|
|
13
|
+
import { t as terminalSize, g as getStringWidth, w as wordWrap, W as WrapMode } from '../../packem_shared/index-DqKWykfa.js';
|
|
14
|
+
import { E as EMPTY_SYMBOL } from '../../packem_shared/constants-DfDr4MHC.js';
|
|
15
|
+
import { A as AbstractPrettyReporter, g as getLongestBadge } from '../../packem_shared/abstract-pretty-reporter-DMPDCslJ.js';
|
|
16
|
+
import { g as getLongestLabel } from '../../packem_shared/get-longest-label-C9PWeyKq.js';
|
|
17
|
+
import { w as writeStream } from '../../packem_shared/write-stream-BG8fhcs3.js';
|
|
18
|
+
|
|
19
|
+
const pailFileFilter = (line) => !/[\\/]pail[\\/]dist/.test(line);
|
|
20
|
+
class SimpleReporter extends AbstractPrettyReporter {
|
|
21
|
+
#stdout;
|
|
22
|
+
#stderr;
|
|
23
|
+
#interactiveManager;
|
|
24
|
+
#interactive = false;
|
|
25
|
+
#inspectOptions;
|
|
26
|
+
#errorOptions;
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
const { error: errorOptions, inspect: inspectOptions, ...rest } = options;
|
|
29
|
+
super({
|
|
30
|
+
uppercase: {
|
|
31
|
+
label: true,
|
|
32
|
+
...rest.uppercase
|
|
33
|
+
},
|
|
34
|
+
...rest
|
|
35
|
+
});
|
|
36
|
+
this.#inspectOptions = { ...defaultInspectorConfig, indent: void 0, ...inspectOptions };
|
|
37
|
+
this.#errorOptions = {
|
|
38
|
+
...errorOptions,
|
|
39
|
+
color: {
|
|
40
|
+
fileLine: green,
|
|
41
|
+
hint: cyan,
|
|
42
|
+
marker: red,
|
|
43
|
+
message: red,
|
|
44
|
+
method: greenBright,
|
|
45
|
+
title: red
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.#stdout = stdout;
|
|
49
|
+
this.#stderr = stderr;
|
|
50
|
+
}
|
|
51
|
+
setStdout(stdout_) {
|
|
52
|
+
this.#stdout = stdout_;
|
|
53
|
+
}
|
|
54
|
+
setStderr(stderr_) {
|
|
55
|
+
this.#stderr = stderr_;
|
|
56
|
+
}
|
|
57
|
+
setInteractiveManager(manager) {
|
|
58
|
+
this.#interactiveManager = manager;
|
|
59
|
+
}
|
|
60
|
+
setIsInteractive(interactive) {
|
|
61
|
+
this.#interactive = interactive;
|
|
62
|
+
}
|
|
63
|
+
log(meta) {
|
|
64
|
+
const message = this.formatMessage(meta);
|
|
65
|
+
const logLevel = meta.type.level;
|
|
66
|
+
const streamType = ["error", "trace", "warn"].includes(logLevel) ? "stderr" : "stdout";
|
|
67
|
+
const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
|
|
68
|
+
if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
|
|
69
|
+
this.#interactiveManager.update(streamType, message.split("\n"), 0);
|
|
70
|
+
} else {
|
|
71
|
+
writeStream(`${message}
|
|
72
|
+
`, stream);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
76
|
+
formatMessage(data) {
|
|
77
|
+
const { columns } = terminalSize();
|
|
78
|
+
let size = columns;
|
|
79
|
+
if (typeof this.styles.messageLength === "number") {
|
|
80
|
+
size = this.styles.messageLength;
|
|
81
|
+
}
|
|
82
|
+
const { badge, context, date, error, file, groups, label, message, prefix, repeated, scope, suffix, traceError, type } = data;
|
|
83
|
+
const { color } = this.loggerTypes[type.name];
|
|
84
|
+
const colorized = color ? colorize[color] : white;
|
|
85
|
+
const groupSpaces = groups.map(() => " ").join("");
|
|
86
|
+
const items = [];
|
|
87
|
+
if (groups.length > 0) {
|
|
88
|
+
items.push(`${groupSpaces + grey(`[${groups.at(-1)}]`)} `);
|
|
89
|
+
}
|
|
90
|
+
if (date) {
|
|
91
|
+
items.push(`${grey(this.styles.dateFormatter(typeof date === "string" ? new Date(date) : date))} `);
|
|
92
|
+
}
|
|
93
|
+
if (badge) {
|
|
94
|
+
items.push(bold(colorized(badge)));
|
|
95
|
+
} else {
|
|
96
|
+
const longestBadge = getLongestBadge(this.loggerTypes);
|
|
97
|
+
if (longestBadge.length > 0) {
|
|
98
|
+
items.push(grey(" ".repeat(longestBadge.length)));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const longestLabel = getLongestLabel(this.loggerTypes);
|
|
102
|
+
const longestWidth = getStringWidth(longestLabel);
|
|
103
|
+
if (label) {
|
|
104
|
+
const labelWidth = getStringWidth(label);
|
|
105
|
+
const pad = Math.max(0, longestWidth - labelWidth);
|
|
106
|
+
items.push(`${bold(colorized(formatLabel(label, this.styles)))} `, " ".repeat(pad));
|
|
107
|
+
} else {
|
|
108
|
+
items.push(" ".repeat(longestWidth + 1));
|
|
109
|
+
}
|
|
110
|
+
if (repeated) {
|
|
111
|
+
items.push(`${bgGrey.white(`[${repeated}x]`)} `);
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(scope) && scope.length > 0) {
|
|
114
|
+
items.push(`${grey(`[${scope.join(" > ")}]`)} `);
|
|
115
|
+
}
|
|
116
|
+
if (prefix) {
|
|
117
|
+
items.push(`${grey(`[${this.styles.underline.prefix ? underline(prefix) : prefix}]`)} `);
|
|
118
|
+
}
|
|
119
|
+
const titleSize = getStringWidth(items.join(""));
|
|
120
|
+
if (message !== EMPTY_SYMBOL) {
|
|
121
|
+
const formattedMessage = typeof message === "string" ? message : inspect(message, this.#inspectOptions);
|
|
122
|
+
items.push(
|
|
123
|
+
groupSpaces + wordWrap(formattedMessage, {
|
|
124
|
+
trim: false,
|
|
125
|
+
width: size - 3,
|
|
126
|
+
wrapMode: WrapMode.STRICT_WIDTH
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (context) {
|
|
131
|
+
let hasError = false;
|
|
132
|
+
items.push(
|
|
133
|
+
...context.map((value) => {
|
|
134
|
+
if (value instanceof Error) {
|
|
135
|
+
hasError = true;
|
|
136
|
+
return `
|
|
137
|
+
|
|
138
|
+
${renderError(value, {
|
|
139
|
+
...this.#errorOptions,
|
|
140
|
+
filterStacktrace: pailFileFilter,
|
|
141
|
+
prefix: groupSpaces
|
|
142
|
+
})}`;
|
|
143
|
+
}
|
|
144
|
+
if (typeof value === "object") {
|
|
145
|
+
return ` ${inspect(value, this.#inspectOptions)}`;
|
|
146
|
+
}
|
|
147
|
+
const newValue = (hasError ? "\n\n" : " ") + value;
|
|
148
|
+
hasError = false;
|
|
149
|
+
return newValue;
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (error) {
|
|
154
|
+
items.push(
|
|
155
|
+
renderError(error, {
|
|
156
|
+
...this.#errorOptions,
|
|
157
|
+
filterStacktrace: pailFileFilter,
|
|
158
|
+
prefix: groupSpaces
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (traceError) {
|
|
163
|
+
items.push(
|
|
164
|
+
`
|
|
165
|
+
|
|
166
|
+
${renderError(traceError, {
|
|
167
|
+
...this.#errorOptions,
|
|
168
|
+
filterStacktrace: pailFileFilter,
|
|
169
|
+
hideErrorCauseCodeView: true,
|
|
170
|
+
hideErrorCodeView: true,
|
|
171
|
+
hideErrorErrorsCodeView: true,
|
|
172
|
+
hideMessage: true,
|
|
173
|
+
prefix: groupSpaces
|
|
174
|
+
})}`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
if (suffix) {
|
|
178
|
+
items.push(` ${groupSpaces}${grey(this.styles.underline.suffix ? underline(suffix) : suffix)}`);
|
|
179
|
+
}
|
|
180
|
+
if (file) {
|
|
181
|
+
const fileMessage = file.name + (file.line ? `:${file.line}` : "");
|
|
182
|
+
const callerPad = Math.max(0, titleSize - getStringWidth("Caller: "));
|
|
183
|
+
items.push("\n", grey("Caller: "), " ".repeat(callerPad), fileMessage, "\n");
|
|
184
|
+
}
|
|
185
|
+
return items.join("");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export { SimpleReporter };
|
package/dist/spinner.d.ts
CHANGED
|
@@ -1,154 +1,220 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
| 'dots4'
|
|
9
|
-
| 'dots5'
|
|
10
|
-
| 'dots6'
|
|
11
|
-
| 'dots7'
|
|
12
|
-
| 'dots8'
|
|
13
|
-
| 'dots9'
|
|
14
|
-
| 'dots10'
|
|
15
|
-
| 'dots11'
|
|
16
|
-
| 'dots12'
|
|
17
|
-
| 'dots13'
|
|
18
|
-
| 'dots14'
|
|
19
|
-
| 'dots8Bit'
|
|
20
|
-
| 'dotsCircle'
|
|
21
|
-
| 'sand'
|
|
22
|
-
| 'line'
|
|
23
|
-
| 'line2'
|
|
24
|
-
| 'rollingLine'
|
|
25
|
-
| 'pipe'
|
|
26
|
-
| 'simpleDots'
|
|
27
|
-
| 'simpleDotsScrolling'
|
|
28
|
-
| 'star'
|
|
29
|
-
| 'star2'
|
|
30
|
-
| 'flip'
|
|
31
|
-
| 'hamburger'
|
|
32
|
-
| 'growVertical'
|
|
33
|
-
| 'growHorizontal'
|
|
34
|
-
| 'balloon'
|
|
35
|
-
| 'balloon2'
|
|
36
|
-
| 'noise'
|
|
37
|
-
| 'bounce'
|
|
38
|
-
| 'boxBounce'
|
|
39
|
-
| 'boxBounce2'
|
|
40
|
-
| 'binary'
|
|
41
|
-
| 'triangle'
|
|
42
|
-
| 'arc'
|
|
43
|
-
| 'circle'
|
|
44
|
-
| 'squareCorners'
|
|
45
|
-
| 'circleQuarters'
|
|
46
|
-
| 'circleHalves'
|
|
47
|
-
| 'squish'
|
|
48
|
-
| 'toggle'
|
|
49
|
-
| 'toggle2'
|
|
50
|
-
| 'toggle3'
|
|
51
|
-
| 'toggle4'
|
|
52
|
-
| 'toggle5'
|
|
53
|
-
| 'toggle6'
|
|
54
|
-
| 'toggle7'
|
|
55
|
-
| 'toggle8'
|
|
56
|
-
| 'toggle9'
|
|
57
|
-
| 'toggle10'
|
|
58
|
-
| 'toggle11'
|
|
59
|
-
| 'toggle12'
|
|
60
|
-
| 'toggle13'
|
|
61
|
-
| 'arrow'
|
|
62
|
-
| 'arrow2'
|
|
63
|
-
| 'arrow3'
|
|
64
|
-
| 'bouncingBar'
|
|
65
|
-
| 'bouncingBall'
|
|
66
|
-
| 'smiley'
|
|
67
|
-
| 'monkey'
|
|
68
|
-
| 'hearts'
|
|
69
|
-
| 'clock'
|
|
70
|
-
| 'earth'
|
|
71
|
-
| 'material'
|
|
72
|
-
| 'moon'
|
|
73
|
-
| 'runner'
|
|
74
|
-
| 'pong'
|
|
75
|
-
| 'shark'
|
|
76
|
-
| 'dqpb'
|
|
77
|
-
| 'weather'
|
|
78
|
-
| 'christmas'
|
|
79
|
-
| 'grenade'
|
|
80
|
-
| 'point'
|
|
81
|
-
| 'layer'
|
|
82
|
-
| 'betaWave'
|
|
83
|
-
| 'fingerDance'
|
|
84
|
-
| 'fistBump'
|
|
85
|
-
| 'soccerHeader'
|
|
86
|
-
| 'mindblown'
|
|
87
|
-
| 'speaker'
|
|
88
|
-
| 'orangePulse'
|
|
89
|
-
| 'bluePulse'
|
|
90
|
-
| 'orangeBluePulse'
|
|
91
|
-
| 'timeTravel'
|
|
92
|
-
| 'aesthetic'
|
|
93
|
-
| 'dwarfFortress';
|
|
94
|
-
|
|
95
|
-
interface SpinnerStyle {
|
|
1
|
+
import type { SpinnerName } from "cli-spinners";
|
|
2
|
+
import type InteractiveManager from "./interactive/interactive-manager.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Spinner style configuration using colorize.
|
|
5
|
+
*/
|
|
6
|
+
export interface SpinnerStyle {
|
|
7
|
+
/** Background color name (e.g., "bgRed", "bgBlue") */
|
|
96
8
|
bgColor?: string;
|
|
9
|
+
/** Background color as hex (e.g., "#FF0000") */
|
|
97
10
|
bgHex?: `#${string}`;
|
|
11
|
+
/** Background color as RGB (e.g., [255, 0, 0]) */
|
|
98
12
|
bgRgb?: [number, number, number];
|
|
13
|
+
/** Apply bold style */
|
|
99
14
|
bold?: boolean;
|
|
15
|
+
/** Foreground color name (e.g., "red", "blue", "green") */
|
|
100
16
|
color?: string;
|
|
17
|
+
/** Apply dim/faint style */
|
|
101
18
|
dim?: boolean;
|
|
19
|
+
/** Foreground color as hex (e.g., "#FF0000") */
|
|
102
20
|
hex?: `#${string}`;
|
|
21
|
+
/** Apply inverse style (swap fg/bg) */
|
|
103
22
|
inverse?: boolean;
|
|
23
|
+
/** Apply italic style */
|
|
104
24
|
italic?: boolean;
|
|
25
|
+
/** Apply overline style */
|
|
105
26
|
overline?: boolean;
|
|
27
|
+
/** Foreground color as RGB (e.g., [255, 0, 0]) */
|
|
106
28
|
rgb?: [number, number, number];
|
|
29
|
+
/** Apply strikethrough style */
|
|
107
30
|
strikethrough?: boolean;
|
|
31
|
+
/** Apply underline style */
|
|
108
32
|
underline?: boolean;
|
|
109
33
|
}
|
|
110
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Spinner completion icons.
|
|
36
|
+
*/
|
|
37
|
+
export interface SpinnerIcons {
|
|
38
|
+
/** Icon to show on failure (default: "✖") */
|
|
111
39
|
error?: string;
|
|
40
|
+
/** Icon to show on info (default: "ℹ") */
|
|
112
41
|
info?: string;
|
|
42
|
+
/** Icon to show on success (default: "✓") */
|
|
113
43
|
success?: string;
|
|
44
|
+
/** Icon to show on warning (default: "⚠") */
|
|
114
45
|
warning?: string;
|
|
115
46
|
}
|
|
116
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Spinner style options.
|
|
49
|
+
*/
|
|
50
|
+
export interface SpinnerOptions {
|
|
51
|
+
/** Custom icons for completion states */
|
|
117
52
|
icons?: SpinnerIcons;
|
|
53
|
+
/** Name of the spinner from cli-spinners */
|
|
118
54
|
name?: SpinnerName;
|
|
55
|
+
/** Prefix text to show before the spinner */
|
|
119
56
|
prefixText?: string;
|
|
57
|
+
/** Style configuration for the spinner */
|
|
120
58
|
style?: SpinnerStyle;
|
|
59
|
+
/** Whether to output spinner (default: true) */
|
|
121
60
|
verbose?: boolean;
|
|
122
61
|
}
|
|
123
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Options for starting a spinner.
|
|
64
|
+
*/
|
|
65
|
+
export interface SpinnerStartOptions {
|
|
66
|
+
/** Prefix text to show before the spinner */
|
|
124
67
|
prefixText?: string;
|
|
125
68
|
}
|
|
126
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Spinner class for creating loading indicators in terminal applications.
|
|
71
|
+
*
|
|
72
|
+
* Provides an easy-to-use interface for displaying spinners with various styles
|
|
73
|
+
* from the cli-spinners library. Works seamlessly with interactive terminal features.
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const spinner = new Spinner({ name: "dots" });
|
|
77
|
+
* spinner.start("Loading...");
|
|
78
|
+
* // ... do work ...
|
|
79
|
+
* spinner.succeed("Done!");
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare class Spinner {
|
|
127
83
|
#private;
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new Spinner instance.
|
|
86
|
+
* @param options Configuration options for the spinner
|
|
87
|
+
* @param interactiveManager Optional interactive manager for terminal control
|
|
88
|
+
*/
|
|
128
89
|
constructor(options?: SpinnerOptions, interactiveManager?: InteractiveManager);
|
|
90
|
+
/**
|
|
91
|
+
* Current elapsed time in milliseconds.
|
|
92
|
+
*/
|
|
129
93
|
get elapsedTime(): number;
|
|
94
|
+
/**
|
|
95
|
+
* Get or set the spinner text.
|
|
96
|
+
*/
|
|
130
97
|
get getText(): string;
|
|
131
98
|
set text(value: string);
|
|
99
|
+
/**
|
|
100
|
+
* Get or set the prefix text.
|
|
101
|
+
*/
|
|
132
102
|
get getPrefixText(): string;
|
|
133
103
|
set prefixText(value: string);
|
|
104
|
+
/**
|
|
105
|
+
* Whether the spinner is currently active.
|
|
106
|
+
*/
|
|
134
107
|
get isRunning(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Set the interactive manager for interactive mode.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
setInteractiveManager(manager?: InteractiveManager): void;
|
|
113
|
+
/**
|
|
114
|
+
* Set the multi spinner reference.
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
setMultiSpinner(multiSpinner?: MultiSpinner): void;
|
|
118
|
+
/**
|
|
119
|
+
* Start the spinner with optional text.
|
|
120
|
+
* @param text Optional text to display
|
|
121
|
+
* @param options
|
|
122
|
+
* @param options.prefixText Optional prefix text to display
|
|
123
|
+
* @returns The spinner instance for chaining
|
|
124
|
+
*/
|
|
135
125
|
start(text?: string, options?: SpinnerStartOptions): this;
|
|
126
|
+
/**
|
|
127
|
+
* Stop the spinner with a success message.
|
|
128
|
+
* @param text Optional success text
|
|
129
|
+
*/
|
|
136
130
|
succeed(text?: string): void;
|
|
131
|
+
/**
|
|
132
|
+
* Stop the spinner with a failure message.
|
|
133
|
+
* @param text Optional failure text
|
|
134
|
+
*/
|
|
137
135
|
failed(text?: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Stop the spinner with a warning message.
|
|
138
|
+
* @param text Optional warning text
|
|
139
|
+
*/
|
|
138
140
|
warn(text?: string): void;
|
|
141
|
+
/**
|
|
142
|
+
* Stop the spinner with an info message.
|
|
143
|
+
* @param text Optional info text
|
|
144
|
+
*/
|
|
139
145
|
info(text?: string): void;
|
|
146
|
+
/**
|
|
147
|
+
* Pause the spinner without stopping it.
|
|
148
|
+
*/
|
|
140
149
|
pause(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Resume the spinner if it was paused.
|
|
152
|
+
*/
|
|
141
153
|
resume(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Get current frame output.
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
getFrameOutput(): string;
|
|
142
159
|
}
|
|
143
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Multi-Spinner class for managing multiple spinners concurrently.
|
|
162
|
+
*
|
|
163
|
+
* Allows displaying and updating multiple spinners simultaneously with
|
|
164
|
+
* consistent formatting and management.
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const multiSpinner = new MultiSpinner({ name: "dots" });
|
|
168
|
+
*
|
|
169
|
+
* const spinner1 = multiSpinner.create("Task 1");
|
|
170
|
+
* const spinner2 = multiSpinner.create("Task 2");
|
|
171
|
+
*
|
|
172
|
+
* spinner1.start();
|
|
173
|
+
* spinner2.start();
|
|
174
|
+
*
|
|
175
|
+
* // ... do work ...
|
|
176
|
+
*
|
|
177
|
+
* spinner1.succeed();
|
|
178
|
+
* spinner2.succeed();
|
|
179
|
+
* multiSpinner.stop();
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export declare class MultiSpinner {
|
|
144
183
|
#private;
|
|
145
184
|
constructor(options?: SpinnerOptions, interactiveManager?: InteractiveManager);
|
|
185
|
+
/**
|
|
186
|
+
* Set the interactive manager for interactive mode.
|
|
187
|
+
* @internal
|
|
188
|
+
*/
|
|
189
|
+
setInteractiveManager(manager?: InteractiveManager): void;
|
|
190
|
+
/**
|
|
191
|
+
* Create a new spinner instance.
|
|
192
|
+
* @param text Initial text for the spinner
|
|
193
|
+
* @param options
|
|
194
|
+
* @param options.prefixText Optional prefix text to display
|
|
195
|
+
* @param options.style Optional style for the spinner
|
|
196
|
+
* @param options.verbose Whether to output spinner (default: true)
|
|
197
|
+
* @returns A new Spinner instance
|
|
198
|
+
*/
|
|
146
199
|
create(text?: string, options?: SpinnerOptions): Spinner;
|
|
200
|
+
/**
|
|
201
|
+
* Remove a spinner from the multi-spinner manager.
|
|
202
|
+
* @param spinner The spinner to remove
|
|
203
|
+
* @returns True if the spinner was removed, false otherwise
|
|
204
|
+
*/
|
|
147
205
|
remove(spinner: Spinner): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Stop all spinners.
|
|
208
|
+
*/
|
|
148
209
|
stop(): void;
|
|
210
|
+
/**
|
|
211
|
+
* Clear all spinners without stopping them.
|
|
212
|
+
*/
|
|
149
213
|
clear(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Render all spinners.
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
218
|
+
renderAll(): void;
|
|
150
219
|
}
|
|
151
|
-
type SpinnerType<T extends string = string, L extends string = string> = Record<T, L> & Spinner;
|
|
152
|
-
|
|
153
|
-
export { MultiSpinner, Spinner };
|
|
154
|
-
export type { SpinnerIcons, SpinnerOptions, SpinnerStartOptions, SpinnerStyle, SpinnerType };
|
|
220
|
+
export type SpinnerType<T extends string = string, L extends string = string> = Record<T, L> & Spinner;
|