@travetto/terminal 6.0.0 → 7.0.0-rc.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/style.ts +9 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/terminal",
3
- "version": "6.0.0",
3
+ "version": "7.0.0-rc.0",
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",
28
- "chalk": "^5.4.1"
27
+ "@travetto/runtime": "^7.0.0-rc.0",
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
  }