@inquirer/core
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -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; |
{ | ||
"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" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63579
1249
Updated@inquirer/type@^1.1.5
Updated@types/node@^20.6.5
Updatedcli-spinners@^2.9.1