@inquirer/core 10.2.0 → 10.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const node_util_1 = require("node:util");
|
|
7
|
-
const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
|
|
8
4
|
const utils_ts_1 = require("./utils.js");
|
|
5
|
+
const ansi_1 = require("@inquirer/ansi");
|
|
9
6
|
const height = (content) => content.split('\n').length;
|
|
10
7
|
const lastLine = (content) => content.split('\n').pop() ?? '';
|
|
11
|
-
function cursorDown(n) {
|
|
12
|
-
return n > 0 ? ansi_escapes_1.default.cursorDown(n) : '';
|
|
13
|
-
}
|
|
14
8
|
class ScreenManager {
|
|
15
9
|
// These variables are keeping information to allow correct prompt re-rendering
|
|
16
10
|
height = 0;
|
|
@@ -59,30 +53,28 @@ class ScreenManager {
|
|
|
59
53
|
const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
|
|
60
54
|
// Return cursor to the input position (on top of the bottomContent)
|
|
61
55
|
if (bottomContentHeight > 0)
|
|
62
|
-
output +=
|
|
56
|
+
output += (0, ansi_1.cursorUp)(bottomContentHeight);
|
|
63
57
|
// Return cursor to the initial left offset.
|
|
64
|
-
output +=
|
|
58
|
+
output += (0, ansi_1.cursorTo)(this.cursorPos.cols);
|
|
65
59
|
/**
|
|
66
60
|
* Render and store state for future re-rendering
|
|
67
61
|
*/
|
|
68
|
-
this.write(cursorDown(this.extraLinesUnderPrompt) +
|
|
69
|
-
ansi_escapes_1.default.eraseLines(this.height) +
|
|
70
|
-
output);
|
|
62
|
+
this.write((0, ansi_1.cursorDown)(this.extraLinesUnderPrompt) + (0, ansi_1.eraseLines)(this.height) + output);
|
|
71
63
|
this.extraLinesUnderPrompt = bottomContentHeight;
|
|
72
64
|
this.height = height(output);
|
|
73
65
|
}
|
|
74
66
|
checkCursorPos() {
|
|
75
67
|
const cursorPos = this.rl.getCursorPos();
|
|
76
68
|
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
77
|
-
this.write(
|
|
69
|
+
this.write((0, ansi_1.cursorTo)(cursorPos.cols));
|
|
78
70
|
this.cursorPos = cursorPos;
|
|
79
71
|
}
|
|
80
72
|
}
|
|
81
73
|
done({ clearContent }) {
|
|
82
74
|
this.rl.setPrompt('');
|
|
83
|
-
let output = cursorDown(this.extraLinesUnderPrompt);
|
|
84
|
-
output += clearContent ?
|
|
85
|
-
output +=
|
|
75
|
+
let output = (0, ansi_1.cursorDown)(this.extraLinesUnderPrompt);
|
|
76
|
+
output += clearContent ? (0, ansi_1.eraseLines)(this.height) : '\n';
|
|
77
|
+
output += ansi_1.cursorShow;
|
|
86
78
|
this.write(output);
|
|
87
79
|
this.rl.close();
|
|
88
80
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { stripVTControlCharacters } from 'node:util';
|
|
2
|
-
import ansiEscapes from 'ansi-escapes';
|
|
3
2
|
import { breakLines, readlineWidth } from "./utils.js";
|
|
3
|
+
import { cursorDown, cursorUp, cursorTo, cursorShow, eraseLines } from '@inquirer/ansi';
|
|
4
4
|
const height = (content) => content.split('\n').length;
|
|
5
5
|
const lastLine = (content) => content.split('\n').pop() ?? '';
|
|
6
|
-
function cursorDown(n) {
|
|
7
|
-
return n > 0 ? ansiEscapes.cursorDown(n) : '';
|
|
8
|
-
}
|
|
9
6
|
export default class ScreenManager {
|
|
10
7
|
// These variables are keeping information to allow correct prompt re-rendering
|
|
11
8
|
height = 0;
|
|
@@ -54,30 +51,28 @@ export default class ScreenManager {
|
|
|
54
51
|
const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
|
|
55
52
|
// Return cursor to the input position (on top of the bottomContent)
|
|
56
53
|
if (bottomContentHeight > 0)
|
|
57
|
-
output +=
|
|
54
|
+
output += cursorUp(bottomContentHeight);
|
|
58
55
|
// Return cursor to the initial left offset.
|
|
59
|
-
output +=
|
|
56
|
+
output += cursorTo(this.cursorPos.cols);
|
|
60
57
|
/**
|
|
61
58
|
* Render and store state for future re-rendering
|
|
62
59
|
*/
|
|
63
|
-
this.write(cursorDown(this.extraLinesUnderPrompt) +
|
|
64
|
-
ansiEscapes.eraseLines(this.height) +
|
|
65
|
-
output);
|
|
60
|
+
this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
|
|
66
61
|
this.extraLinesUnderPrompt = bottomContentHeight;
|
|
67
62
|
this.height = height(output);
|
|
68
63
|
}
|
|
69
64
|
checkCursorPos() {
|
|
70
65
|
const cursorPos = this.rl.getCursorPos();
|
|
71
66
|
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
72
|
-
this.write(
|
|
67
|
+
this.write(cursorTo(cursorPos.cols));
|
|
73
68
|
this.cursorPos = cursorPos;
|
|
74
69
|
}
|
|
75
70
|
}
|
|
76
71
|
done({ clearContent }) {
|
|
77
72
|
this.rl.setPrompt('');
|
|
78
73
|
let output = cursorDown(this.extraLinesUnderPrompt);
|
|
79
|
-
output += clearContent ?
|
|
80
|
-
output +=
|
|
74
|
+
output += clearContent ? eraseLines(this.height) : '\n';
|
|
75
|
+
output += cursorShow;
|
|
81
76
|
this.write(output);
|
|
82
77
|
this.rl.close();
|
|
83
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/core",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.2",
|
|
4
4
|
"description": "Core Inquirer prompt API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"answer",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"tsc": "tshy"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
+
"@inquirer/ansi": "^1.0.0",
|
|
77
78
|
"@inquirer/figures": "^1.0.13",
|
|
78
79
|
"@inquirer/type": "^3.0.8",
|
|
79
|
-
"ansi-escapes": "^4.3.2",
|
|
80
80
|
"cli-width": "^4.1.0",
|
|
81
81
|
"mute-stream": "^2.0.0",
|
|
82
82
|
"signal-exit": "^4.1.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
88
|
-
"@inquirer/testing": "^2.1.
|
|
88
|
+
"@inquirer/testing": "^2.1.50",
|
|
89
89
|
"@types/mute-stream": "^0.0.4",
|
|
90
90
|
"@types/node": "^24.0.15",
|
|
91
91
|
"@types/wrap-ansi": "^3.0.0",
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
".": "./src/index.ts"
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "3fdf43342deb468ee41d698e407d8800700e08dc"
|
|
118
118
|
}
|