@inquirer/core 2.0.0 → 2.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/cjs/index.js
CHANGED
|
@@ -70,6 +70,10 @@ function useState(defaultValue) {
|
|
|
70
70
|
}
|
|
71
71
|
exports.useState = useState;
|
|
72
72
|
function useEffect(cb, depArray) {
|
|
73
|
+
const rl = sessionRl;
|
|
74
|
+
if (!rl) {
|
|
75
|
+
throw new Error('useEffect must be used within a prompt');
|
|
76
|
+
}
|
|
73
77
|
const _idx = index;
|
|
74
78
|
index++;
|
|
75
79
|
const oldDeps = hooks[_idx];
|
|
@@ -80,7 +84,7 @@ function useEffect(cb, depArray) {
|
|
|
80
84
|
if (hasChanged) {
|
|
81
85
|
hooksEffect.push(() => {
|
|
82
86
|
cleanupHook(_idx);
|
|
83
|
-
const cleanFn = cb();
|
|
87
|
+
const cleanFn = cb(rl);
|
|
84
88
|
if (cleanFn != null && typeof cleanFn !== 'function') {
|
|
85
89
|
throw new Error('useEffect return value must be a cleanup function or nothing.');
|
|
86
90
|
}
|
|
@@ -18,7 +18,7 @@ export type KeypressEvent = {
|
|
|
18
18
|
};
|
|
19
19
|
type NotFunction<T> = T extends Function ? never : T;
|
|
20
20
|
export declare function useState<Value>(defaultValue: NotFunction<Value> | (() => Value)): [Value, (newValue: Value) => void];
|
|
21
|
-
export declare function useEffect(cb: () => void | (() => void), depArray: unknown[]): void;
|
|
21
|
+
export declare function useEffect(cb: (rl: InquirerReadline) => void | (() => void), depArray: unknown[]): void;
|
|
22
22
|
export declare function useKeypress(userHandler: (event: KeypressEvent, rl: InquirerReadline) => void): void;
|
|
23
23
|
export declare function useRef<Value>(val: Value): {
|
|
24
24
|
current: Value;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -48,6 +48,10 @@ export function useState(defaultValue) {
|
|
|
48
48
|
];
|
|
49
49
|
}
|
|
50
50
|
export function useEffect(cb, depArray) {
|
|
51
|
+
const rl = sessionRl;
|
|
52
|
+
if (!rl) {
|
|
53
|
+
throw new Error('useEffect must be used within a prompt');
|
|
54
|
+
}
|
|
51
55
|
const _idx = index;
|
|
52
56
|
index++;
|
|
53
57
|
const oldDeps = hooks[_idx];
|
|
@@ -58,7 +62,7 @@ export function useEffect(cb, depArray) {
|
|
|
58
62
|
if (hasChanged) {
|
|
59
63
|
hooksEffect.push(() => {
|
|
60
64
|
cleanupHook(_idx);
|
|
61
|
-
const cleanFn = cb();
|
|
65
|
+
const cleanFn = cb(rl);
|
|
62
66
|
if (cleanFn != null && typeof cleanFn !== 'function') {
|
|
63
67
|
throw new Error('useEffect return value must be a cleanup function or nothing.');
|
|
64
68
|
}
|
|
@@ -18,7 +18,7 @@ export type KeypressEvent = {
|
|
|
18
18
|
};
|
|
19
19
|
type NotFunction<T> = T extends Function ? never : T;
|
|
20
20
|
export declare function useState<Value>(defaultValue: NotFunction<Value> | (() => Value)): [Value, (newValue: Value) => void];
|
|
21
|
-
export declare function useEffect(cb: () => void | (() => void), depArray: unknown[]): void;
|
|
21
|
+
export declare function useEffect(cb: (rl: InquirerReadline) => void | (() => void), depArray: unknown[]): void;
|
|
22
22
|
export declare function useKeypress(userHandler: (event: KeypressEvent, rl: InquirerReadline) => void): void;
|
|
23
23
|
export declare function useRef<Value>(val: Value): {
|
|
24
24
|
current: Value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=14.18.0"
|
|
6
6
|
},
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "d48ecde923e5875de631f7b50f67cfaf00384947"
|
|
98
98
|
}
|