@inquirer/core 12.0.5 → 12.1.0

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.
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- export { isUpKey, isDownKey, isSpaceKey, isBackspaceKey, isTabKey, isNumberKey, isEnterKey, isShiftKey, } from "./lib/key.js";
2
- export * from "./lib/errors.js";
3
- export { usePrefix } from "./lib/use-prefix.js";
4
- export { useState } from "./lib/use-state.js";
5
- export { useEffect } from "./lib/use-effect.js";
6
- export { useMemo } from "./lib/use-memo.js";
7
- export { useRef } from "./lib/use-ref.js";
8
- export { useKeypress } from "./lib/use-keypress.js";
9
- export { makeTheme } from "./lib/make-theme.js";
10
- export { usePagination } from "./lib/pagination/use-pagination.js";
11
- export { createPrompt } from "./lib/create-prompt.js";
12
- export { Separator } from "./lib/Separator.js";
1
+ export { isUpKey, isDownKey, isSpaceKey, isBackspaceKey, isTabKey, isNumberKey, isEnterKey, isShiftKey, } from './lib/key.js';
2
+ export * from './lib/errors.js';
3
+ export { usePrefix } from './lib/use-prefix.js';
4
+ export { useState } from './lib/use-state.js';
5
+ export { useEffect } from './lib/use-effect.js';
6
+ export { useMemo } from './lib/use-memo.js';
7
+ export { useRef } from './lib/use-ref.js';
8
+ export { useKeypress } from './lib/use-keypress.js';
9
+ export { makeTheme } from './lib/make-theme.js';
10
+ export { usePagination } from './lib/pagination/use-pagination.js';
11
+ export { createPrompt } from './lib/create-prompt.js';
12
+ export { Separator } from './lib/Separator.js';
@@ -3,9 +3,9 @@ import { AsyncResource } from 'node:async_hooks';
3
3
  import { withResolver } from '@inquirer/type';
4
4
  import MuteStream from 'mute-stream';
5
5
  import { onExit as onSignalExit } from 'signal-exit';
6
- import ScreenManager from "./screen-manager.js";
7
- import { withHooks, effectScheduler } from "./hook-engine.js";
8
- import { AbortPromptError, CancelPromptError, ExitPromptError } from "./errors.js";
6
+ import ScreenManager from './screen-manager.js';
7
+ import { withHooks, effectScheduler } from './hook-engine.js';
8
+ import { AbortPromptError, CancelPromptError, ExitPromptError } from './errors.js';
9
9
  import path from 'node:path';
10
10
  // Capture the real setImmediate at module load time so it works even when test
11
11
  // frameworks mock timers with vi.useFakeTimers() or similar.
