@nuvin/ink 6.5.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 +117 -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 +11 -0
  54. package/build/devtools.js.map +1 -0
  55. package/build/dom.d.ts +56 -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 +54 -0
  89. package/build/ink.js +309 -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-to-file.d.ts +49 -0
  95. package/build/log-to-file.js +83 -0
  96. package/build/log-to-file.js.map +1 -0
  97. package/build/log-update.d.ts +14 -0
  98. package/build/log-update.js +116 -0
  99. package/build/log-update.js.map +1 -0
  100. package/build/measure-element.d.ts +16 -0
  101. package/build/measure-element.js +9 -0
  102. package/build/measure-element.js.map +1 -0
  103. package/build/measure-text.d.ts +6 -0
  104. package/build/measure-text.js +21 -0
  105. package/build/measure-text.js.map +1 -0
  106. package/build/output.d.ts +34 -0
  107. package/build/output.js +150 -0
  108. package/build/output.js.map +1 -0
  109. package/build/parse-keypress.d.ts +14 -0
  110. package/build/parse-keypress.js +225 -0
  111. package/build/parse-keypress.js.map +1 -0
  112. package/build/reconciler.d.ts +4 -0
  113. package/build/reconciler.js +254 -0
  114. package/build/reconciler.js.map +1 -0
  115. package/build/render-background.d.ts +4 -0
  116. package/build/render-background.js +25 -0
  117. package/build/render-background.js.map +1 -0
  118. package/build/render-border.d.ts +4 -0
  119. package/build/render-border.js +73 -0
  120. package/build/render-border.js.map +1 -0
  121. package/build/render-node-to-output.d.ts +14 -0
  122. package/build/render-node-to-output.js +147 -0
  123. package/build/render-node-to-output.js.map +1 -0
  124. package/build/render.d.ts +88 -0
  125. package/build/render.js +50 -0
  126. package/build/render.js.map +1 -0
  127. package/build/renderer.d.ts +8 -0
  128. package/build/renderer.js +55 -0
  129. package/build/renderer.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 +240 -0
  134. package/build/styles.js +232 -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 +10 -0
  140. package/package.json +195 -0
  141. package/readme.md +2356 -0
