@peteanderson/ansi 0.2.2 → 0.2.4
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 +30 -65
- package/ansi.js +28 -0
- package/package.json +20 -13
- package/dist/ansi.d.ts +0 -12
- package/dist/ansi.js +0 -21
- package/dist/caret.d.ts +0 -25
- package/dist/caret.js +0 -40
- package/dist/erase.d.ts +0 -14
- package/dist/erase.js +0 -15
- package/dist/index.d.ts +0 -106
- package/dist/index.js +0 -2
- package/dist/scroll.d.ts +0 -2
- package/dist/scroll.js +0 -8
- package/dist/sgr/color.d.ts +0 -62
- package/dist/sgr/color.js +0 -111
- package/dist/sgr/index.d.ts +0 -59
- package/dist/sgr/index.js +0 -6
- package/dist/sgr/reset.d.ts +0 -1
- package/dist/sgr/reset.js +0 -3
- package/dist/sgr/sgr.d.ts +0 -14
- package/dist/sgr/sgr.js +0 -47
- package/dist/sgr/style.d.ts +0 -13
- package/dist/sgr/style.js +0 -16
- package/dist/sgr/utils.d.ts +0 -2
- package/dist/sgr/utils.js +0 -16
- package/dist/simplify/atom.d.ts +0 -3
- package/dist/simplify/atom.js +0 -28
- package/dist/simplify/index.d.ts +0 -2
- package/dist/simplify/index.js +0 -2
- package/dist/simplify/lookup.d.ts +0 -5
- package/dist/simplify/lookup.js +0 -77
- package/dist/simplify/simplify.d.ts +0 -1
- package/dist/simplify/simplify.js +0 -24
- package/dist/simplify/state.d.ts +0 -10
- package/dist/simplify/state.js +0 -57
- package/dist/simplify/utils.d.ts +0 -2
- package/dist/simplify/utils.js +0 -31
- package/dist/strip.d.ts +0 -11
- package/dist/strip.js +0 -58
- package/src/ansi.js +0 -26
- package/src/caret.js +0 -49
- package/src/erase.js +0 -17
- package/src/index.js +0 -1
- package/src/scroll.js +0 -10
- package/src/sgr/color.js +0 -130
- package/src/sgr/index.js +0 -5
- package/src/sgr/reset.js +0 -3
- package/src/sgr/sgr.js +0 -66
- package/src/sgr/style.js +0 -19
- package/src/sgr/utils.js +0 -20
- package/src/simplify/atom.js +0 -34
- package/src/simplify/index.js +0 -1
- package/src/simplify/lookup.js +0 -86
- package/src/simplify/simplify.js +0 -33
- package/src/simplify/state.js +0 -73
- package/src/simplify/types.d.ts +0 -28
- package/src/simplify/utils.js +0 -41
- package/src/strip.js +0 -69
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @peteanderson/ansi
|
|
2
2
|
|
|
3
|
-
ANSI escape sequence helpers for Node.js terminal output.
|
|
3
|
+
ANSI escape sequence helpers for Node.js terminal output. Automatically disables color when stdout is not a TTY or when standard environment variables (`NO_COLOR`, `NODE_DISABLE_COLORS`, `FORCE_COLOR`, `TERM=dumb`) indicate it should be.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -11,89 +11,54 @@ npm install @peteanderson/ansi
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
console.log(
|
|
17
|
-
console.log(
|
|
18
|
-
console.log(
|
|
19
|
-
console.log(
|
|
20
|
-
console.log(
|
|
21
|
-
console.log(
|
|
22
|
-
console.log(ansi.simplify(styledText)); // combine adjacent SGR sequences
|
|
14
|
+
const {fg, bg, style, reset, stripAnsiSequences} = require('@peteanderson/ansi');
|
|
15
|
+
|
|
16
|
+
console.log(fg.red('error: something went wrong'));
|
|
17
|
+
console.log(bg.blue(fg.white('highlighted')));
|
|
18
|
+
console.log(style.bold('important'));
|
|
19
|
+
console.log(fg.rgb(5, 2, 0)('custom color'));
|
|
20
|
+
console.log('some styled text' + reset);
|
|
21
|
+
console.log(stripAnsiSequences('\x1b[31mred\x1b[0m')); // => 'red'
|
|
23
22
|
```
|
|
24
23
|
|
|
25
24
|
## API
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
All color and style functions accept a string and return a string. When color is disabled, the functions are identity — they return the input unchanged.
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
### `fg` — foreground colors
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
- Bright colors: `brightBlack` `brightRed` `brightGreen` `brightYellow` `brightBlue` `brightMagenta`
|
|
33
|
-
`brightCyan` `brightWhite`
|
|
34
|
-
- `fg.rgb(r, g, b)(text)` - 24-bit RGB color (r, g, b in 0–5 or grayscale 232–255)
|
|
35
|
-
- `fg.x256(code)(text)` or `fg.x256(r, g, b)(text)` - 256-color palette
|
|
30
|
+
`black` `red` `green` `yellow` `blue` `magenta` `cyan` `white` `gray`
|
|
36
31
|
|
|
37
|
-
|
|
32
|
+
```js
|
|
33
|
+
fg.red('text')
|
|
34
|
+
fg.rgb(r, g, b)('text') // r, g, b in 0–5 for the 6×6×6 cube, or grayscale 232–255
|
|
35
|
+
```
|
|
38
36
|
|
|
39
37
|
### `bg` — background colors
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
`black` `red` `green` `yellow` `blue` `magenta` `cyan` `white`
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- `bg.x256(code)(text)` or `bg.x256(r, g, b)(text)` - 256-color palette
|
|
41
|
+
```js
|
|
42
|
+
bg.green('text')
|
|
43
|
+
bg.rgb(r, g, b)('text')
|
|
44
|
+
```
|
|
48
45
|
|
|
49
46
|
### `style`
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`bold` `dim` `italic` `underline` `inverse` `hidden` `strikethrough` `doubleUnderline` `framed`
|
|
54
|
-
`encircled` `overline`
|
|
55
|
-
|
|
56
|
-
All return functions with `open` and `close` properties for raw sequences.
|
|
57
|
-
|
|
58
|
-
### `caret`
|
|
59
|
-
|
|
60
|
-
- `caret.show` / `caret.hide` - show or hide the cursor
|
|
61
|
-
- `caret.position.get` - get the current cursor position (terminal sends position to stdin)
|
|
62
|
-
- `caret.position.set(row, col)` - set cursor position (1-based indexing)
|
|
63
|
-
- `caret.shape.block` / `caret.shape.underline` / `caret.shape.bar` - change cursor shape
|
|
64
|
-
- `caret.up(n)` / `caret.down(n)` / `caret.forward(n)` / `caret.backward(n)` - move cursor
|
|
65
|
-
- `caret.nextLine(n)` / `caret.prevLine(n)` - move cursor to next/previous line
|
|
66
|
-
- `caret.x(col)` - move cursor to column (1-based)
|
|
67
|
-
- `caret.save` / `caret.restore` - save/restore cursor position (VT100)
|
|
48
|
+
`bold` `dim` `italic` `underline` `inverse` `hidden` `strikethrough`
|
|
68
49
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
- `erase.screen.scrollback` - erase screen and scrollback buffer
|
|
74
|
-
|
|
75
|
-
### `scroll`
|
|
76
|
-
|
|
77
|
-
- `scroll.up(lines)` - scroll up (default 1 line)
|
|
78
|
-
- `scroll.down(lines)` - scroll down (default 1 line)
|
|
79
|
-
|
|
80
|
-
### `strip(text)`
|
|
81
|
-
|
|
82
|
-
Removes all ANSI CSI sequences from a string.
|
|
83
|
-
|
|
84
|
-
### `slice(text, start, end)`
|
|
85
|
-
|
|
86
|
-
Slices a string by visible characters, ignoring ANSI sequences. Works like `String.prototype.slice`
|
|
87
|
-
but counts only visible characters.
|
|
50
|
+
```js
|
|
51
|
+
style.bold('text')
|
|
52
|
+
style.italic(style.bold('text'))
|
|
53
|
+
```
|
|
88
54
|
|
|
89
|
-
### `
|
|
55
|
+
### `reset`
|
|
90
56
|
|
|
91
|
-
|
|
57
|
+
The SGR reset sequence (`\x1b[0m`). An empty string when color is disabled.
|
|
92
58
|
|
|
93
|
-
### `
|
|
59
|
+
### `stripAnsiSequences(text)`
|
|
94
60
|
|
|
95
|
-
|
|
96
|
-
for optimizing styled strings.
|
|
61
|
+
Removes ANSI SGR escape sequences from a string.
|
|
97
62
|
|
|
98
63
|
## License
|
|
99
64
|
|
package/ansi.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const caret = require("./caret");
|
|
4
|
+
const erase = require("./erase");
|
|
5
|
+
const scroll = require("./scroll");
|
|
6
|
+
const {bg, fg, reset, style} = require("./sgr");
|
|
7
|
+
const {simplify} = require("./simplify");
|
|
8
|
+
const {slice} = require("./slice");
|
|
9
|
+
const {sanitize, strip, visibleLength} = require("./strip");
|
|
10
|
+
|
|
11
|
+
const ansi = {
|
|
12
|
+
caret,
|
|
13
|
+
erase,
|
|
14
|
+
scroll,
|
|
15
|
+
|
|
16
|
+
reset,
|
|
17
|
+
style,
|
|
18
|
+
fg,
|
|
19
|
+
bg,
|
|
20
|
+
|
|
21
|
+
strip,
|
|
22
|
+
visibleLength,
|
|
23
|
+
sanitize,
|
|
24
|
+
slice,
|
|
25
|
+
simplify,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = ansi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name" : "@peteanderson/ansi",
|
|
3
|
-
"version" : "0.2.
|
|
3
|
+
"version" : "0.2.4",
|
|
4
4
|
"description" : "ANSI escape sequence generation with automatic feature detection",
|
|
5
5
|
"author" : {
|
|
6
6
|
"name" : "Pete Anderson",
|
|
@@ -8,25 +8,32 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository" : {
|
|
10
10
|
"type" : "git",
|
|
11
|
-
"url" : "
|
|
11
|
+
"url" : "https://github.com/anderson-pete/ansi"
|
|
12
12
|
},
|
|
13
|
-
"keywords" : [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
"keywords" : [
|
|
14
|
+
"ansi",
|
|
15
|
+
"nodejs",
|
|
16
|
+
"color",
|
|
17
|
+
"terminal",
|
|
18
|
+
"cli"
|
|
19
|
+
],
|
|
20
|
+
"engines" : {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"files" : [
|
|
24
|
+
"."
|
|
25
|
+
],
|
|
26
|
+
"main" : "ansi.js",
|
|
27
|
+
"types" : "ansi.d.ts",
|
|
18
28
|
"exports" : {
|
|
19
29
|
".": {
|
|
20
|
-
"
|
|
21
|
-
"require" : "./dist/ansi.js"
|
|
30
|
+
"require": "./ansi.js"
|
|
22
31
|
}
|
|
23
32
|
},
|
|
24
33
|
"license" : "MIT",
|
|
25
34
|
"scripts" : {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"prepack" : "npm run build",
|
|
29
|
-
"tag" : "git tag -a v$npm_package_version -m v$npm_package_version"
|
|
35
|
+
"build" : "rm *.d.ts && tsc --allowJs --declaration --emitDeclarationOnly --moduleResolution node --ignoreDeprecations 6.0 ansi.js",
|
|
36
|
+
"tag" : "git tag -a v$npm_package_version -m v$npm_package_version"
|
|
30
37
|
},
|
|
31
38
|
"devDependencies" : {
|
|
32
39
|
"@types/node" : "^26.0.0",
|
package/dist/ansi.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import caret = require("./caret");
|
|
2
|
-
import erase = require("./erase");
|
|
3
|
-
import scroll = require("./scroll");
|
|
4
|
-
import { reset } from "./sgr/reset";
|
|
5
|
-
import { style } from "./sgr/style";
|
|
6
|
-
import { fg } from "./sgr/color";
|
|
7
|
-
import { bg } from "./sgr/color";
|
|
8
|
-
import { strip } from "./strip";
|
|
9
|
-
import { sanitize } from "./strip";
|
|
10
|
-
import { slice } from "./strip";
|
|
11
|
-
import { simplify } from "./simplify/simplify";
|
|
12
|
-
export { caret, erase, scroll, reset, style, fg, bg, strip, sanitize, slice, simplify };
|
package/dist/ansi.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const caret = require("./caret");
|
|
3
|
-
const erase = require("./erase");
|
|
4
|
-
const scroll = require("./scroll");
|
|
5
|
-
const { bg, fg, reset, style } = require("./sgr");
|
|
6
|
-
const { simplify } = require("./simplify");
|
|
7
|
-
const { sanitize, slice, strip } = require("./strip");
|
|
8
|
-
const ansi = {
|
|
9
|
-
caret,
|
|
10
|
-
erase,
|
|
11
|
-
scroll,
|
|
12
|
-
reset,
|
|
13
|
-
style,
|
|
14
|
-
fg,
|
|
15
|
-
bg,
|
|
16
|
-
strip,
|
|
17
|
-
sanitize,
|
|
18
|
-
slice,
|
|
19
|
-
simplify,
|
|
20
|
-
};
|
|
21
|
-
module.exports = ansi;
|
package/dist/caret.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export let up: (count?: number) => string;
|
|
2
|
-
export let down: (count?: number) => string;
|
|
3
|
-
export let forward: (count?: number) => string;
|
|
4
|
-
export let backward: (count?: number) => string;
|
|
5
|
-
export let nextLine: (count?: number) => string;
|
|
6
|
-
export let prevLine: (count?: number) => string;
|
|
7
|
-
export let x: (x: number) => string;
|
|
8
|
-
export let save: string;
|
|
9
|
-
export let restore: string;
|
|
10
|
-
export let hide: string;
|
|
11
|
-
export let show: string;
|
|
12
|
-
export namespace position {
|
|
13
|
-
let get: string;
|
|
14
|
-
let set: (x: number, y: number) => string;
|
|
15
|
-
}
|
|
16
|
-
export namespace shape {
|
|
17
|
-
export let steadyBlock: string;
|
|
18
|
-
export let steadyBar: string;
|
|
19
|
-
export let steadyUnderline: string;
|
|
20
|
-
export let blinkingBlock: string;
|
|
21
|
-
export let blinkingBar: string;
|
|
22
|
-
export let blinkingUnderline: string;
|
|
23
|
-
let _default: string;
|
|
24
|
-
export { _default as default };
|
|
25
|
-
}
|
package/dist/caret.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @type {(code: string) => (count?: number) => string} */
|
|
3
|
-
const move = code => count => `\x1b[${count === undefined ? "" : count ? count : "?"}${code}`;
|
|
4
|
-
const caret = {
|
|
5
|
-
up: move("A"),
|
|
6
|
-
down: move("B"),
|
|
7
|
-
forward: move("C"),
|
|
8
|
-
backward: move("D"),
|
|
9
|
-
nextLine: move("E"),
|
|
10
|
-
prevLine: move("F"),
|
|
11
|
-
/** @type {(x: number) => string} */
|
|
12
|
-
x: x => `\x1b[${x}G`,
|
|
13
|
-
// These are the old VT100 codes, but they're widely supported by old and new terminals. The
|
|
14
|
-
// newer VT220 codes are standardized by ECMA and ISO, and are also widely supported, but might
|
|
15
|
-
// not work in some older terminals. The VT220 codes are:
|
|
16
|
-
//
|
|
17
|
-
// ```
|
|
18
|
-
// save : "\x1b[s",
|
|
19
|
-
// restore : "\x1b[u",
|
|
20
|
-
// ```
|
|
21
|
-
save: "\x1b7",
|
|
22
|
-
restore: "\x1b8",
|
|
23
|
-
hide: "\x1b[?25l",
|
|
24
|
-
show: "\x1b[?25h",
|
|
25
|
-
position: {
|
|
26
|
-
get: "\x1b[6n",
|
|
27
|
-
/** @type {(x: number, y: number) => string} */
|
|
28
|
-
set: (x, y) => `\x1b[${y};${x}H`,
|
|
29
|
-
},
|
|
30
|
-
shape: {
|
|
31
|
-
steadyBlock: "\x1b[2 q",
|
|
32
|
-
steadyBar: "\x1b[6 q",
|
|
33
|
-
steadyUnderline: "\x1b[4 q",
|
|
34
|
-
blinkingBlock: "\x1b[1 q",
|
|
35
|
-
blinkingBar: "\x1b[5 q",
|
|
36
|
-
blinkingUnderline: "\x1b[3 q",
|
|
37
|
-
default: "\x1b[0 q",
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
module.exports = caret;
|
package/dist/erase.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export namespace line {
|
|
2
|
-
let toStart: string;
|
|
3
|
-
let toEnd: string;
|
|
4
|
-
let full: string;
|
|
5
|
-
}
|
|
6
|
-
export namespace screen {
|
|
7
|
-
let toStart_1: string;
|
|
8
|
-
export { toStart_1 as toStart };
|
|
9
|
-
let toEnd_1: string;
|
|
10
|
-
export { toEnd_1 as toEnd };
|
|
11
|
-
let full_1: string;
|
|
12
|
-
export { full_1 as full };
|
|
13
|
-
export let scrollback: string;
|
|
14
|
-
}
|
package/dist/erase.js
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
declare const _exports: {
|
|
2
|
-
caret: {
|
|
3
|
-
up: (count?: number) => string;
|
|
4
|
-
down: (count?: number) => string;
|
|
5
|
-
forward: (count?: number) => string;
|
|
6
|
-
backward: (count?: number) => string;
|
|
7
|
-
nextLine: (count?: number) => string;
|
|
8
|
-
prevLine: (count?: number) => string;
|
|
9
|
-
x: (x: number) => string;
|
|
10
|
-
save: string;
|
|
11
|
-
restore: string;
|
|
12
|
-
hide: string;
|
|
13
|
-
show: string;
|
|
14
|
-
position: {
|
|
15
|
-
get: string;
|
|
16
|
-
set: (x: number, y: number) => string;
|
|
17
|
-
};
|
|
18
|
-
shape: {
|
|
19
|
-
steadyBlock: string;
|
|
20
|
-
steadyBar: string;
|
|
21
|
-
steadyUnderline: string;
|
|
22
|
-
blinkingBlock: string;
|
|
23
|
-
blinkingBar: string;
|
|
24
|
-
blinkingUnderline: string;
|
|
25
|
-
default: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
erase: {
|
|
29
|
-
line: {
|
|
30
|
-
toStart: string;
|
|
31
|
-
toEnd: string;
|
|
32
|
-
full: string;
|
|
33
|
-
};
|
|
34
|
-
screen: {
|
|
35
|
-
toStart: string;
|
|
36
|
-
toEnd: string;
|
|
37
|
-
full: string;
|
|
38
|
-
scrollback: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
scroll: {
|
|
42
|
-
up: (lines?: number) => string;
|
|
43
|
-
down: (lines?: number) => string;
|
|
44
|
-
};
|
|
45
|
-
reset: string;
|
|
46
|
-
style: {
|
|
47
|
-
bold: import("./sgr/sgr").SGR;
|
|
48
|
-
dim: import("./sgr/sgr").SGR;
|
|
49
|
-
italic: import("./sgr/sgr").SGR;
|
|
50
|
-
underline: import("./sgr/sgr").SGR;
|
|
51
|
-
inverse: import("./sgr/sgr").SGR;
|
|
52
|
-
hidden: import("./sgr/sgr").SGR;
|
|
53
|
-
strikethrough: import("./sgr/sgr").SGR;
|
|
54
|
-
doubleUnderline: import("./sgr/sgr").SGR;
|
|
55
|
-
frame: import("./sgr/sgr").SGR;
|
|
56
|
-
encircle: import("./sgr/sgr").SGR;
|
|
57
|
-
overline: import("./sgr/sgr").SGR;
|
|
58
|
-
};
|
|
59
|
-
fg: {
|
|
60
|
-
black: import("./sgr/sgr").SGR;
|
|
61
|
-
red: import("./sgr/sgr").SGR;
|
|
62
|
-
green: import("./sgr/sgr").SGR;
|
|
63
|
-
yellow: import("./sgr/sgr").SGR;
|
|
64
|
-
blue: import("./sgr/sgr").SGR;
|
|
65
|
-
magenta: import("./sgr/sgr").SGR;
|
|
66
|
-
cyan: import("./sgr/sgr").SGR;
|
|
67
|
-
white: import("./sgr/sgr").SGR;
|
|
68
|
-
brightBlack: import("./sgr/sgr").SGR;
|
|
69
|
-
brightRed: import("./sgr/sgr").SGR;
|
|
70
|
-
brightGreen: import("./sgr/sgr").SGR;
|
|
71
|
-
brightYellow: import("./sgr/sgr").SGR;
|
|
72
|
-
brightBlue: import("./sgr/sgr").SGR;
|
|
73
|
-
brightMagenta: import("./sgr/sgr").SGR;
|
|
74
|
-
brightCyan: import("./sgr/sgr").SGR;
|
|
75
|
-
brightWhite: import("./sgr/sgr").SGR;
|
|
76
|
-
default: string;
|
|
77
|
-
rgb: (r: number, g: number, b: number) => (text: string) => string;
|
|
78
|
-
x256: (arg0: number, arg1?: number, arg2?: number) => (text: string) => string;
|
|
79
|
-
};
|
|
80
|
-
bg: {
|
|
81
|
-
black: import("./sgr/sgr").SGR;
|
|
82
|
-
red: import("./sgr/sgr").SGR;
|
|
83
|
-
green: import("./sgr/sgr").SGR;
|
|
84
|
-
yellow: import("./sgr/sgr").SGR;
|
|
85
|
-
blue: import("./sgr/sgr").SGR;
|
|
86
|
-
magenta: import("./sgr/sgr").SGR;
|
|
87
|
-
cyan: import("./sgr/sgr").SGR;
|
|
88
|
-
white: import("./sgr/sgr").SGR;
|
|
89
|
-
brightBlack: import("./sgr/sgr").SGR;
|
|
90
|
-
brightRed: import("./sgr/sgr").SGR;
|
|
91
|
-
brightGreen: import("./sgr/sgr").SGR;
|
|
92
|
-
brightYellow: import("./sgr/sgr").SGR;
|
|
93
|
-
brightBlue: import("./sgr/sgr").SGR;
|
|
94
|
-
brightMagenta: import("./sgr/sgr").SGR;
|
|
95
|
-
brightCyan: import("./sgr/sgr").SGR;
|
|
96
|
-
brightWhite: import("./sgr/sgr").SGR;
|
|
97
|
-
default: string;
|
|
98
|
-
rgb: (r: number, g: number, b: number) => (text: string) => string;
|
|
99
|
-
x256: (arg0: number, arg1?: number, arg2?: number) => (text: string) => string;
|
|
100
|
-
};
|
|
101
|
-
strip: (text: string) => string;
|
|
102
|
-
sanitize: (text: string) => string;
|
|
103
|
-
slice: typeof import("./strip").slice;
|
|
104
|
-
simplify: typeof import("./simplify/simplify").simplify;
|
|
105
|
-
};
|
|
106
|
-
export = _exports;
|
package/dist/index.js
DELETED
package/dist/scroll.d.ts
DELETED
package/dist/scroll.js
DELETED
package/dist/sgr/color.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export namespace fg {
|
|
2
|
-
export let black: import("./sgr").SGR;
|
|
3
|
-
export let red: import("./sgr").SGR;
|
|
4
|
-
export let green: import("./sgr").SGR;
|
|
5
|
-
export let yellow: import("./sgr").SGR;
|
|
6
|
-
export let blue: import("./sgr").SGR;
|
|
7
|
-
export let magenta: import("./sgr").SGR;
|
|
8
|
-
export let cyan: import("./sgr").SGR;
|
|
9
|
-
export let white: import("./sgr").SGR;
|
|
10
|
-
export let brightBlack: import("./sgr").SGR;
|
|
11
|
-
export let brightRed: import("./sgr").SGR;
|
|
12
|
-
export let brightGreen: import("./sgr").SGR;
|
|
13
|
-
export let brightYellow: import("./sgr").SGR;
|
|
14
|
-
export let brightBlue: import("./sgr").SGR;
|
|
15
|
-
export let brightMagenta: import("./sgr").SGR;
|
|
16
|
-
export let brightCyan: import("./sgr").SGR;
|
|
17
|
-
export let brightWhite: import("./sgr").SGR;
|
|
18
|
-
let _default: string;
|
|
19
|
-
export { _default as default };
|
|
20
|
-
export let rgb: (r: number, g: number, b: number) => (text: string) => string;
|
|
21
|
-
export let x256: (arg0: number, arg1?: number, arg2?: number) => (text: string) => string;
|
|
22
|
-
}
|
|
23
|
-
export namespace bg {
|
|
24
|
-
let black_1: import("./sgr").SGR;
|
|
25
|
-
export { black_1 as black };
|
|
26
|
-
let red_1: import("./sgr").SGR;
|
|
27
|
-
export { red_1 as red };
|
|
28
|
-
let green_1: import("./sgr").SGR;
|
|
29
|
-
export { green_1 as green };
|
|
30
|
-
let yellow_1: import("./sgr").SGR;
|
|
31
|
-
export { yellow_1 as yellow };
|
|
32
|
-
let blue_1: import("./sgr").SGR;
|
|
33
|
-
export { blue_1 as blue };
|
|
34
|
-
let magenta_1: import("./sgr").SGR;
|
|
35
|
-
export { magenta_1 as magenta };
|
|
36
|
-
let cyan_1: import("./sgr").SGR;
|
|
37
|
-
export { cyan_1 as cyan };
|
|
38
|
-
let white_1: import("./sgr").SGR;
|
|
39
|
-
export { white_1 as white };
|
|
40
|
-
let brightBlack_1: import("./sgr").SGR;
|
|
41
|
-
export { brightBlack_1 as brightBlack };
|
|
42
|
-
let brightRed_1: import("./sgr").SGR;
|
|
43
|
-
export { brightRed_1 as brightRed };
|
|
44
|
-
let brightGreen_1: import("./sgr").SGR;
|
|
45
|
-
export { brightGreen_1 as brightGreen };
|
|
46
|
-
let brightYellow_1: import("./sgr").SGR;
|
|
47
|
-
export { brightYellow_1 as brightYellow };
|
|
48
|
-
let brightBlue_1: import("./sgr").SGR;
|
|
49
|
-
export { brightBlue_1 as brightBlue };
|
|
50
|
-
let brightMagenta_1: import("./sgr").SGR;
|
|
51
|
-
export { brightMagenta_1 as brightMagenta };
|
|
52
|
-
let brightCyan_1: import("./sgr").SGR;
|
|
53
|
-
export { brightCyan_1 as brightCyan };
|
|
54
|
-
let brightWhite_1: import("./sgr").SGR;
|
|
55
|
-
export { brightWhite_1 as brightWhite };
|
|
56
|
-
let _default_1: string;
|
|
57
|
-
export { _default_1 as default };
|
|
58
|
-
let rgb_1: (r: number, g: number, b: number) => (text: string) => string;
|
|
59
|
-
export { rgb_1 as rgb };
|
|
60
|
-
let x256_1: (arg0: number, arg1?: number, arg2?: number) => (text: string) => string;
|
|
61
|
-
export { x256_1 as x256 };
|
|
62
|
-
}
|
package/dist/sgr/color.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const { sgr } = require("./sgr");
|
|
3
|
-
/** @type {(r: number, g: number, b: number, open: number, close: number) => (text: string) => string} */
|
|
4
|
-
const rgb = (r, g, b, open, close) => sgr([open, 2, r, g, b], close);
|
|
5
|
-
/**
|
|
6
|
-
* @overload
|
|
7
|
-
* @param {number} code
|
|
8
|
-
* @param {number} open
|
|
9
|
-
* @param {number} close
|
|
10
|
-
* @returns {(text: string) => string}
|
|
11
|
-
*/ /**
|
|
12
|
-
* @overload
|
|
13
|
-
* @param {number} r
|
|
14
|
-
* @param {number} g
|
|
15
|
-
* @param {number} b
|
|
16
|
-
* @param {number} open
|
|
17
|
-
* @param {number} close
|
|
18
|
-
* @returns {(text: string) => string}
|
|
19
|
-
*/ /**
|
|
20
|
-
@type {
|
|
21
|
-
(
|
|
22
|
-
...args: [number, number, number] | [number, number, number, number, number]
|
|
23
|
-
) => (text: string) => string}
|
|
24
|
-
*/
|
|
25
|
-
function x256(...args) {
|
|
26
|
-
if (args.length === 3)
|
|
27
|
-
return sgr([args[1], 5, args[0]], args[2]);
|
|
28
|
-
const [r, g, b, open, close] = args;
|
|
29
|
-
if (r === g && g === b) {
|
|
30
|
-
// grayscale
|
|
31
|
-
return sgr([open, 5, 232 + Math.floor(r * 24 / 256)], close);
|
|
32
|
-
}
|
|
33
|
-
// 6x6x6 color cube
|
|
34
|
-
return sgr([
|
|
35
|
-
open,
|
|
36
|
-
5,
|
|
37
|
-
16 +
|
|
38
|
-
Math.floor(r * 6 / 256) * 36 +
|
|
39
|
-
Math.floor(g * 6 / 256) * 6 +
|
|
40
|
-
Math.floor(b * 6 / 256)
|
|
41
|
-
], close);
|
|
42
|
-
}
|
|
43
|
-
const fg = {
|
|
44
|
-
black: sgr(30, 39),
|
|
45
|
-
red: sgr(31, 39),
|
|
46
|
-
green: sgr(32, 39),
|
|
47
|
-
yellow: sgr(33, 39),
|
|
48
|
-
blue: sgr(34, 39),
|
|
49
|
-
magenta: sgr(35, 39),
|
|
50
|
-
cyan: sgr(36, 39),
|
|
51
|
-
white: sgr(37, 39),
|
|
52
|
-
brightBlack: sgr(90, 39),
|
|
53
|
-
brightRed: sgr(91, 39),
|
|
54
|
-
brightGreen: sgr(92, 39),
|
|
55
|
-
brightYellow: sgr(93, 39),
|
|
56
|
-
brightBlue: sgr(94, 39),
|
|
57
|
-
brightMagenta: sgr(95, 39),
|
|
58
|
-
brightCyan: sgr(96, 39),
|
|
59
|
-
brightWhite: sgr(97, 39),
|
|
60
|
-
default: "\x1b[39m",
|
|
61
|
-
/** @type {(r: number, g: number, b: number) => (text: string) => string} */
|
|
62
|
-
rgb: (r, g, b) => rgb(r, g, b, 38, 39),
|
|
63
|
-
/**
|
|
64
|
-
* @overload
|
|
65
|
-
* @param {number} code
|
|
66
|
-
* @returns {(text: string) => string}
|
|
67
|
-
*/ /**
|
|
68
|
-
* @param {number} r
|
|
69
|
-
* @param {number} g
|
|
70
|
-
* @param {number} b
|
|
71
|
-
* @returns {(text: string) => string}
|
|
72
|
-
*/ /** @type {(arg0: number, arg1?: number, arg2?: number) => (text: string) => string} */
|
|
73
|
-
x256: (arg0, arg1, arg2) => arg1 === undefined || arg2 === undefined
|
|
74
|
-
? x256(arg0, 38, 39)
|
|
75
|
-
: x256(arg0, arg1, arg2, 38, 39),
|
|
76
|
-
};
|
|
77
|
-
const bg = {
|
|
78
|
-
black: sgr(40, 49),
|
|
79
|
-
red: sgr(41, 49),
|
|
80
|
-
green: sgr(42, 49),
|
|
81
|
-
yellow: sgr(43, 49),
|
|
82
|
-
blue: sgr(44, 49),
|
|
83
|
-
magenta: sgr(45, 49),
|
|
84
|
-
cyan: sgr(46, 49),
|
|
85
|
-
white: sgr(47, 49),
|
|
86
|
-
brightBlack: sgr(100, 49),
|
|
87
|
-
brightRed: sgr(101, 49),
|
|
88
|
-
brightGreen: sgr(102, 49),
|
|
89
|
-
brightYellow: sgr(103, 49),
|
|
90
|
-
brightBlue: sgr(104, 49),
|
|
91
|
-
brightMagenta: sgr(105, 49),
|
|
92
|
-
brightCyan: sgr(106, 49),
|
|
93
|
-
brightWhite: sgr(107, 49),
|
|
94
|
-
default: "\x1b[49m",
|
|
95
|
-
/** @type {(r: number, g: number, b: number) => (text: string) => string} */
|
|
96
|
-
rgb: (r, g, b) => rgb(r, g, b, 48, 49),
|
|
97
|
-
/**
|
|
98
|
-
* @overload
|
|
99
|
-
* @param {number} code
|
|
100
|
-
* @returns {(text: string) => string}
|
|
101
|
-
*/ /**
|
|
102
|
-
* @param {number} r
|
|
103
|
-
* @param {number} g
|
|
104
|
-
* @param {number} b
|
|
105
|
-
* @returns {(text: string) => string}
|
|
106
|
-
*/ /** @type {(arg0: number, arg1?: number, arg2?: number) => (text: string) => string} */
|
|
107
|
-
x256: (arg0, arg1, arg2) => arg1 === undefined || arg2 === undefined
|
|
108
|
-
? x256(arg0, 48, 49)
|
|
109
|
-
: x256(arg0, arg1, arg2, 48, 49),
|
|
110
|
-
};
|
|
111
|
-
module.exports = { fg, bg };
|