@aws-solutions-constructs/core 2.77.0 → 2.78.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/.jsii +42 -42
- package/lib/alb-helper.js +2 -3
- package/lib/apigateway-defaults.d.ts +6 -6
- package/lib/apigateway-defaults.js +11 -11
- package/lib/apigateway-helper.d.ts +2 -2
- package/lib/apigateway-helper.js +8 -10
- package/lib/cloudfront-distribution-helper.js +2 -3
- package/lib/cloudwatch-log-group-helper.js +2 -4
- package/lib/cognito-defaults.d.ts +2 -2
- package/lib/cognito-defaults.js +4 -4
- package/lib/cognito-helper.js +3 -5
- package/lib/dynamodb-table-defaults.d.ts +3 -3
- package/lib/dynamodb-table-defaults.js +6 -6
- package/lib/dynamodb-table-helper.js +3 -3
- package/lib/elasticsearch-helper.js +5 -5
- package/lib/eventbridge-helper.js +4 -4
- package/lib/events-rule-defaults.d.ts +1 -1
- package/lib/events-rule-defaults.js +4 -4
- package/lib/fargate-helper.js +2 -3
- package/lib/glue-database-defaults.js +3 -3
- package/lib/glue-job-helper.js +3 -3
- package/lib/glue-table-defaults.js +6 -6
- package/lib/iot-topic-rule-defaults.d.ts +1 -1
- package/lib/iot-topic-rule-defaults.js +6 -6
- package/lib/kendra-helper.d.ts +1 -1
- package/lib/kendra-helper.js +1 -1
- package/lib/kinesis-analytics-defaults.d.ts +2 -2
- package/lib/kinesis-analytics-defaults.js +4 -4
- package/lib/kinesis-analytics-helper.js +2 -2
- package/lib/kinesis-firehose-s3-defaults.d.ts +1 -1
- package/lib/kinesis-firehose-s3-defaults.js +7 -7
- package/lib/kinesis-streams-defaults.d.ts +2 -2
- package/lib/kinesis-streams-defaults.js +4 -4
- package/lib/kinesis-streams-helper.js +2 -3
- package/lib/kms-defaults.d.ts +2 -2
- package/lib/kms-defaults.js +4 -4
- package/lib/kms-helper.js +2 -4
- package/lib/lambda-event-source-mapping-defaults.d.ts +3 -3
- package/lib/lambda-event-source-mapping-defaults.js +16 -16
- package/lib/mediastore-helper.js +2 -3
- package/lib/opensearch-helper.js +2 -2
- package/lib/override-warning-service.js +9 -6
- package/lib/s3-bucket-helper.js +7 -1
- package/lib/sagemaker-helper.d.ts +5 -0
- package/lib/sagemaker-helper.js +10 -9
- package/lib/secretsmanager-defaults.d.ts +2 -2
- package/lib/secretsmanager-defaults.js +4 -4
- package/lib/secretsmanager-helper.js +2 -3
- package/lib/sns-defaults.d.ts +2 -2
- package/lib/sns-defaults.js +4 -4
- package/lib/sns-helper.js +2 -2
- package/lib/sqs-defaults.js +3 -3
- package/lib/sqs-helper.js +2 -2
- package/lib/step-function-defaults.d.ts +1 -1
- package/lib/step-function-defaults.js +3 -3
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +14 -12
- package/lib/vpc-helper.js +1 -3
- package/lib/waf-helper.js +2 -3
- package/lib/websocket-api-helper.js +1 -2
- package/nohoist.sh +11 -0
- package/package.json +5 -4
- package/test/apigateway-helper.test.js +3 -3
- package/test/cloudfront-distribution-api-gateway-helper.test.js +11 -11
- package/test/dynamo-table.test.js +9 -9
- package/test/glue-job-helper.test.js +7 -7
- package/test/glue-table-helper.test.js +5 -5
- package/test/kinesis-analytics.test.js +2 -2
- package/test/kinesis-streams-defaults.test.js +2 -2
- package/test/lambda-event-source.test.js +10 -10
- package/test/override-warning-service.test.js +25 -26
- package/test/pipes-helper.test.js +2 -2
- package/test/step-function-helper.test.js +5 -5
- package/test/utils.test.js +11 -12
- package/.eslintignore +0 -9
- package/node_modules/ansi-regex/index.d.ts +0 -37
- package/node_modules/ansi-regex/index.js +0 -10
- package/node_modules/ansi-regex/license +0 -9
- package/node_modules/ansi-regex/package.json +0 -55
- package/node_modules/ansi-regex/readme.md +0 -78
- package/node_modules/aproba/LICENSE +0 -14
- package/node_modules/aproba/README.md +0 -94
- package/node_modules/aproba/index.js +0 -105
- package/node_modules/aproba/package.json +0 -35
- package/node_modules/are-we-there-yet/LICENSE.md +0 -18
- package/node_modules/are-we-there-yet/README.md +0 -208
- package/node_modules/are-we-there-yet/lib/index.js +0 -4
- package/node_modules/are-we-there-yet/lib/tracker-base.js +0 -13
- package/node_modules/are-we-there-yet/lib/tracker-group.js +0 -112
- package/node_modules/are-we-there-yet/lib/tracker-stream.js +0 -42
- package/node_modules/are-we-there-yet/lib/tracker.js +0 -34
- package/node_modules/are-we-there-yet/package.json +0 -53
- package/node_modules/color-support/LICENSE +0 -15
- package/node_modules/color-support/README.md +0 -129
- package/node_modules/color-support/bin.js +0 -3
- package/node_modules/color-support/browser.js +0 -14
- package/node_modules/color-support/index.js +0 -134
- package/node_modules/color-support/package.json +0 -36
- package/node_modules/console-control-strings/LICENSE +0 -13
- package/node_modules/console-control-strings/README.md +0 -145
- package/node_modules/console-control-strings/index.js +0 -125
- package/node_modules/console-control-strings/package.json +0 -27
- package/node_modules/emoji-regex/LICENSE-MIT.txt +0 -20
- package/node_modules/emoji-regex/README.md +0 -73
- package/node_modules/emoji-regex/es2015/index.js +0 -6
- package/node_modules/emoji-regex/es2015/text.js +0 -6
- package/node_modules/emoji-regex/index.d.ts +0 -23
- package/node_modules/emoji-regex/index.js +0 -6
- package/node_modules/emoji-regex/package.json +0 -50
- package/node_modules/emoji-regex/text.js +0 -6
- package/node_modules/gauge/LICENSE.md +0 -20
- package/node_modules/gauge/README.md +0 -402
- package/node_modules/gauge/lib/base-theme.js +0 -18
- package/node_modules/gauge/lib/error.js +0 -24
- package/node_modules/gauge/lib/has-color.js +0 -4
- package/node_modules/gauge/lib/index.js +0 -289
- package/node_modules/gauge/lib/plumbing.js +0 -50
- package/node_modules/gauge/lib/process.js +0 -3
- package/node_modules/gauge/lib/progress-bar.js +0 -41
- package/node_modules/gauge/lib/render-template.js +0 -222
- package/node_modules/gauge/lib/set-immediate.js +0 -7
- package/node_modules/gauge/lib/set-interval.js +0 -3
- package/node_modules/gauge/lib/spin.js +0 -5
- package/node_modules/gauge/lib/template-item.js +0 -87
- package/node_modules/gauge/lib/theme-set.js +0 -122
- package/node_modules/gauge/lib/themes.js +0 -56
- package/node_modules/gauge/lib/wide-truncate.js +0 -31
- package/node_modules/gauge/package.json +0 -68
- package/node_modules/has-unicode/LICENSE +0 -14
- package/node_modules/has-unicode/README.md +0 -43
- package/node_modules/has-unicode/index.js +0 -16
- package/node_modules/has-unicode/package.json +0 -30
- package/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
- package/node_modules/is-fullwidth-code-point/index.js +0 -50
- package/node_modules/is-fullwidth-code-point/license +0 -9
- package/node_modules/is-fullwidth-code-point/package.json +0 -42
- package/node_modules/is-fullwidth-code-point/readme.md +0 -39
- package/node_modules/set-blocking/LICENSE.txt +0 -14
- package/node_modules/set-blocking/README.md +0 -31
- package/node_modules/set-blocking/index.js +0 -7
- package/node_modules/set-blocking/package.json +0 -42
- package/node_modules/signal-exit/LICENSE.txt +0 -16
- package/node_modules/signal-exit/README.md +0 -74
- package/node_modules/signal-exit/dist/cjs/browser.d.ts +0 -12
- package/node_modules/signal-exit/dist/cjs/browser.d.ts.map +0 -1
- package/node_modules/signal-exit/dist/cjs/browser.js +0 -10
- package/node_modules/signal-exit/dist/cjs/browser.js.map +0 -1
- package/node_modules/signal-exit/dist/cjs/index.d.ts +0 -48
- package/node_modules/signal-exit/dist/cjs/index.d.ts.map +0 -1
- package/node_modules/signal-exit/dist/cjs/index.js +0 -279
- package/node_modules/signal-exit/dist/cjs/index.js.map +0 -1
- package/node_modules/signal-exit/dist/cjs/package.json +0 -3
- package/node_modules/signal-exit/dist/cjs/signals.d.ts +0 -29
- package/node_modules/signal-exit/dist/cjs/signals.d.ts.map +0 -1
- package/node_modules/signal-exit/dist/cjs/signals.js +0 -42
- package/node_modules/signal-exit/dist/cjs/signals.js.map +0 -1
- package/node_modules/signal-exit/dist/mjs/browser.d.ts +0 -12
- package/node_modules/signal-exit/dist/mjs/browser.d.ts.map +0 -1
- package/node_modules/signal-exit/dist/mjs/browser.js +0 -4
- package/node_modules/signal-exit/dist/mjs/browser.js.map +0 -1
- package/node_modules/signal-exit/dist/mjs/index.d.ts +0 -48
- package/node_modules/signal-exit/dist/mjs/index.d.ts.map +0 -1
- package/node_modules/signal-exit/dist/mjs/index.js +0 -275
- package/node_modules/signal-exit/dist/mjs/index.js.map +0 -1
- package/node_modules/signal-exit/dist/mjs/package.json +0 -3
- package/node_modules/signal-exit/dist/mjs/signals.d.ts +0 -29
- package/node_modules/signal-exit/dist/mjs/signals.d.ts.map +0 -1
- package/node_modules/signal-exit/dist/mjs/signals.js +0 -39
- package/node_modules/signal-exit/dist/mjs/signals.js.map +0 -1
- package/node_modules/signal-exit/package.json +0 -106
- package/node_modules/string-width/index.d.ts +0 -29
- package/node_modules/string-width/index.js +0 -47
- package/node_modules/string-width/license +0 -9
- package/node_modules/string-width/package.json +0 -56
- package/node_modules/string-width/readme.md +0 -50
- package/node_modules/strip-ansi/index.d.ts +0 -17
- package/node_modules/strip-ansi/index.js +0 -4
- package/node_modules/strip-ansi/license +0 -9
- package/node_modules/strip-ansi/package.json +0 -54
- package/node_modules/strip-ansi/readme.md +0 -46
- package/node_modules/wide-align/LICENSE +0 -14
- package/node_modules/wide-align/README.md +0 -47
- package/node_modules/wide-align/align.js +0 -65
- package/node_modules/wide-align/package.json +0 -33
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
var Plumbing = require('./plumbing.js')
|
|
3
|
-
var hasUnicode = require('has-unicode')
|
|
4
|
-
var hasColor = require('./has-color.js')
|
|
5
|
-
var onExit = require('signal-exit').onExit
|
|
6
|
-
var defaultThemes = require('./themes')
|
|
7
|
-
var setInterval = require('./set-interval.js')
|
|
8
|
-
var process = require('./process.js')
|
|
9
|
-
var setImmediate = require('./set-immediate')
|
|
10
|
-
|
|
11
|
-
module.exports = Gauge
|
|
12
|
-
|
|
13
|
-
function callWith (obj, method) {
|
|
14
|
-
return function () {
|
|
15
|
-
return method.call(obj)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function Gauge (arg1, arg2) {
|
|
20
|
-
var options, writeTo
|
|
21
|
-
if (arg1 && arg1.write) {
|
|
22
|
-
writeTo = arg1
|
|
23
|
-
options = arg2 || {}
|
|
24
|
-
} else if (arg2 && arg2.write) {
|
|
25
|
-
writeTo = arg2
|
|
26
|
-
options = arg1 || {}
|
|
27
|
-
} else {
|
|
28
|
-
writeTo = process.stderr
|
|
29
|
-
options = arg1 || arg2 || {}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
this._status = {
|
|
33
|
-
spun: 0,
|
|
34
|
-
section: '',
|
|
35
|
-
subsection: '',
|
|
36
|
-
}
|
|
37
|
-
this._paused = false // are we paused for back pressure?
|
|
38
|
-
this._disabled = true // are all progress bar updates disabled?
|
|
39
|
-
this._showing = false // do we WANT the progress bar on screen
|
|
40
|
-
this._onScreen = false // IS the progress bar on screen
|
|
41
|
-
this._needsRedraw = false // should we print something at next tick?
|
|
42
|
-
this._hideCursor = options.hideCursor == null ? true : options.hideCursor
|
|
43
|
-
this._fixedFramerate = options.fixedFramerate == null
|
|
44
|
-
? !(/^v0\.8\./.test(process.version))
|
|
45
|
-
: options.fixedFramerate
|
|
46
|
-
this._lastUpdateAt = null
|
|
47
|
-
this._updateInterval = options.updateInterval == null ? 50 : options.updateInterval
|
|
48
|
-
|
|
49
|
-
this._themes = options.themes || defaultThemes
|
|
50
|
-
this._theme = options.theme
|
|
51
|
-
var theme = this._computeTheme(options.theme)
|
|
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: '' },
|
|
57
|
-
]
|
|
58
|
-
this.setWriteTo(writeTo, options.tty)
|
|
59
|
-
var PlumbingClass = options.Plumbing || Plumbing
|
|
60
|
-
this._gauge = new PlumbingClass(theme, template, this.getWidth())
|
|
61
|
-
|
|
62
|
-
this._$$doRedraw = callWith(this, this._doRedraw)
|
|
63
|
-
this._$$handleSizeChange = callWith(this, this._handleSizeChange)
|
|
64
|
-
|
|
65
|
-
this._cleanupOnExit = options.cleanupOnExit == null || options.cleanupOnExit
|
|
66
|
-
this._removeOnExit = null
|
|
67
|
-
|
|
68
|
-
if (options.enabled || (options.enabled == null && this._tty && this._tty.isTTY)) {
|
|
69
|
-
this.enable()
|
|
70
|
-
} else {
|
|
71
|
-
this.disable()
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
Gauge.prototype = {}
|
|
75
|
-
|
|
76
|
-
Gauge.prototype.isEnabled = function () {
|
|
77
|
-
return !this._disabled
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
Gauge.prototype.setTemplate = function (template) {
|
|
81
|
-
this._gauge.setTemplate(template)
|
|
82
|
-
if (this._showing) {
|
|
83
|
-
this._requestRedraw()
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
Gauge.prototype._computeTheme = function (theme) {
|
|
88
|
-
if (!theme) {
|
|
89
|
-
theme = {}
|
|
90
|
-
}
|
|
91
|
-
if (typeof theme === 'string') {
|
|
92
|
-
theme = this._themes.getTheme(theme)
|
|
93
|
-
} else if (
|
|
94
|
-
Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null
|
|
95
|
-
) {
|
|
96
|
-
var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode
|
|
97
|
-
var useColor = theme.hasColor == null ? hasColor : theme.hasColor
|
|
98
|
-
theme = this._themes.getDefault({
|
|
99
|
-
hasUnicode: useUnicode,
|
|
100
|
-
hasColor: useColor,
|
|
101
|
-
platform: theme.platform,
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
return theme
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
Gauge.prototype.setThemeset = function (themes) {
|
|
108
|
-
this._themes = themes
|
|
109
|
-
this.setTheme(this._theme)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
Gauge.prototype.setTheme = function (theme) {
|
|
113
|
-
this._gauge.setTheme(this._computeTheme(theme))
|
|
114
|
-
if (this._showing) {
|
|
115
|
-
this._requestRedraw()
|
|
116
|
-
}
|
|
117
|
-
this._theme = theme
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
Gauge.prototype._requestRedraw = function () {
|
|
121
|
-
this._needsRedraw = true
|
|
122
|
-
if (!this._fixedFramerate) {
|
|
123
|
-
this._doRedraw()
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
Gauge.prototype.getWidth = function () {
|
|
128
|
-
return ((this._tty && this._tty.columns) || 80) - 1
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
Gauge.prototype.setWriteTo = function (writeTo, tty) {
|
|
132
|
-
var enabled = !this._disabled
|
|
133
|
-
if (enabled) {
|
|
134
|
-
this.disable()
|
|
135
|
-
}
|
|
136
|
-
this._writeTo = writeTo
|
|
137
|
-
this._tty = tty ||
|
|
138
|
-
(writeTo === process.stderr && process.stdout.isTTY && process.stdout) ||
|
|
139
|
-
(writeTo.isTTY && writeTo) ||
|
|
140
|
-
this._tty
|
|
141
|
-
if (this._gauge) {
|
|
142
|
-
this._gauge.setWidth(this.getWidth())
|
|
143
|
-
}
|
|
144
|
-
if (enabled) {
|
|
145
|
-
this.enable()
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
Gauge.prototype.enable = function () {
|
|
150
|
-
if (!this._disabled) {
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
this._disabled = false
|
|
154
|
-
if (this._tty) {
|
|
155
|
-
this._enableEvents()
|
|
156
|
-
}
|
|
157
|
-
if (this._showing) {
|
|
158
|
-
this.show()
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
Gauge.prototype.disable = function () {
|
|
163
|
-
if (this._disabled) {
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
if (this._showing) {
|
|
167
|
-
this._lastUpdateAt = null
|
|
168
|
-
this._showing = false
|
|
169
|
-
this._doRedraw()
|
|
170
|
-
this._showing = true
|
|
171
|
-
}
|
|
172
|
-
this._disabled = true
|
|
173
|
-
if (this._tty) {
|
|
174
|
-
this._disableEvents()
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
Gauge.prototype._enableEvents = function () {
|
|
179
|
-
if (this._cleanupOnExit) {
|
|
180
|
-
this._removeOnExit = onExit(callWith(this, this.disable))
|
|
181
|
-
}
|
|
182
|
-
this._tty.on('resize', this._$$handleSizeChange)
|
|
183
|
-
if (this._fixedFramerate) {
|
|
184
|
-
this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval)
|
|
185
|
-
if (this.redrawTracker.unref) {
|
|
186
|
-
this.redrawTracker.unref()
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
Gauge.prototype._disableEvents = function () {
|
|
192
|
-
this._tty.removeListener('resize', this._$$handleSizeChange)
|
|
193
|
-
if (this._fixedFramerate) {
|
|
194
|
-
clearInterval(this.redrawTracker)
|
|
195
|
-
}
|
|
196
|
-
if (this._removeOnExit) {
|
|
197
|
-
this._removeOnExit()
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
Gauge.prototype.hide = function (cb) {
|
|
202
|
-
if (this._disabled) {
|
|
203
|
-
return cb && process.nextTick(cb)
|
|
204
|
-
}
|
|
205
|
-
if (!this._showing) {
|
|
206
|
-
return cb && process.nextTick(cb)
|
|
207
|
-
}
|
|
208
|
-
this._showing = false
|
|
209
|
-
this._doRedraw()
|
|
210
|
-
cb && setImmediate(cb)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
Gauge.prototype.show = function (section, completed) {
|
|
214
|
-
this._showing = true
|
|
215
|
-
if (typeof section === 'string') {
|
|
216
|
-
this._status.section = section
|
|
217
|
-
} else if (typeof section === 'object') {
|
|
218
|
-
var sectionKeys = Object.keys(section)
|
|
219
|
-
for (var ii = 0; ii < sectionKeys.length; ++ii) {
|
|
220
|
-
var key = sectionKeys[ii]
|
|
221
|
-
this._status[key] = section[key]
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (completed != null) {
|
|
225
|
-
this._status.completed = completed
|
|
226
|
-
}
|
|
227
|
-
if (this._disabled) {
|
|
228
|
-
return
|
|
229
|
-
}
|
|
230
|
-
this._requestRedraw()
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
Gauge.prototype.pulse = function (subsection) {
|
|
234
|
-
this._status.subsection = subsection || ''
|
|
235
|
-
this._status.spun++
|
|
236
|
-
if (this._disabled) {
|
|
237
|
-
return
|
|
238
|
-
}
|
|
239
|
-
if (!this._showing) {
|
|
240
|
-
return
|
|
241
|
-
}
|
|
242
|
-
this._requestRedraw()
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
Gauge.prototype._handleSizeChange = function () {
|
|
246
|
-
this._gauge.setWidth(this._tty.columns - 1)
|
|
247
|
-
this._requestRedraw()
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
Gauge.prototype._doRedraw = function () {
|
|
251
|
-
if (this._disabled || this._paused) {
|
|
252
|
-
return
|
|
253
|
-
}
|
|
254
|
-
if (!this._fixedFramerate) {
|
|
255
|
-
var now = Date.now()
|
|
256
|
-
if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) {
|
|
257
|
-
return
|
|
258
|
-
}
|
|
259
|
-
this._lastUpdateAt = now
|
|
260
|
-
}
|
|
261
|
-
if (!this._showing && this._onScreen) {
|
|
262
|
-
this._onScreen = false
|
|
263
|
-
var result = this._gauge.hide()
|
|
264
|
-
if (this._hideCursor) {
|
|
265
|
-
result += this._gauge.showCursor()
|
|
266
|
-
}
|
|
267
|
-
return this._writeTo.write(result)
|
|
268
|
-
}
|
|
269
|
-
if (!this._showing && !this._onScreen) {
|
|
270
|
-
return
|
|
271
|
-
}
|
|
272
|
-
if (this._showing && !this._onScreen) {
|
|
273
|
-
this._onScreen = true
|
|
274
|
-
this._needsRedraw = true
|
|
275
|
-
if (this._hideCursor) {
|
|
276
|
-
this._writeTo.write(this._gauge.hideCursor())
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (!this._needsRedraw) {
|
|
280
|
-
return
|
|
281
|
-
}
|
|
282
|
-
if (!this._writeTo.write(this._gauge.show(this._status))) {
|
|
283
|
-
this._paused = true
|
|
284
|
-
this._writeTo.on('drain', callWith(this, function () {
|
|
285
|
-
this._paused = false
|
|
286
|
-
this._doRedraw()
|
|
287
|
-
}))
|
|
288
|
-
}
|
|
289
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
var consoleControl = require('console-control-strings')
|
|
3
|
-
var renderTemplate = require('./render-template.js')
|
|
4
|
-
var validate = require('aproba')
|
|
5
|
-
|
|
6
|
-
var Plumbing = module.exports = function (theme, template, width) {
|
|
7
|
-
if (!width) {
|
|
8
|
-
width = 80
|
|
9
|
-
}
|
|
10
|
-
validate('OAN', [theme, template, width])
|
|
11
|
-
this.showing = false
|
|
12
|
-
this.theme = theme
|
|
13
|
-
this.width = width
|
|
14
|
-
this.template = template
|
|
15
|
-
}
|
|
16
|
-
Plumbing.prototype = {}
|
|
17
|
-
|
|
18
|
-
Plumbing.prototype.setTheme = function (theme) {
|
|
19
|
-
validate('O', [theme])
|
|
20
|
-
this.theme = theme
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
Plumbing.prototype.setTemplate = function (template) {
|
|
24
|
-
validate('A', [template])
|
|
25
|
-
this.template = template
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Plumbing.prototype.setWidth = function (width) {
|
|
29
|
-
validate('N', [width])
|
|
30
|
-
this.width = width
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
Plumbing.prototype.hide = function () {
|
|
34
|
-
return consoleControl.gotoSOL() + consoleControl.eraseLine()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
Plumbing.prototype.hideCursor = consoleControl.hideCursor
|
|
38
|
-
|
|
39
|
-
Plumbing.prototype.showCursor = consoleControl.showCursor
|
|
40
|
-
|
|
41
|
-
Plumbing.prototype.show = function (status) {
|
|
42
|
-
var values = Object.create(this.theme)
|
|
43
|
-
for (var key in status) {
|
|
44
|
-
values[key] = status[key]
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return renderTemplate(this.width, this.template, values).trim() +
|
|
48
|
-
consoleControl.color('reset') +
|
|
49
|
-
consoleControl.eraseLine() + consoleControl.gotoSOL()
|
|
50
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
var validate = require('aproba')
|
|
3
|
-
var renderTemplate = require('./render-template.js')
|
|
4
|
-
var wideTruncate = require('./wide-truncate')
|
|
5
|
-
var stringWidth = require('string-width')
|
|
6
|
-
|
|
7
|
-
module.exports = function (theme, width, completed) {
|
|
8
|
-
validate('ONN', [theme, width, completed])
|
|
9
|
-
if (completed < 0) {
|
|
10
|
-
completed = 0
|
|
11
|
-
}
|
|
12
|
-
if (completed > 1) {
|
|
13
|
-
completed = 1
|
|
14
|
-
}
|
|
15
|
-
if (width <= 0) {
|
|
16
|
-
return ''
|
|
17
|
-
}
|
|
18
|
-
var sofar = Math.round(width * completed)
|
|
19
|
-
var rest = width - sofar
|
|
20
|
-
var template = [
|
|
21
|
-
{ type: 'complete', value: repeat(theme.complete, sofar), length: sofar },
|
|
22
|
-
{ type: 'remaining', value: repeat(theme.remaining, rest), length: rest },
|
|
23
|
-
]
|
|
24
|
-
return renderTemplate(width, template, theme)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// lodash's way of repeating
|
|
28
|
-
function repeat (string, width) {
|
|
29
|
-
var result = ''
|
|
30
|
-
var n = width
|
|
31
|
-
do {
|
|
32
|
-
if (n % 2) {
|
|
33
|
-
result += string
|
|
34
|
-
}
|
|
35
|
-
n = Math.floor(n / 2)
|
|
36
|
-
/* eslint no-self-assign: 0 */
|
|
37
|
-
string += string
|
|
38
|
-
} while (n && stringWidth(result) < width)
|
|
39
|
-
|
|
40
|
-
return wideTruncate(result, width)
|
|
41
|
-
}
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
var align = require('wide-align')
|
|
3
|
-
var validate = require('aproba')
|
|
4
|
-
var wideTruncate = require('./wide-truncate')
|
|
5
|
-
var error = require('./error')
|
|
6
|
-
var TemplateItem = require('./template-item')
|
|
7
|
-
|
|
8
|
-
function renderValueWithValues (values) {
|
|
9
|
-
return function (item) {
|
|
10
|
-
return renderValue(item, values)
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var renderTemplate = module.exports = function (width, template, values) {
|
|
15
|
-
var items = prepareItems(width, template, values)
|
|
16
|
-
var rendered = items.map(renderValueWithValues(values)).join('')
|
|
17
|
-
return align.left(wideTruncate(rendered, width), width)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function preType (item) {
|
|
21
|
-
var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1)
|
|
22
|
-
return 'pre' + cappedTypeName
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function postType (item) {
|
|
26
|
-
var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1)
|
|
27
|
-
return 'post' + cappedTypeName
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function hasPreOrPost (item, values) {
|
|
31
|
-
if (!item.type) {
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
return values[preType(item)] || values[postType(item)]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function generatePreAndPost (baseItem, parentValues) {
|
|
38
|
-
var item = Object.assign({}, baseItem)
|
|
39
|
-
var values = Object.create(parentValues)
|
|
40
|
-
var template = []
|
|
41
|
-
var pre = preType(item)
|
|
42
|
-
var post = postType(item)
|
|
43
|
-
if (values[pre]) {
|
|
44
|
-
template.push({ value: values[pre] })
|
|
45
|
-
values[pre] = null
|
|
46
|
-
}
|
|
47
|
-
item.minLength = null
|
|
48
|
-
item.length = null
|
|
49
|
-
item.maxLength = null
|
|
50
|
-
template.push(item)
|
|
51
|
-
values[item.type] = values[item.type]
|
|
52
|
-
if (values[post]) {
|
|
53
|
-
template.push({ value: values[post] })
|
|
54
|
-
values[post] = null
|
|
55
|
-
}
|
|
56
|
-
return function ($1, $2, length) {
|
|
57
|
-
return renderTemplate(length, template, values)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function prepareItems (width, template, values) {
|
|
62
|
-
function cloneAndObjectify (item, index, arr) {
|
|
63
|
-
var cloned = new TemplateItem(item, width)
|
|
64
|
-
var type = cloned.type
|
|
65
|
-
if (cloned.value == null) {
|
|
66
|
-
if (!(type in values)) {
|
|
67
|
-
if (cloned.default == null) {
|
|
68
|
-
throw new error.MissingTemplateValue(cloned, values)
|
|
69
|
-
} else {
|
|
70
|
-
cloned.value = cloned.default
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
cloned.value = values[type]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (cloned.value == null || cloned.value === '') {
|
|
77
|
-
return null
|
|
78
|
-
}
|
|
79
|
-
cloned.index = index
|
|
80
|
-
cloned.first = index === 0
|
|
81
|
-
cloned.last = index === arr.length - 1
|
|
82
|
-
if (hasPreOrPost(cloned, values)) {
|
|
83
|
-
cloned.value = generatePreAndPost(cloned, values)
|
|
84
|
-
}
|
|
85
|
-
return cloned
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var output = template.map(cloneAndObjectify).filter(function (item) {
|
|
89
|
-
return item != null
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
var remainingSpace = width
|
|
93
|
-
var variableCount = output.length
|
|
94
|
-
|
|
95
|
-
function consumeSpace (length) {
|
|
96
|
-
if (length > remainingSpace) {
|
|
97
|
-
length = remainingSpace
|
|
98
|
-
}
|
|
99
|
-
remainingSpace -= length
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function finishSizing (item, length) {
|
|
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
|
-
}
|
|
112
|
-
item.minLength = null
|
|
113
|
-
item.maxLength = null
|
|
114
|
-
--variableCount
|
|
115
|
-
item.finished = true
|
|
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
|
-
}
|
|
122
|
-
consumeSpace(item.getLength())
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
output.forEach(function (item) {
|
|
126
|
-
if (!item.kerning) {
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
var prevPadRight = item.first ? 0 : output[item.index - 1].padRight
|
|
130
|
-
if (!item.first && prevPadRight < item.kerning) {
|
|
131
|
-
item.padLeft = item.kerning - prevPadRight
|
|
132
|
-
}
|
|
133
|
-
if (!item.last) {
|
|
134
|
-
item.padRight = item.kerning
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
// Finish any that have a fixed (literal or intuited) length
|
|
139
|
-
output.forEach(function (item) {
|
|
140
|
-
if (item.getBaseLength() == null) {
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
finishSizing(item)
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
var resized = 0
|
|
147
|
-
var resizing
|
|
148
|
-
var hunkSize
|
|
149
|
-
do {
|
|
150
|
-
resizing = false
|
|
151
|
-
hunkSize = Math.round(remainingSpace / variableCount)
|
|
152
|
-
output.forEach(function (item) {
|
|
153
|
-
if (item.finished) {
|
|
154
|
-
return
|
|
155
|
-
}
|
|
156
|
-
if (!item.maxLength) {
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
if (item.getMaxLength() < hunkSize) {
|
|
160
|
-
finishSizing(item, item.maxLength)
|
|
161
|
-
resizing = true
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
} while (resizing && resized++ < output.length)
|
|
165
|
-
if (resizing) {
|
|
166
|
-
throw new error.Internal('Resize loop iterated too many times while determining maxLength')
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
resized = 0
|
|
170
|
-
do {
|
|
171
|
-
resizing = false
|
|
172
|
-
hunkSize = Math.round(remainingSpace / variableCount)
|
|
173
|
-
output.forEach(function (item) {
|
|
174
|
-
if (item.finished) {
|
|
175
|
-
return
|
|
176
|
-
}
|
|
177
|
-
if (!item.minLength) {
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
if (item.getMinLength() >= hunkSize) {
|
|
181
|
-
finishSizing(item, item.minLength)
|
|
182
|
-
resizing = true
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
} while (resizing && resized++ < output.length)
|
|
186
|
-
if (resizing) {
|
|
187
|
-
throw new error.Internal('Resize loop iterated too many times while determining minLength')
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
hunkSize = Math.round(remainingSpace / variableCount)
|
|
191
|
-
output.forEach(function (item) {
|
|
192
|
-
if (item.finished) {
|
|
193
|
-
return
|
|
194
|
-
}
|
|
195
|
-
finishSizing(item, hunkSize)
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
return output
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function renderFunction (item, values, length) {
|
|
202
|
-
validate('OON', arguments)
|
|
203
|
-
if (item.type) {
|
|
204
|
-
return item.value(values, values[item.type + 'Theme'] || {}, length)
|
|
205
|
-
} else {
|
|
206
|
-
return item.value(values, {}, length)
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function renderValue (item, values) {
|
|
211
|
-
var length = item.getBaseLength()
|
|
212
|
-
var value = typeof item.value === 'function' ? renderFunction(item, values, length) : item.value
|
|
213
|
-
if (value == null || value === '') {
|
|
214
|
-
return ''
|
|
215
|
-
}
|
|
216
|
-
var alignWith = align[item.align] || align.left
|
|
217
|
-
var leftPadding = item.padLeft ? align.left('', item.padLeft) : ''
|
|
218
|
-
var rightPadding = item.padRight ? align.right('', item.padRight) : ''
|
|
219
|
-
var truncated = wideTruncate(String(value), length)
|
|
220
|
-
var aligned = alignWith(truncated, length)
|
|
221
|
-
return leftPadding + aligned + rightPadding
|
|
222
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
var stringWidth = require('string-width')
|
|
3
|
-
|
|
4
|
-
module.exports = TemplateItem
|
|
5
|
-
|
|
6
|
-
function isPercent (num) {
|
|
7
|
-
if (typeof num !== 'string') {
|
|
8
|
-
return false
|
|
9
|
-
}
|
|
10
|
-
return num.slice(-1) === '%'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function percent (num) {
|
|
14
|
-
return Number(num.slice(0, -1)) / 100
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function TemplateItem (values, outputLength) {
|
|
18
|
-
this.overallOutputLength = outputLength
|
|
19
|
-
this.finished = false
|
|
20
|
-
this.type = null
|
|
21
|
-
this.value = null
|
|
22
|
-
this.length = null
|
|
23
|
-
this.maxLength = null
|
|
24
|
-
this.minLength = null
|
|
25
|
-
this.kerning = null
|
|
26
|
-
this.align = 'left'
|
|
27
|
-
this.padLeft = 0
|
|
28
|
-
this.padRight = 0
|
|
29
|
-
this.index = null
|
|
30
|
-
this.first = null
|
|
31
|
-
this.last = null
|
|
32
|
-
if (typeof values === 'string') {
|
|
33
|
-
this.value = values
|
|
34
|
-
} else {
|
|
35
|
-
for (var prop in values) {
|
|
36
|
-
this[prop] = values[prop]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// Realize percents
|
|
40
|
-
if (isPercent(this.length)) {
|
|
41
|
-
this.length = Math.round(this.overallOutputLength * percent(this.length))
|
|
42
|
-
}
|
|
43
|
-
if (isPercent(this.minLength)) {
|
|
44
|
-
this.minLength = Math.round(this.overallOutputLength * percent(this.minLength))
|
|
45
|
-
}
|
|
46
|
-
if (isPercent(this.maxLength)) {
|
|
47
|
-
this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength))
|
|
48
|
-
}
|
|
49
|
-
return this
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
TemplateItem.prototype = {}
|
|
53
|
-
|
|
54
|
-
TemplateItem.prototype.getBaseLength = function () {
|
|
55
|
-
var length = this.length
|
|
56
|
-
if (
|
|
57
|
-
length == null &&
|
|
58
|
-
typeof this.value === 'string' &&
|
|
59
|
-
this.maxLength == null &&
|
|
60
|
-
this.minLength == null
|
|
61
|
-
) {
|
|
62
|
-
length = stringWidth(this.value)
|
|
63
|
-
}
|
|
64
|
-
return length
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
TemplateItem.prototype.getLength = function () {
|
|
68
|
-
var length = this.getBaseLength()
|
|
69
|
-
if (length == null) {
|
|
70
|
-
return null
|
|
71
|
-
}
|
|
72
|
-
return length + this.padLeft + this.padRight
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
TemplateItem.prototype.getMaxLength = function () {
|
|
76
|
-
if (this.maxLength == null) {
|
|
77
|
-
return null
|
|
78
|
-
}
|
|
79
|
-
return this.maxLength + this.padLeft + this.padRight
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
TemplateItem.prototype.getMinLength = function () {
|
|
83
|
-
if (this.minLength == null) {
|
|
84
|
-
return null
|
|
85
|
-
}
|
|
86
|
-
return this.minLength + this.padLeft + this.padRight
|
|
87
|
-
}
|