@peteanderson/ansi 1.0.1 → 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/README.md +23 -3
- 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/features.d.ts +1 -3
- package/dist/features/features.d.ts.map +1 -1
- 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 +2 -0
- package/dist/pad.d.ts.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.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 +45 -39
- 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/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/strip.d.ts +3 -0
- package/dist/strip.d.ts.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 +3 -2
- package/src/ansi.ts +11 -36
- package/src/features/features.ts +1 -8
- package/src/features/index.ts +3 -1
- package/src/features/types.ts +10 -1
- package/src/pad.ts +4 -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/rgb.ts +48 -0
- package/src/sgr/color/utils.ts +2 -3
- 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 -54
- package/src/sgr/style.ts +35 -18
- package/src/sgr/types.ts +91 -0
- package/src/simplify/simplify.ts +3 -1
- package/src/slice.ts +3 -1
- package/src/strip.ts +5 -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/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/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/src/sgr/style.ts
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {TypedObject} from "../typed-object";
|
|
2
|
+
import {lazy} from "./lazy";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const sgr = makeSGR(enabled);
|
|
4
|
+
import type {ChainKey, FormatBuilder, Style} from "./types";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
6
|
+
const propParams = TypedObject.entries<Record<keyof Style, SkipFirst<Parameters<FormatBuilder>>>>({
|
|
7
|
+
bold : [ 1, 22, true],
|
|
8
|
+
dim : [ 2, 22, true],
|
|
9
|
+
italic : [ 3, 23],
|
|
10
|
+
underline : [ 4, 24],
|
|
11
|
+
inverse : [ 7, 27],
|
|
12
|
+
hidden : [ 8, 28],
|
|
13
|
+
strikethrough : [ 9, 29],
|
|
14
|
+
doubleUnderline : [21, 24],
|
|
15
|
+
frame : [51, 54],
|
|
16
|
+
encircle : [52, 54],
|
|
17
|
+
overline : [53, 55],
|
|
18
|
+
});
|
|
20
19
|
|
|
21
|
-
export
|
|
20
|
+
export function makeStyle(
|
|
21
|
+
keys : ReadonlySet<ChainKey>,
|
|
22
|
+
makeFormatter : FormatBuilder,
|
|
23
|
+
enabled : boolean,
|
|
24
|
+
): Style<any> {
|
|
25
|
+
const rtn = {} as Style<any>;
|
|
26
|
+
|
|
27
|
+
for (const [key, args] of propParams) {
|
|
28
|
+
if (keys.has(key)) {
|
|
29
|
+
lazy.add(rtn, key, () => {
|
|
30
|
+
const newKeys = new Set(keys);
|
|
31
|
+
newKeys.delete(key);
|
|
32
|
+
return enabled ? makeFormatter(newKeys, ...args) : makeFormatter(newKeys, 0, 0);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return rtn;
|
|
38
|
+
}
|
package/src/sgr/types.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export type ColorKey = "fg" | "bg";
|
|
2
|
+
|
|
3
|
+
export type StyleKey =
|
|
4
|
+
| "bold"
|
|
5
|
+
| "dim"
|
|
6
|
+
| "italic"
|
|
7
|
+
| "underline"
|
|
8
|
+
| "inverse"
|
|
9
|
+
| "hidden"
|
|
10
|
+
| "strikethrough"
|
|
11
|
+
| "doubleUnderline"
|
|
12
|
+
| "frame"
|
|
13
|
+
| "encircle"
|
|
14
|
+
| "overline";
|
|
15
|
+
|
|
16
|
+
export type ChainKey = ColorKey | StyleKey;
|
|
17
|
+
|
|
18
|
+
export type Chain<Keys extends ChainKey> = Color<Keys> & Style<Keys>;
|
|
19
|
+
|
|
20
|
+
export type ChainBuilder = <Keys extends ChainKey>(
|
|
21
|
+
keys : ReadonlySet<Keys>,
|
|
22
|
+
baseFormat : FormatBase,
|
|
23
|
+
) => Chain<Keys>;
|
|
24
|
+
|
|
25
|
+
export type Code = number | number[];
|
|
26
|
+
|
|
27
|
+
export interface FormatBase {
|
|
28
|
+
(text: string): string;
|
|
29
|
+
|
|
30
|
+
open : string;
|
|
31
|
+
close : string;
|
|
32
|
+
codes : {open: Code, close: Code};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ChainedFormat<Keys extends ChainKey = ChainKey> extends FormatBase {
|
|
36
|
+
and: Chain<Keys>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type Format<Keys extends ChainKey = ChainKey> =
|
|
40
|
+
[Keys] extends [never] ? FormatBase : ChainedFormat<Keys>;
|
|
41
|
+
|
|
42
|
+
export type FormatBuilder = <Keys extends ChainKey = ChainKey>(
|
|
43
|
+
keys : ReadonlySet<Keys>,
|
|
44
|
+
open : Code,
|
|
45
|
+
close : Code,
|
|
46
|
+
reset? : boolean,
|
|
47
|
+
) => Format<Keys>;
|
|
48
|
+
|
|
49
|
+
export interface Channel<Keys extends ChainKey = ChainKey> {
|
|
50
|
+
black : Format<Keys>;
|
|
51
|
+
red : Format<Keys>;
|
|
52
|
+
green : Format<Keys>;
|
|
53
|
+
yellow : Format<Keys>;
|
|
54
|
+
blue : Format<Keys>;
|
|
55
|
+
magenta : Format<Keys>;
|
|
56
|
+
cyan : Format<Keys>;
|
|
57
|
+
white : Format<Keys>;
|
|
58
|
+
|
|
59
|
+
brightBlack : Format<Keys>;
|
|
60
|
+
brightRed : Format<Keys>;
|
|
61
|
+
brightGreen : Format<Keys>;
|
|
62
|
+
brightYellow : Format<Keys>;
|
|
63
|
+
brightBlue : Format<Keys>;
|
|
64
|
+
brightMagenta : Format<Keys>;
|
|
65
|
+
brightCyan : Format<Keys>;
|
|
66
|
+
brightWhite : Format<Keys>;
|
|
67
|
+
|
|
68
|
+
rgb: (r: number, g: number, b: number) => Format<Keys>;
|
|
69
|
+
|
|
70
|
+
x256: {
|
|
71
|
+
(code: number): Format<Keys>;
|
|
72
|
+
(r: number, g: number, b: number): Format<Keys>;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
default: string,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type Color<Keys extends ChainKey = ChainKey> = {
|
|
79
|
+
[K in Extract<ColorKey, Keys>]: Channel<Exclude<Keys, K>>;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type Style<Keys extends ChainKey = ChainKey> = {
|
|
83
|
+
[K in Extract<StyleKey, Keys>]: Format<Exclude<Keys, K>>;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export interface SGR {
|
|
87
|
+
fg : Channel<Exclude<ChainKey, "fg">>;
|
|
88
|
+
bg : Channel<Exclude<ChainKey, "bg">>;
|
|
89
|
+
style : Style;
|
|
90
|
+
reset : string;
|
|
91
|
+
}
|
package/src/simplify/simplify.ts
CHANGED
package/src/slice.ts
CHANGED
|
@@ -83,4 +83,6 @@ export function slice(text: string, start: number, end: number): string {
|
|
|
83
83
|
const trailingSequences = skippedSequences(text, endIndex);
|
|
84
84
|
|
|
85
85
|
return leadingSequences + text.slice(startIndex, endIndex) + trailingSequences;
|
|
86
|
-
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type Slice = typeof slice;
|
package/src/strip.ts
CHANGED
|
@@ -7,4 +7,8 @@ export const strip = (text: string): string => text.replace(new RegExp(r
|
|
|
7
7
|
export const visibleLength = (text: string): number => strip(text).length;
|
|
8
8
|
|
|
9
9
|
/** Remove all ANSI escape codes except SGR codes (m), which are used for color and styling. */
|
|
10
|
-
export const sanitize = (text: string): string => text.replace(new RegExp(rxUnsafe), "");
|
|
10
|
+
export const sanitize = (text: string): string => text.replace(new RegExp(rxUnsafe), "");
|
|
11
|
+
|
|
12
|
+
export type Strip = typeof strip;
|
|
13
|
+
export type VisibleLength = typeof visibleLength;
|
|
14
|
+
export type Sanitize = typeof sanitize;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export type TypedPropertyDescriptorMap<T> = {
|
|
2
|
+
[K in keyof T]: TypedPropertyDescriptor<T[K]>;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export interface TypedObject {
|
|
6
|
+
getOwnPropertyNames<T>(o: T): KeyOf<T>[];
|
|
7
|
+
|
|
8
|
+
keys<T> (o: T): KeyOf<T>[];
|
|
9
|
+
values<T> (o: T): ValuesOf<T>;
|
|
10
|
+
entries<T>(o: T): EntriesOf<T>;
|
|
11
|
+
fromEntries<K extends keyof any, V>(entries: Iterable<readonly [K, V]>): Record<K, V>;
|
|
12
|
+
|
|
13
|
+
create<T>(prototype: object, properties: TypedPropertyDescriptorMap<T>): T;
|
|
14
|
+
|
|
15
|
+
recreate<T, U>(
|
|
16
|
+
o : T,
|
|
17
|
+
fn : <K extends keyof T>(
|
|
18
|
+
key : K,
|
|
19
|
+
property : TypedPropertyDescriptor<T[K]>
|
|
20
|
+
) => [K, TypedPropertyDescriptor<U>]
|
|
21
|
+
): Record<keyof T, U>;
|
|
22
|
+
|
|
23
|
+
transform<T, K extends keyof any, V>(
|
|
24
|
+
o : T,
|
|
25
|
+
fn : (key: KeyOf<T>, value: T[keyof T]) => readonly [K, V]
|
|
26
|
+
): Record<K, V>;
|
|
27
|
+
|
|
28
|
+
toMap<T extends {}, K = KeyOf<T>, V = T[keyof T]>(
|
|
29
|
+
o : T,
|
|
30
|
+
transform? : (key: KeyOf<T>, value: T[keyof T]) => readonly [K, V]
|
|
31
|
+
): Map<K, V>;
|
|
32
|
+
}
|
|
33
|
+
export const TypedObject = Object.freeze({
|
|
34
|
+
getOwnPropertyNames : Object.getOwnPropertyNames,
|
|
35
|
+
keys : Object.keys,
|
|
36
|
+
values : Object.values,
|
|
37
|
+
entries : Object.entries,
|
|
38
|
+
fromEntries : Object.fromEntries,
|
|
39
|
+
create : Object.create,
|
|
40
|
+
|
|
41
|
+
recreate: <T, U>(
|
|
42
|
+
o : T,
|
|
43
|
+
fn : <K extends keyof T>(
|
|
44
|
+
key : K,
|
|
45
|
+
property : TypedPropertyDescriptor<T[K]>
|
|
46
|
+
) => [K, TypedPropertyDescriptor<U>]
|
|
47
|
+
): Record<keyof T, U> => Object.create(
|
|
48
|
+
Object.getPrototypeOf(o),
|
|
49
|
+
TypedObject.transform(Object.getOwnPropertyDescriptors(o), fn as any),
|
|
50
|
+
),
|
|
51
|
+
|
|
52
|
+
transform: <T, K extends keyof any, V>(
|
|
53
|
+
o : T,
|
|
54
|
+
fn : (key: KeyOf<T>, value: T[keyof T]) => readonly [K, V],
|
|
55
|
+
): Record<K, V> => TypedObject.fromEntries(
|
|
56
|
+
TypedObject.entries(o).map(([key, value]) => fn(key as any, value)),
|
|
57
|
+
),
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
@type {
|
|
61
|
+
<T extends {}, K = KeyOf<T>, V = T[keyof T]>(
|
|
62
|
+
o : T,
|
|
63
|
+
transform? : (key: KeyOf<T>, value: T[keyof T]) => readonly [K, V]
|
|
64
|
+
) => Map<K, V>
|
|
65
|
+
}
|
|
66
|
+
*/
|
|
67
|
+
toMap<T extends {}, K = KeyOf<T>, V = T[keyof T]>(
|
|
68
|
+
o : T,
|
|
69
|
+
transform? : (key: KeyOf<T>, value: T[keyof T]) => readonly [K, V],
|
|
70
|
+
): Map<K, V> {
|
|
71
|
+
const map = new Map<K, V>();
|
|
72
|
+
|
|
73
|
+
if (transform) {
|
|
74
|
+
for (const [key, value] of TypedObject.entries(o)) {
|
|
75
|
+
const [newKey, newValue] = transform(key as any, value);
|
|
76
|
+
map.set(newKey, newValue);
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
for (const [key, value] of TypedObject.entries(o))
|
|
80
|
+
map.set(key as any, value as any);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return map;
|
|
84
|
+
},
|
|
85
|
+
}) as TypedObject;
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type {Caret} from "./caret";
|
|
2
|
+
import type {Erase} from "./erase";
|
|
3
|
+
import type {Features} from "./features";
|
|
4
|
+
import type {PadEnd, PadStart} from "./pad";
|
|
5
|
+
import type {Scroll} from "./scroll";
|
|
6
|
+
import type {SGR} from "./sgr";
|
|
7
|
+
import type {Simplify} from "./simplify";
|
|
8
|
+
import type {Slice} from "./slice";
|
|
9
|
+
import type {Sanitize, Strip, VisibleLength} from "./strip";
|
|
10
|
+
import type {Terminal} from "./terminal";
|
|
11
|
+
|
|
12
|
+
export type Ansi = SGR & {
|
|
13
|
+
caret : Caret;
|
|
14
|
+
erase : Erase;
|
|
15
|
+
scroll : Scroll;
|
|
16
|
+
terminal : Terminal;
|
|
17
|
+
|
|
18
|
+
padEnd : PadEnd;
|
|
19
|
+
padStart : PadStart;
|
|
20
|
+
|
|
21
|
+
strip : Strip;
|
|
22
|
+
visibleLength : VisibleLength;
|
|
23
|
+
sanitize : Sanitize;
|
|
24
|
+
slice : Slice;
|
|
25
|
+
simplify : Simplify;
|
|
26
|
+
|
|
27
|
+
features : Features;
|
|
28
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
|
|
2
|
+
type UnionToIntersection<U> =
|
|
3
|
+
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
4
|
+
|
|
5
|
+
type StringKey<T> = T extends number ? `${T}` : T extends string ? T : never;
|
|
6
|
+
type KeyOf<T> = StringKey<keyof T>;
|
|
7
|
+
|
|
8
|
+
type ValueOf<T, K extends keyof T = keyof T> = Required<T>[K];
|
|
9
|
+
type ValuesOf<T, K extends [...(keyof T)[]] = (keyof T)[]> = {
|
|
10
|
+
[P in keyof K]: K[P] extends keyof T ? ValueOf<T, K[P]> : never;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type EntryOf<T, K extends keyof T = keyof T> = [K, ValueOf<T, K>];
|
|
14
|
+
type EntriesOf<T, K extends [...(keyof T)[]] = (keyof T)[]> = {
|
|
15
|
+
[P in keyof K]: K[P] extends keyof T ? EntryOf<T, K[P]> : never;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type SkipFirst<T> = T extends [infer First, ...infer Rest] ? Rest : [];
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { SGR } from "../sgr";
|
|
2
|
-
export interface Channel {
|
|
3
|
-
black: SGR;
|
|
4
|
-
red: SGR;
|
|
5
|
-
green: SGR;
|
|
6
|
-
yellow: SGR;
|
|
7
|
-
blue: SGR;
|
|
8
|
-
magenta: SGR;
|
|
9
|
-
cyan: SGR;
|
|
10
|
-
white: SGR;
|
|
11
|
-
brightBlack: SGR;
|
|
12
|
-
brightRed: SGR;
|
|
13
|
-
brightGreen: SGR;
|
|
14
|
-
brightYellow: SGR;
|
|
15
|
-
brightBlue: SGR;
|
|
16
|
-
brightMagenta: SGR;
|
|
17
|
-
brightCyan: SGR;
|
|
18
|
-
brightWhite: SGR;
|
|
19
|
-
rgb: (r: number, g: number, b: number) => SGR;
|
|
20
|
-
x256: {
|
|
21
|
-
(code: number): SGR;
|
|
22
|
-
(r: number, g: number, b: number): SGR;
|
|
23
|
-
};
|
|
24
|
-
default: string;
|
|
25
|
-
}
|
|
26
|
-
export type Color = {
|
|
27
|
-
fg: Channel;
|
|
28
|
-
bg: Channel;
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/sgr/color/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,QAAQ,CAAC;AAEhC,MAAM,WAAW,OAAO;IACvB,KAAK,EAAK,GAAG,CAAC;IACd,GAAG,EAAO,GAAG,CAAC;IACd,KAAK,EAAK,GAAG,CAAC;IACd,MAAM,EAAI,GAAG,CAAC;IACd,IAAI,EAAM,GAAG,CAAC;IACd,OAAO,EAAG,GAAG,CAAC;IACd,IAAI,EAAM,GAAG,CAAC;IACd,KAAK,EAAK,GAAG,CAAC;IAEd,WAAW,EAAK,GAAG,CAAC;IACpB,SAAS,EAAO,GAAG,CAAC;IACpB,WAAW,EAAK,GAAG,CAAC;IACpB,YAAY,EAAI,GAAG,CAAC;IACpB,UAAU,EAAM,GAAG,CAAC;IACpB,aAAa,EAAG,GAAG,CAAC;IACpB,UAAU,EAAM,GAAG,CAAC;IACpB,WAAW,EAAK,GAAG,CAAC;IAEpB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;IAE9C,IAAI,EAAE;QACL,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QACpB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;KACvC,CAAC;IAEF,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,KAAK,GAAG;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAC,CAAC"}
|
package/dist/sgr/utils.d.ts
DELETED
package/dist/sgr/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sgr/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAEhC,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAcvD"}
|
package/dist/sgr/utils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.combine = combine;
|
|
4
|
-
function combine(code, codes) {
|
|
5
|
-
if (!codes.length)
|
|
6
|
-
return code;
|
|
7
|
-
const rtn = Array.isArray(code) ? [...code] : [code];
|
|
8
|
-
for (const c of codes) {
|
|
9
|
-
if (Array.isArray(c))
|
|
10
|
-
rtn.push(...c);
|
|
11
|
-
else
|
|
12
|
-
rtn.push(c);
|
|
13
|
-
}
|
|
14
|
-
return rtn;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/sgr/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/sgr/utils.ts"],"names":[],"mappings":";;AAEA,0BAcC;AAdD,SAAgB,OAAO,CAAC,IAAU,EAAE,KAAa;IAChD,IAAI,CAAC,KAAK,CAAC,MAAM;QAChB,OAAO,IAAI,CAAC;IAEb,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YACnB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;YAEf,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
package/src/sgr/color/types.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type {SGR} from "../sgr";
|
|
2
|
-
|
|
3
|
-
export interface Channel {
|
|
4
|
-
black : SGR;
|
|
5
|
-
red : SGR;
|
|
6
|
-
green : SGR;
|
|
7
|
-
yellow : SGR;
|
|
8
|
-
blue : SGR;
|
|
9
|
-
magenta : SGR;
|
|
10
|
-
cyan : SGR;
|
|
11
|
-
white : SGR;
|
|
12
|
-
|
|
13
|
-
brightBlack : SGR;
|
|
14
|
-
brightRed : SGR;
|
|
15
|
-
brightGreen : SGR;
|
|
16
|
-
brightYellow : SGR;
|
|
17
|
-
brightBlue : SGR;
|
|
18
|
-
brightMagenta : SGR;
|
|
19
|
-
brightCyan : SGR;
|
|
20
|
-
brightWhite : SGR;
|
|
21
|
-
|
|
22
|
-
rgb: (r: number, g: number, b: number) => SGR;
|
|
23
|
-
|
|
24
|
-
x256: {
|
|
25
|
-
(code: number): SGR;
|
|
26
|
-
(r: number, g: number, b: number): SGR;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
default: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type Color = {fg: Channel; bg: Channel};
|
package/src/sgr/utils.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type {Code} from "./sgr";
|
|
2
|
-
|
|
3
|
-
export function combine(code: Code, codes: Code[]): Code {
|
|
4
|
-
if (!codes.length)
|
|
5
|
-
return code;
|
|
6
|
-
|
|
7
|
-
const rtn = Array.isArray(code) ? [...code] : [code];
|
|
8
|
-
|
|
9
|
-
for (const c of codes) {
|
|
10
|
-
if (Array.isArray(c))
|
|
11
|
-
rtn.push(...c);
|
|
12
|
-
else
|
|
13
|
-
rtn.push(c);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return rtn;
|
|
17
|
-
}
|
|
File without changes
|