@peteanderson/ansi 1.0.0 → 2.0.0
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/LICENSE +7 -0
- package/README.md +194 -0
- package/dist/ansi.d.ts +79 -41
- package/dist/ansi.d.ts.map +1 -1
- package/dist/ansi.js +9 -6
- package/dist/ansi.js.map +1 -1
- package/dist/features/build.d.ts.map +1 -1
- package/dist/features/build.js.map +1 -1
- package/dist/features/detect.d.ts.map +1 -1
- package/dist/features/detect.js.map +1 -1
- package/dist/features/features.d.ts +1 -3
- package/dist/features/features.d.ts.map +1 -1
- package/dist/features/features.js +12 -13
- package/dist/features/features.js.map +1 -1
- package/dist/features/index.d.ts +1 -0
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/types.d.ts +2 -0
- package/dist/features/types.d.ts.map +1 -1
- package/dist/pad.d.ts +10 -0
- package/dist/pad.d.ts.map +1 -1
- package/dist/pad.js +8 -0
- package/dist/pad.js.map +1 -1
- package/dist/sgr/color/channel.d.ts +4 -0
- package/dist/sgr/color/channel.d.ts.map +1 -0
- package/dist/sgr/color/channel.js +33 -0
- package/dist/sgr/color/channel.js.map +1 -0
- package/dist/sgr/color/color.d.ts +3 -4
- package/dist/sgr/color/color.d.ts.map +1 -1
- package/dist/sgr/color/color.js +16 -65
- package/dist/sgr/color/color.js.map +1 -1
- package/dist/sgr/color/context.d.ts +13 -0
- package/dist/sgr/color/context.d.ts.map +1 -0
- package/dist/sgr/color/context.js +24 -0
- package/dist/sgr/color/context.js.map +1 -0
- package/dist/sgr/color/rgb.d.ts +5 -0
- package/dist/sgr/color/rgb.d.ts.map +1 -0
- package/dist/sgr/color/rgb.js +32 -0
- package/dist/sgr/color/rgb.js.map +1 -0
- package/dist/sgr/color/utils.d.ts.map +1 -1
- package/dist/sgr/color/utils.js +12 -4
- package/dist/sgr/color/utils.js.map +1 -1
- package/dist/sgr/combine.d.ts +3 -0
- package/dist/sgr/combine.d.ts.map +1 -0
- package/dist/sgr/combine.js +14 -0
- package/dist/sgr/combine.js.map +1 -0
- package/dist/sgr/format-builder.d.ts +3 -0
- package/dist/sgr/format-builder.d.ts.map +1 -0
- package/dist/sgr/format-builder.js +33 -0
- package/dist/sgr/format-builder.js.map +1 -0
- package/dist/sgr/index.d.ts +2 -3
- package/dist/sgr/index.d.ts.map +1 -1
- package/dist/sgr/index.js +1 -3
- package/dist/sgr/index.js.map +1 -1
- package/dist/sgr/lazy.d.ts +6 -0
- package/dist/sgr/lazy.d.ts.map +1 -0
- package/dist/sgr/lazy.js +17 -0
- package/dist/sgr/lazy.js.map +1 -0
- package/dist/sgr/sgr.d.ts +3 -14
- package/dist/sgr/sgr.d.ts.map +1 -1
- package/dist/sgr/sgr.js +44 -37
- package/dist/sgr/sgr.js.map +1 -1
- package/dist/sgr/style.d.ts +2 -14
- package/dist/sgr/style.d.ts.map +1 -1
- package/dist/sgr/style.js +27 -16
- package/dist/sgr/style.js.map +1 -1
- package/dist/sgr/types.d.ts +59 -0
- package/dist/sgr/types.d.ts.map +1 -0
- package/dist/sgr/{color/types.js.map → types.js.map} +1 -1
- package/dist/simplify/atom.d.ts.map +1 -1
- package/dist/simplify/atom.js +8 -1
- package/dist/simplify/atom.js.map +1 -1
- package/dist/simplify/simplify.d.ts +1 -0
- package/dist/simplify/simplify.d.ts.map +1 -1
- package/dist/slice.d.ts +1 -0
- package/dist/slice.d.ts.map +1 -1
- package/dist/slice.js +1 -0
- package/dist/slice.js.map +1 -1
- package/dist/strip.d.ts +6 -0
- package/dist/strip.d.ts.map +1 -1
- package/dist/strip.js +3 -0
- package/dist/strip.js.map +1 -1
- package/dist/typed-object.d.ts +16 -0
- package/dist/typed-object.d.ts.map +1 -0
- package/dist/typed-object.js +36 -0
- package/dist/typed-object.js.map +1 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +26 -10
- package/src/ansi.ts +11 -36
- package/src/features/build.ts +4 -3
- package/src/features/detect.ts +6 -3
- package/src/features/features.ts +19 -30
- package/src/features/index.ts +2 -0
- package/src/features/types.ts +9 -0
- package/src/pad.ts +12 -1
- package/src/sgr/color/channel.ts +44 -0
- package/src/sgr/color/color.ts +30 -95
- package/src/sgr/color/context.ts +44 -0
- package/src/sgr/color/index.ts +1 -1
- package/src/sgr/color/rgb.ts +48 -0
- package/src/sgr/color/utils.ts +13 -4
- package/src/sgr/combine.ts +13 -0
- package/src/sgr/format-builder.ts +47 -0
- package/src/sgr/index.ts +3 -3
- package/src/sgr/lazy.ts +21 -0
- package/src/sgr/sgr.ts +61 -57
- package/src/sgr/style.ts +35 -18
- package/src/sgr/types.ts +91 -0
- package/src/simplify/atom.ts +8 -2
- package/src/simplify/simplify.ts +3 -1
- package/src/slice.ts +4 -1
- package/src/strip.ts +10 -1
- package/src/typed-object.ts +85 -0
- package/src/types.ts +28 -0
- package/src/utility-types.d.ts +18 -0
- package/dist/sgr/color/test-rgb.d.ts +0 -3
- package/dist/sgr/color/test-rgb.d.ts.map +0 -1
- package/dist/sgr/color/test-rgb.js +0 -149
- package/dist/sgr/color/test-rgb.js.map +0 -1
- package/dist/sgr/color/types.d.ts +0 -30
- package/dist/sgr/color/types.d.ts.map +0 -1
- package/dist/sgr/utils.d.ts +0 -3
- package/dist/sgr/utils.d.ts.map +0 -1
- package/dist/sgr/utils.js +0 -16
- package/dist/sgr/utils.js.map +0 -1
- package/dist/simplify/test.d.ts +0 -2
- package/dist/simplify/test.d.ts.map +0 -1
- package/dist/simplify/test.js +0 -64
- package/dist/simplify/test.js.map +0 -1
- package/src/sgr/color/types.ts +0 -32
- package/src/sgr/utils.ts +0 -17
- /package/dist/sgr/{color/types.js → types.js} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 Pete Anderson
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# @peteanderson/ansi
|
|
2
|
+
|
|
3
|
+
ANSI escape sequence helpers for Node.js terminal output. Automatically detects terminal
|
|
4
|
+
capabilities and adapts output accordingly.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @peteanderson/ansi
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
const ansi = require("@peteanderson/ansi");
|
|
16
|
+
|
|
17
|
+
console.log(ansi.fg.red("error: something went wrong"));
|
|
18
|
+
// Fluent chaining with .and
|
|
19
|
+
console.log(ansi.bg.blue.and.fg.white.and.bold("highlighted"));
|
|
20
|
+
console.log(ansi.style.bold("important"));
|
|
21
|
+
console.log(ansi.fg.rgb(5, 2, 0)("custom color"));
|
|
22
|
+
|
|
23
|
+
// Disable colors for a specific stream
|
|
24
|
+
const ansiNoColor = ansi(1); // force 1-bit (no color)
|
|
25
|
+
console.log(ansiNoColor.fg.red("this won't be colored"));
|
|
26
|
+
|
|
27
|
+
// Override specific features
|
|
28
|
+
const customAnsi = ansi({colorDepth: 8, caret: false});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Feature Detection
|
|
32
|
+
|
|
33
|
+
The module automatically detects:
|
|
34
|
+
|
|
35
|
+
- **Color depth**: 1 (none), 4 (16 colors), 8 (256 colors), 24 (true color)
|
|
36
|
+
- **Style support**: enabled if color depth > 1
|
|
37
|
+
- **Other features**: caret, erase, scroll — enabled if output is a TTY and `TERM` is not `dumb`
|
|
38
|
+
|
|
39
|
+
When disabled, features output empty strings. Color outputs plain text. This can be overridden:
|
|
40
|
+
|
|
41
|
+
- Pass a boolean to force color on/off
|
|
42
|
+
- Pass a number to set specific color depth (1, 3, 4, 8, or 24)
|
|
43
|
+
- Pass a stream to use for detection
|
|
44
|
+
- Pass a partial features object to override individual features
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
### Default Export
|
|
49
|
+
|
|
50
|
+
The module exports a callable function with detection-based properties:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
const ansi = require("@peteanderson/ansi");
|
|
54
|
+
const customAnsi = ansi(options); // returns configured instance
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `fg` — foreground colors
|
|
58
|
+
|
|
59
|
+
Functions that wrap text with color codes (or plain text if disabled):
|
|
60
|
+
|
|
61
|
+
- Basic colors: `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `default`
|
|
62
|
+
- Bright colors: `brightBlack` `brightRed` `brightGreen` `brightYellow` `brightBlue` `brightMagenta`
|
|
63
|
+
`brightCyan` `brightWhite`
|
|
64
|
+
- `fg.rgb(r, g, b)(text)` - 24-bit RGB color, downscaled for lower color depths
|
|
65
|
+
- `fg.x256(code)(text)` or `fg.x256(r, g, b)(text)` - 256-color palette, downscaled as needed
|
|
66
|
+
|
|
67
|
+
All return functions with `open` and `close` properties for raw sequences and an `and` property for
|
|
68
|
+
fluent chaining.
|
|
69
|
+
|
|
70
|
+
### `bg` — background colors
|
|
71
|
+
|
|
72
|
+
Functions that wrap text with color codes (or plain text if disabled):
|
|
73
|
+
|
|
74
|
+
- Basic colors: `black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `default`
|
|
75
|
+
- Bright colors: `brightBlack` `brightRed` `brightGreen` `brightYellow` `brightBlue` `brightMagenta`
|
|
76
|
+
`brightCyan` `brightWhite`
|
|
77
|
+
- `bg.rgb(r, g, b)(text)` - 24-bit RGB color, downscaled for lower color depths
|
|
78
|
+
- `bg.x256(code)(text)` or `bg.x256(r, g, b)(text)` - 256-color palette, downscaled as needed
|
|
79
|
+
|
|
80
|
+
All return functions with `open` and `close` properties for raw sequences and an `and` property for
|
|
81
|
+
fluent chaining.
|
|
82
|
+
|
|
83
|
+
### `style`
|
|
84
|
+
|
|
85
|
+
Functions that wrap text with style codes (disabled if color depth = 1):
|
|
86
|
+
|
|
87
|
+
`bold` `dim` `italic` `underline` `inverse` `hidden` `strikethrough` `doubleUnderline` `framed`
|
|
88
|
+
`encircled` `overline`
|
|
89
|
+
|
|
90
|
+
All return functions with `open` and `close` properties for raw sequences and an `and` property for
|
|
91
|
+
fluent chaining.
|
|
92
|
+
|
|
93
|
+
#### Fluent Chaining with `.and`
|
|
94
|
+
|
|
95
|
+
Styles can be chained using the `.and` property for a natural, fluent interface. The `style`
|
|
96
|
+
namespace is unnested in chains:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
// Top-level: use style namespace
|
|
100
|
+
ansi.style.bold("bold text");
|
|
101
|
+
|
|
102
|
+
// In a chain: no need for style namespace
|
|
103
|
+
ansi.fg.white.and.bg.blue.and.bold("white on blue, bold");
|
|
104
|
+
ansi.fg.red.and.underline("red underlined");
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `reset`
|
|
108
|
+
|
|
109
|
+
The SGR reset sequence. Empty string if color is disabled.
|
|
110
|
+
|
|
111
|
+
### `caret`
|
|
112
|
+
|
|
113
|
+
Available if feature is enabled:
|
|
114
|
+
|
|
115
|
+
- `caret.show` / `caret.hide` - show or hide the cursor
|
|
116
|
+
- `caret.position.get` - get the current cursor position (terminal sends position to stdin)
|
|
117
|
+
- `caret.position.set(row, col)` - set cursor position (1-based indexing)
|
|
118
|
+
- `caret.shape.block` / `caret.shape.underline` / `caret.shape.bar` - change cursor shape
|
|
119
|
+
- `caret.up(n)` / `caret.down(n)` / `caret.forward(n)` / `caret.backward(n)` - move cursor
|
|
120
|
+
- `caret.nextLine(n)` / `caret.prevLine(n)` - move cursor to next/previous line
|
|
121
|
+
- `caret.x(col)` - move cursor to column (1-based)
|
|
122
|
+
- `caret.save` / `caret.restore` - save/restore cursor position (VT100)
|
|
123
|
+
|
|
124
|
+
### `terminal`
|
|
125
|
+
|
|
126
|
+
Terminal control features (available if feature is enabled):
|
|
127
|
+
|
|
128
|
+
- `terminal.focusReporting.enable` / `terminal.focusReporting.disable` - enable/disable focus
|
|
129
|
+
reporting
|
|
130
|
+
- `terminal.alternateBuffer.on` / `terminal.alternateBuffer.off` - switch to/from alternate buffer
|
|
131
|
+
- `terminal.alternateBuffer.legacy.on` / `terminal.alternateBuffer.legacy.off` - use legacy
|
|
132
|
+
alternate buffer sequences
|
|
133
|
+
- `terminal.bracketedPasteMode.enable` / `terminal.bracketedPasteMode.disable` - enable/disable
|
|
134
|
+
bracketed paste mode
|
|
135
|
+
|
|
136
|
+
### `erase`
|
|
137
|
+
|
|
138
|
+
Available if feature is enabled:
|
|
139
|
+
|
|
140
|
+
- `erase.line.toStart` / `erase.line.toEnd` / `erase.line.full` - erase line
|
|
141
|
+
- `erase.screen.toStart` / `erase.screen.toEnd` / `erase.screen.full` - erase screen
|
|
142
|
+
- `erase.screen.scrollback` - erase screen and scrollback buffer
|
|
143
|
+
|
|
144
|
+
### `scroll`
|
|
145
|
+
|
|
146
|
+
Available if feature is enabled:
|
|
147
|
+
|
|
148
|
+
- `scroll.up(lines)` - scroll up (default 1 line)
|
|
149
|
+
- `scroll.down(lines)` - scroll down (default 1 line)
|
|
150
|
+
|
|
151
|
+
### `strip(text)`
|
|
152
|
+
|
|
153
|
+
Removes all ANSI CSI sequences from a string (always available).
|
|
154
|
+
|
|
155
|
+
### `slice(text, start, end)`
|
|
156
|
+
|
|
157
|
+
Slices a string by visible characters, ignoring ANSI sequences (always available).
|
|
158
|
+
|
|
159
|
+
### `sanitize(text)`
|
|
160
|
+
|
|
161
|
+
Removes "unsafe" CSI sequences, leaving only color and style codes (always available).
|
|
162
|
+
|
|
163
|
+
### `simplify(text)`
|
|
164
|
+
|
|
165
|
+
Simplifies ANSI SGR sequences by combining adjacent sequences and removing redundant codes (always
|
|
166
|
+
available).
|
|
167
|
+
|
|
168
|
+
### `visibleLength(text)`
|
|
169
|
+
|
|
170
|
+
Returns the visible length of a string with all ANSI sequences removed (always available).
|
|
171
|
+
|
|
172
|
+
### `padStart(text, targetLength)` and `padEnd(text, targetLength)`
|
|
173
|
+
|
|
174
|
+
Pads a string to a target visible length using spaces. Accounts for ANSI sequences when calculating
|
|
175
|
+
length.
|
|
176
|
+
|
|
177
|
+
### `features`
|
|
178
|
+
|
|
179
|
+
Object containing the detected feature configuration:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
{
|
|
183
|
+
colorDepth : 1 | 3 | 4 | 8 | 24;
|
|
184
|
+
style : boolean;
|
|
185
|
+
caret : boolean;
|
|
186
|
+
erase : boolean;
|
|
187
|
+
scroll : boolean;
|
|
188
|
+
terminal : boolean;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
MIT
|
package/dist/ansi.d.ts
CHANGED
|
@@ -1,46 +1,84 @@
|
|
|
1
1
|
import { padEnd, padStart } from "./pad";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
padEnd: typeof padEnd;
|
|
20
|
-
padStart: typeof padStart;
|
|
21
|
-
strip: typeof strip;
|
|
22
|
-
visibleLength: typeof visibleLength;
|
|
23
|
-
sanitize: typeof sanitize;
|
|
24
|
-
slice: typeof slice;
|
|
25
|
-
simplify: typeof simplify;
|
|
26
|
-
features: Features;
|
|
2
|
+
import { strip, visibleLength } from "./strip";
|
|
3
|
+
import type { Args } from "./features";
|
|
4
|
+
import type { Ansi } from "./types";
|
|
5
|
+
declare function makeAnsi(...args: Args): Ansi;
|
|
6
|
+
export declare const ansi: typeof makeAnsi & import("./sgr").SGR & {
|
|
7
|
+
caret: import("./caret").Caret;
|
|
8
|
+
erase: import("./erase").Erase;
|
|
9
|
+
scroll: import("./scroll").Scroll;
|
|
10
|
+
terminal: import("./terminal").Terminal;
|
|
11
|
+
padEnd: import("./pad").PadEnd;
|
|
12
|
+
padStart: import("./pad").PadStart;
|
|
13
|
+
strip: import("./strip").Strip;
|
|
14
|
+
visibleLength: import("./strip").VisibleLength;
|
|
15
|
+
sanitize: import("./strip").Sanitize;
|
|
16
|
+
slice: import("./slice").Slice;
|
|
17
|
+
simplify: import("./simplify").Simplify;
|
|
18
|
+
features: import("./features").Features;
|
|
27
19
|
};
|
|
28
|
-
export declare
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
20
|
+
export declare const fg: import("./sgr/types").Channel<"bg" | import("./sgr/types").StyleKey>, bg: import("./sgr/types").Channel<"fg" | import("./sgr/types").StyleKey>, style: import("./sgr/types").Style<import("./sgr/types").ChainKey>, reset: string, caret: {
|
|
21
|
+
up: (count?: number) => string;
|
|
22
|
+
down: (count?: number) => string;
|
|
23
|
+
forward: (count?: number) => string;
|
|
24
|
+
backward: (count?: number) => string;
|
|
25
|
+
nextLine: (count?: number) => string;
|
|
26
|
+
prevLine: (count?: number) => string;
|
|
27
|
+
x: (x: number) => string;
|
|
28
|
+
save: string;
|
|
29
|
+
restore: string;
|
|
30
|
+
hide: string;
|
|
31
|
+
show: string;
|
|
32
|
+
position: {
|
|
33
|
+
get: string;
|
|
34
|
+
set: (x: number, y: number) => string;
|
|
35
|
+
};
|
|
36
|
+
shape: {
|
|
37
|
+
steadyBlock: string;
|
|
38
|
+
steadyBar: string;
|
|
39
|
+
steadyUnderline: string;
|
|
40
|
+
blinkingBlock: string;
|
|
41
|
+
blinkingBar: string;
|
|
42
|
+
blinkingUnderline: string;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
}, erase: {
|
|
46
|
+
line: {
|
|
47
|
+
toStart: string;
|
|
48
|
+
toEnd: string;
|
|
49
|
+
full: string;
|
|
50
|
+
};
|
|
51
|
+
screen: {
|
|
52
|
+
toStart: string;
|
|
53
|
+
toEnd: string;
|
|
54
|
+
full: string;
|
|
55
|
+
scrollback: string;
|
|
56
|
+
};
|
|
57
|
+
}, scroll: {
|
|
58
|
+
up: (lines?: number) => string;
|
|
59
|
+
down: (lines?: number) => string;
|
|
60
|
+
}, terminal: {
|
|
61
|
+
focusReporting: {
|
|
62
|
+
enable: string;
|
|
63
|
+
disable: string;
|
|
64
|
+
focus: string;
|
|
65
|
+
blur: string;
|
|
66
|
+
};
|
|
67
|
+
alternateScreen: {
|
|
68
|
+
enable: string;
|
|
69
|
+
disable: string;
|
|
70
|
+
legacy: {
|
|
71
|
+
enable: string;
|
|
72
|
+
disable: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
bracketedPaste: {
|
|
76
|
+
enable: string;
|
|
77
|
+
disable: string;
|
|
78
|
+
start: string;
|
|
79
|
+
end: string;
|
|
80
|
+
};
|
|
44
81
|
};
|
|
82
|
+
export { padEnd, padStart, strip, visibleLength };
|
|
45
83
|
export default ansi;
|
|
46
84
|
//# sourceMappingURL=ansi.d.ts.map
|
package/dist/ansi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAqB,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAqB,OAAO,CAAC;AAKtD,OAAO,EAAW,KAAK,EAAE,aAAa,EAAC,MAAO,SAAS,CAAC;AAGxD,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,SAAS,CAAC;AAElC,iBAAS,QAAQ,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,CAuBrC;AAED,eAAO,MAAM,IAAI;;;;;;;;;;;;;CAAsC,CAAC;AAExD,eAAO,MAAO,EAAE,wEAAE,EAAE,wEAAE,KAAK,+DAAE,KAAK,UAAE,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;GAAE,KAAK;;;;;;;;;;;;GAAE,MAAM;;;GAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;CAAQ,CAAC;AAE3E,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAC,CAAA;AAE/C,eAAe,IAAI,CAAC"}
|
package/dist/ansi.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.visibleLength = exports.strip = exports.padStart = exports.padEnd = exports.terminal = exports.scroll = exports.erase = exports.caret = exports.reset = exports.style = exports.bg = exports.fg = exports.ansi = void 0;
|
|
4
4
|
const caret_1 = require("./caret");
|
|
5
5
|
const erase_1 = require("./erase");
|
|
6
6
|
const features_1 = require("./features");
|
|
7
7
|
const pad_1 = require("./pad");
|
|
8
|
+
Object.defineProperty(exports, "padEnd", { enumerable: true, get: function () { return pad_1.padEnd; } });
|
|
9
|
+
Object.defineProperty(exports, "padStart", { enumerable: true, get: function () { return pad_1.padStart; } });
|
|
8
10
|
const scroll_1 = require("./scroll");
|
|
9
11
|
const sgr_1 = require("./sgr");
|
|
10
12
|
const simplify_1 = require("./simplify");
|
|
11
13
|
const slice_1 = require("./slice");
|
|
12
14
|
const strip_1 = require("./strip");
|
|
15
|
+
Object.defineProperty(exports, "strip", { enumerable: true, get: function () { return strip_1.strip; } });
|
|
16
|
+
Object.defineProperty(exports, "visibleLength", { enumerable: true, get: function () { return strip_1.visibleLength; } });
|
|
13
17
|
const terminal_1 = require("./terminal");
|
|
14
18
|
function makeAnsi(...args) {
|
|
15
19
|
const features = (0, features_1.getFeatures)(...args);
|
|
16
20
|
return {
|
|
21
|
+
...(0, sgr_1.makeSGR)(features),
|
|
17
22
|
caret: (0, caret_1.makeCaret)(features.caret),
|
|
18
23
|
erase: (0, erase_1.makeErase)(features.erase),
|
|
19
24
|
scroll: (0, scroll_1.makeScroll)(features.scroll),
|
|
20
|
-
reset: (0, sgr_1.makeReset)(features.colorDepth > 1),
|
|
21
|
-
style: (0, sgr_1.makeStyle)(features.style),
|
|
22
|
-
...(0, sgr_1.makeColor)(features.colorDepth),
|
|
23
25
|
terminal: (0, terminal_1.makeTerminal)(features.terminal),
|
|
24
26
|
padEnd: pad_1.padEnd,
|
|
25
27
|
padStart: pad_1.padStart,
|
|
@@ -31,6 +33,7 @@ function makeAnsi(...args) {
|
|
|
31
33
|
features,
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
exports.
|
|
36
|
+
exports.ansi = Object.assign(makeAnsi, makeAnsi());
|
|
37
|
+
exports.fg = exports.ansi.fg, exports.bg = exports.ansi.bg, exports.style = exports.ansi.style, exports.reset = exports.ansi.reset, exports.caret = exports.ansi.caret, exports.erase = exports.ansi.erase, exports.scroll = exports.ansi.scroll, exports.terminal = exports.ansi.terminal;
|
|
38
|
+
exports.default = exports.ansi;
|
|
36
39
|
//# sourceMappingURL=ansi.js.map
|
package/dist/ansi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":";;;AAAA,mCAAwD;AACxD,mCAAwD;AACxD,yCAA2D;AAC3D,+BAAsD;AAwC9C,uFAxCA,YAAM,OAwCA;AAAE,yFAxCA,cAAQ,OAwCA;AAvCxB,qCAAyD;AACzD,+BAAsD;AACtD,yCAA2D;AAC3D,mCAAwD;AACxD,mCAAwD;AAmC9B,sFAnCR,aAAK,OAmCQ;AAAE,8FAnCR,qBAAa,OAmCQ;AAlC9C,yCAA2D;AAK3D,SAAS,QAAQ,CAAC,GAAG,IAAU;IAC9B,MAAM,QAAQ,GAAG,IAAA,sBAAW,EAAC,GAAG,IAAI,CAAC,CAAC;IAEtC,OAAO;QACN,GAAG,IAAA,aAAO,EAAC,QAAQ,CAAC;QAEpB,KAAK,EAAI,IAAA,iBAAS,EAAC,QAAQ,CAAC,KAAK,CAAC;QAClC,KAAK,EAAI,IAAA,iBAAS,EAAC,QAAQ,CAAC,KAAK,CAAC;QAClC,MAAM,EAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,MAAM,CAAC;QAEpC,QAAQ,EAAE,IAAA,uBAAY,EAAC,QAAQ,CAAC,QAAQ,CAAC;QAEzC,MAAM,EAAN,YAAM;QACN,QAAQ,EAAR,cAAQ;QAER,KAAK,EAAL,aAAK;QACL,aAAa,EAAb,qBAAa;QACb,QAAQ,EAAR,gBAAQ;QACR,KAAK,EAAL,aAAK;QACL,QAAQ,EAAR,mBAAQ;QAER,QAAQ;KACR,CAAC;AACH,CAAC;AAEY,QAAA,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AAE1C,UAAE,GAAsD,YAAI,KAAxD,UAAE,GAAkD,YAAI,KAApD,aAAK,GAA2C,YAAI,QAA7C,aAAK,GAAoC,YAAI,QAAtC,aAAK,GAA6B,YAAI,QAA/B,aAAK,GAAsB,YAAI,QAAxB,cAAM,GAAc,YAAI,SAAhB,gBAAQ,GAAI,YAAI,UAAC;AAI3E,kBAAe,YAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/features/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/features/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAWlD,wBAAgB,KAAK,CACpB,KAAK,EAAQ,OAAO,EACpB,UAAU,EAAG,UAAU,EACvB,KAAK,CAAC,EAAO,OAAO,EACpB,KAAK,CAAC,EAAO,OAAO,EACpB,KAAK,CAAC,EAAO,OAAO,EACpB,MAAM,CAAC,EAAM,OAAO,EACpB,QAAQ,CAAC,EAAI,OAAO,GAClB,QAAQ,CAmBV;AAED,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,EAAE,SAAS,OAAO,KAAG,QAC7B,CAAC;AAE/B,eAAO,MAAM,MAAM,GAAI,OAAO,OAAO,EAAE,YAAY,UAAU,KAAG,QACvC,CAAC;AAE1B,eAAO,MAAM,GAAG,GAAI,QAAQ,MAAM,CAAC,WAAW,KAAG,QACd,CAAC;AAEpC,eAAO,MAAM,IAAI,QAAO,QACM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/features/build.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/features/build.ts"],"names":[],"mappings":";;;AAaA,sBA2BC;AAxCD,qCAA6D;AAI7D,SAAS,mBAAmB,CAAC,UAAkB;IAC9C,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,UAAU,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAChC,IAAI,UAAU,IAAI,CAAC;QAAG,OAAO,CAAC,CAAC;IAC/B,IAAI,UAAU,IAAI,CAAC;QAAG,OAAO,CAAC,CAAC;IAC/B,IAAI,UAAU,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,CAAC;AACV,CAAC;AAED,SAAgB,KAAK,CACpB,KAAoB,EACpB,UAAuB,EACvB,KAAoB,EACpB,KAAoB,EACpB,KAAoB,EACpB,MAAoB,EACpB,QAAoB;IAEpB,IACC,KAAK,KAAQ,SAAS;QACtB,KAAK,KAAQ,SAAS;QACtB,KAAK,KAAQ,SAAS;QACtB,MAAM,KAAO,SAAS;QACtB,QAAQ,KAAK,SAAS;QAEtB,OAAO,EAAC,UAAU,EAAE,mBAAmB,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAC,CAAC;IAE7F,MAAM,OAAO,GAAG,IAAA,6BAAoB,EAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACxD,OAAO;QACN,UAAU,EAAG,mBAAmB,CAAC,UAAU,CAAC;QAC5C,KAAK,EAAQ,KAAK,IAAO,OAAO,CAAC,KAAK;QACtC,KAAK,EAAQ,KAAK,IAAO,OAAO,CAAC,KAAK;QACtC,KAAK,EAAQ,KAAK,IAAO,OAAO,CAAC,KAAK;QACtC,MAAM,EAAO,MAAM,IAAM,OAAO,CAAC,MAAM;QACvC,QAAQ,EAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ;KACzC,CAAC;AACH,CAAC;AAEM,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,OAAgB,EAAY,EAAE,CACrE,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AADlB,QAAA,OAAO,WACW;AAExB,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,UAAsB,EAAY,EAAE,CAC1E,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AADb,QAAA,MAAM,UACO;AAEnB,MAAM,GAAG,GAAG,CAAC,MAA0B,EAAY,EAAE,CAC3D,KAAK,CAAC,IAAI,EAAE,IAAA,sBAAa,EAAC,MAAM,CAAC,CAAC,CAAC;AADvB,QAAA,GAAG,OACoB;AAE7B,MAAM,IAAI,GAAG,GAAa,EAAE,CAClC,KAAK,CAAC,KAAK,EAAE,IAAA,sBAAa,GAAE,CAAC,CAAC;AADlB,QAAA,IAAI,QACc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/features/detect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/features/detect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAElD,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,GAAG,UAAU,CAmBrE;AAED,wBAAgB,oBAAoB,CACnC,KAAK,EAAQ,OAAO,EACpB,UAAU,EAAG,UAAU,GACrB,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAS9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../src/features/detect.ts"],"names":[],"mappings":";;AAEA,sCAmBC;AAED,
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../src/features/detect.ts"],"names":[],"mappings":";;AAEA,sCAmBC;AAED,oDAYC;AAjCD,SAAgB,aAAa,CAAC,MAA2B;IACxD,IAAI,MAAM,EAAE,KAAK;QAChB,OAAO,MAAM,CAAC,aAAa,EAAgB,CAAC;IAE7C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB;QAC1D,OAAO,CAAC,CAAC;IAEV,QAAQ,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QACjC,KAAK,EAAE,CAAC;QACR,KAAK,MAAM,CAAC;QACZ,KAAK,GAAG;YACP,OAAO,CAAC,CAAC;QACV,KAAK,GAAG;YACP,OAAO,CAAC,CAAC;QACV,KAAK,GAAG;YACP,OAAO,EAAE,CAAC;QACX;YACC,OAAO,CAAC,CAAC;IACX,CAAC;AACF,CAAC;AAED,SAAgB,oBAAoB,CACnC,KAAoB,EACpB,UAAuB;IAEvB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC;IACrD,OAAO;QACN,KAAK,EAAM,UAAU,GAAG,CAAC;QACzB,KAAK,EAAM,OAAO;QAClB,KAAK,EAAM,OAAO;QAClB,MAAM,EAAK,OAAO;QAClB,QAAQ,EAAG,OAAO;KAClB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ColorDepth, Features } from "./types";
|
|
3
|
-
export type Args = [enabled: boolean, stream?: NodeJS.WriteStream] | [colorDepth: ColorDepth, stream?: NodeJS.WriteStream] | [features: Partial<Features>, stream?: NodeJS.WriteStream] | [socket: Socket] | [stream?: NodeJS.WriteStream];
|
|
1
|
+
import type { Args, Features } from "./types";
|
|
4
2
|
export declare function getFeatures(...args: Args): Features;
|
|
5
3
|
//# sourceMappingURL=features.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/features/features.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/features/features.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAE5C,wBAAgB,WAAW,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,QAAQ,CA6BnD"}
|
|
@@ -6,20 +6,19 @@ const node_tty_1 = require("node:tty");
|
|
|
6
6
|
const build_1 = require("./build");
|
|
7
7
|
const detect_1 = require("./detect");
|
|
8
8
|
function getFeatures(...args) {
|
|
9
|
-
|
|
10
|
-
if (typeof
|
|
11
|
-
return (0, build_1.boolean)((
|
|
12
|
-
if (typeof
|
|
13
|
-
return (0, build_1.number)((
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (input instanceof node_net_1.Socket)
|
|
9
|
+
let [features, stream] = args;
|
|
10
|
+
if (typeof features === "boolean")
|
|
11
|
+
return (0, build_1.boolean)((stream ?? process.stdout).isTTY, features);
|
|
12
|
+
if (typeof features === "number")
|
|
13
|
+
return (0, build_1.number)((stream ?? process.stdout).isTTY, features);
|
|
14
|
+
if (!features || typeof features !== "object")
|
|
15
|
+
features = (stream ?? process.stdout);
|
|
16
|
+
if (features instanceof node_tty_1.WriteStream)
|
|
17
|
+
return (0, build_1.tty)(features);
|
|
18
|
+
if (features instanceof node_net_1.Socket)
|
|
20
19
|
return (0, build_1.pipe)();
|
|
21
|
-
const { colorDepth, style, caret, erase, scroll, terminal } =
|
|
22
|
-
|
|
20
|
+
const { colorDepth, style, caret, erase, scroll, terminal } = features;
|
|
21
|
+
stream ?? (stream = process.stdout);
|
|
23
22
|
if (colorDepth)
|
|
24
23
|
(0, build_1.build)(stream.isTTY, colorDepth, style, caret, erase, scroll, terminal);
|
|
25
24
|
if (stream.isTTY)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/features/features.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/features/features.ts"],"names":[],"mappings":";;AAOA,kCA6BC;AApCD,uCAA2D;AAC3D,uCAA2D;AAC3D,mCAA0D;AAC1D,qCAA2D;AAI3D,SAAgB,WAAW,CAAC,GAAG,IAAU;IACxC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAE9B,IAAI,OAAO,QAAQ,KAAK,SAAS;QAChC,OAAO,IAAA,eAAO,EAAC,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAE5D,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAC/B,OAAO,IAAA,cAAM,EAAC,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAE3D,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAC5C,QAAQ,GAAG,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvC,IAAI,QAAQ,YAAY,sBAAW;QAClC,OAAO,IAAA,WAAG,EAAC,QAAQ,CAAC,CAAC;IAEtB,IAAI,QAAQ,YAAY,iBAAM;QAC7B,OAAO,IAAA,YAAI,GAAE,CAAC;IAEf,MAAM,EAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAErE,MAAM,KAAN,MAAM,GAAK,OAAO,CAAC,MAAM,EAAC;IAE1B,IAAI,UAAU;QACb,IAAA,aAAK,EAAC,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAExE,IAAI,MAAM,CAAC,KAAK;QACf,OAAO,IAAA,aAAK,EAAC,IAAI,EAAE,IAAA,sBAAa,EAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAElF,OAAO,IAAA,aAAK,EAAC,KAAK,EAAE,IAAA,sBAAa,GAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/features/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,mBAAmB,SAAS,CAAC"}
|
package/dist/features/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Socket } from "node:net";
|
|
1
2
|
export type ColorDepth = 1 | 3 | 4 | 8 | 24;
|
|
2
3
|
export interface Features {
|
|
3
4
|
colorDepth: ColorDepth;
|
|
@@ -7,4 +8,5 @@ export interface Features {
|
|
|
7
8
|
scroll: boolean;
|
|
8
9
|
terminal: boolean;
|
|
9
10
|
}
|
|
11
|
+
export type Args = [enabled: boolean, stream?: NodeJS.WriteStream] | [colorDepth: ColorDepth, stream?: NodeJS.WriteStream] | [features: Partial<Features>, stream?: NodeJS.WriteStream] | [socket: Socket] | [stream?: NodeJS.WriteStream];
|
|
10
12
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/features/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AAE5C,MAAM,WAAW,QAAQ;IACxB,UAAU,EAAG,UAAU,CAAC;IACxB,KAAK,EAAQ,OAAO,CAAC;IACrB,KAAK,EAAQ,OAAO,CAAC;IACrB,KAAK,EAAQ,OAAO,CAAC;IACrB,MAAM,EAAO,OAAO,CAAC;IACrB,QAAQ,EAAK,OAAO,CAAC;CACrB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/features/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAErC,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AAE5C,MAAM,WAAW,QAAQ;IACxB,UAAU,EAAG,UAAU,CAAC;IACxB,KAAK,EAAQ,OAAO,CAAC;IACrB,KAAK,EAAQ,OAAO,CAAC;IACrB,KAAK,EAAQ,OAAO,CAAC;IACrB,MAAM,EAAO,OAAO,CAAC;IACrB,QAAQ,EAAK,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,IAAI,GACb,CAAC,OAAO,EAAM,OAAO,EAAY,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,GAC7D,CAAC,UAAU,EAAG,UAAU,EAAS,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,GAC7D,CAAC,QAAQ,EAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,GAC7D,CAAC,MAAM,EAAO,MAAM,CAAC,GACrB,CAAC,MAAM,CAAC,EAAM,MAAM,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/pad.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pad the given text at the end with the specified fill string to the target visible length without
|
|
3
|
+
* counting ANSI escape codes.
|
|
4
|
+
*/
|
|
1
5
|
export declare const padEnd: (text: string, targetLength: number, fillString?: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Pad the given text at the start with the specified fill string to the target visible length
|
|
8
|
+
* without counting ANSI escape codes.
|
|
9
|
+
*/
|
|
2
10
|
export declare const padStart: (text: string, targetLength: number, fillString?: string) => string;
|
|
11
|
+
export type PadEnd = typeof padEnd;
|
|
12
|
+
export type PadStart = typeof padStart;
|
|
3
13
|
//# sourceMappingURL=pad.d.ts.map
|
package/dist/pad.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pad.d.ts","sourceRoot":"","sources":["../src/pad.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,cAAc,MAAM,EAAE,mBAAgB,KAAG,MACgB,CAAC;AAE/F,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,EAAE,cAAc,MAAM,EAAE,mBAAgB,KAAG,MACc,CAAC"}
|
|
1
|
+
{"version":3,"file":"pad.d.ts","sourceRoot":"","sources":["../src/pad.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,cAAc,MAAM,EAAE,mBAAgB,KAAG,MACgB,CAAC;AAE/F;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,EAAE,cAAc,MAAM,EAAE,mBAAgB,KAAG,MACc,CAAC;AAE/F,MAAM,MAAM,MAAM,GAAK,OAAO,MAAM,CAAC;AACrC,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC"}
|
package/dist/pad.js
CHANGED
|
@@ -2,8 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.padStart = exports.padEnd = void 0;
|
|
4
4
|
const strip_1 = require("./strip");
|
|
5
|
+
/**
|
|
6
|
+
* Pad the given text at the end with the specified fill string to the target visible length without
|
|
7
|
+
* counting ANSI escape codes.
|
|
8
|
+
*/
|
|
5
9
|
const padEnd = (text, targetLength, fillString = " ") => text + fillString.repeat(Math.max(0, targetLength - (0, strip_1.visibleLength)(text)) / fillString.length);
|
|
6
10
|
exports.padEnd = padEnd;
|
|
11
|
+
/**
|
|
12
|
+
* Pad the given text at the start with the specified fill string to the target visible length
|
|
13
|
+
* without counting ANSI escape codes.
|
|
14
|
+
*/
|
|
7
15
|
const padStart = (text, targetLength, fillString = " ") => fillString.repeat(Math.max(0, targetLength - (0, strip_1.visibleLength)(text)) / fillString.length) + text;
|
|
8
16
|
exports.padStart = padStart;
|
|
9
17
|
//# sourceMappingURL=pad.js.map
|
package/dist/pad.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pad.js","sourceRoot":"","sources":["../src/pad.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;
|
|
1
|
+
{"version":3,"file":"pad.js","sourceRoot":"","sources":["../src/pad.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC;;;GAGG;AACI,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,YAAoB,EAAE,UAAU,GAAG,GAAG,EAAU,EAAE,CACtF,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,IAAA,qBAAa,EAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AADlF,QAAA,MAAM,UAC4E;AAE/F;;;GAGG;AACI,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,YAAoB,EAAE,UAAU,GAAG,GAAG,EAAU,EAAE,CACxF,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,IAAA,qBAAa,EAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AADlF,QAAA,QAAQ,YAC0E"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColorDepth } from "../../features";
|
|
2
|
+
import type { ChainKey, Channel, ColorKey, FormatBuilder, Style } from "../types";
|
|
3
|
+
export declare function makeChannel(keys: ReadonlySet<ChainKey>, makeFormatter: FormatBuilder, style: Style, colorDepth: ColorDepth, channel: ColorKey): Channel;
|
|
4
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/sgr/color/channel.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,MAA6C,gBAAgB,CAAC;AACtF,OAAO,KAAK,EAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AAahF,wBAAgB,WAAW,CAC1B,IAAI,EAAY,WAAW,CAAC,QAAQ,CAAC,EACrC,aAAa,EAAG,aAAa,EAC7B,KAAK,EAAW,KAAK,EACrB,UAAU,EAAM,UAAU,EAC1B,OAAO,EAAS,QAAQ,GACtB,OAAO,CAmBT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeChannel = makeChannel;
|
|
4
|
+
const lazy_1 = require("../lazy");
|
|
5
|
+
const context_1 = require("./context");
|
|
6
|
+
const rgb_1 = require("./rgb");
|
|
7
|
+
const colors = [
|
|
8
|
+
"black",
|
|
9
|
+
"red",
|
|
10
|
+
"green",
|
|
11
|
+
"yellow",
|
|
12
|
+
"blue",
|
|
13
|
+
"magenta",
|
|
14
|
+
"cyan",
|
|
15
|
+
"white",
|
|
16
|
+
];
|
|
17
|
+
function makeChannel(keys, makeFormatter, style, colorDepth, channel) {
|
|
18
|
+
const ctx = (0, context_1.buildContext)(keys, makeFormatter, style, colorDepth, channel);
|
|
19
|
+
const { build, bright, open, close } = ctx;
|
|
20
|
+
const rtn = {
|
|
21
|
+
rgb: (0, rgb_1.makeRGB)(ctx),
|
|
22
|
+
x256: (0, rgb_1.makeX256)(ctx),
|
|
23
|
+
default: colorDepth > 1 ? `\x1b[${close}m` : "",
|
|
24
|
+
};
|
|
25
|
+
for (let i = 0; i < colors.length; i++) {
|
|
26
|
+
const color = colors[i];
|
|
27
|
+
const brightColor = `bright${color[0].toUpperCase()}${color.slice(1)}`;
|
|
28
|
+
lazy_1.lazy.add(rtn, color, () => build(open + i));
|
|
29
|
+
lazy_1.lazy.add(rtn, brightColor, () => bright(i));
|
|
30
|
+
}
|
|
31
|
+
return rtn;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../../src/sgr/color/channel.ts"],"names":[],"mappings":";;AAkBA,kCAyBC;AA3CD,kCAA0C;AAC1C,uCAA4C;AAC5C,+BAAwC;AAKxC,MAAM,MAAM,GAAG;IACd,OAAO;IACP,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;IACN,SAAS;IACT,MAAM;IACN,OAAO;CACE,CAAC;AAEX,SAAgB,WAAW,CAC1B,IAAqC,EACrC,aAA6B,EAC7B,KAAqB,EACrB,UAA0B,EAC1B,OAAwB;IAExB,MAAM,GAAG,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC1E,MAAM,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAC,GAAG,GAAG,CAAC;IAEzC,MAAM,GAAG,GAAG;QACX,GAAG,EAAO,IAAA,aAAO,EAAC,GAAG,CAAC;QACtB,IAAI,EAAM,IAAA,cAAQ,EAAC,GAAG,CAAC;QACvB,OAAO,EAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;KACrC,CAAC;IAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,KAAK,GAAS,MAAM,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,WAAW,GAAG,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAEvE,WAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QAClD,WAAI,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ColorDepth } from "../../features
|
|
2
|
-
import type { Color } from "
|
|
3
|
-
export
|
|
4
|
-
export declare const makeColor: (colorDepth?: ColorDepth) => Color;
|
|
1
|
+
import type { ColorDepth } from "../../features";
|
|
2
|
+
import type { ChainKey, Color, FormatBuilder, Style } from "../types";
|
|
3
|
+
export declare function makeColor(keys: ReadonlySet<ChainKey>, makeFormatter: FormatBuilder, style: Style, colorDepth: ColorDepth): Color<any>;
|
|
5
4
|
//# sourceMappingURL=color.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/sgr/color/color.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/sgr/color/color.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAiC,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AAIpE,wBAAgB,SAAS,CACxB,IAAI,EAAY,WAAW,CAAC,QAAQ,CAAC,EACrC,aAAa,EAAG,aAAa,EAC7B,KAAK,EAAW,KAAK,EACrB,UAAU,EAAM,UAAU,GACxB,KAAK,CAAC,GAAG,CAAC,CAcZ"}
|