Comparing version 2.0.0-1 to 2.0.0-2
@@ -35,2 +35,3 @@ "use strict"; | ||
} = this.props; | ||
stdin.setEncoding('utf8'); | ||
stdin.setRawMode(isEnabled); | ||
@@ -45,6 +46,5 @@ | ||
_defineProperty(this, "handleInput", data => { | ||
const s = String(data); // Exit on Ctrl+C | ||
if (s === '\x03') { | ||
_defineProperty(this, "handleInput", input => { | ||
// Exit on Ctrl+C | ||
if (input === '\x03') { | ||
// eslint-disable-line unicorn/no-hex-escape | ||
@@ -51,0 +51,0 @@ process.exit(0); // eslint-disable-line unicorn/no-process-exit |
@@ -44,2 +44,4 @@ "use strict"; | ||
var _debounceFn = _interopRequireDefault(require("debounce-fn")); | ||
var _createReconciler = _interopRequireDefault(require("./create-reconciler")); | ||
@@ -85,5 +87,12 @@ | ||
const log = _logUpdate.default.create(options.stdout); | ||
const log = _logUpdate.default.create(options.stdout); // Ignore last render after unmounting a tree to prevent empty output before exit | ||
const reconciler = (0, _createReconciler.default)(document, () => { | ||
let ignoreRender = false; | ||
const onRender = () => { | ||
if (ignoreRender) { | ||
return; | ||
} | ||
const output = render(document.body); | ||
@@ -97,4 +106,7 @@ | ||
log(output); | ||
}); | ||
}; | ||
const debouncedRender = options.debug ? onRender : (0, _debounceFn.default)(onRender); | ||
const reconciler = (0, _createReconciler.default)(document, debouncedRender); | ||
if (!options.stdout._inkContainer) { | ||
@@ -111,2 +123,9 @@ options.stdout._inkContainer = reconciler.createContainer(document.body, false); | ||
return () => { | ||
if (typeof debouncedRender.cancel === 'function') { | ||
debouncedRender.cancel(); | ||
onRender(); | ||
log.done(); | ||
} | ||
ignoreRender = true; | ||
reconciler.updateContainer(null, options.stdout._inkContainer); | ||
@@ -113,0 +132,0 @@ }; |
@@ -24,5 +24,2 @@ "use strict"; | ||
}) { | ||
transformers.forEach(transformer => { | ||
text = transformer(text); | ||
}); | ||
const lines = text.split('\n'); | ||
@@ -39,3 +36,9 @@ let offsetY = 0; | ||
this.output[y + offsetY][x + offsetX] = (0, _sliceAnsi.default)(line, offsetX, offsetX + 1); | ||
let char = (0, _sliceAnsi.default)(line, offsetX, offsetX + 1); | ||
for (const transformer of transformers) { | ||
char = transformer(char); | ||
} | ||
this.output[y + offsetY][x + offsetX] = char; | ||
} | ||
@@ -42,0 +45,0 @@ |
{ | ||
"name": "ink", | ||
"version": "2.0.0-1", | ||
"version": "2.0.0-2", | ||
"description": "React for CLI", | ||
@@ -44,2 +44,3 @@ "license": "MIT", | ||
"cli-cursor": "^2.1.0", | ||
"debounce-fn": "^1.0.0", | ||
"log-update": "^2.3.0", | ||
@@ -46,0 +47,0 @@ "prop-types": "^15.6.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44311
715
13
+ Addeddebounce-fn@^1.0.0
+ Addeddebounce-fn@1.0.0(transitive)