@inquirer/core
Advanced tools
@@ -97,5 +97,7 @@ "use strict"; | ||
| }); | ||
| // Warning: Clean the hooks before exiting the `withUpdates` block. | ||
| // Failure to do so means an updates would hit the same effects again. | ||
| store.hooksEffect.length = 0; | ||
| })(); | ||
| store.hooksEffect.length = 0; | ||
| }, | ||
| }; |
@@ -6,3 +6,2 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const cli_width_1 = __importDefault(require("cli-width")); | ||
| const strip_ansi_1 = __importDefault(require("strip-ansi")); | ||
@@ -61,3 +60,3 @@ const ansi_escapes_1 = __importDefault(require("ansi-escapes")); | ||
| this.cursorPos = this.rl.getCursorPos(); | ||
| const width = (0, cli_width_1.default)({ defaultWidth: 80, output: this.rl.output }); | ||
| const width = (0, utils_mjs_1.readlineWidth)(); | ||
| content = (0, utils_mjs_1.breakLines)(content, width); | ||
@@ -64,0 +63,0 @@ bottomContent = (0, utils_mjs_1.breakLines)(bottomContent, width); |
@@ -8,8 +8,5 @@ "use strict"; | ||
| const chalk_1 = __importDefault(require("chalk")); | ||
| const cli_width_1 = __importDefault(require("cli-width")); | ||
| const utils_mjs_1 = require('./utils.js'); | ||
| const hook_engine_mjs_1 = require('./hook-engine.js'); | ||
| const use_ref_mjs_1 = require('./use-ref.js'); | ||
| function usePagination(output, { active, pageSize = 7, }) { | ||
| const rl = (0, hook_engine_mjs_1.readline)(); | ||
| const state = (0, use_ref_mjs_1.useRef)({ | ||
@@ -19,3 +16,3 @@ pointer: 0, | ||
| }); | ||
| const width = (0, cli_width_1.default)({ defaultWidth: 80, output: rl.output }); | ||
| const width = (0, utils_mjs_1.readlineWidth)(); | ||
| const lines = (0, utils_mjs_1.breakLines)(output, width).split('\n'); | ||
@@ -22,0 +19,0 @@ // Make sure there's enough lines to paginate |
@@ -6,4 +6,6 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.breakLines = void 0; | ||
| exports.readlineWidth = exports.breakLines = void 0; | ||
| const cli_width_1 = __importDefault(require("cli-width")); | ||
| const wrap_ansi_1 = __importDefault(require("wrap-ansi")); | ||
| const hook_engine_mjs_1 = require('./hook-engine.js'); | ||
| /** | ||
@@ -16,8 +18,18 @@ * Force line returns at specific width. This function is ANSI code friendly and it'll | ||
| */ | ||
| const breakLines = (content, width) => content | ||
| .split('\n') | ||
| .flatMap((line) => (0, wrap_ansi_1.default)(line, width, { trim: false, hard: true }) | ||
| .split('\n') | ||
| .map((str) => str.trimEnd())) | ||
| .join('\n'); | ||
| function breakLines(content, width) { | ||
| return content | ||
| .split('\n') | ||
| .flatMap((line) => (0, wrap_ansi_1.default)(line, width, { trim: false, hard: true }) | ||
| .split('\n') | ||
| .map((str) => str.trimEnd())) | ||
| .join('\n'); | ||
| } | ||
| exports.breakLines = breakLines; | ||
| /** | ||
| * Returns the width of the active readline, or 80 as default value. | ||
| * @returns {number} | ||
| */ | ||
| function readlineWidth() { | ||
| return (0, cli_width_1.default)({ defaultWidth: 80, output: (0, hook_engine_mjs_1.readline)().output }); | ||
| } | ||
| exports.readlineWidth = readlineWidth; |
@@ -8,2 +8,7 @@ /** | ||
| */ | ||
| export declare const breakLines: (content: string, width: number) => string; | ||
| export declare function breakLines(content: string, width: number): string; | ||
| /** | ||
| * Returns the width of the active readline, or 80 as default value. | ||
| * @returns {number} | ||
| */ | ||
| export declare function readlineWidth(): number; |
@@ -88,5 +88,7 @@ import { AsyncLocalStorage, AsyncResource } from 'node:async_hooks'; | ||
| }); | ||
| // Warning: Clean the hooks before exiting the `withUpdates` block. | ||
| // Failure to do so means an updates would hit the same effects again. | ||
| store.hooksEffect.length = 0; | ||
| })(); | ||
| store.hooksEffect.length = 0; | ||
| }, | ||
| }; |
@@ -1,5 +0,4 @@ | ||
| import cliWidth from 'cli-width'; | ||
| import stripAnsi from 'strip-ansi'; | ||
| import ansiEscapes from 'ansi-escapes'; | ||
| import { breakLines } from './utils.mjs'; | ||
| import { breakLines, readlineWidth } from './utils.mjs'; | ||
| const height = (content) => content.split('\n').length; | ||
@@ -36,3 +35,3 @@ const lastLine = (content) => content.split('\n').pop() ?? ''; | ||
| this.cursorPos = this.rl.getCursorPos(); | ||
| const width = cliWidth({ defaultWidth: 80, output: this.rl.output }); | ||
| const width = readlineWidth(); | ||
| content = breakLines(content, width); | ||
@@ -39,0 +38,0 @@ bottomContent = breakLines(bottomContent, width); |
| import chalk from 'chalk'; | ||
| import cliWidth from 'cli-width'; | ||
| import { breakLines } from './utils.mjs'; | ||
| import { readline } from './hook-engine.mjs'; | ||
| import { breakLines, readlineWidth } from './utils.mjs'; | ||
| import { useRef } from './use-ref.mjs'; | ||
| export function usePagination(output, { active, pageSize = 7, }) { | ||
| const rl = readline(); | ||
| const state = useRef({ | ||
@@ -12,3 +9,3 @@ pointer: 0, | ||
| }); | ||
| const width = cliWidth({ defaultWidth: 80, output: rl.output }); | ||
| const width = readlineWidth(); | ||
| const lines = breakLines(output, width).split('\n'); | ||
@@ -15,0 +12,0 @@ // Make sure there's enough lines to paginate |
@@ -0,2 +1,4 @@ | ||
| import cliWidth from 'cli-width'; | ||
| import wrapAnsi from 'wrap-ansi'; | ||
| import { readline } from './hook-engine.mjs'; | ||
| /** | ||
@@ -9,7 +11,16 @@ * Force line returns at specific width. This function is ANSI code friendly and it'll | ||
| */ | ||
| export const breakLines = (content, width) => content | ||
| .split('\n') | ||
| .flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }) | ||
| .split('\n') | ||
| .map((str) => str.trimEnd())) | ||
| .join('\n'); | ||
| export function breakLines(content, width) { | ||
| return content | ||
| .split('\n') | ||
| .flatMap((line) => wrapAnsi(line, width, { trim: false, hard: true }) | ||
| .split('\n') | ||
| .map((str) => str.trimEnd())) | ||
| .join('\n'); | ||
| } | ||
| /** | ||
| * Returns the width of the active readline, or 80 as default value. | ||
| * @returns {number} | ||
| */ | ||
| export function readlineWidth() { | ||
| return cliWidth({ defaultWidth: 80, output: readline().output }); | ||
| } |
@@ -8,2 +8,7 @@ /** | ||
| */ | ||
| export declare const breakLines: (content: string, width: number) => string; | ||
| export declare function breakLines(content: string, width: number): string; | ||
| /** | ||
| * Returns the width of the active readline, or 80 as default value. | ||
| * @returns {number} | ||
| */ | ||
| export declare function readlineWidth(): number; |
+6
-6
| { | ||
| "name": "@inquirer/core", | ||
| "version": "5.0.0", | ||
| "version": "5.0.1", | ||
| "engines": { | ||
@@ -60,9 +60,9 @@ "node": ">=14.18.0" | ||
| "dependencies": { | ||
| "@inquirer/type": "^1.1.4", | ||
| "@inquirer/type": "^1.1.5", | ||
| "@types/mute-stream": "^0.0.1", | ||
| "@types/node": "^20.6.0", | ||
| "@types/node": "^20.6.5", | ||
| "@types/wrap-ansi": "^3.0.0", | ||
| "ansi-escapes": "^4.3.2", | ||
| "chalk": "^4.1.2", | ||
| "cli-spinners": "^2.9.0", | ||
| "cli-spinners": "^2.9.1", | ||
| "cli-width": "^4.1.0", | ||
@@ -77,3 +77,3 @@ "figures": "^3.2.0", | ||
| "devDependencies": { | ||
| "@inquirer/testing": "^2.1.6" | ||
| "@inquirer/testing": "^2.1.7" | ||
| }, | ||
@@ -100,3 +100,3 @@ "scripts": { | ||
| }, | ||
| "gitHead": "c2d1c5fdfd1029f78351fb04e06f1cfb29d55bb6" | ||
| "gitHead": "85784061d702778bc9dd48ca08f09ee9976b06ee" | ||
| } |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
63579
1.45%1249
1.96%Updated
Updated
Updated