ink-testing-library
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -19,2 +19,6 @@ /// <reference types="node" resolution-mode="require"/> | ||
isTTY: boolean; | ||
data: string | null; | ||
constructor(options?: { | ||
isTTY?: boolean; | ||
}); | ||
write: (data: string) => void; | ||
@@ -25,2 +29,5 @@ setEncoding(): void; | ||
pause(): void; | ||
ref(): void; | ||
unref(): void; | ||
read: () => string | null; | ||
} | ||
@@ -27,0 +34,0 @@ type Instance = { |
import { EventEmitter } from 'node:events'; | ||
import { render as inkRender } from 'ink'; | ||
class Stdout extends EventEmitter { | ||
constructor() { | ||
super(...arguments); | ||
Object.defineProperty(this, "frames", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: [] | ||
}); | ||
Object.defineProperty(this, "_lastFrame", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "write", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: (frame) => { | ||
this.frames.push(frame); | ||
this._lastFrame = frame; | ||
} | ||
}); | ||
Object.defineProperty(this, "lastFrame", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: () => this._lastFrame | ||
}); | ||
} | ||
get columns() { | ||
return 100; | ||
} | ||
frames = []; | ||
_lastFrame; | ||
write = (frame) => { | ||
this.frames.push(frame); | ||
this._lastFrame = frame; | ||
}; | ||
lastFrame = () => this._lastFrame; | ||
} | ||
class Stderr extends EventEmitter { | ||
constructor() { | ||
super(...arguments); | ||
Object.defineProperty(this, "frames", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: [] | ||
}); | ||
Object.defineProperty(this, "_lastFrame", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "write", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: (frame) => { | ||
this.frames.push(frame); | ||
this._lastFrame = frame; | ||
} | ||
}); | ||
Object.defineProperty(this, "lastFrame", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: () => this._lastFrame | ||
}); | ||
} | ||
frames = []; | ||
_lastFrame; | ||
write = (frame) => { | ||
this.frames.push(frame); | ||
this._lastFrame = frame; | ||
}; | ||
lastFrame = () => this._lastFrame; | ||
} | ||
class Stdin extends EventEmitter { | ||
constructor() { | ||
super(...arguments); | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
Object.defineProperty(this, "isTTY", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: true | ||
}); | ||
Object.defineProperty(this, "write", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: (data) => { | ||
this.emit('data', data); | ||
} | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
isTTY = true; | ||
data = null; // eslint-disable-line @typescript-eslint/ban-types | ||
constructor(options = {}) { | ||
super(); | ||
this.isTTY = options.isTTY ?? true; | ||
} | ||
write = (data) => { | ||
this.data = data; | ||
this.emit('readable'); | ||
this.emit('data', data); | ||
}; | ||
setEncoding() { | ||
@@ -101,2 +49,14 @@ // Do nothing | ||
} | ||
ref() { | ||
// Do nothing | ||
} | ||
unref() { | ||
// Do nothing | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
read = () => { | ||
const { data } = this; | ||
this.data = null; | ||
return data; | ||
}; | ||
} | ||
@@ -117,3 +77,3 @@ const instances = []; | ||
exitOnCtrlC: false, | ||
patchConsole: false | ||
patchConsole: false, | ||
}); | ||
@@ -129,3 +89,3 @@ instances.push(instance); | ||
frames: stdout.frames, | ||
lastFrame: stdout.lastFrame | ||
lastFrame: stdout.lastFrame, | ||
}; | ||
@@ -132,0 +92,0 @@ }; |
{ | ||
"name": "ink-testing-library", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Utilities for testing Ink apps", | ||
@@ -18,3 +18,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=14.16" | ||
"node": ">=18" | ||
}, | ||
@@ -35,16 +35,16 @@ "scripts": { | ||
"devDependencies": { | ||
"@sindresorhus/tsconfig": "^3.0.1", | ||
"@types/react": "^18.0.0", | ||
"@vdemedes/prettier-config": "^1.0.1", | ||
"ava": "^5.1.1", | ||
"delay": "^5.0.0", | ||
"@sindresorhus/tsconfig": "^5.0.0", | ||
"@types/react": "^18.3.2", | ||
"@vdemedes/prettier-config": "^2.0.1", | ||
"ava": "^6.1.3", | ||
"delay": "^6.0.0", | ||
"eslint-config-xo-react": "^0.27.0", | ||
"eslint-plugin-react": "^7.32.2", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"ink": "^4.0.0", | ||
"prettier": "^2.0.4", | ||
"react": "^18.0.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.4", | ||
"xo": "^0.53.0" | ||
"eslint-plugin-react": "^7.34.1", | ||
"eslint-plugin-react-hooks": "^4.6.2", | ||
"ink": "^5.0.0", | ||
"prettier": "^3.2.5", | ||
"react": "^18.3.1", | ||
"tsimp": "^2.0.11", | ||
"typescript": "^5.4.5", | ||
"xo": "^0.58.0" | ||
}, | ||
@@ -65,3 +65,3 @@ "peerDependencies": { | ||
"nodeArguments": [ | ||
"--loader=ts-node/esm" | ||
"--import=tsimp" | ||
] | ||
@@ -71,5 +71,8 @@ }, | ||
"extends": "xo-react", | ||
"prettier": true | ||
"prettier": true, | ||
"rules": { | ||
"unicorn/prefer-event-target": "off" | ||
} | ||
}, | ||
"prettier": "@vdemedes/prettier-config" | ||
} |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
10991
139
1