@orkestrel/console 0.0.12 → 0.0.14
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/README.md +8 -8
- package/dist/src/browser/index.d.ts +47 -38
- package/dist/src/browser/index.js +27 -18
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +121 -82
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +263 -174
- package/dist/src/core/index.d.ts +263 -174
- package/dist/src/core/index.js +121 -82
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +64 -45
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +115 -80
- package/dist/src/server/index.d.ts +115 -80
- package/dist/src/server/index.js +64 -45
- package/dist/src/server/index.js.map +1 -1
- package/package.json +15 -16
package/dist/src/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
2
|
-
import { EmitterHooks } from '@orkestrel/emitter';
|
|
3
|
-
import { EmitterInterface } from '@orkestrel/emitter';
|
|
1
|
+
import type { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
2
|
+
import type { EmitterHooks } from '@orkestrel/emitter';
|
|
3
|
+
import type { EmitterInterface } from '@orkestrel/emitter';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Pads (or, when over budget, truncates) `text` to exactly `columns` visible columns, positioning
|
|
@@ -29,9 +29,11 @@ import { EmitterInterface } from '@orkestrel/emitter';
|
|
|
29
29
|
export declare function align(text: string, columns: number, alignment?: Alignment): string;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Names the horizontal text alignment within a fixed-width cell —
|
|
33
|
-
* {@link ColumnSpec} (and the box / separator title) aligns by.
|
|
34
|
-
*
|
|
32
|
+
* Names the horizontal text alignment within a fixed-width cell — `left` / `center` / `right`,
|
|
33
|
+
* the conventional set a {@link ColumnSpec} (and the box / separator title) aligns by.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* A value set rather than a binary toggle, so it stays a union.
|
|
35
37
|
*/
|
|
36
38
|
export declare type Alignment = 'left' | 'center' | 'right';
|
|
37
39
|
|
|
@@ -56,12 +58,13 @@ export declare const ANSI_PATTERN: RegExp;
|
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* Implements the cross-environment default {@link RendererInterface} — renders style data as ANSI
|
|
59
|
-
* SGR escape codes,
|
|
60
|
-
* is the single styling output the whole console / terminal system uses in a terminal;
|
|
61
|
-
* the browser `%c` / CSS renderer implements the same contract over
|
|
62
|
-
* the same {@link Style}, so retargeting changes the renderer, never the style model.
|
|
61
|
+
* SGR escape codes, stateless and event-free.
|
|
63
62
|
*
|
|
64
63
|
* @remarks
|
|
64
|
+
* It is the single styling output the whole console / terminal system uses in a terminal; the
|
|
65
|
+
* browser `%c` / CSS renderer implements the same contract over the same {@link Style}, so
|
|
66
|
+
* retargeting changes the renderer, never the style model.
|
|
67
|
+
*
|
|
65
68
|
* - **Style is data in, SGR string out.** It reads the style's `foreground` /
|
|
66
69
|
* `background` / `attributes` and emits one `ESC[…m` sequence whose parameters are the
|
|
67
70
|
* mapped SGR numbers (foreground 30–37 / 90–97, background 40–47 / 100–107, attributes
|
|
@@ -85,7 +88,8 @@ export declare class ANSIRenderer implements RendererInterface {
|
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
/**
|
|
88
|
-
* Names a text-style attribute —
|
|
91
|
+
* Names a text-style attribute — `bold` / `dim` / `italic` / `underline` / `inverse` /
|
|
92
|
+
* `strikethrough`, the standard SGR text effects.
|
|
89
93
|
*
|
|
90
94
|
* @remarks
|
|
91
95
|
* Style as data: an `Attribute` is a name. The ANSI renderer maps each to its SGR
|
|
@@ -115,16 +119,16 @@ export declare const ATTRIBUTES: readonly Attribute[];
|
|
|
115
119
|
export declare const BACKGROUND_CODES: Readonly<Record<Exclude<Color, 'default'>, number>>;
|
|
116
120
|
|
|
117
121
|
/**
|
|
118
|
-
* Holds the default empty-cell glyph {@link import('./helpers.js').renderBar} draws the remaining
|
|
119
|
-
* progress bar with — the light-shade block `░` (U+2591). A single visible cell; a
|
|
120
|
-
* it through {@link import('./types.js').BarOptions}
|
|
122
|
+
* Holds the default empty-cell glyph {@link import('./helpers.js').renderBar} draws the remaining
|
|
123
|
+
* run of a progress bar with — the light-shade block `░` (U+2591). A single visible cell; a
|
|
124
|
+
* consumer overrides it through {@link import('./types.js').BarOptions.empty}.
|
|
121
125
|
*/
|
|
122
126
|
export declare const BAR_EMPTY = "\u2591";
|
|
123
127
|
|
|
124
128
|
/**
|
|
125
|
-
* Holds the default filled-cell glyph {@link import('./helpers.js').renderBar} draws the completed
|
|
126
|
-
* progress bar with — the full block `█` (U+2588). A single visible cell; a consumer
|
|
127
|
-
* through {@link import('./types.js').BarOptions}
|
|
129
|
+
* Holds the default filled-cell glyph {@link import('./helpers.js').renderBar} draws the completed
|
|
130
|
+
* run of a progress bar with — the full block `█` (U+2588). A single visible cell; a consumer
|
|
131
|
+
* overrides it through {@link import('./types.js').BarOptions.fill}.
|
|
128
132
|
*/
|
|
129
133
|
export declare const BAR_FILL = "\u2588";
|
|
130
134
|
|
|
@@ -155,14 +159,17 @@ export declare interface BarOptions {
|
|
|
155
159
|
readonly style?: Style;
|
|
156
160
|
}
|
|
157
161
|
|
|
158
|
-
/** Holds the
|
|
162
|
+
/** Holds the bell control character (`U+0007`) that can terminate an OSC sequence. */
|
|
159
163
|
export declare const BEL: string;
|
|
160
164
|
|
|
161
165
|
/**
|
|
162
166
|
* Holds the complete {@link BorderChars} junction set for each {@link BorderStyle} — the standard
|
|
163
|
-
* Unicode box-drawing glyphs at
|
|
164
|
-
*
|
|
165
|
-
*
|
|
167
|
+
* Unicode box-drawing glyphs at each line weight, deeply frozen.
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
* The renderers ({@link import('./helpers.js').renderBox} /
|
|
171
|
+
* {@link import('./helpers.js').renderTable}) look the style up here, so no glyph literal lives in
|
|
172
|
+
* a renderer.
|
|
166
173
|
*
|
|
167
174
|
* @remarks
|
|
168
175
|
* `round` shares `single`'s edges and tees — only its corners differ (the rounded `╭╮╰╯`).
|
|
@@ -170,10 +177,13 @@ export declare const BEL: string;
|
|
|
170
177
|
export declare const BORDER_CHARS: Readonly<Record<BorderStyle, BorderChars>>;
|
|
171
178
|
|
|
172
179
|
/**
|
|
173
|
-
* Represents one complete box-drawing junction set for a {@link BorderStyle} —
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
180
|
+
* Represents one complete box-drawing junction set for a {@link BorderStyle} — the edges, the
|
|
181
|
+
* corners, and the `T` / cross junctions the box and table renderers need to frame content and
|
|
182
|
+
* rule a table.
|
|
183
|
+
*
|
|
184
|
+
* @remarks
|
|
185
|
+
* Plain data (the value lives in {@link BORDER_CHARS}); the renderers read these so no glyph
|
|
186
|
+
* literal is hard-coded in a renderer.
|
|
177
187
|
*
|
|
178
188
|
* @remarks
|
|
179
189
|
* - `horizontal` / `vertical` — the edge run characters.
|
|
@@ -198,12 +208,13 @@ export declare interface BorderChars {
|
|
|
198
208
|
}
|
|
199
209
|
|
|
200
210
|
/**
|
|
201
|
-
* Names a box-drawing border style —
|
|
202
|
-
* with
|
|
203
|
-
*
|
|
204
|
-
* never a toggle — so it stays a union.
|
|
211
|
+
* Names a box-drawing border style — `single` / `double` / `round` / `heavy`, the standard
|
|
212
|
+
* Unicode line weights the renderers frame with, each selecting a full junction set in
|
|
213
|
+
* {@link BORDER_CHARS}.
|
|
205
214
|
*
|
|
206
215
|
* @remarks
|
|
216
|
+
* A named, fixed set (an external-spec value family) rather than a toggle, so it stays a union.
|
|
217
|
+
*
|
|
207
218
|
* `single` (`┌─┐`), `double` (`╔═╗`), `round` (`╭─╮` — single edges, rounded corners), and
|
|
208
219
|
* `heavy` (`┏━┓`). The renderer looks the style up in {@link BORDER_CHARS}; styling the
|
|
209
220
|
* border (a color) is a separate, orthogonal concern handled by the optional `styler`.
|
|
@@ -211,8 +222,8 @@ export declare interface BorderChars {
|
|
|
211
222
|
export declare type BorderStyle = 'single' | 'double' | 'round' | 'heavy';
|
|
212
223
|
|
|
213
224
|
/**
|
|
214
|
-
* Configures {@link import('./helpers.js').renderBox} — content framed in box-drawing
|
|
215
|
-
*
|
|
225
|
+
* Configures {@link import('./helpers.js').renderBox} — content framed in box-drawing characters. A
|
|
226
|
+
* `Reporter` supplies its own chrome style only when the caller gives neither `styler` nor `style`.
|
|
216
227
|
*
|
|
217
228
|
* @remarks
|
|
218
229
|
* - `content` — the body text; embedded newlines split it into lines, each framed on its own
|
|
@@ -286,7 +297,8 @@ export declare class Capture implements CaptureInterface {
|
|
|
286
297
|
/**
|
|
287
298
|
* Maps each {@link CaptureLevel} to its {@link LogLevel} for the optional sink forward — the projection the
|
|
288
299
|
* Capture routes through when writing an intercepted call to a {@link
|
|
289
|
-
* import('./types.js').SinkInterface}
|
|
300
|
+
* import('./types.js').SinkInterface}. `sink.write(text, CAPTURE_LEVEL_MAP[level])` is the call
|
|
301
|
+
* this map backs. `warn` /
|
|
290
302
|
* `error` / `debug` / `info` map to their matching {@link LogLevel}; `log` maps to `info` (a plain
|
|
291
303
|
* console log is informational — the default stream), so a stream-aware sink routes `warn` / `error`
|
|
292
304
|
* captures to the right stream. The source of truth for the capture-to-log projection.
|
|
@@ -323,13 +335,13 @@ export declare interface CapturedMessage {
|
|
|
323
335
|
}
|
|
324
336
|
|
|
325
337
|
/**
|
|
326
|
-
* Declares the observable events a {@link CaptureInterface} emits
|
|
338
|
+
* Declares the observable events a {@link CaptureInterface} emits — `capture(message)` per
|
|
339
|
+
* intercepted call, plus the `start` and `stop` lifecycle signals.
|
|
327
340
|
*
|
|
328
341
|
* @remarks
|
|
329
|
-
* - `capture` —
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
* - `start` / `stop` — the lifecycle signals: `start` fires when interception is installed (the
|
|
342
|
+
* - `capture` — fires for every intercepted `console.*` call (one per call, while active),
|
|
343
|
+
* carrying the frozen {@link CapturedMessage}. The hook a live console viewer / tee rides.
|
|
344
|
+
* - `start` / `stop` — `start` fires when interception is installed (the
|
|
333
345
|
* first `start()` on an inactive capture), `stop` when it is torn down (a `stop()` on an active
|
|
334
346
|
* capture, and from `destroy()`); both are pure signals (empty tuples) so a consumer can mirror
|
|
335
347
|
* the global-patch lifecycle (for example log that capture is engaged). They earn their place by
|
|
@@ -380,7 +392,10 @@ export declare interface CaptureInterface {
|
|
|
380
392
|
start(): void;
|
|
381
393
|
/** Restores the snapshot-original `console.*` — a no-op when not `active`. */
|
|
382
394
|
stop(): void;
|
|
383
|
-
/**
|
|
395
|
+
/**
|
|
396
|
+
* Returns a copy of the whole captured buffer, oldest first (capped at `limit`), or — given
|
|
397
|
+
* a {@link CaptureLevel} — a copy of only that level's bucket.
|
|
398
|
+
*/
|
|
384
399
|
messages(): readonly CapturedMessage[];
|
|
385
400
|
/** Returns a copy of the captured buffer for one {@link CaptureLevel}, oldest first (capped at `limit`). */
|
|
386
401
|
messages(level: CaptureLevel): readonly CapturedMessage[];
|
|
@@ -391,12 +406,13 @@ export declare interface CaptureInterface {
|
|
|
391
406
|
}
|
|
392
407
|
|
|
393
408
|
/**
|
|
394
|
-
* Identifies one intercepted `console` method —
|
|
395
|
-
*
|
|
396
|
-
* / `error` / `debug`); a named value family (it indexes {@link CAPTURE_LEVEL_MAP} to a
|
|
397
|
-
* {@link LogLevel} for the optional sink forward), never a binary toggle — so it stays a union.
|
|
409
|
+
* Identifies one intercepted `console` method — `log` / `info` / `warn` / `error` / `debug`, the
|
|
410
|
+
* names a {@link CaptureInterface} patches and reports under.
|
|
398
411
|
*
|
|
399
412
|
* @remarks
|
|
413
|
+
* A named value family (it indexes {@link CAPTURE_LEVEL_MAP} to a {@link LogLevel} for the
|
|
414
|
+
* optional sink forward) rather than a binary toggle, so it stays a union.
|
|
415
|
+
*
|
|
400
416
|
* distinct from {@link LogLevel}: a `CaptureLevel` names the originating console method (which
|
|
401
417
|
* `console.x` was called), not a severity threshold — there is no ordering and no gating (every
|
|
402
418
|
* configured method is captured). `log` and `info` are separate methods (both default-stream),
|
|
@@ -406,7 +422,9 @@ export declare interface CaptureInterface {
|
|
|
406
422
|
export declare type CaptureLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
407
423
|
|
|
408
424
|
/**
|
|
409
|
-
* Configures the {@link import('./Capture.js').Capture} constructor
|
|
425
|
+
* Configures the {@link import('./Capture.js').Capture} constructor — the `on` / `error` emitter
|
|
426
|
+
* keys, the `levels` intercepted, the `mirror` pass-through, the `sink` forward, and the buffer
|
|
427
|
+
* `limit`.
|
|
410
428
|
*
|
|
411
429
|
* @remarks
|
|
412
430
|
* - `on` — the reserved {@link EmitterHooks} key: initial listeners for the
|
|
@@ -438,8 +456,8 @@ export declare interface CaptureOptions {
|
|
|
438
456
|
}
|
|
439
457
|
|
|
440
458
|
/**
|
|
441
|
-
* Represents the structured outcome of {@link import('./factories.js').createCaptureResult} — the
|
|
442
|
-
* own return `value` plus the
|
|
459
|
+
* Represents the structured outcome of {@link import('./factories.js').createCaptureResult} — the
|
|
460
|
+
* wrapped function's own return `value` plus the `messages` it logged while it ran.
|
|
443
461
|
*
|
|
444
462
|
* @remarks
|
|
445
463
|
* - `value` — whatever the wrapped `fn` returned (its `T`).
|
|
@@ -497,12 +515,12 @@ export declare interface ColumnSpec {
|
|
|
497
515
|
}
|
|
498
516
|
|
|
499
517
|
/**
|
|
500
|
-
*
|
|
518
|
+
* Carries a {@link ConsoleErrorCode} and an optional `context` bag — the error the console layer
|
|
519
|
+
* throws for an internal invariant violated at a defensive guard.
|
|
501
520
|
*
|
|
502
521
|
* @remarks
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
* (`INVARIANT`).
|
|
522
|
+
* `INVARIANT` is the code for a guard that is structurally unreachable, so a `catch` branches on
|
|
523
|
+
* `error.code` rather than parsing the message.
|
|
506
524
|
*/
|
|
507
525
|
export declare class ConsoleError extends Error {
|
|
508
526
|
readonly code: ConsoleErrorCode;
|
|
@@ -511,11 +529,12 @@ export declare class ConsoleError extends Error {
|
|
|
511
529
|
}
|
|
512
530
|
|
|
513
531
|
/**
|
|
514
|
-
* Names
|
|
532
|
+
* Names the machine-readable error code a {@link import('./errors.js').ConsoleError} carries —
|
|
533
|
+
* `INVARIANT`, the only code the package throws.
|
|
515
534
|
*
|
|
516
535
|
* @remarks
|
|
517
|
-
* `INVARIANT`
|
|
518
|
-
* structurally impossible to trip
|
|
536
|
+
* `INVARIANT` reports that an internal invariant or unreachable guard was violated — a defensive
|
|
537
|
+
* check that is structurally impossible to trip.
|
|
519
538
|
*/
|
|
520
539
|
export declare type ConsoleErrorCode = 'INVARIANT';
|
|
521
540
|
|
|
@@ -635,10 +654,13 @@ export declare function createCaptureResult<T>(fn: () => T, options?: CaptureOpt
|
|
|
635
654
|
export declare function createConsoleSink(): SinkInterface;
|
|
636
655
|
|
|
637
656
|
/**
|
|
638
|
-
* Creates the fluent, composable {@link StylerInterface} —
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
657
|
+
* Creates the fluent, composable {@link StylerInterface} — ANSI by default, retargeted by a
|
|
658
|
+
* `renderer` and stripped of color by `enabled: false`.
|
|
659
|
+
*
|
|
660
|
+
* @remarks
|
|
661
|
+
* It builds a {@link import('./types.js').Style} under the hood and renders it through a
|
|
662
|
+
* {@link import('./types.js').RendererInterface}, so `styler.red.bold('hi')` yields styled text.
|
|
663
|
+
* Chains are immutable, so a base styler is freely reusable.
|
|
642
664
|
*
|
|
643
665
|
* @param options - See {@link StylerOptions}
|
|
644
666
|
* @returns A base {@link StylerInterface}
|
|
@@ -702,11 +724,14 @@ export declare const CSI: string;
|
|
|
702
724
|
export declare const DEFAULT_ALIGN: Alignment;
|
|
703
725
|
|
|
704
726
|
/**
|
|
705
|
-
* Sets the default visible cell count of a progress-bar track — the glyph run
|
|
706
|
-
* import('./helpers.js').renderBar} fills
|
|
707
|
-
* its bar to
|
|
708
|
-
*
|
|
709
|
-
*
|
|
727
|
+
* Sets the default visible cell count of a progress-bar track — the glyph run
|
|
728
|
+
* {@link import('./helpers.js').renderBar} fills, and the width a
|
|
729
|
+
* {@link import('./types.js').ProgressInterface} sizes its bar to. `30` cells.
|
|
730
|
+
*
|
|
731
|
+
* @remarks
|
|
732
|
+
* Thirty cells is a compact, terminal-friendly default; a consumer overrides it through
|
|
733
|
+
* `options.width`. It is distinct from {@link DEFAULT_WIDTH} (the renderers' 80-column line
|
|
734
|
+
* width) — a bar track is one inline element, not a full-width rule.
|
|
710
735
|
*/
|
|
711
736
|
export declare const DEFAULT_BAR_WIDTH = 30;
|
|
712
737
|
|
|
@@ -714,11 +739,13 @@ export declare const DEFAULT_BAR_WIDTH = 30;
|
|
|
714
739
|
export declare const DEFAULT_BORDER: BorderStyle;
|
|
715
740
|
|
|
716
741
|
/**
|
|
717
|
-
* Sets the default bounded-buffer cap for a {@link import('./types.js').CaptureInterface} —
|
|
718
|
-
* many recent {@link CapturedMessage}s are retained per buffer (the total buffer
|
|
719
|
-
* bucket; oldest dropped first)
|
|
720
|
-
*
|
|
721
|
-
*
|
|
742
|
+
* Sets the default bounded-buffer cap for a {@link import('./types.js').CaptureInterface} — `1000`,
|
|
743
|
+
* so at most that many recent {@link CapturedMessage}s are retained per buffer (the total buffer
|
|
744
|
+
* and each by-level bucket; oldest dropped first) and retention is always bounded.
|
|
745
|
+
*
|
|
746
|
+
* @remarks
|
|
747
|
+
* A long-running capture can never grow without bound (the same retention precedent as
|
|
748
|
+
* {@link DEFAULT_LOG_LIMIT}); a consumer overrides the cap through `options.limit`.
|
|
722
749
|
*/
|
|
723
750
|
export declare const DEFAULT_CAPTURE_LIMIT = 1000;
|
|
724
751
|
|
|
@@ -726,9 +753,12 @@ export declare const DEFAULT_CAPTURE_LIMIT = 1000;
|
|
|
726
753
|
export declare const DEFAULT_LOG_LEVEL: LogLevel;
|
|
727
754
|
|
|
728
755
|
/**
|
|
729
|
-
* Sets the default bounded-retention cap for a {@link import('./types.js').LoggerInterface} —
|
|
730
|
-
* most
|
|
731
|
-
*
|
|
756
|
+
* Sets the default bounded-retention cap for a {@link import('./types.js').LoggerInterface} —
|
|
757
|
+
* `1000`, so at most that many recent records are kept and retention is always bounded.
|
|
758
|
+
*
|
|
759
|
+
* @remarks
|
|
760
|
+
* The oldest record is dropped after the cap is reached; a consumer overrides the cap through
|
|
761
|
+
* `options.limit`.
|
|
732
762
|
*/
|
|
733
763
|
export declare const DEFAULT_LOG_LIMIT = 1000;
|
|
734
764
|
|
|
@@ -736,16 +766,21 @@ export declare const DEFAULT_LOG_LIMIT = 1000;
|
|
|
736
766
|
export declare const DEFAULT_PADDING = 1;
|
|
737
767
|
|
|
738
768
|
/**
|
|
739
|
-
* Sets the default timer period
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
769
|
+
* Sets the default timer period between a {@link import('./types.js').SpinnerInterface}'s frames —
|
|
770
|
+
* the `setInterval` interval `start()` arms, `80` ms (≈12.5 frames/second).
|
|
771
|
+
*
|
|
772
|
+
* @remarks
|
|
773
|
+
* That is the conventional spinner cadence: fast enough to read as motion, slow enough not to
|
|
774
|
+
* thrash a terminal. A consumer overrides it through `options.interval`.
|
|
743
775
|
*/
|
|
744
776
|
export declare const DEFAULT_SPINNER_INTERVAL = 80;
|
|
745
777
|
|
|
746
778
|
/**
|
|
747
|
-
* Holds the default {@link Theme} — every role bound to its default {@link Style},
|
|
748
|
-
*
|
|
779
|
+
* Holds the default {@link Theme} — every role bound to its default {@link Style}, assembled from
|
|
780
|
+
* {@link LEVEL_COLORS}, {@link STATUS_ICONS}, and {@link STATUS_COLORS} and deeply frozen.
|
|
781
|
+
*
|
|
782
|
+
* @remarks
|
|
783
|
+
* It is the base {@link import('./factories.js').createTheme} merges over, and the theme every
|
|
749
784
|
* entity uses when none is supplied.
|
|
750
785
|
*
|
|
751
786
|
* @remarks
|
|
@@ -762,7 +797,7 @@ export declare const DEFAULT_THEME: Theme;
|
|
|
762
797
|
* Sets the default visible column width for the width-aware renderers — the separator rule and a
|
|
763
798
|
* {@link import('./helpers.js').renderBox} with no explicit `width`, and the reporter's
|
|
764
799
|
* `section` rule. A sane terminal default (80 columns); a caller overrides it per-call or through
|
|
765
|
-
* {@link import('./types.js').ReporterOptions}
|
|
800
|
+
* {@link import('./types.js').ReporterOptions.width}.
|
|
766
801
|
*/
|
|
767
802
|
export declare const DEFAULT_WIDTH = 80;
|
|
768
803
|
|
|
@@ -774,7 +809,7 @@ export declare const DEFAULT_WIDTH = 80;
|
|
|
774
809
|
export declare const EMPTY_STYLE: Style;
|
|
775
810
|
|
|
776
811
|
/**
|
|
777
|
-
* Holds the
|
|
812
|
+
* Holds the escape control character (`U+001B`) that begins every ANSI escape sequence. Built
|
|
778
813
|
* with `String.fromCharCode` so no raw control character appears in source.
|
|
779
814
|
*/
|
|
780
815
|
export declare const ESC: string;
|
|
@@ -864,7 +899,8 @@ export declare function formatRecord(record: LogRecord, styler: StylerInterface,
|
|
|
864
899
|
export declare function formatTime(time: number): string;
|
|
865
900
|
|
|
866
901
|
/**
|
|
867
|
-
* Snapshots and deeply freezes one {@link Style} value
|
|
902
|
+
* Snapshots and deeply freezes one {@link Style} value, including an independent frozen copy of
|
|
903
|
+
* its `attributes`.
|
|
868
904
|
*
|
|
869
905
|
* @param style - The caller-owned style to snapshot
|
|
870
906
|
* @returns A frozen style record with an independently frozen attributes list
|
|
@@ -881,7 +917,7 @@ export declare function formatTime(time: number): string;
|
|
|
881
917
|
export declare function freezeStyle(style: Style): Style;
|
|
882
918
|
|
|
883
919
|
/**
|
|
884
|
-
* Narrows an unknown caught value to a {@link ConsoleError}.
|
|
920
|
+
* Narrows an unknown caught value to a {@link ConsoleError} — the guard a `catch` branches on.
|
|
885
921
|
*
|
|
886
922
|
* @param value - The value to test (typically a `catch` binding)
|
|
887
923
|
* @returns True if `value` is a {@link ConsoleError}; false otherwise
|
|
@@ -924,8 +960,9 @@ export declare const LEVEL_SEVERITY: Readonly<Record<LogLevel, number>>;
|
|
|
924
960
|
export declare const LOG_LEVELS: readonly LogLevel[];
|
|
925
961
|
|
|
926
962
|
/**
|
|
927
|
-
* Represents the line layout a logger writes —
|
|
928
|
-
*
|
|
963
|
+
* Represents the line layout a logger writes — `(record, styler, theme) => string`, one
|
|
964
|
+
* {@link LogRecord} plus the styling substrate in and one finished line out.
|
|
965
|
+
* {@link import('./helpers.js').formatRecord} is the default.
|
|
929
966
|
*
|
|
930
967
|
* @param record - The frozen record to lay out
|
|
931
968
|
* @param styler - The logger's {@link StylerInterface} — color through it (and through
|
|
@@ -992,11 +1029,12 @@ export declare class Logger implements LoggerInterface {
|
|
|
992
1029
|
}
|
|
993
1030
|
|
|
994
1031
|
/**
|
|
995
|
-
* Declares the observable events a {@link LoggerInterface} emits —
|
|
1032
|
+
* Declares the observable events a {@link LoggerInterface} emits — `entry(record)` for every
|
|
1033
|
+
* accepted record, the transport seam.
|
|
996
1034
|
*
|
|
997
1035
|
* @remarks
|
|
998
|
-
* `entry`
|
|
999
|
-
*
|
|
1036
|
+
* `entry` carries the frozen {@link LogRecord} and fires even when the logger is
|
|
1037
|
+
* `silent` (silence suppresses only the
|
|
1000
1038
|
* sink write, never the event, so transports keep receiving records). Listener isolation is
|
|
1001
1039
|
* the emitter's: a listener throw routes to the emitter's `error` handler, never onto
|
|
1002
1040
|
* this map — so a buggy transport can never perturb logging.
|
|
@@ -1117,8 +1155,14 @@ export declare class LoggerManager implements LoggerManagerInterface {
|
|
|
1117
1155
|
*/
|
|
1118
1156
|
export declare interface LoggerManagerInterface {
|
|
1119
1157
|
readonly count: number;
|
|
1158
|
+
/**
|
|
1159
|
+
* Mints and stores a logger named `name`, the manager's defaults flowing in — a
|
|
1160
|
+
* re-register of the same name overwrites.
|
|
1161
|
+
*/
|
|
1120
1162
|
register(name: string, options?: LoggerOptions): LoggerInterface;
|
|
1163
|
+
/** Looks one registered logger up by name. */
|
|
1121
1164
|
logger(name: string): LoggerInterface | undefined;
|
|
1165
|
+
/** Lists the registered loggers in insertion order. */
|
|
1122
1166
|
loggers(): readonly LoggerInterface[];
|
|
1123
1167
|
/** Fans out a `debug` log to every registered logger. */
|
|
1124
1168
|
debug(message: string, data?: Record<string, unknown>): void;
|
|
@@ -1128,21 +1172,24 @@ export declare interface LoggerManagerInterface {
|
|
|
1128
1172
|
warn(message: string, data?: Record<string, unknown>): void;
|
|
1129
1173
|
/** Fans out an `error` log to every registered logger. */
|
|
1130
1174
|
error(message: string, data?: Record<string, unknown>): void;
|
|
1175
|
+
/**
|
|
1176
|
+
* Removes every registered logger with `remove()`, one with `remove(name)`, or a batch
|
|
1177
|
+
* with `remove(names)`.
|
|
1178
|
+
*/
|
|
1131
1179
|
remove(): void;
|
|
1132
1180
|
remove(name: string): boolean;
|
|
1133
1181
|
remove(names: readonly string[]): boolean;
|
|
1134
1182
|
}
|
|
1135
1183
|
|
|
1136
1184
|
/**
|
|
1137
|
-
* Configures the {@link import('./loggers/LoggerManager.js').LoggerManager} constructor
|
|
1185
|
+
* Configures the {@link import('./loggers/LoggerManager.js').LoggerManager} constructor — the
|
|
1186
|
+
* `level` / `sink` / `styler` / `theme` / `format` / `limit` / `silent` defaults flowed into every
|
|
1187
|
+
* logger it mints.
|
|
1138
1188
|
*
|
|
1139
1189
|
* @remarks
|
|
1140
1190
|
* The manager is an event-free registry — it carries no emitter of its own (each
|
|
1141
|
-
* registered {@link LoggerInterface} owns its observable `emitter`).
|
|
1142
|
-
*
|
|
1143
|
-
* wins: `level` (default threshold), `sink` (shared output target), `styler` (shared
|
|
1144
|
-
* coloring), `theme` (semantic styles), `format` (line layout), `limit` (retention cap),
|
|
1145
|
-
* and `silent`.
|
|
1191
|
+
* registered {@link LoggerInterface} owns its observable `emitter`). A per-`register`
|
|
1192
|
+
* override wins over any default supplied here.
|
|
1146
1193
|
*/
|
|
1147
1194
|
export declare interface LoggerManagerOptions {
|
|
1148
1195
|
readonly level?: LogLevel;
|
|
@@ -1155,7 +1202,9 @@ export declare interface LoggerManagerOptions {
|
|
|
1155
1202
|
}
|
|
1156
1203
|
|
|
1157
1204
|
/**
|
|
1158
|
-
* Configures the {@link import('./loggers/Logger.js').Logger} constructor
|
|
1205
|
+
* Configures the {@link import('./loggers/Logger.js').Logger} constructor — the `on` / `error`
|
|
1206
|
+
* emitter keys, the `level` threshold, the logger's `name`, the `sink` / `styler` / `theme` /
|
|
1207
|
+
* `format` line substrate, the retention `limit`, and the `silent` write switch.
|
|
1159
1208
|
*
|
|
1160
1209
|
* @remarks
|
|
1161
1210
|
* - `on` — the reserved {@link EmitterHooks} key: initial listeners for the
|
|
@@ -1191,21 +1240,21 @@ export declare interface LoggerOptions {
|
|
|
1191
1240
|
}
|
|
1192
1241
|
|
|
1193
1242
|
/**
|
|
1194
|
-
* Names the severity level of a {@link LogRecord} — one coherent, ascending
|
|
1243
|
+
* Names the severity level of a {@link LogRecord} — one coherent, ascending scale, `debug` <
|
|
1244
|
+
* `info` < `warn` < `error`, that a {@link LoggerInterface} gates by threshold.
|
|
1195
1245
|
*
|
|
1196
1246
|
* @remarks
|
|
1197
|
-
*
|
|
1198
|
-
*
|
|
1199
|
-
* one below it is dropped (see {@link LEVEL_SEVERITY} for the numeric order). A level is a
|
|
1247
|
+
* A record at or above the logger's `level` is kept (and written), one below it is
|
|
1248
|
+
* dropped (see {@link LEVEL_SEVERITY} for the numeric order). A level is a
|
|
1200
1249
|
* level — its visual treatment (color) is a separate styling concern, never a pseudo-level
|
|
1201
1250
|
* like `success` / `ready`.
|
|
1202
1251
|
*/
|
|
1203
1252
|
export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
1204
1253
|
|
|
1205
1254
|
/**
|
|
1206
|
-
* Represents one immutable, serializable log entry
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1255
|
+
* Represents one immutable, serializable log entry. A {@link LoggerInterface} builds one per call,
|
|
1256
|
+
* freezes it, retains a bounded tail of them, and emits it on `entry`; every sink / transport
|
|
1257
|
+
* consumes this exact shape.
|
|
1209
1258
|
*
|
|
1210
1259
|
* @remarks
|
|
1211
1260
|
* - `level` — the record's {@link LogLevel}.
|
|
@@ -1250,9 +1299,9 @@ export declare interface LogRecord {
|
|
|
1250
1299
|
export declare function meetsLevel(threshold: LogLevel, level: LogLevel): boolean;
|
|
1251
1300
|
|
|
1252
1301
|
/**
|
|
1253
|
-
* Colors `text` through `styler
|
|
1254
|
-
* single optional-styling primitive every renderer applies to
|
|
1255
|
-
*
|
|
1302
|
+
* Colors `text` through `styler` and an optional by-value {@link Style}, or returns it verbatim
|
|
1303
|
+
* when `styler` is `undefined` — the single optional-styling primitive every renderer applies to
|
|
1304
|
+
* its border / title / connector glyphs.
|
|
1256
1305
|
*
|
|
1257
1306
|
* @remarks
|
|
1258
1307
|
* The renderers all take an optional `styler`: present ⇒ glyphs are colored, absent ⇒ plain.
|
|
@@ -1270,13 +1319,16 @@ export declare function paint(styler: StylerInterface | undefined, text: string,
|
|
|
1270
1319
|
|
|
1271
1320
|
/**
|
|
1272
1321
|
* Implements an update-driven, observable progress bar — {@link update} recomputes the bar through
|
|
1273
|
-
* {@link renderBar}, writes `\r` + bar to its {@link SinkInterface}, and emits the `{ current,
|
|
1274
|
-
* on `update`.
|
|
1275
|
-
*
|
|
1276
|
-
* Universal — the one {@link StylerInterface} + the one {@link SinkInterface}, no `node:*`, no
|
|
1277
|
-
* `process.stdout`. No self-timer (unlike {@link import('./Spinner.js').Spinner}) — the caller drives it.
|
|
1322
|
+
* {@link renderBar}, writes `\r` + bar to its {@link SinkInterface}, and emits the `{ current,
|
|
1323
|
+
* total }` on `update`. No self-timer, unlike {@link import('./Spinner.js').Spinner} — the caller
|
|
1324
|
+
* drives it.
|
|
1278
1325
|
*
|
|
1279
1326
|
* @remarks
|
|
1327
|
+
* The leading `\r` is what an overwrite-capable sink (the TTY sink) redraws on; a plain sink
|
|
1328
|
+
* degrades to a fresh, non-overwriting line — the line-overwrite is the sink's job. Universal —
|
|
1329
|
+
* the one {@link StylerInterface} + the one {@link SinkInterface}, no `node:*`, no
|
|
1330
|
+
* `process.stdout`.
|
|
1331
|
+
*
|
|
1280
1332
|
* - **Update-driven.** Each {@link update} clamps `current` to `[0, total]`, renders the bar (filled
|
|
1281
1333
|
* to `current / total`, with the trailing `percent (current/total)` + message) through {@link renderBar},
|
|
1282
1334
|
* emits `update`, and writes `'\r' + bar`. Progress advances only when the caller reports it.
|
|
@@ -1311,10 +1363,11 @@ export declare class Progress implements ProgressInterface {
|
|
|
1311
1363
|
}
|
|
1312
1364
|
|
|
1313
1365
|
/**
|
|
1314
|
-
* Declares the observable events a {@link ProgressInterface} emits
|
|
1366
|
+
* Declares the observable events a {@link ProgressInterface} emits — `update(progress)` per
|
|
1367
|
+
* report, plus a `succeed` signal on a successful finish.
|
|
1315
1368
|
*
|
|
1316
1369
|
* @remarks
|
|
1317
|
-
* - `update` —
|
|
1370
|
+
* - `update` — fires on every `update(current)` (and on `succeed` / `fail`),
|
|
1318
1371
|
* carrying the `{ current, total }` progress (the clamped `current`). The hook a non-sink consumer
|
|
1319
1372
|
* rides to observe progress without a terminal.
|
|
1320
1373
|
* - `succeed` — the terminal signal: fires once from `succeed()` (a successful finish), a pure
|
|
@@ -1335,9 +1388,10 @@ export declare type ProgressEventMap = {
|
|
|
1335
1388
|
|
|
1336
1389
|
/**
|
|
1337
1390
|
* Declares an update-driven, observable progress bar — `update(current)` recomputes the bar through
|
|
1338
|
-
* {@link import('./helpers.js').renderBar}, writes `\r` + bar to its {@link SinkInterface}, and
|
|
1339
|
-
* the `{ current, total }` on `update`. The line-overwrite is the sink's job (a TTY sink
|
|
1340
|
-
* on the `\r`; a plain sink degrades to a fresh line). No self-timer — the caller drives
|
|
1391
|
+
* {@link import('./helpers.js').renderBar}, writes `\r` + bar to its {@link SinkInterface}, and
|
|
1392
|
+
* emits the `{ current, total }` on `update`. The line-overwrite is the sink's job (a TTY sink
|
|
1393
|
+
* overwrites on the `\r`; a plain sink degrades to a fresh line). No self-timer — the caller drives
|
|
1394
|
+
* it.
|
|
1341
1395
|
*
|
|
1342
1396
|
* @remarks
|
|
1343
1397
|
* - **Update-driven.** Each `update(current, message?)` clamps `current` to `[0, total]`, renders
|
|
@@ -1362,7 +1416,10 @@ export declare interface ProgressInterface {
|
|
|
1362
1416
|
readonly current: number;
|
|
1363
1417
|
/** Holds the target value the bar fills toward. */
|
|
1364
1418
|
readonly total: number;
|
|
1365
|
-
/**
|
|
1419
|
+
/**
|
|
1420
|
+
* Reports progress: clamps `current`, re-renders the bar, emits `update`, writes `\r` + bar.
|
|
1421
|
+
* Ignored after a terminal `succeed` or `fail`.
|
|
1422
|
+
*/
|
|
1366
1423
|
update(current: number, message?: string): void;
|
|
1367
1424
|
/** Finishes successfully — renders a full bar + newline, emits a final `update` then `succeed`. */
|
|
1368
1425
|
succeed(message?: string): void;
|
|
@@ -1373,7 +1430,9 @@ export declare interface ProgressInterface {
|
|
|
1373
1430
|
}
|
|
1374
1431
|
|
|
1375
1432
|
/**
|
|
1376
|
-
* Configures the {@link import('./Progress.js').Progress} constructor
|
|
1433
|
+
* Configures the {@link import('./Progress.js').Progress} constructor — the `on` / `error` emitter
|
|
1434
|
+
* keys, the required `total`, the `message` shown, the bar's `width` / `fill` / `empty` glyphs, and
|
|
1435
|
+
* the `sink` / `styler` / `theme` line substrate.
|
|
1377
1436
|
*
|
|
1378
1437
|
* @remarks
|
|
1379
1438
|
* - `on` — the reserved {@link EmitterHooks} key: initial listeners for the
|
|
@@ -1407,8 +1466,8 @@ export declare interface ProgressOptions {
|
|
|
1407
1466
|
}
|
|
1408
1467
|
|
|
1409
1468
|
/**
|
|
1410
|
-
* Reports one advance of a {@link ProgressInterface} — the clamped
|
|
1411
|
-
*
|
|
1469
|
+
* Reports one advance of a {@link ProgressInterface} — the clamped payload carried by the `update`
|
|
1470
|
+
* event of {@link ProgressEventMap}.
|
|
1412
1471
|
*
|
|
1413
1472
|
* @remarks
|
|
1414
1473
|
* `current` is always the value after clamping into `[0, total]`, so a listener never sees an
|
|
@@ -1423,12 +1482,15 @@ export declare interface ProgressReport {
|
|
|
1423
1482
|
|
|
1424
1483
|
/**
|
|
1425
1484
|
* Renders a determinate progress bar string — a filled / empty glyph track followed by the percentage
|
|
1426
|
-
* and the `(current/total)` count (`█████░░░░░ 50% (5/10)`). Pure: same
|
|
1427
|
-
* same string.
|
|
1428
|
-
* separator), shared so a {@link import('./types.js').ProgressInterface} and any direct caller draw
|
|
1429
|
-
* the one bar — never a second, hand-rolled one.
|
|
1485
|
+
* and the `(current/total)` count (`█████░░░░░ 50% (5/10)`). Pure and width-aware: same
|
|
1486
|
+
* {@link BarOptions} → same string.
|
|
1430
1487
|
*
|
|
1431
1488
|
* @remarks
|
|
1489
|
+
* It is the animation-layer sibling of the `render*` renderers (box / table / tree / separator),
|
|
1490
|
+
* shared so a {@link import('./types.js').ProgressInterface} and any direct caller draw the one
|
|
1491
|
+
* bar — never a second,
|
|
1492
|
+
* hand-rolled one.
|
|
1493
|
+
*
|
|
1432
1494
|
* - **Fill fraction, clamped.** The filled cell count is `round((current / total) · width)` with
|
|
1433
1495
|
* `current` clamped to `[0, total]`, so an overrun never over-fills and a negative never under-fills.
|
|
1434
1496
|
* A `total <= 0` renders a full track (there is nothing to fill toward — the work is trivially done).
|
|
@@ -1542,8 +1604,8 @@ export declare function renderSeparator(options: SeparatorOptions): string;
|
|
|
1542
1604
|
export declare function renderTable(options: TableOptions): string;
|
|
1543
1605
|
|
|
1544
1606
|
/**
|
|
1545
|
-
* Renders a nested {@link TreeNode} tree
|
|
1546
|
-
* {@link TreeOptions} → same string.
|
|
1607
|
+
* Renders a nested {@link TreeNode} tree whose connectors derive from the chosen `border` set.
|
|
1608
|
+
* Pure: same {@link TreeOptions} → same string.
|
|
1547
1609
|
*
|
|
1548
1610
|
* @remarks
|
|
1549
1611
|
* The `root` label is the unindented first line; its descendants are drawn beneath it with
|
|
@@ -1567,10 +1629,14 @@ export declare function renderTable(options: TableOptions): string;
|
|
|
1567
1629
|
export declare function renderTree(options: TreeOptions): string;
|
|
1568
1630
|
|
|
1569
1631
|
/**
|
|
1570
|
-
* Renders the connector-prefixed lines for a {@link TreeNode} list — the recursive core
|
|
1571
|
-
*
|
|
1572
|
-
*
|
|
1573
|
-
*
|
|
1632
|
+
* Renders the connector-prefixed lines for a {@link TreeNode} list — the recursive core behind
|
|
1633
|
+
* {@link renderTree}, whose third options argument requires `border` and groups the optional
|
|
1634
|
+
* `styler` and `style`.
|
|
1635
|
+
*
|
|
1636
|
+
* @remarks
|
|
1637
|
+
* Each child is drawn as `prefix` + its connector (`├─ ` for any but the last, `└─ ` for the
|
|
1638
|
+
* last) + its label, with its own descendants recursed beneath under the carried guide (`│ `
|
|
1639
|
+
* under a non-last node, ` ` under the last).
|
|
1574
1640
|
*
|
|
1575
1641
|
* @remarks
|
|
1576
1642
|
* A centralized, exported recursion branch so it is directly testable and
|
|
@@ -1695,7 +1761,9 @@ export declare interface ReporterInterface {
|
|
|
1695
1761
|
}
|
|
1696
1762
|
|
|
1697
1763
|
/**
|
|
1698
|
-
* Configures the {@link import('./Reporter.js').Reporter} constructor
|
|
1764
|
+
* Configures the {@link import('./Reporter.js').Reporter} constructor — the `sink` every line is
|
|
1765
|
+
* written to, the `styler` and `theme` it formats through, and the `width` its layouts measure
|
|
1766
|
+
* against.
|
|
1699
1767
|
*
|
|
1700
1768
|
* @remarks
|
|
1701
1769
|
* - `sink` — where every formatted line is written; defaults to
|
|
@@ -1727,7 +1795,8 @@ export declare const RESET: string;
|
|
|
1727
1795
|
export declare const RESET_CODE = 0;
|
|
1728
1796
|
|
|
1729
1797
|
/**
|
|
1730
|
-
* Implements the bounded, level-keyed retention engine
|
|
1798
|
+
* Implements the bounded, level-keyed retention engine the console and process captures buffer
|
|
1799
|
+
* through — one capped total buffer
|
|
1731
1800
|
* plus one capped bucket per level, generic over the record type each capture carries.
|
|
1732
1801
|
*
|
|
1733
1802
|
* @remarks
|
|
@@ -1781,9 +1850,15 @@ export declare class Retention<T extends {
|
|
|
1781
1850
|
export declare interface RetentionInterface<T extends {
|
|
1782
1851
|
readonly level: string;
|
|
1783
1852
|
}> {
|
|
1784
|
-
/**
|
|
1853
|
+
/**
|
|
1854
|
+
* Retains one record — appends it to the total buffer and to its level's bucket, evicting the
|
|
1855
|
+
* oldest of each past `limit`.
|
|
1856
|
+
*/
|
|
1785
1857
|
add(record: T): void;
|
|
1786
|
-
/**
|
|
1858
|
+
/**
|
|
1859
|
+
* Returns a copy of the whole retained buffer, oldest first, or — given a level — a copy of
|
|
1860
|
+
* that level's bucket, empty for a level with no bucket.
|
|
1861
|
+
*/
|
|
1787
1862
|
records(): readonly T[];
|
|
1788
1863
|
/** Returns a copy of one level's bucket, oldest first; empty for a level with no bucket. */
|
|
1789
1864
|
records(level: T['level']): readonly T[];
|
|
@@ -1792,9 +1867,9 @@ export declare interface RetentionInterface<T extends {
|
|
|
1792
1867
|
}
|
|
1793
1868
|
|
|
1794
1869
|
/**
|
|
1795
|
-
* Sets the
|
|
1796
|
-
* (and so `Reporter.timing`) switches from a `…ms` rendering to a `…s` (seconds, 2 d.p.)
|
|
1797
|
-
*
|
|
1870
|
+
* Sets the millisecond threshold at or above which {@link import('./helpers.js').formatDuration}
|
|
1871
|
+
* (and so `Reporter.timing`) switches from a `…ms` rendering to a `…s` (seconds, 2 d.p.) rendering
|
|
1872
|
+
* — `1000`, exactly one second.
|
|
1798
1873
|
*/
|
|
1799
1874
|
export declare const SECOND_MS = 1000;
|
|
1800
1875
|
|
|
@@ -1835,7 +1910,7 @@ export declare const SEPARATOR_TITLE_GAP = " ";
|
|
|
1835
1910
|
|
|
1836
1911
|
/**
|
|
1837
1912
|
* Configures {@link import('./helpers.js').renderSeparator} — a horizontal rule, optionally
|
|
1838
|
-
* carrying a centered title.
|
|
1913
|
+
* carrying a centered title. Every key is optional.
|
|
1839
1914
|
*
|
|
1840
1915
|
* @remarks
|
|
1841
1916
|
* - `title` — text to embed in the rule (for example a section heading). Omitted ⇒ an unbroken line.
|
|
@@ -1873,13 +1948,15 @@ export declare interface SeparatorOptions {
|
|
|
1873
1948
|
*/
|
|
1874
1949
|
export declare interface SinkInterface {
|
|
1875
1950
|
/**
|
|
1876
|
-
* Writes one already-formatted chunk of output
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
1879
|
-
*
|
|
1880
|
-
* terminator
|
|
1881
|
-
* `
|
|
1882
|
-
*
|
|
1951
|
+
* Writes one already-formatted chunk of output — one line without its terminator, or a
|
|
1952
|
+
* `\r`-leading redraw frame written verbatim, routed by the optional `level`.
|
|
1953
|
+
*
|
|
1954
|
+
* @remarks
|
|
1955
|
+
* The sink's target supplies the terminator (for example `console.log`; the server TTY sink
|
|
1956
|
+
* appends one), unless `text` begins with `\r`: that is an in-place redraw frame (the
|
|
1957
|
+
* Spinner / Progress animation protocol). A tick frame carries no terminator; a final frame
|
|
1958
|
+
* carries its own. `level` is the originating record's {@link LogLevel} — supplied so a
|
|
1959
|
+
* stream-aware sink can route (for example `error` to `stderr`); a plain sink ignores it.
|
|
1883
1960
|
*/
|
|
1884
1961
|
write(text: string, level?: LogLevel): void;
|
|
1885
1962
|
}
|
|
@@ -1887,12 +1964,14 @@ export declare interface SinkInterface {
|
|
|
1887
1964
|
/**
|
|
1888
1965
|
* Implements a self-driving, observable activity spinner — a glyph cycle that advances on a
|
|
1889
1966
|
* periodic timer, writing each `\r` + frame line to its {@link SinkInterface} and emitting it on
|
|
1890
|
-
* `frame`. The
|
|
1891
|
-
* sink degrades to a fresh, non-overwriting line — the line-overwrite is the sink's job, never
|
|
1892
|
-
* the spinner's. Universal — `setInterval` + the one {@link StylerInterface} + the one
|
|
1893
|
-
* {@link SinkInterface}, no `node:*`, no `process.stdout`.
|
|
1967
|
+
* `frame`. The timer is always cleared on an outcome, so the spinner is leak-free.
|
|
1894
1968
|
*
|
|
1895
1969
|
* @remarks
|
|
1970
|
+
* The leading `\r` is what an overwrite-capable sink (the TTY sink) redraws on; a plain sink
|
|
1971
|
+
* degrades to a fresh, non-overwriting line — the line-overwrite is the sink's job, never the
|
|
1972
|
+
* spinner's. Universal — `setInterval` + the one {@link StylerInterface} + the one
|
|
1973
|
+
* {@link SinkInterface}, no `node:*`, no `process.stdout`.
|
|
1974
|
+
*
|
|
1896
1975
|
* - **Self-driving but deterministically testable.** `start()` arms a `setInterval` that calls
|
|
1897
1976
|
* {@link tick} each `interval`; each {@link tick} builds the styled `glyph + message` line for the
|
|
1898
1977
|
* current frame, emits it on `frame`, writes `'\r' + line` to the sink, then advances the frame
|
|
@@ -1935,21 +2014,25 @@ export declare class Spinner implements SpinnerInterface {
|
|
|
1935
2014
|
}
|
|
1936
2015
|
|
|
1937
2016
|
/**
|
|
1938
|
-
* Holds the default spinner frame cycle a {@link import('./types.js').SpinnerInterface} advances
|
|
1939
|
-
* the
|
|
1940
|
-
*
|
|
2017
|
+
* Holds the default spinner frame cycle a {@link import('./types.js').SpinnerInterface} advances
|
|
2018
|
+
* through — the braille-pattern glyphs (`⠋⠙⠹…`, the U+2800 block) that read as a smoothly rotating
|
|
2019
|
+
* dot.
|
|
1941
2020
|
*
|
|
1942
2021
|
* @remarks
|
|
2022
|
+
* The cycle is the universal terminal-spinner convention. Frozen; a consumer swaps the whole
|
|
2023
|
+
* cycle through `options.frames`.
|
|
2024
|
+
*
|
|
1943
2025
|
* Braille glyphs are single visible cells, so every frame occupies one column — the spinner glyph
|
|
1944
2026
|
* never shifts the message beside it as it advances. The source of truth for the default frame axis.
|
|
1945
2027
|
*/
|
|
1946
2028
|
export declare const SPINNER_FRAMES: readonly string[];
|
|
1947
2029
|
|
|
1948
2030
|
/**
|
|
1949
|
-
* Declares the observable events a {@link SpinnerInterface} emits
|
|
2031
|
+
* Declares the observable events a {@link SpinnerInterface} emits — `frame(line)` per advance and
|
|
2032
|
+
* per outcome, plus the `start` and `stop` timer-lifecycle signals.
|
|
1950
2033
|
*
|
|
1951
2034
|
* @remarks
|
|
1952
|
-
* - `frame` —
|
|
2035
|
+
* - `frame` — fires once per advance (every `tick()`, whether driven by the internal
|
|
1953
2036
|
* timer or called directly) and on the final `succeed` / `fail` line, carrying the rendered frame
|
|
1954
2037
|
* line (the same text written to the sink, minus the leading `\r`). The hook a non-sink consumer
|
|
1955
2038
|
* (a test, a remote mirror) rides to observe the animation without a terminal.
|
|
@@ -2018,7 +2101,9 @@ export declare interface SpinnerInterface {
|
|
|
2018
2101
|
}
|
|
2019
2102
|
|
|
2020
2103
|
/**
|
|
2021
|
-
* Configures the {@link import('./Spinner.js').Spinner} constructor
|
|
2104
|
+
* Configures the {@link import('./Spinner.js').Spinner} constructor — the `on` / `error` emitter
|
|
2105
|
+
* keys, the `message` shown, the glyph `frames` and their `interval`, and the `sink` / `styler` /
|
|
2106
|
+
* `theme` line substrate.
|
|
2022
2107
|
*
|
|
2023
2108
|
* @remarks
|
|
2024
2109
|
* - `on` — the reserved {@link EmitterHooks} key: initial listeners for the
|
|
@@ -2072,8 +2157,9 @@ export declare const STATUS_ICONS: Readonly<Record<StatusLevel, string>>;
|
|
|
2072
2157
|
export declare const STATUS_LEVELS: readonly StatusLevel[];
|
|
2073
2158
|
|
|
2074
2159
|
/**
|
|
2075
|
-
* Names a narrative outcome level —
|
|
2076
|
-
* with its own icon + color
|
|
2160
|
+
* Names a narrative outcome level — `success` / `error` / `warn` / `info`, the states
|
|
2161
|
+
* {@link ReporterInterface.status} reports, each with its own icon + color
|
|
2162
|
+
* ({@link STATUS_ICONS} / {@link STATUS_COLORS}).
|
|
2077
2163
|
*
|
|
2078
2164
|
* @remarks
|
|
2079
2165
|
* distinct from {@link LogLevel} (`debug` / `info` / `warn` / `error`): a `StatusLevel` is a
|
|
@@ -2085,8 +2171,8 @@ export declare const STATUS_LEVELS: readonly StatusLevel[];
|
|
|
2085
2171
|
export declare type StatusLevel = 'success' | 'error' | 'warn' | 'info';
|
|
2086
2172
|
|
|
2087
2173
|
/**
|
|
2088
|
-
* Represents where one step sits in a sequence —
|
|
2089
|
-
*
|
|
2174
|
+
* Represents where one step sits in a sequence — what {@link ReporterInterface.step} renders as a
|
|
2175
|
+
* `[2/5]` prefix.
|
|
2090
2176
|
*
|
|
2091
2177
|
* @remarks
|
|
2092
2178
|
* Both are 1-based for display (`{ index: 2, total: 5 }` ⇒ `[2/5]`); the reporter formats
|
|
@@ -2151,7 +2237,8 @@ export declare function strip(text: string): string;
|
|
|
2151
2237
|
|
|
2152
2238
|
/**
|
|
2153
2239
|
* Removes every non-printing C0 control character from `text` except `\t` / `\n` / `\r`
|
|
2154
|
-
* (meaningful whitespace), plus DEL —
|
|
2240
|
+
* (meaningful whitespace), plus DEL — a separate pass from {@link strip}, so `width` stays
|
|
2241
|
+
* untouched.
|
|
2155
2242
|
*
|
|
2156
2243
|
* @remarks
|
|
2157
2244
|
* Deliberately separate from {@link strip} (ANSI-escape removal only, so `width` /
|
|
@@ -2262,14 +2349,15 @@ export declare interface StylerInterface {
|
|
|
2262
2349
|
}
|
|
2263
2350
|
|
|
2264
2351
|
/**
|
|
2265
|
-
* Configures {@link createStyler}
|
|
2352
|
+
* Configures {@link createStyler} — `renderer` selects the output target, defaulting to the ANSI
|
|
2353
|
+
* renderer, and `enabled` is the no-color switch, defaulting to `true`.
|
|
2266
2354
|
*
|
|
2267
2355
|
* @remarks
|
|
2268
|
-
* - `renderer` — the {@link RendererInterface} every style renders through
|
|
2269
|
-
*
|
|
2270
|
-
*
|
|
2271
|
-
* - `enabled` —
|
|
2272
|
-
*
|
|
2356
|
+
* - `renderer` — the {@link RendererInterface} every style renders through, so the styler
|
|
2357
|
+
* works unchanged in any terminal. Inject a browser `%c` renderer to retarget with no
|
|
2358
|
+
* other change.
|
|
2359
|
+
* - `enabled` — when `false`, the styler returns text verbatim, for a non-TTY, a
|
|
2360
|
+
* `NO_COLOR` environment, or piped output.
|
|
2273
2361
|
*/
|
|
2274
2362
|
export declare interface StylerOptions {
|
|
2275
2363
|
readonly renderer?: RendererInterface;
|
|
@@ -2277,8 +2365,9 @@ export declare interface StylerOptions {
|
|
|
2277
2365
|
}
|
|
2278
2366
|
|
|
2279
2367
|
/**
|
|
2280
|
-
* Configures {@link import('./helpers.js').renderTable} — a bordered grid of columns + rows
|
|
2281
|
-
*
|
|
2368
|
+
* Configures {@link import('./helpers.js').renderTable} — a bordered grid of columns + rows with
|
|
2369
|
+
* per-column alignment and width-aware sizing. A `Reporter` supplies its own chrome style only when
|
|
2370
|
+
* the caller gives neither `styler` nor `style`.
|
|
2282
2371
|
*
|
|
2283
2372
|
* @remarks
|
|
2284
2373
|
* - `columns` — the {@link ColumnSpec}s, left to right; their `label`s form the header row.
|
|
@@ -2300,9 +2389,8 @@ export declare interface TableOptions {
|
|
|
2300
2389
|
}
|
|
2301
2390
|
|
|
2302
2391
|
/**
|
|
2303
|
-
* Represents the app-wide semantic style vocabulary —
|
|
2304
|
-
*
|
|
2305
|
-
* surface speaks it.
|
|
2392
|
+
* Represents the app-wide semantic style vocabulary — each role bound to a {@link Style} value.
|
|
2393
|
+
* Pass one theme to a logger / reporter / spinner / progress and every surface speaks it.
|
|
2306
2394
|
*
|
|
2307
2395
|
* @remarks
|
|
2308
2396
|
* - `levels` — the label style per {@link LogLevel} (a log line's severity label).
|
|
@@ -2325,14 +2413,14 @@ export declare interface Theme {
|
|
|
2325
2413
|
}
|
|
2326
2414
|
|
|
2327
2415
|
/**
|
|
2328
|
-
* Holds the options for {@link createTheme} — the roles to override on {@link DEFAULT_THEME}
|
|
2416
|
+
* Holds the options for {@link createTheme} — the roles to override on {@link DEFAULT_THEME}, a
|
|
2417
|
+
* status supplying its whole copied `{ icon, style }` record.
|
|
2329
2418
|
*
|
|
2330
2419
|
* @remarks
|
|
2331
2420
|
* Every key is optional and merges per role, never per theme: an omitted role keeps its
|
|
2332
2421
|
* default, and `levels` / `statuses` merge per entry, so `{ levels: { warn: … } }` restyles
|
|
2333
|
-
* the `warn` label and leaves `debug`, `info`, and `error` alone.
|
|
2334
|
-
*
|
|
2335
|
-
* style leaf it receives.
|
|
2422
|
+
* the `warn` label and leaves `debug`, `info`, and `error` alone. {@link createTheme}
|
|
2423
|
+
* snapshots and freezes each status record and every style leaf it receives.
|
|
2336
2424
|
*/
|
|
2337
2425
|
export declare interface ThemeOptions {
|
|
2338
2426
|
readonly levels?: Readonly<Partial<Record<LogLevel, Style>>>;
|
|
@@ -2369,8 +2457,9 @@ export declare interface TreeNode {
|
|
|
2369
2457
|
}
|
|
2370
2458
|
|
|
2371
2459
|
/**
|
|
2372
|
-
* Configures {@link import('./helpers.js').renderTree} — a nested {@link TreeNode} tree drawn
|
|
2373
|
-
*
|
|
2460
|
+
* Configures {@link import('./helpers.js').renderTree} — a nested {@link TreeNode} tree drawn with
|
|
2461
|
+
* box-drawing connectors. A `Reporter` supplies its own chrome style only when the caller gives
|
|
2462
|
+
* neither `styler` nor `style`.
|
|
2374
2463
|
*
|
|
2375
2464
|
* @remarks
|
|
2376
2465
|
* - `root` — the top {@link TreeNode}; its `label` is the unindented first line and its
|
|
@@ -2410,8 +2499,8 @@ export declare interface TreeOptions {
|
|
|
2410
2499
|
export declare function width(text: string): number;
|
|
2411
2500
|
|
|
2412
2501
|
/**
|
|
2413
|
-
* Groups the
|
|
2414
|
-
*
|
|
2502
|
+
* Groups the write targets a level-routing sink chooses between — each of the backend's own member
|
|
2503
|
+
* type.
|
|
2415
2504
|
*
|
|
2416
2505
|
* @remarks
|
|
2417
2506
|
* The member type is the sink's own: a bound `console` method in core, a browser `%c` console
|