@orkestrel/console 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/browser/index.d.ts +32 -17
- package/dist/src/browser/index.js +19 -24
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +596 -394
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +224 -77
- package/dist/src/core/index.d.ts +224 -77
- package/dist/src/core/index.js +594 -393
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +47 -13
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +50 -19
- package/dist/src/server/index.d.ts +50 -19
- package/dist/src/server/index.js +47 -14
- package/dist/src/server/index.js.map +1 -1
- package/package.json +6 -4
package/dist/src/core/index.d.ts
CHANGED
|
@@ -200,6 +200,7 @@ export declare type BorderStyle = 'single' | 'double' | 'round' | 'heavy';
|
|
|
200
200
|
* that wide (content wider than the budget is not truncated — `renderTable` is the
|
|
201
201
|
* width-bounded renderer).
|
|
202
202
|
* - `styler` — colors the border (and title) when supplied; alignment is unaffected.
|
|
203
|
+
* - `style` — an optional by-value style rendered through `styler` for the frame and title.
|
|
203
204
|
*/
|
|
204
205
|
export declare interface BoxOptions {
|
|
205
206
|
readonly content: string;
|
|
@@ -208,6 +209,7 @@ export declare interface BoxOptions {
|
|
|
208
209
|
readonly border?: BorderStyle;
|
|
209
210
|
readonly width?: number;
|
|
210
211
|
readonly styler?: StylerInterface;
|
|
212
|
+
readonly style?: Style;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
/**
|
|
@@ -409,7 +411,7 @@ export declare interface CaptureOptions {
|
|
|
409
411
|
}
|
|
410
412
|
|
|
411
413
|
/**
|
|
412
|
-
* The structured outcome of {@link import('./
|
|
414
|
+
* The structured outcome of {@link import('./helpers.js').withCapture} — the wrapped function's
|
|
413
415
|
* own return `value` plus the {@link CapturedMessage}s intercepted while it ran.
|
|
414
416
|
*
|
|
415
417
|
* @remarks
|
|
@@ -450,7 +452,7 @@ export declare type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'mag
|
|
|
450
452
|
* chainable accessors. The source of truth for the color axis; the styler drives its
|
|
451
453
|
* accessors from this array so the literals live in one place.
|
|
452
454
|
*/
|
|
453
|
-
export declare const COLORS:
|
|
455
|
+
export declare const COLORS: ReadonlyArray<Exclude<Color, 'default'>>;
|
|
454
456
|
|
|
455
457
|
/**
|
|
456
458
|
* One column of a {@link TableOptions} — its header label and how its cells align.
|
|
@@ -768,6 +770,36 @@ export declare function createSpinner(options?: SpinnerOptions): SpinnerInterfac
|
|
|
768
770
|
*/
|
|
769
771
|
export declare function createStyler(options?: StylerOptions): StylerInterface;
|
|
770
772
|
|
|
773
|
+
/**
|
|
774
|
+
* Create a {@link Theme} — the app-wide semantic style vocabulary, merged role by role over
|
|
775
|
+
* {@link DEFAULT_THEME}. Hand one theme to a logger / reporter / spinner / progress and every
|
|
776
|
+
* surface speaks it; omit `options` for the defaults.
|
|
777
|
+
*
|
|
778
|
+
* @param options - See {@link ThemeOptions}
|
|
779
|
+
* @returns A frozen {@link Theme}
|
|
780
|
+
*
|
|
781
|
+
* @remarks
|
|
782
|
+
* - **Merges per ROLE, not per theme.** An omitted role keeps its default, and `levels` /
|
|
783
|
+
* `statuses` merge per ENTRY — `{ levels: { warn: … } }` restyles the `warn` label and
|
|
784
|
+
* leaves `debug` / `info` / `error` untouched.
|
|
785
|
+
* - **Frozen and shareable.** The factory snapshots and deep-freezes every style leaf. The
|
|
786
|
+
* returned theme and its `levels` / `statuses` records are frozen. Each status record is also
|
|
787
|
+
* copied and frozen. One theme is therefore safely shared across every entity.
|
|
788
|
+
*
|
|
789
|
+
* @example
|
|
790
|
+
* ```ts
|
|
791
|
+
* import { createStyler, createTheme } from '@src/core'
|
|
792
|
+
*
|
|
793
|
+
* const styler = createStyler()
|
|
794
|
+
* const theme = createTheme({
|
|
795
|
+
* levels: { warn: styler.brightYellow.bold.style }, // only the warn label changes
|
|
796
|
+
* accent: styler.magenta.style, // spinner glyph, progress fill, step prefix
|
|
797
|
+
* })
|
|
798
|
+
* theme.levels.error // still the default red
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
export declare function createTheme(options?: ThemeOptions): Theme;
|
|
802
|
+
|
|
771
803
|
/** The Control Sequence Introducer (`ESC[`) that opens every SGR sequence. */
|
|
772
804
|
export declare const CSI: string;
|
|
773
805
|
|
|
@@ -823,6 +855,21 @@ export declare const DEFAULT_PADDING = 1;
|
|
|
823
855
|
*/
|
|
824
856
|
export declare const DEFAULT_SPINNER_INTERVAL = 80;
|
|
825
857
|
|
|
858
|
+
/**
|
|
859
|
+
* The default {@link Theme} — every role bound to its default {@link Style}, deeply frozen.
|
|
860
|
+
* The base {@link import('./factories.js').createTheme} merges over, and the theme every
|
|
861
|
+
* entity uses when none is supplied.
|
|
862
|
+
*
|
|
863
|
+
* @remarks
|
|
864
|
+
* - `levels` — each {@link LogLevel} label in its {@link LEVEL_COLORS} color, no attributes.
|
|
865
|
+
* - `statuses` — each {@link StatusLevel}'s {@link STATUS_ICONS} glyph in its
|
|
866
|
+
* {@link STATUS_COLORS} color.
|
|
867
|
+
* - `accent` — `cyan`: the spinner glyph, the progress fill, a step prefix.
|
|
868
|
+
* - `chrome` — `dim`: separators, box / table / tree frames, and a log line's timestamp /
|
|
869
|
+
* name / data surround. A color-free attribute, so chrome recedes on any background.
|
|
870
|
+
*/
|
|
871
|
+
export declare const DEFAULT_THEME: Theme;
|
|
872
|
+
|
|
826
873
|
/**
|
|
827
874
|
* The default visible column width for the width-aware renderers — the separator rule and a
|
|
828
875
|
* {@link import('./helpers.js').renderBox} with no explicit `width`, and the reporter's
|
|
@@ -891,7 +938,7 @@ export declare function formatDuration(ms: number): string;
|
|
|
891
938
|
*
|
|
892
939
|
* @remarks
|
|
893
940
|
* Layout: `{time} {LEVEL} {[name]} {message}{ data}` — the ISO timestamp (dimmed), the
|
|
894
|
-
* upper-cased level label (
|
|
941
|
+
* upper-cased level label (rendered through the theme's level role),
|
|
895
942
|
* the originating logger's `name` in brackets (omitted when absent), the message, and the
|
|
896
943
|
* structured `data` appended as compact JSON (omitted when absent / empty). Coloring flows
|
|
897
944
|
* through the injected `styler`, so a disabled styler yields a plain line and a browser
|
|
@@ -900,15 +947,20 @@ export declare function formatDuration(ms: number): string;
|
|
|
900
947
|
*
|
|
901
948
|
* @param record - The {@link LogRecord} to render
|
|
902
949
|
* @param styler - The {@link StylerInterface} the labels are colored through
|
|
950
|
+
* @param theme - The {@link Theme} supplying the level and chrome roles
|
|
903
951
|
* @returns The formatted, styled line (no trailing newline — the sink's target adds it)
|
|
904
952
|
*
|
|
905
953
|
* @example
|
|
906
954
|
* ```ts
|
|
907
|
-
* formatRecord(
|
|
955
|
+
* formatRecord(
|
|
956
|
+
* { level: 'warn', message: 'low disk', time: 0, name: 'fs' },
|
|
957
|
+
* createStyler(),
|
|
958
|
+
* DEFAULT_THEME,
|
|
959
|
+
* )
|
|
908
960
|
* // '<dim>1970-01-01T00:00:00.000Z</> <yellow>WARN</> [fs] low disk'
|
|
909
961
|
* ```
|
|
910
962
|
*/
|
|
911
|
-
export declare function formatRecord(record: LogRecord, styler: StylerInterface): string;
|
|
963
|
+
export declare function formatRecord(record: LogRecord, styler: StylerInterface, theme: Theme): string;
|
|
912
964
|
|
|
913
965
|
/**
|
|
914
966
|
* Format a {@link LogRecord}'s `time` (epoch milliseconds) as an ISO-8601 timestamp string.
|
|
@@ -923,6 +975,23 @@ export declare function formatRecord(record: LogRecord, styler: StylerInterface)
|
|
|
923
975
|
*/
|
|
924
976
|
export declare function formatTime(time: number): string;
|
|
925
977
|
|
|
978
|
+
/**
|
|
979
|
+
* Snapshot and deeply freeze one {@link Style} value.
|
|
980
|
+
*
|
|
981
|
+
* @param style - The caller-owned style to snapshot
|
|
982
|
+
* @returns A frozen style record with an independently frozen attributes list
|
|
983
|
+
*
|
|
984
|
+
* @remarks
|
|
985
|
+
* The record spread captures accessor values once and preserves each present color channel.
|
|
986
|
+
* Copying `attributes` prevents later mutation of a caller-owned list from changing the result.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* ```ts
|
|
990
|
+
* freezeStyle({ foreground: 'red', attributes: ['bold'] })
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
993
|
+
export declare function freezeStyle(style: Style): Style;
|
|
994
|
+
|
|
926
995
|
/**
|
|
927
996
|
* Narrow an unknown caught value to a {@link ConsoleError}.
|
|
928
997
|
*
|
|
@@ -966,6 +1035,25 @@ export declare const LEVEL_SEVERITY: Readonly<Record<LogLevel, number>>;
|
|
|
966
1035
|
*/
|
|
967
1036
|
export declare const LEVELS: readonly LogLevel[];
|
|
968
1037
|
|
|
1038
|
+
/**
|
|
1039
|
+
* The line layout a logger writes — one {@link LogRecord} plus the styling substrate in,
|
|
1040
|
+
* one finished line out. {@link import('./helpers.js').formatRecord} is the default.
|
|
1041
|
+
*
|
|
1042
|
+
* @param record - The frozen record to lay out
|
|
1043
|
+
* @param styler - The logger's {@link StylerInterface} — color through it (and through
|
|
1044
|
+
* {@link StylerInterface.render} for a {@link Theme} role) so a disabled styler yields a
|
|
1045
|
+
* plain line with no second code path
|
|
1046
|
+
* @param theme - The logger's {@link Theme} — the level label style, the chrome surround
|
|
1047
|
+
* @returns The line to write, WITHOUT a trailing terminator (the sink's target supplies it)
|
|
1048
|
+
*
|
|
1049
|
+
* @remarks
|
|
1050
|
+
* The formatter owns the LINE; the `entry` event owns the RECORD. A transport that wants
|
|
1051
|
+
* structure rides the event rather than parsing a line back out of this. A formatter throw
|
|
1052
|
+
* propagates to the caller of `logger.info` and prevents that line's write, so keep it total.
|
|
1053
|
+
* A manager fans out sequentially; a formatter throw stops the remaining loggers for that call.
|
|
1054
|
+
*/
|
|
1055
|
+
export declare type LogFormatFunction = (record: LogRecord, styler: StylerInterface, theme: Theme) => string;
|
|
1056
|
+
|
|
969
1057
|
/**
|
|
970
1058
|
* An observable, leveled logger (AGENTS §13) — the entry point into the structured-logging
|
|
971
1059
|
* pipeline. Each `debug` / `info` / `warn` / `error` call builds a frozen {@link LogRecord},
|
|
@@ -1079,17 +1167,19 @@ export declare interface LoggerInterface {
|
|
|
1079
1167
|
* @remarks
|
|
1080
1168
|
* - **Registry (§9).** Loggers live in an insertion-ordered `Map` keyed by `name`.
|
|
1081
1169
|
* `register(name, options?)` mints a {@link Logger} named `name` — the manager's default
|
|
1082
|
-
* `level` / `sink` / `styler` / `limit` / `silent` flow in unless
|
|
1170
|
+
* `level` / `sink` / `styler` / `theme` / `format` / `limit` / `silent` flow in unless
|
|
1171
|
+
* `options` OVERRIDES them
|
|
1083
1172
|
* (`name` is always the registry key, so any `options.name` is ignored) — stores it (a
|
|
1084
1173
|
* re-`register` of the same name OVERWRITES, last write wins), and returns it. `count` is
|
|
1085
1174
|
* the map size, `logger(name)` looks one up, `loggers()` lists them in insertion order.
|
|
1086
1175
|
* - **Removal (§9.2).** `remove()` clears ALL, `remove(name)` drops ONE (`true` if present),
|
|
1087
|
-
* `remove(names)` drops a batch (`true` if any was removed).
|
|
1176
|
+
* `remove(names)` drops a batch (`true` if any was removed).
|
|
1088
1177
|
* (Removal does NOT `destroy` the returned loggers — a caller still holding one keeps using
|
|
1089
1178
|
* it; the manager simply stops tracking it.)
|
|
1090
1179
|
* - **Fan-out.** `debug` / `info` / `warn` / `error(message, data?)` forward the one call to
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1180
|
+
* every registered logger in insertion order; each gates / emits / writes per its own `level`
|
|
1181
|
+
* and `sink`. A formatter throw is a programmer error and propagates, stopping the remaining
|
|
1182
|
+
* loggers for that call. A fan-out over an empty registry is a no-op.
|
|
1093
1183
|
* - **Event-free.** No emitter, no events — the manager is a pure registry; observability is
|
|
1094
1184
|
* per-{@link Logger}.
|
|
1095
1185
|
*
|
|
@@ -1116,7 +1206,6 @@ export declare class LoggerManager implements LoggerManagerInterface {
|
|
|
1116
1206
|
remove(names: readonly string[]): boolean;
|
|
1117
1207
|
remove(name: string): boolean;
|
|
1118
1208
|
remove(): void;
|
|
1119
|
-
clear(): void;
|
|
1120
1209
|
}
|
|
1121
1210
|
|
|
1122
1211
|
/**
|
|
@@ -1130,7 +1219,7 @@ export declare class LoggerManager implements LoggerManagerInterface {
|
|
|
1130
1219
|
* (a re-`register` of the same name OVERWRITES — last write wins), and returns it.
|
|
1131
1220
|
* `logger(name)` looks one up; `loggers()` lists them in insertion order; `count` is the size.
|
|
1132
1221
|
* - **Removal (§9.2).** `remove()` clears ALL, `remove(name)` drops ONE, `remove(names)` drops
|
|
1133
|
-
* a batch (`true` when any was removed).
|
|
1222
|
+
* a batch (`true` when any was removed).
|
|
1134
1223
|
* - **Fan-out.** `debug` / `info` / `warn` / `error(message, data?)` forward the call to every
|
|
1135
1224
|
* registered logger (each gates / emits / writes per its own `level` and `sink`).
|
|
1136
1225
|
* - **Event-free.** No emitter, no events — each logger carries its own observability; the
|
|
@@ -1152,7 +1241,6 @@ export declare interface LoggerManagerInterface {
|
|
|
1152
1241
|
remove(): void;
|
|
1153
1242
|
remove(name: string): boolean;
|
|
1154
1243
|
remove(names: readonly string[]): boolean;
|
|
1155
|
-
clear(): void;
|
|
1156
1244
|
}
|
|
1157
1245
|
|
|
1158
1246
|
/**
|
|
@@ -1163,12 +1251,15 @@ export declare interface LoggerManagerInterface {
|
|
|
1163
1251
|
* registered {@link LoggerInterface} owns its observable `emitter`). These options supply
|
|
1164
1252
|
* the DEFAULTS flowed into every logger the manager mints, unless a per-`register` override
|
|
1165
1253
|
* wins: `level` (default threshold), `sink` (shared output target), `styler` (shared
|
|
1166
|
-
* coloring), `limit` (retention cap),
|
|
1254
|
+
* coloring), `theme` (semantic styles), `format` (line layout), `limit` (retention cap),
|
|
1255
|
+
* and `silent`.
|
|
1167
1256
|
*/
|
|
1168
1257
|
export declare interface LoggerManagerOptions {
|
|
1169
1258
|
readonly level?: LogLevel;
|
|
1170
1259
|
readonly sink?: SinkInterface;
|
|
1171
1260
|
readonly styler?: StylerInterface;
|
|
1261
|
+
readonly theme?: Theme;
|
|
1262
|
+
readonly format?: LogFormatFunction;
|
|
1172
1263
|
readonly limit?: number;
|
|
1173
1264
|
readonly silent?: boolean;
|
|
1174
1265
|
}
|
|
@@ -1187,6 +1278,10 @@ export declare interface LoggerManagerOptions {
|
|
|
1187
1278
|
* {@link import('./factories.js').createConsoleSink} (the snapshotted-console sink).
|
|
1188
1279
|
* - `styler` — the {@link StylerInterface} the line is colored through; defaults to
|
|
1189
1280
|
* {@link import('./factories.js').createStyler} (ANSI). Styling is orthogonal to level.
|
|
1281
|
+
* - `theme` — the {@link Theme} supplying the line's semantic styles; defaults to
|
|
1282
|
+
* {@link DEFAULT_THEME}.
|
|
1283
|
+
* - `format` — the {@link LogFormatFunction} that owns the written line; defaults to
|
|
1284
|
+
* {@link import('./helpers.js').formatRecord}.
|
|
1190
1285
|
* - `limit` — the bounded retention cap: at most this many recent records are kept
|
|
1191
1286
|
* (oldest dropped first). Defaults to {@link DEFAULT_LOG_LIMIT}; never unbounded.
|
|
1192
1287
|
* - `silent` — when `true`, suppresses the SINK WRITE only; `entry` still fires and the
|
|
@@ -1199,6 +1294,8 @@ export declare interface LoggerOptions {
|
|
|
1199
1294
|
readonly name?: string;
|
|
1200
1295
|
readonly sink?: SinkInterface;
|
|
1201
1296
|
readonly styler?: StylerInterface;
|
|
1297
|
+
readonly theme?: Theme;
|
|
1298
|
+
readonly format?: LogFormatFunction;
|
|
1202
1299
|
readonly limit?: number;
|
|
1203
1300
|
readonly silent?: boolean;
|
|
1204
1301
|
}
|
|
@@ -1276,9 +1373,10 @@ export declare function meetsLevel(threshold: LogLevel, level: LogLevel): boolea
|
|
|
1276
1373
|
*
|
|
1277
1374
|
* @param styler - The {@link StylerInterface} to color with, or `undefined` for no styling
|
|
1278
1375
|
* @param text - The glyphs / text to color
|
|
1376
|
+
* @param style - An optional {@link Style} to render by value instead of the styler's chain
|
|
1279
1377
|
* @returns `styler(text)` when a styler is given, else `text` unchanged
|
|
1280
1378
|
*/
|
|
1281
|
-
export declare function paint(styler: StylerInterface | undefined, text: string): string;
|
|
1379
|
+
export declare function paint(styler: StylerInterface | undefined, text: string, style?: Style): string;
|
|
1282
1380
|
|
|
1283
1381
|
/**
|
|
1284
1382
|
* An update-driven, observable progress bar (AGENTS §13) — {@link update} recomputes the bar via
|
|
@@ -1337,6 +1435,7 @@ export declare class Progress implements ProgressInterface {
|
|
|
1337
1435
|
* import('./helpers.js').width}), so a multi-cell glyph still yields a `width`-wide track.
|
|
1338
1436
|
* - `styler` — colors the FILLED run when supplied (the empty run + the trailing label stay plain);
|
|
1339
1437
|
* the layout is identical with or without color, since the track is measured on visible width.
|
|
1438
|
+
* - `style` — an optional by-value style rendered through `styler` for the filled run.
|
|
1340
1439
|
*/
|
|
1341
1440
|
export declare interface ProgressBarOptions {
|
|
1342
1441
|
readonly current: number;
|
|
@@ -1345,6 +1444,7 @@ export declare interface ProgressBarOptions {
|
|
|
1345
1444
|
readonly fill?: string;
|
|
1346
1445
|
readonly empty?: string;
|
|
1347
1446
|
readonly styler?: StylerInterface;
|
|
1447
|
+
readonly style?: Style;
|
|
1348
1448
|
}
|
|
1349
1449
|
|
|
1350
1450
|
/**
|
|
@@ -1424,10 +1524,14 @@ export declare interface ProgressInterface {
|
|
|
1424
1524
|
* `complete` / `failure` argument.
|
|
1425
1525
|
* - `width` — the bar track's visible cell count, handed to {@link import('./helpers.js').renderBar};
|
|
1426
1526
|
* defaults to {@link DEFAULT_BAR_WIDTH}.
|
|
1527
|
+
* - `fill` / `empty` — the filled and empty track glyphs handed to
|
|
1528
|
+
* {@link import('./helpers.js').renderBar}; default to {@link BAR_FILL} / {@link BAR_EMPTY}.
|
|
1427
1529
|
* - `sink` — where each `\r` + bar line is written; defaults to
|
|
1428
1530
|
* {@link import('./factories.js').createConsoleSink}. A TTY sink (C-g) overwrites on the `\r`.
|
|
1429
1531
|
* - `styler` — the {@link StylerInterface} the filled run is colored through; defaults to
|
|
1430
1532
|
* {@link import('./factories.js').createStyler} (ANSI). The ONE styler the whole system shares.
|
|
1533
|
+
* - `theme` — the {@link Theme} supplying the filled run's accent role; defaults to
|
|
1534
|
+
* {@link DEFAULT_THEME}.
|
|
1431
1535
|
*/
|
|
1432
1536
|
export declare interface ProgressOptions {
|
|
1433
1537
|
readonly on?: EmitterHooks<ProgressEventMap>;
|
|
@@ -1435,8 +1539,11 @@ export declare interface ProgressOptions {
|
|
|
1435
1539
|
readonly total: number;
|
|
1436
1540
|
readonly message?: string;
|
|
1437
1541
|
readonly width?: number;
|
|
1542
|
+
readonly fill?: string;
|
|
1543
|
+
readonly empty?: string;
|
|
1438
1544
|
readonly sink?: SinkInterface;
|
|
1439
1545
|
readonly styler?: StylerInterface;
|
|
1546
|
+
readonly theme?: Theme;
|
|
1440
1547
|
}
|
|
1441
1548
|
|
|
1442
1549
|
/**
|
|
@@ -1562,7 +1669,7 @@ export declare function renderTable(options: TableOptions): string;
|
|
|
1562
1669
|
*
|
|
1563
1670
|
* @remarks
|
|
1564
1671
|
* The `root` label is the unindented first line; its descendants are drawn beneath it with
|
|
1565
|
-
* {@link
|
|
1672
|
+
* {@link BORDER_CHARS} — `├─ ` before each child but the last, `└─ ` before the last, and the
|
|
1566
1673
|
* carried prefix using `│ ` under an ancestor that still has later siblings or ` ` under a
|
|
1567
1674
|
* last ancestor (so the guides line up exactly under the branch they descend from). Node
|
|
1568
1675
|
* labels are written as given (an already-styled label is honored); `options.styler` colors
|
|
@@ -1593,16 +1700,17 @@ export declare function renderTree(options: TreeOptions): string;
|
|
|
1593
1700
|
*
|
|
1594
1701
|
* @param nodes - The sibling {@link TreeNode}s to render at this depth
|
|
1595
1702
|
* @param prefix - The guide/gap string carried in from the ancestor chain (`''` at the root)
|
|
1596
|
-
* @param
|
|
1703
|
+
* @param options - The required `border` selection plus optional connector `styler` and
|
|
1704
|
+
* by-value `style`
|
|
1597
1705
|
* @returns The rendered lines for `nodes` and all their descendants
|
|
1598
1706
|
*
|
|
1599
1707
|
* @example
|
|
1600
1708
|
* ```ts
|
|
1601
|
-
* renderTreeChildren([{ label: 'a' }, { label: 'b' }], '')
|
|
1709
|
+
* renderTreeChildren([{ label: 'a' }, { label: 'b' }], '', { border: 'single' })
|
|
1602
1710
|
* // ['├─ a', '└─ b']
|
|
1603
1711
|
* ```
|
|
1604
1712
|
*/
|
|
1605
|
-
export declare function renderTreeChildren(nodes: readonly TreeNode[], prefix: string, styler
|
|
1713
|
+
export declare function renderTreeChildren(nodes: readonly TreeNode[], prefix: string, options: Required<Pick<TreeOptions, 'border'>> & Pick<TreeOptions, 'style' | 'styler'>): readonly string[];
|
|
1606
1714
|
|
|
1607
1715
|
/**
|
|
1608
1716
|
* Repeat `unit` until it fills exactly `count` VISIBLE columns, trimming a trailing partial
|
|
@@ -1638,7 +1746,7 @@ export declare function repeatTo(unit: string, count: number): string;
|
|
|
1638
1746
|
* capture (the capture chunk), no level retention (the logger). Just format + write.
|
|
1639
1747
|
* - **`status` is a narrative OUTCOME, not a log level.** Its {@link StatusLevel} (`success` /
|
|
1640
1748
|
* `error` / `warn` / `info`) is distinct from {@link import('./types.js').LogLevel}: an icon
|
|
1641
|
-
*
|
|
1749
|
+
* supplied theme status icon + style, with `error` routed to the sink's
|
|
1642
1750
|
* error stream (the `level` hint forwarded to {@link SinkInterface.write}) — there is no
|
|
1643
1751
|
* gating and no severity ordering.
|
|
1644
1752
|
* - **Width-aware.** `section` (and a `box` with no explicit `width`) lay out to the reporter's
|
|
@@ -1719,6 +1827,8 @@ export declare interface ReporterInterface {
|
|
|
1719
1827
|
* - `styler` — the {@link StylerInterface} every line is colored through; defaults to
|
|
1720
1828
|
* {@link import('./factories.js').createStyler} (ANSI). The ONE styler the whole system
|
|
1721
1829
|
* shares — no second colorizer. A disabled styler yields plain narration.
|
|
1830
|
+
* - `theme` — the {@link Theme} supplying status, accent, and chrome roles; defaults to
|
|
1831
|
+
* {@link DEFAULT_THEME}.
|
|
1722
1832
|
* - `width` — the default column width handed to the separator / box renderers (the section
|
|
1723
1833
|
* rule, a `box` with no explicit width); defaults to {@link DEFAULT_WIDTH}.
|
|
1724
1834
|
*
|
|
@@ -1728,6 +1838,7 @@ export declare interface ReporterInterface {
|
|
|
1728
1838
|
export declare interface ReporterOptions {
|
|
1729
1839
|
readonly sink?: SinkInterface;
|
|
1730
1840
|
readonly styler?: StylerInterface;
|
|
1841
|
+
readonly theme?: Theme;
|
|
1731
1842
|
readonly width?: number;
|
|
1732
1843
|
}
|
|
1733
1844
|
|
|
@@ -1764,12 +1875,14 @@ export declare const SEPARATOR_TITLE_GAP = " ";
|
|
|
1764
1875
|
* (`─`). The VISIBLE width of the rule is `width` regardless of the fill's escape codes.
|
|
1765
1876
|
* - `styler` — colors the rule (and the embedded title) when supplied; the layout is
|
|
1766
1877
|
* identical with or without it, since width is measured on the visible content.
|
|
1878
|
+
* - `style` — an optional by-value style rendered through `styler` for the rule and title.
|
|
1767
1879
|
*/
|
|
1768
1880
|
export declare interface SeparatorOptions {
|
|
1769
1881
|
readonly title?: string;
|
|
1770
1882
|
readonly width?: number;
|
|
1771
1883
|
readonly fill?: string;
|
|
1772
1884
|
readonly styler?: StylerInterface;
|
|
1885
|
+
readonly style?: Style;
|
|
1773
1886
|
}
|
|
1774
1887
|
|
|
1775
1888
|
/**
|
|
@@ -1794,7 +1907,8 @@ export declare interface SinkInterface {
|
|
|
1794
1907
|
* Write one already-formatted chunk of output. `text` receives ONE LINE WITHOUT its
|
|
1795
1908
|
* terminator — the sink's target supplies it (e.g. `console.log`; the server TTY sink
|
|
1796
1909
|
* appends one) — UNLESS `text` begins with `\r`: that is an in-place REDRAW frame (the
|
|
1797
|
-
* Spinner / Progress animation protocol)
|
|
1910
|
+
* Spinner / Progress animation protocol), written verbatim. A tick frame carries no
|
|
1911
|
+
* terminator; a final frame carries its own.
|
|
1798
1912
|
* `level` is the originating record's {@link LogLevel} — supplied so a stream-aware sink
|
|
1799
1913
|
* can route (e.g. `error` to `stderr`); a plain sink ignores it.
|
|
1800
1914
|
*/
|
|
@@ -1821,7 +1935,7 @@ export declare interface SinkInterface {
|
|
|
1821
1935
|
* - **Idempotent `start`.** A {@link start} while already `active` is a no-op (it never arms a second
|
|
1822
1936
|
* timer).
|
|
1823
1937
|
* - **Outcome lines.** {@link success} / {@link failure} clear the timer then write + emit a FINAL line —
|
|
1824
|
-
* the
|
|
1938
|
+
* the supplied theme status icon + style (`✔` / `✖` by default) + the message — terminated
|
|
1825
1939
|
* by a newline (the activity is over; the line is committed, not overwritten). {@link failure} routes to
|
|
1826
1940
|
* the sink's error stream.
|
|
1827
1941
|
* - **Lifecycle (§10).** {@link stop} clears the timer and LEAVES the current line; {@link destroy}
|
|
@@ -1905,7 +2019,7 @@ export declare type SpinnerEventMap = {
|
|
|
1905
2019
|
* - **Idempotent `start`.** A `start()` while already `active` is a no-op (it never arms a second
|
|
1906
2020
|
* timer). `active` reflects whether the timer is currently armed.
|
|
1907
2021
|
* - **Outcome lines.** `success(message?)` / `failure(message?)` clear the timer, then write + emit a
|
|
1908
|
-
* FINAL line — the
|
|
2022
|
+
* FINAL line — the theme's success / error status icon + style (`✔` / `✖` by default) + the
|
|
1909
2023
|
* message — terminated by a newline (the activity is over; the line is committed, not overwritten).
|
|
1910
2024
|
* `failure` routes to the sink's error stream.
|
|
1911
2025
|
* - **Lifecycle (§10).** `stop()` clears the timer and LEAVES the current line (no final write);
|
|
@@ -1952,6 +2066,8 @@ export declare interface SpinnerInterface {
|
|
|
1952
2066
|
* {@link import('./factories.js').createConsoleSink}. A TTY sink (C-g) overwrites on the `\r`.
|
|
1953
2067
|
* - `styler` — the {@link StylerInterface} the glyph is colored through; defaults to
|
|
1954
2068
|
* {@link import('./factories.js').createStyler} (ANSI). The ONE styler the whole system shares.
|
|
2069
|
+
* - `theme` — the {@link Theme} supplying the accent and outcome roles; defaults to
|
|
2070
|
+
* {@link DEFAULT_THEME}.
|
|
1955
2071
|
*/
|
|
1956
2072
|
export declare interface SpinnerOptions {
|
|
1957
2073
|
readonly on?: EmitterHooks<SpinnerEventMap>;
|
|
@@ -1961,6 +2077,7 @@ export declare interface SpinnerOptions {
|
|
|
1961
2077
|
readonly interval?: number;
|
|
1962
2078
|
readonly sink?: SinkInterface;
|
|
1963
2079
|
readonly styler?: StylerInterface;
|
|
2080
|
+
readonly theme?: Theme;
|
|
1964
2081
|
}
|
|
1965
2082
|
|
|
1966
2083
|
/**
|
|
@@ -2102,51 +2219,6 @@ export declare interface Style {
|
|
|
2102
2219
|
readonly attributes: readonly Attribute[];
|
|
2103
2220
|
}
|
|
2104
2221
|
|
|
2105
|
-
/**
|
|
2106
|
-
* The fluent, composable styler — the consumer-facing API over the style engine. It
|
|
2107
|
-
* builds a {@link Style} (style as DATA) and renders it through an injected
|
|
2108
|
-
* {@link RendererInterface} (the ANSI default, or a browser `%c` renderer at C-f). Each
|
|
2109
|
-
* color / attribute accessor is immutable copy-on-write: it returns a NEW styler's
|
|
2110
|
-
* surface with the token added, so `styler.red.bold('hi')` composes without mutating,
|
|
2111
|
-
* and a base styler is freely reusable.
|
|
2112
|
-
*
|
|
2113
|
-
* @remarks
|
|
2114
|
-
* - **Callable surface.** A `Styler` is not itself callable; its {@link surface} getter
|
|
2115
|
-
* returns the {@link StylerInterface} — a render FUNCTION carrying the chainable
|
|
2116
|
-
* accessors. The accessors are installed as LAZY getters (`Object.defineProperties`),
|
|
2117
|
-
* so a chain materializes only the stylers it actually walks — never the full tree —
|
|
2118
|
-
* and the recursion terminates. The factory returns that surface; this class is the
|
|
2119
|
-
* engine behind it.
|
|
2120
|
-
* - **Immutable.** `#foreground` and `#attribute` return a fresh `Styler` (the style is
|
|
2121
|
-
* rebuilt, never mutated). A later color of the same channel WINS (last write); a
|
|
2122
|
-
* repeated attribute is idempotent (de-duplicated, order preserved).
|
|
2123
|
-
* - **`enabled` switch.** When `false`, the render function returns text VERBATIM — no
|
|
2124
|
-
* renderer call, no escape codes (for a non-TTY / `NO_COLOR` / piped output).
|
|
2125
|
-
* - **Event-free** — a pure styling primitive (AGENTS §13), like `Scheduler`.
|
|
2126
|
-
*/
|
|
2127
|
-
export declare class Styler {
|
|
2128
|
-
#private;
|
|
2129
|
-
constructor(renderer: RendererInterface, enabled: boolean, style: Style);
|
|
2130
|
-
/** The accumulated style DATA — the empty style on a base styler. */
|
|
2131
|
-
get style(): Style;
|
|
2132
|
-
/** Whether styling is applied; when `false`, the surface returns text unchanged. */
|
|
2133
|
-
get enabled(): boolean;
|
|
2134
|
-
/**
|
|
2135
|
-
* The fluent {@link StylerInterface} value — a render function (`text => string`) with
|
|
2136
|
-
* `style`, `enabled`, and every {@link Color} / {@link Attribute} as a LAZY accessor
|
|
2137
|
-
* (each computes the next styler's surface only when read). This is what consumers
|
|
2138
|
-
* hold and call.
|
|
2139
|
-
*
|
|
2140
|
-
* @remarks
|
|
2141
|
-
* The accessors are defined as getters (not eagerly-merged values), so accessing one
|
|
2142
|
-
* builds exactly one child styler — the tree is never fully materialized and the
|
|
2143
|
-
* construction terminates. The assembled function is then narrowed to
|
|
2144
|
-
* {@link StylerInterface} through {@link #isSurface} (a real structural check), so no
|
|
2145
|
-
* type assertion is used (AGENTS §1 / §14 — narrow, never assert).
|
|
2146
|
-
*/
|
|
2147
|
-
get surface(): StylerInterface;
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
2222
|
/**
|
|
2151
2223
|
* The fluent, composable styling surface — the consumer-facing API. It is BOTH a
|
|
2152
2224
|
* function (call it with text to render the accumulated style) AND a record of
|
|
@@ -2159,6 +2231,10 @@ export declare class Styler {
|
|
|
2159
2231
|
* styler is reusable and the chains never interfere.
|
|
2160
2232
|
* - Calling the styler builds the {@link Style} under the hood and renders it through the
|
|
2161
2233
|
* injected renderer. When `enabled` is `false`, it returns the text verbatim.
|
|
2234
|
+
* - `render` is the DATA door beside the accessor chain: it renders a {@link Style} value
|
|
2235
|
+
* (a {@link Theme} role, say) merged over the accumulated style, so a caller styles by
|
|
2236
|
+
* value where the chain styles by name. Both go through the same renderer and the same
|
|
2237
|
+
* `enabled` switch.
|
|
2162
2238
|
* - `style` exposes the accumulated style DATA (the empty style on a base styler), and
|
|
2163
2239
|
* `enabled` reflects the switch — both inspectable and testable.
|
|
2164
2240
|
* - A later color of the same channel wins (`styler.red.blue` is blue); a repeated
|
|
@@ -2171,6 +2247,26 @@ export declare interface StylerInterface {
|
|
|
2171
2247
|
readonly style: Style;
|
|
2172
2248
|
/** Whether styling is applied; when `false`, calls return text unchanged. */
|
|
2173
2249
|
readonly enabled: boolean;
|
|
2250
|
+
/**
|
|
2251
|
+
* Render `text` in `style` merged OVER the accumulated style — the by-value counterpart
|
|
2252
|
+
* of the accessor chain, and the door a {@link Theme} role is applied through.
|
|
2253
|
+
*
|
|
2254
|
+
* @param style - The style to overlay; its colors win over the accumulated ones and its
|
|
2255
|
+
* attributes join them (de-duplicated, accumulated ones first)
|
|
2256
|
+
* @param text - The text to wrap
|
|
2257
|
+
* @returns The rendered text — verbatim when `enabled` is `false`, and (by the
|
|
2258
|
+
* {@link RendererInterface} contract) when the merged style or `text` is empty
|
|
2259
|
+
*
|
|
2260
|
+
* @example
|
|
2261
|
+
* ```ts
|
|
2262
|
+
* import { createStyler, DEFAULT_THEME } from '@src/core'
|
|
2263
|
+
*
|
|
2264
|
+
* const styler = createStyler()
|
|
2265
|
+
* styler.render(DEFAULT_THEME.levels.warn, 'WARN') // yellow
|
|
2266
|
+
* styler.bold.render(DEFAULT_THEME.chrome, '│') // dim, over the accumulated bold
|
|
2267
|
+
* ```
|
|
2268
|
+
*/
|
|
2269
|
+
render(style: Style, text: string): string;
|
|
2174
2270
|
readonly black: StylerInterface;
|
|
2175
2271
|
readonly red: StylerInterface;
|
|
2176
2272
|
readonly green: StylerInterface;
|
|
@@ -2223,25 +2319,71 @@ export declare interface StylerOptions {
|
|
|
2223
2319
|
* - `styler` — colors the border + header labels when supplied; the cells are written as
|
|
2224
2320
|
* given (already-styled cells are honored — their VISIBLE width drives column sizing, never
|
|
2225
2321
|
* their raw `.length`).
|
|
2322
|
+
* - `style` — an optional by-value style rendered through `styler` for the frame and headers.
|
|
2226
2323
|
*/
|
|
2227
2324
|
export declare interface TableOptions {
|
|
2228
2325
|
readonly columns: readonly ColumnSpec[];
|
|
2229
|
-
readonly rows: readonly
|
|
2326
|
+
readonly rows: ReadonlyArray<readonly string[]>;
|
|
2230
2327
|
readonly border?: BorderStyle;
|
|
2231
2328
|
readonly styler?: StylerInterface;
|
|
2329
|
+
readonly style?: Style;
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
/**
|
|
2333
|
+
* The app-wide semantic style vocabulary — every role the console system styles, bound to a
|
|
2334
|
+
* {@link Style} value. Pass one theme to a logger / reporter / spinner / progress and every
|
|
2335
|
+
* surface speaks it.
|
|
2336
|
+
*
|
|
2337
|
+
* @remarks
|
|
2338
|
+
* - `levels` — the label style per {@link LogLevel} (a log line's severity label).
|
|
2339
|
+
* - `statuses` — the icon + style per {@link StatusLevel} (a reporter outcome, a spinner's
|
|
2340
|
+
* final line).
|
|
2341
|
+
* - `accent` — the one highlight role: a spinner glyph, a progress bar's filled run, a
|
|
2342
|
+
* step prefix.
|
|
2343
|
+
* - `chrome` — the frame role: separators, box / table / tree connectors, and a log line's
|
|
2344
|
+
* timestamp / name / data surround.
|
|
2345
|
+
* - A theme is the vocabulary the WHOLE application shares; a per-entity option (a
|
|
2346
|
+
* `ProgressOptions.fill`, a `BoxOptions.border`) is the presentation of that one instance.
|
|
2347
|
+
* - A theme returned by {@link createTheme} is frozen with every {@link Style} leaf deeply
|
|
2348
|
+
* frozen, so one theme is safely shared across every entity.
|
|
2349
|
+
*/
|
|
2350
|
+
export declare interface Theme {
|
|
2351
|
+
readonly levels: Readonly<Record<LogLevel, Style>>;
|
|
2352
|
+
readonly statuses: Readonly<Record<StatusLevel, ThemeStatus>>;
|
|
2353
|
+
readonly accent: Style;
|
|
2354
|
+
readonly chrome: Style;
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
/**
|
|
2358
|
+
* Options for {@link createTheme} — the roles to override on {@link DEFAULT_THEME}.
|
|
2359
|
+
*
|
|
2360
|
+
* @remarks
|
|
2361
|
+
* Every key is optional and merges per ROLE, never per theme: an omitted role keeps its
|
|
2362
|
+
* default, and `levels` / `statuses` merge per entry, so `{ levels: { warn: … } }` restyles
|
|
2363
|
+
* the `warn` label and leaves the other three alone. A status override supplies its whole
|
|
2364
|
+
* `{ icon, style }` record; {@link createTheme} snapshots and freezes that record and every
|
|
2365
|
+
* style leaf it receives.
|
|
2366
|
+
*/
|
|
2367
|
+
export declare interface ThemeOptions {
|
|
2368
|
+
readonly levels?: Readonly<Partial<Record<LogLevel, Style>>>;
|
|
2369
|
+
readonly statuses?: Readonly<Partial<Record<StatusLevel, ThemeStatus>>>;
|
|
2370
|
+
readonly accent?: Style;
|
|
2371
|
+
readonly chrome?: Style;
|
|
2232
2372
|
}
|
|
2233
2373
|
|
|
2234
2374
|
/**
|
|
2235
|
-
*
|
|
2236
|
-
*
|
|
2237
|
-
*
|
|
2375
|
+
* One narrative outcome's presentation — the icon glyph a {@link StatusLevel} shows and the
|
|
2376
|
+
* {@link Style} the line renders in.
|
|
2377
|
+
*
|
|
2378
|
+
* @remarks
|
|
2379
|
+
* The themed counterpart of the {@link STATUS_ICONS} / {@link STATUS_COLORS} defaults: those
|
|
2380
|
+
* two constants are the SOURCE of {@link DEFAULT_THEME}'s statuses. A status override supplies
|
|
2381
|
+
* the whole record — both `icon` and `style` — through {@link ThemeOptions}.
|
|
2238
2382
|
*/
|
|
2239
|
-
export declare
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
gap: " ";
|
|
2244
|
-
}>;
|
|
2383
|
+
export declare interface ThemeStatus {
|
|
2384
|
+
readonly icon: string;
|
|
2385
|
+
readonly style: Style;
|
|
2386
|
+
}
|
|
2245
2387
|
|
|
2246
2388
|
/**
|
|
2247
2389
|
* One node of a {@link TreeOptions} tree — a label plus optional children, recursively.
|
|
@@ -2264,11 +2406,16 @@ export declare interface TreeNode {
|
|
|
2264
2406
|
* - `root` — the top {@link TreeNode}; its `label` is the unindented first line and its
|
|
2265
2407
|
* `children` descend beneath it (`├─` for each but the last, `└─` for the last, `│` guides
|
|
2266
2408
|
* carried down through earlier branches).
|
|
2409
|
+
* - `border` — the {@link BorderStyle} whose junction set supplies every connector;
|
|
2410
|
+
* defaults to {@link DEFAULT_BORDER} (`single`).
|
|
2267
2411
|
* - `styler` — colors the connectors when supplied; node labels are written as given.
|
|
2412
|
+
* - `style` — an optional by-value style rendered through `styler` for the connectors.
|
|
2268
2413
|
*/
|
|
2269
2414
|
export declare interface TreeOptions {
|
|
2270
2415
|
readonly root: TreeNode;
|
|
2416
|
+
readonly border?: BorderStyle;
|
|
2271
2417
|
readonly styler?: StylerInterface;
|
|
2418
|
+
readonly style?: Style;
|
|
2272
2419
|
}
|
|
2273
2420
|
|
|
2274
2421
|
/**
|