@inquirer/core 12.0.3 → 12.0.4

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/README.md CHANGED
@@ -8,21 +8,53 @@ It aims to implements a lightweight API similar to React hooks - but without JSX
8
8
 
9
9
  <table>
10
10
  <tr>
11
- <th>npm</th>
12
11
  <th>yarn</th>
12
+ <th>pnpm</th>
13
13
  </tr>
14
14
  <tr>
15
15
  <td>
16
16
 
17
17
  ```sh
18
- npm install @inquirer/core
18
+ yarn add @inquirer/core
19
19
  ```
20
20
 
21
21
  </td>
22
22
  <td>
23
23
 
24
24
  ```sh
25
- yarn add @inquirer/core
25
+ pnpm add @inquirer/core
26
+ ```
27
+
28
+ </td>
29
+ </tr>
30
+ <tr>
31
+ <th>bun</th>
32
+ <th>deno</th>
33
+ </tr>
34
+ <tr>
35
+ <td>
36
+
37
+ ```sh
38
+ bun add @inquirer/core
39
+ ```
40
+
41
+ </td>
42
+ <td>
43
+
44
+ ```sh
45
+ deno add npm:@inquirer/core
46
+ ```
47
+
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <th colSpan="2">npm</th>
52
+ </tr>
53
+ <tr>
54
+ <td colSpan="2">
55
+
56
+ ```sh
57
+ npm install @inquirer/core
26
58
  ```
27
59
 
28
60
  </td>
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,4 @@
1
+ export function f(x) {
2
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion
3
+ return x;
4
+ }
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,3 @@
1
+ export function f(x) {
2
+ return x; // oxlint-disable-line typescript/no-unsafe-type-assertion
3
+ }
@@ -0,0 +1,9 @@
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 {};
@@ -0,0 +1,5 @@
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 */
@@ -1,9 +1,9 @@
1
1
  import * as readline from 'node:readline';
2
2
  import { AsyncResource } from 'node:async_hooks';
3
+ import { withResolver } from '@inquirer/type';
3
4
  import MuteStream from 'mute-stream';
4
5
  import { onExit as onSignalExit } from 'signal-exit';
5
6
  import ScreenManager from "./screen-manager.js";
6
- import { PromisePolyfill } from "./promise-polyfill.js";
7
7
  import { withHooks, effectScheduler } from "./hook-engine.js";
8
8
  import { AbortPromptError, CancelPromptError, ExitPromptError } from "./errors.js";
9
9
  import path from 'node:path';
@@ -52,19 +52,20 @@ export function createPrompt(view) {
52
52
  // Add mute capabilities to the output
53
53
  const output = new MuteStream();
54
54
  output.pipe(context.output ?? process.stdout);
55
- // oxlint-disable-next-line typescript/no-unsafe-type-assertion
55
+ /* oxlint-disable typescript/no-unsafe-type-assertion */
56
56
  const rl = readline.createInterface({
57
57
  terminal: true,
58
58
  input,
59
59
  output,
60
60
  });
61
+ /* oxlint-enable typescript/no-unsafe-type-assertion */
61
62
  // Mute the output after readline has initialized so readline can perform
62
63
  // any terminal setup writes (e.g. Windows Console API initialization)
63
64
  // before suppressing output. ScreenManager will unmute/mute around each
64
65
  // render call as needed.
65
66
  output.mute();
66
67
  const screen = new ScreenManager(rl);
67
- const { promise, resolve, reject } = PromisePolyfill.withResolver();
68
+ const { promise, resolve, reject } = withResolver();
68
69
  return withHooks(rl, (cycle) => {
69
70
  // Clear hook effects synchronously before the prompt settles: readline
70
71
  // emits keypresses synchronously within a single data event, so a
@@ -16,16 +16,14 @@ function createStore(rl) {
16
16
  // Run callback in with the hook engine setup.
17
17
  export function withHooks(rl, cb) {
18
18
  const store = createStore(rl);
19
- return hookStorage.run(store, () => {
20
- function cycle(render) {
21
- store.handleChange = () => {
22
- store.index = 0;
23
- render();
24
- };
25
- store.handleChange();
26
- }
27
- return cb(cycle);
28
- });
19
+ function cycle(render) {
20
+ store.handleChange = () => {
21
+ store.index = 0;
22
+ render();
23
+ };
24
+ store.handleChange();
25
+ }
26
+ return hookStorage.run(store, () => cb(cycle));
29
27
  }
30
28
  // Safe getStore utility that'll return the store or throw if undefined.
31
29
  function getStore() {
@@ -23,11 +23,11 @@ function deepMerge(...objects) {
23
23
  return output;
24
24
  }
25
25
  export function makeTheme(...themes) {
26
- // oxlint-disable-next-line typescript/no-unsafe-type-assertion
26
+ /* oxlint-disable typescript/no-unsafe-type-assertion */
27
27
  const themesToMerge = [
28
28
  getDefaultTheme(),
29
29
  ...themes.filter((theme) => theme != null),
30
30
  ];
31
- // oxlint-disable-next-line typescript/no-unsafe-type-assertion
32
31
  return deepMerge(...themesToMerge);
32
+ /* oxlint-enable typescript/no-unsafe-type-assertion */
33
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/core",
3
- "version": "12.0.3",
3
+ "version": "12.0.4",
4
4
  "description": "Core Inquirer prompt API",
5
5
  "keywords": [
6
6
  "answer",
@@ -67,9 +67,9 @@
67
67
  "tsc": "tsc"
68
68
  },
69
69
  "dependencies": {
70
- "@inquirer/ansi": "^2.0.8",
70
+ "@inquirer/ansi": "^2.0.9",
71
71
  "@inquirer/figures": "^2.0.9",
72
- "@inquirer/type": "4.1.1",
72
+ "@inquirer/type": "4.2.0",
73
73
  "cli-width": "^4.1.0",
74
74
  "fast-wrap-ansi": "^0.2.0",
75
75
  "mute-stream": "^3.0.0",
@@ -94,5 +94,5 @@
94
94
  },
95
95
  "main": "./dist/index.js",
96
96
  "types": "./dist/index.d.ts",
97
- "gitHead": "cbdb34bfc6c245941d80ef88493c50b3d6dbfce6"
97
+ "gitHead": "a9436bd94d55a439df308f50e77a7cd0b2078e98"
98
98
  }
@@ -1,7 +0,0 @@
1
- export declare class PromisePolyfill<T> extends Promise<T> {
2
- static withResolver<T>(): {
3
- promise: Promise<T>;
4
- resolve: (value: T) => void;
5
- reject: (error: unknown) => void;
6
- };
7
- }
@@ -1,14 +0,0 @@
1
- // TODO: Remove this class once Node 22 becomes the minimum supported version.
2
- export class PromisePolyfill extends Promise {
3
- // Available starting from Node 22
4
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
5
- static withResolver() {
6
- let resolve;
7
- let reject;
8
- const promise = new Promise((res, rej) => {
9
- resolve = res;
10
- reject = rej;
11
- });
12
- return { promise, resolve: resolve, reject: reject };
13
- }
14
- }