1
- export const console : any ;
2
1
/**
3
- * Creates an image.
4
- * @private
5
- * @param {string } source The source
6
- * @return {Image } A configured (but not yet loaded) image.
7
- */
8
- export function createImage ( source : string ) : Image ;
9
- export const locale : string ;
10
- export const metadata : {
11
- readonly name : string ;
12
- readonly description : string ;
13
- readonly copyright : any ;
14
- readonly license : string ;
15
- readonly bugs : string ;
16
- readonly bin : string ;
17
- version : ( style ?: number ) => string ;
18
- } ;
19
- /**
20
- * Organise a block of delimited text into a panel
21
- * @private
22
- * @param {string } buffer_ Input plain text.
23
- * @param {string } delimiter_ Field delimiter.
24
- * @param {number } width_ Panel width.
25
- * @return {object } The columnify configuration.
26
- */
27
- declare function panel ( buffer_ : string , delimiter_ : string , width_ : number ) : object ;
28
- export const renderMode : import ( "@thebespokepixel/n-selector" ) . NSelector ;
29
- /**
30
- * Create a text wrapping instance.
2
+ * Truwrap - take input from write() and composed a wrapped text block.
31
3
*
32
- * @param {object } options options object
33
- * @param {number } options.left Left margin.
34
- * @param {number } options.right Right margin.
35
- * @param {number } options.width Manually set view width.
36
- * @param {mode } options.mode [soft | hyphen | hard | keep | container]
37
- * @param {number } options.tabWidth Desired width of TAB character.
38
- * @param {Stream.writable } options.outStream Where to direct output.
39
- * @param {Regexp } options.tokenRegex Override the tokenisers regexp.
40
- * @return {api } A truwrap api instance.
4
+ * @class Truwrap (name)
41
5
*/
42
- export function truwrap ( { left, right, width, mode, tabWidth, outStream, tokenRegex } : {
43
- left : number ;
44
- right : number ;
45
- width : number ;
46
- mode : any ;
47
- tabWidth : number ;
6
+ export class Truwrap {
7
+ /**
8
+ * The base Truwrap instance/api
9
+ *
10
+ * @param {Object } options options object
11
+ * @param {number } [options.left=2] Left margin.
12
+ * @param {number } [options.right=2] Right margin.
13
+ * @param {number } options.width Manually set view width.
14
+ * @param {string } [options.mode='soft'] [soft | hyphen | hard | keep | container
15
+ * @param {number } [options.tabWidth=4] Desired width of TAB character.
16
+ * @param {Stream.writable } options.outStream Where to direct output.
17
+ * @param {Regexp } options.tokenRegex Override the tokenisers regexp.
18
+ */
19
+ constructor ( { left, right, width, mode, tabWidth, outStream, tokenRegex } : {
20
+ left ?: number ;
21
+ right ?: number ;
22
+ width : number ;
23
+ mode ?: string ;
24
+ tabWidth ?: number ;
25
+ outStream : any ;
26
+ tokenRegex : any ;
27
+ } ) ;
48
28
outStream : any ;
49
- tokenRegex : any ;
50
- } ) : {
29
+ buffer : string ;
30
+ mode : string ;
31
+ ttyActive : boolean ;
32
+ ttyWidth : any ;
33
+ viewWidth : number ;
34
+ viewHandler : { } ;
51
35
/**
52
36
* End a block, setting blocking mode and flushing buffers if needed.
53
- * @function
54
- * @return { undefined } has side effect of writing to stream
37
+ *
38
+ * @return { string } The wrapped output, has side effect of writing to stream if defined.
55
39
*/
56
- end ( ) : undefined ;
40
+ end ( ) : string ;
57
41
/**
58
42
* Fetch the width in characters of the wrapping view.
59
- * @function
60
- * @return {number } wrapping width
43
+ *
44
+ * @return {number } The width.
61
45
*/
62
- getWidth : typeof unimplemented ;
46
+ getWidth ( ) : number ;
63
47
/**
64
48
* Create a multicolumn panel within this view
65
- * @function
66
- * @param {panelObject } content - Object for columnify
67
- * @param { object } configuration - Configuration for columnify
68
- * @return { string } - The rendered panel.
49
+ *
50
+ * @param {panelObject } content_ Object for columnify
51
+ * @param { Object } configuration Configuration for columnify
52
+ * @return { Object } this instance, to allow chaining
69
53
*/
70
- panel ( content : any , configuration : object ) : string ;
54
+ panel ( content_ : any , configuration : any ) : any ;
71
55
/**
72
56
* Generate linebreaks within this view
73
- * @function
74
- * @param {number } newlines - number of new lines to add.
75
- * @return {api } has side effect of writing to stream.
57
+ *
58
+ * @param {number } newlines number of new lines to add.
59
+ * @return {Object } this instance, to allow chaining
76
60
*/
77
61
break ( newlines ?: number ) : any ;
78
62
/**
79
63
* Similar to css' clear. Write a clearing newline to the stream.
80
- * @function
81
- * @return { api } has side effect of writing to stream.
64
+ *
65
+ * @return { Object } this instance, to allow chaining
82
66
*/
83
67
clear ( ) : any ;
84
68
/**
85
69
* Write text via the wrapping logic
86
- * @function
87
- * @param { string } text - The raw, unwrapped test to wrap.
88
- * @return { api } has side effect of writing to stream.
70
+ *
71
+ * @param { string } content_ The content
72
+ * @return { Object } this instance, to allow chaining
89
73
*/
90
- write ( text : string ) : any ;
91
- } ;
74
+ write ( content_ : string ) : any ;
75
+ }
76
+ /**
77
+ * Creates an image.
78
+ * @private
79
+ * @param {string } source The source
80
+ * @return {Image } A configured (but not yet loaded) image.
81
+ */
82
+ export function createImage ( source : string ) : Image ;
83
+ /**
84
+ * Organise a block of delimited text into a panel
85
+ * @private
86
+ * @param {string } buffer_ Input plain text.
87
+ * @param {string } delimiter_ Field delimiter.
88
+ * @param {number } width_ Panel width.
89
+ * @return {Object } The columnify configuration.
90
+ */
91
+ declare function panel ( buffer_ : string , delimiter_ : string , width_ : number ) : any ;
92
+ /**
93
+ * Create an n-selector for module modes
94
+ *
95
+ * @type {Function }
96
+ */
97
+ export const renderMode : Function ;
98
+ /**
99
+ * Create a text wrapping instance.
100
+ *
101
+ * @param {Object } options options object
102
+ * @param {number } [options.left=2] Left margin.
103
+ * @param {number } [options.right=2] Right margin.
104
+ * @param {number } options.width Manually set view width.
105
+ * @param {string } [options.mode='soft'] [soft | hyphen | hard | keep | container
106
+ * @param {number } [options.tabWidth=4] Desired width of TAB character.
107
+ * @param {Stream.writable } options.outStream Where to direct output.
108
+ * @param {Regexp } options.tokenRegex Override the tokenisers regexp.
109
+ * @return {Truwrap } { description_of_the_return_value }
110
+ */
111
+ export function truwrap ( options : {
112
+ left ?: number ;
113
+ right ?: number ;
114
+ width : number ;
115
+ mode ?: string ;
116
+ tabWidth ?: number ;
117
+ outStream : any ;
118
+ tokenRegex : any ;
119
+ } ) : Truwrap ;
92
120
/**
93
121
* Provides an image formatted for inclusion in the TTY
94
122
* @private
@@ -109,20 +137,14 @@ declare class Image {
109
137
filePath : any ;
110
138
/**
111
139
* Load and render the image into the CLI
112
- * @param {object } options - The options to set
140
+ * @param {Object } options - The options to set
113
141
* @property {number } align - The line count needed to realign the cursor.
114
142
* @property {boolean } stretch - Do we stretch the image to match the width
115
143
* and height.
116
144
* @property {boolean } nobreak - Do we clear the image with a newline?
117
145
* @return {string } The string to insert into the output buffer, with base64
118
146
* encoded image.
119
147
*/
120
- render ( options : object ) : string ;
148
+ render ( options : any ) : string ;
121
149
}
122
- /**
123
- * Throw a error if a method remains unimplemented
124
- * @private
125
- * @return {undefined }
126
- */
127
- declare function unimplemented ( ) : undefined ;
128
150
export { panel as parsePanel } ;
0 commit comments