@visulima/is-ansi-color-supported
Version:
Detect whether a terminal or browser supports ansi colors.
34 lines (30 loc) • 1.42 kB
JavaScript
import { SPACE_TRUE_COLORS, SPACE_16_COLORS, SPACE_MONO } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
export { SPACE_256_COLORS } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
var __defProp$1 = Object.defineProperty;
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
const isColorSupported$1 = /* @__PURE__ */ __name$1(() => (() => {
if (typeof navigator !== "undefined") {
if (navigator.userAgentData) {
const brand = navigator.userAgentData.brands.find(({ b }) => b === "Chromium");
if (brand?.version > 93) {
return SPACE_TRUE_COLORS;
}
}
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
return SPACE_16_COLORS;
}
}
return SPACE_MONO;
})(), "isColorSupported");
const isStdoutColorSupported$1 = isColorSupported$1;
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
const isColorSupported = /* @__PURE__ */ __name(() => (() => {
if (process.env.NEXT_RUNTIME !== void 0 && process.env.NEXT_RUNTIME.includes("edge")) {
return SPACE_16_COLORS;
}
return isStdoutColorSupported$1();
})(), "isColorSupported");
const isStdoutColorSupported = isColorSupported;
const isStderrColorSupported = isColorSupported;
export { SPACE_16_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };