termark 2.1.0 → 3.0.1
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 +192 -313
- package/dist/index.cjs +5 -1
- package/dist/index.d.cts +492 -0
- package/dist/index.d.mts +492 -0
- package/dist/index.mjs +5 -1
- package/package.json +32 -21
- package/dist/index.d.ts +0 -383
- package/dist/util.d.ts +0 -157
package/README.md
CHANGED
|
@@ -1,313 +1,192 @@
|
|
|
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
|
-
##
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
import
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
import
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
termark
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
termark
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
import termark from 'termark';
|
|
194
|
-
|
|
195
|
-
// Instead of using this:
|
|
196
|
-
termark.blue('...');
|
|
197
|
-
|
|
198
|
-
// ...you can use this:
|
|
199
|
-
termark.blue`...`;
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Nested styles
|
|
203
|
-
|
|
204
|
-
```ts
|
|
205
|
-
import termark from 'termark';
|
|
206
|
-
|
|
207
|
-
termark.blue(
|
|
208
|
-
'This is some blue text ' +
|
|
209
|
-
termark.yellow('That becomes yellow,') +
|
|
210
|
-
' that becomes blue again.'
|
|
211
|
-
);
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Colour-detection utilities
|
|
215
|
-
|
|
216
|
-
```ts
|
|
217
|
-
import termark from 'termark';
|
|
218
|
-
|
|
219
|
-
termark.areColorsEnabled; // Check whether terminal colours are enabled.
|
|
220
|
-
termark.is8bitEnabled; // Check whether 8-bit (256) colours are enabled.
|
|
221
|
-
termark.is24bitEnabled; // Check whether 24-bit (truecolor) colours are enabled.
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Class v. Object
|
|
225
|
-
|
|
226
|
-
You can use Termark by importing the object, or you can import the class:
|
|
227
|
-
|
|
228
|
-
```ts
|
|
229
|
-
import { Termark } from 'termark';
|
|
230
|
-
|
|
231
|
-
const termark = new Termark(); // This is the same as importing the `termark` object.
|
|
232
|
-
termark.success('Termark is working!');
|
|
233
|
-
|
|
234
|
-
// Alternatively, you could do this:
|
|
235
|
-
Termark.init.success('This work, too!');
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
`Termark.init` enables using the `Termark` class as the default `termark` object.
|
|
239
|
-
|
|
240
|
-
### Custom themes and loggers
|
|
241
|
-
|
|
242
|
-
You can create custom themes (a collection of multiple styles) and loggers:
|
|
243
|
-
|
|
244
|
-
```ts
|
|
245
|
-
import termark, { Termark } from 'termark';
|
|
246
|
-
|
|
247
|
-
const myTheme = Termark.createTheme(
|
|
248
|
-
termark.blue, // <- Notice that we specify a built-in function *without calling it*!
|
|
249
|
-
termark.bold // Same goes for this one.
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
console.log(
|
|
253
|
-
myTheme('This text is bold and blue!')
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
// ------
|
|
257
|
-
|
|
258
|
-
// All properties but `default` are completely optional.
|
|
259
|
-
// If omitted, default ones are used
|
|
260
|
-
const myLogger = Termark.createLogger({
|
|
261
|
-
default: [
|
|
262
|
-
termark.cyan,
|
|
263
|
-
termark.italic
|
|
264
|
-
],
|
|
265
|
-
success: {
|
|
266
|
-
prefix: false, // Disable built-in prefix
|
|
267
|
-
styles: [
|
|
268
|
-
termark.greenBright,
|
|
269
|
-
termark.bold
|
|
270
|
-
]
|
|
271
|
-
},
|
|
272
|
-
info: {
|
|
273
|
-
prefix: 'Info' // Custom prefix to override the default
|
|
274
|
-
// No custom styles--use default ones.
|
|
275
|
-
},
|
|
276
|
-
// leave `warn` as-is
|
|
277
|
-
error: {
|
|
278
|
-
// Use default prefix; omitting or setting to an empty string have the same result.
|
|
279
|
-
styles: [
|
|
280
|
-
termark.bgRedBright,
|
|
281
|
-
termark.dim
|
|
282
|
-
]
|
|
283
|
-
},
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
myLogger.log('...'); // Uses the `default` property's options.
|
|
287
|
-
myLogger.success('...'); // Omitted prefix, uses custom styles.
|
|
288
|
-
myLogger.info('...'); // Uses custom prefix, default styles.
|
|
289
|
-
myLogger.warn('...'); // Left as-is.
|
|
290
|
-
myLogger.error('...'); // Uses default prefix, with custom styles.
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
## Licence
|
|
294
|
-
|
|
295
|
-
Termark's code is licenced under the [Apache licence version 2](https://www.apache.org/licenses/LICENSE-2.0).
|
|
296
|
-
The full licence text is present in these source files.
|
|
297
|
-
In addition, this snippet of text is present at the top of all files:
|
|
298
|
-
|
|
299
|
-
```txt
|
|
300
|
-
Copyright 2025 Q
|
|
301
|
-
|
|
302
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
303
|
-
you may not use this file except in compliance with the License.
|
|
304
|
-
You may obtain a copy of the License at
|
|
305
|
-
|
|
306
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
307
|
-
|
|
308
|
-
Unless required by applicable law or agreed to in writing, software
|
|
309
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
310
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
311
|
-
See the License for the specific language governing permissions and
|
|
312
|
-
limitations under the License.
|
|
313
|
-
```
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img alt="Termark" src="logo.webp" title="Termark logo" />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
Termark is a basic library to format console output to the standard non-browser terminal.
|
|
6
|
+
|
|
7
|
+
<!-- TOC -->
|
|
8
|
+
|
|
9
|
+
- [Features](#features)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [ESM & CJS compatibility](#esm--cjs-compatibility)
|
|
13
|
+
- [Basic usage](#basic-usage)
|
|
14
|
+
- [Licence](#licence)
|
|
15
|
+
<!-- TOC -->
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Familiar syntax** (`fmt.bold.brightRed.bgBlue("...")`)
|
|
20
|
+
- **ESM & CJS compatibility**
|
|
21
|
+
- [**NO_COLOR**](https://no-color.org/)-friendly
|
|
22
|
+
- [**FORCE_COLOR**](https://force-color.org/)-friendly
|
|
23
|
+
- **`truecolor` support** including gradients
|
|
24
|
+
- **Automatic colour-support detection** with **step-wise fallback** (truecolor → 8-bit → 4-bit → plain text)
|
|
25
|
+
- **Extensible** via `extend`; includes built-in support for `css-color-names` via `fromColObject`
|
|
26
|
+
- **Runtime-agnostic** (currently supported: Node, Bun, Deno)
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
|
|
32
|
+
Termark can be installed via any package manager that can interact with the NPM registry:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# NPM
|
|
36
|
+
npm i termark
|
|
37
|
+
|
|
38
|
+
# PNPM
|
|
39
|
+
pnpm add termark
|
|
40
|
+
|
|
41
|
+
# Deno
|
|
42
|
+
deno add npm:termark
|
|
43
|
+
|
|
44
|
+
# Bun
|
|
45
|
+
bun add termark
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### ESM & CJS compatibility
|
|
49
|
+
|
|
50
|
+
Termark is compatible with ECMAScript modules (`import`/`export` syntax) and CommonJS:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
// CJS:
|
|
54
|
+
const { fmt } = require("termark");
|
|
55
|
+
|
|
56
|
+
// ESM:
|
|
57
|
+
import { fmt } from "termark";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Basic usage
|
|
61
|
+
|
|
62
|
+
All exports of Termark are named exports, with the primary tool being `fmt` ("format"):
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { fmt } from "termark";
|
|
66
|
+
|
|
67
|
+
// Basic chaining syntax
|
|
68
|
+
console.log(fmt.blue.bold("Text"));
|
|
69
|
+
|
|
70
|
+
// Nesting style
|
|
71
|
+
console.log(fmt.bold.red(`Error: This ${fmt.brightCyan("file")} is corrupted!`));
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Advanced colouring
|
|
75
|
+
|
|
76
|
+
Termark features methods like `hex` and `rgb` as well as the powerful `gradient` for advanced, versatile colouring.
|
|
77
|
+
All of these methods feature `bg*` variants, e.g. `bgHex`, which apply colour to the background of the text rather
|
|
78
|
+
than the text itself.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { fmt } from "termark";
|
|
82
|
+
|
|
83
|
+
// Hex and RGB colour-mapping
|
|
84
|
+
console.log(fmt.hex("#80b3ff").text("Light blue text"));
|
|
85
|
+
console.log(fmt.rgb([0, 255, 128]).text("Light green text"));
|
|
86
|
+
|
|
87
|
+
// Gradients (supports hex string/RGB tuple arrays)
|
|
88
|
+
const sunset = ["#ff5e62", "#f96"];
|
|
89
|
+
console.log(fmt.gradient(sunset).text("Beautiful terminal gradient"));
|
|
90
|
+
|
|
91
|
+
// Background variants (`bgHex`, `bgRgb`, `bgGradient`)
|
|
92
|
+
console.log(fmt.bgHex("#222").white("..."));
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Termark also features the ability to use singular 8-bit colour codes to style outputs with `fg` and `bg`.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { fmt } from "termark";
|
|
99
|
+
|
|
100
|
+
console.log(fmt.fg(57).text("..."));
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Note:** The `.text()` method is designed for `hex`, `rgb`, `gradient` and `fg` (and their `bg*` counterparts) when
|
|
104
|
+
they are the last in the chain or when no other styling is needed. However, technically _all_ styling chains can be
|
|
105
|
+
terminated by `.text()`, e.g. `fmt.bold.red.text("...")`. `.text()` exists to eliminate the need to write
|
|
106
|
+
`hex("#338cd1")("Coloured text")`, which is still an option, but it's not elegant.
|
|
107
|
+
|
|
108
|
+
### Layout utilities
|
|
109
|
+
|
|
110
|
+
#### `box`
|
|
111
|
+
|
|
112
|
+
Termark features a powerful `box` method which lets you encase your text in a, well, box.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { fmt, box } from "termark";
|
|
116
|
+
|
|
117
|
+
const myBox = box(fmt.bold.brightGreen("Deployment successful!"), {
|
|
118
|
+
kind: "rounded",
|
|
119
|
+
padding: 2, // Vertical padding only increases every four units by default.
|
|
120
|
+
margin: 3, // Vertical margin only increases every four units by default.
|
|
121
|
+
style: fmt.hex("#ffa500"), // Orange border
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
console.log(myBox);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Note:** `margin` and `padding` also accept objects to customize top, bottom, left, and right margin/padding.
|
|
128
|
+
|
|
129
|
+
### Extensibility
|
|
130
|
+
|
|
131
|
+
**Note:** All extensions of Termark must be called as the last one in a given chain, and a string must be passed.
|
|
132
|
+
|
|
133
|
+
#### via `extend`
|
|
134
|
+
|
|
135
|
+
With the `extend` function, any kind of method can be created as an extension of Termark, such as shortcuts to styles.
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { extend } from "termark";
|
|
139
|
+
|
|
140
|
+
const myLib = extend((base) => ({
|
|
141
|
+
// Formatting extensions
|
|
142
|
+
shout: (str) => base.red.bold(str.toUpperCase()),
|
|
143
|
+
// Colouring extensions
|
|
144
|
+
orange: (str) => base.hex("#ffa500").text(str),
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
console.log(myLib.shout("This text is bold in red and all-caps"));
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Transformations apply to nested styles, too; for `shout` above, all nested text will be upper-case.
|
|
151
|
+
|
|
152
|
+
#### via `fromColObject`
|
|
153
|
+
|
|
154
|
+
The `fromColObject` function enables mapping mass colour dictionaries into styling methods. Excellent for packages
|
|
155
|
+
like [`css-color-names`](https://github.com/bahamas10/css-color-names) or
|
|
156
|
+
[`color-names`](https://github.com/meodai/color-names) (the latter with some additional work).
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
import { fromColObject } from "termark";
|
|
160
|
+
import cssColours from "css-color-names";
|
|
161
|
+
|
|
162
|
+
const extendedWithCss = fromColObject(cssColours);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
By default, background styling methods aren't created. To do that, simply pass `true` for the second parameter.
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import { fromColObject } from "termark";
|
|
169
|
+
import cssColours from "css-color-names";
|
|
170
|
+
|
|
171
|
+
const withBg = fromColObject(cssColours, true);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Hyperlinks
|
|
175
|
+
|
|
176
|
+
Hyperlinks are achieved by Termark with the help
|
|
177
|
+
of [OSC 8](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). Currently, it is non-standard, and may not be supported in every terminal.
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
import { fmt } from "termark";
|
|
181
|
+
|
|
182
|
+
const link = fmt.link("https://q-file.com");
|
|
183
|
+
const linkWithText = fmt.link("https://q-file.com", "Website");
|
|
184
|
+
|
|
185
|
+
const styled = fmt.hex("#a7f").link("https://q-file.com", "Website");
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`link` must be called as the last element in the chain.
|
|
189
|
+
|
|
190
|
+
## Licence
|
|
191
|
+
|
|
192
|
+
Termark's code is licenced under the [Apache licence version 2](https://www.apache.org/licenses/LICENSE-2.0).
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){if(typeof globalThis.process?.env==`object`)return globalThis.process.env[e];if(typeof globalThis.Deno?.env?.get==`function`)try{return globalThis.Deno.env.get(e)}catch{return}}function t(){if(globalThis.process?.stdout?.isTTY)return!0;if(typeof globalThis.Deno?.stdout?.isTerminal==`function`)try{return globalThis.Deno.stdout?.isTerminal()}catch{return!1}return!1}function n(){let t=e(`NO_COLOR`)||e(`NODE_DISABLE_COLORS`);return t!==void 0&&t!==``}function r(){if(n())return 0;let r=e(`FORCE_COLOR`);if(r!==void 0)return r===`0`?0:r===`1`?1:r===`2`?2:r===`3`?3:1;if(!t())return e(`CI`)&&(e(`GITHUB_ACTIONS`)||e(`GITLAB_CI`))?1:0;let i=e(`TERM`);if(i===`dumb`)return 0;let a=e(`COLORTERM`);return a===`truecolor`||a===`24bit`||e(`TERM_PROGRAM`)===`vscode`?3:i&&/-256(color)?$/i.test(i)||e(`TERM_PROGRAM`)===`Apple_Terminal`?2:(i&&/color|ansi|cygwin|linux/i.test(i),1)}const i=/^#?([a-f\d]{3}|[a-f\d]{6})$/i;function a(e,t,n){return Math.min(Math.max(e,t),n)}function o(e,t){if(e.length===1)return e[0];let n=t*(e.length-1),r=Math.min(Math.floor(n),e.length-2),i=n-r,a=e[r],o=e[r+1];return[Math.round(a[0]+(o[0]-a[0])*i),Math.round(a[1]+(o[1]-a[1])*i),Math.round(a[2]+(o[2]-a[2])*i)]}function s(e){return e.slice(0,1).toUpperCase()+e.slice(1)}function c(e){let t=i.exec(e);if(!t)return[255,255,255];let n=t[1].replace(/^#/,``),r=3^n.length?n:n.split(``).map(e=>e+e).join(``),a=parseInt(r,16);return[a>>16&255,a>>8&255,a&255]}function l([e,t,n]){return e^t||t^n?16+36*Math.round(e/51)+6*Math.round(t/51)+Math.round(n/51):e<8?16:e>248?231:Math.round((e-8)*24/247)+232}function u(e){if(e<8)return 30+e;if(e<16)return 82+e;let t,n,r;if(e<232){let i=e-16,a=i%36;t=(i/36|0)/5,n=(a/6|0)/5,r=a%6/5}else t=n=r=((e-232)*10+8)/255;let i=Math.max(t,n,r)*2,a=Math.round(t),o=Math.round(n)<<1,s=Math.round(r)<<2,c=2^i?0:60;return 30+(s|o|a)+c}function d(e){return`\x1b[${e}m`}function f(e,t,n){return e.indexOf(n)===-1?`${t}${e}${n}`:`${t}${e.replaceAll(n,n+t)}${n}`}const p={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],blink:[5,25],inverse:[7,27],overline:[53,55],hidden:[8,28],strike:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],brightBlack:[90,39],grey:[90,39],gray:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBrightBlack:[100,49],bgGrey:[100,49],bgGray:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49]};function m(e,t,n){let r=Array.from(e),i=r.length,a=t?.map(e=>typeof e==`string`?c(e):e),s=n?.map(e=>typeof e==`string`?c(e):e);return r.map((e,t)=>{let n=i>1?t/(i-1):0,r=``,c=``;if(a){let[e,t,i]=o(a,n);r+=`\x1b[38;2;${e};${t};${i}m`,c=`\x1B[39m`+c}if(s){let[e,t,i]=o(s,n);r+=`\x1b[48;2;${e};${t};${i}m`,c=`\x1B[49m`+c}return r+e+c}).join(``)}function h(e){return e.type===`fg`?_(e.code,`fg`):e.type===`bg`?_(e.code,`bg`):e.type===`hex`?y(e.hex,`fg`):e.type===`bgHex`?y(e.hex,`bg`):e.type===`rgb`?v([e.r,e.g,e.b],`fg`):e.type===`bgRgb`?v([e.r,e.g,e.b],`bg`):[``,``]}function g(e,t){let n=t.filter(e=>typeof e!=`string`&&(e.type===`gradient`||e.type===`bgGradient`)),r=n.filter(e=>e.type===`gradient`).at(-1),i=n.filter(e=>e.type===`bgGradient`).at(-1);return t.reduce((t,n)=>{let a=r||i?m(e,r?.colours,i?.colours):t;if(typeof n==`string`)return f(a,d(p[n][0]),d(p[n][1]));{let[e,t]=h(n);return f(a,e,t)}},e)}function _(e,t){if(n()||r()===0)return[``,``];let i=a(e,0,255),o=d(t===`fg`?39:49);if(r()>=2)return[d(t===`fg`?`38;5;${i}`:`48;5;${i}`),o];{let e=u(i);return[d(t===`fg`?e:e+10),o]}}function v(e,t){if(n()||r()===0)return[``,``];let i=e.map(e=>a(e,0,255)),o=d(t===`fg`?39:49);if(r()===3){let e=i.join(`;`);return[d(t===`fg`?`38;2;${e}`:`48;2;${e}`),o]}if(r()===2){let e=l(i);return[d(t===`fg`?`38;5;${e}`:`48;5;${e}`),o]}{let n=u(l(e));return[d(t===`fg`?n:n+10),o]}}function y(e,t){return i.test(e)?v(c(e),t):[``,``]}function b(e,t){let n=`\x1B]8;;`;return`${n}${e}\\${t||e}${n}\\`}function x(e,t){return new Proxy(t=>g(t,e),{get(n,r){return r in p?x([...e,r],t):r===`fg`?n=>x([...e,{type:`fg`,code:n}],t):r===`bg`?n=>x([...e,{type:`bg`,code:n}],t):r===`hex`?n=>x([...e,{type:`hex`,hex:n}],t):r===`bgHex`?n=>x([...e,{type:`bgHex`,hex:n}],t):r===`rgb`?([n,r,i])=>x([...e,{type:`rgb`,r:n,g:r,b:i}],t):r===`bgRgb`?([n,r,i])=>x([...e,{type:`bgRgb`,r:n,g:r,b:i}],t):r===`gradient`?n=>x([...e,{type:`gradient`,colours:n}],t):r===`bgGradient`?n=>x([...e,{type:`bgGradient`,colours:n}],t):r===`link`?(t,n)=>b(t,g(n??t,e)):r===`text`?t=>g(t,e):r in t?n=>g(t[r](n),e):n[r]}})}const S=x([],{});function C(){return r()!==0}function w(e){return r()>=e}function T(e){return r()<=e}function E(e){return t=>{let n=/(\u{001B}\[[0-9;]*[A-PRZ])|(.+?)/giu,r=``;for(let i of t.matchAll(n)){let t=i[0];r+=t.charCodeAt(0)===27?t:e(t)}return r}}const D=E(e=>e.toUpperCase()),O=E(e=>e.toLowerCase());function k(e){return e.replace(/\u{001B}\[[0-9;]*m/gu,``)}const A={sharp:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`─`,v:`│`},rounded:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`,h:`─`,v:`│`},double:{tl:`╔`,tr:`╗`,bl:`╚`,br:`╝`,h:`═`,v:`║`},heavy:{tl:`┏`,tr:`┓`,bl:`┗`,br:`┛`,h:`━`,v:`┃`},dashed:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`⹀`,v:`╎`},dotted:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`╌`,v:`┊`},ascii:{tl:`+`,tr:`+`,bl:`+`,br:`+`,h:`-`,v:`|`}};function j(e,t={}){let{kind:n=`sharp`,style:r=e=>e,padding:i=1,margin:a=0}=t,o=typeof n==`string`?A[n]:n,s=typeof i==`number`?Math.floor(i/4):i.top??0,c=typeof i==`number`?Math.floor(i/4):i.bottom??0,l=typeof a==`number`?Math.floor(a/4):a.top??0,u=typeof a==`number`?Math.floor(a/4):a.bottom??0,d=e.split(`
|
|
2
|
+
`),f=d.map(e=>k(e).length),p=Math.max(...f),m=o.tl+o.h.repeat(p+(typeof i==`number`?i*2:(i.left??0)+(i.right??0)))+o.tr,h=o.bl+o.h.repeat(p+(typeof i==`number`?i*2:(i.left??0)+(i.right??0)))+o.br,g=` `.repeat(typeof a==`number`?a:a.left??0),_=` `.repeat(typeof a==`number`?a:a.right??0),v=`
|
|
3
|
+
`.repeat(l),y=`
|
|
4
|
+
`.repeat(u),b=g+r(m)+_,x=g+r(h)+_,S=g+r(o.v),C=r(o.v)+_;return`${v}${b}\n${d.map(e=>{let t=k(e),n=e+` `.repeat(p-t.length),r=S+` `.repeat((typeof i==`number`?i*2:(i.left??0)+(i.right??0))+t.length)+C,a=i===0?``:`${r}\n`.repeat(s),o=i===0?``:`\n${r}`.repeat(c),l=` `.repeat(typeof i==`number`?i:i.left??0),u=` `.repeat(typeof i==`number`?i:i.right??0);return`${a}${S}${l}${n}${u}${C}${o}`}).join(`
|
|
5
|
+
`)}\n${x}${y}`}function M(e){if(Array.isArray(e)){let t={};for(let n of e)Object.assign(t,n(S));return x([],t)}return x([],e(S))}function N(e,t){let n=Object.entries(e).map(([e,t])=>[e,e=>S.hex(t).text(e)]),r=t?Object.entries(e).map(([e,t])=>[`bg${s(e)}`,e=>S.bgHex(t).text(e)]):null;return M(()=>Object.fromEntries([...n,...r??[]]))}exports.ansiLowerCase=O,exports.ansiUpperCase=D,exports.areColoursSupported=C,exports.box=j,exports.extend=M,exports.fmt=S,exports.termark=S,exports.fromColObject=N,exports.getColorLevel=r,exports.getColourLevel=r,exports.hasNoColor=n,exports.hasNoColour=n,exports.link=b,exports.stripAnsi=k,exports.supports=w,exports.supportsAtMost=T,exports.transformPreserveAnsi=E;
|