termark 2.0.0 → 3.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/LICENCE.txt +177 -177
- package/README.md +180 -259
- package/README.npm.md +57 -0
- package/dist/__internal/conversion.cjs +1 -0
- package/dist/__internal/conversion.mjs +1 -0
- package/dist/__internal/env.cjs +1 -0
- package/dist/__internal/env.d.mts +21 -0
- package/dist/__internal/env.mjs +1 -0
- package/dist/__internal/format.cjs +1 -0
- package/dist/__internal/format.mjs +1 -0
- package/dist/__internal/impl.cjs +1 -0
- package/dist/__internal/impl.mjs +1 -0
- package/dist/__internal/styling.cjs +1 -0
- package/dist/__internal/styling.d.mts +115 -0
- package/dist/__internal/styling.mjs +1 -0
- package/dist/__internal/util.cjs +1 -0
- package/dist/__internal/util.mjs +1 -0
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +161 -0
- package/dist/index.mjs +4 -1
- package/dist/types.d.mts +279 -0
- package/dist/utilities.cjs +1 -0
- package/dist/utilities.d.mts +54 -0
- package/dist/utilities.mjs +1 -0
- package/package.json +49 -37
- package/dist/index.d.ts +0 -338
- package/dist/util.d.ts +0 -51
package/package.json
CHANGED
|
@@ -1,39 +1,51 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "https://codeberg.org/Genesis_Software/termark.git"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
34
|
-
"@types/node": "^24.3.0",
|
|
35
|
-
"rollup": "^4.49.0",
|
|
36
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
37
|
-
"typescript": "^5.9.2"
|
|
2
|
+
"name": "termark",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "A basic library to format console output to the standard non-browser terminal.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"console",
|
|
7
|
+
"formatting",
|
|
8
|
+
"node",
|
|
9
|
+
"output",
|
|
10
|
+
"utility"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://genesis.q-file.com/projects/termark",
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"author": "Miyazaki \"Q\" Hashimoto",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://codeberg.org/Genesis_Software/termark.git"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.mjs",
|
|
22
|
+
"types": "./dist/index.d.mts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"import": "./dist/index.mjs",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
38
28
|
}
|
|
39
|
-
}
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^24.3.0",
|
|
32
|
+
"oxfmt": "^0.50.0",
|
|
33
|
+
"oxlint": "^1.65.0",
|
|
34
|
+
"tsdown": "^0.22.0",
|
|
35
|
+
"tsx": "^4.22.0",
|
|
36
|
+
"typescript": "^5.9.2",
|
|
37
|
+
"vitest": "^4.1.6"
|
|
38
|
+
},
|
|
39
|
+
"readme": "README.npm.md",
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsdown --config .config/tsdown.config.ts",
|
|
42
|
+
"format": "oxfmt --config .config/oxfmt.config.ts",
|
|
43
|
+
"lint": "oxlint",
|
|
44
|
+
"lint:fix": "oxlint --fix",
|
|
45
|
+
"test": "vitest --config .config/vitest.config.ts",
|
|
46
|
+
"demo:truecolor": "tsx examples/truecolor.ts",
|
|
47
|
+
"demo:box": "tsx examples/box.ts",
|
|
48
|
+
"demo:basic": "tsx examples/basic.ts",
|
|
49
|
+
"demo:link": "tsx examples/link.ts"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import { ANSIStyleType, RGB } from './util';
|
|
2
|
-
/**
|
|
3
|
-
* The `Termark` class is almost the same as the {@linkcode termark} object and by using `Termark.init`, it effectively does become the same.
|
|
4
|
-
*
|
|
5
|
-
* However, it is nonetheless useful as it enables type-safety,
|
|
6
|
-
*
|
|
7
|
-
* You use this class the same way as you would the {@linkcode termark} object.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* import { Termark } from 'termark';
|
|
12
|
-
*
|
|
13
|
-
* const termark = new Termark(); // This is the same as if you'd import the `termark` object.
|
|
14
|
-
* termark.success('Termark is working!');
|
|
15
|
-
*
|
|
16
|
-
* // Alternatively, you could do:
|
|
17
|
-
* Termark.init.success('This works, too!');
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @see The {@linkcode termark} object.
|
|
21
|
-
*/
|
|
22
|
-
export declare class Termark {
|
|
23
|
-
/**
|
|
24
|
-
* A reference to a Termark instance.
|
|
25
|
-
*
|
|
26
|
-
* This is an object that holds the properties defined below.
|
|
27
|
-
*/
|
|
28
|
-
private static termarkInstance;
|
|
29
|
-
/**
|
|
30
|
-
* A static getter function that returns a Termark reference object.
|
|
31
|
-
*
|
|
32
|
-
* With this method, it's possible to use the `Termark` class like an object.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* import { Termark } from 'termark';
|
|
37
|
-
* Termark.init.success('...');
|
|
38
|
-
*
|
|
39
|
-
* // ...is the same as:
|
|
40
|
-
*
|
|
41
|
-
* import termark from 'termark';
|
|
42
|
-
* termark.success('...');
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
static get init(): Termark;
|
|
46
|
-
/** Check whether terminal colours are enabled. */
|
|
47
|
-
areColorsEnabled: boolean;
|
|
48
|
-
/** Check whether 8-bit colours are enabled. */
|
|
49
|
-
is8bitEnabled: boolean;
|
|
50
|
-
/** Check whether 24-bit colours are enabled. */
|
|
51
|
-
is24bitEnabled: boolean;
|
|
52
|
-
/** Reset all styles. */
|
|
53
|
-
reset: (input: string | TemplateStringsArray) => string;
|
|
54
|
-
/** Make some text bold. */
|
|
55
|
-
bold: (input: string | TemplateStringsArray) => string;
|
|
56
|
-
/** Make some text thin. */
|
|
57
|
-
dim: (input: string | TemplateStringsArray) => string;
|
|
58
|
-
/** Make some text italic. May not be widely supported. */
|
|
59
|
-
italic: (input: string | TemplateStringsArray) => string;
|
|
60
|
-
/** Underline some text. */
|
|
61
|
-
underline: (input: string | TemplateStringsArray) => string;
|
|
62
|
-
/** Make some text blink slowly. */
|
|
63
|
-
blink: (input: string | TemplateStringsArray) => string;
|
|
64
|
-
/** Invert some text (foreground colour becomes background colour, background colour becomes foreground colour). */
|
|
65
|
-
inverse: (input: string | TemplateStringsArray) => string;
|
|
66
|
-
/** Add a line above some text. May not be widely supported. */
|
|
67
|
-
overline: (input: string | TemplateStringsArray) => string;
|
|
68
|
-
/** Visually hide some text. */
|
|
69
|
-
hidden: (input: string | TemplateStringsArray) => string;
|
|
70
|
-
/** Add a line through (strike) some text. */
|
|
71
|
-
strike: (input: string | TemplateStringsArray) => string;
|
|
72
|
-
/** Colour some text black. */
|
|
73
|
-
black: (input: string | TemplateStringsArray) => string;
|
|
74
|
-
/** Colour some text red. */
|
|
75
|
-
red: (input: string | TemplateStringsArray) => string;
|
|
76
|
-
/** Colour some text green. */
|
|
77
|
-
green: (input: string | TemplateStringsArray) => string;
|
|
78
|
-
/** Colour some text yellow. */
|
|
79
|
-
yellow: (input: string | TemplateStringsArray) => string;
|
|
80
|
-
/** Colour some text blue. */
|
|
81
|
-
blue: (input: string | TemplateStringsArray) => string;
|
|
82
|
-
/** Colour some text magenta. */
|
|
83
|
-
magenta: (input: string | TemplateStringsArray) => string;
|
|
84
|
-
/** Colour some text cyan. */
|
|
85
|
-
cyan: (input: string | TemplateStringsArray) => string;
|
|
86
|
-
/** Colour some text white. */
|
|
87
|
-
white: (input: string | TemplateStringsArray) => string;
|
|
88
|
-
/** Colour some text bright black (grey). */
|
|
89
|
-
blackBright: (input: string | TemplateStringsArray) => string;
|
|
90
|
-
/** Colour some text bright red. */
|
|
91
|
-
redBright: (input: string | TemplateStringsArray) => string;
|
|
92
|
-
/** Colour some text bright green. */
|
|
93
|
-
greenBright: (input: string | TemplateStringsArray) => string;
|
|
94
|
-
/** Colour some text bright yellow. */
|
|
95
|
-
yellowBright: (input: string | TemplateStringsArray) => string;
|
|
96
|
-
/** Colour some text bright blue. */
|
|
97
|
-
blueBright: (input: string | TemplateStringsArray) => string;
|
|
98
|
-
/** Colour some text bright magenta. */
|
|
99
|
-
magentaBright: (input: string | TemplateStringsArray) => string;
|
|
100
|
-
/** Colour some text bright cyan. */
|
|
101
|
-
cyanBright: (input: string | TemplateStringsArray) => string;
|
|
102
|
-
/** Colour some text bright white. */
|
|
103
|
-
whiteBright: (input: string | TemplateStringsArray) => string;
|
|
104
|
-
/** Colour the background of some text black. */
|
|
105
|
-
bgBlack: (input: string | TemplateStringsArray) => string;
|
|
106
|
-
/** Colour the background of some text red. */
|
|
107
|
-
bgRed: (input: string | TemplateStringsArray) => string;
|
|
108
|
-
/** Colour the background of some text green. */
|
|
109
|
-
bgGreen: (input: string | TemplateStringsArray) => string;
|
|
110
|
-
/** Colour the background of some text yellow. */
|
|
111
|
-
bgYellow: (input: string | TemplateStringsArray) => string;
|
|
112
|
-
/** Colour the background of some text blue. */
|
|
113
|
-
bgBlue: (input: string | TemplateStringsArray) => string;
|
|
114
|
-
/** Colour the background of some text magenta. */
|
|
115
|
-
bgMagenta: (input: string | TemplateStringsArray) => string;
|
|
116
|
-
/** Colour the background of some text cyan. */
|
|
117
|
-
bgCyan: (input: string | TemplateStringsArray) => string;
|
|
118
|
-
/** Colour the background of some text white. */
|
|
119
|
-
bgWhite: (input: string | TemplateStringsArray) => string;
|
|
120
|
-
/** Colour the background of some text bright black (grey). */
|
|
121
|
-
bgBlackBright: (input: string | TemplateStringsArray) => string;
|
|
122
|
-
/** Colour the background of some text bright red. */
|
|
123
|
-
bgRedBright: (input: string | TemplateStringsArray) => string;
|
|
124
|
-
/** Colour the background of some text bright green. */
|
|
125
|
-
bgGreenBright: (input: string | TemplateStringsArray) => string;
|
|
126
|
-
/** Colour the background of some text bright yellow. */
|
|
127
|
-
bgYellowBright: (input: string | TemplateStringsArray) => string;
|
|
128
|
-
/** Colour the background of some text bright blue. */
|
|
129
|
-
bgBlueBright: (input: string | TemplateStringsArray) => string;
|
|
130
|
-
/** Colour the background of some text bright magenta. */
|
|
131
|
-
bgMagentaBright: (input: string | TemplateStringsArray) => string;
|
|
132
|
-
/** Colour the background of some text bright cyan. */
|
|
133
|
-
bgCyanBright: (input: string | TemplateStringsArray) => string;
|
|
134
|
-
/** Colour the background of some text bright white. */
|
|
135
|
-
bgWhiteBright: (input: string | TemplateStringsArray) => string;
|
|
136
|
-
/**
|
|
137
|
-
* Make some text or its background one of 256 colours.
|
|
138
|
-
* If `color` is bigger than 255 or smaller than 0, it automatically rounds to 255 or 0 respectively.
|
|
139
|
-
*
|
|
140
|
-
* @param type Whether the styling should be applied to the text itself or the background.
|
|
141
|
-
* @param color A number between 0 and 255 that specifies the colour.
|
|
142
|
-
* @param content The string that should be styled.
|
|
143
|
-
* @returns If terminal colours are enabled and [8-bit colours](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) are supported, the stylized text. If either is false, it returns the plain string.
|
|
144
|
-
* @see https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
|
145
|
-
*/
|
|
146
|
-
ansi256(type: ANSIStyleType, color: number): (input: string | TemplateStringsArray) => string;
|
|
147
|
-
/**
|
|
148
|
-
* Make some text or its background using custom RGB values.
|
|
149
|
-
*
|
|
150
|
-
* @param type Whether to apply the colour to the text itself or its background.
|
|
151
|
-
* @param rgb A list of `red`, `green`, and `blue` values.
|
|
152
|
-
* @returns A function to specify an input, which returns the stylized text, assuming colours are enabled, *and* `truecolor` is enabled as well.
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* ```typescript
|
|
156
|
-
* import termark from 'termark';
|
|
157
|
-
*
|
|
158
|
-
* termark.rgb('background', 128, 84, 249)('...');
|
|
159
|
-
* termark.rgb('text', [85, 222, 124])('...');
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
rgb(type: ANSIStyleType, ...rgb: RGB | [RGB]): (input: string | TemplateStringsArray) => string;
|
|
163
|
-
/**
|
|
164
|
-
* Apply a gradient to some text or its background.
|
|
165
|
-
*
|
|
166
|
-
* @param type Whether to apply the gradient to the text itself or its background.
|
|
167
|
-
* @param colors An array of RGB values
|
|
168
|
-
* @returns A function to specify an input, which returns the stylized input, assuming colours are enabled, *and* `truecolor` is enabled as well.
|
|
169
|
-
* @see https://htmlcolorcodes.com/ For colour conversions.
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```typescript
|
|
173
|
-
* import termark from 'termark';
|
|
174
|
-
*
|
|
175
|
-
* termark.gradient('text', [[53, 72, 172], [200, 230, 121]])('...');
|
|
176
|
-
* termark.gradient('background', [[222, 111, 0], [93, 255, 68], [0, 224, 110]])('...');
|
|
177
|
-
* ```
|
|
178
|
-
*/
|
|
179
|
-
gradient(type: ANSIStyleType, colors: RGB[]): (input: string | TemplateStringsArray) => string;
|
|
180
|
-
/**
|
|
181
|
-
* Logs a `message` to the console on the `info` level.
|
|
182
|
-
*
|
|
183
|
-
* **Note:** Since there is no dedicated '`success`' method, we have to print to the same level
|
|
184
|
-
* as `info()`.
|
|
185
|
-
*
|
|
186
|
-
* @param message The message to be logged in green as a success (info).
|
|
187
|
-
* @param prefix An optional brand prefix.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* import termark from 'termark';
|
|
192
|
-
*
|
|
193
|
-
* termark.success('...'); // Logs "..." in green as a success (info).
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
success(message: string, prefix?: string): void;
|
|
197
|
-
/**
|
|
198
|
-
* Logs a `message` to the console on the `info` level.
|
|
199
|
-
*
|
|
200
|
-
* @param message The message to be logged in blue as an info.
|
|
201
|
-
* @param prefix An optional brand prefix.
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* ```typescript
|
|
205
|
-
* import termark from 'termark';
|
|
206
|
-
*
|
|
207
|
-
* termark.info('...'); // Logs "..." in blue as an info.
|
|
208
|
-
* ```
|
|
209
|
-
*/
|
|
210
|
-
info(message: string, prefix?: string): void;
|
|
211
|
-
/**
|
|
212
|
-
* Logs a `message` to the console on the `error` level.
|
|
213
|
-
*
|
|
214
|
-
* **Note:** In Node, `console.warn` and `console.error` print to the *same* level (`error`),
|
|
215
|
-
* and are therefore interchangeable. As such, this method only exists to provide a different look
|
|
216
|
-
* for an error message (e.g., for non-fatal errors).
|
|
217
|
-
*
|
|
218
|
-
* @param message The message to be logged in yellow as a warning (error).
|
|
219
|
-
* @param prefix An optional brand prefix.
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* ```typescript
|
|
223
|
-
* import termark from 'termark';
|
|
224
|
-
*
|
|
225
|
-
* termark.warn('...'); // Logs "..." in yellow as a warning (error).
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
warn(message: string, prefix?: string): void;
|
|
229
|
-
/**
|
|
230
|
-
* Logs a `message` to the console on the `error` level.
|
|
231
|
-
*
|
|
232
|
-
* @param message The message to be logged in red as an error.
|
|
233
|
-
* @param prefix An optional brand prefix.
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* ```typescript
|
|
237
|
-
* import termark from 'termark';
|
|
238
|
-
*
|
|
239
|
-
* termark.error('...'); // Logs "..." in red as an error.
|
|
240
|
-
* ```
|
|
241
|
-
*/
|
|
242
|
-
error(message: string, prefix?: string): void;
|
|
243
|
-
/**
|
|
244
|
-
* Style some text using entirely custom settings.
|
|
245
|
-
*
|
|
246
|
-
* Please not that this method will not return any errors by itself.
|
|
247
|
-
* As such, it's advised that you're familiar with [the ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code) if you plan to use this method.
|
|
248
|
-
* However, this method will still return the plain text if the styling you want to apply doesn't exist.
|
|
249
|
-
*
|
|
250
|
-
* Also note that you **mustn't include the actual escape sequence (e.g., `\x1b[`), nor the symbol at the end of the code (e.g., `m`)**, only the parameters themselves.
|
|
251
|
-
*
|
|
252
|
-
* @param opener The code that should be prepended to the text. This is for styling your input itself.
|
|
253
|
-
* @param closer The code that should be appended to the text. This is for styling what comes after your input. It's best if this is either `0`, or the code to set the default style of something (e.g., `39` to reset to the default text colour).
|
|
254
|
-
* @param type Whether the formatting should be viewed as applying colour, or performing simple styling.If it is the former, styling won't be applied if terminal colours are disabled.
|
|
255
|
-
* @returns The text stylized using `opener`.
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* ```typescript
|
|
259
|
-
* import termark from 'termark';
|
|
260
|
-
*
|
|
261
|
-
* termark.custom('58;2;33', 59)('...'); // This should result in a string with a blue underline.
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
custom(opener: string | number, closer: string | number, type: 'asColor' | 'asFormat'): (input: string | TemplateStringsArray) => string;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* The `termark` object enables accessing all features of Termark:
|
|
268
|
-
*
|
|
269
|
-
* - Properties (retrieve information)
|
|
270
|
-
* - Methods (commands)
|
|
271
|
-
*
|
|
272
|
-
* For info regarding ANSI styling:
|
|
273
|
-
* @see https://en.wikipedia.org/wiki/ANSI_escape_code
|
|
274
|
-
*
|
|
275
|
-
* ---
|
|
276
|
-
*
|
|
277
|
-
* With properties, you're able to use features of Termark that don't execute
|
|
278
|
-
* any command per se, but simply to retrieve information; you don't perform
|
|
279
|
-
* any operation with these.
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
* ```typescript
|
|
283
|
-
* import termark from 'termark';
|
|
284
|
-
*
|
|
285
|
-
* // All properties provided by Termark:
|
|
286
|
-
*
|
|
287
|
-
* termark.areColorsEnabled; // Check whether colours are enabled
|
|
288
|
-
* termark.is8bitEnabled; // Check whether 8-bit (256) colours are enabled
|
|
289
|
-
* termark.is24bitEnabled; // Check whether 24-bit (truecolor) colours are enabled
|
|
290
|
-
* ```
|
|
291
|
-
*
|
|
292
|
-
* In addition, properties on the `Termark` class are static-ish, i.e., they only do one thing, and you have no input on it.
|
|
293
|
-
*
|
|
294
|
-
* ---
|
|
295
|
-
*
|
|
296
|
-
* With methods on the other hand, you *do* perform commands and operations.
|
|
297
|
-
* Methods are dynamic, meaning that you *do* specify how they work.
|
|
298
|
-
*
|
|
299
|
-
* @example
|
|
300
|
-
* ```typescript
|
|
301
|
-
* import termark from 'termark';
|
|
302
|
-
*
|
|
303
|
-
* termark.red('...'); // Returns "..." in red.
|
|
304
|
-
* termark.rgb('background', [255, 255, 255])('...'); // Returns "..." with a white background.
|
|
305
|
-
* ```
|
|
306
|
-
*
|
|
307
|
-
* With all methods, you **must** append either `('...')` or ``` `...` ```, and replace "`...`"
|
|
308
|
-
* with a string of your choosing. This is made possible by the fact that most of (see below) Termark's
|
|
309
|
-
* methods return a function where you specify your input.
|
|
310
|
-
*
|
|
311
|
-
* @example
|
|
312
|
-
* ```typescript
|
|
313
|
-
* import termark from 'termark';
|
|
314
|
-
*
|
|
315
|
-
* termark.ansi256('text', 33)('This is blue text');
|
|
316
|
-
* termark.ansi256('text', 33)`This is also blue text`;
|
|
317
|
-
* ```
|
|
318
|
-
*
|
|
319
|
-
* ### Exceptions
|
|
320
|
-
*
|
|
321
|
-
* There are some exceptions to the above, however; not *all* of Termark's methods return
|
|
322
|
-
* a function to specify your input. These ones are:
|
|
323
|
-
*
|
|
324
|
-
* ```typescript
|
|
325
|
-
* import termark from 'termark';
|
|
326
|
-
*
|
|
327
|
-
* termark.success('...');
|
|
328
|
-
* termark.info('...');
|
|
329
|
-
* termark.warn('...');
|
|
330
|
-
* termark.error('...');
|
|
331
|
-
* ```
|
|
332
|
-
*
|
|
333
|
-
* This is because the above three methods handle console outputs for you. Therefore, they needn't
|
|
334
|
-
* return a function where you specify your input.
|
|
335
|
-
*/
|
|
336
|
-
declare const termark: Termark;
|
|
337
|
-
export default termark;
|
|
338
|
-
export declare const areColorsEnabled: boolean, is8bitEnabled: boolean, is24bitEnabled: boolean, reset: (input: string | TemplateStringsArray) => string, bold: (input: string | TemplateStringsArray) => string, dim: (input: string | TemplateStringsArray) => string, italic: (input: string | TemplateStringsArray) => string, underline: (input: string | TemplateStringsArray) => string, blink: (input: string | TemplateStringsArray) => string, inverse: (input: string | TemplateStringsArray) => string, overline: (input: string | TemplateStringsArray) => string, hidden: (input: string | TemplateStringsArray) => string, strike: (input: string | TemplateStringsArray) => string, black: (input: string | TemplateStringsArray) => string, red: (input: string | TemplateStringsArray) => string, green: (input: string | TemplateStringsArray) => string, yellow: (input: string | TemplateStringsArray) => string, blue: (input: string | TemplateStringsArray) => string, magenta: (input: string | TemplateStringsArray) => string, cyan: (input: string | TemplateStringsArray) => string, white: (input: string | TemplateStringsArray) => string, blackBright: (input: string | TemplateStringsArray) => string, redBright: (input: string | TemplateStringsArray) => string, greenBright: (input: string | TemplateStringsArray) => string, yellowBright: (input: string | TemplateStringsArray) => string, blueBright: (input: string | TemplateStringsArray) => string, magentaBright: (input: string | TemplateStringsArray) => string, cyanBright: (input: string | TemplateStringsArray) => string, whiteBright: (input: string | TemplateStringsArray) => string, bgBlack: (input: string | TemplateStringsArray) => string, bgRed: (input: string | TemplateStringsArray) => string, bgGreen: (input: string | TemplateStringsArray) => string, bgYellow: (input: string | TemplateStringsArray) => string, bgBlue: (input: string | TemplateStringsArray) => string, bgMagenta: (input: string | TemplateStringsArray) => string, bgCyan: (input: string | TemplateStringsArray) => string, bgWhite: (input: string | TemplateStringsArray) => string, bgBlackBright: (input: string | TemplateStringsArray) => string, bgRedBright: (input: string | TemplateStringsArray) => string, bgGreenBright: (input: string | TemplateStringsArray) => string, bgYellowBright: (input: string | TemplateStringsArray) => string, bgBlueBright: (input: string | TemplateStringsArray) => string, bgMagentaBright: (input: string | TemplateStringsArray) => string, bgCyanBright: (input: string | TemplateStringsArray) => string, bgWhiteBright: (input: string | TemplateStringsArray) => string, ansi256: (type: ANSIStyleType, color: number) => (input: string | TemplateStringsArray) => string, rgb: (type: ANSIStyleType, ...rgb: RGB | [RGB]) => (input: string | TemplateStringsArray) => string, gradient: (type: ANSIStyleType, colors: RGB[]) => (input: string | TemplateStringsArray) => string, success: (message: string, prefix?: string) => void, info: (message: string, prefix?: string) => void, warn: (message: string, prefix?: string) => void, error: (message: string, prefix?: string) => void, custom: (opener: string | number, closer: string | number, type: "asColor" | "asFormat") => (input: string | TemplateStringsArray) => string;
|
package/dist/util.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
export type ANSIStyleType = 'text' | 'background';
|
|
2
|
-
export type RGB = [number, number, number];
|
|
3
|
-
/**
|
|
4
|
-
* Check whether terminal colours are supported/enabled.
|
|
5
|
-
*
|
|
6
|
-
* @returns If the `NO_COLOR` environment variable is undefined, true. If it has any value, it returns false, as per the [specifications](https://no-color.org/).
|
|
7
|
-
*/
|
|
8
|
-
export declare const areColoursEnabled: () => boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Check whether a colour level is supported.
|
|
11
|
-
*
|
|
12
|
-
* @returns A property that is used to check the colour level support.
|
|
13
|
-
*/
|
|
14
|
-
export declare const getColourSupport: () => {
|
|
15
|
-
is16bit: boolean;
|
|
16
|
-
is256: boolean;
|
|
17
|
-
isTrueColor: boolean;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Format some text using ANSI codes.
|
|
21
|
-
*
|
|
22
|
-
* @param open The code prepended to the text. This is used to style the text itself.
|
|
23
|
-
* @param close The code appended to the text. This is used to style what comes immediately after the text, and should ideally be a reset code.
|
|
24
|
-
* @param type Whether the styling applies basic formatting, or colours the text.
|
|
25
|
-
* @returns If terminal colours are enabled and `type` is set to `'color'`, some coloured text. If `type` is set to `'format'`, the formatted text.
|
|
26
|
-
*/
|
|
27
|
-
export declare function format(open: number | string, close: number | string, type: 'format' | 'color'): (input: string | TemplateStringsArray) => string;
|
|
28
|
-
/**
|
|
29
|
-
* Calculate an intermediate colour between two colours.
|
|
30
|
-
*
|
|
31
|
-
* This is done as follows:
|
|
32
|
-
* We have two colours: `C1 = (R1,G1,B1)`, and `C2 = (R2,G2,B2)`, and we need to generate a gradient over a string of length `L`.
|
|
33
|
-
* For each character at index `i` (from 0 to `L-1`), we need to find an interpolated colour `Ci`.
|
|
34
|
-
*
|
|
35
|
-
* For that, we can do the following:
|
|
36
|
-
* ```txt
|
|
37
|
-
* t = i/(L-1)
|
|
38
|
-
*
|
|
39
|
-
* Ri = R1 + t * (R2 - R1)
|
|
40
|
-
* Gi = G1 + t * (G2 - G1)
|
|
41
|
-
* Bi = B1 + t * (B2 - B1)
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* We then apply `Ci` to each character `i` to get our (mostly) smooth gradient.
|
|
45
|
-
*
|
|
46
|
-
* @param color1 The starting colour.
|
|
47
|
-
* @param color2 The ending colour.
|
|
48
|
-
* @param factor How to calculate the colour.
|
|
49
|
-
* @returns An RGB value that is the colour between `color1` and `color2` at `factor`.
|
|
50
|
-
*/
|
|
51
|
-
export declare function interpolate(color1: RGB, color2: RGB, factor: number): RGB;
|