UNPKG

keycloakify

Version:

Framework to create custom Keycloak UIs

275 lines (217 loc) 7.74 kB
"use strict"; exports.id = 877; exports.ids = [877]; exports.modules = { /***/ 85877: /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "default": () => (/* binding */ cliTruncate) }); ;// CONCATENATED MODULE: ./node_modules/listr2/node_modules/is-fullwidth-code-point/index.js /* eslint-disable yoda */ function isFullwidthCodePoint(codePoint) { if (!Number.isInteger(codePoint)) { return false; } // Code points are derived from: // https://unicode.org/Public/UNIDATA/EastAsianWidth.txt return codePoint >= 0x1100 && ( codePoint <= 0x115F || // Hangul Jamo codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET // CJK Radicals Supplement .. Enclosed CJK Letters and Months (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A (0x3250 <= codePoint && codePoint <= 0x4DBF) || // CJK Unified Ideographs .. Yi Radicals (0x4E00 <= codePoint && codePoint <= 0xA4C6) || // Hangul Jamo Extended-A (0xA960 <= codePoint && codePoint <= 0xA97C) || // Hangul Syllables (0xAC00 <= codePoint && codePoint <= 0xD7A3) || // CJK Compatibility Ideographs (0xF900 <= codePoint && codePoint <= 0xFAFF) || // Vertical Forms (0xFE10 <= codePoint && codePoint <= 0xFE19) || // CJK Compatibility Forms .. Small Form Variants (0xFE30 <= codePoint && codePoint <= 0xFE6B) || // Halfwidth and Fullwidth Forms (0xFF01 <= codePoint && codePoint <= 0xFF60) || (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || // Kana Supplement (0x1B000 <= codePoint && codePoint <= 0x1B001) || // Enclosed Ideographic Supplement (0x1F200 <= codePoint && codePoint <= 0x1F251) || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane (0x20000 <= codePoint && codePoint <= 0x3FFFD) ); } // EXTERNAL MODULE: ./node_modules/listr2/node_modules/ansi-styles/index.js var ansi_styles = __webpack_require__(51284); ;// CONCATENATED MODULE: ./node_modules/listr2/node_modules/slice-ansi/index.js const astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/; const ESCAPES = [ '\u001B', '\u009B' ]; const wrapAnsi = code => `${ESCAPES[0]}[${code}m`; const checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => { let output = []; ansiCodes = [...ansiCodes]; for (let ansiCode of ansiCodes) { const ansiCodeOrigin = ansiCode; if (ansiCode.includes(';')) { ansiCode = ansiCode.split(';')[0][0] + '0'; } const item = ansi_styles/* default.codes.get */.ZP.codes.get(Number.parseInt(ansiCode, 10)); if (item) { const indexEscape = ansiCodes.indexOf(item.toString()); if (indexEscape === -1) { output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin)); } else { ansiCodes.splice(indexEscape, 1); } } else if (isEscapes) { output.push(wrapAnsi(0)); break; } else { output.push(wrapAnsi(ansiCodeOrigin)); } } if (isEscapes) { output = output.filter((element, index) => output.indexOf(element) === index); if (endAnsiCode !== undefined) { const fistEscapeCode = wrapAnsi(ansi_styles/* default.codes.get */.ZP.codes.get(Number.parseInt(endAnsiCode, 10))); // TODO: Remove the use of `.reduce` here. // eslint-disable-next-line unicorn/no-array-reduce output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []); } } return output.join(''); }; function sliceAnsi(string, begin, end) { const characters = [...string]; const ansiCodes = []; let stringEnd = typeof end === 'number' ? end : characters.length; let isInsideEscape = false; let ansiCode; let visible = 0; let output = ''; for (const [index, character] of characters.entries()) { let leftEscape = false; if (ESCAPES.includes(character)) { const code = /\d[^m]*/.exec(string.slice(index, index + 18)); ansiCode = code && code.length > 0 ? code[0] : undefined; if (visible < stringEnd) { isInsideEscape = true; if (ansiCode !== undefined) { ansiCodes.push(ansiCode); } } } else if (isInsideEscape && character === 'm') { isInsideEscape = false; leftEscape = true; } if (!isInsideEscape && !leftEscape) { visible++; } if (!astralRegex.test(character) && isFullwidthCodePoint(character.codePointAt())) { visible++; if (typeof end !== 'number') { stringEnd++; } } if (visible > begin && visible <= stringEnd) { output += character; } else if (visible === begin && !isInsideEscape && ansiCode !== undefined) { output = checkAnsi(ansiCodes); } else if (visible >= stringEnd) { output += checkAnsi(ansiCodes, true, ansiCode); break; } } return output; } // EXTERNAL MODULE: ./node_modules/listr2/node_modules/string-width/index.js var string_width = __webpack_require__(10509); ;// CONCATENATED MODULE: ./node_modules/listr2/node_modules/cli-truncate/index.js function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) { if (string.charAt(wantedIndex) === ' ') { return wantedIndex; } const direction = shouldSearchRight ? 1 : -1; for (let index = 0; index <= 3; index++) { const finalIndex = wantedIndex + (index * direction); if (string.charAt(finalIndex) === ' ') { return finalIndex; } } return wantedIndex; } function cliTruncate(text, columns, options = {}) { const { position = 'end', space = false, preferTruncationOnSpace = false, } = options; let {truncationCharacter = '…'} = options; if (typeof text !== 'string') { throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`); } if (typeof columns !== 'number') { throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`); } if (columns < 1) { return ''; } if (columns === 1) { return truncationCharacter; } const length = (0,string_width/* default */.Z)(text); if (length <= columns) { return text; } if (position === 'start') { if (preferTruncationOnSpace) { const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true); return truncationCharacter + sliceAnsi(text, nearestSpace, length).trim(); } if (space === true) { truncationCharacter += ' '; } return truncationCharacter + sliceAnsi(text, length - columns + (0,string_width/* default */.Z)(truncationCharacter), length); } if (position === 'middle') { if (space === true) { truncationCharacter = ` ${truncationCharacter} `; } const half = Math.floor(columns / 2); if (preferTruncationOnSpace) { const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half); const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true); return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim(); } return ( sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + (0,string_width/* default */.Z)(truncationCharacter), length) ); } if (position === 'end') { if (preferTruncationOnSpace) { const nearestSpace = getIndexOfNearestSpace(text, columns - 1); return sliceAnsi(text, 0, nearestSpace) + truncationCharacter; } if (space === true) { truncationCharacter = ` ${truncationCharacter}`; } return sliceAnsi(text, 0, columns - (0,string_width/* default */.Z)(truncationCharacter)) + truncationCharacter; } throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`); } /***/ }) }; ;