@@ -169,11 +169,18 @@ export function createPrompt(view) {
169
169
  // poll) lets that stale data flow through readline harmlessly—no keypress
170
170
  // handlers are registered yet and the output is muted, so the stale
171
171
  // keystrokes are silently discarded.
172
+ // This only applies to TTY inputs, where early data is stale keystrokes
173
+ // the user typed before the prompt started. Piped input (stdin from a
174
+ // script or test harness) is intentional: deferring there risks dropping
175
+ // the answer itself, since data already waiting on the pipe flows
176
+ // through readline during the deferral tick and is then discarded,
177
+ // leaving the prompt waiting forever (seen as intermittent 30s timeouts
178
+ // in the Deno integration suite).
172
179
  // Old-style streams (like MuteStream) have no such buffering, so the
173
180
  // render cycle starts immediately.
174
181
  //
175
182
  // @see https://github.com/SBoudrias/Inquirer.js/issues/1303
176
- if ('readableFlowing' in input) {
183
+ if ('readableFlowing' in input && input.isTTY) {
177
184
  const immediate = nativeSetImmediate(startCycle);
178
185
  cleanups.add(() => nativeClearImmediate(immediate));
179
186
  }
@@ -1,6 +1,6 @@
1
1
  /* eslint @typescript-eslint/no-explicit-any: ["off"] */
2
2
  import { AsyncLocalStorage, AsyncResource } from 'node:async_hooks';
3
- import { HookError, ValidationError } from "./errors.js";
3
+ import { HookError, ValidationError } from './errors.js';
4
4
  const hookStorage = new AsyncLocalStorage();
5
5
  function createStore(rl) {
6
6
  const store = {
@@ -1,4 +1,4 @@
1
- import { getDefaultTheme } from "./theme.js";
1
+ import { getDefaultTheme } from './theme.js';
2
2
  function isPlainObject(value) {
3
3
  if (typeof value !== 'object' || value === null)
4
4
  return false;
@@ -12,6 +12,9 @@ function deepMerge(...objects) {
12
12
  const output = {};
13
13
  for (const obj of objects) {
14
14
  for (const [key, value] of Object.entries(obj)) {
15
+ // A key explicitly set to `undefined` keeps the value from the previous theme.
16
+ if (value === undefined)
17
+ continue;
15
18
  const prevValue = output[key];
16
19
  output[key] =
17
20
  isPlainObject(prevValue) && isPlainObject(value)
@@ -1,5 +1,5 @@
1
- import { useRef } from "../use-ref.js";
2
- import { readlineWidth, breakLines } from "../utils.js";
1
+ import { useRef } from '../use-ref.js';
2
+ import { readlineWidth, breakLines } from '../utils.js';
3
3
  function usePointerPosition({ active, renderedItems, pageSize, loop, }) {
4
4
  const state = useRef({
5
5
  lastPointer: active,
@@ -1,5 +1,5 @@
1
1
  import { stripVTControlCharacters } from 'node:util';
2
- import { breakLines, readlineWidth } from "./utils.js";
2
+ import { breakLines, readlineWidth } from './utils.js';
3
3
  import { cursorDown, cursorLeft, 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() ?? '';
package/dist/lib/theme.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { styleText } from 'node:util';
2
2
  import figures from '@inquirer/figures';
3
- import { getDefaultKeybindings } from "./key.js";
3
+ import { getDefaultKeybindings } from './key.js';
4
4
  export const defaultTheme = {
5
5
  prefix: {
6
6
  idle: styleText('blue', '?'),
@@ -1,4 +1,4 @@
1
- import { withPointer, effectScheduler } from "./hook-engine.js";
1
+ import { withPointer, effectScheduler } from './hook-engine.js';
2
2
  export function useEffect(cb, depArray) {
3
3
  withPointer((pointer) => {
4
4
  const oldDeps = pointer.get();
@@ -1,6 +1,6 @@
1
- import { useRef } from "./use-ref.js";
2
- import { useEffect } from "./use-effect.js";
3
- import { withUpdates } from "./hook-engine.js";
1
+ import { useRef } from './use-ref.js';
2
+ import { useEffect } from './use-effect.js';
3
+ import { withUpdates } from './hook-engine.js';
4
4
  export function useKeypress(userHandler) {
5
5
  const signal = useRef(userHandler);
6
6
  signal.current = userHandler;
@@ -1,4 +1,4 @@
1
- import { withPointer } from "./hook-engine.js";
1
+ import { withPointer } from './hook-engine.js';
2
2
  export function useMemo(fn, dependencies) {
3
3
  return withPointer((pointer) => {
4
4
  const prev = pointer.get();
@@ -1,6 +1,6 @@
1
- import { useState } from "./use-state.js";
2
- import { useEffect } from "./use-effect.js";
3
- import { makeTheme } from "./make-theme.js";
1
+ import { useState } from './use-state.js';
2
+ import { useEffect } from './use-effect.js';
3
+ import { makeTheme } from './make-theme.js';
4
4
  export function usePrefix({ status = 'idle', theme, }) {
5
5
  const [showLoader, setShowLoader] = useState(false);
6
6
  const [tick, setTick] = useState(0);
@@ -1,4 +1,4 @@
1
- import { useState } from "./use-state.js";
1
+ import { useState } from './use-state.js';
2
2
  export function useRef(val) {
3
3
  return useState({ current: val })[0];
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import { AsyncResource } from 'node:async_hooks';
2
- import { withPointer, handleChange } from "./hook-engine.js";
2
+ import { withPointer, handleChange } from './hook-engine.js';
3
3
  function isFactory(value) {
4
4
  return typeof value === 'function';
5
5
  }
package/dist/lib/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import cliWidth from 'cli-width';
2
2
  import { wrapAnsi } from 'fast-wrap-ansi';
3
- import { readline } from "./hook-engine.js";
3
+ import { readline } from './hook-engine.js';
4
4
  /**
5
5
  * Force line returns at specific width. This function is ANSI code friendly and it'll
6
6
  * ignore invisible codes during width calculation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/core",
3
- "version": "12.0.5",
3
+ "version": "12.1.0",
4
4
  "description": "Core Inquirer prompt API",
5
5
  "keywords": [
6
6
  "answer",
@@ -41,7 +41,7 @@
41
41
  "yo",
42
42
  "zsh"
43
43
  ],
44
- "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/core/README.md",
44
+ "homepage": "https://github.com/SBoudrias/Inquirer.js/blob/HEAD/packages/core/README.md",
45
45
  "license": "MIT",
46
46
  "author": "Simon Boudrias <admin@simonboudrias.com>",
47
47
  "repository": {
@@ -67,19 +67,19 @@
67
67
  "tsc": "tsc"
68
68
  },
69
69
  "dependencies": {
70
- "@inquirer/ansi": "^2.0.9",
71
- "@inquirer/figures": "^2.0.9",
72
- "@inquirer/type": "4.2.0",
70
+ "@inquirer/ansi": "^2.1.0",
71
+ "@inquirer/figures": "^2.1.0",
72
+ "@inquirer/type": "4.3.0",
73
73
  "cli-width": "^4.1.0",
74
74
  "fast-wrap-ansi": "^0.2.0",
75
- "mute-stream": "^3.0.0",
75
+ "mute-stream": "^4.0.0",
76
76
  "signal-exit": "^4.1.0"
77
77
  },
78
78
  "devDependencies": {
79
- "@repo/tsconfig": "0.0.0",
79
+ "@repo/tsconfig": "0.1.0",
80
80
  "@types/mute-stream": "^0.0.4",
81
81
  "@types/node": "^26.1.1",
82
- "typescript": "^6.0.2"
82
+ "typescript": "^7.0.2"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@types/node": ">=18"
@@ -90,9 +90,9 @@
90
90
  }
91
91
  },
92
92
  "engines": {
93
- "node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
93
+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
94
94
  },
95
95
  "main": "./dist/index.js",
96
96
  "types": "./dist/index.d.ts",
97
- "gitHead": "ea3130ebc609a6a3910b5397244044de7eda3d05"
97
+ "gitHead": "00ded073f80523aaeaf8a903bbfb535994990475"
98
98
  }
@@ -1,9 +0,0 @@
1
- type A = {
2
- a: string;
3
- };
4
- type B = {
5
- a: string;
6
- b: number;
7
- };
8
- export declare function f(x: A): B;
9
- export {};
@@ -1,4 +0,0 @@
1
- export function f(x) {
2
- // oxlint-disable-next-line typescript/no-unsafe-type-assertion
3
- return x;
4
- }
@@ -1,9 +0,0 @@
1
- type A = {
2
- a: string;
3
- };
4
- type B = {
5
- a: string;
6
- b: number;
7
- };
8
- export declare function f(x: A): B;
9
- export {};
@@ -1,3 +0,0 @@
1
- export function f(x) {
2
- return x; // oxlint-disable-line typescript/no-unsafe-type-assertion
3
- }
@@ -1,9 +0,0 @@
1
- type A = {
2
- a: string;
3
- };
4
- type B = {
5
- a: string;
6
- b: number;
7
- };
8
- export declare function f(x: A): B;
9
- export {};
@@ -1,5 +0,0 @@
1
- /* oxlint-disable typescript/no-unsafe-type-assertion */
2
- export function f(x) {
3
- return x;
4
- }
5
- /* oxlint-enable typescript/no-unsafe-type-assertion */