@reliverse/rempts 1.7.57 → 1.7.59

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.
@@ -1,106 +1,261 @@
1
- interface SpinnerOptions {
2
- cancelMessage?: string;
3
- color?: string;
4
- delay?: number;
5
- errorMessage?: string;
6
- failText?: string;
7
- frames?: string[];
8
- hideCursor?: boolean;
9
- indicator?: "dots" | "timer";
10
- onCancel?: () => void;
11
- prefixText?: string;
12
- signal?: AbortSignal;
13
- silent?: boolean;
14
- spinner?: string;
15
- successText?: string;
16
- text: string;
1
+ /**
2
+ * Environment toggles:
3
+ * - Disable by setting CLI_NO_SPINNER=1 or CLI_NO_COLOR=1
4
+ * - Auto-disables in CI and when not a TTY; override with isEnabled: true
5
+ * - Respect env behavior can be bypassed with respectEnv: false
6
+ * Defaults:
7
+ * - spinner: "dots", color: "cyan", hideCursor: true, discardStdin: true, stream defaults to stderr.
8
+ */
9
+ import { randomSpinner } from "cli-spinners";
10
+ import prettyBytes from "pretty-bytes";
11
+ import prettyMilliseconds from "pretty-ms";
12
+ import { type Ora, type OraOptions, type OraPromiseOptions } from "./spinner-impl.js";
13
+ export interface SpinnerOptions extends Omit<OraOptions, "text"> {
14
+ readonly respectEnv?: boolean;
15
+ readonly showTiming?: boolean;
16
+ readonly defaultSuccess?: string;
17
+ readonly defaultFail?: string;
18
+ text?: string;
19
+ readonly textColor?: string | ((text: string) => string);
20
+ readonly prefixColor?: string | ((text: string) => string);
21
+ readonly suffixColor?: string | ((text: string) => string);
22
+ readonly successColor?: string | ((text: string) => string);
23
+ readonly failColor?: string | ((text: string) => string);
24
+ readonly theme?: {
25
+ readonly info?: (text: string) => string;
26
+ readonly success?: (text: string) => string;
27
+ readonly error?: (text: string) => string;
28
+ readonly dim?: (text: string) => string;
29
+ readonly progress?: (text: string) => string;
30
+ readonly rate?: (text: string) => string;
31
+ readonly bytes?: (text: string) => string;
32
+ readonly percentage?: (text: string) => string;
33
+ };
17
34
  }
18
- interface ProgressOptions {
19
- current: number;
20
- total: number;
21
- format?: "percentage" | "count" | "both";
35
+ export interface SpinnerGroupOptions extends SpinnerOptions {
36
+ readonly items: readonly string[];
37
+ readonly concurrent?: boolean;
22
38
  }
23
- interface SpinnerControls {
24
- start: (text?: string) => SpinnerControls;
25
- stop: (text?: string, code?: number) => void;
26
- setText: (text: string) => void;
27
- setProgress: (progress: ProgressOptions) => void;
28
- succeed: (text?: string) => void;
29
- fail: (text?: string) => void;
30
- warn: (text?: string) => void;
31
- info: (text?: string) => void;
32
- isSpinning: () => boolean;
33
- clear: () => void;
34
- getElapsedTime: () => number;
35
- pause: () => void;
36
- resume: () => void;
37
- dispose: () => void;
38
- isCancelled: boolean;
39
+ export interface FileProgressOptions {
40
+ readonly totalBytes?: number;
41
+ readonly showBytes?: boolean;
42
+ readonly showRate?: boolean;
39
43
  }
44
+ export type SimpleSpinner = Ora;
45
+ export declare const defaultSpinnerOptions: Readonly<SpinnerOptions>;
46
+ export declare function isSpinnerEnabled(options?: {
47
+ stream?: NodeJS.WriteStream;
48
+ respectEnv?: boolean;
49
+ isEnabled?: boolean;
50
+ }): boolean;
51
+ export declare function createSpinner(input?: string | SpinnerOptions): SimpleSpinner;
52
+ export declare function withSpinnerPromise<T>(action: Promise<T> | ((spinner: Ora) => Promise<T>), options?: string | (OraPromiseOptions<T> & SpinnerOptions)): Promise<T>;
53
+ export declare function withSpinner<T>(textOrOptions: string | SpinnerOptions, action: (spinner: Ora) => Promise<T>, onSuccessText?: string | ((result: T) => string), onFailText?: string | ((error: Error) => string)): Promise<T>;
40
54
  /**
41
- * Creates a terminal spinner with enhanced controls and styling options.
42
- *
43
- * @example
44
- * ```typescript
45
- * // Basic usage
46
- * const spinner = useSpinner({ text: "Loading..." }).start();
47
- * spinner.stop();
48
- *
49
- * // With progress tracking
50
- * const spinner = useSpinner({ text: "Processing files..." }).start();
51
- * for (let i = 0; i < files.length; i++) {
52
- * spinner.setProgress({ current: i + 1, total: files.length });
53
- * await processFile(files[i]);
54
- * }
55
- * spinner.succeed();
56
- *
57
- * // With custom color and spinner
58
- * const spinner = useSpinner({
59
- * text: "Processing...",
60
- * color: "cyan",
61
- * spinner: "dots"
62
- * }).start();
63
- *
64
- * // With success/failure states
65
- * const spinner = useSpinner({
66
- * text: "Uploading...",
67
- * successText: "Upload complete!",
68
- * failText: "Upload failed!"
69
- * }).start();
70
- * try {
71
- * await uploadFile();
72
- * spinner.succeed();
73
- * } catch (error) {
74
- * spinner.fail();
75
- * }
76
- *
77
- * // Using the wrapper for async operations
78
- * await useSpinner.promise(
79
- * async (spinner) => {
80
- * await longOperation();
81
- * spinner.setProgress({ current: 50, total: 100 });
82
- * },
83
- * {
84
- * text: "Working...",
85
- * successText: "Done!",
86
- * failText: "Failed!"
87
- * }
88
- * );
89
- * ```
55
+ * Update spinner text with optional prefix/suffix
90
56
  */
91
- export declare function useSpinner(options: SpinnerOptions): SpinnerControls;
92
- export declare namespace useSpinner {
93
- var promise: <T>(operation: (spinner: SpinnerControls) => Promise<T>, options: SpinnerOptions) => Promise<T>;
94
- var nested: (parentOptions: SpinnerOptions) => {
95
- start: () => {
96
- child: (childOptions: SpinnerOptions) => SpinnerControls;
97
- finish: (success: boolean, text?: string) => void;
98
- dispose: () => void;
99
- };
100
- };
101
- var withTiming: <T>(operation: (spinner: SpinnerControls) => Promise<T>, options: SpinnerOptions) => Promise<{
102
- result: T;
103
- duration: number;
104
- }>;
105
- }
106
- export {};
57
+ export declare function updateSpinnerText(spinner: SimpleSpinner, text: string, options?: {
58
+ prefix?: string;
59
+ suffix?: string;
60
+ }): void;
61
+ /**
62
+ * Stop spinner and persist with custom symbol and text
63
+ */
64
+ export declare function stopAndPersist(spinner: SimpleSpinner, options: {
65
+ symbol?: string;
66
+ text?: string;
67
+ prefixText?: string | (() => string);
68
+ suffixText?: string | (() => string);
69
+ }): void;
70
+ /**
71
+ * Create a spinner with timing that automatically shows elapsed time
72
+ */
73
+ export declare function createTimedSpinner(input?: string | Omit<SpinnerOptions, "showTiming">): {
74
+ spinner: SimpleSpinner;
75
+ getElapsed: () => number;
76
+ succeedWithTiming: (text?: string) => void;
77
+ failWithTiming: (text?: string) => void;
78
+ };
79
+ /**
80
+ * Create multiple spinners for concurrent operations
81
+ */
82
+ export declare function createSpinnerGroup(options: SpinnerGroupOptions): {
83
+ spinners: SimpleSpinner[];
84
+ updateAll: (text: string) => void;
85
+ succeedAll: (text?: string) => void;
86
+ failAll: (text?: string) => void;
87
+ stopAll: () => void;
88
+ };
89
+ /**
90
+ * Enhanced withSpinner that includes common patterns used in the codebase
91
+ */
92
+ export declare function withEnhancedSpinner<T>(textOrOptions: string | (SpinnerOptions & {
93
+ successText?: string;
94
+ failText?: string;
95
+ showTiming?: boolean;
96
+ }), action: (spinner: SimpleSpinner & {
97
+ updateText: (text: string, options?: {
98
+ prefix?: string;
99
+ suffix?: string;
100
+ }) => void;
101
+ setProgress: (current: number, total: number, text?: string) => void;
102
+ }) => Promise<T>): Promise<T>;
103
+ /**
104
+ * Check if a spinner is currently running
105
+ */
106
+ export declare function isSpinnerRunning(spinner: SimpleSpinner): boolean;
107
+ /**
108
+ * Safely stop a spinner if it's running
109
+ */
110
+ export declare function safeStopSpinner(spinner: SimpleSpinner | null): void;
111
+ /**
112
+ * Create a spinner that automatically handles common build/publish patterns
113
+ */
114
+ export declare function createBuildSpinner(operation: string, options?: Omit<SpinnerOptions, "text">): {
115
+ spinner: SimpleSpinner;
116
+ complete: (message?: string) => void;
117
+ error: (error: Error | string) => void;
118
+ updateProgress: (step: string) => void;
119
+ };
120
+ /**
121
+ * Create a spinner with file progress tracking
122
+ */
123
+ export declare function createFileProgressSpinner(operation: string, options?: SpinnerOptions & FileProgressOptions): {
124
+ spinner: SimpleSpinner;
125
+ updateProgress: (bytesProcessed: number, fileName?: string) => void;
126
+ updateRate: (bytesPerSecond: number) => void;
127
+ complete: (message?: string) => void;
128
+ error: (error: Error | string) => void;
129
+ };
130
+ /**
131
+ * Create a multi-step operation spinner with automatic timing
132
+ */
133
+ export declare function createMultiStepSpinner(operationName: string, steps: readonly string[], options?: SpinnerOptions): {
134
+ spinner: SimpleSpinner;
135
+ nextStep: (stepIndex?: number) => void;
136
+ complete: (message?: string) => void;
137
+ error: (error: Error | string, stepIndex?: number) => void;
138
+ getCurrentStep: () => number;
139
+ };
140
+ /**
141
+ * Enhanced timing utility using pretty-ms
142
+ */
143
+ export declare function formatSpinnerTiming(startTime: number, options?: {
144
+ verbose?: boolean;
145
+ }): string;
146
+ /**
147
+ * Format bytes for spinner display using pretty-bytes
148
+ */
149
+ export declare function formatSpinnerBytes(bytes: number, options?: {
150
+ binary?: boolean;
151
+ }): string;
152
+ /**
153
+ * Format elapsed time for spinner display using pretty-ms
154
+ */
155
+ export declare function formatSpinnerElapsed(elapsed: number, options?: {
156
+ verbose?: boolean;
157
+ }): string;
158
+ /**
159
+ * Create a spinner for download/upload operations with byte tracking
160
+ */
161
+ export declare function createTransferSpinner(operation: string, options?: SpinnerOptions & {
162
+ totalBytes?: number;
163
+ showRate?: boolean;
164
+ }): {
165
+ spinner: SimpleSpinner;
166
+ updateBytes: (bytesTransferred: number, fileName?: string) => void;
167
+ updateRate: (bytesPerSecond: number) => void;
168
+ complete: (message?: string, totalBytesTransferred?: number) => void;
169
+ error: (error: Error | string) => void;
170
+ };
171
+ export declare const spinners: {
172
+ readonly toggle: import("cli-spinners").Spinner;
173
+ readonly line: import("cli-spinners").Spinner;
174
+ readonly binary: import("cli-spinners").Spinner;
175
+ readonly dots: import("cli-spinners").Spinner;
176
+ readonly dots2: import("cli-spinners").Spinner;
177
+ readonly dots3: import("cli-spinners").Spinner;
178
+ readonly dots4: import("cli-spinners").Spinner;
179
+ readonly dots5: import("cli-spinners").Spinner;
180
+ readonly dots6: import("cli-spinners").Spinner;
181
+ readonly dots7: import("cli-spinners").Spinner;
182
+ readonly dots8: import("cli-spinners").Spinner;
183
+ readonly dots9: import("cli-spinners").Spinner;
184
+ readonly dots10: import("cli-spinners").Spinner;
185
+ readonly dots11: import("cli-spinners").Spinner;
186
+ readonly dots12: import("cli-spinners").Spinner;
187
+ readonly dots13: import("cli-spinners").Spinner;
188
+ readonly dots14: import("cli-spinners").Spinner;
189
+ readonly dots8Bit: import("cli-spinners").Spinner;
190
+ readonly dotsCircle: import("cli-spinners").Spinner;
191
+ readonly sand: import("cli-spinners").Spinner;
192
+ readonly line2: import("cli-spinners").Spinner;
193
+ readonly pipe: import("cli-spinners").Spinner;
194
+ readonly simpleDots: import("cli-spinners").Spinner;
195
+ readonly simpleDotsScrolling: import("cli-spinners").Spinner;
196
+ readonly star: import("cli-spinners").Spinner;
197
+ readonly star2: import("cli-spinners").Spinner;
198
+ readonly flip: import("cli-spinners").Spinner;
199
+ readonly hamburger: import("cli-spinners").Spinner;
200
+ readonly growVertical: import("cli-spinners").Spinner;
201
+ readonly growHorizontal: import("cli-spinners").Spinner;
202
+ readonly balloon: import("cli-spinners").Spinner;
203
+ readonly balloon2: import("cli-spinners").Spinner;
204
+ readonly noise: import("cli-spinners").Spinner;
205
+ readonly bounce: import("cli-spinners").Spinner;
206
+ readonly boxBounce: import("cli-spinners").Spinner;
207
+ readonly boxBounce2: import("cli-spinners").Spinner;
208
+ readonly triangle: import("cli-spinners").Spinner;
209
+ readonly arc: import("cli-spinners").Spinner;
210
+ readonly circle: import("cli-spinners").Spinner;
211
+ readonly squareCorners: import("cli-spinners").Spinner;
212
+ readonly circleQuarters: import("cli-spinners").Spinner;
213
+ readonly circleHalves: import("cli-spinners").Spinner;
214
+ readonly squish: import("cli-spinners").Spinner;
215
+ readonly toggle2: import("cli-spinners").Spinner;
216
+ readonly toggle3: import("cli-spinners").Spinner;
217
+ readonly toggle4: import("cli-spinners").Spinner;
218
+ readonly toggle5: import("cli-spinners").Spinner;
219
+ readonly toggle6: import("cli-spinners").Spinner;
220
+ readonly toggle7: import("cli-spinners").Spinner;
221
+ readonly toggle8: import("cli-spinners").Spinner;
222
+ readonly toggle9: import("cli-spinners").Spinner;
223
+ readonly toggle10: import("cli-spinners").Spinner;
224
+ readonly toggle11: import("cli-spinners").Spinner;
225
+ readonly toggle12: import("cli-spinners").Spinner;
226
+ readonly toggle13: import("cli-spinners").Spinner;
227
+ readonly arrow: import("cli-spinners").Spinner;
228
+ readonly arrow2: import("cli-spinners").Spinner;
229
+ readonly arrow3: import("cli-spinners").Spinner;
230
+ readonly bouncingBar: import("cli-spinners").Spinner;
231
+ readonly bouncingBall: import("cli-spinners").Spinner;
232
+ readonly smiley: import("cli-spinners").Spinner;
233
+ readonly monkey: import("cli-spinners").Spinner;
234
+ readonly hearts: import("cli-spinners").Spinner;
235
+ readonly clock: import("cli-spinners").Spinner;
236
+ readonly earth: import("cli-spinners").Spinner;
237
+ readonly material: import("cli-spinners").Spinner;
238
+ readonly moon: import("cli-spinners").Spinner;
239
+ readonly runner: import("cli-spinners").Spinner;
240
+ readonly pong: import("cli-spinners").Spinner;
241
+ readonly shark: import("cli-spinners").Spinner;
242
+ readonly dqpb: import("cli-spinners").Spinner;
243
+ readonly weather: import("cli-spinners").Spinner;
244
+ readonly christmas: import("cli-spinners").Spinner;
245
+ readonly grenade: import("cli-spinners").Spinner;
246
+ readonly point: import("cli-spinners").Spinner;
247
+ readonly layer: import("cli-spinners").Spinner;
248
+ readonly betaWave: import("cli-spinners").Spinner;
249
+ readonly fingerDance: import("cli-spinners").Spinner;
250
+ readonly fistBump: import("cli-spinners").Spinner;
251
+ readonly soccerHeader: import("cli-spinners").Spinner;
252
+ readonly mindblown: import("cli-spinners").Spinner;
253
+ readonly speaker: import("cli-spinners").Spinner;
254
+ readonly orangePulse: import("cli-spinners").Spinner;
255
+ readonly bluePulse: import("cli-spinners").Spinner;
256
+ readonly orangeBluePulse: import("cli-spinners").Spinner;
257
+ readonly timeTravel: import("cli-spinners").Spinner;
258
+ readonly aesthetic: import("cli-spinners").Spinner;
259
+ readonly dwarfFortress: import("cli-spinners").Spinner;
260
+ };
261
+ export { randomSpinner, prettyBytes, prettyMilliseconds };