@gjsify/tty 0.4.21 → 0.4.22
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/lib/esm/index.js +1 -1
- package/package.json +7 -7
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{Readable as e,Writable as t}from"node:stream";import n from"@girs/glib-2.0";import{nativeTerminal as r}from"@gjsify/terminal-native";var ReadStream=class extends e{isRaw=!1;fd;constructor(e=0){super(),this.fd=e}get isTTY(){return isatty(this.fd)}setRawMode(e){return r&&r.Terminal.set_raw_mode(this.fd,e),this.isRaw!==e&&(this.isRaw=e,this.emit(`modeChange`)),this}},WriteStream=class extends t{isRaw=!1;fd;_print=console.log;_columns=80;_rows=24;constructor(e){super(),this.fd=e,this._detectSize()}get isTTY(){return isatty(this.fd)}get columns(){if(r){let[e,,t]=r.Terminal.get_size(this.fd);if(e&&t>0)return t}return this._columns}set columns(e){this._columns=e}get rows(){if(r){let[e,t]=r.Terminal.get_size(this.fd);if(e&&t>0)return t}return this._rows}set rows(e){this._rows=e}_detectSize(){if(r){let[e,t,n]=r.Terminal.get_size(this.fd);if(e&&n>0){this._columns=n,this._rows=t;return}}let e=
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{Readable as e,Writable as t}from"node:stream";import n from"@girs/glib-2.0";import{nativeTerminal as r}from"@gjsify/terminal-native";var ReadStream=class extends e{isRaw=!1;fd;constructor(e=0){super(),this.fd=e}get isTTY(){return isatty(this.fd)}setRawMode(e){return r&&r.Terminal.set_raw_mode(this.fd,e),this.isRaw!==e&&(this.isRaw=e,this.emit(`modeChange`)),this}},WriteStream=class extends t{isRaw=!1;fd;_print=console.log;_columns=80;_rows=24;constructor(e){super(),this.fd=e,this._detectSize()}get isTTY(){return isatty(this.fd)}get columns(){if(r){let[e,,t]=r.Terminal.get_size(this.fd);if(e&&t>0)return t}return this._columns}set columns(e){this._columns=e}get rows(){if(r){let[e,t]=r.Terminal.get_size(this.fd);if(e&&t>0)return t}return this._rows}set rows(e){this._rows=e}_detectSize(){if(r){let[e,t,n]=r.Terminal.get_size(this.fd);if(e&&n>0){this._columns=n,this._rows=t;return}}let e=globalThis.process?.env,t=parseInt(e?.COLUMNS||(n===void 0?``:n.getenv(`COLUMNS`))||`0`,10),i=parseInt(e?.LINES||(n===void 0?``:n.getenv(`LINES`))||`0`,10);t>0&&(this._columns=t),i>0&&(this._rows=i)}clearLine(e,t){let n;return n=e===-1?`\x1B[1K`:e===1?`\x1B[0K`:`\x1B[2K`,this.write(n,t)}clearScreenDown(e){return this.write(`\x1B[0J`,e)}cursorTo(e,t,n){typeof t==`function`&&(n=t,t=void 0);let r;return r=t==null?`\x1b[${e+1}G`:`\x1b[${t+1};${e+1}H`,this.write(r,n)}moveCursor(e,t,n){let r=``;return e>0?r+=`\x1b[${e}C`:e<0&&(r+=`\x1b[${-e}D`),t>0?r+=`\x1b[${t}B`:t<0&&(r+=`\x1b[${-t}A`),r.length===0?(n&&n(),!0):this.write(r,n)}getColorDepth(e){let t=e||globalThis.process?.env||{};if(`FORCE_COLOR`in t){let e=t.FORCE_COLOR;return e===`0`||e===`false`?1:e===`1`?4:e===`2`?8:e===`3`?24:4}if(`NO_COLOR`in t)return 1;let n=t.TERM||``,r=t.COLORTERM||``;return r===`truecolor`||r===`24bit`?24:n===`xterm-256color`||n.endsWith(`-256color`)?8:r?4:n===`dumb`?1:n.startsWith(`xterm`)||n.startsWith(`screen`)||n.startsWith(`vt100`)||n.startsWith(`linux`)?4:1}getWindowSize(){return[this.columns,this.rows]}hasColors(e,t){let n,r;switch(typeof e==`object`?(r=e,n=16):(n=e??16,r=t),this.getColorDepth(r)){case 1:return n>=2;case 4:return n>=16;case 8:return n>=256;case 24:return n>=16777216;default:return!1}}setRawMode(e){return r&&r.Terminal.set_raw_mode(this.fd,e),this.isRaw!==e&&(this.isRaw=e,this.emit(`modeChange`)),this}_write(e,t,n){this._print(t===`buffer`?e.toString(`utf-8`):e),n(null)}_changeColumns(e){e!==this._columns&&(this._columns=e,this.emit(`resize`))}_changeRows(e){e!==this._rows&&(this._rows=e,this.emit(`resize`))}};function isatty(e){return e instanceof ReadStream||e instanceof WriteStream?isatty(e.fd):typeof e==`number`?r?r.Terminal.is_tty(e):n.log_writer_supports_color(e):!1}var i={isatty,WriteStream,ReadStream};export{ReadStream,WriteStream,i as default,isatty};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/tty",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.22",
|
|
4
4
|
"description": "Node.js tty module for Gjs",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"tty"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@gjsify/cli": "^0.4.
|
|
37
|
-
"@gjsify/unit": "^0.4.
|
|
38
|
-
"@types/node": "^25.
|
|
36
|
+
"@gjsify/cli": "^0.4.22",
|
|
37
|
+
"@gjsify/unit": "^0.4.22",
|
|
38
|
+
"@types/node": "^25.9.1",
|
|
39
39
|
"typescript": "^6.0.3"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@girs/glib-2.0": "2.88.0-4.0.
|
|
43
|
-
"@gjsify/stream": "^0.4.
|
|
44
|
-
"@gjsify/terminal-native": "^0.4.
|
|
42
|
+
"@girs/glib-2.0": "2.88.0-4.0.1",
|
|
43
|
+
"@gjsify/stream": "^0.4.22",
|
|
44
|
+
"@gjsify/terminal-native": "^0.4.22"
|
|
45
45
|
}
|
|
46
46
|
}
|