@aws-solutions-constructs/core 2.50.0 → 2.52.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/.eslintignore +2 -0
- package/.jsii +50 -5
- package/node_modules/ansi-regex/index.js +8 -2
- package/node_modules/ansi-regex/license +4 -16
- package/node_modules/ansi-regex/package.json +53 -62
- package/node_modules/ansi-regex/readme.md +48 -9
- package/node_modules/aproba/index.js +33 -33
- package/node_modules/aproba/package.json +5 -4
- package/node_modules/are-we-there-yet/LICENSE.md +18 -0
- package/node_modules/are-we-there-yet/README.md +16 -3
- package/node_modules/are-we-there-yet/lib/tracker-base.js +13 -0
- package/node_modules/are-we-there-yet/lib/tracker-group.js +112 -0
- package/node_modules/are-we-there-yet/lib/tracker-stream.js +42 -0
- package/node_modules/are-we-there-yet/lib/tracker.js +34 -0
- package/node_modules/are-we-there-yet/package.json +38 -20
- package/node_modules/color-support/README.md +129 -0
- package/node_modules/color-support/bin.js +3 -0
- package/node_modules/color-support/browser.js +14 -0
- package/node_modules/color-support/index.js +134 -0
- package/node_modules/color-support/package.json +36 -0
- package/node_modules/gauge/LICENSE.md +20 -0
- package/node_modules/gauge/README.md +19 -16
- package/node_modules/gauge/{base-theme.js → lib/base-theme.js} +7 -3
- package/node_modules/gauge/lib/has-color.js +4 -0
- package/node_modules/gauge/{index.js → lib/index.js} +90 -34
- package/node_modules/gauge/{plumbing.js → lib/plumbing.js} +3 -1
- package/node_modules/gauge/{progress-bar.js → lib/progress-bar.js} +12 -6
- package/node_modules/gauge/{render-template.js → lib/render-template.js} +69 -28
- package/node_modules/gauge/{template-item.js → lib/template-item.js} +21 -7
- package/node_modules/gauge/{theme-set.js → lib/theme-set.js} +31 -24
- package/node_modules/gauge/lib/themes.js +56 -0
- package/node_modules/gauge/{wide-truncate.js → lib/wide-truncate.js} +9 -3
- package/node_modules/gauge/package.json +47 -42
- package/node_modules/is-fullwidth-code-point/index.js +40 -36
- package/node_modules/is-fullwidth-code-point/license +4 -16
- package/node_modules/is-fullwidth-code-point/package.json +40 -43
- package/node_modules/is-fullwidth-code-point/readme.md +8 -8
- package/node_modules/npmlog/LICENSE.md +20 -0
- package/node_modules/npmlog/{log.js → lib/log.js} +149 -58
- package/node_modules/npmlog/package.json +36 -12
- package/node_modules/signal-exit/LICENSE.txt +1 -1
- package/node_modules/signal-exit/README.md +56 -21
- package/node_modules/signal-exit/dist/cjs/browser.d.ts +12 -0
- package/node_modules/signal-exit/dist/cjs/browser.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/cjs/browser.js +10 -0
- package/node_modules/signal-exit/dist/cjs/browser.js.map +1 -0
- package/node_modules/signal-exit/dist/cjs/index.d.ts +48 -0
- package/node_modules/signal-exit/dist/cjs/index.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/cjs/index.js +279 -0
- package/node_modules/signal-exit/dist/cjs/index.js.map +1 -0
- package/node_modules/signal-exit/dist/cjs/package.json +3 -0
- package/node_modules/signal-exit/dist/cjs/signals.d.ts +29 -0
- package/node_modules/signal-exit/dist/cjs/signals.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/cjs/signals.js +42 -0
- package/node_modules/signal-exit/dist/cjs/signals.js.map +1 -0
- package/node_modules/signal-exit/dist/mjs/browser.d.ts +12 -0
- package/node_modules/signal-exit/dist/mjs/browser.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/mjs/browser.js +4 -0
- package/node_modules/signal-exit/dist/mjs/browser.js.map +1 -0
- package/node_modules/signal-exit/dist/mjs/index.d.ts +48 -0
- package/node_modules/signal-exit/dist/mjs/index.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/mjs/index.js +275 -0
- package/node_modules/signal-exit/dist/mjs/index.js.map +1 -0
- package/node_modules/signal-exit/dist/mjs/package.json +3 -0
- package/node_modules/signal-exit/dist/mjs/signals.d.ts +29 -0
- package/node_modules/signal-exit/dist/mjs/signals.d.ts.map +1 -0
- package/node_modules/signal-exit/dist/mjs/signals.js +39 -0
- package/node_modules/signal-exit/dist/mjs/signals.js.map +1 -0
- package/node_modules/signal-exit/package.json +87 -19
- package/node_modules/string-width/index.js +29 -19
- package/node_modules/string-width/license +4 -16
- package/node_modules/string-width/package.json +54 -54
- package/node_modules/string-width/readme.md +17 -9
- package/node_modules/strip-ansi/index.js +2 -4
- package/node_modules/strip-ansi/license +4 -16
- package/node_modules/strip-ansi/package.json +52 -55
- package/node_modules/strip-ansi/readme.md +20 -7
- package/package.json +11 -10
- package/test/test-helper.d.ts +1 -1
- package/test/test-helper.js +5 -5
- package/node_modules/are-we-there-yet/CHANGES.md +0 -37
- package/node_modules/are-we-there-yet/LICENSE +0 -5
- package/node_modules/are-we-there-yet/tracker-base.js +0 -11
- package/node_modules/are-we-there-yet/tracker-group.js +0 -107
- package/node_modules/are-we-there-yet/tracker-stream.js +0 -36
- package/node_modules/are-we-there-yet/tracker.js +0 -30
- package/node_modules/code-point-at/index.js +0 -32
- package/node_modules/code-point-at/license +0 -21
- package/node_modules/code-point-at/package.json +0 -38
- package/node_modules/code-point-at/readme.md +0 -32
- package/node_modules/core-util-is/LICENSE +0 -19
- package/node_modules/core-util-is/README.md +0 -3
- package/node_modules/core-util-is/lib/util.js +0 -107
- package/node_modules/core-util-is/package.json +0 -38
- package/node_modules/delegates/.npmignore +0 -1
- package/node_modules/delegates/History.md +0 -22
- package/node_modules/delegates/License +0 -20
- package/node_modules/delegates/Makefile +0 -8
- package/node_modules/delegates/Readme.md +0 -94
- package/node_modules/delegates/index.js +0 -121
- package/node_modules/delegates/package.json +0 -13
- package/node_modules/delegates/test/index.js +0 -94
- package/node_modules/gauge/CHANGELOG.md +0 -160
- package/node_modules/gauge/LICENSE +0 -13
- package/node_modules/gauge/has-color.js +0 -12
- package/node_modules/gauge/themes.js +0 -54
- package/node_modules/inherits/LICENSE +0 -16
- package/node_modules/inherits/README.md +0 -42
- package/node_modules/inherits/inherits.js +0 -9
- package/node_modules/inherits/inherits_browser.js +0 -27
- package/node_modules/inherits/package.json +0 -29
- package/node_modules/isarray/.npmignore +0 -1
- package/node_modules/isarray/.travis.yml +0 -4
- package/node_modules/isarray/Makefile +0 -6
- package/node_modules/isarray/README.md +0 -60
- package/node_modules/isarray/component.json +0 -19
- package/node_modules/isarray/index.js +0 -5
- package/node_modules/isarray/package.json +0 -45
- package/node_modules/isarray/test.js +0 -20
- package/node_modules/number-is-nan/index.js +0 -4
- package/node_modules/number-is-nan/license +0 -21
- package/node_modules/number-is-nan/package.json +0 -35
- package/node_modules/number-is-nan/readme.md +0 -28
- package/node_modules/object-assign/index.js +0 -90
- package/node_modules/object-assign/license +0 -21
- package/node_modules/object-assign/package.json +0 -42
- package/node_modules/object-assign/readme.md +0 -61
- package/node_modules/process-nextick-args/index.js +0 -45
- package/node_modules/process-nextick-args/license.md +0 -19
- package/node_modules/process-nextick-args/package.json +0 -25
- package/node_modules/process-nextick-args/readme.md +0 -18
- package/node_modules/readable-stream/.travis.yml +0 -34
- package/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/readable-stream/LICENSE +0 -47
- package/node_modules/readable-stream/README.md +0 -58
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/node_modules/readable-stream/duplex-browser.js +0 -1
- package/node_modules/readable-stream/duplex.js +0 -1
- package/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- package/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- package/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- package/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- package/node_modules/readable-stream/lib/_stream_writable.js +0 -685
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -78
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -84
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/readable-stream/package.json +0 -52
- package/node_modules/readable-stream/passthrough.js +0 -1
- package/node_modules/readable-stream/readable-browser.js +0 -7
- package/node_modules/readable-stream/readable.js +0 -19
- package/node_modules/readable-stream/transform.js +0 -1
- package/node_modules/readable-stream/writable-browser.js +0 -1
- package/node_modules/readable-stream/writable.js +0 -8
- package/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/safe-buffer/index.js +0 -62
- package/node_modules/safe-buffer/package.json +0 -37
- package/node_modules/signal-exit/index.js +0 -202
- package/node_modules/signal-exit/signals.js +0 -53
- package/node_modules/string_decoder/.travis.yml +0 -50
- package/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/string_decoder/README.md +0 -47
- package/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/string_decoder/package.json +0 -31
- package/node_modules/util-deprecate/History.md +0 -16
- package/node_modules/util-deprecate/LICENSE +0 -24
- package/node_modules/util-deprecate/README.md +0 -53
- package/node_modules/util-deprecate/browser.js +0 -67
- package/node_modules/util-deprecate/node.js +0 -6
- package/node_modules/util-deprecate/package.json +0 -27
- package/node_modules/wide-align/node_modules/ansi-regex/index.js +0 -10
- package/node_modules/wide-align/node_modules/ansi-regex/license +0 -9
- package/node_modules/wide-align/node_modules/ansi-regex/package.json +0 -55
- package/node_modules/wide-align/node_modules/ansi-regex/readme.md +0 -78
- package/node_modules/wide-align/node_modules/is-fullwidth-code-point/index.js +0 -50
- package/node_modules/wide-align/node_modules/is-fullwidth-code-point/license +0 -9
- package/node_modules/wide-align/node_modules/is-fullwidth-code-point/package.json +0 -42
- package/node_modules/wide-align/node_modules/is-fullwidth-code-point/readme.md +0 -39
- package/node_modules/wide-align/node_modules/string-width/index.js +0 -47
- package/node_modules/wide-align/node_modules/string-width/license +0 -9
- package/node_modules/wide-align/node_modules/string-width/package.json +0 -56
- package/node_modules/wide-align/node_modules/string-width/readme.md +0 -50
- package/node_modules/wide-align/node_modules/strip-ansi/index.js +0 -4
- package/node_modules/wide-align/node_modules/strip-ansi/license +0 -9
- package/node_modules/wide-align/node_modules/strip-ansi/package.json +0 -54
- package/node_modules/wide-align/node_modules/strip-ansi/readme.md +0 -46
- /package/node_modules/{wide-align/node_modules/ansi-regex → ansi-regex}/index.d.ts +0 -0
- /package/node_modules/are-we-there-yet/{index.js → lib/index.js} +0 -0
- /package/node_modules/{npmlog → color-support}/LICENSE +0 -0
- /package/node_modules/gauge/{error.js → lib/error.js} +0 -0
- /package/node_modules/gauge/{process.js → lib/process.js} +0 -0
- /package/node_modules/gauge/{set-immediate.js → lib/set-immediate.js} +0 -0
- /package/node_modules/gauge/{set-interval.js → lib/set-interval.js} +0 -0
- /package/node_modules/gauge/{spin.js → lib/spin.js} +0 -0
- /package/node_modules/{wide-align/node_modules/is-fullwidth-code-point → is-fullwidth-code-point}/index.d.ts +0 -0
- /package/node_modules/{wide-align/node_modules/string-width → string-width}/index.d.ts +0 -0
- /package/node_modules/{wide-align/node_modules/strip-ansi → strip-ansi}/index.d.ts +0 -0
|
@@ -8,14 +8,17 @@ var Gauge = require("gauge")
|
|
|
8
8
|
|
|
9
9
|
var gauge = new Gauge()
|
|
10
10
|
|
|
11
|
-
gauge.show("
|
|
12
|
-
|
|
13
|
-
gauge.pulse("
|
|
14
|
-
|
|
15
|
-
gauge.
|
|
11
|
+
gauge.show("working…", 0)
|
|
12
|
+
setTimeout(() => { gauge.pulse(); gauge.show("working…", 0.25) }, 500)
|
|
13
|
+
setTimeout(() => { gauge.pulse(); gauge.show("working…", 0.50) }, 1000)
|
|
14
|
+
setTimeout(() => { gauge.pulse(); gauge.show("working…", 0.75) }, 1500)
|
|
15
|
+
setTimeout(() => { gauge.pulse(); gauge.show("working…", 0.99) }, 2000)
|
|
16
|
+
setTimeout(() => gauge.hide(), 2300)
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
See also the [demos](docs/demo.js):
|
|
20
|
+
|
|
21
|
+

|
|
19
22
|
|
|
20
23
|
|
|
21
24
|
### CHANGES FROM 1.x
|
|
@@ -46,12 +49,12 @@ if **stream** isn't a tty and a tty isn't explicitly provided.
|
|
|
46
49
|
|
|
47
50
|
If **stream** is a terminal or if you pass in **tty** to **options** then we
|
|
48
51
|
will detect terminal resizes and redraw to fit. We do this by watching for
|
|
49
|
-
`resize` events on the tty. (To work around a bug in
|
|
52
|
+
`resize` events on the tty. (To work around a bug in versions of Node prior
|
|
50
53
|
to 2.5.0, we watch for them on stdout if the tty is stderr.) Resizes to
|
|
51
54
|
larger window sizes will be clean, but shrinking the window will always
|
|
52
55
|
result in some cruft.
|
|
53
56
|
|
|
54
|
-
**IMPORTANT:** If you
|
|
57
|
+
**IMPORTANT:** If you previously were passing in a non-tty stream but you still
|
|
55
58
|
want output (for example, a stream wrapped by the `ansi` module) then you
|
|
56
59
|
need to pass in the **tty** option below, as `gauge` needs access to
|
|
57
60
|
the underlying tty in order to do things like terminal resizes and terminal
|
|
@@ -60,7 +63,7 @@ width detection.
|
|
|
60
63
|
The **options** object can have the following properties, all of which are
|
|
61
64
|
optional:
|
|
62
65
|
|
|
63
|
-
* **updateInterval**: How often gauge updates should be drawn, in
|
|
66
|
+
* **updateInterval**: How often gauge updates should be drawn, in milliseconds.
|
|
64
67
|
* **fixedFramerate**: Defaults to false on node 0.8, true on everything
|
|
65
68
|
else. When this is true a timer is created to trigger once every
|
|
66
69
|
`updateInterval` ms, when false, updates are printed as soon as they come
|
|
@@ -76,7 +79,7 @@ optional:
|
|
|
76
79
|
* The name of a theme, which will be looked up in the current *themes*
|
|
77
80
|
object.
|
|
78
81
|
* A configuration object with any of `hasUnicode`, `hasColor` or
|
|
79
|
-
`platform` keys, which if
|
|
82
|
+
`platform` keys, which if will be used to override our guesses when making
|
|
80
83
|
a default theme selection.
|
|
81
84
|
|
|
82
85
|
If no theme is selected then a default is picked using a combination of our
|
|
@@ -94,7 +97,7 @@ optional:
|
|
|
94
97
|
the gauge starts enabled. If disabled then all update commands are
|
|
95
98
|
ignored and no gauge will be printed until you call `.enable()`.
|
|
96
99
|
* **Plumbing**: The class to use to actually generate the gauge for
|
|
97
|
-
printing. This defaults to `require('gauge/plumbing')` and
|
|
100
|
+
printing. This defaults to `require('gauge/plumbing')` and ordinarily you
|
|
98
101
|
shouldn't need to override this.
|
|
99
102
|
* **cleanupOnExit**: Defaults to true. Ordinarily we register an exit
|
|
100
103
|
handler to make sure your cursor is turned back on and the progress bar
|
|
@@ -162,7 +165,7 @@ Change the active theme, will be displayed with the next show or pulse. This can
|
|
|
162
165
|
* The name of a theme, which will be looked up in the current *themes*
|
|
163
166
|
object.
|
|
164
167
|
* A configuration object with any of `hasUnicode`, `hasColor` or
|
|
165
|
-
`platform` keys, which if
|
|
168
|
+
`platform` keys, which if will be used to override our guesses when making
|
|
166
169
|
a default theme selection.
|
|
167
170
|
|
|
168
171
|
If no theme is selected then a default is picked using a combination of our
|
|
@@ -194,7 +197,7 @@ var ourTheme = themes({hasUnicode: true, hasColor: false, platform: 'darwin'})
|
|
|
194
197
|
|
|
195
198
|
// create a new theme based on the color ascii theme for this platform
|
|
196
199
|
// that brackets the progress bar with arrows
|
|
197
|
-
var ourTheme = themes.newTheme(
|
|
200
|
+
var ourTheme = themes.newTheme(themes({hasUnicode: false, hasColor: true}), {
|
|
198
201
|
preProgressbar: '→',
|
|
199
202
|
postProgressbar: '←'
|
|
200
203
|
})
|
|
@@ -207,7 +210,7 @@ var ThemeSet = require('gauge/theme-set')
|
|
|
207
210
|
var themes = new ThemeSet()
|
|
208
211
|
// or
|
|
209
212
|
var themes = require('gauge/themes')
|
|
210
|
-
var mythemes = themes.
|
|
213
|
+
var mythemes = themes.newThemeSet() // creates a new themeset based on the default themes
|
|
211
214
|
```
|
|
212
215
|
|
|
213
216
|
#### themes(opts)
|
|
@@ -311,7 +314,7 @@ This *mixes-in* `theme` into all themes currently defined. It also adds it
|
|
|
311
314
|
to the default parent theme for this themeset, so future themes added to
|
|
312
315
|
this themeset will get the values from `theme` by default.
|
|
313
316
|
|
|
314
|
-
#### themes.
|
|
317
|
+
#### themes.newThemeSet()
|
|
315
318
|
|
|
316
319
|
Copy the current themeset into a new one. This allows you to easily inherit
|
|
317
320
|
one themeset from another.
|
|
@@ -350,7 +353,7 @@ be be included verbatum in the output, or objects with the following properties:
|
|
|
350
353
|
* *align* – (Default: left) Possible values "left", "right" and "center". Works
|
|
351
354
|
as you'd expect from word processors.
|
|
352
355
|
* *length* – Provides a single value for both *minLength* and *maxLength*. If both
|
|
353
|
-
*length* and *minLength or *maxLength* are
|
|
356
|
+
*length* and *minLength or *maxLength* are specified then the latter take precedence.
|
|
354
357
|
* *value* – A literal value to use for this template item.
|
|
355
358
|
* *default* – A default value to use for this template item if a value
|
|
356
359
|
wasn't otherwise passed in.
|
|
@@ -4,11 +4,15 @@ var progressBar = require('./progress-bar.js')
|
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
activityIndicator: function (values, theme, width) {
|
|
7
|
-
if (values.spun == null)
|
|
7
|
+
if (values.spun == null) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
8
10
|
return spin(theme, values.spun)
|
|
9
11
|
},
|
|
10
12
|
progressbar: function (values, theme, width) {
|
|
11
|
-
if (values.completed == null)
|
|
13
|
+
if (values.completed == null) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
12
16
|
return progressBar(theme, width, values.completed)
|
|
13
|
-
}
|
|
17
|
+
},
|
|
14
18
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var Plumbing = require('./plumbing.js')
|
|
3
3
|
var hasUnicode = require('has-unicode')
|
|
4
4
|
var hasColor = require('./has-color.js')
|
|
5
|
-
var onExit = require('signal-exit')
|
|
5
|
+
var onExit = require('signal-exit').onExit
|
|
6
6
|
var defaultThemes = require('./themes')
|
|
7
7
|
var setInterval = require('./set-interval.js')
|
|
8
8
|
var process = require('./process.js')
|
|
@@ -32,7 +32,7 @@ function Gauge (arg1, arg2) {
|
|
|
32
32
|
this._status = {
|
|
33
33
|
spun: 0,
|
|
34
34
|
section: '',
|
|
35
|
-
subsection: ''
|
|
35
|
+
subsection: '',
|
|
36
36
|
}
|
|
37
37
|
this._paused = false // are we paused for back pressure?
|
|
38
38
|
this._disabled = true // are all progress bar updates disabled?
|
|
@@ -50,10 +50,10 @@ function Gauge (arg1, arg2) {
|
|
|
50
50
|
this._theme = options.theme
|
|
51
51
|
var theme = this._computeTheme(options.theme)
|
|
52
52
|
var template = options.template || [
|
|
53
|
-
{type: 'progressbar', length: 20},
|
|
54
|
-
{type: 'activityIndicator', kerning: 1, length: 1},
|
|
55
|
-
{type: 'section', kerning: 1, default: ''},
|
|
56
|
-
{type: 'subsection', kerning: 1, default: ''}
|
|
53
|
+
{ type: 'progressbar', length: 20 },
|
|
54
|
+
{ type: 'activityIndicator', kerning: 1, length: 1 },
|
|
55
|
+
{ type: 'section', kerning: 1, default: '' },
|
|
56
|
+
{ type: 'subsection', kerning: 1, default: '' },
|
|
57
57
|
]
|
|
58
58
|
this.setWriteTo(writeTo, options.tty)
|
|
59
59
|
var PlumbingClass = options.Plumbing || Plumbing
|
|
@@ -79,17 +79,27 @@ Gauge.prototype.isEnabled = function () {
|
|
|
79
79
|
|
|
80
80
|
Gauge.prototype.setTemplate = function (template) {
|
|
81
81
|
this._gauge.setTemplate(template)
|
|
82
|
-
if (this._showing)
|
|
82
|
+
if (this._showing) {
|
|
83
|
+
this._requestRedraw()
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
Gauge.prototype._computeTheme = function (theme) {
|
|
86
|
-
if (!theme)
|
|
88
|
+
if (!theme) {
|
|
89
|
+
theme = {}
|
|
90
|
+
}
|
|
87
91
|
if (typeof theme === 'string') {
|
|
88
92
|
theme = this._themes.getTheme(theme)
|
|
89
|
-
} else if (
|
|
93
|
+
} else if (
|
|
94
|
+
Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null
|
|
95
|
+
) {
|
|
90
96
|
var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode
|
|
91
97
|
var useColor = theme.hasColor == null ? hasColor : theme.hasColor
|
|
92
|
-
theme = this._themes.getDefault({
|
|
98
|
+
theme = this._themes.getDefault({
|
|
99
|
+
hasUnicode: useUnicode,
|
|
100
|
+
hasColor: useColor,
|
|
101
|
+
platform: theme.platform,
|
|
102
|
+
})
|
|
93
103
|
}
|
|
94
104
|
return theme
|
|
95
105
|
}
|
|
@@ -101,13 +111,17 @@ Gauge.prototype.setThemeset = function (themes) {
|
|
|
101
111
|
|
|
102
112
|
Gauge.prototype.setTheme = function (theme) {
|
|
103
113
|
this._gauge.setTheme(this._computeTheme(theme))
|
|
104
|
-
if (this._showing)
|
|
114
|
+
if (this._showing) {
|
|
115
|
+
this._requestRedraw()
|
|
116
|
+
}
|
|
105
117
|
this._theme = theme
|
|
106
118
|
}
|
|
107
119
|
|
|
108
120
|
Gauge.prototype._requestRedraw = function () {
|
|
109
121
|
this._needsRedraw = true
|
|
110
|
-
if (!this._fixedFramerate)
|
|
122
|
+
if (!this._fixedFramerate) {
|
|
123
|
+
this._doRedraw()
|
|
124
|
+
}
|
|
111
125
|
}
|
|
112
126
|
|
|
113
127
|
Gauge.prototype.getWidth = function () {
|
|
@@ -116,25 +130,39 @@ Gauge.prototype.getWidth = function () {
|
|
|
116
130
|
|
|
117
131
|
Gauge.prototype.setWriteTo = function (writeTo, tty) {
|
|
118
132
|
var enabled = !this._disabled
|
|
119
|
-
if (enabled)
|
|
133
|
+
if (enabled) {
|
|
134
|
+
this.disable()
|
|
135
|
+
}
|
|
120
136
|
this._writeTo = writeTo
|
|
121
137
|
this._tty = tty ||
|
|
122
138
|
(writeTo === process.stderr && process.stdout.isTTY && process.stdout) ||
|
|
123
139
|
(writeTo.isTTY && writeTo) ||
|
|
124
140
|
this._tty
|
|
125
|
-
if (this._gauge)
|
|
126
|
-
|
|
141
|
+
if (this._gauge) {
|
|
142
|
+
this._gauge.setWidth(this.getWidth())
|
|
143
|
+
}
|
|
144
|
+
if (enabled) {
|
|
145
|
+
this.enable()
|
|
146
|
+
}
|
|
127
147
|
}
|
|
128
148
|
|
|
129
149
|
Gauge.prototype.enable = function () {
|
|
130
|
-
if (!this._disabled)
|
|
150
|
+
if (!this._disabled) {
|
|
151
|
+
return
|
|
152
|
+
}
|
|
131
153
|
this._disabled = false
|
|
132
|
-
if (this._tty)
|
|
133
|
-
|
|
154
|
+
if (this._tty) {
|
|
155
|
+
this._enableEvents()
|
|
156
|
+
}
|
|
157
|
+
if (this._showing) {
|
|
158
|
+
this.show()
|
|
159
|
+
}
|
|
134
160
|
}
|
|
135
161
|
|
|
136
162
|
Gauge.prototype.disable = function () {
|
|
137
|
-
if (this._disabled)
|
|
163
|
+
if (this._disabled) {
|
|
164
|
+
return
|
|
165
|
+
}
|
|
138
166
|
if (this._showing) {
|
|
139
167
|
this._lastUpdateAt = null
|
|
140
168
|
this._showing = false
|
|
@@ -142,7 +170,9 @@ Gauge.prototype.disable = function () {
|
|
|
142
170
|
this._showing = true
|
|
143
171
|
}
|
|
144
172
|
this._disabled = true
|
|
145
|
-
if (this._tty)
|
|
173
|
+
if (this._tty) {
|
|
174
|
+
this._disableEvents()
|
|
175
|
+
}
|
|
146
176
|
}
|
|
147
177
|
|
|
148
178
|
Gauge.prototype._enableEvents = function () {
|
|
@@ -152,19 +182,29 @@ Gauge.prototype._enableEvents = function () {
|
|
|
152
182
|
this._tty.on('resize', this._$$handleSizeChange)
|
|
153
183
|
if (this._fixedFramerate) {
|
|
154
184
|
this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval)
|
|
155
|
-
if (this.redrawTracker.unref)
|
|
185
|
+
if (this.redrawTracker.unref) {
|
|
186
|
+
this.redrawTracker.unref()
|
|
187
|
+
}
|
|
156
188
|
}
|
|
157
189
|
}
|
|
158
190
|
|
|
159
191
|
Gauge.prototype._disableEvents = function () {
|
|
160
192
|
this._tty.removeListener('resize', this._$$handleSizeChange)
|
|
161
|
-
if (this._fixedFramerate)
|
|
162
|
-
|
|
193
|
+
if (this._fixedFramerate) {
|
|
194
|
+
clearInterval(this.redrawTracker)
|
|
195
|
+
}
|
|
196
|
+
if (this._removeOnExit) {
|
|
197
|
+
this._removeOnExit()
|
|
198
|
+
}
|
|
163
199
|
}
|
|
164
200
|
|
|
165
201
|
Gauge.prototype.hide = function (cb) {
|
|
166
|
-
if (this._disabled)
|
|
167
|
-
|
|
202
|
+
if (this._disabled) {
|
|
203
|
+
return cb && process.nextTick(cb)
|
|
204
|
+
}
|
|
205
|
+
if (!this._showing) {
|
|
206
|
+
return cb && process.nextTick(cb)
|
|
207
|
+
}
|
|
168
208
|
this._showing = false
|
|
169
209
|
this._doRedraw()
|
|
170
210
|
cb && setImmediate(cb)
|
|
@@ -181,16 +221,24 @@ Gauge.prototype.show = function (section, completed) {
|
|
|
181
221
|
this._status[key] = section[key]
|
|
182
222
|
}
|
|
183
223
|
}
|
|
184
|
-
if (completed != null)
|
|
185
|
-
|
|
224
|
+
if (completed != null) {
|
|
225
|
+
this._status.completed = completed
|
|
226
|
+
}
|
|
227
|
+
if (this._disabled) {
|
|
228
|
+
return
|
|
229
|
+
}
|
|
186
230
|
this._requestRedraw()
|
|
187
231
|
}
|
|
188
232
|
|
|
189
233
|
Gauge.prototype.pulse = function (subsection) {
|
|
190
234
|
this._status.subsection = subsection || ''
|
|
191
|
-
this._status.spun
|
|
192
|
-
if (this._disabled)
|
|
193
|
-
|
|
235
|
+
this._status.spun++
|
|
236
|
+
if (this._disabled) {
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
if (!this._showing) {
|
|
240
|
+
return
|
|
241
|
+
}
|
|
194
242
|
this._requestRedraw()
|
|
195
243
|
}
|
|
196
244
|
|
|
@@ -200,10 +248,14 @@ Gauge.prototype._handleSizeChange = function () {
|
|
|
200
248
|
}
|
|
201
249
|
|
|
202
250
|
Gauge.prototype._doRedraw = function () {
|
|
203
|
-
if (this._disabled || this._paused)
|
|
251
|
+
if (this._disabled || this._paused) {
|
|
252
|
+
return
|
|
253
|
+
}
|
|
204
254
|
if (!this._fixedFramerate) {
|
|
205
255
|
var now = Date.now()
|
|
206
|
-
if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval)
|
|
256
|
+
if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) {
|
|
257
|
+
return
|
|
258
|
+
}
|
|
207
259
|
this._lastUpdateAt = now
|
|
208
260
|
}
|
|
209
261
|
if (!this._showing && this._onScreen) {
|
|
@@ -214,7 +266,9 @@ Gauge.prototype._doRedraw = function () {
|
|
|
214
266
|
}
|
|
215
267
|
return this._writeTo.write(result)
|
|
216
268
|
}
|
|
217
|
-
if (!this._showing && !this._onScreen)
|
|
269
|
+
if (!this._showing && !this._onScreen) {
|
|
270
|
+
return
|
|
271
|
+
}
|
|
218
272
|
if (this._showing && !this._onScreen) {
|
|
219
273
|
this._onScreen = true
|
|
220
274
|
this._needsRedraw = true
|
|
@@ -222,7 +276,9 @@ Gauge.prototype._doRedraw = function () {
|
|
|
222
276
|
this._writeTo.write(this._gauge.hideCursor())
|
|
223
277
|
}
|
|
224
278
|
}
|
|
225
|
-
if (!this._needsRedraw)
|
|
279
|
+
if (!this._needsRedraw) {
|
|
280
|
+
return
|
|
281
|
+
}
|
|
226
282
|
if (!this._writeTo.write(this._gauge.show(this._status))) {
|
|
227
283
|
this._paused = true
|
|
228
284
|
this._writeTo.on('drain', callWith(this, function () {
|
|
@@ -4,7 +4,9 @@ var renderTemplate = require('./render-template.js')
|
|
|
4
4
|
var validate = require('aproba')
|
|
5
5
|
|
|
6
6
|
var Plumbing = module.exports = function (theme, template, width) {
|
|
7
|
-
if (!width)
|
|
7
|
+
if (!width) {
|
|
8
|
+
width = 80
|
|
9
|
+
}
|
|
8
10
|
validate('OAN', [theme, template, width])
|
|
9
11
|
this.showing = false
|
|
10
12
|
this.theme = theme
|
|
@@ -6,14 +6,20 @@ var stringWidth = require('string-width')
|
|
|
6
6
|
|
|
7
7
|
module.exports = function (theme, width, completed) {
|
|
8
8
|
validate('ONN', [theme, width, completed])
|
|
9
|
-
if (completed < 0)
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (completed < 0) {
|
|
10
|
+
completed = 0
|
|
11
|
+
}
|
|
12
|
+
if (completed > 1) {
|
|
13
|
+
completed = 1
|
|
14
|
+
}
|
|
15
|
+
if (width <= 0) {
|
|
16
|
+
return ''
|
|
17
|
+
}
|
|
12
18
|
var sofar = Math.round(width * completed)
|
|
13
19
|
var rest = width - sofar
|
|
14
20
|
var template = [
|
|
15
|
-
{type: 'complete', value: repeat(theme.complete, sofar), length: sofar},
|
|
16
|
-
{type: 'remaining', value: repeat(theme.remaining, rest), length: rest}
|
|
21
|
+
{ type: 'complete', value: repeat(theme.complete, sofar), length: sofar },
|
|
22
|
+
{ type: 'remaining', value: repeat(theme.remaining, rest), length: rest },
|
|
17
23
|
]
|
|
18
24
|
return renderTemplate(width, template, theme)
|
|
19
25
|
}
|
|
@@ -27,7 +33,7 @@ function repeat (string, width) {
|
|
|
27
33
|
result += string
|
|
28
34
|
}
|
|
29
35
|
n = Math.floor(n / 2)
|
|
30
|
-
/*eslint no-self-assign: 0*/
|
|
36
|
+
/* eslint no-self-assign: 0 */
|
|
31
37
|
string += string
|
|
32
38
|
} while (n && stringWidth(result) < width)
|
|
33
39
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
var align = require('wide-align')
|
|
3
3
|
var validate = require('aproba')
|
|
4
|
-
var objectAssign = require('object-assign')
|
|
5
4
|
var wideTruncate = require('./wide-truncate')
|
|
6
5
|
var error = require('./error')
|
|
7
6
|
var TemplateItem = require('./template-item')
|
|
@@ -29,18 +28,20 @@ function postType (item) {
|
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
function hasPreOrPost (item, values) {
|
|
32
|
-
if (!item.type)
|
|
31
|
+
if (!item.type) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
33
34
|
return values[preType(item)] || values[postType(item)]
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
function generatePreAndPost (baseItem, parentValues) {
|
|
37
|
-
var item =
|
|
38
|
+
var item = Object.assign({}, baseItem)
|
|
38
39
|
var values = Object.create(parentValues)
|
|
39
40
|
var template = []
|
|
40
41
|
var pre = preType(item)
|
|
41
42
|
var post = postType(item)
|
|
42
43
|
if (values[pre]) {
|
|
43
|
-
template.push({value: values[pre]})
|
|
44
|
+
template.push({ value: values[pre] })
|
|
44
45
|
values[pre] = null
|
|
45
46
|
}
|
|
46
47
|
item.minLength = null
|
|
@@ -49,7 +50,7 @@ function generatePreAndPost (baseItem, parentValues) {
|
|
|
49
50
|
template.push(item)
|
|
50
51
|
values[item.type] = values[item.type]
|
|
51
52
|
if (values[post]) {
|
|
52
|
-
template.push({value: values[post]})
|
|
53
|
+
template.push({ value: values[post] })
|
|
53
54
|
values[post] = null
|
|
54
55
|
}
|
|
55
56
|
return function ($1, $2, length) {
|
|
@@ -72,49 +73,73 @@ function prepareItems (width, template, values) {
|
|
|
72
73
|
cloned.value = values[type]
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
if (cloned.value == null || cloned.value === '')
|
|
76
|
+
if (cloned.value == null || cloned.value === '') {
|
|
77
|
+
return null
|
|
78
|
+
}
|
|
76
79
|
cloned.index = index
|
|
77
80
|
cloned.first = index === 0
|
|
78
81
|
cloned.last = index === arr.length - 1
|
|
79
|
-
if (hasPreOrPost(cloned, values))
|
|
82
|
+
if (hasPreOrPost(cloned, values)) {
|
|
83
|
+
cloned.value = generatePreAndPost(cloned, values)
|
|
84
|
+
}
|
|
80
85
|
return cloned
|
|
81
86
|
}
|
|
82
87
|
|
|
83
|
-
var output = template.map(cloneAndObjectify).filter(function (item) {
|
|
88
|
+
var output = template.map(cloneAndObjectify).filter(function (item) {
|
|
89
|
+
return item != null
|
|
90
|
+
})
|
|
84
91
|
|
|
85
|
-
var outputLength = 0
|
|
86
92
|
var remainingSpace = width
|
|
87
93
|
var variableCount = output.length
|
|
88
94
|
|
|
89
95
|
function consumeSpace (length) {
|
|
90
|
-
if (length > remainingSpace)
|
|
91
|
-
|
|
96
|
+
if (length > remainingSpace) {
|
|
97
|
+
length = remainingSpace
|
|
98
|
+
}
|
|
92
99
|
remainingSpace -= length
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
function finishSizing (item, length) {
|
|
96
|
-
if (item.finished)
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
if (item.finished) {
|
|
104
|
+
throw new error.Internal('Tried to finish template item that was already finished')
|
|
105
|
+
}
|
|
106
|
+
if (length === Infinity) {
|
|
107
|
+
throw new error.Internal('Length of template item cannot be infinity')
|
|
108
|
+
}
|
|
109
|
+
if (length != null) {
|
|
110
|
+
item.length = length
|
|
111
|
+
}
|
|
99
112
|
item.minLength = null
|
|
100
113
|
item.maxLength = null
|
|
101
114
|
--variableCount
|
|
102
115
|
item.finished = true
|
|
103
|
-
if (item.length == null)
|
|
104
|
-
|
|
116
|
+
if (item.length == null) {
|
|
117
|
+
item.length = item.getBaseLength()
|
|
118
|
+
}
|
|
119
|
+
if (item.length == null) {
|
|
120
|
+
throw new error.Internal('Finished template items must have a length')
|
|
121
|
+
}
|
|
105
122
|
consumeSpace(item.getLength())
|
|
106
123
|
}
|
|
107
124
|
|
|
108
125
|
output.forEach(function (item) {
|
|
109
|
-
if (!item.kerning)
|
|
126
|
+
if (!item.kerning) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
110
129
|
var prevPadRight = item.first ? 0 : output[item.index - 1].padRight
|
|
111
|
-
if (!item.first && prevPadRight < item.kerning)
|
|
112
|
-
|
|
130
|
+
if (!item.first && prevPadRight < item.kerning) {
|
|
131
|
+
item.padLeft = item.kerning - prevPadRight
|
|
132
|
+
}
|
|
133
|
+
if (!item.last) {
|
|
134
|
+
item.padRight = item.kerning
|
|
135
|
+
}
|
|
113
136
|
})
|
|
114
137
|
|
|
115
138
|
// Finish any that have a fixed (literal or intuited) length
|
|
116
139
|
output.forEach(function (item) {
|
|
117
|
-
if (item.getBaseLength() == null)
|
|
140
|
+
if (item.getBaseLength() == null) {
|
|
141
|
+
return
|
|
142
|
+
}
|
|
118
143
|
finishSizing(item)
|
|
119
144
|
})
|
|
120
145
|
|
|
@@ -125,34 +150,48 @@ function prepareItems (width, template, values) {
|
|
|
125
150
|
resizing = false
|
|
126
151
|
hunkSize = Math.round(remainingSpace / variableCount)
|
|
127
152
|
output.forEach(function (item) {
|
|
128
|
-
if (item.finished)
|
|
129
|
-
|
|
153
|
+
if (item.finished) {
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
if (!item.maxLength) {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
130
159
|
if (item.getMaxLength() < hunkSize) {
|
|
131
160
|
finishSizing(item, item.maxLength)
|
|
132
161
|
resizing = true
|
|
133
162
|
}
|
|
134
163
|
})
|
|
135
164
|
} while (resizing && resized++ < output.length)
|
|
136
|
-
if (resizing)
|
|
165
|
+
if (resizing) {
|
|
166
|
+
throw new error.Internal('Resize loop iterated too many times while determining maxLength')
|
|
167
|
+
}
|
|
137
168
|
|
|
138
169
|
resized = 0
|
|
139
170
|
do {
|
|
140
171
|
resizing = false
|
|
141
172
|
hunkSize = Math.round(remainingSpace / variableCount)
|
|
142
173
|
output.forEach(function (item) {
|
|
143
|
-
if (item.finished)
|
|
144
|
-
|
|
174
|
+
if (item.finished) {
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
if (!item.minLength) {
|
|
178
|
+
return
|
|
179
|
+
}
|
|
145
180
|
if (item.getMinLength() >= hunkSize) {
|
|
146
181
|
finishSizing(item, item.minLength)
|
|
147
182
|
resizing = true
|
|
148
183
|
}
|
|
149
184
|
})
|
|
150
185
|
} while (resizing && resized++ < output.length)
|
|
151
|
-
if (resizing)
|
|
186
|
+
if (resizing) {
|
|
187
|
+
throw new error.Internal('Resize loop iterated too many times while determining minLength')
|
|
188
|
+
}
|
|
152
189
|
|
|
153
190
|
hunkSize = Math.round(remainingSpace / variableCount)
|
|
154
191
|
output.forEach(function (item) {
|
|
155
|
-
if (item.finished)
|
|
192
|
+
if (item.finished) {
|
|
193
|
+
return
|
|
194
|
+
}
|
|
156
195
|
finishSizing(item, hunkSize)
|
|
157
196
|
})
|
|
158
197
|
|
|
@@ -171,7 +210,9 @@ function renderFunction (item, values, length) {
|
|
|
171
210
|
function renderValue (item, values) {
|
|
172
211
|
var length = item.getBaseLength()
|
|
173
212
|
var value = typeof item.value === 'function' ? renderFunction(item, values, length) : item.value
|
|
174
|
-
if (value == null || value === '')
|
|
213
|
+
if (value == null || value === '') {
|
|
214
|
+
return ''
|
|
215
|
+
}
|
|
175
216
|
var alignWith = align[item.align] || align.left
|
|
176
217
|
var leftPadding = item.padLeft ? align.left('', item.padLeft) : ''
|
|
177
218
|
var rightPadding = item.padRight ? align.right('', item.padRight) : ''
|
|
@@ -4,7 +4,9 @@ var stringWidth = require('string-width')
|
|
|
4
4
|
module.exports = TemplateItem
|
|
5
5
|
|
|
6
6
|
function isPercent (num) {
|
|
7
|
-
if (typeof num !== 'string')
|
|
7
|
+
if (typeof num !== 'string') {
|
|
8
|
+
return false
|
|
9
|
+
}
|
|
8
10
|
return num.slice(-1) === '%'
|
|
9
11
|
}
|
|
10
12
|
|
|
@@ -30,7 +32,9 @@ function TemplateItem (values, outputLength) {
|
|
|
30
32
|
if (typeof values === 'string') {
|
|
31
33
|
this.value = values
|
|
32
34
|
} else {
|
|
33
|
-
for (var prop in values)
|
|
35
|
+
for (var prop in values) {
|
|
36
|
+
this[prop] = values[prop]
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
// Realize percents
|
|
36
40
|
if (isPercent(this.length)) {
|
|
@@ -49,7 +53,12 @@ TemplateItem.prototype = {}
|
|
|
49
53
|
|
|
50
54
|
TemplateItem.prototype.getBaseLength = function () {
|
|
51
55
|
var length = this.length
|
|
52
|
-
if (
|
|
56
|
+
if (
|
|
57
|
+
length == null &&
|
|
58
|
+
typeof this.value === 'string' &&
|
|
59
|
+
this.maxLength == null &&
|
|
60
|
+
this.minLength == null
|
|
61
|
+
) {
|
|
53
62
|
length = stringWidth(this.value)
|
|
54
63
|
}
|
|
55
64
|
return length
|
|
@@ -57,17 +66,22 @@ TemplateItem.prototype.getBaseLength = function () {
|
|
|
57
66
|
|
|
58
67
|
TemplateItem.prototype.getLength = function () {
|
|
59
68
|
var length = this.getBaseLength()
|
|
60
|
-
if (length == null)
|
|
69
|
+
if (length == null) {
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
61
72
|
return length + this.padLeft + this.padRight
|
|
62
73
|
}
|
|
63
74
|
|
|
64
75
|
TemplateItem.prototype.getMaxLength = function () {
|
|
65
|
-
if (this.maxLength == null)
|
|
76
|
+
if (this.maxLength == null) {
|
|
77
|
+
return null
|
|
78
|
+
}
|
|
66
79
|
return this.maxLength + this.padLeft + this.padRight
|
|
67
80
|
}
|
|
68
81
|
|
|
69
82
|
TemplateItem.prototype.getMinLength = function () {
|
|
70
|
-
if (this.minLength == null)
|
|
83
|
+
if (this.minLength == null) {
|
|
84
|
+
return null
|
|
85
|
+
}
|
|
71
86
|
return this.minLength + this.padLeft + this.padRight
|
|
72
87
|
}
|
|
73
|
-
|