@jrichman/ink 6.3.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.
Files changed (141) hide show
  1. package/build/colorize.d.ts +3 -0
  2. package/build/colorize.js +48 -0
  3. package/build/colorize.js.map +1 -0
  4. package/build/components/AccessibilityContext.d.ts +3 -0
  5. package/build/components/AccessibilityContext.js +5 -0
  6. package/build/components/AccessibilityContext.js.map +1 -0
  7. package/build/components/App.d.ts +59 -0
  8. package/build/components/App.js +286 -0
  9. package/build/components/App.js.map +1 -0
  10. package/build/components/AppContext.d.ts +11 -0
  11. package/build/components/AppContext.js +11 -0
  12. package/build/components/AppContext.js.map +1 -0
  13. package/build/components/BackgroundContext.d.ts +4 -0
  14. package/build/components/BackgroundContext.js +3 -0
  15. package/build/components/BackgroundContext.js.map +1 -0
  16. package/build/components/Box.d.ts +122 -0
  17. package/build/components/Box.js +34 -0
  18. package/build/components/Box.js.map +1 -0
  19. package/build/components/ErrorOverview.d.ts +6 -0
  20. package/build/components/ErrorOverview.js +84 -0
  21. package/build/components/ErrorOverview.js.map +1 -0
  22. package/build/components/FocusContext.d.ts +16 -0
  23. package/build/components/FocusContext.js +17 -0
  24. package/build/components/FocusContext.js.map +1 -0
  25. package/build/components/Newline.d.ts +13 -0
  26. package/build/components/Newline.js +8 -0
  27. package/build/components/Newline.js.map +1 -0
  28. package/build/components/Spacer.d.ts +7 -0
  29. package/build/components/Spacer.js +11 -0
  30. package/build/components/Spacer.js.map +1 -0
  31. package/build/components/Static.d.ts +24 -0
  32. package/build/components/Static.js +28 -0
  33. package/build/components/Static.js.map +1 -0
  34. package/build/components/StderrContext.d.ts +15 -0
  35. package/build/components/StderrContext.js +13 -0
  36. package/build/components/StderrContext.js.map +1 -0
  37. package/build/components/StdinContext.d.ts +22 -0
  38. package/build/components/StdinContext.js +19 -0
  39. package/build/components/StdinContext.js.map +1 -0
  40. package/build/components/StdoutContext.d.ts +15 -0
  41. package/build/components/StdoutContext.js +13 -0
  42. package/build/components/StdoutContext.js.map +1 -0
  43. package/build/components/Text.d.ts +55 -0
  44. package/build/components/Text.js +50 -0
  45. package/build/components/Text.js.map +1 -0
  46. package/build/components/Transform.d.ts +16 -0
  47. package/build/components/Transform.js +15 -0
  48. package/build/components/Transform.js.map +1 -0
  49. package/build/devtools-window-polyfill.d.ts +1 -0
  50. package/build/devtools-window-polyfill.js +65 -0
  51. package/build/devtools-window-polyfill.js.map +1 -0
  52. package/build/devtools.d.ts +1 -0
  53. package/build/devtools.js +2 -0
  54. package/build/devtools.js.map +1 -0
  55. package/build/dom.d.ts +62 -0
  56. package/build/dom.js +123 -0
  57. package/build/dom.js.map +1 -0
  58. package/build/get-max-width.d.ts +3 -0
  59. package/build/get-max-width.js +10 -0
  60. package/build/get-max-width.js.map +1 -0
  61. package/build/hooks/use-app.d.ts +5 -0
  62. package/build/hooks/use-app.js +8 -0
  63. package/build/hooks/use-app.js.map +1 -0
  64. package/build/hooks/use-focus-manager.d.ts +28 -0
  65. package/build/hooks/use-focus-manager.js +17 -0
  66. package/build/hooks/use-focus-manager.js.map +1 -0
  67. package/build/hooks/use-focus.d.ts +29 -0
  68. package/build/hooks/use-focus.js +42 -0
  69. package/build/hooks/use-focus.js.map +1 -0
  70. package/build/hooks/use-input.d.ts +93 -0
  71. package/build/hooks/use-input.js +93 -0
  72. package/build/hooks/use-input.js.map +1 -0
  73. package/build/hooks/use-is-screen-reader-enabled.d.ts +5 -0
  74. package/build/hooks/use-is-screen-reader-enabled.js +11 -0
  75. package/build/hooks/use-is-screen-reader-enabled.js.map +1 -0
  76. package/build/hooks/use-stderr.d.ts +5 -0
  77. package/build/hooks/use-stderr.js +8 -0
  78. package/build/hooks/use-stderr.js.map +1 -0
  79. package/build/hooks/use-stdin.d.ts +5 -0
  80. package/build/hooks/use-stdin.js +8 -0
  81. package/build/hooks/use-stdin.js.map +1 -0
  82. package/build/hooks/use-stdout.d.ts +5 -0
  83. package/build/hooks/use-stdout.js +8 -0
  84. package/build/hooks/use-stdout.js.map +1 -0
  85. package/build/index.d.ts +28 -0
  86. package/build/index.js +17 -0
  87. package/build/index.js.map +1 -0
  88. package/build/ink.d.ts +43 -0
  89. package/build/ink.js +315 -0
  90. package/build/ink.js.map +1 -0
  91. package/build/instances.d.ts +3 -0
  92. package/build/instances.js +8 -0
  93. package/build/instances.js.map +1 -0
  94. package/build/log-update.d.ts +15 -0
  95. package/build/log-update.js +109 -0
  96. package/build/log-update.js.map +1 -0
  97. package/build/measure-element.d.ts +38 -0
  98. package/build/measure-element.js +118 -0
  99. package/build/measure-element.js.map +1 -0
  100. package/build/measure-text.d.ts +6 -0
  101. package/build/measure-text.js +21 -0
  102. package/build/measure-text.js.map +1 -0
  103. package/build/output.d.ts +36 -0
  104. package/build/output.js +191 -0
  105. package/build/output.js.map +1 -0
  106. package/build/parse-keypress.d.ts +14 -0
  107. package/build/parse-keypress.js +225 -0
  108. package/build/parse-keypress.js.map +1 -0
  109. package/build/reconciler.d.ts +4 -0
  110. package/build/reconciler.js +254 -0
  111. package/build/reconciler.js.map +1 -0
  112. package/build/render-background.d.ts +4 -0
  113. package/build/render-background.js +25 -0
  114. package/build/render-background.js.map +1 -0
  115. package/build/render-border.d.ts +4 -0
  116. package/build/render-border.js +73 -0
  117. package/build/render-border.js.map +1 -0
  118. package/build/render-node-to-output.d.ts +14 -0
  119. package/build/render-node-to-output.js +296 -0
  120. package/build/render-node-to-output.js.map +1 -0
  121. package/build/render.d.ts +87 -0
  122. package/build/render.js +50 -0
  123. package/build/render.js.map +1 -0
  124. package/build/renderer.d.ts +8 -0
  125. package/build/renderer.js +55 -0
  126. package/build/renderer.js.map +1 -0
  127. package/build/scroll.d.ts +8 -0
  128. package/build/scroll.js +35 -0
  129. package/build/scroll.js.map +1 -0
  130. package/build/squash-text-nodes.d.ts +3 -0
  131. package/build/squash-text-nodes.js +35 -0
  132. package/build/squash-text-nodes.js.map +1 -0
  133. package/build/styles.d.ts +260 -0
  134. package/build/styles.js +257 -0
  135. package/build/styles.js.map +1 -0
  136. package/build/wrap-text.d.ts +3 -0
  137. package/build/wrap-text.js +31 -0
  138. package/build/wrap-text.js.map +1 -0
  139. package/license +9 -0
  140. package/package.json +194 -0
  141. package/readme.md +2331 -0
