@gesslar/toolkit 3.37.0 → 3.39.1
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/package.json +1 -1
- package/src/node/lib/DirectoryObject.js +57 -0
- package/src/node/lib/FileObject.js +55 -0
- package/src/node/lib/Term.js +98 -8
- package/types/node/lib/DirectoryObject.d.ts +31 -0
- package/types/node/lib/DirectoryObject.d.ts.map +1 -1
- package/types/node/lib/FileObject.d.ts +31 -0
- package/types/node/lib/FileObject.d.ts.map +1 -1
- package/types/node/lib/Term.d.ts +40 -2
- package/types/node/lib/Term.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import {glob, mkdir, opendir, readdir, rmdir, stat} from "node:fs/promises"
|
|
8
8
|
import path, {relative} from "node:path"
|
|
9
9
|
import {URL} from "node:url"
|
|
10
|
+
import {inspect} from "node:util"
|
|
10
11
|
|
|
11
12
|
import Data from "../../browser/lib/Data.js"
|
|
12
13
|
import FileObject from "./FileObject.js"
|
|
@@ -158,6 +159,62 @@ export default class DirectoryObject extends FS {
|
|
|
158
159
|
return `[${this.constructor.name}: ${this.path}]`
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Returns a JSON-serializable representation of the DirectoryObject.
|
|
164
|
+
*
|
|
165
|
+
* @returns {object} Plain object with directory metadata
|
|
166
|
+
*/
|
|
167
|
+
toJSON() {
|
|
168
|
+
return {
|
|
169
|
+
supplied: this.supplied,
|
|
170
|
+
path: this.path,
|
|
171
|
+
name: this.name,
|
|
172
|
+
module: this.module,
|
|
173
|
+
extension: this.extension,
|
|
174
|
+
isDirectory: this.isDirectory,
|
|
175
|
+
parentPath: this.#meta.parentPath,
|
|
176
|
+
sep: this.sep,
|
|
177
|
+
trail: this.trail,
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Custom Node.js inspect implementation for console.log output.
|
|
183
|
+
*
|
|
184
|
+
* @param {number} depth - Inspection depth
|
|
185
|
+
* @param {object} options - Inspect options
|
|
186
|
+
* @param {Function} ins - The inspect function
|
|
187
|
+
* @returns {string} Formatted string representation
|
|
188
|
+
*/
|
|
189
|
+
[inspect.custom](depth, options, ins) {
|
|
190
|
+
return `${this.constructor.name} ${ins(this.toJSON(), options)}`
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Returns the directory path as a primitive value, enabling natural use in
|
|
195
|
+
* string contexts. String and default hints return the directory path; number
|
|
196
|
+
* hint returns NaN.
|
|
197
|
+
*
|
|
198
|
+
* @param {"string"|"number"|"default"} hint - The coercion type hint
|
|
199
|
+
* @returns {string|number} The directory path, or NaN for numeric coercion
|
|
200
|
+
*/
|
|
201
|
+
[Symbol.toPrimitive](hint) {
|
|
202
|
+
if(hint === "number") {
|
|
203
|
+
return NaN
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return this.path
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Returns the directory path as a primitive string value.
|
|
211
|
+
*
|
|
212
|
+
* @returns {string} The directory path
|
|
213
|
+
*/
|
|
214
|
+
valueOf() {
|
|
215
|
+
return this.path
|
|
216
|
+
}
|
|
217
|
+
|
|
161
218
|
/**
|
|
162
219
|
* Checks if the directory exists (async).
|
|
163
220
|
*
|
|
@@ -9,6 +9,7 @@ import fs from "node:fs/promises"
|
|
|
9
9
|
import YAML from "yaml"
|
|
10
10
|
import {URL} from "node:url"
|
|
11
11
|
import {Buffer} from "node:buffer"
|
|
12
|
+
import {inspect} from "node:util"
|
|
12
13
|
|
|
13
14
|
import Data from "../../browser/lib/Data.js"
|
|
14
15
|
import DirectoryObject from "./DirectoryObject.js"
|
|
@@ -147,6 +148,60 @@ export default class FileObject extends FS {
|
|
|
147
148
|
return `[${this.constructor.name}: ${this.path}]`
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Returns a JSON-serializable representation of the FileObject.
|
|
153
|
+
*
|
|
154
|
+
* @returns {object} Plain object with file metadata
|
|
155
|
+
*/
|
|
156
|
+
toJSON() {
|
|
157
|
+
return {
|
|
158
|
+
supplied: this.supplied,
|
|
159
|
+
path: this.path,
|
|
160
|
+
name: this.name,
|
|
161
|
+
module: this.module,
|
|
162
|
+
extension: this.extension,
|
|
163
|
+
isFile: this.isFile,
|
|
164
|
+
parentPath: this.parentPath,
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Custom Node.js inspect implementation for console.log output.
|
|
170
|
+
*
|
|
171
|
+
* @param {number} depth - Inspection depth
|
|
172
|
+
* @param {object} options - Inspect options
|
|
173
|
+
* @param {Function} ins - The inspect function
|
|
174
|
+
* @returns {string} Formatted string representation
|
|
175
|
+
*/
|
|
176
|
+
[inspect.custom](depth, options, ins) {
|
|
177
|
+
return `${this.constructor.name} ${ins(this.toJSON(), options)}`
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Returns the file path as a primitive value, enabling natural use in
|
|
182
|
+
* string contexts. String and default hints return the file path; number
|
|
183
|
+
* hint returns NaN.
|
|
184
|
+
*
|
|
185
|
+
* @param {"string"|"number"|"default"} hint - The coercion type hint
|
|
186
|
+
* @returns {string|number} The file path, or NaN for numeric coercion
|
|
187
|
+
*/
|
|
188
|
+
[Symbol.toPrimitive](hint) {
|
|
189
|
+
if(hint === "number") {
|
|
190
|
+
return NaN
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return this.path
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Returns the file path as a primitive string value.
|
|
198
|
+
*
|
|
199
|
+
* @returns {string} The file path
|
|
200
|
+
*/
|
|
201
|
+
valueOf() {
|
|
202
|
+
return this.path
|
|
203
|
+
}
|
|
204
|
+
|
|
150
205
|
/**
|
|
151
206
|
* Checks if the file exists (async).
|
|
152
207
|
*
|
package/src/node/lib/Term.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import c from "@gesslar/colours"
|
|
1
2
|
import console, {Console} from "node:console"
|
|
2
3
|
import process from "node:process"
|
|
3
4
|
import {Writable} from "node:stream"
|
|
4
|
-
import supportsColor from "supports-color"
|
|
5
5
|
import {stripVTControlCharacters} from "node:util"
|
|
6
|
-
import
|
|
6
|
+
import supportsColor from "supports-color"
|
|
7
7
|
|
|
8
|
+
import Promised from "../../browser/lib/Promised.js"
|
|
9
|
+
import Time from "../../browser/lib/Time.js"
|
|
8
10
|
import Sass from "./Sass.js"
|
|
9
11
|
|
|
10
12
|
c.alias.set("success", "{F035}")
|
|
@@ -488,13 +490,15 @@ export default class Term {
|
|
|
488
490
|
* If in Char Mode, it resolves on Enter, Ctrl+D, or the ANSI 'R' terminator.
|
|
489
491
|
*
|
|
490
492
|
* @param {(text: string) => boolean} [terminator] - Optional callback to check if input is complete.
|
|
491
|
-
* @
|
|
493
|
+
* @param {number} [timeoutMs=0] - Optional timeout in milliseconds. Resolves with empty string if exceeded.
|
|
494
|
+
* @returns {Promise<string>} Resolves with the input data, or empty string on timeout.
|
|
492
495
|
*/
|
|
493
|
-
static data(terminator = () => false) {
|
|
496
|
+
static data(terminator = () => false, timeoutMs = 0) {
|
|
494
497
|
process.stdin.resume()
|
|
495
498
|
|
|
496
499
|
return new Promise((resolve, reject) => {
|
|
497
500
|
const chunks = []
|
|
501
|
+
let timer = null
|
|
498
502
|
|
|
499
503
|
function onData(chunk) {
|
|
500
504
|
const s = chunk.toString()
|
|
@@ -532,6 +536,7 @@ export default class Term {
|
|
|
532
536
|
}
|
|
533
537
|
|
|
534
538
|
function cleanup() {
|
|
539
|
+
clearTimeout(timer)
|
|
535
540
|
process.stdin.off("data", onData)
|
|
536
541
|
process.stdin.off("end", onEnd)
|
|
537
542
|
process.stdin.off("error", onError)
|
|
@@ -544,11 +549,15 @@ export default class Term {
|
|
|
544
549
|
process.stdin.on("data", onData)
|
|
545
550
|
process.stdin.once("end", onEnd)
|
|
546
551
|
process.stdin.once("error", onError)
|
|
552
|
+
|
|
553
|
+
if(timeoutMs > 0)
|
|
554
|
+
timer = setTimeout(onEnd, timeoutMs)
|
|
547
555
|
})
|
|
548
556
|
}
|
|
549
557
|
|
|
550
558
|
/**
|
|
551
559
|
* Gets the current cursor position in the terminal.
|
|
560
|
+
* Returns [0, 0] for non-interactive terminals or if the terminal does not respond within the timeout.
|
|
552
561
|
*
|
|
553
562
|
* @returns {Promise<[number, number]>} Resolves with [x, y] cursor position.
|
|
554
563
|
*/
|
|
@@ -567,13 +576,16 @@ export default class Term {
|
|
|
567
576
|
// 2. Start the listener FIRST (do not await yet)
|
|
568
577
|
const dataPromise = this.data((text => {
|
|
569
578
|
return this.isCharMode && text.endsWith("R")
|
|
570
|
-
}).bind(this))
|
|
579
|
+
}).bind(this), 25)
|
|
571
580
|
|
|
572
581
|
// 3. Write to stdout AFTER the listener is ready
|
|
573
582
|
this.write("\x1b[6n")
|
|
574
583
|
|
|
575
584
|
// 4. Now await the response
|
|
576
|
-
const positionData = await
|
|
585
|
+
const positionData = await Promised.race([
|
|
586
|
+
Time.after(25),
|
|
587
|
+
dataPromise
|
|
588
|
+
])
|
|
577
589
|
|
|
578
590
|
// 5. Restore the previous mode
|
|
579
591
|
prevRawMode ? this.setCharMode() : this.setLineMode()
|
|
@@ -601,8 +613,11 @@ export default class Term {
|
|
|
601
613
|
})
|
|
602
614
|
}
|
|
603
615
|
|
|
604
|
-
|
|
605
|
-
|
|
616
|
+
/**
|
|
617
|
+
* Spinner animation frames using Braille patterns (widely supported).
|
|
618
|
+
*
|
|
619
|
+
* @type {readonly string[]}
|
|
620
|
+
*/
|
|
606
621
|
static spinFrames = Object.freeze(["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"])
|
|
607
622
|
|
|
608
623
|
// static async spinimate(delay=300, options = {position: {x: 0,y: 0}}) {
|
|
@@ -648,4 +663,79 @@ export default class Term {
|
|
|
648
663
|
|
|
649
664
|
return this
|
|
650
665
|
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Switch to the alternate screen buffer.
|
|
669
|
+
*
|
|
670
|
+
* @returns {void}
|
|
671
|
+
*/
|
|
672
|
+
static altScreen() {
|
|
673
|
+
this.write("\x1b[?1049h")
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Switch back to the main screen buffer.
|
|
678
|
+
*
|
|
679
|
+
* @returns {void}
|
|
680
|
+
*/
|
|
681
|
+
static mainScreen() {
|
|
682
|
+
this.write("\x1b[?1049l")
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Queries the terminal to determine whether the alternate screen buffer is currently active.
|
|
687
|
+
* Returns undefined for non-interactive terminals or if the terminal does not respond within the timeout.
|
|
688
|
+
*
|
|
689
|
+
* @returns {Promise<boolean|undefined>} true if in alt screen, false if in main screen, undefined if unknown.
|
|
690
|
+
*/
|
|
691
|
+
static async isAltScreen() {
|
|
692
|
+
if(!this.isInteractive)
|
|
693
|
+
return undefined
|
|
694
|
+
|
|
695
|
+
const prevRawMode = this.isCharMode
|
|
696
|
+
|
|
697
|
+
// 1. Force Raw Mode so the terminal sends the report immediately
|
|
698
|
+
this.setCharMode()
|
|
699
|
+
process.stdin.setEncoding("utf8")
|
|
700
|
+
|
|
701
|
+
// 2. Start the listener FIRST (do not await yet)
|
|
702
|
+
const dataPromise = this.data((text => {
|
|
703
|
+
return this.isCharMode && text.endsWith("$y")
|
|
704
|
+
}).bind(this), 25)
|
|
705
|
+
|
|
706
|
+
this.write("\x1b[?1049$p")
|
|
707
|
+
|
|
708
|
+
const response = await Promised.race([
|
|
709
|
+
Time.after(25),
|
|
710
|
+
dataPromise
|
|
711
|
+
])
|
|
712
|
+
|
|
713
|
+
prevRawMode ? this.setCharMode() : this.setLineMode()
|
|
714
|
+
|
|
715
|
+
if(response === "\x1b[?1049;1$y")
|
|
716
|
+
return true
|
|
717
|
+
|
|
718
|
+
if(response === "\x1b[?1049;2$y")
|
|
719
|
+
return false
|
|
720
|
+
|
|
721
|
+
return undefined
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Save the current screen contents.
|
|
726
|
+
*
|
|
727
|
+
* @returns {void}
|
|
728
|
+
*/
|
|
729
|
+
static saveScreen() {
|
|
730
|
+
this.write("\x1b[?47h")
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Restore previously saved screen contents.
|
|
735
|
+
*
|
|
736
|
+
* @returns {void}
|
|
737
|
+
*/
|
|
738
|
+
static restoreScreen() {
|
|
739
|
+
this.write("\x1b[?47l")
|
|
740
|
+
}
|
|
651
741
|
}
|
|
@@ -80,6 +80,18 @@ export default class DirectoryObject extends FS {
|
|
|
80
80
|
* @param {string?} [supplied="."] - The directory path (defaults to current directory)
|
|
81
81
|
*/
|
|
82
82
|
constructor(supplied?: string | null);
|
|
83
|
+
/**
|
|
84
|
+
* Returns a JSON-serializable representation of the DirectoryObject.
|
|
85
|
+
*
|
|
86
|
+
* @returns {object} Plain object with directory metadata
|
|
87
|
+
*/
|
|
88
|
+
toJSON(): object;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the directory path as a primitive string value.
|
|
91
|
+
*
|
|
92
|
+
* @returns {string} The directory path
|
|
93
|
+
*/
|
|
94
|
+
valueOf(): string;
|
|
83
95
|
/**
|
|
84
96
|
* Checks if the directory exists (async).
|
|
85
97
|
*
|
|
@@ -322,6 +334,24 @@ export default class DirectoryObject extends FS {
|
|
|
322
334
|
* console.log(escaped.path) // "/projects/git/toolkit/foo/bar.js"
|
|
323
335
|
*/
|
|
324
336
|
getFile(filename: string): FileObject;
|
|
337
|
+
/**
|
|
338
|
+
* Custom Node.js inspect implementation for console.log output.
|
|
339
|
+
*
|
|
340
|
+
* @param {number} depth - Inspection depth
|
|
341
|
+
* @param {object} options - Inspect options
|
|
342
|
+
* @param {Function} ins - The inspect function
|
|
343
|
+
* @returns {string} Formatted string representation
|
|
344
|
+
*/
|
|
345
|
+
[inspect.custom](depth: number, options: object, ins: Function): string;
|
|
346
|
+
/**
|
|
347
|
+
* Returns the directory path as a primitive value, enabling natural use in
|
|
348
|
+
* string contexts. String and default hints return the directory path; number
|
|
349
|
+
* hint returns NaN.
|
|
350
|
+
*
|
|
351
|
+
* @param {"string"|"number"|"default"} hint - The coercion type hint
|
|
352
|
+
* @returns {string|number} The directory path, or NaN for numeric coercion
|
|
353
|
+
*/
|
|
354
|
+
[Symbol.toPrimitive](hint: "string" | "number" | "default"): string | number;
|
|
325
355
|
#private;
|
|
326
356
|
}
|
|
327
357
|
export type GeneratorType = {
|
|
@@ -380,4 +410,5 @@ export type DirectoryMeta = {
|
|
|
380
410
|
import FS from "./FileSystem.js";
|
|
381
411
|
import { URL } from "node:url";
|
|
382
412
|
import FileObject from "./FileObject.js";
|
|
413
|
+
import { inspect } from "node:util";
|
|
383
414
|
//# sourceMappingURL=DirectoryObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH;IAuDE;;;;;;;;;OASG;IACH,kBALa,eAAe,CAO3B;IA7CD;;;;OAIG;IACH,uBAFW,MAAM,OAAC,EA4BjB;IAyBD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IA8BD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;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;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,kBAbW,MAAM,GACJ,UAAU,CAkCtB;IAxgBD;;;;;;;OAOG;IACH,wBALW,MAAM,WACN,MAAM,kBAEJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,2BAHW,QAAQ,GAAC,QAAQ,GAAC,SAAS,GACzB,MAAM,GAAC,MAAM,CAQzB;;CA+eF;;UA1qBa,MAAY;QAAC,KAAK,EAAE,eAAe,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAC;eACnD,MAAY,aAAa;;;;;;iBAMzB,OAAO;;;;eACP,MAAM,GAAC,IAAI;;;;YACX,MAAM,GAAC,IAAI;;;;UACX,MAAM,GAAC,IAAI;;;;YACX,eAAe,GAAC,SAAS;;;;gBACzB,MAAM,GAAC,IAAI;;;;UACX,MAAM,GAAC,IAAI;;;;SACX,MAAM,GAAC,IAAI;;;;cACX,MAAM,GAAC,IAAI;;;;WACX,KAAK,CAAC,MAAM,CAAC,GAAC,IAAI;;;;SAClB,GAAG,GAAC,IAAI;;eAvBP,iBAAiB;oBALd,UAAU;uBAIL,iBAAiB;wBAHlB,WAAW"}
|
|
@@ -42,6 +42,18 @@ export default class FileObject extends FS {
|
|
|
42
42
|
* @param {DirectoryObject|string|null} [parent] - The parent directory (object or string)
|
|
43
43
|
*/
|
|
44
44
|
constructor(submitted: string, parent?: DirectoryObject | string | null);
|
|
45
|
+
/**
|
|
46
|
+
* Returns a JSON-serializable representation of the FileObject.
|
|
47
|
+
*
|
|
48
|
+
* @returns {object} Plain object with file metadata
|
|
49
|
+
*/
|
|
50
|
+
toJSON(): object;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the file path as a primitive string value.
|
|
53
|
+
*
|
|
54
|
+
* @returns {string} The file path
|
|
55
|
+
*/
|
|
56
|
+
valueOf(): string;
|
|
45
57
|
/**
|
|
46
58
|
* Checks if the file exists (async).
|
|
47
59
|
*
|
|
@@ -249,12 +261,31 @@ export default class FileObject extends FS {
|
|
|
249
261
|
* await file.delete()
|
|
250
262
|
*/
|
|
251
263
|
delete(): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Custom Node.js inspect implementation for console.log output.
|
|
266
|
+
*
|
|
267
|
+
* @param {number} depth - Inspection depth
|
|
268
|
+
* @param {object} options - Inspect options
|
|
269
|
+
* @param {Function} ins - The inspect function
|
|
270
|
+
* @returns {string} Formatted string representation
|
|
271
|
+
*/
|
|
272
|
+
[inspect.custom](depth: number, options: object, ins: Function): string;
|
|
273
|
+
/**
|
|
274
|
+
* Returns the file path as a primitive value, enabling natural use in
|
|
275
|
+
* string contexts. String and default hints return the file path; number
|
|
276
|
+
* hint returns NaN.
|
|
277
|
+
*
|
|
278
|
+
* @param {"string"|"number"|"default"} hint - The coercion type hint
|
|
279
|
+
* @returns {string|number} The file path, or NaN for numeric coercion
|
|
280
|
+
*/
|
|
281
|
+
[Symbol.toPrimitive](hint: "string" | "number" | "default"): string | number;
|
|
252
282
|
#private;
|
|
253
283
|
}
|
|
254
284
|
import FS from "./FileSystem.js";
|
|
255
285
|
import { URL } from "node:url";
|
|
256
286
|
import DirectoryObject from "./DirectoryObject.js";
|
|
257
287
|
import { Buffer } from "node:buffer";
|
|
288
|
+
import { inspect } from "node:util";
|
|
258
289
|
import JSON5 from "json5";
|
|
259
290
|
import YAML from "yaml";
|
|
260
291
|
//# sourceMappingURL=FileObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;GAaG;AAEH;IACE;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;I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gBAXW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAiC5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC,CAyB/B;IAED;;;;;;;;;;;;;OAaG;IACH,kBATW,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC,CA0C/B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,IAAI,CAAC,CAczB;IA3cD;;;;;;;OAOG;IACH,wBALW,MAAM,WACN,MAAM,kBAEJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,2BAHW,QAAQ,GAAC,QAAQ,GAAC,SAAS,GACzB,MAAM,GAAC,MAAM,CAQzB;;CA+dF;eAjpBc,iBAAiB;oBANd,UAAU;4BAKA,sBAAsB;uBAJ7B,aAAa;wBACZ,WAAW;kBALf,OAAO;iBAER,MAAM"}
|
package/types/node/lib/Term.d.ts
CHANGED
|
@@ -266,11 +266,13 @@ export default class Term {
|
|
|
266
266
|
* If in Char Mode, it resolves on Enter, Ctrl+D, or the ANSI 'R' terminator.
|
|
267
267
|
*
|
|
268
268
|
* @param {(text: string) => boolean} [terminator] - Optional callback to check if input is complete.
|
|
269
|
-
* @
|
|
269
|
+
* @param {number} [timeoutMs=0] - Optional timeout in milliseconds. Resolves with empty string if exceeded.
|
|
270
|
+
* @returns {Promise<string>} Resolves with the input data, or empty string on timeout.
|
|
270
271
|
*/
|
|
271
|
-
static data(terminator?: (text: string) => boolean): Promise<string>;
|
|
272
|
+
static data(terminator?: (text: string) => boolean, timeoutMs?: number): Promise<string>;
|
|
272
273
|
/**
|
|
273
274
|
* Gets the current cursor position in the terminal.
|
|
275
|
+
* Returns [0, 0] for non-interactive terminals or if the terminal does not respond within the timeout.
|
|
274
276
|
*
|
|
275
277
|
* @returns {Promise<[number, number]>} Resolves with [x, y] cursor position.
|
|
276
278
|
*/
|
|
@@ -282,6 +284,11 @@ export default class Term {
|
|
|
282
284
|
* @returns {Promise<void>} Resolves when write completes.
|
|
283
285
|
*/
|
|
284
286
|
static directWrite(output: string): Promise<void>;
|
|
287
|
+
/**
|
|
288
|
+
* Spinner animation frames using Braille patterns (widely supported).
|
|
289
|
+
*
|
|
290
|
+
* @type {readonly string[]}
|
|
291
|
+
*/
|
|
285
292
|
static spinFrames: readonly string[];
|
|
286
293
|
/**
|
|
287
294
|
* Pause stdin, preventing it from emitting data events.
|
|
@@ -301,5 +308,36 @@ export default class Term {
|
|
|
301
308
|
* @returns {typeof Term} The Term class for chaining.
|
|
302
309
|
*/
|
|
303
310
|
static utf8(): typeof Term;
|
|
311
|
+
/**
|
|
312
|
+
* Switch to the alternate screen buffer.
|
|
313
|
+
*
|
|
314
|
+
* @returns {void}
|
|
315
|
+
*/
|
|
316
|
+
static altScreen(): void;
|
|
317
|
+
/**
|
|
318
|
+
* Switch back to the main screen buffer.
|
|
319
|
+
*
|
|
320
|
+
* @returns {void}
|
|
321
|
+
*/
|
|
322
|
+
static mainScreen(): void;
|
|
323
|
+
/**
|
|
324
|
+
* Queries the terminal to determine whether the alternate screen buffer is currently active.
|
|
325
|
+
* Returns undefined for non-interactive terminals or if the terminal does not respond within the timeout.
|
|
326
|
+
*
|
|
327
|
+
* @returns {Promise<boolean|undefined>} true if in alt screen, false if in main screen, undefined if unknown.
|
|
328
|
+
*/
|
|
329
|
+
static isAltScreen(): Promise<boolean | undefined>;
|
|
330
|
+
/**
|
|
331
|
+
* Save the current screen contents.
|
|
332
|
+
*
|
|
333
|
+
* @returns {void}
|
|
334
|
+
*/
|
|
335
|
+
static saveScreen(): void;
|
|
336
|
+
/**
|
|
337
|
+
* Restore previously saved screen contents.
|
|
338
|
+
*
|
|
339
|
+
* @returns {void}
|
|
340
|
+
*/
|
|
341
|
+
static restoreScreen(): void;
|
|
304
342
|
}
|
|
305
343
|
//# sourceMappingURL=Term.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Term.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Term.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Term.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Term.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;GAYG;AACH;IACE,0CAAyB;IAEzB,+CAIC;IAED;;;;OAIG;IACH,sBAFU,MAAM,GAAG,SAAS,CAI3B;IAED;;;;OAIG;IACH,mBAFU,MAAM,GAAG,SAAS,CAI3B;IAED;;;;OAIG;IACH,kBAFU;QAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;KAAC,CAIhE;IAED;;;;OAIG;IACH,4BAFU,OAAO,CAMhB;IAED;;;;OAIG;IACH,uBAFU,OAAO,CAMhB;IAED;;;;OAIG;IACH,oBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,qBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,qBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAIpB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAIpB;IAED;;OAEG;IACH,wBAEC;IAED;;;;;;;;OAQG;IACH,0BANW,MAAM,QAAQ,YAEtB;QAAgC,UAAU,GAAlC,KAAK,CAAC,MAAM,CAAC;QACK,UAAU,GAA5B,OAAO;QACW,aAAa,GAA/B,OAAO;KACjB,QA2DA;IAED;;;;;;;;;;;;;;OAcG;IACH,oBALW,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,eAEjD;QAAyB,MAAM,EAAvB,OAAO;KACf,GAAU,IAAI,CAOhB;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,gCAHW,MAAM,GAAG,KAAK,CAAC,MA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