@gjsify/tty 0.53.0 → 0.54.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/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{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{Readable as e,Writable as t}from"node:stream";import n from"@girs/glib-2.0";import{nativeIsTty as r,nativeSetRawMode as i,nativeTerminalSize as a,noteRawMode as o}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 o(this.fd,e,e=>i(this.fd,e)===!0)&&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(){return a(this.fd)?.columns??this._columns}set columns(e){this._columns=e}get rows(){return a(this.fd)?.rows??this._rows}set rows(e){this._rows=e}_detectSize(){let e=a(this.fd);if(e){this._columns=e.columns,this._rows=e.rows;return}let t=globalThis.process?.env,r=parseInt(t?.COLUMNS||(n===void 0?``:n.getenv(`COLUMNS`))||`0`,10),i=parseInt(t?.LINES||(n===void 0?``:n.getenv(`LINES`))||`0`,10);r>0&&(this._columns=r),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 o(this.fd,e,e=>i(this.fd,e)===!0)&&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(e)??n.log_writer_supports_color(e):!1}var s={isatty,WriteStream,ReadStream};export{ReadStream,WriteStream,s as default,isatty};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/tty",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
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,15 +33,15 @@
|
|
|
33
33
|
"tty"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@gjsify/cli": "^0.
|
|
37
|
-
"@gjsify/unit": "^0.
|
|
36
|
+
"@gjsify/cli": "^0.54.0",
|
|
37
|
+
"@gjsify/unit": "^0.54.0",
|
|
38
38
|
"@types/node": "^25.9.2",
|
|
39
39
|
"typescript": "^6.0.3"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@girs/glib-2.0": "5.4.0",
|
|
43
|
-
"@gjsify/stream": "^0.
|
|
44
|
-
"@gjsify/terminal-native": "^0.
|
|
43
|
+
"@gjsify/stream": "^0.54.0",
|
|
44
|
+
"@gjsify/terminal-native": "^0.54.0"
|
|
45
45
|
},
|
|
46
46
|
"gjsify": {
|
|
47
47
|
"runtimes": {
|