mirror of
https://github.com/tvytlx/ai-agent-deep-dive.git
synced 2026-04-04 16:14:50 +08:00
Add extracted source directory and README navigation
This commit is contained in:
100
extracted-source/node_modules/supports-hyperlinks/index.js
generated
vendored
Normal file
100
extracted-source/node_modules/supports-hyperlinks/index.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
const supportsColor = require('supports-color');
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
function parseVersion(versionString) {
|
||||
if (/^\d{3,4}$/.test(versionString)) {
|
||||
// Env var doesn't always use dots. example: 4601 => 46.1.0
|
||||
const m = /(\d{1,2})(\d{2})/.exec(versionString);
|
||||
return {
|
||||
major: 0,
|
||||
minor: parseInt(m[1], 10),
|
||||
patch: parseInt(m[2], 10)
|
||||
};
|
||||
}
|
||||
|
||||
const versions = (versionString || '').split('.').map(n => parseInt(n, 10));
|
||||
return {
|
||||
major: versions[0],
|
||||
minor: versions[1],
|
||||
patch: versions[2]
|
||||
};
|
||||
}
|
||||
|
||||
function supportsHyperlink(stream) {
|
||||
const {env} = process;
|
||||
|
||||
if ('FORCE_HYPERLINK' in env) {
|
||||
return !(env.FORCE_HYPERLINK.length > 0 && parseInt(env.FORCE_HYPERLINK, 10) === 0);
|
||||
}
|
||||
|
||||
if (hasFlag('no-hyperlink') || hasFlag('no-hyperlinks') || hasFlag('hyperlink=false') || hasFlag('hyperlink=never')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasFlag('hyperlink=true') || hasFlag('hyperlink=always')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Netlify does not run a TTY, it does not need `supportsColor` check
|
||||
if ('NETLIFY' in env) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If they specify no colors, they probably don't want hyperlinks.
|
||||
if (!supportsColor.supportsColor(stream)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stream && !stream.isTTY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
const version = parseVersion(env.TERM_PROGRAM_VERSION);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app':
|
||||
if (version.major === 3) {
|
||||
return version.minor >= 1;
|
||||
}
|
||||
|
||||
return version.major > 3;
|
||||
case 'WezTerm':
|
||||
return version.major >= 20200620;
|
||||
case 'vscode':
|
||||
return version.major > 1 || version.major === 1 && version.minor >= 72;
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if ('VTE_VERSION' in env) {
|
||||
// 0.50.0 was supposed to support hyperlinks, but throws a segfault
|
||||
if (env.VTE_VERSION === '0.50.0') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const version = parseVersion(env.VTE_VERSION);
|
||||
return version.major > 0 || version.minor >= 50;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
supportsHyperlink,
|
||||
stdout: supportsHyperlink(process.stdout),
|
||||
stderr: supportsHyperlink(process.stderr)
|
||||
};
|
||||
135
extracted-source/node_modules/supports-hyperlinks/node_modules/supports-color/index.js
generated
vendored
Normal file
135
extracted-source/node_modules/supports-hyperlinks/node_modules/supports-color/index.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
'use strict';
|
||||
const os = require('os');
|
||||
const tty = require('tty');
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
const {env} = process;
|
||||
|
||||
let forceColor;
|
||||
if (hasFlag('no-color') ||
|
||||
hasFlag('no-colors') ||
|
||||
hasFlag('color=false') ||
|
||||
hasFlag('color=never')) {
|
||||
forceColor = 0;
|
||||
} else if (hasFlag('color') ||
|
||||
hasFlag('colors') ||
|
||||
hasFlag('color=true') ||
|
||||
hasFlag('color=always')) {
|
||||
forceColor = 1;
|
||||
}
|
||||
|
||||
if ('FORCE_COLOR' in env) {
|
||||
if (env.FORCE_COLOR === 'true') {
|
||||
forceColor = 1;
|
||||
} else if (env.FORCE_COLOR === 'false') {
|
||||
forceColor = 0;
|
||||
} else {
|
||||
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
||||
}
|
||||
}
|
||||
|
||||
function translateLevel(level) {
|
||||
if (level === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3
|
||||
};
|
||||
}
|
||||
|
||||
function supportsColor(haveStream, streamIsTTY) {
|
||||
if (forceColor === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hasFlag('color=16m') ||
|
||||
hasFlag('color=full') ||
|
||||
hasFlag('color=truecolor')) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (hasFlag('color=256')) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const min = forceColor || 0;
|
||||
|
||||
if (env.TERM === 'dumb') {
|
||||
return min;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
||||
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
||||
const osRelease = os.release().split('.');
|
||||
if (
|
||||
Number(osRelease[0]) >= 10 &&
|
||||
Number(osRelease[2]) >= 10586
|
||||
) {
|
||||
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (env.COLORTERM === 'truecolor') {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app':
|
||||
return version >= 3 ? 3 : 2;
|
||||
case 'Apple_Terminal':
|
||||
return 2;
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if (/-256(color)?$/i.test(env.TERM)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
function getSupportLevel(stream) {
|
||||
const level = supportsColor(stream, stream && stream.isTTY);
|
||||
return translateLevel(level);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
supportsColor: getSupportLevel,
|
||||
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
||||
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
||||
};
|
||||
Reference in New Issue
Block a user