@elench/testkit 0.1.113 → 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.
Files changed (196) hide show
  1. package/lib/cli/assistant/app.mjs +4 -2
  2. package/lib/cli/assistant/session.mjs +5 -1
  3. package/lib/cli/assistant/state.mjs +1 -2
  4. package/lib/cli/components/blocks/run-tree.mjs +7 -2
  5. package/lib/cli/components/hooks/use-element-layout.mjs +63 -0
  6. package/lib/cli/components/hooks/use-spinner-frame.mjs +26 -0
  7. package/lib/playwright/index.d.ts +1 -0
  8. package/lib/playwright/index.mjs +1 -0
  9. package/lib/runner/default-runtime-runner.mjs +5 -28
  10. package/lib/runner/lifecycle.mjs +2 -51
  11. package/lib/runner/managed-processes.mjs +2 -1
  12. package/lib/runner/playwright-config.mjs +13 -1
  13. package/lib/runner/playwright-runner.mjs +85 -15
  14. package/lib/runner/processes.mjs +59 -3
  15. package/lib/runner/subprocess.mjs +155 -0
  16. package/lib/shared/file-timeout.mjs +1 -1
  17. package/lib/ui/index.d.ts +2 -0
  18. package/lib/ui/index.mjs +1 -0
  19. package/node_modules/@alcalzone/ansi-tokenize/README.md +0 -5
  20. package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.d.ts +8 -0
  21. package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.js +10 -8
  22. package/node_modules/@alcalzone/ansi-tokenize/build/ansiCodes.js.map +1 -1
  23. package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.d.ts +1 -5
  24. package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.js +9 -45
  25. package/node_modules/@alcalzone/ansi-tokenize/build/tokenize.js.map +1 -1
  26. package/node_modules/@alcalzone/ansi-tokenize/package.json +1 -1
  27. package/node_modules/@elench/next-analysis/package.json +1 -1
  28. package/node_modules/@elench/testkit-bridge/package.json +2 -2
  29. package/node_modules/@elench/testkit-protocol/package.json +1 -1
  30. package/node_modules/@elench/ts-analysis/package.json +1 -1
  31. package/node_modules/cli-boxes/index.d.ts +95 -90
  32. package/node_modules/cli-boxes/index.js +5 -2
  33. package/node_modules/cli-boxes/package.json +6 -13
  34. package/node_modules/cli-boxes/readme.md +15 -3
  35. package/node_modules/cli-truncate/index.d.ts +1 -1
  36. package/node_modules/cli-truncate/package.json +4 -4
  37. package/node_modules/cli-truncate/readme.md +1 -0
  38. package/node_modules/ink/build/apply-styles.js +175 -0
  39. package/node_modules/ink/build/build-layout.js +77 -0
  40. package/node_modules/ink/build/calculate-wrapped-text.js +53 -0
  41. package/node_modules/ink/build/components/App.d.ts +1 -4
  42. package/node_modules/ink/build/components/App.js +22 -142
  43. package/node_modules/ink/build/components/App.js.map +1 -1
  44. package/node_modules/ink/build/components/AppContext.d.ts +3 -23
  45. package/node_modules/ink/build/components/AppContext.js +4 -7
  46. package/node_modules/ink/build/components/AppContext.js.map +1 -1
  47. package/node_modules/ink/build/components/Box.d.ts +3 -16
  48. package/node_modules/ink/build/components/Color.js +62 -0
  49. package/node_modules/ink/build/components/Cursor.d.ts +83 -0
  50. package/node_modules/ink/build/components/Cursor.js +53 -0
  51. package/node_modules/ink/build/components/Cursor.js.map +1 -0
  52. package/node_modules/ink/build/components/ErrorBoundary.d.ts +2 -2
  53. package/node_modules/ink/build/components/ErrorOverview.js +6 -6
  54. package/node_modules/ink/build/components/ErrorOverview.js.map +1 -1
  55. package/node_modules/ink/build/components/Static.js.map +1 -1
  56. package/node_modules/ink/build/components/StdinContext.d.ts +1 -7
  57. package/node_modules/ink/build/components/StdinContext.js +0 -1
  58. package/node_modules/ink/build/components/StdinContext.js.map +1 -1
  59. package/node_modules/ink/build/components/Text.d.ts +1 -1
  60. package/node_modules/ink/build/components/Text.js +1 -1
  61. package/node_modules/ink/build/components/Text.js.map +1 -1
  62. package/node_modules/ink/build/components/Transform.d.ts +1 -1
  63. package/node_modules/ink/build/devtools-window-polyfill.js +4 -7
  64. package/node_modules/ink/build/devtools-window-polyfill.js.map +1 -1
  65. package/node_modules/ink/build/devtools.js +6 -31
  66. package/node_modules/ink/build/devtools.js.map +1 -1
  67. package/node_modules/ink/build/dom.d.ts +1 -5
  68. package/node_modules/ink/build/dom.js +1 -20
  69. package/node_modules/ink/build/dom.js.map +1 -1
  70. package/node_modules/ink/build/experimental/apply-style.js +140 -0
  71. package/node_modules/ink/build/experimental/dom.js +123 -0
  72. package/node_modules/ink/build/experimental/output.js +91 -0
  73. package/node_modules/ink/build/experimental/reconciler.js +141 -0
  74. package/node_modules/ink/build/experimental/renderer.js +81 -0
  75. package/node_modules/ink/build/hooks/use-app.d.ts +1 -1
  76. package/node_modules/ink/build/hooks/use-app.js +1 -1
  77. package/node_modules/ink/build/hooks/use-cursor.d.ts +1 -1
  78. package/node_modules/ink/build/hooks/use-cursor.js +1 -1
  79. package/node_modules/ink/build/hooks/use-focus-manager.d.ts +2 -17
  80. package/node_modules/ink/build/hooks/use-focus-manager.js +1 -2
  81. package/node_modules/ink/build/hooks/use-focus-manager.js.map +1 -1
  82. package/node_modules/ink/build/hooks/use-focus.d.ts +1 -2
  83. package/node_modules/ink/build/hooks/use-focus.js +4 -5
  84. package/node_modules/ink/build/hooks/use-focus.js.map +1 -1
  85. package/node_modules/ink/build/hooks/use-input.d.ts +1 -2
  86. package/node_modules/ink/build/hooks/use-input.js +80 -82
  87. package/node_modules/ink/build/hooks/use-input.js.map +1 -1
  88. package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.d.ts +1 -2
  89. package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js +1 -2
  90. package/node_modules/ink/build/hooks/use-is-screen-reader-enabled.js.map +1 -1
  91. package/node_modules/ink/build/hooks/use-stderr.d.ts +1 -1
  92. package/node_modules/ink/build/hooks/use-stderr.js +1 -1
  93. package/node_modules/ink/build/hooks/use-stdin.d.ts +2 -4
  94. package/node_modules/ink/build/hooks/use-stdin.js +1 -2
  95. package/node_modules/ink/build/hooks/use-stdin.js.map +1 -1
  96. package/node_modules/ink/build/hooks/use-stdout.d.ts +1 -1
  97. package/node_modules/ink/build/hooks/use-stdout.js +1 -1
  98. package/node_modules/ink/build/hooks/useInput.js +38 -0
  99. package/node_modules/ink/build/index.d.ts +1 -8
  100. package/node_modules/ink/build/index.js +0 -4
  101. package/node_modules/ink/build/index.js.map +1 -1
  102. package/node_modules/ink/build/ink.d.ts +3 -48
  103. package/node_modules/ink/build/ink.js +155 -325
  104. package/node_modules/ink/build/ink.js.map +1 -1
  105. package/node_modules/ink/build/input-parser.d.ts +1 -4
  106. package/node_modules/ink/build/input-parser.js +30 -70
  107. package/node_modules/ink/build/input-parser.js.map +1 -1
  108. package/node_modules/ink/build/instance.js +205 -0
  109. package/node_modules/ink/build/layout.d.ts +7 -0
  110. package/node_modules/ink/build/layout.js +33 -0
  111. package/node_modules/ink/build/layout.js.map +1 -0
  112. package/node_modules/ink/build/log-update.d.ts +0 -1
  113. package/node_modules/ink/build/log-update.js +1 -13
  114. package/node_modules/ink/build/log-update.js.map +1 -1
  115. package/node_modules/ink/build/measure-element.d.ts +0 -4
  116. package/node_modules/ink/build/measure-element.js +0 -4
  117. package/node_modules/ink/build/measure-element.js.map +1 -1
  118. package/node_modules/ink/build/options.d.ts +52 -0
  119. package/node_modules/ink/build/options.js +2 -0
  120. package/node_modules/ink/build/options.js.map +1 -0
  121. package/node_modules/ink/build/output.js +0 -25
  122. package/node_modules/ink/build/output.js.map +1 -1
  123. package/node_modules/ink/build/parse-keypress.d.ts +3 -1
  124. package/node_modules/ink/build/parse-keypress.js +17 -19
  125. package/node_modules/ink/build/parse-keypress.js.map +1 -1
  126. package/node_modules/ink/build/reconciler.js +27 -46
  127. package/node_modules/ink/build/reconciler.js.map +1 -1
  128. package/node_modules/ink/build/render-border.js +18 -29
  129. package/node_modules/ink/build/render-border.js.map +1 -1
  130. package/node_modules/ink/build/render-to-string.js +1 -2
  131. package/node_modules/ink/build/render-to-string.js.map +1 -1
  132. package/node_modules/ink/build/render.d.ts +2 -57
  133. package/node_modules/ink/build/render.js +11 -18
  134. package/node_modules/ink/build/render.js.map +1 -1
  135. package/node_modules/ink/build/screen-reader-update.d.ts +13 -0
  136. package/node_modules/ink/build/screen-reader-update.js +38 -0
  137. package/node_modules/ink/build/screen-reader-update.js.map +1 -0
  138. package/node_modules/ink/build/styles.d.ts +16 -78
  139. package/node_modules/ink/build/styles.js +31 -102
  140. package/node_modules/ink/build/styles.js.map +1 -1
  141. package/node_modules/ink/build/utils.d.ts +2 -9
  142. package/node_modules/ink/build/utils.js +3 -18
  143. package/node_modules/ink/build/utils.js.map +1 -1
  144. package/node_modules/ink/build/wrap-text.js +0 -7
  145. package/node_modules/ink/build/wrap-text.js.map +1 -1
  146. package/node_modules/ink/build/write-synchronized.d.ts +1 -1
  147. package/node_modules/ink/build/write-synchronized.js +2 -4
  148. package/node_modules/ink/build/write-synchronized.js.map +1 -1
  149. package/node_modules/ink/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  150. package/node_modules/ink/node_modules/emoji-regex/README.md +107 -0
  151. package/node_modules/ink/node_modules/emoji-regex/index.d.ts +3 -0
  152. package/node_modules/ink/node_modules/emoji-regex/index.js +4 -0
  153. package/node_modules/ink/node_modules/emoji-regex/index.mjs +4 -0
  154. package/node_modules/ink/node_modules/emoji-regex/package.json +45 -0
  155. package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/index.d.ts +1 -1
  156. package/node_modules/ink/node_modules/wrap-ansi/index.js +222 -0
  157. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/index.d.ts +39 -0
  158. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/index.js +82 -0
  159. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/license +9 -0
  160. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/package.json +64 -0
  161. package/node_modules/ink/node_modules/wrap-ansi/node_modules/string-width/readme.md +66 -0
  162. package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/package.json +11 -11
  163. package/node_modules/{wrap-ansi → ink/node_modules/wrap-ansi}/readme.md +0 -2
  164. package/node_modules/ink/package.json +98 -34
  165. package/node_modules/ink/readme.md +48 -554
  166. package/node_modules/slice-ansi/index.d.ts +1 -1
  167. package/node_modules/slice-ansi/index.js +89 -146
  168. package/node_modules/slice-ansi/package.json +5 -5
  169. package/node_modules/slice-ansi/readme.md +0 -1
  170. package/node_modules/slice-ansi/tokenize-ansi.js +1 -1
  171. package/package.json +11 -10
  172. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.d.ts +188 -0
  173. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.d.ts.map +1 -0
  174. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.js +293 -0
  175. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/dist/index.js.map +1 -0
  176. package/packages/testkit-bridge/node_modules/@elench/testkit-protocol/package.json +25 -0
  177. package/node_modules/@alcalzone/ansi-tokenize/build/consts.d.ts +0 -17
  178. package/node_modules/@alcalzone/ansi-tokenize/build/consts.js +0 -28
  179. package/node_modules/@alcalzone/ansi-tokenize/build/consts.js.map +0 -1
  180. package/node_modules/ink/build/components/AnimationContext.d.ts +0 -9
  181. package/node_modules/ink/build/components/AnimationContext.js +0 -13
  182. package/node_modules/ink/build/components/AnimationContext.js.map +0 -1
  183. package/node_modules/ink/build/hooks/use-animation.d.ts +0 -49
  184. package/node_modules/ink/build/hooks/use-animation.js +0 -87
  185. package/node_modules/ink/build/hooks/use-animation.js.map +0 -1
  186. package/node_modules/ink/build/hooks/use-box-metrics.d.ts +0 -59
  187. package/node_modules/ink/build/hooks/use-box-metrics.js +0 -88
  188. package/node_modules/ink/build/hooks/use-box-metrics.js.map +0 -1
  189. package/node_modules/ink/build/hooks/use-paste.d.ts +0 -35
  190. package/node_modules/ink/build/hooks/use-paste.js +0 -62
  191. package/node_modules/ink/build/hooks/use-paste.js.map +0 -1
  192. package/node_modules/ink/build/hooks/use-window-size.d.ts +0 -18
  193. package/node_modules/ink/build/hooks/use-window-size.js +0 -22
  194. package/node_modules/ink/build/hooks/use-window-size.js.map +0 -1
  195. package/node_modules/wrap-ansi/index.js +0 -468
  196. /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
- A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
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
- A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
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
- A React hook that returns methods to control the terminal cursor position.
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
- A React hook that returns methods to control the terminal cursor position.
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 is not changed.
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
- A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
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
- A React hook that returns methods to enable or disable focus management for all components or manually switch focus to the next or previous components.
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;AA6CvE;;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;QACzB,QAAQ,EAAE,YAAY,CAAC,QAAQ;KAC/B,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,eAAe,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 React hook that returns focus state and focus controls for the current component.
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 React hook that returns focus state and focus controls for the current component.
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, add, remove]);
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, activate, deactivate]);
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, isRawModeSupported, setRawMode]);
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;;;EAGE;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,C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B,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
- A React hook that returns `void` and handles user input.
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';