package/build/dom.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { type Node as YogaNode } from 'yoga-layout';
2
+ import { type Styles } from './styles.js';
3
+ import { type OutputTransformer } from './render-node-to-output.js';
4
+ type InkNode = {
5
+ parentNode: DOMElement | undefined;
6
+ yogaNode?: YogaNode;
7
+ internal_static?: boolean;
8
+ style: Styles;
9
+ };
10
+ export type TextName = '#text';
11
+ export type ElementNames = 'ink-root' | 'ink-box' | 'ink-text' | 'ink-virtual-text';
12
+ export type NodeNames = ElementNames | TextName;
13
+ export type DOMElement = {
14
+ nodeName: ElementNames;
15
+ attributes: Record<string, DOMNodeAttribute>;
16
+ childNodes: DOMNode[];
17
+ internal_transform?: OutputTransformer;
18
+ internal_accessibility?: {
19
+ role?: 'button' | 'checkbox' | 'combobox' | 'list' | 'listbox' | 'listitem' | 'menu' | 'menuitem' | 'option' | 'progressbar' | 'radio' | 'radiogroup' | 'tab' | 'tablist' | 'table' | 'textbox' | 'timer' | 'toolbar';
20
+ state?: {
21
+ busy?: boolean;
22
+ checked?: boolean;
23
+ disabled?: boolean;
24
+ expanded?: boolean;
25
+ multiline?: boolean;
26
+ multiselectable?: boolean;
27
+ readonly?: boolean;
28
+ required?: boolean;
29
+ selected?: boolean;
30
+ };
31
+ };
32
+ isStaticDirty?: boolean;
33
+ staticNode?: DOMElement;
34
+ onComputeLayout?: () => void;
35
+ onRender?: () => void;
36
+ onImmediateRender?: () => void;
37
+ internal_scrollTop?: number;
38
+ internal_scrollHeight?: number;
39
+ internal_clientHeight?: number;
40
+ internal_scrollLeft?: number;
41
+ internal_scrollWidth?: number;
42
+ internal_clientWidth?: number;
43
+ } & InkNode;
44
+ export type TextNode = {
45
+ nodeName: TextName;
46
+ nodeValue: string;
47
+ } & InkNode;
48
+ export type DOMNode<T = {
49
+ nodeName: NodeNames;
50
+ }> = T extends {
51
+ nodeName: infer U;
52
+ } ? U extends '#text' ? TextNode : DOMElement : never;
53
+ export type DOMNodeAttribute = boolean | string | number;
54
+ export declare const createNode: (nodeName: ElementNames) => DOMElement;
55
+ export declare const appendChildNode: (node: DOMElement, childNode: DOMElement) => void;
56
+ export declare const insertBeforeNode: (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode) => void;
57
+ export declare const removeChildNode: (node: DOMElement, removeNode: DOMNode) => void;
58
+ export declare const setAttribute: (node: DOMElement, key: string, value: DOMNodeAttribute) => void;
59
+ export declare const setStyle: (node: DOMNode, style: Styles) => void;
60
+ export declare const createTextNode: (text: string) => TextNode;
61
+ export declare const setTextNodeValue: (node: TextNode, text: string) => void;
62
+ export {};
package/build/dom.js ADDED
@@ -0,0 +1,123 @@
1
+ import Yoga from 'yoga-layout';
2
+ import measureText from './measure-text.js';
3
+ import wrapText from './wrap-text.js';
4
+ import squashTextNodes from './squash-text-nodes.js';
5
+ export const createNode = (nodeName) => {
6
+ const node = {
7
+ nodeName,
8
+ style: {},
9
+ attributes: {},
10
+ childNodes: [],
11
+ parentNode: undefined,
12
+ yogaNode: nodeName === 'ink-virtual-text' ? undefined : Yoga.Node.create(),
13
+ // eslint-disable-next-line @typescript-eslint/naming-convention
14
+ internal_accessibility: {},
15
+ };
16
+ if (nodeName === 'ink-text') {
17
+ node.yogaNode?.setMeasureFunc(measureTextNode.bind(null, node));
18
+ }
19
+ return node;
20
+ };
21
+ export const appendChildNode = (node, childNode) => {
22
+ if (childNode.parentNode) {
23
+ removeChildNode(childNode.parentNode, childNode);
24
+ }
25
+ childNode.parentNode = node;
26
+ node.childNodes.push(childNode);
27
+ if (childNode.yogaNode) {
28
+ node.yogaNode?.insertChild(childNode.yogaNode, node.yogaNode.getChildCount());
29
+ }
30
+ if (node.nodeName === 'ink-text' || node.nodeName === 'ink-virtual-text') {
31
+ markNodeAsDirty(node);
32
+ }
33
+ };
34
+ export const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
35
+ if (newChildNode.parentNode) {
36
+ removeChildNode(newChildNode.parentNode, newChildNode);
37
+ }
38
+ newChildNode.parentNode = node;
39
+ const index = node.childNodes.indexOf(beforeChildNode);
40
+ if (index >= 0) {
41
+ node.childNodes.splice(index, 0, newChildNode);
42
+ if (newChildNode.yogaNode) {
43
+ node.yogaNode?.insertChild(newChildNode.yogaNode, index);
44
+ }
45
+ return;
46
+ }
47
+ node.childNodes.push(newChildNode);
48
+ if (newChildNode.yogaNode) {
49
+ node.yogaNode?.insertChild(newChildNode.yogaNode, node.yogaNode.getChildCount());
50
+ }
51
+ if (node.nodeName === 'ink-text' || node.nodeName === 'ink-virtual-text') {
52
+ markNodeAsDirty(node);
53
+ }
54
+ };
55
+ export const removeChildNode = (node, removeNode) => {
56
+ if (removeNode.yogaNode) {
57
+ removeNode.parentNode?.yogaNode?.removeChild(removeNode.yogaNode);
58
+ }
59
+ removeNode.parentNode = undefined;
60
+ const index = node.childNodes.indexOf(removeNode);
61
+ if (index >= 0) {
62
+ node.childNodes.splice(index, 1);
63
+ }
64
+ if (node.nodeName === 'ink-text' || node.nodeName === 'ink-virtual-text') {
65
+ markNodeAsDirty(node);
66
+ }
67
+ };
68
+ export const setAttribute = (node, key, value) => {
69
+ if (key === 'internal_accessibility') {
70
+ node.internal_accessibility = value;
71
+ return;
72
+ }
73
+ node.attributes[key] = value;
74
+ };
75
+ export const setStyle = (node, style) => {
76
+ node.style = style;
77
+ };
78
+ export const createTextNode = (text) => {
79
+ const node = {
80
+ nodeName: '#text',
81
+ nodeValue: text,
82
+ yogaNode: undefined,
83
+ parentNode: undefined,
84
+ style: {},
85
+ };
86
+ setTextNodeValue(node, text);
87
+ return node;
88
+ };
89
+ const measureTextNode = function (node, width) {
90
+ const text = node.nodeName === '#text' ? node.nodeValue : squashTextNodes(node);
91
+ const dimensions = measureText(text);
92
+ // Text fits into container, no need to wrap
93
+ if (dimensions.width <= width) {
94
+ return dimensions;
95
+ }
96
+ // This is happening when <Box> is shrinking child nodes and Yoga asks
97
+ // if we can fit this text node in a <1px space, so we just tell Yoga "no"
98
+ if (dimensions.width >= 1 && width > 0 && width < 1) {
99
+ return dimensions;
100
+ }
101
+ const textWrap = node.style?.textWrap ?? 'wrap';
102
+ const wrappedText = wrapText(text, width, textWrap);
103
+ return measureText(wrappedText);
104
+ };
105
+ const findClosestYogaNode = (node) => {
106
+ if (!node?.parentNode) {
107
+ return undefined;
108
+ }
109
+ return node.yogaNode ?? findClosestYogaNode(node.parentNode);
110
+ };
111
+ const markNodeAsDirty = (node) => {
112
+ // Mark closest Yoga node as dirty to measure text dimensions again
113
+ const yogaNode = findClosestYogaNode(node);
114
+ yogaNode?.markDirty();
115
+ };
116
+ export const setTextNodeValue = (node, text) => {
117
+ if (typeof text !== 'string') {
118
+ text = String(text);
119
+ }
120
+ node.nodeValue = text;
121
+ markNodeAsDirty(node);
122
+ };
123
+ //# sourceMappingURL=dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,OAAO,IAA6B,MAAM,aAAa,CAAC;AACxD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,eAAe,MAAM,wBAAwB,CAAC;AA0FrD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAsB,EAAc,EAAE;IAChE,MAAM,IAAI,GAAe;QACxB,QAAQ;QACR,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,QAAQ,KAAK,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QAC1E,gEAAgE;QAChE,sBAAsB,EAAE,E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AU,CAAC;IACnB,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAC;IAChD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEpD,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAwB,EAAE;IACpE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAAc,EAAQ,EAAE;IAChD,mEAAmE;IACnE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAc,EAAE,IAAY,EAAQ,EAAE;IACtE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACtB,eAAe,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Node as YogaNode } from 'yoga-layout';
2
+ declare const getMaxWidth: (yogaNode: YogaNode) => number;
3
+ export default getMaxWidth;
@@ -0,0 +1,10 @@
1
+ import Yoga from 'yoga-layout';
2
+ const getMaxWidth = (yogaNode) => {
3
+ return (yogaNode.getComputedWidth() -
4
+ yogaNode.getComputedPadding(Yoga.EDGE_LEFT) -
5
+ yogaNode.getComputedPadding(Yoga.EDGE_RIGHT) -
6
+ yogaNode.getComputedBorder(Yoga.EDGE_LEFT) -
7
+ yogaNode.getComputedBorder(Yoga.EDGE_RIGHT));
8
+ };
9
+ export default getMaxWidth;
10
+ //# sourceMappingURL=get-max-width.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-max-width.js","sourceRoot":"","sources":["../src/get-max-width.ts"],"names":[],"mappings":"AAAA,OAAO,IAA6B,MAAM,aAAa,CAAC;AAExD,MAAM,WAAW,GAAG,CAAC,QAAkB,EAAE,EAAE;IAC1C,OAAO,CACN,QAAQ,CAAC,gBAAgB,EAAE;QAC3B,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC;QAC3C,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC;QAC5C,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC;QAC1C,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAC3C,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ `useApp` is a React hook that exposes a method to manually exit the app (unmount).
3
+ */
4
+ declare const useApp: () => import("../components/AppContext.js").Props;
5
+ export default useApp;
@@ -0,0 +1,8 @@
1
+ import { useContext } from 'react';
2
+ import AppContext from '../components/AppContext.js';
3
+ /**
4
+ `useApp` is a React hook that exposes a method to manually exit the app (unmount).
5
+ */
6
+ const useApp = () => useContext(AppContext);
7
+ export default useApp;
8
+ //# sourceMappingURL=use-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-app.js","sourceRoot":"","sources":["../../src/hooks/use-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAErD;;EAEE;AACF,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAC5C,eAAe,MAAM,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { type Props } from '../components/FocusContext.js';
2
+ type Output = {
3
+ /**
4
+ Enable focus management for all components.
5
+ */
6
+ enableFocus: Props['enableFocus'];
7
+ /**
8
+ Disable focus management for all components. The currently active component (if there's one) will lose its focus.
9
+ */
10
+ disableFocus: Props['disableFocus'];
11
+ /**
12
+ Switch focus to the next focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the last in the list of focusable components, focus will be switched to the first focusable component.
13
+ */
14
+ focusNext: Props['focusNext'];
15
+ /**
16
+ Switch focus to the previous focusable component. If there's no active component right now, focus will be given to the first focusable component. If the active component is the first in the list of focusable components, focus will be switched to the last focusable component.
17
+ */
18
+ focusPrevious: Props['focusPrevious'];
19
+ /**
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
+ */
22
+ focus: Props['focus'];
23
+ };
24
+ /**
25
+ This hook exposes methods to enable or disable focus management for all components or manually switch focus to next or previous components.
26
+ */
27
+ declare const useFocusManager: () => Output;
28
+ export default useFocusManager;
@@ -0,0 +1,17 @@
1
+ import { useContext } from 'react';
2
+ import FocusContext from '../components/FocusContext.js';
3
+ /**
4
+ This hook exposes methods to enable or disable focus management for all components or manually switch focus to next or previous components.
5
+ */
6
+ const useFocusManager = () => {
7
+ const focusContext = useContext(FocusContext);
8
+ return {
9
+ enableFocus: focusContext.enableFocus,
10
+ disableFocus: focusContext.disableFocus,
11
+ focusNext: focusContext.focusNext,
12
+ focusPrevious: focusContext.focusPrevious,
13
+ focus: focusContext.focus,
14
+ };
15
+ };
16
+ export default useFocusManager;
17
+ //# sourceMappingURL=use-focus-manager.js.map
@@ -0,0 +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;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"}
@@ -0,0 +1,29 @@
1
+ type Input = {
2
+ /**
3
+ Enable or disable this component's focus, while still maintaining its position in the list of focusable components.
4
+ */
5
+ isActive?: boolean;
6
+ /**
7
+ Auto-focus this component if there's no active (focused) component right now.
8
+ */
9
+ autoFocus?: boolean;
10
+ /**
11
+ Assign an ID to this component, so it can be programmatically focused with `focus(id)`.
12
+ */
13
+ id?: string;
14
+ };
15
+ type Output = {
16
+ /**
17
+ Determines whether this component is focused.
18
+ */
19
+ isFocused: boolean;
20
+ /**
21
+ Allows focusing a specific element with the provided `id`.
22
+ */
23
+ focus: (id: string) => void;
24
+ };
25
+ /**
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.
27
+ */
28
+ declare const useFocus: ({ isActive, autoFocus, id: customId, }?: Input) => Output;
29
+ export default useFocus;
@@ -0,0 +1,42 @@
1
+ import { useEffect, useContext, useMemo } from 'react';
2
+ import FocusContext from '../components/FocusContext.js';
3
+ import useStdin from './use-stdin.js';
4
+ /**
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.
6
+ */
7
+ const useFocus = ({ isActive = true, autoFocus = false, id: customId, } = {}) => {
8
+ const { isRawModeSupported, setRawMode } = useStdin();
9
+ const { activeId, add, remove, activate, deactivate, focus } = useContext(FocusContext);
10
+ const id = useMemo(() => {
11
+ return customId ?? Math.random().toString().slice(2, 7);
12
+ }, [customId]);
13
+ useEffect(() => {
14
+ add(id, { autoFocus });
15
+ return () => {
16
+ remove(id);
17
+ };
18
+ }, [id, autoFocus]);
19
+ useEffect(() => {
20
+ if (isActive) {
21
+ activate(id);
22
+ }
23
+ else {
24
+ deactivate(id);
25
+ }
26
+ }, [isActive, id]);
27
+ useEffect(() => {
28
+ if (!isRawModeSupported || !isActive) {
29
+ return;
30
+ }
31
+ setRawMode(true);
32
+ return () => {
33
+ setRawMode(false);
34
+ };
35
+ }, [isActive]);
36
+ return {
37
+ isFocused: Boolean(id) && activeId === id,
38
+ focus,
39
+ };
40
+ };
41
+ export default useFocus;
42
+ //# sourceMappingURL=use-focus.js.map
@@ -0,0 +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;;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"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ Handy information about a key that was pressed.
3
+ */
4
+ export type Key = {
5
+ /**
6
+ Up arrow key was pressed.
7
+ */
8
+ upArrow: boolean;
9
+ /**
10
+ Down arrow key was pressed.
11
+ */
12
+ downArrow: boolean;
13
+ /**
14
+ Left arrow key was pressed.
15
+ */
16
+ leftArrow: boolean;
17
+ /**
18
+ Right arrow key was pressed.
19
+ */
20
+ rightArrow: boolean;
21
+ /**
22
+ Page Down key was pressed.
23
+ */
24
+ pageDown: boolean;
25
+ /**
26
+ Page Up key was pressed.
27
+ */
28
+ pageUp: boolean;
29
+ /**
30
+ Return (Enter) key was pressed.
31
+ */
32
+ return: boolean;
33
+ /**
34
+ Escape key was pressed.
35
+ */
36
+ escape: boolean;
37
+ /**
38
+ Ctrl key was pressed.
39
+ */
40
+ ctrl: boolean;
41
+ /**
42
+ Shift key was pressed.
43
+ */
44
+ shift: boolean;
45
+ /**
46
+ Tab key was pressed.
47
+ */
48
+ tab: boolean;
49
+ /**
50
+ Backspace key was pressed.
51
+ */
52
+ backspace: boolean;
53
+ /**
54
+ Delete key was pressed.
55
+ */
56
+ delete: boolean;
57
+ /**
58
+ [Meta key](https://en.wikipedia.org/wiki/Meta_key) was pressed.
59
+ */
60
+ meta: boolean;
61
+ };
62
+ type Handler = (input: string, key: Key) => void;
63
+ type Options = {
64
+ /**
65
+ Enable or disable capturing of user input. Useful when there are multiple `useInput` hooks used at once to avoid handling the same input several times.
66
+
67
+ @default true
68
+ */
69
+ isActive?: boolean;
70
+ };
71
+ /**
72
+ 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`.
73
+
74
+ ```
75
+ import {useInput} from 'ink';
76
+
77
+ const UserInput = () => {
78
+ useInput((input, key) => {
79
+ if (input === 'q') {
80
+ // Exit program
81
+ }
82
+
83
+ if (key.leftArrow) {
84
+ // Left arrow key pressed
85
+ }
86
+ });
87
+
88
+ return …
89
+ };
90
+ ```
91
+ */
92
+ declare const useInput: (inputHandler: Handler, options?: Options) => void;
93
+ export default useInput;
@@ -0,0 +1,93 @@
1
+ import { useEffect } from 'react';
2
+ import parseKeypress, { nonAlphanumericKeys } from '../parse-keypress.js';
3
+ import reconciler from '../reconciler.js';
4
+ import useStdin from './use-stdin.js';
5
+ /**
6
+ 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`.
7
+
8
+ ```
9
+ import {useInput} from 'ink';
10
+
11
+ const UserInput = () => {
12
+ useInput((input, key) => {
13
+ if (input === 'q') {
14
+ // Exit program
15
+ }
16
+
17
+ if (key.leftArrow) {
18
+ // Left arrow key pressed
19
+ }
20
+ });
21
+
22
+ return …
23
+ };
24
+ ```
25
+ */
26
+ const useInput = (inputHandler, options = {}) => {
27
+ // eslint-disable-next-line @typescript-eslint/naming-convention
28
+ const { stdin, setRawMode, internal_exitOnCtrlC, internal_eventEmitter } = useStdin();
29
+ useEffect(() => {
30
+ if (options.isActive === false) {
31
+ return;
32
+ }
33
+ setRawMode(true);
34
+ return () => {
35
+ setRawMode(false);
36
+ };
37
+ }, [options.isActive, setRawMode]);
38
+ useEffect(() => {
39
+ if (options.isActive === false) {
40
+ return;
41
+ }
42
+ const handleData = (data) => {
43
+ const keypress = parseKeypress(data);
44
+ const key = {
45
+ upArrow: keypress.name === 'up',
46
+ downArrow: keypress.name === 'down',
47
+ leftArrow: keypress.name === 'left',
48
+ rightArrow: keypress.name === 'right',
49
+ pageDown: keypress.name === 'pagedown',
50
+ pageUp: keypress.name === 'pageup',
51
+ return: keypress.name === 'return',
52
+ escape: keypress.name === 'escape',
53
+ ctrl: keypress.ctrl,
54
+ shift: keypress.shift,
55
+ tab: keypress.name === 'tab',
56
+ backspace: keypress.name === 'backspace',
57
+ delete: keypress.name === 'delete',
58
+ // `parseKeypress` parses \u001B\u001B[A (meta + up arrow) as meta = false
59
+ // but with option = true, so we need to take this into account here
60
+ // to avoid breaking changes in Ink.
61
+ // TODO(vadimdemedes): consider removing this in the next major version.
62
+ meta: keypress.meta || keypress.name === 'escape' || keypress.option,
63
+ };
64
+ let input = keypress.ctrl ? keypress.name : keypress.sequence;
65
+ if (nonAlphanumericKeys.includes(keypress.name)) {
66
+ input = '';
67
+ }
68
+ // Strip meta if it's still remaining after `parseKeypress`
69
+ // TODO(vadimdemedes): remove this in the next major version.
70
+ if (input.startsWith('\u001B')) {
71
+ input = input.slice(1);
72
+ }
73
+ if (input.length === 1 &&
74
+ typeof input[0] === 'string' &&
75
+ /[A-Z]/.test(input[0])) {
76
+ key.shift = true;
77
+ }
78
+ // If app is not supposed to exit on Ctrl+C, then let input listener handle it
79
+ if (!(input === 'c' && key.ctrl) || !internal_exitOnCtrlC) {
80
+ // @ts-expect-error TypeScript types for `batchedUpdates` require an argument, but React's codebase doesn't provide it and it works without it as expected.
81
+ reconciler.batchedUpdates(() => {
82
+ inputHandler(input, key);
83
+ });
84
+ }
85
+ };
86
+ internal_eventEmitter?.on('input', handleData);
87
+ return () => {
88
+ internal_eventEmitter?.removeListener('input', handleData);
89
+ };
90
+ }, [options.isActive, stdin, internal_exitOnCtrlC, inputHandler]);
91
+ };
92
+ export default useInput;
93
+ //# sourceMappingURL=use-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-input.js","sourceRoot":"","sources":["../../src/hooks/use-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,aAAa,EAAE,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACxE,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAwFtC;;;;;;;;;;;;;;;;;;;;EAoBE;AACF,MAAM,QAAQ,GAAG,CAAC,YAAqB,EAAE,UAAmB,EAAE,EAAE,EAAE;IACjE,gEAAgE;IAChE,MAAM,EAAC,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,qBAAqB,EAAC,GACrE,QAAQ,EAAE,CAAC;IAEZ,SAAS,CAAC,GAAG,EAAE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AAoB,EAAE,YAAY,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ Returns whether a screen reader is enabled. This is useful when you want to render different output for screen readers.
3
+ */
4
+ declare const useIsScreenReaderEnabled: () => boolean;
5
+ export default useIsScreenReaderEnabled;
@@ -0,0 +1,11 @@
1
+ import { useContext } from 'react';
2
+ import { accessibilityContext } from '../components/AccessibilityContext.js';
3
+ /**
4
+ Returns whether a screen reader is enabled. This is useful when you want to render different output for screen readers.
5
+ */
6
+ const useIsScreenReaderEnabled = () => {
7
+ const { isScreenReaderEnabled } = useContext(accessibilityContext);
8
+ return isScreenReaderEnabled;
9
+ };
10
+ export default useIsScreenReaderEnabled;
11
+ //# sourceMappingURL=use-is-screen-reader-enabled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-is-screen-reader-enabled.js","sourceRoot":"","sources":["../../src/hooks/use-is-screen-reader-enabled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,oBAAoB,EAAC,MAAM,uCAAuC,CAAC;AAE3E;;EAEE;AACF,MAAM,wBAAwB,GAAG,GAAY,EAAE;IAC9C,MAAM,EAAC,qBAAqB,EAAC,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjE,OAAO,qBAAqB,CAAC;AAC9B,CAAC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ `useStderr` is a React hook that exposes the stderr stream.
3
+ */
4
+ declare const useStderr: () => import("../components/StderrContext.js").Props;
5
+ export default useStderr;
@@ -0,0 +1,8 @@
1
+ import { useContext } from 'react';
2
+ import StderrContext from '../components/StderrContext.js';
3
+ /**
4
+ `useStderr` is a React hook that exposes the stderr stream.
5
+ */
6
+ const useStderr = () => useContext(StderrContext);
7
+ export default useStderr;
8
+ //# sourceMappingURL=use-stderr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stderr.js","sourceRoot":"","sources":["../../src/hooks/use-stderr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAE3D;;EAEE;AACF,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClD,eAAe,SAAS,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ `useStdin` is a React hook that exposes the stdin stream.
3
+ */
4
+ declare const useStdin: () => import("../components/StdinContext.js").Props;
5
+ export default useStdin;
@@ -0,0 +1,8 @@
1
+ import { useContext } from 'react';
2
+ import StdinContext from '../components/StdinContext.js';
3
+ /**
4
+ `useStdin` is a React hook that exposes the stdin stream.
5
+ */
6
+ const useStdin = () => useContext(StdinContext);
7
+ export default useStdin;
8
+ //# sourceMappingURL=use-stdin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stdin.js","sourceRoot":"","sources":["../../src/hooks/use-stdin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,YAAY,MAAM,+BAA+B,CAAC;AAEzD;;EAEE;AACF,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AAChD,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ `useStdout` is a React hook that exposes the stdout stream where Ink renders your app.
3
+ */
4
+ declare const useStdout: () => import("../components/StdoutContext.js").Props;
5
+ export default useStdout;
@@ -0,0 +1,8 @@
1
+ import { useContext } from 'react';
2
+ import StdoutContext from '../components/StdoutContext.js';
3
+ /**
4
+ `useStdout` is a React hook that exposes the stdout stream where Ink renders your app.
5
+ */
6
+ const useStdout = () => useContext(StdoutContext);
7
+ export default useStdout;
8
+ //# sourceMappingURL=use-stdout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stdout.js","sourceRoot":"","sources":["../../src/hooks/use-stdout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAE3D;;EAEE;AACF,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClD,eAAe,SAAS,CAAC"}