Socket
Socket
Sign inDemoInstall

@inquirer/core

Package Overview
Dependencies
Maintainers
3
Versions
82
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 0.0.24-alpha.0 to 0.0.25-alpha.0

6

dist/index.d.ts

@@ -8,5 +8,6 @@ /// <reference types="node" resolution-mode="require"/>

export * from './lib/Paginator.js';
declare type StdioOptions = {
declare type Context = {
input?: NodeJS.ReadableStream;
output?: NodeJS.WritableStream;
clearPromptOnDone?: boolean;
};

@@ -35,2 +36,3 @@ export declare type InquirerReadline = readline.ReadLine & {

};
export declare function createPrompt<Value, Config extends AsyncPromptConfig>(view: (config: Config & ResolvedPromptConfig, done: (value: Value) => void) => string | [string, string | undefined]): (options: Config, stdio?: StdioOptions) => Promise<Value>;
export declare type Prompt<Value, Config> = (options: Config, context?: Context) => Promise<Value>;
export declare function createPrompt<Value, Config extends AsyncPromptConfig>(view: (config: Config & ResolvedPromptConfig, done: (value: Value) => void) => string | [string, string | undefined]): Prompt<Value, Config>;

@@ -21,6 +21,8 @@ import readline from 'node:readline';

const _idx = index;
const value = _idx in hooks ? hooks[_idx] : defaultValue;
index++;
if (!(_idx in hooks)) {
hooks[_idx] = defaultValue;
}
return [
value,
hooks[_idx],
(newValue) => {

@@ -35,2 +37,3 @@ hooks[_idx] = newValue;

const _idx = index;
index++;
const oldDeps = hooks[_idx];

@@ -46,3 +49,2 @@ let hasChanged = true;

hooks[_idx] = depArray;
index++;
}

@@ -68,8 +70,8 @@ export function useKeypress(userHandler) {

export function createPrompt(view) {
return async function (options, stdio) {
const prompt = async (options, context) => {
// Default `input` to stdin
const input = stdio?.input ?? process.stdin;
const input = context?.input ?? process.stdin;
// Add mute capabilities to the output
const output = new MuteStream();
output.pipe(stdio?.output ?? process.stdout);
output.pipe(context?.output ?? process.stdout);
const rl = readline.createInterface({

@@ -89,2 +91,8 @@ terminal: true,

}
if (context?.clearPromptOnDone) {
screen.clean();
}
else {
screen.clearContent();
}
screen.done();

@@ -98,2 +106,3 @@ // Reset hooks state

};
index = 0;
hooks = [];

@@ -111,2 +120,3 @@ const workLoop = (config) => {

};
return prompt;
}

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

render(content: string, bottomContent?: string): void;
clean(extraLines: number): void;
clean(): void;
clearContent(): void;
done(): void;
}

@@ -33,4 +33,4 @@ import cliWidth from 'cli-width';

render(content, bottomContent = '') {
this.clean();
this.rl.output.unmute();
this.clean(this.extraLinesUnderPrompt);
/**

@@ -81,15 +81,23 @@ * Write message to screen and setPrompt to control backspace

}
clean(extraLines) {
util.down(this.rl, extraLines);
clean() {
this.rl.output.unmute();
util.down(this.rl, this.extraLinesUnderPrompt);
util.clearLine(this.rl, this.height);
this.extraLinesUnderPrompt = 0;
this.rl.output.mute();
}
done() {
clearContent() {
this.rl.output.unmute();
// Reset the cursor at the end of the previously displayed content
util.down(this.rl, this.extraLinesUnderPrompt);
this.rl.output.write('\n');
this.rl.output.mute();
}
done() {
this.rl.setPrompt('');
this.rl.output.unmute();
this.rl.output.write('\n');
this.rl.output.write(ansiEscapes.cursorShow);
this.rl.output.end();
this.rl.close();
}
}
{
"name": "@inquirer/core",
"type": "module",
"version": "0.0.24-alpha.0",
"version": "0.0.25-alpha.0",
"description": "Core Inquirer prompt API",

@@ -32,2 +32,5 @@ "main": "dist/index.js",

},
"devDependencies": {
"@inquirer/testing": "^0.0.1-alpha.0"
},
"scripts": {

@@ -39,3 +42,3 @@ "tsc": "tsc"

},
"gitHead": "0e054fd0b58bf56e94088136dfd36b74246a5187"
"gitHead": "ec30ebf811b25a9e60b3bb50186a91394914caf6"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc