🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@inquirer/core

Package Overview
Dependencies
Maintainers
3
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inquirer/core - npm Package Compare versions

Comparing version

to
3.1.0

15

./dist/cjs/index.js

@@ -186,2 +186,5 @@ "use strict";

const answer = new type_1.CancelablePromise((resolve, reject) => {
const checkCursorPos = () => {
screen.checkCursorPos();
};
const onExit = () => {

@@ -204,4 +207,5 @@ try {

screen.done();
process.removeListener('SIGINT', onForceExit);
sessionRl === null || sessionRl === void 0 ? void 0 : sessionRl.input.removeListener('keypress', checkCursorPos);
resetHookState();
process.removeListener('SIGINT', onForceExit);
};

@@ -248,3 +252,10 @@ cancel = () => {

// TODO: we should display a loader while we get the default options.
(0, options_mjs_1.getPromptConfig)(config).then(workLoop, reject);
(0, options_mjs_1.getPromptConfig)(config).then((resolvedConfig) => {
workLoop(resolvedConfig);
// Re-renders only happen when the state change; but the readline cursor could change position
// and that also requires a re-render (and a manual one because we mute the streams).
// We set the listener after the initial workLoop to avoid a double render if render triggered
// by a state change sets the cursor to the right position.
sessionRl === null || sessionRl === void 0 ? void 0 : sessionRl.input.on('keypress', checkCursorPos);
}, reject);
});

@@ -251,0 +262,0 @@ answer.catch(() => {

@@ -186,2 +186,5 @@ "use strict";

const answer = new type_1.CancelablePromise((resolve, reject) => {
const checkCursorPos = () => {
screen.checkCursorPos();
};
const onExit = () => {

@@ -204,4 +207,5 @@ try {

screen.done();
process.removeListener('SIGINT', onForceExit);
sessionRl === null || sessionRl === void 0 ? void 0 : sessionRl.input.removeListener('keypress', checkCursorPos);
resetHookState();
process.removeListener('SIGINT', onForceExit);
};

@@ -248,3 +252,10 @@ cancel = () => {

// TODO: we should display a loader while we get the default options.
(0, options_mjs_1.getPromptConfig)(config).then(workLoop, reject);
(0, options_mjs_1.getPromptConfig)(config).then((resolvedConfig) => {
workLoop(resolvedConfig);
// Re-renders only happen when the state change; but the readline cursor could change position
// and that also requires a re-render (and a manual one because we mute the streams).
// We set the listener after the initial workLoop to avoid a double render if render triggered
// by a state change sets the cursor to the right position.
sessionRl === null || sessionRl === void 0 ? void 0 : sessionRl.input.on('keypress', checkCursorPos);
}, reject);
});

@@ -251,0 +262,0 @@ answer.catch(() => {

29

dist/cjs/lib/screen-manager.js

@@ -8,3 +8,2 @@ "use strict";

const strip_ansi_1 = __importDefault(require("strip-ansi"));
const string_width_1 = __importDefault(require("string-width"));
const ansi_escapes_1 = __importDefault(require("ansi-escapes"));

@@ -35,3 +34,10 @@ const utils_mjs_1 = require('./utils.js');

});
Object.defineProperty(this, "cursorPos", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.rl = rl;
this.cursorPos = rl.getCursorPos();
}

@@ -55,3 +61,3 @@ render(content, bottomContent = '') {

// SetPrompt will change cursor position, now we can get correct value
const cursorPos = this.rl._getCursorPos();
this.cursorPos = this.rl.getCursorPos();
const width = (0, cli_width_1.default)({ defaultWidth: 80, output: this.rl.output });

@@ -72,3 +78,3 @@ content = (0, utils_mjs_1.breakLines)(content, width);

// content in order to correctly cleanup and re-render.
const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - cursorPos.rows;
const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);

@@ -78,8 +84,4 @@ // Return cursor to the input position (on top of the bottomContent)

output += ansi_escapes_1.default.cursorUp(bottomContentHeight);
// Move cursor at the start of the line, then return to the initial left offset.
const backward = (0, string_width_1.default)(lastLine(output));
if (backward > 0)
output += ansi_escapes_1.default.cursorBackward(backward);
if (cursorPos.cols > 0)
output += ansi_escapes_1.default.cursorForward(cursorPos.cols);
// Return cursor to the initial left offset.
output += ansi_escapes_1.default.cursorTo(this.cursorPos.cols);
/**

@@ -93,2 +95,11 @@ * Set up state for next re-rendering

}
checkCursorPos() {
const cursorPos = this.rl.getCursorPos();
if (cursorPos.cols !== this.cursorPos.cols) {
this.rl.output.unmute();
this.rl.output.write(ansi_escapes_1.default.cursorTo(cursorPos.cols));
this.rl.output.mute();
this.cursorPos = cursorPos;
}
}
clean() {

@@ -95,0 +106,0 @@ this.rl.output.unmute();

@@ -6,4 +6,6 @@ import { InquirerReadline } from '../index.js';

private extraLinesUnderPrompt;
private cursorPos;
constructor(rl: InquirerReadline);
render(content: string, bottomContent?: string): void;
checkCursorPos(): void;
clean(): void;

@@ -10,0 +12,0 @@ clearContent(): void;

{
"name": "@inquirer/core",
"version": "3.0.0",
"version": "3.1.0",
"engines": {

@@ -71,3 +71,2 @@ "node": ">=14.18.0"

"run-async": "^3.0.0",
"string-width": "^4.2.3",
"strip-ansi": "^6.0.1",

@@ -101,3 +100,3 @@ "wrap-ansi": "^6.0.1"

},
"gitHead": "18144628b03b62c346cb7d9d55a2c526b1ed5d8a"
"gitHead": "ab9dd2f301e02d2cc0fec699ce100b174f2b798e"
}

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