@kingkoo1985/ink 6.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/colorize.d.ts +4 -0
- package/build/colorize.js +59 -0
- package/build/colorize.js.map +1 -0
- package/build/components/AccessibilityContext.d.ts +3 -0
- package/build/components/AccessibilityContext.js +5 -0
- package/build/components/AccessibilityContext.js.map +1 -0
- package/build/components/App.d.ts +68 -0
- package/build/components/App.js +290 -0
- package/build/components/App.js.map +1 -0
- package/build/components/AppContext.d.ts +52 -0
- package/build/components/AppContext.js +16 -0
- package/build/components/AppContext.js.map +1 -0
- package/build/components/BackgroundContext.d.ts +4 -0
- package/build/components/BackgroundContext.js +3 -0
- package/build/components/BackgroundContext.js.map +1 -0
- package/build/components/Box.d.ts +171 -0
- package/build/components/Box.js +40 -0
- package/build/components/Box.js.map +1 -0
- package/build/components/ErrorOverview.d.ts +6 -0
- package/build/components/ErrorOverview.js +84 -0
- package/build/components/ErrorOverview.js.map +1 -0
- package/build/components/FocusContext.d.ts +16 -0
- package/build/components/FocusContext.js +16 -0
- package/build/components/FocusContext.js.map +1 -0
- package/build/components/Newline.d.ts +13 -0
- package/build/components/Newline.js +8 -0
- package/build/components/Newline.js.map +1 -0
- package/build/components/Spacer.d.ts +7 -0
- package/build/components/Spacer.js +11 -0
- package/build/components/Spacer.js.map +1 -0
- package/build/components/Static.d.ts +24 -0
- package/build/components/Static.js +29 -0
- package/build/components/Static.js.map +1 -0
- package/build/components/StaticRender.d.ts +8 -0
- package/build/components/StaticRender.js +19 -0
- package/build/components/StaticRender.js.map +1 -0
- package/build/components/StderrContext.d.ts +15 -0
- package/build/components/StderrContext.js +12 -0
- package/build/components/StderrContext.js.map +1 -0
- package/build/components/StdinContext.d.ts +22 -0
- package/build/components/StdinContext.js +16 -0
- package/build/components/StdinContext.js.map +1 -0
- package/build/components/StdoutContext.d.ts +15 -0
- package/build/components/StdoutContext.js +12 -0
- package/build/components/StdoutContext.js.map +1 -0
- package/build/components/Text.d.ts +63 -0
- package/build/components/Text.js +50 -0
- package/build/components/Text.js.map +1 -0
- package/build/components/Transform.d.ts +16 -0
- package/build/components/Transform.js +15 -0
- package/build/components/Transform.js.map +1 -0
- package/build/data-limited-lru-map.d.ts +20 -0
- package/build/data-limited-lru-map.js +65 -0
- package/build/data-limited-lru-map.js.map +1 -0
- package/build/debug-log.d.ts +2 -0
- package/build/debug-log.js +44 -0
- package/build/debug-log.js.map +1 -0
- package/build/devtools-window-polyfill.d.ts +1 -0
- package/build/devtools-window-polyfill.js +65 -0
- package/build/devtools-window-polyfill.js.map +1 -0
- package/build/devtools.d.ts +1 -0
- package/build/devtools.js +8 -0
- package/build/devtools.js.map +1 -0
- package/build/dom.d.ts +114 -0
- package/build/dom.js +169 -0
- package/build/dom.js.map +1 -0
- package/build/get-max-width.d.ts +3 -0
- package/build/get-max-width.js +10 -0
- package/build/get-max-width.js.map +1 -0
- package/build/hooks/use-app.d.ts +5 -0
- package/build/hooks/use-app.js +8 -0
- package/build/hooks/use-app.js.map +1 -0
- package/build/hooks/use-focus-manager.d.ts +28 -0
- package/build/hooks/use-focus-manager.js +17 -0
- package/build/hooks/use-focus-manager.js.map +1 -0
- package/build/hooks/use-focus.d.ts +29 -0
- package/build/hooks/use-focus.js +42 -0
- package/build/hooks/use-focus.js.map +1 -0
- package/build/hooks/use-input.d.ts +93 -0
- package/build/hooks/use-input.js +92 -0
- package/build/hooks/use-input.js.map +1 -0
- package/build/hooks/use-is-screen-reader-enabled.d.ts +5 -0
- package/build/hooks/use-is-screen-reader-enabled.js +11 -0
- package/build/hooks/use-is-screen-reader-enabled.js.map +1 -0
- package/build/hooks/use-stderr.d.ts +5 -0
- package/build/hooks/use-stderr.js +8 -0
- package/build/hooks/use-stderr.js.map +1 -0
- package/build/hooks/use-stdin.d.ts +5 -0
- package/build/hooks/use-stdin.js +8 -0
- package/build/hooks/use-stdin.js.map +1 -0
- package/build/hooks/use-stdout.d.ts +5 -0
- package/build/hooks/use-stdout.js +8 -0
- package/build/hooks/use-stdout.js.map +1 -0
- package/build/index.d.ts +38 -0
- package/build/index.js +27 -0
- package/build/index.js.map +1 -0
- package/build/ink.d.ts +110 -0
- package/build/ink.js +576 -0
- package/build/ink.js.map +1 -0
- package/build/instances.d.ts +3 -0
- package/build/instances.js +8 -0
- package/build/instances.js.map +1 -0
- package/build/layout.d.ts +18 -0
- package/build/layout.js +54 -0
- package/build/layout.js.map +1 -0
- package/build/log-update.d.ts +28 -0
- package/build/log-update.js +529 -0
- package/build/log-update.js.map +1 -0
- package/build/measure-element.d.ts +119 -0
- package/build/measure-element.js +825 -0
- package/build/measure-element.js.map +1 -0
- package/build/measure-text.d.ts +50 -0
- package/build/measure-text.js +237 -0
- package/build/measure-text.js.map +1 -0
- package/build/output.d.ts +242 -0
- package/build/output.js +607 -0
- package/build/output.js.map +1 -0
- package/build/parse-keypress.d.ts +14 -0
- package/build/parse-keypress.js +225 -0
- package/build/parse-keypress.js.map +1 -0
- package/build/reconciler.d.ts +4 -0
- package/build/reconciler.js +326 -0
- package/build/reconciler.js.map +1 -0
- package/build/render-background.d.ts +4 -0
- package/build/render-background.js +37 -0
- package/build/render-background.js.map +1 -0
- package/build/render-border.d.ts +4 -0
- package/build/render-border.js +81 -0
- package/build/render-border.js.map +1 -0
- package/build/render-cached.d.ts +18 -0
- package/build/render-cached.js +66 -0
- package/build/render-cached.js.map +1 -0
- package/build/render-container.d.ts +27 -0
- package/build/render-container.js +169 -0
- package/build/render-container.js.map +1 -0
- package/build/render-node-to-output.d.ts +32 -0
- package/build/render-node-to-output.js +177 -0
- package/build/render-node-to-output.js.map +1 -0
- package/build/render-screen-reader.d.ts +5 -0
- package/build/render-screen-reader.js +54 -0
- package/build/render-screen-reader.js.map +1 -0
- package/build/render-scrollbar.d.ts +23 -0
- package/build/render-scrollbar.js +70 -0
- package/build/render-scrollbar.js.map +1 -0
- package/build/render-sticky.d.ts +53 -0
- package/build/render-sticky.js +317 -0
- package/build/render-sticky.js.map +1 -0
- package/build/render-text-node.d.ts +20 -0
- package/build/render-text-node.js +155 -0
- package/build/render-text-node.js.map +1 -0
- package/build/render.d.ts +165 -0
- package/build/render.js +60 -0
- package/build/render.js.map +1 -0
- package/build/renderer.d.ts +24 -0
- package/build/renderer.js +292 -0
- package/build/renderer.js.map +1 -0
- package/build/replay.d.ts +59 -0
- package/build/replay.js +128 -0
- package/build/replay.js.map +1 -0
- package/build/resize-observer.d.ts +24 -0
- package/build/resize-observer.js +102 -0
- package/build/resize-observer.js.map +1 -0
- package/build/scroll.d.ts +11 -0
- package/build/scroll.js +123 -0
- package/build/scroll.js.map +1 -0
- package/build/selection.d.ts +52 -0
- package/build/selection.js +359 -0
- package/build/selection.js.map +1 -0
- package/build/serialization.d.ts +25 -0
- package/build/serialization.js +224 -0
- package/build/serialization.js.map +1 -0
- package/build/squash-text-nodes.d.ts +16 -0
- package/build/squash-text-nodes.js +58 -0
- package/build/squash-text-nodes.js.map +1 -0
- package/build/styled-line.d.ts +58 -0
- package/build/styled-line.js +629 -0
- package/build/styled-line.js.map +1 -0
- package/build/styles.d.ts +286 -0
- package/build/styles.js +257 -0
- package/build/styles.js.map +1 -0
- package/build/terminal-buffer.d.ts +57 -0
- package/build/terminal-buffer.js +507 -0
- package/build/terminal-buffer.js.map +1 -0
- package/build/text-wrap.d.ts +12 -0
- package/build/text-wrap.js +154 -0
- package/build/text-wrap.js.map +1 -0
- package/build/tokenize.d.ts +47 -0
- package/build/tokenize.js +419 -0
- package/build/tokenize.js.map +1 -0
- package/build/vertical-gap.d.ts +17 -0
- package/build/vertical-gap.js +20 -0
- package/build/vertical-gap.js.map +1 -0
- package/build/worker/animation-controller.d.ts +72 -0
- package/build/worker/animation-controller.js +128 -0
- package/build/worker/animation-controller.js.map +1 -0
- package/build/worker/ansi-utils.d.ts +16 -0
- package/build/worker/ansi-utils.js +40 -0
- package/build/worker/ansi-utils.js.map +1 -0
- package/build/worker/canvas.d.ts +49 -0
- package/build/worker/canvas.js +90 -0
- package/build/worker/canvas.js.map +1 -0
- package/build/worker/compositor.d.ts +33 -0
- package/build/worker/compositor.js +308 -0
- package/build/worker/compositor.js.map +1 -0
- package/build/worker/platform.d.ts +15 -0
- package/build/worker/platform.js +19 -0
- package/build/worker/platform.js.map +1 -0
- package/build/worker/render-worker.d.ts +112 -0
- package/build/worker/render-worker.js +944 -0
- package/build/worker/render-worker.js.map +1 -0
- package/build/worker/scene-manager.d.ts +26 -0
- package/build/worker/scene-manager.js +109 -0
- package/build/worker/scene-manager.js.map +1 -0
- package/build/worker/scroll-optimizer.d.ts +32 -0
- package/build/worker/scroll-optimizer.js +110 -0
- package/build/worker/scroll-optimizer.js.map +1 -0
- package/build/worker/terminal-writer.d.ts +116 -0
- package/build/worker/terminal-writer.js +708 -0
- package/build/worker/terminal-writer.js.map +1 -0
- package/build/worker/worker-entry.d.ts +6 -0
- package/build/worker/worker-entry.js +130 -0
- package/build/worker/worker-entry.js.map +1 -0
- package/license +9 -0
- package/package.json +208 -0
- package/readme.md +2353 -0
package/build/ink.js
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { throttle } from 'es-toolkit/compat';
|
|
4
|
+
import ansiEscapes from 'ansi-escapes';
|
|
5
|
+
import isInCi from 'is-in-ci';
|
|
6
|
+
import autoBind from 'auto-bind';
|
|
7
|
+
import signalExit from 'signal-exit';
|
|
8
|
+
import patchConsole from 'patch-console';
|
|
9
|
+
import { LegacyRoot } from 'react-reconciler/constants.js';
|
|
10
|
+
import Yoga from 'yoga-layout';
|
|
11
|
+
import wrapAnsi from 'wrap-ansi';
|
|
12
|
+
import reconciler from './reconciler.js';
|
|
13
|
+
import render from './renderer.js';
|
|
14
|
+
import * as dom from './dom.js';
|
|
15
|
+
import logUpdate, { positionImeCursor } from './log-update.js';
|
|
16
|
+
import instances from './instances.js';
|
|
17
|
+
import App from './components/App.js';
|
|
18
|
+
import { accessibilityContext as AccessibilityContext } from './components/AccessibilityContext.js';
|
|
19
|
+
import { calculateScroll } from './scroll.js';
|
|
20
|
+
import { measureAndExtractObservers, } from './resize-observer.js'; // Removed unused imports
|
|
21
|
+
import { Selection } from './selection.js';
|
|
22
|
+
import TerminalBuffer from './terminal-buffer.js';
|
|
23
|
+
import { setEnableToStyledCharactersCache, clearToStyledCharactersCache, } from './measure-text.js';
|
|
24
|
+
const noop = () => { };
|
|
25
|
+
const rainbowColors = [
|
|
26
|
+
'red',
|
|
27
|
+
'green',
|
|
28
|
+
'yellow',
|
|
29
|
+
'blue',
|
|
30
|
+
'magenta',
|
|
31
|
+
'cyan',
|
|
32
|
+
'white',
|
|
33
|
+
'blackBright',
|
|
34
|
+
'redBright',
|
|
35
|
+
'greenBright',
|
|
36
|
+
'yellowBright',
|
|
37
|
+
'blueBright',
|
|
38
|
+
'magentaBright',
|
|
39
|
+
'cyanBright',
|
|
40
|
+
'whiteBright',
|
|
41
|
+
];
|
|
42
|
+
export default class Ink {
|
|
43
|
+
rootNode;
|
|
44
|
+
options;
|
|
45
|
+
log;
|
|
46
|
+
throttledLog;
|
|
47
|
+
isScreenReaderEnabled;
|
|
48
|
+
selection;
|
|
49
|
+
terminalBuffer;
|
|
50
|
+
optionsState;
|
|
51
|
+
// Ignore last render after unmounting a tree to prevent empty output before exit
|
|
52
|
+
isUnmounted;
|
|
53
|
+
lastOutput;
|
|
54
|
+
lastOutputHeight;
|
|
55
|
+
lastCursorPosition;
|
|
56
|
+
container;
|
|
57
|
+
node;
|
|
58
|
+
// This variable is used only in debug mode to store full static output
|
|
59
|
+
// so that it's rerendered every time, not just new static parts, like in non-debug mode
|
|
60
|
+
fullStaticOutput;
|
|
61
|
+
exitPromise;
|
|
62
|
+
restoreConsole;
|
|
63
|
+
unsubscribeResize;
|
|
64
|
+
unsubscribeSelection;
|
|
65
|
+
frameIndex = 0;
|
|
66
|
+
isTerminalResized = false;
|
|
67
|
+
constructor(options) {
|
|
68
|
+
autoBind(this);
|
|
69
|
+
this.options = options;
|
|
70
|
+
if (options.cacheToStyledCharacters === false) {
|
|
71
|
+
setEnableToStyledCharactersCache(false);
|
|
72
|
+
}
|
|
73
|
+
else if (options.cacheToStyledCharacters === true) {
|
|
74
|
+
setEnableToStyledCharactersCache(true);
|
|
75
|
+
}
|
|
76
|
+
this.optionsState = {
|
|
77
|
+
isAlternateBufferEnabled: options.isAlternateBufferEnabled ?? options.alternateBuffer,
|
|
78
|
+
stickyHeadersInBackbuffer: options.stickyHeadersInBackbuffer,
|
|
79
|
+
animatedScroll: options.animatedScroll,
|
|
80
|
+
animationInterval: options.animationInterval,
|
|
81
|
+
backbufferUpdateDelay: options.backbufferUpdateDelay,
|
|
82
|
+
maxScrollbackLength: options.maxScrollbackLength,
|
|
83
|
+
forceScrollToBottomOnBackbufferRefresh: options.forceScrollToBottomOnBackbufferRefresh,
|
|
84
|
+
};
|
|
85
|
+
this.rootNode = dom.createNode('ink-root');
|
|
86
|
+
this.rootNode.onComputeLayout = this.calculateLayout;
|
|
87
|
+
this.isScreenReaderEnabled =
|
|
88
|
+
options.isScreenReaderEnabled ??
|
|
89
|
+
process.env['INK_SCREEN_READER'] === 'true';
|
|
90
|
+
this.selection = new Selection();
|
|
91
|
+
const unthrottled = options.debug || this.isScreenReaderEnabled;
|
|
92
|
+
const maxFps = options.maxFps ?? 30;
|
|
93
|
+
const renderThrottleMs = maxFps > 0 ? Math.max(1, Math.ceil(1000 / maxFps)) : 0;
|
|
94
|
+
const onRender = unthrottled
|
|
95
|
+
? this.onRender
|
|
96
|
+
: throttle(this.onRender, renderThrottleMs, {
|
|
97
|
+
leading: true,
|
|
98
|
+
trailing: true,
|
|
99
|
+
});
|
|
100
|
+
let isRenderScheduled = false;
|
|
101
|
+
const renderMethod = options.standardReactLayoutTiming
|
|
102
|
+
? () => {
|
|
103
|
+
if (isRenderScheduled)
|
|
104
|
+
return;
|
|
105
|
+
isRenderScheduled = true;
|
|
106
|
+
queueMicrotask(() => {
|
|
107
|
+
isRenderScheduled = false;
|
|
108
|
+
void onRender();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
: onRender;
|
|
112
|
+
this.rootNode.onRender = renderMethod;
|
|
113
|
+
this.unsubscribeSelection = this.selection.onChange(renderMethod);
|
|
114
|
+
this.rootNode.onImmediateRender = options.standardReactLayoutTiming
|
|
115
|
+
? renderMethod
|
|
116
|
+
: this.onRender; // Original unthrottled method
|
|
117
|
+
if (options.renderProcess === true || options.terminalBuffer === true) {
|
|
118
|
+
this.terminalBuffer = new TerminalBuffer(options.stdout.columns ?? 80, options.stdout.rows ?? 24, {
|
|
119
|
+
debugRainbowEnabled: options.debugRainbow,
|
|
120
|
+
renderInProcess: !options.renderProcess && options.terminalBuffer,
|
|
121
|
+
stdout: options.stdout,
|
|
122
|
+
isAlternateBufferEnabled: options.isAlternateBufferEnabled,
|
|
123
|
+
stickyHeadersInBackbuffer: options.stickyHeadersInBackbuffer,
|
|
124
|
+
animatedScroll: options.animatedScroll,
|
|
125
|
+
animationInterval: options.animationInterval,
|
|
126
|
+
backbufferUpdateDelay: options.backbufferUpdateDelay,
|
|
127
|
+
maxScrollbackLength: options.maxScrollbackLength,
|
|
128
|
+
forceScrollToBottomOnBackbufferRefresh: options.forceScrollToBottomOnBackbufferRefresh,
|
|
129
|
+
cacheToStyledCharacters: options.cacheToStyledCharacters,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
this.log = logUpdate.create(options.stdout, {
|
|
133
|
+
alternateBuffer: options.alternateBuffer,
|
|
134
|
+
alternateBufferAlreadyActive: options.alternateBufferAlreadyActive,
|
|
135
|
+
getRows: () => options.stdout.rows,
|
|
136
|
+
getColumns: () => options.stdout.columns,
|
|
137
|
+
incremental: options.incrementalRendering,
|
|
138
|
+
});
|
|
139
|
+
this.throttledLog = unthrottled
|
|
140
|
+
? this.log
|
|
141
|
+
: throttle(this.log, undefined, {
|
|
142
|
+
leading: true,
|
|
143
|
+
trailing: true,
|
|
144
|
+
});
|
|
145
|
+
// Ignore last render after unmounting a tree to prevent empty output before exit
|
|
146
|
+
this.isUnmounted = false;
|
|
147
|
+
// Store last output to only rerender when needed
|
|
148
|
+
this.lastOutput = '';
|
|
149
|
+
this.lastOutputHeight = 0;
|
|
150
|
+
// This variable is used only in debug mode to store full static output
|
|
151
|
+
// so that it's rerendered every time, not just new static parts, like in non-debug mode
|
|
152
|
+
this.fullStaticOutput = '';
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
154
|
+
this.container = reconciler.createContainer(this.rootNode, LegacyRoot, null, false, null, 'id', () => { }, () => { }, () => { }, () => { }, null);
|
|
155
|
+
// Unmount when process exits
|
|
156
|
+
this.unsubscribeExit = signalExit(this.unmount, { alwaysLast: false });
|
|
157
|
+
if (process.env['DEV'] === 'true') {
|
|
158
|
+
reconciler.injectIntoDevTools({
|
|
159
|
+
bundleType: 0,
|
|
160
|
+
// Reporting React DOM's version, not Ink's
|
|
161
|
+
// See https://github.com/facebook/react/issues/16666#issuecomment-532639905
|
|
162
|
+
version: '16.13.1',
|
|
163
|
+
rendererPackageName: 'ink',
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (options.patchConsole) {
|
|
167
|
+
this.patchConsole();
|
|
168
|
+
}
|
|
169
|
+
if (!isInCi) {
|
|
170
|
+
options.stdout.on('resize', this.resized);
|
|
171
|
+
this.unsubscribeResize = () => {
|
|
172
|
+
options.stdout.off('resize', this.resized);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
resized = () => {
|
|
177
|
+
const terminalWidth = this.options.stdout.columns ?? 80;
|
|
178
|
+
const terminalHeight = this.options.stdout.rows ?? 24;
|
|
179
|
+
clearToStyledCharactersCache();
|
|
180
|
+
this.terminalBuffer?.resize(terminalWidth, terminalHeight);
|
|
181
|
+
this.resetScrollbackPadding(this.rootNode);
|
|
182
|
+
this.isTerminalResized = true;
|
|
183
|
+
this.calculateLayout();
|
|
184
|
+
void this.onRender();
|
|
185
|
+
};
|
|
186
|
+
getSelection() {
|
|
187
|
+
return this.selection;
|
|
188
|
+
}
|
|
189
|
+
resolveExitPromise = () => { };
|
|
190
|
+
rejectExitPromise = () => { };
|
|
191
|
+
unsubscribeExit = () => { };
|
|
192
|
+
calculateLayout = () => {
|
|
193
|
+
// The 'columns' property can be undefined or 0 when not using a TTY.
|
|
194
|
+
// In that case we fall back to 80.
|
|
195
|
+
const terminalWidth = this.options.stdout.columns ?? 80;
|
|
196
|
+
this.rootNode.yogaNode.setWidth(terminalWidth);
|
|
197
|
+
this.rootNode.yogaNode.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR);
|
|
198
|
+
const observerEntries = new Map();
|
|
199
|
+
this.calculateLayoutAndTriggerObservers(this.rootNode, observerEntries, this.isTerminalResized);
|
|
200
|
+
this.isTerminalResized = false;
|
|
201
|
+
for (const [observer, entries] of observerEntries) {
|
|
202
|
+
observer.internalTrigger(entries);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
calculateLayoutAndTriggerObservers(node, observerEntries, isTerminalResized = false) {
|
|
206
|
+
if (node.nodeName === 'ink-box') {
|
|
207
|
+
const { style } = node;
|
|
208
|
+
const overflow = style.overflow ?? 'visible';
|
|
209
|
+
const overflowX = style.overflowX ?? overflow;
|
|
210
|
+
const overflowY = style.overflowY ?? overflow;
|
|
211
|
+
if (overflowX === 'scroll' || overflowY === 'scroll') {
|
|
212
|
+
calculateScroll(node, isTerminalResized);
|
|
213
|
+
}
|
|
214
|
+
else if (node.internal_scrollState) {
|
|
215
|
+
delete node.internal_scrollState;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
measureAndExtractObservers(node, observerEntries);
|
|
219
|
+
if (node.internal_static ||
|
|
220
|
+
(node.nodeName === 'ink-static-render' && node.cachedRender)) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
for (const child of node.childNodes) {
|
|
224
|
+
if (child.nodeName !== '#text') {
|
|
225
|
+
this.calculateLayoutAndTriggerObservers(child, observerEntries, isTerminalResized);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
onRender = async () => {
|
|
230
|
+
if (this.isUnmounted) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const startTime = performance.now();
|
|
234
|
+
let debugRainbowColor;
|
|
235
|
+
if (this.options.debugRainbow) {
|
|
236
|
+
debugRainbowColor = rainbowColors[this.frameIndex % rainbowColors.length];
|
|
237
|
+
this.frameIndex++;
|
|
238
|
+
}
|
|
239
|
+
const { output, outputHeight, staticOutput, styledOutput, cursorPosition, root, } = render(this.rootNode, {
|
|
240
|
+
isScreenReaderEnabled: this.isScreenReaderEnabled,
|
|
241
|
+
selection: this.selection,
|
|
242
|
+
selectionStyle: this.options.selectionStyle,
|
|
243
|
+
skipScrollbars: Boolean(this.terminalBuffer),
|
|
244
|
+
});
|
|
245
|
+
if (this.terminalBuffer && root) {
|
|
246
|
+
await this.renderWithTerminalBuffer(root, cursorPosition);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
// If <Static> output isn't empty, it means new children have been added to it
|
|
250
|
+
const hasStaticOutput = Boolean(staticOutput && staticOutput !== '\n');
|
|
251
|
+
const renderOptions = {
|
|
252
|
+
output,
|
|
253
|
+
outputHeight,
|
|
254
|
+
staticOutput,
|
|
255
|
+
styledOutput,
|
|
256
|
+
cursorPosition,
|
|
257
|
+
debugRainbowColor,
|
|
258
|
+
hasStaticOutput,
|
|
259
|
+
};
|
|
260
|
+
if (this.options.debug) {
|
|
261
|
+
this.renderDebug(renderOptions);
|
|
262
|
+
}
|
|
263
|
+
else if (isInCi) {
|
|
264
|
+
this.renderCi(renderOptions);
|
|
265
|
+
}
|
|
266
|
+
else if (this.optionsState.isAlternateBufferEnabled) {
|
|
267
|
+
this.renderAlternateBuffer(renderOptions);
|
|
268
|
+
}
|
|
269
|
+
else if (this.isScreenReaderEnabled) {
|
|
270
|
+
this.renderScreenReader(renderOptions);
|
|
271
|
+
}
|
|
272
|
+
else if (this.lastOutputHeight >= this.options.stdout.rows) {
|
|
273
|
+
this.renderFullTerminal(renderOptions);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this.renderLegacy(renderOptions);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
this.callOnRender(startTime, output, staticOutput);
|
|
280
|
+
};
|
|
281
|
+
recalculateLayout() {
|
|
282
|
+
this.markAllTextNodesDirty(this.rootNode);
|
|
283
|
+
this.calculateLayout();
|
|
284
|
+
void this.onRender();
|
|
285
|
+
}
|
|
286
|
+
onRerender = () => {
|
|
287
|
+
if (this.isUnmounted) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
this.log.clear();
|
|
291
|
+
this.lastOutput = '';
|
|
292
|
+
this.resetScrollbackPadding(this.rootNode);
|
|
293
|
+
void this.onRender();
|
|
294
|
+
};
|
|
295
|
+
setOptions = (options) => {
|
|
296
|
+
this.optionsState = {
|
|
297
|
+
...this.optionsState,
|
|
298
|
+
...options,
|
|
299
|
+
};
|
|
300
|
+
this.terminalBuffer?.updateOptions(this.optionsState);
|
|
301
|
+
this.lastOutput = '';
|
|
302
|
+
if (this.node) {
|
|
303
|
+
this.render(this.node);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
this.onRerender();
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
render(node) {
|
|
310
|
+
this.node = node;
|
|
311
|
+
const tree = (React.createElement(AccessibilityContext.Provider, { value: { isScreenReaderEnabled: this.isScreenReaderEnabled } },
|
|
312
|
+
React.createElement(App, { stdin: this.options.stdin, stdout: this.options.stdout, stderr: this.options.stderr, writeToStdout: this.writeToStdout, writeToStderr: this.writeToStderr, exitOnCtrlC: this.options.exitOnCtrlC, selection: this.selection, options: this.optionsState, setOptions: this.setOptions, dumpCurrentFrame: this.dumpCurrentFrame, startRecording: this.startRecording, stopRecording: this.stopRecording, onExit: this.unmount, onRerender: this.onRerender }, node)));
|
|
313
|
+
// @ts-expect-error the types for `react-reconciler` are not up to date with the library.
|
|
314
|
+
reconciler.updateContainerSync(tree, this.container, null, noop);
|
|
315
|
+
// @ts-expect-error the types for `react-reconciler` are not up to date with the library.
|
|
316
|
+
reconciler.flushSyncWork();
|
|
317
|
+
}
|
|
318
|
+
writeToStdout(data) {
|
|
319
|
+
if (this.isUnmounted) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (this.options.debug) {
|
|
323
|
+
this.options.stdout.write(data + this.fullStaticOutput + this.lastOutput);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (isInCi) {
|
|
327
|
+
this.options.stdout.write(data);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.log.clear();
|
|
331
|
+
this.options.stdout.write(data);
|
|
332
|
+
this.log(this.lastOutput, []);
|
|
333
|
+
}
|
|
334
|
+
writeToStderr(data) {
|
|
335
|
+
if (this.isUnmounted) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (this.options.debug) {
|
|
339
|
+
this.options.stderr.write(data);
|
|
340
|
+
this.options.stdout.write(this.fullStaticOutput + this.lastOutput);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (isInCi) {
|
|
344
|
+
this.options.stderr.write(data);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
this.log.clear();
|
|
348
|
+
this.options.stderr.write(data);
|
|
349
|
+
this.log(this.lastOutput, []);
|
|
350
|
+
}
|
|
351
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
352
|
+
unmount(error) {
|
|
353
|
+
if (this.isUnmounted) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
this.calculateLayout();
|
|
357
|
+
void this.onRender();
|
|
358
|
+
this.unsubscribeExit();
|
|
359
|
+
if (typeof this.restoreConsole === 'function') {
|
|
360
|
+
this.restoreConsole();
|
|
361
|
+
}
|
|
362
|
+
if (typeof this.unsubscribeResize === 'function') {
|
|
363
|
+
this.unsubscribeResize();
|
|
364
|
+
}
|
|
365
|
+
if (typeof this.unsubscribeSelection === 'function') {
|
|
366
|
+
this.unsubscribeSelection();
|
|
367
|
+
}
|
|
368
|
+
// CIs don't handle erasing ansi escapes well, so it's better to
|
|
369
|
+
// only render last frame of non-static output
|
|
370
|
+
if (isInCi) {
|
|
371
|
+
this.options.stdout.write(this.lastOutput + '\n');
|
|
372
|
+
}
|
|
373
|
+
else if (!this.options.debug) {
|
|
374
|
+
this.log.done();
|
|
375
|
+
if (this.terminalBuffer) {
|
|
376
|
+
this.terminalBuffer.done();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (this.terminalBuffer) {
|
|
380
|
+
this.terminalBuffer.destroy();
|
|
381
|
+
}
|
|
382
|
+
this.isUnmounted = true;
|
|
383
|
+
// @ts-expect-error the types for `react-reconciler` are not up to date with the library.
|
|
384
|
+
reconciler.updateContainerSync(null, this.container, null, noop);
|
|
385
|
+
// @ts-expect-error the types for `react-reconciler` are not up to date with the library.
|
|
386
|
+
reconciler.flushSyncWork();
|
|
387
|
+
instances.delete(this.options.stdout);
|
|
388
|
+
if (error instanceof Error) {
|
|
389
|
+
this.rejectExitPromise(error);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
this.resolveExitPromise();
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
async waitUntilExit() {
|
|
396
|
+
this.exitPromise ||= new Promise((resolve, reject) => {
|
|
397
|
+
this.resolveExitPromise = resolve;
|
|
398
|
+
this.rejectExitPromise = reject;
|
|
399
|
+
});
|
|
400
|
+
return this.exitPromise;
|
|
401
|
+
}
|
|
402
|
+
dumpCurrentFrame(filename) {
|
|
403
|
+
if (this.terminalBuffer) {
|
|
404
|
+
this.terminalBuffer.dumpCurrentFrame(filename);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
console.error('dumpCurrentFrame is only supported when terminalBuffer is true');
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
startRecording(filename) {
|
|
411
|
+
if (this.terminalBuffer) {
|
|
412
|
+
this.terminalBuffer.startRecording(filename);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
console.error('startRecording is only supported when terminalBuffer is true');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
stopRecording() {
|
|
419
|
+
if (this.terminalBuffer) {
|
|
420
|
+
this.terminalBuffer.stopRecording();
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
console.error('stopRecording is only supported when terminalBuffer is true');
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
clear() {
|
|
427
|
+
if (!isInCi && !this.options.debug) {
|
|
428
|
+
this.log.clear();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
patchConsole() {
|
|
432
|
+
if (this.options.debug) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
this.restoreConsole = patchConsole((stream, data) => {
|
|
436
|
+
if (stream === 'stdout') {
|
|
437
|
+
this.writeToStdout(data);
|
|
438
|
+
}
|
|
439
|
+
if (stream === 'stderr') {
|
|
440
|
+
const isReactMessage = data.startsWith('The above error occurred');
|
|
441
|
+
if (!isReactMessage) {
|
|
442
|
+
this.writeToStderr(data);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
async renderWithTerminalBuffer(root, cursorPosition) {
|
|
448
|
+
const appliedChanges = this.terminalBuffer.update(0, Number.MAX_SAFE_INTEGER, root, cursorPosition);
|
|
449
|
+
if (appliedChanges) {
|
|
450
|
+
await this.terminalBuffer.render();
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
renderDebug({ output, staticOutput, hasStaticOutput, }) {
|
|
454
|
+
if (hasStaticOutput) {
|
|
455
|
+
this.fullStaticOutput += staticOutput;
|
|
456
|
+
}
|
|
457
|
+
this.options.stdout.write(this.fullStaticOutput + output);
|
|
458
|
+
}
|
|
459
|
+
renderCi({ output, outputHeight, staticOutput, hasStaticOutput, }) {
|
|
460
|
+
if (hasStaticOutput) {
|
|
461
|
+
this.options.stdout.write(staticOutput);
|
|
462
|
+
}
|
|
463
|
+
this.lastOutput = output;
|
|
464
|
+
this.lastOutputHeight = outputHeight;
|
|
465
|
+
}
|
|
466
|
+
renderAlternateBuffer({ output, styledOutput, staticOutput, cursorPosition, debugRainbowColor, hasStaticOutput, }) {
|
|
467
|
+
if (hasStaticOutput) {
|
|
468
|
+
this.fullStaticOutput += staticOutput;
|
|
469
|
+
}
|
|
470
|
+
this.log(this.fullStaticOutput + output, styledOutput, debugRainbowColor, cursorPosition);
|
|
471
|
+
this.lastOutput = output;
|
|
472
|
+
}
|
|
473
|
+
renderScreenReader({ output, staticOutput, hasStaticOutput, }) {
|
|
474
|
+
if (hasStaticOutput) {
|
|
475
|
+
// We need to erase the main output before writing new static output
|
|
476
|
+
const erase = this.lastOutputHeight > 0
|
|
477
|
+
? ansiEscapes.eraseLines(this.lastOutputHeight)
|
|
478
|
+
: '';
|
|
479
|
+
this.options.stdout.write(erase + staticOutput);
|
|
480
|
+
// After erasing, the last output is gone, so we should reset its height
|
|
481
|
+
this.lastOutputHeight = 0;
|
|
482
|
+
}
|
|
483
|
+
if (output === this.lastOutput && !hasStaticOutput) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
const terminalWidth = this.options.stdout.columns ?? 80;
|
|
487
|
+
const wrappedOutput = wrapAnsi(output, terminalWidth, {
|
|
488
|
+
trim: false,
|
|
489
|
+
hard: true,
|
|
490
|
+
});
|
|
491
|
+
// If we haven't erased yet, do it now.
|
|
492
|
+
if (hasStaticOutput) {
|
|
493
|
+
this.options.stdout.write(wrappedOutput);
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
const erase = this.lastOutputHeight > 0
|
|
497
|
+
? ansiEscapes.eraseLines(this.lastOutputHeight)
|
|
498
|
+
: '';
|
|
499
|
+
this.options.stdout.write(erase + wrappedOutput);
|
|
500
|
+
}
|
|
501
|
+
this.lastOutput = output;
|
|
502
|
+
this.lastOutputHeight =
|
|
503
|
+
wrappedOutput === '' ? 0 : wrappedOutput.split('\n').length;
|
|
504
|
+
}
|
|
505
|
+
renderFullTerminal({ output, outputHeight, staticOutput, cursorPosition, hasStaticOutput, }) {
|
|
506
|
+
if (hasStaticOutput) {
|
|
507
|
+
this.fullStaticOutput += staticOutput;
|
|
508
|
+
}
|
|
509
|
+
// Build a single buffer for all operations
|
|
510
|
+
let buffer = '';
|
|
511
|
+
buffer += ansiEscapes.clearTerminal + this.fullStaticOutput + output;
|
|
512
|
+
// Position cursor after screen clear if requested by a component
|
|
513
|
+
if (cursorPosition) {
|
|
514
|
+
const lineCount = output.split('\n').length;
|
|
515
|
+
buffer += positionImeCursor(lineCount, cursorPosition);
|
|
516
|
+
}
|
|
517
|
+
this.options.stdout.write(buffer);
|
|
518
|
+
this.lastOutput = output;
|
|
519
|
+
this.lastOutputHeight = outputHeight;
|
|
520
|
+
this.lastCursorPosition = cursorPosition;
|
|
521
|
+
this.log.sync(output, cursorPosition);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* The goal is to remove this method making terminal buffer required.
|
|
525
|
+
*/
|
|
526
|
+
renderLegacy({ output, outputHeight, styledOutput, staticOutput, cursorPosition, debugRainbowColor, hasStaticOutput, }) {
|
|
527
|
+
if (hasStaticOutput) {
|
|
528
|
+
this.fullStaticOutput += staticOutput;
|
|
529
|
+
}
|
|
530
|
+
// To ensure static output is cleanly rendered before main output, clear main output first
|
|
531
|
+
if (hasStaticOutput) {
|
|
532
|
+
this.log.clear();
|
|
533
|
+
this.options.stdout.write(staticOutput);
|
|
534
|
+
this.log(output, styledOutput, debugRainbowColor, cursorPosition);
|
|
535
|
+
}
|
|
536
|
+
const outputChanged = output !== this.lastOutput;
|
|
537
|
+
const cursorChanged = cursorPosition !== this.lastCursorPosition &&
|
|
538
|
+
(!cursorPosition ||
|
|
539
|
+
!this.lastCursorPosition ||
|
|
540
|
+
cursorPosition.row !== this.lastCursorPosition.row ||
|
|
541
|
+
cursorPosition.col !== this.lastCursorPosition.col);
|
|
542
|
+
if (!hasStaticOutput && (outputChanged || cursorChanged)) {
|
|
543
|
+
this.throttledLog(output, styledOutput, debugRainbowColor, cursorPosition);
|
|
544
|
+
}
|
|
545
|
+
this.lastOutput = output;
|
|
546
|
+
this.lastOutputHeight = outputHeight;
|
|
547
|
+
this.lastCursorPosition = cursorPosition;
|
|
548
|
+
}
|
|
549
|
+
markAllTextNodesDirty(node) {
|
|
550
|
+
if (node.nodeName === 'ink-text' && node.yogaNode) {
|
|
551
|
+
node.yogaNode.markDirty();
|
|
552
|
+
}
|
|
553
|
+
for (const child of node.childNodes) {
|
|
554
|
+
if (child.nodeName !== '#text') {
|
|
555
|
+
this.markAllTextNodesDirty(child);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
resetScrollbackPadding(node) {
|
|
560
|
+
node.internalMaxScrollTop = 0;
|
|
561
|
+
node.internalIsScrollbackDirty = false;
|
|
562
|
+
for (const child of node.childNodes) {
|
|
563
|
+
if (child.nodeName !== '#text') {
|
|
564
|
+
this.resetScrollbackPadding(child);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
callOnRender(startTime, output, staticOutput) {
|
|
569
|
+
this.options.onRender?.({
|
|
570
|
+
renderTime: performance.now() - startTime,
|
|
571
|
+
output,
|
|
572
|
+
staticOutput,
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
//# sourceMappingURL=ink.js.map
|
package/build/ink.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ink.js","sourceRoot":"","sources":["../src/ink.tsx"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAC,QAAQ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AE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACzC,MAAM;YACN,YAAY;SACZ,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Store all instances of Ink (instance.js) to ensure that consecutive render() calls
|
|
2
|
+
// use the same instance of Ink and don't create a new one
|
|
3
|
+
//
|
|
4
|
+
// This map has to be stored in a separate file, because render.js creates instances,
|
|
5
|
+
// but instance.js should delete itself from the map on unmount
|
|
6
|
+
const instances = new WeakMap();
|
|
7
|
+
export default instances;
|
|
8
|
+
//# sourceMappingURL=instances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instances.js","sourceRoot":"","sources":["../src/instances.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,0DAA0D;AAC1D,EAAE;AACF,qFAAqF;AACrF,+DAA+D;AAI/D,MAAM,SAAS,GAAG,IAAI,OAAO,EAA2B,CAAC;AACzD,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type DOMNode } from './dom.js';
|
|
7
|
+
import { type TextFragment } from './measure-element.js';
|
|
8
|
+
export type LayoutState = Record<string, any>;
|
|
9
|
+
export type LayoutCallbacks<T extends LayoutState> = {
|
|
10
|
+
onText: (fragment: TextFragment, state: T) => void;
|
|
11
|
+
onNewline: (count: number, state: T) => void;
|
|
12
|
+
onSpace: (count: number, state: T) => void;
|
|
13
|
+
initialState: () => T;
|
|
14
|
+
};
|
|
15
|
+
export declare const processLayout: <T extends LayoutState>(node: DOMNode, callbacks: LayoutCallbacks<T>) => {
|
|
16
|
+
state: T;
|
|
17
|
+
lineBottom: number;
|
|
18
|
+
};
|