@elench/testkit 0.1.114 → 0.1.115
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/lib/cli/assistant/app.mjs +4 -2
- package/lib/cli/assistant/session.mjs +5 -1
- package/lib/cli/assistant/state.mjs +1 -2
- package/lib/cli/components/blocks/run-tree.mjs +7 -2
- package/lib/cli/components/hooks/use-element-layout.mjs +63 -0
- package/lib/cli/components/hooks/use-spinner-frame.mjs +26 -0
- package/node_modules/@alcalzone/ansi-tokenize/README.md +0 -5
- package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.d.ts +8 -0
- package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.js +10 -8
- package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.js.map +1 -1
- package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.d.ts +1 -5
- package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.js +9 -45
- package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.js.map +1 -1
- package/node_modules/@alcalzone/ansi-tokenize/package.json +1 -1
- package/node_modules/@elench/next-analysis/package.json +1 -1
- package/node_modules/@elench/testkit-bridge/package.json +2 -2
- package/node_modules/@elench/testkit-protocol/package.json +1 -1
- package/node_modules/@elench/ts-analysis/package.json +1 -1
- package/node_modules/cli-boxes/index.d.ts +95 -90
- package/node_modules/cli-boxes/index.js +5 -2
- package/node_modules/cli-boxes/package.json +6 -13
- package/node_modules/cli-boxes/readme.md +15 -3
- package/node_modules/cli-truncate/index.d.ts +1 -1
- package/node_modules/cli-truncate/package.json +4 -4
- package/node_modules/cli-truncate/readme.md +1 -0
- package/node_modules/ink/build/apply-styles.js +175 -0
- package/node_modules/ink/build/build-layout.js +77 -0
- package/node_modules/ink/build/calculate-wrapped-text.js +53 -0
- package/node_modules/ink/build/components/App.d.ts +1 -4
- package/node_modules/ink/build/components/App.js +22 -142
- package/node_modules/ink/build/components/App.js.map +1 -1
- package/node_modules/ink/build/components/AppContext.d.ts +3 -23
- package/node_modules/ink/build/components/AppContext.js +4 -7
- package/node_modules/ink/build/components/AppContext.js.map +1 -1
- package/node_modules/ink/build/components/Box.d.ts +3 -16
- package/node_modules/ink/build/components/Color.js +62 -0
- package/node_modules/ink/build/components/Cursor.d.ts +83 -0
- package/node_modules/ink/build/components/Cursor.js +53 -0
- package/node_modules/ink/build/components/Cursor.js.map +1 -0
- package/node_modules/ink/build/components/ErrorBoundary.d.ts +2 -2
- package/node_modules/ink/build/components/ErrorOverview.js +6 -6
- package/node_modules/ink/build/components/ErrorOverview.js.map +1 -1
- package/node_modules/ink/build/components/Static.js.map +1 -1
- package/node_modules/ink/build/components/StdinContext.d.ts +1 -7
- package/node_modules/ink/build/components/StdinContext.js +0 -1
- package/node_modules/ink/build/components/StdinContext.js.map +1 -1
- package/node_modules/ink/build/components/Text.d.ts +1 -1
- package/node_modules/ink/build/components/Text.js +1 -1
- package/node_modules/ink/build/components/Text.js.map +1 -1
- package/node_modules/ink/build/components/Transform.d.ts +1 -1
- package/node_modules/ink/build/devtools-window-polyfill.js +4 -7
- package/node_modules/ink/build/devtools-window-polyfill.js.map +1 -1
- package/node_modules/ink/build/devtools.js +6 -31
- package/node_modules/ink/build/devtools.js.map +1 -1
- package/node_modules/ink/build/dom.d.ts +1 -5
- package/node_modules/ink/build/dom.js +1 -20
- package/node_modules/ink/build/dom.js.map +1 -1
- package/node_modules/ink/build/experimental/apply-style.js +140 -0
- package/node_modules/ink/build/experimental/dom.js +123 -0
- package/node_modules/ink/build/experimental/output.js +91 -0
- package/node_modules/ink/build/experimental/reconciler.js +141 -0
- package/node_modules/ink/build/experimental/renderer.js +81 -0
- package/node_modules/ink/build/hooks/use-app.d.ts +1 -1
- package/node_modules/ink/build/hooks/use-app.js +1 -1
- package/node_modules/ink/build/hooks/use-cursor.d.ts +1 -1
- package/node_modules/ink/build/hooks/use-cursor.js +1 -1
- package/node_modules/ink/build/hooks/use-focus-manager.d.ts +2 -17
- package/node_modules/ink/build/hooks/use-focus-manager.js +1 -2
- package/node_modules/ink/build/hooks/use-focus-manager.js.map +1 -1
- package/node_modules/ink/build/hooks/use-focus.d.ts +1 -2
- package/node_modules/ink/build/hooks/use-focus.js +4 -5
- package/node_modules/ink/build/hooks/use-focus.js.map +1 -1
- package/node_modules/ink/build/hooks/use-input.d.ts +1 -2
- package/node_modules/ink/build/hooks/use-input.js +80 -82
- package/node_modules/ink/build/hooks/use-input.js.map +1 -1
- package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.d.ts +1 -2
- package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js +1 -2
- package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js.map +1 -1
- package/node_modules/ink/build/hooks/use-stderr.d.ts +1 -1
- package/node_modules/ink/build/hooks/use-stderr.js +1 -1
- package/node_modules/ink/build/hooks/use-stdin.d.ts +2 -4
- package/node_modules/ink/build/hooks/use-stdin.js +1 -2
- package/node_modules/ink/build/hooks/use-stdin.js.map +1 -1
- package/node_modules/ink/build/hooks/use-stdout.d.ts +1 -1
- package/node_modules/ink/build/hooks/use-stdout.js +1 -1
- package/node_modules/ink/build/hooks/useInput.js +38 -0
- package/node_modules/ink/build/index.d.ts +1 -8
- package/node_modules/ink/build/index.js +0 -4
- package/node_modules/ink/build/index.js.map +1 -1
- package/node_modules/ink/build/ink.d.ts +3 -48
- package/node_modules/ink/build/ink.js +155 -325
- package/node_modules/ink/build/ink.js.map +1 -1
- package/node_modules/ink/build/input-parser.d.ts +1 -4
- package/node_modules/ink/build/input-parser.js +30 -70
- package/node_modules/ink/build/input-parser.js.map +1 -1
- package/node_modules/ink/build/instance.js +205 -0
- package/node_modules/ink/build/layout.d.ts +7 -0
- package/node_modules/ink/build/layout.js +33 -0
- package/node_modules/ink/build/layout.js.map +1 -0
- package/node_modules/ink/build/log-update.d.ts +0 -1
- package/node_modules/ink/build/log-update.js +1 -13
- package/node_modules/ink/build/log-update.js.map +1 -1
- package/node_modules/ink/build/measure-element.d.ts +0 -4
- package/node_modules/ink/build/measure-element.js +0 -4
- package/node_modules/ink/build/measure-element.js.map +1 -1
- package/node_modules/ink/build/options.d.ts +52 -0
- package/node_modules/ink/build/options.js +2 -0
- package/node_modules/ink/build/options.js.map +1 -0
- package/node_modules/ink/build/output.js +0 -25
- package/node_modules/ink/build/output.js.map +1 -1
- package/node_modules/ink/build/parse-keypress.d.ts +3 -1
- package/node_modules/ink/build/parse-keypress.js +17 -19
- package/node_modules/ink/build/parse-keypress.js.map +1 -1
- package/node_modules/ink/build/reconciler.js +27 -46
- package/node_modules/ink/build/reconciler.js.map +1 -1
- package/node_modules/ink/build/render-border.js +18 -29
- package/node_modules/ink/build/render-border.js.map +1 -1
- package/node_modules/ink/build/render-to-string.js +1 -2
- package/node_modules/ink/build/render-to-string.js.map +1 -1
- package/node_modules/ink/build/render.d.ts +2 -57
- package/node_modules/ink/build/render.js +11 -18
- package/node_modules/ink/build/render.js.map +1 -1
- package/node_modules/ink/build/screen-reader-update.d.ts +13 -0
- package/node_modules/ink/build/screen-reader-update.js +38 -0
- package/node_modules/ink/build/screen-reader-update.js.map +1 -0
- package/node_modules/ink/build/styles.d.ts +16 -78
- package/node_modules/ink/build/styles.js +31 -102
- package/node_modules/ink/build/styles.js.map +1 -1
- package/node_modules/ink/build/utils.d.ts +2 -9
- package/node_modules/ink/build/utils.js +3 -18
- package/node_modules/ink/build/utils.js.map +1 -1
- package/node_modules/ink/build/wrap-text.js +0 -7
- package/node_modules/ink/build/wrap-text.js.map +1 -1
- package/node_modules/ink/build/write-synchronized.d.ts +1 -1
- package/node_modules/ink/build/write-synchronized.js +2 -4
- package/node_modules/ink/build/write-synchronized.js.map +1 -1
- package/node_modules/ink/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/ink/node_modules/emoji-regex/README.md +107 -0
- package/node_modules/ink/node_modules/emoji-regex/index.d.ts +3 -0
- package/node_modules/ink/node_modules/emoji-regex/index.js +4 -0
- package/node_modules/ink/node_modules/emoji-regex/index.mjs +4 -0
- package/node_modules/ink/node_modules/emoji-regex/package.json +45 -0
- package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/index.d.ts +1 -1
- package/node_modules/ink/node_modules/wrap-ansi/index.js +222 -0
- package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/index.js +82 -0
- package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/license +9 -0
- package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/package.json +64 -0
- package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/readme.md +66 -0
- package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/package.json +11 -11
- package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/readme.md +0 -2
- package/node_modules/ink/package.json +98 -34
- package/node_modules/ink/readme.md +48 -554
- package/node_modules/slice-ansi/index.d.ts +1 -1
- package/node_modules/slice-ansi/index.js +89 -146
- package/node_modules/slice-ansi/package.json +5 -5
- package/node_modules/slice-ansi/readme.md +0 -1
- package/node_modules/slice-ansi/tokenize-ansi.js +1 -1
- package/package.json +11 -10
- package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.d.ts +188 -0
- package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.d.ts.map +1 -0
- package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.js +293 -0
- package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.js.map +1 -0
- package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/package.json +25 -0
- package/node_modules/@alcalzone/ansi-tokenize/build/consts.d.ts +0 -17
- package/node_modules/@alcalzone/ansi-tokenize/build/consts.js +0 -28
- package/node_modules/@alcalzone/ansi-tokenize/build/consts.js.map +0 -1
- package/node_modules/ink/build/components/AnimationContext.d.ts +0 -9
- package/node_modules/ink/build/components/AnimationContext.js +0 -13
- package/node_modules/ink/build/components/AnimationContext.js.map +0 -1
- package/node_modules/ink/build/hooks/use-animation.d.ts +0 -49
- package/node_modules/ink/build/hooks/use-animation.js +0 -87
- package/node_modules/ink/build/hooks/use-animation.js.map +0 -1
- package/node_modules/ink/build/hooks/use-box-metrics.d.ts +0 -59
- package/node_modules/ink/build/hooks/use-box-metrics.js +0 -88
- package/node_modules/ink/build/hooks/use-box-metrics.js.map +0 -1
- package/node_modules/ink/build/hooks/use-paste.d.ts +0 -35
- package/node_modules/ink/build/hooks/use-paste.js +0 -62
- package/node_modules/ink/build/hooks/use-paste.js.map +0 -1
- package/node_modules/ink/build/hooks/use-window-size.d.ts +0 -18
- package/node_modules/ink/build/hooks/use-window-size.js +0 -22
- package/node_modules/ink/build/hooks/use-window-size.js.map +0 -1
- package/node_modules/wrap-ansi/index.js +0 -468
- /package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/license +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _stringLength = _interopRequireDefault(require("string-length"));
|
|
9
|
+
|
|
10
|
+
var _sliceAnsi = _interopRequireDefault(require("slice-ansi"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* "Virtual" output class
|
|
16
|
+
*
|
|
17
|
+
* Handles the positioning and saving of the output of each node in the tree.
|
|
18
|
+
* Also responsible for applying transformations to each character of the output.
|
|
19
|
+
*
|
|
20
|
+
* Used to generate the final output of all nodes before writing it to actual output stream (e.g. stdout)
|
|
21
|
+
*/
|
|
22
|
+
class Output {
|
|
23
|
+
constructor({
|
|
24
|
+
width,
|
|
25
|
+
height
|
|
26
|
+
}) {
|
|
27
|
+
this.width = width;
|
|
28
|
+
this.height = height;
|
|
29
|
+
this.writes = []; // Initialize output array with a specific set of rows, so that margin/padding at the bottom is preserved
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
write(x, y, text, {
|
|
33
|
+
transformers
|
|
34
|
+
}) {
|
|
35
|
+
if (!text) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.writes.push({
|
|
40
|
+
x,
|
|
41
|
+
y,
|
|
42
|
+
text,
|
|
43
|
+
transformers
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get() {
|
|
48
|
+
const output = [];
|
|
49
|
+
|
|
50
|
+
for (let y = 0; y < this.height; y++) {
|
|
51
|
+
output.push(' '.repeat(this.width));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const write of this.writes) {
|
|
55
|
+
const {
|
|
56
|
+
x,
|
|
57
|
+
y,
|
|
58
|
+
text,
|
|
59
|
+
transformers
|
|
60
|
+
} = write;
|
|
61
|
+
const lines = text.split('\n');
|
|
62
|
+
let offsetY = 0;
|
|
63
|
+
|
|
64
|
+
for (let line of lines) {
|
|
65
|
+
const currentLine = output[y + offsetY]; // Line can be missing if `text` is taller than height of pre-initialized `this.output`
|
|
66
|
+
|
|
67
|
+
if (!currentLine) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const length = (0, _stringLength.default)(line);
|
|
72
|
+
|
|
73
|
+
for (const transformer of transformers) {
|
|
74
|
+
line = transformer(line);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
output[y + offsetY] = (0, _sliceAnsi.default)(currentLine, 0, x) + line + (0, _sliceAnsi.default)(currentLine, x + length);
|
|
78
|
+
offsetY++;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const generatedOutput = output.map(line => line.trimRight()).join('\n');
|
|
83
|
+
return {
|
|
84
|
+
output: generatedOutput,
|
|
85
|
+
height: output.length
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
exports.default = Output;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _scheduler = require("scheduler");
|
|
9
|
+
|
|
10
|
+
var _reactReconciler = _interopRequireDefault(require("react-reconciler"));
|
|
11
|
+
|
|
12
|
+
var _dom = require("./dom");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const NO_CONTEXT = true;
|
|
17
|
+
const hostConfig = {
|
|
18
|
+
schedulePassiveEffects: _scheduler.unstable_scheduleCallback,
|
|
19
|
+
cancelPassiveEffects: _scheduler.unstable_cancelCallback,
|
|
20
|
+
now: Date.now,
|
|
21
|
+
getRootHostContext: () => NO_CONTEXT,
|
|
22
|
+
prepareForCommit: () => {},
|
|
23
|
+
resetAfterCommit: rootNode => {
|
|
24
|
+
// Since renders are throttled at the instance level and <Static> component children
|
|
25
|
+
// are rendered only once and then get deleted, we need an escape hatch to
|
|
26
|
+
// trigger an immediate render to ensure <Static> children are written to output before they get erased
|
|
27
|
+
if (rootNode.isStaticDirty) {
|
|
28
|
+
rootNode.isStaticDirty = false;
|
|
29
|
+
rootNode.onImmediateRender();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
rootNode.onRender();
|
|
34
|
+
},
|
|
35
|
+
getChildHostContext: () => NO_CONTEXT,
|
|
36
|
+
shouldSetTextContent: (type, props) => {
|
|
37
|
+
return typeof props.children === 'string' || typeof props.children === 'number';
|
|
38
|
+
},
|
|
39
|
+
createInstance: (type, newProps) => {
|
|
40
|
+
const node = (0, _dom.createNode)(type);
|
|
41
|
+
|
|
42
|
+
for (const [key, value] of Object.entries(newProps)) {
|
|
43
|
+
if (key === 'children') {
|
|
44
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
45
|
+
if (type === 'div') {
|
|
46
|
+
// Text node must be wrapped in another node, so that text can be aligned within container
|
|
47
|
+
const textNode = (0, _dom.createNode)('div');
|
|
48
|
+
(0, _dom.setTextContent)(textNode, value);
|
|
49
|
+
(0, _dom.appendChildNode)(node, textNode);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (type === 'span') {
|
|
53
|
+
(0, _dom.setTextContent)(node, value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else if (key === 'style') {
|
|
57
|
+
(0, _dom.setStyle)(node, value);
|
|
58
|
+
} else if (key === 'unstable__transformChildren') {
|
|
59
|
+
node.unstable__transformChildren = value; // eslint-disable-line camelcase
|
|
60
|
+
} else if (key === 'unstable__static') {
|
|
61
|
+
node.unstable__static = true; // eslint-disable-line camelcase
|
|
62
|
+
} else {
|
|
63
|
+
(0, _dom.setAttribute)(node, key, value);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return node;
|
|
68
|
+
},
|
|
69
|
+
createTextInstance: _dom.createTextNode,
|
|
70
|
+
resetTextContent: node => {
|
|
71
|
+
if (node.textContent) {
|
|
72
|
+
node.textContent = '';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (node.childNodes.length > 0) {
|
|
76
|
+
for (const childNode of node.childNodes) {
|
|
77
|
+
(0, _dom.removeChildNode)(node, childNode);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
getPublicInstance: instance => instance,
|
|
82
|
+
appendInitialChild: _dom.appendChildNode,
|
|
83
|
+
appendChild: _dom.appendChildNode,
|
|
84
|
+
insertBefore: _dom.insertBeforeNode,
|
|
85
|
+
finalizeInitialChildren: (node, type, props, rootNode) => {
|
|
86
|
+
if (node.unstable__static) {
|
|
87
|
+
rootNode.isStaticDirty = true;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
supportsMutation: true,
|
|
91
|
+
appendChildToContainer: _dom.appendChildNode,
|
|
92
|
+
insertInContainerBefore: _dom.insertBeforeNode,
|
|
93
|
+
removeChildFromContainer: _dom.removeChildNode,
|
|
94
|
+
prepareUpdate: (node, type, oldProps, newProps, rootNode) => {
|
|
95
|
+
if (node.unstable__static) {
|
|
96
|
+
rootNode.isStaticDirty = true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return true;
|
|
100
|
+
},
|
|
101
|
+
commitUpdate: (node, updatePayload, type, oldProps, newProps) => {
|
|
102
|
+
for (const [key, value] of Object.entries(newProps)) {
|
|
103
|
+
if (key === 'children') {
|
|
104
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
105
|
+
if (type === 'div') {
|
|
106
|
+
// Text node must be wrapped in another node, so that text can be aligned within container
|
|
107
|
+
// If there's no such node, a new one must be created
|
|
108
|
+
if (node.childNodes.length === 0) {
|
|
109
|
+
const textNode = (0, _dom.createNode)('div');
|
|
110
|
+
(0, _dom.setTextContent)(textNode, value);
|
|
111
|
+
(0, _dom.appendChildNode)(node, textNode);
|
|
112
|
+
} else {
|
|
113
|
+
(0, _dom.setTextContent)(node.childNodes[0], value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (type === 'span') {
|
|
118
|
+
(0, _dom.setTextContent)(node, value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} else if (key === 'style') {
|
|
122
|
+
(0, _dom.setStyle)(node, value);
|
|
123
|
+
} else if (key === 'unstable__transformChildren') {
|
|
124
|
+
node.unstable__transformChildren = value; // eslint-disable-line camelcase
|
|
125
|
+
} else if (key === 'unstable__static') {
|
|
126
|
+
node.unstable__static = true; // eslint-disable-line camelcase
|
|
127
|
+
} else {
|
|
128
|
+
(0, _dom.setAttribute)(node, key, value);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
commitTextUpdate: (node, oldText, newText) => {
|
|
133
|
+
(0, _dom.setTextContent)(node, newText);
|
|
134
|
+
},
|
|
135
|
+
removeChild: _dom.removeChildNode
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
var _default = (0, _reactReconciler.default)(hostConfig); // eslint-disable-line new-cap
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
exports.default = _default;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _yogaLayoutPrebuilt = _interopRequireDefault(require("yoga-layout-prebuilt"));
|
|
9
|
+
|
|
10
|
+
var _renderNodeToOutput = _interopRequireDefault(require("../render-node-to-output"));
|
|
11
|
+
|
|
12
|
+
var _calculateWrappedText = _interopRequireDefault(require("../calculate-wrapped-text"));
|
|
13
|
+
|
|
14
|
+
var _output = _interopRequireDefault(require("./output"));
|
|
15
|
+
|
|
16
|
+
var _dom = require("./dom");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
// Since <Static> components can be placed anywhere in the tree, this helper finds and returns them
|
|
21
|
+
const findStaticNode = node => {
|
|
22
|
+
if (node.unstable__static) {
|
|
23
|
+
return node;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for (const childNode of node.childNodes) {
|
|
27
|
+
if (childNode.unstable__static) {
|
|
28
|
+
return childNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (Array.isArray(childNode.childNodes) && childNode.childNodes.length > 0) {
|
|
32
|
+
return findStaticNode(childNode);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var _default = ({
|
|
38
|
+
terminalWidth = 100
|
|
39
|
+
}) => {
|
|
40
|
+
return node => {
|
|
41
|
+
(0, _dom.setStyle)(node, {
|
|
42
|
+
width: terminalWidth
|
|
43
|
+
});
|
|
44
|
+
node.yogaNode.calculateLayout(_yogaLayoutPrebuilt.default.UNDEFINED, _yogaLayoutPrebuilt.default.UNDEFINED, _yogaLayoutPrebuilt.default.DIRECTION_LTR);
|
|
45
|
+
(0, _calculateWrappedText.default)(node);
|
|
46
|
+
node.yogaNode.calculateLayout(_yogaLayoutPrebuilt.default.UNDEFINED, _yogaLayoutPrebuilt.default.UNDEFINED, _yogaLayoutPrebuilt.default.DIRECTION_LTR);
|
|
47
|
+
const output = new _output.default({
|
|
48
|
+
width: node.yogaNode.getComputedWidth(),
|
|
49
|
+
height: node.yogaNode.getComputedHeight()
|
|
50
|
+
});
|
|
51
|
+
(0, _renderNodeToOutput.default)(node, output, {
|
|
52
|
+
skipStaticElements: true
|
|
53
|
+
});
|
|
54
|
+
const staticNode = findStaticNode(node);
|
|
55
|
+
let staticOutput;
|
|
56
|
+
|
|
57
|
+
if (staticNode) {
|
|
58
|
+
staticOutput = new _output.default({
|
|
59
|
+
width: staticNode.yogaNode.getComputedWidth(),
|
|
60
|
+
height: staticNode.yogaNode.getComputedHeight()
|
|
61
|
+
});
|
|
62
|
+
(0, _renderNodeToOutput.default)(staticNode, staticOutput, {
|
|
63
|
+
skipStaticElements: false
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
output: generatedOutput,
|
|
69
|
+
height: outputHeight
|
|
70
|
+
} = output.get();
|
|
71
|
+
return {
|
|
72
|
+
output: generatedOutput,
|
|
73
|
+
outputHeight,
|
|
74
|
+
// Newline at the end is needed, because static output doesn't have one, so
|
|
75
|
+
// interactive output will override last line of static output
|
|
76
|
+
staticOutput: staticOutput ? `${staticOutput.get().output}\n` : undefined
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.default = _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
2
|
+
`useApp` is a React hook that exposes a method to manually exit the app (unmount).
|
|
3
3
|
*/
|
|
4
4
|
declare const useApp: () => import("../components/AppContext.js").Props;
|
|
5
5
|
export default useApp;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import AppContext from '../components/AppContext.js';
|
|
3
3
|
/**
|
|
4
|
-
|
|
4
|
+
`useApp` is a React hook that exposes a method to manually exit the app (unmount).
|
|
5
5
|
*/
|
|
6
6
|
const useApp = () => useContext(AppContext);
|
|
7
7
|
export default useApp;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CursorPosition } from '../log-update.js';
|
|
2
2
|
/**
|
|
3
|
-
|
|
3
|
+
`useCursor` is a React hook that lets you control the terminal cursor position.
|
|
4
4
|
|
|
5
5
|
Setting a cursor position makes the cursor visible at the specified coordinates (relative to the Ink output origin). This is useful for IME (Input Method Editor) support, where the composing character is displayed at the cursor location.
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext, useRef, useCallback, useInsertionEffect } from 'react';
|
|
2
2
|
import CursorContext from '../components/CursorContext.js';
|
|
3
3
|
/**
|
|
4
|
-
|
|
4
|
+
`useCursor` is a React hook that lets you control the terminal cursor position.
|
|
5
5
|
|
|
6
6
|
Setting a cursor position makes the cursor visible at the specified coordinates (relative to the Ink output origin). This is useful for IME (Input Method Editor) support, where the composing character is displayed at the cursor location.
|
|
7
7
|
|
|
@@ -17,27 +17,12 @@ type Output = {
|
|
|
17
17
|
*/
|
|
18
18
|
focusPrevious: Props['focusPrevious'];
|
|
19
19
|
/**
|
|
20
|
-
Switch focus to the element with provided `id`. If there's no element with that `id`, focus
|
|
20
|
+
Switch focus to the element with provided `id`. If there's no element with that `id`, focus will be given to the first focusable component.
|
|
21
21
|
*/
|
|
22
22
|
focus: Props['focus'];
|
|
23
|
-
/**
|
|
24
|
-
The ID of the currently focused component, or `undefined` if no component is focused.
|
|
25
|
-
|
|
26
|
-
@example
|
|
27
|
-
```tsx
|
|
28
|
-
import {Text, useFocusManager} from 'ink';
|
|
29
|
-
|
|
30
|
-
const Example = () => {
|
|
31
|
-
const {activeId} = useFocusManager();
|
|
32
|
-
|
|
33
|
-
return <Text>Focused: {activeId ?? 'none'}</Text>;
|
|
34
|
-
};
|
|
35
|
-
```
|
|
36
|
-
*/
|
|
37
|
-
activeId: Props['activeId'];
|
|
38
23
|
};
|
|
39
24
|
/**
|
|
40
|
-
|
|
25
|
+
This hook exposes methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
|
|
41
26
|
*/
|
|
42
27
|
declare const useFocusManager: () => Output;
|
|
43
28
|
export default useFocusManager;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import FocusContext from '../components/FocusContext.js';
|
|
3
3
|
/**
|
|
4
|
-
|
|
4
|
+
This hook exposes methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
|
|
5
5
|
*/
|
|
6
6
|
const useFocusManager = () => {
|
|
7
7
|
const focusContext = useContext(FocusContext);
|
|
@@ -11,7 +11,6 @@ const useFocusManager = () => {
|
|
|
11
11
|
focusNext: focusContext.focusNext,
|
|
12
12
|
focusPrevious: focusContext.focusPrevious,
|
|
13
13
|
focus: focusContext.focus,
|
|
14
|
-
activeId: focusContext.activeId,
|
|
15
14
|
};
|
|
16
15
|
};
|
|
17
16
|
export default useFocusManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-focus-manager.js","sourceRoot":"","sources":["../../src/hooks/use-focus-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,YAA0B,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-focus-manager.js","sourceRoot":"","sources":["../../src/hooks/use-focus-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,YAA0B,MAAM,+BAA+B,CAAC;AA6BvE;;EAEE;AACF,MAAM,eAAe,GAAG,GAAW,EAAE;IACpC,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAE9C,OAAO;QACN,WAAW,EAAE,YAAY,CAAC,WAAW;QACrC,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,SAAS,EAAE,YAAY,CAAC,SAAS;QACjC,aAAa,EAAE,YAAY,CAAC,aAAa;QACzC,KAAK,EAAE,YAAY,CAAC,KAAK;KACzB,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -23,8 +23,7 @@ type Output = {
|
|
|
23
23
|
focus: (id: string) => void;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
A
|
|
27
|
-
A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses <kbd>Tab</kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
|
|
26
|
+
A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses <kbd>Tab</kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered. This hook returns an object with an `isFocused` boolean property, which determines whether this component is focused.
|
|
28
27
|
*/
|
|
29
28
|
declare const useFocus: ({ isActive, autoFocus, id: customId, }?: Input) => Output;
|
|
30
29
|
export default useFocus;
|
|
@@ -2,8 +2,7 @@ import { useEffect, useContext, useMemo } from 'react';
|
|
|
2
2
|
import FocusContext from '../components/FocusContext.js';
|
|
3
3
|
import useStdin from './use-stdin.js';
|
|
4
4
|
/**
|
|
5
|
-
A
|
|
6
|
-
A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses <kbd>Tab</kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
|
|
5
|
+
A component that uses the `useFocus` hook becomes "focusable" to Ink, so when the user presses <kbd>Tab</kbd>, Ink will switch focus to this component. If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered. This hook returns an object with an `isFocused` boolean property, which determines whether this component is focused.
|
|
7
6
|
*/
|
|
8
7
|
const useFocus = ({ isActive = true, autoFocus = false, id: customId, } = {}) => {
|
|
9
8
|
const { isRawModeSupported, setRawMode } = useStdin();
|
|
@@ -16,7 +15,7 @@ const useFocus = ({ isActive = true, autoFocus = false, id: customId, } = {}) =>
|
|
|
16
15
|
return () => {
|
|
17
16
|
remove(id);
|
|
18
17
|
};
|
|
19
|
-
}, [id, autoFocus
|
|
18
|
+
}, [id, autoFocus]);
|
|
20
19
|
useEffect(() => {
|
|
21
20
|
if (isActive) {
|
|
22
21
|
activate(id);
|
|
@@ -24,7 +23,7 @@ const useFocus = ({ isActive = true, autoFocus = false, id: customId, } = {}) =>
|
|
|
24
23
|
else {
|
|
25
24
|
deactivate(id);
|
|
26
25
|
}
|
|
27
|
-
}, [isActive, id
|
|
26
|
+
}, [isActive, id]);
|
|
28
27
|
useEffect(() => {
|
|
29
28
|
if (!isRawModeSupported || !isActive) {
|
|
30
29
|
return;
|
|
@@ -33,7 +32,7 @@ const useFocus = ({ isActive = true, autoFocus = false, id: customId, } = {}) =>
|
|
|
33
32
|
return () => {
|
|
34
33
|
setRawMode(false);
|
|
35
34
|
};
|
|
36
|
-
}, [isActive
|
|
35
|
+
}, [isActive]);
|
|
37
36
|
return {
|
|
38
37
|
isFocused: Boolean(id) && activeId === id,
|
|
39
38
|
focus,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-focus.js","sourceRoot":"","sources":["../../src/hooks/use-focus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AACrD,OAAO,YAAY,MAAM,+BAA+B,CAAC;AACzD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AA+BtC
|
|
1
|
+
{"version":3,"file":"use-focus.js","sourceRoot":"","sources":["../../src/hooks/use-focus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AACrD,OAAO,YAAY,MAAM,+BAA+B,CAAC;AACzD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AA+BtC;;EAEE;AACF,MAAM,QAAQ,GAAG,CAAC,EACjB,QAAQ,GAAG,IAAI,EACf,SAAS,GAAG,KAAK,EACjB,EAAE,EAAE,QAAQ,MACF,EAAE,EAAU,EAAE;IACxB,MAAM,EAAC,kBAAkB,EAAE,UAAU,EAAC,GAAG,QAAQ,EAAE,CAAC;IACpD,MAAM,EAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAC,GACzD,UAAU,CAAC,YAAY,CAAC,CAAC;IAE1B,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;QACvB,OAAO,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,SAAS,CAAC,GAAG,EAAE;QACd,GAAG,CAAC,EAAE,EAAE,EAAC,SAAS,EAAC,CAAC,CAAC;QAErB,OAAO,GAAG,EAAE;YACX,MAAM,CAAC,EAAE,CAAC,CAAC;QACZ,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;IAEpB,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,QAAQ,EAAE,CAAC;YACd,QAAQ,CAAC,EAAE,CAAC,CAAC;QACd,CAAC;aAAM,CAAC;YACP,UAAU,CAAC,EAAE,CAAC,CAAC;QAChB,CAAC;IACF,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IAEnB,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,kBAAkB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtC,OAAO;QACR,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,CAAC;QAEjB,OAAO,GAAG,EAAE;YACX,UAAU,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO;QACN,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,IAAI,QAAQ,KAAK,EAAE;QACzC,KAAK;KACL,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -107,8 +107,7 @@ type Options = {
|
|
|
107
107
|
isActive?: boolean;
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
110
|
-
|
|
111
|
-
It's a more convenient alternative to using `StdinContext` and listening for `data` events. The callback you pass to `useInput` is called for each character when the user enters any input. However, if the user pastes text and it's more than one character, the callback will be called only once, and the whole string will be passed as `input`.
|
|
110
|
+
This hook is used for handling user input. It's a more convenient alternative to using `StdinContext` and listening for `data` events. The callback you pass to `useInput` is called for each character when the user enters any input. However, if the user pastes text and it's more than one character, the callback will be called only once, and the whole string will be passed as `input`.
|
|
112
111
|
|
|
113
112
|
```
|
|
114
113
|
import {useInput} from 'ink';
|