123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.replaceSymbols = exports.fallbackSymbols = exports.mainSymbols = void 0;
- // process.env dot-notation access prints:
- // Property 'TERM' comes from an index signature, so it must be accessed with ['TERM'].ts(4111)
- /* eslint dot-notation: ["off"] */
- const node_process_1 = __importDefault(require("node:process"));
- // Ported from is-unicode-supported
- function isUnicodeSupported() {
- if (node_process_1.default.platform !== 'win32') {
- return node_process_1.default.env['TERM'] !== 'linux'; // Linux console (kernel)
- }
- return (Boolean(node_process_1.default.env['WT_SESSION']) || // Windows Terminal
- Boolean(node_process_1.default.env['TERMINUS_SUBLIME']) || // Terminus (<0.2.27)
- node_process_1.default.env['ConEmuTask'] === '{cmd::Cmder}' || // ConEmu and cmder
- node_process_1.default.env['TERM_PROGRAM'] === 'Terminus-Sublime' ||
- node_process_1.default.env['TERM_PROGRAM'] === 'vscode' ||
- node_process_1.default.env['TERM'] === 'xterm-256color' ||
- node_process_1.default.env['TERM'] === 'alacritty' ||
- node_process_1.default.env['TERMINAL_EMULATOR'] === 'JetBrains-JediTerm');
- }
- // Ported from figures
- const common = {
- circleQuestionMark: '(?)',
- questionMarkPrefix: '(?)',
- square: '█',
- squareDarkShade: '▓',
- squareMediumShade: '▒',
- squareLightShade: '░',
- squareTop: '▀',
- squareBottom: '▄',
- squareLeft: '▌',
- squareRight: '▐',
- squareCenter: '■',
- bullet: '●',
- dot: '․',
- ellipsis: '…',
- pointerSmall: '›',
- triangleUp: '▲',
- triangleUpSmall: '▴',
- triangleDown: '▼',
- triangleDownSmall: '▾',
- triangleLeftSmall: '◂',
- triangleRightSmall: '▸',
- home: '⌂',
- heart: '♥',
- musicNote: '♪',
- musicNoteBeamed: '♫',
- arrowUp: '↑',
- arrowDown: '↓',
- arrowLeft: '←',
- arrowRight: '→',
- arrowLeftRight: '↔',
- arrowUpDown: '↕',
- almostEqual: '≈',
- notEqual: '≠',
- lessOrEqual: '≤',
- greaterOrEqual: '≥',
- identical: '≡',
- infinity: '∞',
- subscriptZero: '₀',
- subscriptOne: '₁',
- subscriptTwo: '₂',
- subscriptThree: '₃',
- subscriptFour: '₄',
- subscriptFive: '₅',
- subscriptSix: '₆',
- subscriptSeven: '₇',
- subscriptEight: '₈',
- subscriptNine: '₉',
- oneHalf: '½',
- oneThird: '⅓',
- oneQuarter: '¼',
- oneFifth: '⅕',
- oneSixth: '⅙',
- oneEighth: '⅛',
- twoThirds: '⅔',
- twoFifths: '⅖',
- threeQuarters: '¾',
- threeFifths: '⅗',
- threeEighths: '⅜',
- fourFifths: '⅘',
- fiveSixths: '⅚',
- fiveEighths: '⅝',
- sevenEighths: '⅞',
- line: '─',
- lineBold: '━',
- lineDouble: '═',
- lineDashed0: '┄',
- lineDashed1: '┅',
- lineDashed2: '┈',
- lineDashed3: '┉',
- lineDashed4: '╌',
- lineDashed5: '╍',
- lineDashed6: '╴',
- lineDashed7: '╶',
- lineDashed8: '╸',
- lineDashed9: '╺',
- lineDashed10: '╼',
- lineDashed11: '╾',
- lineDashed12: '−',
- lineDashed13: '–',
- lineDashed14: '‐',
- lineDashed15: '⁃',
- lineVertical: '│',
- lineVerticalBold: '┃',
- lineVerticalDouble: '║',
- lineVerticalDashed0: '┆',
- lineVerticalDashed1: '┇',
- lineVerticalDashed2: '┊',
- lineVerticalDashed3: '┋',
- lineVerticalDashed4: '╎',
- lineVerticalDashed5: '╏',
- lineVerticalDashed6: '╵',
- lineVerticalDashed7: '╷',
- lineVerticalDashed8: '╹',
- lineVerticalDashed9: '╻',
- lineVerticalDashed10: '╽',
- lineVerticalDashed11: '╿',
- lineDownLeft: '┐',
- lineDownLeftArc: '╮',
- lineDownBoldLeftBold: '┓',
- lineDownBoldLeft: '┒',
- lineDownLeftBold: '┑',
- lineDownDoubleLeftDouble: '╗',
- lineDownDoubleLeft: '╖',
- lineDownLeftDouble: '╕',
- lineDownRight: '┌',
- lineDownRightArc: '╭',
- lineDownBoldRightBold: '┏',
- lineDownBoldRight: '┎',
- lineDownRightBold: '┍',
- lineDownDoubleRightDouble: '╔',
- lineDownDoubleRight: '╓',
- lineDownRightDouble: '╒',
- lineUpLeft: '┘',
- lineUpLeftArc: '╯',
- lineUpBoldLeftBold: '┛',
- lineUpBoldLeft: '┚',
- lineUpLeftBold: '┙',
- lineUpDoubleLeftDouble: '╝',
- lineUpDoubleLeft: '╜',
- lineUpLeftDouble: '╛',
- lineUpRight: '└',
- lineUpRightArc: '╰',
- lineUpBoldRightBold: '┗',
- lineUpBoldRight: '┖',
- lineUpRightBold: '┕',
- lineUpDoubleRightDouble: '╚',
- lineUpDoubleRight: '╙',
- lineUpRightDouble: '╘',
- lineUpDownLeft: '┤',
- lineUpBoldDownBoldLeftBold: '┫',
- lineUpBoldDownBoldLeft: '┨',
- lineUpDownLeftBold: '┥',
- lineUpBoldDownLeftBold: '┩',
- lineUpDownBoldLeftBold: '┪',
- lineUpDownBoldLeft: '┧',
- lineUpBoldDownLeft: '┦',
- lineUpDoubleDownDoubleLeftDouble: '╣',
- lineUpDoubleDownDoubleLeft: '╢',
- lineUpDownLeftDouble: '╡',
- lineUpDownRight: '├',
- lineUpBoldDownBoldRightBold: '┣',
- lineUpBoldDownBoldRight: '┠',
- lineUpDownRightBold: '┝',
- lineUpBoldDownRightBold: '┡',
- lineUpDownBoldRightBold: '┢',
- lineUpDownBoldRight: '┟',
- lineUpBoldDownRight: '┞',
- lineUpDoubleDownDoubleRightDouble: '╠',
- lineUpDoubleDownDoubleRight: '╟',
- lineUpDownRightDouble: '╞',
- lineDownLeftRight: '┬',
- lineDownBoldLeftBoldRightBold: '┳',
- lineDownLeftBoldRightBold: '┯',
- lineDownBoldLeftRight: '┰',
- lineDownBoldLeftBoldRight: '┱',
- lineDownBoldLeftRightBold: '┲',
- lineDownLeftRightBold: '┮',
- lineDownLeftBoldRight: '┭',
- lineDownDoubleLeftDoubleRightDouble: '╦',
- lineDownDoubleLeftRight: '╥',
- lineDownLeftDoubleRightDouble: '╤',
- lineUpLeftRight: '┴',
- lineUpBoldLeftBoldRightBold: '┻',
- lineUpLeftBoldRightBold: '┷',
- lineUpBoldLeftRight: '┸',
- lineUpBoldLeftBoldRight: '┹',
- lineUpBoldLeftRightBold: '┺',
- lineUpLeftRightBold: '┶',
- lineUpLeftBoldRight: '┵',
- lineUpDoubleLeftDoubleRightDouble: '╩',
- lineUpDoubleLeftRight: '╨',
- lineUpLeftDoubleRightDouble: '╧',
- lineUpDownLeftRight: '┼',
- lineUpBoldDownBoldLeftBoldRightBold: '╋',
- lineUpDownBoldLeftBoldRightBold: '╈',
- lineUpBoldDownLeftBoldRightBold: '╇',
- lineUpBoldDownBoldLeftRightBold: '╊',
- lineUpBoldDownBoldLeftBoldRight: '╉',
- lineUpBoldDownLeftRight: '╀',
- lineUpDownBoldLeftRight: '╁',
- lineUpDownLeftBoldRight: '┽',
- lineUpDownLeftRightBold: '┾',
- lineUpBoldDownBoldLeftRight: '╂',
- lineUpDownLeftBoldRightBold: '┿',
- lineUpBoldDownLeftBoldRight: '╃',
- lineUpBoldDownLeftRightBold: '╄',
- lineUpDownBoldLeftBoldRight: '╅',
- lineUpDownBoldLeftRightBold: '╆',
- lineUpDoubleDownDoubleLeftDoubleRightDouble: '╬',
- lineUpDoubleDownDoubleLeftRight: '╫',
- lineUpDownLeftDoubleRightDouble: '╪',
- lineCross: '╳',
- lineBackslash: '╲',
- lineSlash: '╱',
- };
- const specialMainSymbols = {
- tick: '✔',
- info: 'ℹ',
- warning: '⚠',
- cross: '✘',
- squareSmall: '◻',
- squareSmallFilled: '◼',
- circle: '◯',
- circleFilled: '◉',
- circleDotted: '◌',
- circleDouble: '◎',
- circleCircle: 'ⓞ',
- circleCross: 'ⓧ',
- circlePipe: 'Ⓘ',
- radioOn: '◉',
- radioOff: '◯',
- checkboxOn: '☒',
- checkboxOff: '☐',
- checkboxCircleOn: 'ⓧ',
- checkboxCircleOff: 'Ⓘ',
- pointer: '❯',
- triangleUpOutline: '△',
- triangleLeft: '◀',
- triangleRight: '▶',
- lozenge: '◆',
- lozengeOutline: '◇',
- hamburger: '☰',
- smiley: '㋡',
- mustache: '෴',
- star: '★',
- play: '▶',
- nodejs: '⬢',
- oneSeventh: '⅐',
- oneNinth: '⅑',
- oneTenth: '⅒',
- };
- const specialFallbackSymbols = {
- tick: '√',
- info: 'i',
- warning: '‼',
- cross: '×',
- squareSmall: '□',
- squareSmallFilled: '■',
- circle: '( )',
- circleFilled: '(*)',
- circleDotted: '( )',
- circleDouble: '( )',
- circleCircle: '(○)',
- circleCross: '(×)',
- circlePipe: '(│)',
- radioOn: '(*)',
- radioOff: '( )',
- checkboxOn: '[×]',
- checkboxOff: '[ ]',
- checkboxCircleOn: '(×)',
- checkboxCircleOff: '( )',
- pointer: '>',
- triangleUpOutline: '∆',
- triangleLeft: '◄',
- triangleRight: '►',
- lozenge: '♦',
- lozengeOutline: '◊',
- hamburger: '≡',
- smiley: '☺',
- mustache: '┌─┐',
- star: '✶',
- play: '►',
- nodejs: '♦',
- oneSeventh: '1/7',
- oneNinth: '1/9',
- oneTenth: '1/10',
- };
- exports.mainSymbols = { ...common, ...specialMainSymbols };
- exports.fallbackSymbols = {
- ...common,
- ...specialFallbackSymbols,
- };
- const shouldUseMain = isUnicodeSupported();
- const figures = shouldUseMain ? exports.mainSymbols : exports.fallbackSymbols;
- exports.default = figures;
- const replacements = Object.entries(specialMainSymbols);
- // On terminals which do not support Unicode symbols, substitute them to other symbols
- const replaceSymbols = (string, { useFallback = !shouldUseMain } = {}) => {
- if (useFallback) {
- for (const [key, mainSymbol] of replacements) {
- const fallbackSymbol = exports.fallbackSymbols[key];
- if (!fallbackSymbol) {
- throw new Error(`Unable to find fallback for ${key}`);
- }
- string = string.replaceAll(mainSymbol, fallbackSymbol);
- }
- }
- return string;
- };
- exports.replaceSymbols = replaceSymbols;
|