supports-hyperlinks 3.2.0 → 4.1.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/browser.js +9 -7
- package/index.d.ts +24 -5
- package/index.js +39 -32
- package/package.json +10 -12
package/browser.js
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
export function createSupportsHyperlinks() {
|
2
|
+
return false;
|
3
|
+
}
|
4
|
+
|
5
|
+
const supportsHyperlinks = {
|
6
|
+
stdout: createSupportsHyperlinks(),
|
7
|
+
stderr: createSupportsHyperlinks(),
|
8
8
|
};
|
9
|
+
|
10
|
+
export default supportsHyperlinks;
|
package/index.d.ts
CHANGED
@@ -1,6 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
}): boolean;
|
1
|
+
/**
|
2
|
+
Creates a supports hyperlinks check for a given stream.
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
@param stream - Optional stream to check for hyperlink support.
|
5
|
+
@returns boolean indicating whether hyperlinks are supported.
|
6
|
+
*/
|
7
|
+
export function createSupportsHyperlinks(stream?: {isTTY?: boolean}): boolean;
|
8
|
+
|
9
|
+
/**
|
10
|
+
Object containing hyperlink support status for stdout and stderr.
|
11
|
+
*/
|
12
|
+
type SupportsHyperlinks = {
|
13
|
+
/**
|
14
|
+
Whether stdout supports hyperlinks.
|
15
|
+
*/
|
16
|
+
stdout: boolean;
|
17
|
+
/**
|
18
|
+
Whether stderr supports hyperlinks.
|
19
|
+
*/
|
20
|
+
stderr: boolean;
|
21
|
+
};
|
22
|
+
|
23
|
+
declare const supportsHyperlinks: SupportsHyperlinks;
|
24
|
+
|
25
|
+
export default supportsHyperlinks;
|
package/index.js
CHANGED
@@ -1,38 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@param {string} versionString
|
7
|
-
@returns {{ major: number, minor: number, patch: number }}
|
8
|
-
*/
|
9
|
-
function parseVersion(versionString) {
|
1
|
+
import process from 'node:process';
|
2
|
+
import {createSupportsColor} from 'supports-color';
|
3
|
+
import hasFlag from 'has-flag';
|
4
|
+
|
5
|
+
function parseVersion(versionString = '') {
|
10
6
|
if (/^\d{3,4}$/.test(versionString)) {
|
11
7
|
// Env var doesn't always use dots. example: 4601 => 46.1.0
|
12
|
-
const
|
8
|
+
const match = /(\d{1,2})(\d{2})/.exec(versionString) ?? [];
|
13
9
|
return {
|
14
10
|
major: 0,
|
15
|
-
minor: parseInt(
|
16
|
-
patch: parseInt(
|
11
|
+
minor: Number.parseInt(match[1], 10),
|
12
|
+
patch: Number.parseInt(match[2], 10),
|
17
13
|
};
|
18
14
|
}
|
19
15
|
|
20
|
-
const versions = (versionString
|
16
|
+
const versions = (versionString ?? '').split('.').map(n => Number.parseInt(n, 10));
|
21
17
|
return {
|
22
18
|
major: versions[0],
|
23
19
|
minor: versions[1],
|
24
|
-
patch: versions[2]
|
20
|
+
patch: versions[2],
|
25
21
|
};
|
26
22
|
}
|
27
23
|
|
28
|
-
/**
|
29
|
-
@param {{ isTTY?: boolean | undefined }} stream
|
30
|
-
@returns {boolean}
|
31
|
-
*/
|
32
24
|
// eslint-disable-next-line complexity
|
33
|
-
function
|
25
|
+
export function createSupportsHyperlinks(stream) {
|
34
26
|
const {
|
35
27
|
CI,
|
28
|
+
CURSOR_TRACE_ID,
|
36
29
|
FORCE_HYPERLINK,
|
37
30
|
NETLIFY,
|
38
31
|
TEAMCITY_VERSION,
|
@@ -43,7 +36,7 @@ function supportsHyperlink(stream) {
|
|
43
36
|
} = process.env;
|
44
37
|
|
45
38
|
if (FORCE_HYPERLINK) {
|
46
|
-
return !(FORCE_HYPERLINK.length > 0 && parseInt(FORCE_HYPERLINK, 10) === 0);
|
39
|
+
return !(FORCE_HYPERLINK.length > 0 && Number.parseInt(FORCE_HYPERLINK, 10) === 0);
|
47
40
|
}
|
48
41
|
|
49
42
|
if (hasFlag('no-hyperlink') || hasFlag('no-hyperlinks') || hasFlag('hyperlink=false') || hasFlag('hyperlink=never')) {
|
@@ -60,7 +53,7 @@ function supportsHyperlink(stream) {
|
|
60
53
|
}
|
61
54
|
|
62
55
|
// If they specify no colors, they probably don't want hyperlinks.
|
63
|
-
if (!
|
56
|
+
if (!createSupportsColor(stream)) {
|
64
57
|
return false;
|
65
58
|
}
|
66
59
|
|
@@ -86,22 +79,34 @@ function supportsHyperlink(stream) {
|
|
86
79
|
}
|
87
80
|
|
88
81
|
if (TERM_PROGRAM) {
|
89
|
-
const version = parseVersion(TERM_PROGRAM_VERSION
|
82
|
+
const version = parseVersion(TERM_PROGRAM_VERSION);
|
90
83
|
|
91
84
|
switch (TERM_PROGRAM) {
|
92
|
-
case 'iTerm.app':
|
85
|
+
case 'iTerm.app': {
|
93
86
|
if (version.major === 3) {
|
94
87
|
return version.minor >= 1;
|
95
88
|
}
|
96
89
|
|
97
90
|
return version.major > 3;
|
98
|
-
|
99
|
-
|
100
|
-
case '
|
91
|
+
}
|
92
|
+
|
93
|
+
case 'WezTerm': {
|
94
|
+
return version.major >= 20_200_620;
|
95
|
+
}
|
96
|
+
|
97
|
+
case 'vscode': {
|
98
|
+
// Cursor forked VS Code and supports hyperlinks in 0.x.x
|
99
|
+
if (CURSOR_TRACE_ID) {
|
100
|
+
return true;
|
101
|
+
}
|
102
|
+
|
101
103
|
// eslint-disable-next-line no-mixed-operators
|
102
104
|
return version.major > 1 || version.major === 1 && version.minor >= 72;
|
103
|
-
|
105
|
+
}
|
106
|
+
|
107
|
+
case 'ghostty': {
|
104
108
|
return true;
|
109
|
+
}
|
105
110
|
// No default
|
106
111
|
}
|
107
112
|
}
|
@@ -117,17 +122,19 @@ function supportsHyperlink(stream) {
|
|
117
122
|
}
|
118
123
|
|
119
124
|
switch (TERM) {
|
120
|
-
case 'alacritty':
|
125
|
+
case 'alacritty': {
|
121
126
|
// Support added in v0.11 (2022-10-13)
|
122
127
|
return true;
|
128
|
+
}
|
123
129
|
// No default
|
124
130
|
}
|
125
131
|
|
126
132
|
return false;
|
127
133
|
}
|
128
134
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
stderr: supportsHyperlink(process.stderr)
|
135
|
+
const supportsHyperlinks = {
|
136
|
+
stdout: createSupportsHyperlinks(process.stdout),
|
137
|
+
stderr: createSupportsHyperlinks(process.stderr),
|
133
138
|
};
|
139
|
+
|
140
|
+
export default supportsHyperlinks;
|
package/package.json
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "supports-hyperlinks",
|
3
|
-
"version": "
|
3
|
+
"version": "4.1.0",
|
4
4
|
"description": "Detect whether a terminal supports hyperlinks",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": "chalk/supports-hyperlinks",
|
7
7
|
"funding": "https://github.com/chalk/supports-hyperlinks?sponsor=1",
|
8
|
+
"type": "module",
|
8
9
|
"exports": {
|
9
10
|
"types": "./index.d.ts",
|
10
11
|
"default": "./index.js"
|
11
12
|
},
|
12
13
|
"sideEffects": false,
|
13
14
|
"engines": {
|
14
|
-
"node": ">=
|
15
|
+
"node": ">=20"
|
15
16
|
},
|
16
17
|
"scripts": {
|
17
|
-
"
|
18
|
-
"test": "ava"
|
18
|
+
"test": "xo && ava && tsc index.d.ts"
|
19
19
|
},
|
20
20
|
"files": [
|
21
21
|
"index.js",
|
@@ -35,15 +35,13 @@
|
|
35
35
|
"console"
|
36
36
|
],
|
37
37
|
"dependencies": {
|
38
|
-
"has-flag": "^
|
39
|
-
"supports-color": "^
|
38
|
+
"has-flag": "^5.0.1",
|
39
|
+
"supports-color": "^10.0.0"
|
40
40
|
},
|
41
41
|
"devDependencies": {
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"typescript": "^4.9.5",
|
47
|
-
"xo": "^0.53.0"
|
42
|
+
"ava": "^6.2.0",
|
43
|
+
"codecov": "^3.8.3",
|
44
|
+
"typescript": "^5.8.2",
|
45
|
+
"xo": "^0.60.0"
|
48
46
|
}
|
49
47
|
}
|