supports-color 9.2.3 → 9.3.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/browser.js CHANGED
@@ -1,15 +1,26 @@
1
1
  /* eslint-env browser */
2
2
 
3
- const isBlinkBasedBrowser = navigator.userAgentData
4
- ? navigator.userAgentData.brands.some(({brand}) => brand === 'Chromium')
5
- : /\b(Chrome|Chromium)\//.test(navigator.userAgent);
3
+ const level = (() => {
4
+ if (navigator.userAgentData) {
5
+ const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
6
+ if (brand?.version > 93) {
7
+ return 3;
8
+ }
9
+ }
6
10
 
7
- const colorSupport = isBlinkBasedBrowser ? {
8
- level: 1,
11
+ if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
12
+ return 1;
13
+ }
14
+
15
+ return 0;
16
+ })();
17
+
18
+ const colorSupport = level !== 0 && {
19
+ level,
9
20
  hasBasic: true,
10
- has256: false,
11
- has16m: false,
12
- } : false;
21
+ has256: level >= 2,
22
+ has16m: level >= 3,
23
+ };
13
24
 
14
25
  const supportsColor = {
15
26
  stdout: colorSupport,
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {WriteStream} from 'node:tty';
1
+ import type {WriteStream} from 'node:tty';
2
2
 
3
3
  export interface Options {
4
4
  /**
package/index.js CHANGED
@@ -3,7 +3,8 @@ import os from 'node:os';
3
3
  import tty from 'node:tty';
4
4
 
5
5
  // From: https://github.com/sindresorhus/has-flag/blob/main/index.js
6
- function hasFlag(flag, argv = process.argv) {
6
+ /// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
7
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
7
8
  const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
8
9
  const position = argv.indexOf(prefix + flag);
9
10
  const terminatorPosition = argv.indexOf('--');
@@ -80,6 +81,12 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
80
81
  }
81
82
  }
82
83
 
84
+ // Check for Azure DevOps pipelines.
85
+ // Has to be above the `!streamIsTTY` check.
86
+ if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
87
+ return 1;
88
+ }
89
+
83
90
  if (haveStream && !streamIsTTY && forceColor === undefined) {
84
91
  return 0;
85
92
  }
@@ -105,7 +112,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
105
112
  }
106
113
 
107
114
  if ('CI' in env) {
108
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
115
+ if ('GITHUB_ACTIONS' in env) {
116
+ return 3;
117
+ }
118
+
119
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
109
120
  return 1;
110
121
  }
111
122
 
@@ -116,12 +127,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
116
127
  return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
117
128
  }
118
129
 
119
- // Check for Azure DevOps pipelines
120
- if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
121
- return 1;
130
+ if (env.COLORTERM === 'truecolor') {
131
+ return 3;
122
132
  }
123
133
 
124
- if (env.COLORTERM === 'truecolor') {
134
+ if (env.TERM === 'xterm-kitty') {
125
135
  return 3;
126
136
  }
127
137
 
@@ -129,10 +139,13 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
129
139
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
130
140
 
131
141
  switch (env.TERM_PROGRAM) {
132
- case 'iTerm.app':
142
+ case 'iTerm.app': {
133
143
  return version >= 3 ? 3 : 2;
134
- case 'Apple_Terminal':
144
+ }
145
+
146
+ case 'Apple_Terminal': {
135
147
  return 2;
148
+ }
136
149
  // No default
137
150
  }
138
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supports-color",
3
- "version": "9.2.3",
3
+ "version": "9.3.1",
4
4
  "description": "Detect whether a terminal supports color",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/supports-color",
@@ -56,6 +56,6 @@
56
56
  "import-fresh": "^3.3.0",
57
57
  "tsd": "^0.18.0",
58
58
  "typescript": "^4.4.3",
59
- "xo": "^0.44.0"
59
+ "xo": "^0.49.0"
60
60
  }
61
61
  }