Skip to content

Commit

Permalink
Major(@inquirer/core): Move InquirerReadline type to the @inquirer/ty…
Browse files Browse the repository at this point in the history
…pe package
  • Loading branch information
SBoudrias committed Jun 29, 2024
1 parent 057cee7 commit 8ad0d1a
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 16 deletions.
1 change: 0 additions & 1 deletion packages/core/src/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ export type { Theme } from './lib/theme.mjs';
export { usePagination } from './lib/pagination/use-pagination.mjs';
export { createPrompt } from './lib/create-prompt.mjs';
export { Separator } from './lib/Separator.mjs';
export { type InquirerReadline } from './lib/read-line.type.mjs';
2 changes: 1 addition & 1 deletion packages/core/src/lib/create-prompt.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CancelablePromise, type Prompt, type Prettify } from '@inquirer/type';
import MuteStream from 'mute-stream';
import { onExit as onSignalExit } from 'signal-exit';
import ScreenManager from './screen-manager.mjs';
import type { InquirerReadline } from './read-line.type.mjs';
import type { InquirerReadline } from '@inquirer/type';
import { withHooks, effectScheduler } from './hook-engine.mjs';
import { CancelPromptError, ExitPromptError } from './errors.mjs';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/hook-engine.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint @typescript-eslint/no-explicit-any: ["off"] */

import { AsyncLocalStorage, AsyncResource } from 'node:async_hooks';
import type { InquirerReadline } from './read-line.type.mjs';
import type { InquirerReadline } from '@inquirer/type';
import { HookError, ValidationError } from './errors.mjs';

type HookStore = {
Expand Down
8 changes: 0 additions & 8 deletions packages/core/src/lib/read-line.type.mts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/core/src/lib/screen-manager.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { CursorPos } from 'node:readline';
import stripAnsi from 'strip-ansi';
import ansiEscapes from 'ansi-escapes';
import { breakLines, readlineWidth } from './utils.mjs';
import type { InquirerReadline } from './read-line.type.mjs';
import type { InquirerReadline } from '@inquirer/type';

const height = (content: string): number => content.split('\n').length;
const lastLine = (content: string): string => content.split('\n').pop() ?? '';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/use-effect.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { withPointer, effectScheduler } from './hook-engine.mjs';
import type { InquirerReadline } from './read-line.type.mjs';
import type { InquirerReadline } from '@inquirer/type';

export function useEffect(
cb: (rl: InquirerReadline) => void | (() => void),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/use-keypress.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type InquirerReadline } from './read-line.type.mjs';
import { type InquirerReadline } from '@inquirer/type';
import { type KeypressEvent } from './key.mjs';
import { useRef } from './use-ref.mjs';
import { useEffect } from './use-effect.mjs';
Expand Down
3 changes: 1 addition & 2 deletions packages/editor/src/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import {
usePrefix,
isEnterKey,
makeTheme,
type InquirerReadline,
type Theme,
} from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
import type { PartialDeep, InquirerReadline } from '@inquirer/type';

type EditorConfig = {
message: string;
Expand Down
3 changes: 3 additions & 0 deletions packages/type/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
],
"author": "Simon Boudrias <admin@simonboudrias.com>",
"license": "MIT",
"dependencies": {
"mute-stream": "^1.0.0"
},
"scripts": {
"tsc": "yarn run tsc:esm && yarn run tsc:cjs",
"tsc:esm": "rm -rf dist/esm && tsc -p ./tsconfig.json",
Expand Down
9 changes: 9 additions & 0 deletions packages/type/src/index.mts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import * as readline from 'node:readline';
import MuteStream from 'mute-stream';

export type InquirerReadline = readline.ReadLine & {
output: MuteStream;
input: NodeJS.ReadableStream;
clearLine: (dir: 0 | 1 | -1) => void; // https://nodejs.org/api/readline.html#rlclearlinedir
};

export class CancelablePromise<T> extends Promise<T> {
public cancel: () => void = () => {};
}
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ __metadata:
"@inquirer/type@npm:^1.3.3, @inquirer/type@workspace:packages/type":
version: 0.0.0-use.local
resolution: "@inquirer/type@workspace:packages/type"
dependencies:
mute-stream: "npm:^1.0.0"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 8ad0d1a

Please sign in to comment.