@travetto/terminal 6.0.0-rc.2 → 6.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/README.md CHANGED
@@ -23,6 +23,7 @@ Oddly enough, colorizing output in a terminal is a fairly complex process. The
23
23
  * 1 - Basic color support, 16 colors
24
24
  * 2 - Enhanced color support, 225 colors, providing a fair representation of most colors
25
25
  * 3 - True color, 24bit color with R, G, B each getting 8-bits. Can represent any color needed
26
+
26
27
  This module provides the ability to define color palettes using RGB colors, and additionally provides support for palettes based on a dark or light background for a given terminal. Support for this is widespread, but when it fails, it will gracefully assume a dark background.
27
28
 
28
29
  These palettes then are usable at runtime, with the module determining light or dark palettes, as well as falling back to the closest color value based on what the existing terminal supports. This means a color like 'olivegreen', will get the proper output in 24bit color support, a close approximation in enhanced color support, fall back to green in basic color support, and will be color less at level 0.
@@ -74,6 +75,7 @@ Within the [Travetto](https://travetto.dev) framework, there are plenty of comma
74
75
  * Progress Bars
75
76
  * Waiting Indicators
76
77
  * Streaming Content
78
+
77
79
  This is generally meant for use within the framework, and so is highly tailored to the specific needs and scenarios. You can see this pattern play out in the [Compiler](https://github.com/travetto/travetto/tree/main/module/compiler#readme "The compiler infrastructure for the Travetto framework") progress output, or in [Pack](https://github.com/travetto/travetto/tree/main/module/pack#readme "Code packing utilities")'s output.
78
80
 
79
81
  In these scenarios, the dynamic behaviors are dependent on having an interactive TTY. When running without access to a proper stdin, the output will default to basic line printing. This dynamic behavior can also be disabled using the environment variable `TRV_QUIET`. When set to `1` will provide a minimal text-based experience.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/terminal",
3
- "version": "6.0.0-rc.2",
3
+ "version": "6.0.1",
4
4
  "description": "General terminal support",
5
5
  "keywords": [
6
6
  "terminal",
@@ -24,8 +24,8 @@
24
24
  "directory": "module/terminal"
25
25
  },
26
26
  "dependencies": {
27
- "@travetto/runtime": "^6.0.0-rc.2",
28
- "chalk": "^5.4.1"
27
+ "@travetto/runtime": "^6.0.1",
28
+ "chalk": "^5.6.2"
29
29
  },
30
30
  "travetto": {
31
31
  "displayName": "Terminal"
package/src/style.ts CHANGED
@@ -10,13 +10,13 @@ export type TermStyleFn = (input: TemplatePrim) => string;
10
10
  type TermStyledTemplate<T extends string> = (values: TemplateStringsArray, ...keys: (Partial<Record<T, TemplatePrim>> | string)[]) => string;
11
11
  export type ColorLevel = 0 | 1 | 2 | 3;
12
12
 
13
- export class StyleUtil {
13
+ const DARK_ANSI_256 = new Set([
14
+ 0, 1, 2, 3, 4, 5, 6, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 52, 53, 54,
15
+ 55, 56, 58, 59, 60, 64, 65, 66, 70, 76, 88, 89, 90, 91, 92, 94, 95, 96, 100, 101, 106, 112, 124, 125, 126, 127, 128, 130, 136, 142,
16
+ 148, 160, 161, 162, 163, 164, 166, 172, 178, 184, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243
17
+ ]);
14
18
 
15
- static #darkAnsi256 = new Set([
16
- 0, 1, 2, 3, 4, 5, 6, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 52, 53, 54,
17
- 55, 56, 58, 59, 60, 64, 65, 66, 70, 76, 88, 89, 90, 91, 92, 94, 95, 96, 100, 101, 106, 112, 124, 125, 126, 127, 128, 130, 136, 142,
18
- 148, 160, 161, 162, 163, 164, 166, 172, 178, 184, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243
19
- ]);
19
+ export class StyleUtil {
20
20
 
21
21
  static #scheme: { key: string, dark: boolean } = { key: '', dark: true };
22
22
 
@@ -27,7 +27,7 @@ export class StyleUtil {
27
27
  if (typeof input === 'string') {
28
28
  return chalk.hex(input);
29
29
  } else {
30
- let style: chalk.Chalk = chalk;
30
+ let style = chalk;
31
31
  for (const key of TypedObject.keys(input)) {
32
32
  switch (key) {
33
33
  case 'text': style = style.hex(input[key]!); break;
@@ -50,7 +50,7 @@ export class StyleUtil {
50
50
  }
51
51
 
52
52
  const [, bg = '0'] = key.split(';');
53
- const dark = this.#darkAnsi256.has(+bg);
53
+ const dark = DARK_ANSI_256.has(+bg);
54
54
  Object.assign(this.#scheme, { key, dark });
55
55
  return dark;
56
56
  }
@@ -103,7 +103,7 @@ export class StyleUtil {
103
103
  return `${values[i] ?? ''}${final ?? ''}`;
104
104
  });
105
105
  if (values.length > keys.length) {
106
- out.push(values[values.length - 1]);
106
+ out.push(values.at(-1)!);
107
107
  }
108
108
  return out.join('');
109
109
  }