@@ -0,0 +1,254 @@
1
+ import process from 'node:process';
2
+ import createReconciler from 'react-reconciler';
3
+ import { DefaultEventPriority, NoEventPriority, } from 'react-reconciler/constants.js';
4
+ import Yoga from 'yoga-layout';
5
+ import { createContext } from 'react';
6
+ import { createTextNode, appendChildNode, insertBeforeNode, removeChildNode, setStyle, setTextNodeValue, createNode, setAttribute, } from './dom.js';
7
+ import applyStyles from './styles.js';
8
+ // We need to conditionally perform devtools connection to avoid
9
+ // accidentally breaking other third-party code.
10
+ // See https://github.com/vadimdemedes/ink/issues/384
11
+ if (process.env['DEV'] === 'true') {
12
+ try {
13
+ await import('./devtools.js');
14
+ }
15
+ catch (error) {
16
+ if (error.code === 'ERR_MODULE_NOT_FOUND') {
17
+ console.warn(`
18
+ The environment variable DEV is set to true, so Ink tried to import \`react-devtools-core\`,
19
+ but this failed as it was not installed. Debugging with React Devtools requires it.
20
+
21
+ To install use this command:
22
+
23
+ $ npm install --save-dev react-devtools-core
24
+ `.trim() + '\n');
25
+ }
26
+ else {
27
+ // eslint-disable-next-line @typescript-eslint/only-throw-error
28
+ throw error;
29
+ }
30
+ }
31
+ }
32
+ const diff = (before, after) => {
33
+ if (before === after) {
34
+ return;
35
+ }
36
+ if (!before) {
37
+ return after;
38
+ }
39
+ const changed = {};
40
+ let isChanged = false;
41
+ for (const key of Object.keys(before)) {
42
+ const isDeleted = after ? !Object.hasOwn(after, key) : true;
43
+ if (isDeleted) {
44
+ changed[key] = undefined;
45
+ isChanged = true;
46
+ }
47
+ }
48
+ if (after) {
49
+ for (const key of Object.keys(after)) {
50
+ if (after[key] !== before[key]) {
51
+ changed[key] = after[key];
52
+ isChanged = true;
53
+ }
54
+ }
55
+ }
56
+ return isChanged ? changed : undefined;
57
+ };
58
+ const cleanupYogaNode = (node) => {
59
+ node?.unsetMeasureFunc();
60
+ node?.freeRecursive();
61
+ };
62
+ let currentUpdatePriority = NoEventPriority;
63
+ let currentRootNode;
64
+ export default createReconciler({
65
+ getRootHostContext: () => ({
66
+ isInsideText: false,
67
+ }),
68
+ prepareForCommit: () => null,
69
+ preparePortalMount: () => null,
70
+ clearContainer: () => false,
71
+ resetAfterCommit(rootNode) {
72
+ if (typeof rootNode.onComputeLayout === 'function') {
73
+ rootNode.onComputeLayout();
74
+ }
75
+ // Since renders are throttled at the instance level and <Static> component children
76
+ // are rendered only once and then get deleted, we need an escape hatch to
77
+ // trigger an immediate render to ensure <Static> children are written to output before they get erased
78
+ if (rootNode.isStaticDirty) {
79
+ rootNode.isStaticDirty = false;
80
+ if (typeof rootNode.onImmediateRender === 'function') {
81
+ rootNode.onImmediateRender();
82
+ }
83
+ return;
84
+ }
85
+ if (typeof rootNode.onRender === 'function') {
86
+ rootNode.onRender();
87
+ }
88
+ },
89
+ getChildHostContext(parentHostContext, type) {
90
+ const previousIsInsideText = parentHostContext.isInsideText;
91
+ const isInsideText = type === 'ink-text' || type === 'ink-virtual-text';
92
+ if (previousIsInsideText === isInsideText) {
93
+ return parentHostContext;
94
+ }
95
+ return { isInsideText };
96
+ },
97
+ shouldSetTextContent: () => false,
98
+ createInstance(originalType, newProps, rootNode, hostContext) {
99
+ if (hostContext.isInsideText && originalType === 'ink-box') {
100
+ throw new Error(`<Box> can’t be nested inside <Text> component`);
101
+ }
102
+ const type = originalType === 'ink-text' && hostContext.isInsideText
103
+ ? 'ink-virtual-text'
104
+ : originalType;
105
+ const node = createNode(type);
106
+ for (const [key, value] of Object.entries(newProps)) {
107
+ if (key === 'children') {
108
+ continue;
109
+ }
110
+ if (key === 'style') {
111
+ setStyle(node, value);
112
+ if (node.yogaNode) {
113
+ applyStyles(node.yogaNode, value);
114
+ }
115
+ continue;
116
+ }
117
+ if (key === 'internal_transform') {
118
+ node.internal_transform = value;
119
+ continue;
120
+ }
121
+ if (key === 'internal_static') {
122
+ currentRootNode = rootNode;
123
+ node.internal_static = true;
124
+ rootNode.isStaticDirty = true;
125
+ // Save reference to <Static> node to skip traversal of entire
126
+ // node tree to find it
127
+ rootNode.staticNode = node;
128
+ continue;
129
+ }
130
+ setAttribute(node, key, value);
131
+ }
132
+ return node;
133
+ },
134
+ createTextInstance(text, _root, hostContext) {
135
+ if (!hostContext.isInsideText) {
136
+ throw new Error(`Text string "${text}" must be rendered inside <Text> component`);
137
+ }
138
+ return createTextNode(text);
139
+ },
140
+ resetTextContent() { },
141
+ hideTextInstance(node) {
142
+ setTextNodeValue(node, '');
143
+ },
144
+ unhideTextInstance(node, text) {
145
+ setTextNodeValue(node, text);
146
+ },
147
+ getPublicInstance: instance => instance,
148
+ hideInstance(node) {
149
+ node.yogaNode?.setDisplay(Yoga.DISPLAY_NONE);
150
+ },
151
+ unhideInstance(node) {
152
+ node.yogaNode?.setDisplay(Yoga.DISPLAY_FLEX);
153
+ },
154
+ appendInitialChild: appendChildNode,
155
+ appendChild: appendChildNode,
156
+ insertBefore: insertBeforeNode,
157
+ finalizeInitialChildren() {
158
+ return false;
159
+ },
160
+ isPrimaryRenderer: true,
161
+ supportsMutation: true,
162
+ supportsPersistence: false,
163
+ supportsHydration: false,
164
+ scheduleTimeout: setTimeout,
165
+ cancelTimeout: clearTimeout,
166
+ noTimeout: -1,
167
+ beforeActiveInstanceBlur() { },
168
+ afterActiveInstanceBlur() { },
169
+ detachDeletedInstance() { },
170
+ getInstanceFromNode: () => null,
171
+ prepareScopeUpdate() { },
172
+ getInstanceFromScope: () => null,
173
+ appendChildToContainer: appendChildNode,
174
+ insertInContainerBefore: insertBeforeNode,
175
+ removeChildFromContainer(node, removeNode) {
176
+ removeChildNode(node, removeNode);
177
+ cleanupYogaNode(removeNode.yogaNode);
178
+ },
179
+ commitUpdate(node, _type, oldProps, newProps) {
180
+ if (currentRootNode && node.internal_static) {
181
+ currentRootNode.isStaticDirty = true;
182
+ }
183
+ const props = diff(oldProps, newProps);
184
+ const style = diff(oldProps['style'], newProps['style']);
185
+ if (!props && !style) {
186
+ return;
187
+ }
188
+ if (props) {
189
+ for (const [key, value] of Object.entries(props)) {
190
+ if (key === 'style') {
191
+ setStyle(node, value);
192
+ continue;
193
+ }
194
+ if (key === 'internal_transform') {
195
+ node.internal_transform = value;
196
+ continue;
197
+ }
198
+ if (key === 'internal_static') {
199
+ node.internal_static = true;
200
+ continue;
201
+ }
202
+ setAttribute(node, key, value);
203
+ }
204
+ }
205
+ if (style && node.yogaNode) {
206
+ applyStyles(node.yogaNode, style);
207
+ }
208
+ },
209
+ commitTextUpdate(node, _oldText, newText) {
210
+ setTextNodeValue(node, newText);
211
+ },
212
+ removeChild(node, removeNode) {
213
+ removeChildNode(node, removeNode);
214
+ cleanupYogaNode(removeNode.yogaNode);
215
+ },
216
+ setCurrentUpdatePriority(newPriority) {
217
+ currentUpdatePriority = newPriority;
218
+ },
219
+ getCurrentUpdatePriority: () => currentUpdatePriority,
220
+ resolveUpdatePriority() {
221
+ if (currentUpdatePriority !== NoEventPriority) {
222
+ return currentUpdatePriority;
223
+ }
224
+ return DefaultEventPriority;
225
+ },
226
+ maySuspendCommit() {
227
+ return false;
228
+ },
229
+ // eslint-disable-next-line @typescript-eslint/naming-convention
230
+ NotPendingTransition: undefined,
231
+ // eslint-disable-next-line @typescript-eslint/naming-convention
232
+ HostTransitionContext: createContext(null),
233
+ resetFormInstance() { },
234
+ requestPostPaintCallback() { },
235
+ shouldAttemptEagerTransition() {
236
+ return false;
237
+ },
238
+ trackSchedulerEvent() { },
239
+ resolveEventType() {
240
+ return null;
241
+ },
242
+ resolveEventTimeStamp() {
243
+ return -1.1;
244
+ },
245
+ preloadInstance() {
246
+ return true;
247
+ },
248
+ startSuspendingCommit() { },
249
+ suspendInstance() { },
250
+ waitForCommitToBeReady() {
251
+ return null;
252
+ },
253
+ });
254
+ //# sourceMappingURL=reconciler.js.map
@@ -0,0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;QAC3C,qBAAqB,GAAG,WAAW,CAAC;IACrC,CAAC;IACD,wBAAwB,EAAE,GAAG,EAAE,CAAC,qBAAqB;IACrD,qBAAqB;QACpB,IAAI,qBAAqB,KAAK,eAAe,EAAE,CAAC;YAC/C,OAAO,qBAAqB,CAAC;QAC9B,CAAC;QAED,OAAO,oBAAoB,CAAC;IAC7B,CAAC;IACD,gBAAgB;QACf,OAAO,KAAK,CAAC;IACd,CAAC;IACD,gEAAgE;IAChE,oBAAoB,EAAE,SAAS;IAC/B,gEAAgE;IAChE,qBAAqB,EAAE,aAAa,CACnC,IAAI,CACgC;IACrC,iBAAiB,KAAI,CAAC;IACtB,wBAAwB,KAAI,CAAC;IAC7B,4BAA4B;QAC3B,OAAO,KAAK,CAAC;IACd,CAAC;IACD,mBAAmB,KAAI,CAAC;IACxB,gBAAgB;QACf,OAAO,IAAI,CAAC;IACb,CAAC;IACD,qBAAqB;QACpB,OAAO,CAAC,GAAG,CAAC;IACb,CAAC;IACD,eAAe;QACd,OAAO,IAAI,CAAC;IACb,CAAC;IACD,qBAAqB,KAAI,CAAC;IAC1B,eAAe,KAAI,CAAC;IACpB,sBAAsB;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type DOMNode } from './dom.js';
2
+ import type Output from './output.js';
3
+ declare const renderBackground: (x: number, y: number, node: DOMNode, output: Output) => void;
4
+ export default renderBackground;
@@ -0,0 +1,25 @@
1
+ import colorize from './colorize.js';
2
+ const renderBackground = (x, y, node, output) => {
3
+ if (!node.style.backgroundColor) {
4
+ return;
5
+ }
6
+ const width = node.yogaNode.getComputedWidth();
7
+ const height = node.yogaNode.getComputedHeight();
8
+ // Calculate the actual content area considering borders
9
+ const leftBorderWidth = node.style.borderStyle && node.style.borderLeft !== false ? 1 : 0;
10
+ const rightBorderWidth = node.style.borderStyle && node.style.borderRight !== false ? 1 : 0;
11
+ const topBorderHeight = node.style.borderStyle && node.style.borderTop !== false ? 1 : 0;
12
+ const bottomBorderHeight = node.style.borderStyle && node.style.borderBottom !== false ? 1 : 0;
13
+ const contentWidth = width - leftBorderWidth - rightBorderWidth;
14
+ const contentHeight = height - topBorderHeight - bottomBorderHeight;
15
+ if (!(contentWidth > 0 && contentHeight > 0)) {
16
+ return;
17
+ }
18
+ // Create background fill for each row
19
+ const backgroundLine = colorize(' '.repeat(contentWidth), node.style.backgroundColor, 'background');
20
+ for (let row = 0; row < contentHeight; row++) {
21
+ output.write(x + leftBorderWidth, y + topBorderHeight + row, backgroundLine, { transformers: [] });
22
+ }
23
+ };
24
+ export default renderBackground;
25
+ //# sourceMappingURL=render-background.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-background.js","sourceRoot":"","sources":["../src/render-background.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AAIrC,MAAM,gBAAgB,GAAG,CACxB,CAAS,EACT,CAAS,EACT,IAAa,EACb,MAAc,EACP,EAAE;IACT,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QACjC,OAAO;IACR,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,QAAS,CAAC,gBAAgB,EAAE,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAS,CAAC,iBAAiB,EAAE,CAAC;IAElD,wDAAwD;IACxD,MAAM,eAAe,GACpB,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,MAAM,gBAAgB,GACrB,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,MAAM,eAAe,GACpB,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,kBAAkB,GACvB,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAErE,MAAM,YAAY,GAAG,KAAK,GAAG,eAAe,GAAG,gBAAgB,CAAC;IAChE,MAAM,aAAa,GAAG,MAAM,GAAG,eAAe,GAAG,kBAAkB,CAAC;IAEpE,IAAI,CAAC,CAAC,YAAY,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;QAC9C,OAAO;IACR,CAAC;IAED,sCAAsC;IACtC,MAAM,cAAc,GAAG,QAAQ,CAC9B,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,EACxB,IAAI,CAAC,KAAK,CAAC,eAAe,EAC1B,YAAY,CACZ,CAAC;IAEF,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,aAAa,EAAE,GAAG,EAAE,EAAE,CAAC;QAC9C,MAAM,CAAC,KAAK,CACX,CAAC,GAAG,eAAe,EACnB,CAAC,GAAG,eAAe,GAAG,GAAG,EACzB,cAAc,EACd,EAAC,YAAY,EAAE,EAAE,EAAC,CAClB,CAAC;IACH,CAAC;AACF,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type DOMNode } from './dom.js';
2
+ import type Output from './output.js';
3
+ declare const renderBorder: (x: number, y: number, node: DOMNode, output: Output) => void;
4
+ export default renderBorder;
@@ -0,0 +1,73 @@
1
+ import cliBoxes from 'cli-boxes';
2
+ import chalk from 'chalk';
3
+ import colorize from './colorize.js';
4
+ const renderBorder = (x, y, node, output) => {
5
+ if (node.style.borderStyle) {
6
+ const width = node.yogaNode.getComputedWidth();
7
+ const height = node.yogaNode.getComputedHeight();
8
+ const box = typeof node.style.borderStyle === 'string'
9
+ ? cliBoxes[node.style.borderStyle]
10
+ : node.style.borderStyle;
11
+ const topBorderColor = node.style.borderTopColor ?? node.style.borderColor;
12
+ const bottomBorderColor = node.style.borderBottomColor ?? node.style.borderColor;
13
+ const leftBorderColor = node.style.borderLeftColor ?? node.style.borderColor;
14
+ const rightBorderColor = node.style.borderRightColor ?? node.style.borderColor;
15
+ const dimTopBorderColor = node.style.borderTopDimColor ?? node.style.borderDimColor;
16
+ const dimBottomBorderColor = node.style.borderBottomDimColor ?? node.style.borderDimColor;
17
+ const dimLeftBorderColor = node.style.borderLeftDimColor ?? node.style.borderDimColor;
18
+ const dimRightBorderColor = node.style.borderRightDimColor ?? node.style.borderDimColor;
19
+ const showTopBorder = node.style.borderTop !== false;
20
+ const showBottomBorder = node.style.borderBottom !== false;
21
+ const showLeftBorder = node.style.borderLeft !== false;
22
+ const showRightBorder = node.style.borderRight !== false;
23
+ const contentWidth = width - (showLeftBorder ? 1 : 0) - (showRightBorder ? 1 : 0);
24
+ let topBorder = showTopBorder
25
+ ? colorize((showLeftBorder ? box.topLeft : '') +
26
+ box.top.repeat(contentWidth) +
27
+ (showRightBorder ? box.topRight : ''), topBorderColor, 'foreground')
28
+ : undefined;
29
+ if (showTopBorder && dimTopBorderColor) {
30
+ topBorder = chalk.dim(topBorder);
31
+ }
32
+ let verticalBorderHeight = height;
33
+ if (showTopBorder) {
34
+ verticalBorderHeight -= 1;
35
+ }
36
+ if (showBottomBorder) {
37
+ verticalBorderHeight -= 1;
38
+ }
39
+ let leftBorder = (colorize(box.left, leftBorderColor, 'foreground') + '\n').repeat(verticalBorderHeight);
40
+ if (dimLeftBorderColor) {
41
+ leftBorder = chalk.dim(leftBorder);
42
+ }
43
+ let rightBorder = (colorize(box.right, rightBorderColor, 'foreground') + '\n').repeat(verticalBorderHeight);
44
+ if (dimRightBorderColor) {
45
+ rightBorder = chalk.dim(rightBorder);
46
+ }
47
+ let bottomBorder = showBottomBorder
48
+ ? colorize((showLeftBorder ? box.bottomLeft : '') +
49
+ box.bottom.repeat(contentWidth) +
50
+ (showRightBorder ? box.bottomRight : ''), bottomBorderColor, 'foreground')
51
+ : undefined;
52
+ if (showBottomBorder && dimBottomBorderColor) {
53
+ bottomBorder = chalk.dim(bottomBorder);
54
+ }
55
+ const offsetY = showTopBorder ? 1 : 0;
56
+ if (topBorder) {
57
+ output.write(x, y, topBorder, { transformers: [] });
58
+ }
59
+ if (showLeftBorder) {
60
+ output.write(x, y + offsetY, leftBorder, { transformers: [] });
61
+ }
62
+ if (showRightBorder) {
63
+ output.write(x + width - 1, y + offsetY, rightBorder, {
64
+ transformers: [],
65
+ });
66
+ }
67
+ if (bottomBorder) {
68
+ output.write(x, y + height - 1, bottomBorder, { transformers: [] });
69
+ }
70
+ }
71
+ };
72
+ export default renderBorder;
73
+ //# sourceMappingURL=render-border.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-border.js","sourceRoot":"","sources":["../src/render-border.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,eAAe,CAAC;AAIrC,MAAM,YAAY,GAAG,CACpB,CAAS,EACT,CAAS,EACT,IAAa,EACb,MAAc,EACP,EAAE;IACT,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAS,CAAC,gBAAgB,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAS,CAAC,iBAAiB,EAAE,CAAC;QAClD,MAAM,GAAG,GACR,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,QAAQ;YACzC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;YAClC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;QAE3B,M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AAC"}
@@ -0,0 +1,14 @@
1
+ import { type DOMElement } from './dom.js';
2
+ import type Output from './output.js';
3
+ export type OutputTransformer = (s: string, index: number) => string;
4
+ export declare const renderNodeToScreenReaderOutput: (node: DOMElement, options?: {
5
+ parentRole?: string;
6
+ skipStaticElements?: boolean;
7
+ }) => string;
8
+ declare const renderNodeToOutput: (node: DOMElement, output: Output, options: {
9
+ offsetX?: number;
10
+ offsetY?: number;
11
+ transformers?: OutputTransformer[];
12
+ skipStaticElements: boolean;
13
+ }) => void;
14
+ export default renderNodeToOutput;
@@ -0,0 +1,147 @@
1
+ import widestLine from 'widest-line';
2
+ import indentString from 'indent-string';
3
+ import Yoga from 'yoga-layout';
4
+ import wrapText from './wrap-text.js';
5
+ import getMaxWidth from './get-max-width.js';
6
+ import squashTextNodes from './squash-text-nodes.js';
7
+ import renderBorder from './render-border.js';
8
+ import renderBackground from './render-background.js';
9
+ // If parent container is `<Box>`, text nodes will be treated as separate nodes in
10
+ // the tree and will have their own coordinates in the layout.
11
+ // To ensure text nodes are aligned correctly, take X and Y of the first text node
12
+ // and use it as offset for the rest of the nodes
13
+ // Only first node is taken into account, because other text nodes can't have margin or padding,
14
+ // so their coordinates will be relative to the first node anyway
15
+ const applyPaddingToText = (node, text) => {
16
+ const yogaNode = node.childNodes[0]?.yogaNode;
17
+ if (yogaNode) {
18
+ const offsetX = yogaNode.getComputedLeft();
19
+ const offsetY = yogaNode.getComputedTop();
20
+ text = '\n'.repeat(offsetY) + indentString(text, offsetX);
21
+ }
22
+ return text;
23
+ };
24
+ export const renderNodeToScreenReaderOutput = (node, options = {}) => {
25
+ if (options.skipStaticElements && node.internal_static) {
26
+ return '';
27
+ }
28
+ if (node.yogaNode?.getDisplay() === Yoga.DISPLAY_NONE) {
29
+ return '';
30
+ }
31
+ let output = '';
32
+ if (node.nodeName === 'ink-text') {
33
+ output = squashTextNodes(node);
34
+ }
35
+ else if (node.nodeName === 'ink-box' || node.nodeName === 'ink-root') {
36
+ const separator = node.style.flexDirection === 'row' ||
37
+ node.style.flexDirection === 'row-reverse'
38
+ ? ' '
39
+ : '\n';
40
+ const childNodes = node.style.flexDirection === 'row-reverse' ||
41
+ node.style.flexDirection === 'column-reverse'
42
+ ? [...node.childNodes].reverse()
43
+ : [...node.childNodes];
44
+ output = childNodes
45
+ .map(childNode => {
46
+ const screenReaderOutput = renderNodeToScreenReaderOutput(childNode, {
47
+ parentRole: node.internal_accessibility?.role,
48
+ skipStaticElements: options.skipStaticElements,
49
+ });
50
+ return screenReaderOutput;
51
+ })
52
+ .filter(Boolean)
53
+ .join(separator);
54
+ }
55
+ if (node.internal_accessibility) {
56
+ const { role, state } = node.internal_accessibility;
57
+ if (state) {
58
+ const stateKeys = Object.keys(state);
59
+ const stateDescription = stateKeys.filter(key => state[key]).join(', ');
60
+ if (stateDescription) {
61
+ output = `(${stateDescription}) ${output}`;
62
+ }
63
+ }
64
+ if (role && role !== options.parentRole) {
65
+ output = `${role}: ${output}`;
66
+ }
67
+ }
68
+ return output;
69
+ };
70
+ // After nodes are laid out, render each to output object, which later gets rendered to terminal
71
+ const renderNodeToOutput = (node, output, options) => {
72
+ const { offsetX = 0, offsetY = 0, transformers = [], skipStaticElements, } = options;
73
+ if (skipStaticElements && node.internal_static) {
74
+ return;
75
+ }
76
+ const { yogaNode } = node;
77
+ if (yogaNode) {
78
+ if (yogaNode.getDisplay() === Yoga.DISPLAY_NONE) {
79
+ return;
80
+ }
81
+ // Left and top positions in Yoga are relative to their parent node
82
+ const x = offsetX + yogaNode.getComputedLeft();
83
+ const y = offsetY + yogaNode.getComputedTop();
84
+ // Transformers are functions that transform final text output of each component
85
+ // See Output class for logic that applies transformers
86
+ let newTransformers = transformers;
87
+ if (typeof node.internal_transform === 'function') {
88
+ newTransformers = [node.internal_transform, ...transformers];
89
+ }
90
+ if (node.nodeName === 'ink-text') {
91
+ let text = squashTextNodes(node);
92
+ if (text.length > 0) {
93
+ const currentWidth = widestLine(text);
94
+ const maxWidth = getMaxWidth(yogaNode);
95
+ if (currentWidth > maxWidth) {
96
+ const textWrap = node.style.textWrap ?? 'wrap';
97
+ text = wrapText(text, maxWidth, textWrap);
98
+ }
99
+ text = applyPaddingToText(node, text);
100
+ output.write(x, y, text, { transformers: newTransformers });
101
+ }
102
+ return;
103
+ }
104
+ let clipped = false;
105
+ if (node.nodeName === 'ink-box') {
106
+ renderBackground(x, y, node, output);
107
+ renderBorder(x, y, node, output);
108
+ const clipHorizontally = node.style.overflowX === 'hidden' || node.style.overflow === 'hidden';
109
+ const clipVertically = node.style.overflowY === 'hidden' || node.style.overflow === 'hidden';
110
+ if (clipHorizontally || clipVertically) {
111
+ const x1 = clipHorizontally
112
+ ? x + yogaNode.getComputedBorder(Yoga.EDGE_LEFT)
113
+ : undefined;
114
+ const x2 = clipHorizontally
115
+ ? x +
116
+ yogaNode.getComputedWidth() -
117
+ yogaNode.getComputedBorder(Yoga.EDGE_RIGHT)
118
+ : undefined;
119
+ const y1 = clipVertically
120
+ ? y + yogaNode.getComputedBorder(Yoga.EDGE_TOP)
121
+ : undefined;
122
+ const y2 = clipVertically
123
+ ? y +
124
+ yogaNode.getComputedHeight() -
125
+ yogaNode.getComputedBorder(Yoga.EDGE_BOTTOM)
126
+ : undefined;
127
+ output.clip({ x1, x2, y1, y2 });
128
+ clipped = true;
129
+ }
130
+ }
131
+ if (node.nodeName === 'ink-root' || node.nodeName === 'ink-box') {
132
+ for (const childNode of node.childNodes) {
133
+ renderNodeToOutput(childNode, output, {
134
+ offsetX: x,
135
+ offsetY: y,
136
+ transformers: newTransformers,
137
+ skipStaticElements,
138
+ });
139
+ }
140
+ if (clipped) {
141
+ output.unclip();
142
+ }
143
+ }
144
+ }
145
+ };
146
+ export default renderNodeToOutput;
147
+ //# sourceMappingURL=render-node-to-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-node-to-output.js","sourceRoot":"","sources":["../src/render-node-to-output.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,C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
2
+ import Ink, { type RenderMetrics } from './ink.js';
3
+ export type RenderOptions = {
4
+ /**
5
+ Output stream where app will be rendered.
6
+
7
+ @default process.stdout
8
+ */
9
+ stdout?: NodeJS.WriteStream;
10
+ /**
11
+ Input stream where app will listen for input.
12
+
13
+ @default process.stdin
14
+ */
15
+ stdin?: NodeJS.ReadStream;
16
+ /**
17
+ Error stream.
18
+ @default process.stderr
19
+ */
20
+ stderr?: NodeJS.WriteStream;
21
+ /**
22
+ If true, each update will be rendered as separate output, without replacing the previous one.
23
+
24
+ @default false
25
+ */
26
+ debug?: boolean;
27
+ /**
28
+ Configure whether Ink should listen for Ctrl+C keyboard input and exit the app. This is needed in case `process.stdin` is in raw mode, because then Ctrl+C is ignored by default and the process is expected to handle it manually.
29
+
30
+ @default true
31
+ */
32
+ exitOnCtrlC?: boolean;
33
+ /**
34
+ Patch console methods to ensure console output doesn't mix with Ink's output.
35
+
36
+ @default true
37
+ */
38
+ patchConsole?: boolean;
39
+ /**
40
+ Runs the given callback after each render and re-render.
41
+ */
42
+ onRender?: (metrics: RenderMetrics) => void;
43
+ /**
44
+ Enable screen reader support. See https://github.com/vadimdemedes/ink/blob/master/readme.md#screen-reader-support
45
+
46
+ @default process.env['INK_SCREEN_READER'] === 'true'
47
+ */
48
+ isScreenReaderEnabled?: boolean;
49
+ /**
50
+ Maximum frames per second for render updates.
51
+ This controls how frequently the UI can update to prevent excessive re-rendering.
52
+ Higher values allow more frequent updates but may impact performance.
53
+
54
+ @default 30
55
+ */
56
+ maxFps?: number;
57
+ /**
58
+ Enable incremental rendering mode which only updates changed lines instead of redrawing the entire output.
59
+ This can reduce flickering and improve performance for frequently updating UIs.
60
+
61
+ @default false
62
+ */
63
+ incrementalRendering?: boolean;
64
+ };
65
+ export type Instance = {
66
+ /**
67
+ Replace the previous root node with a new one or update props of the current root node.
68
+ */
69
+ rerender: Ink['render'];
70
+ /**
71
+ Manually unmount the whole Ink app.
72
+ */
73
+ unmount: Ink['unmount'];
74
+ /**
75
+ Returns a promise that resolves when the app is unmounted.
76
+ */
77
+ waitUntilExit: Ink['waitUntilExit'];
78
+ cleanup: () => void;
79
+ /**
80
+ Clear output.
81
+ */
82
+ clear: () => void;
83
+ };
84
+ /**
85
+ Mount a component and render the output.
86
+ */
87
+ declare const render: (node: ReactNode, options?: NodeJS.WriteStream | RenderOptions) => Instance;
88
+ export default render;