bare-tty 5.2.0 → 5.2.2
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 +4 -0
- package/binding.c +1 -0
- package/index.d.ts +18 -0
- package/index.js +11 -3
- package/lib/constants.d.ts +5 -1
- package/lib/constants.js +3 -0
- package/package.json +1 -1
- package/prebuilds/android-arm/bare-tty.bare +0 -0
- package/prebuilds/android-arm64/bare-tty.bare +0 -0
- package/prebuilds/android-ia32/bare-tty.bare +0 -0
- package/prebuilds/android-x64/bare-tty.bare +0 -0
- package/prebuilds/darwin-arm64/bare-tty.bare +0 -0
- package/prebuilds/darwin-x64/bare-tty.bare +0 -0
- package/prebuilds/ios-arm64/bare-tty.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-tty.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-tty.bare +0 -0
- package/prebuilds/linux-arm64/bare-tty.bare +0 -0
- package/prebuilds/linux-x64/bare-tty.bare +0 -0
- package/prebuilds/win32-arm64/bare-tty.bare +0 -0
- package/prebuilds/win32-x64/bare-tty.bare +0 -0
package/README.md
CHANGED
package/binding.c
CHANGED
package/index.d.ts
CHANGED
|
@@ -7,14 +7,22 @@ interface ReadStreamOptions extends ReadableOptions {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
interface ReadStream extends Readable {
|
|
10
|
+
/** The stream's underlying file descriptor. */
|
|
10
11
|
readonly fd: number
|
|
12
|
+
/** Always `true`, identifying the stream as a TTY. */
|
|
11
13
|
readonly isTTY: true
|
|
12
14
|
|
|
15
|
+
/** Set the TTY mode directly, using one of the `constants.mode` values. Returns the stream. */
|
|
13
16
|
setMode(mode: number): this
|
|
17
|
+
/**
|
|
18
|
+
* Enable or disable raw mode. In raw mode, input is delivered byte-by-byte without line buffering
|
|
19
|
+
* or special key processing. Returns the stream.
|
|
20
|
+
*/
|
|
14
21
|
setRawMode(mode: boolean): this
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
declare class ReadStream extends Readable {
|
|
25
|
+
/** Create a `ReadStream` for the TTY file descriptor `fd`. */
|
|
18
26
|
constructor(fd: number, opts?: ReadStreamOptions)
|
|
19
27
|
}
|
|
20
28
|
|
|
@@ -23,18 +31,28 @@ interface WriteStreamEvents extends WritableEvents {
|
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
interface WriteStream<M extends WriteStreamEvents = WriteStreamEvents> extends Writable<M> {
|
|
34
|
+
/** The stream's underlying file descriptor. */
|
|
26
35
|
readonly fd: number
|
|
36
|
+
/** Always `true`, identifying the stream as a TTY. */
|
|
27
37
|
readonly isTTY: true
|
|
38
|
+
/** The current number of columns in the TTY. */
|
|
28
39
|
readonly columns: number
|
|
40
|
+
/** The current number of rows in the TTY. */
|
|
29
41
|
readonly rows: number
|
|
30
42
|
|
|
43
|
+
/** Return the current TTY dimensions as `[width, height]`. */
|
|
31
44
|
getWindowSize(): [width: number, height: number]
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
declare class WriteStream<M extends WriteStreamEvents = WriteStreamEvents> extends Writable<M> {
|
|
48
|
+
/** Create a `WriteStream` for the TTY file descriptor `fd`. */
|
|
35
49
|
constructor(fd: number, opts?: WritableOptions)
|
|
36
50
|
}
|
|
37
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Return whether `fd` refers to a TTY.
|
|
54
|
+
* @param fd - The file descriptor to check.
|
|
55
|
+
*/
|
|
38
56
|
declare function isTTY(fd: number): boolean
|
|
39
57
|
|
|
40
58
|
export {
|
package/index.js
CHANGED
|
@@ -6,7 +6,12 @@ const errors = require('./lib/errors')
|
|
|
6
6
|
|
|
7
7
|
const defaultReadBufferSize = 65536
|
|
8
8
|
const empty = Buffer.alloc(0)
|
|
9
|
-
const modes = new Set([
|
|
9
|
+
const modes = new Set([
|
|
10
|
+
constants.mode.NORMAL,
|
|
11
|
+
constants.mode.RAW,
|
|
12
|
+
constants.mode.RAW_VT,
|
|
13
|
+
constants.mode.IO
|
|
14
|
+
])
|
|
10
15
|
|
|
11
16
|
exports.ReadStream = class TTYReadStream extends Readable {
|
|
12
17
|
constructor(fd, opts = {}) {
|
|
@@ -45,7 +50,7 @@ exports.ReadStream = class TTYReadStream extends Readable {
|
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
setRawMode(enabled) {
|
|
48
|
-
return this.setMode(enabled ? constants.mode.
|
|
53
|
+
return this.setMode(enabled ? constants.mode.RAW_VT : constants.mode.NORMAL)
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
_alive() {
|
|
@@ -99,7 +104,10 @@ exports.ReadStream = class TTYReadStream extends Readable {
|
|
|
99
104
|
return
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
|
|
107
|
+
// Unpooled, as a read too small to be given a buffer of its own would
|
|
108
|
+
// otherwise pin the whole pool it came from for as long as its consumer
|
|
109
|
+
// holds on to it.
|
|
110
|
+
const copy = Buffer.allocUnsafeSlow(read)
|
|
103
111
|
copy.set(this._buffer.subarray(0, read))
|
|
104
112
|
|
|
105
113
|
if (this.push(copy) === false && this.destroying === false) {
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native mode and internal state flags used by `ReadStream`/`WriteStream`, such as `mode.NORMAL`
|
|
3
|
+
* and `mode.RAW`.
|
|
4
|
+
*/
|
|
1
5
|
declare const constants: {
|
|
2
|
-
mode: { NORMAL: number; RAW: number; IO: number }
|
|
6
|
+
mode: { NORMAL: number; RAW: number; RAW_VT: number; IO: number }
|
|
3
7
|
state: { READING: number; CLOSING: number; CLOSED: number }
|
|
4
8
|
}
|
|
5
9
|
|
package/lib/constants.js
CHANGED
|
@@ -4,6 +4,7 @@ module.exports = exports = {
|
|
|
4
4
|
mode: {
|
|
5
5
|
NORMAL: binding.MODE_NORMAL,
|
|
6
6
|
RAW: binding.MODE_RAW,
|
|
7
|
+
RAW_VT: binding.MODE_RAW_VT,
|
|
7
8
|
IO: binding.MODE_IO || 0
|
|
8
9
|
},
|
|
9
10
|
|
|
@@ -18,5 +19,7 @@ module.exports = exports = {
|
|
|
18
19
|
exports.MODE_NORMAL = exports.mode.NORMAL
|
|
19
20
|
/** @deprecated Use `mode.RAW` */
|
|
20
21
|
exports.MODE_RAW = exports.mode.RAW
|
|
22
|
+
/** @deprecated Use `mode.RAW_VT` */
|
|
23
|
+
exports.MODE_RAW_VT = exports.mode.RAW_VT
|
|
21
24
|
/** @deprecated Use `mode.IO` */
|
|
22
25
|
exports.MODE_IO = exports.mode.IO
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|