fix: maxListeners warning (#240)
This commit is contained in:
11
vendor/ink/build/components/App.js
vendored
11
vendor/ink/build/components/App.js
vendored
@@ -12,6 +12,9 @@ import StdoutContext from './StdoutContext.js';
|
|||||||
const tab = '\t';
|
const tab = '\t';
|
||||||
const shiftTab = '\u001B[Z';
|
const shiftTab = '\u001B[Z';
|
||||||
const escape = '\u001B';
|
const escape = '\u001B';
|
||||||
|
// Maximum number of event listeners to allow on stdin and internal_eventEmitter.
|
||||||
|
const MAX_INPUT_LISTENERS = 20;
|
||||||
|
|
||||||
export default class App extends PureComponent {
|
export default class App extends PureComponent {
|
||||||
static displayName = 'InternalApp';
|
static displayName = 'InternalApp';
|
||||||
static getDerivedStateFromError(error) {
|
static getDerivedStateFromError(error) {
|
||||||
@@ -27,7 +30,7 @@ export default class App extends PureComponent {
|
|||||||
// Increase max listeners to accommodate multiple useInput hooks across components
|
// Increase max listeners to accommodate multiple useInput hooks across components
|
||||||
internal_eventEmitter = (() => {
|
internal_eventEmitter = (() => {
|
||||||
const emitter = new EventEmitter();
|
const emitter = new EventEmitter();
|
||||||
emitter.setMaxListeners(20);
|
emitter.setMaxListeners(MAX_INPUT_LISTENERS);
|
||||||
return emitter;
|
return emitter;
|
||||||
})();
|
})();
|
||||||
isRawModeSupported() {
|
isRawModeSupported() {
|
||||||
@@ -42,6 +45,10 @@ export default class App extends PureComponent {
|
|||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
cliCursor.hide(this.props.stdout);
|
cliCursor.hide(this.props.stdout);
|
||||||
|
// Increase max listeners on stdin to accommodate multiple useInput hooks
|
||||||
|
if (this.props.stdin?.setMaxListeners) {
|
||||||
|
this.props.stdin.setMaxListeners(MAX_INPUT_LISTENERS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
cliCursor.show(this.props.stdout);
|
cliCursor.show(this.props.stdout);
|
||||||
@@ -62,6 +69,8 @@ export default class App extends PureComponent {
|
|||||||
throw new Error('Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
|
throw new Error('Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Increase max listeners on stdin to accommodate multiple useInput hooks
|
||||||
|
stdin.setMaxListeners(MAX_INPUT_LISTENERS);
|
||||||
stdin.setEncoding('utf8');
|
stdin.setEncoding('utf8');
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
if (this.rawModeEnabledCount === 0) {
|
if (this.rawModeEnabledCount === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user