ink 3.2.0 → 4.0.0
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 +3 -3
- package/build/colorize.js +30 -35
- package/build/colorize.js.map +1 -1
- package/build/components/App.d.ts +12 -12
- package/build/components/App.js +287 -208
- package/build/components/App.js.map +1 -1
- package/build/components/AppContext.d.ts +2 -2
- package/build/components/AppContext.js +5 -6
- package/build/components/AppContext.js.map +1 -1
- package/build/components/Box.d.ts +5 -5
- package/build/components/Box.js +15 -38
- package/build/components/Box.js.map +1 -1
- package/build/components/ErrorOverview.d.ts +5 -5
- package/build/components/ErrorOverview.js +40 -58
- package/build/components/ErrorOverview.js.map +1 -1
- package/build/components/FocusContext.d.ts +2 -2
- package/build/components/FocusContext.js +13 -14
- package/build/components/FocusContext.js.map +1 -1
- package/build/components/Newline.d.ts +4 -5
- package/build/components/Newline.js +4 -9
- package/build/components/Newline.js.map +1 -1
- package/build/components/Spacer.d.ts +2 -3
- package/build/components/Spacer.js +5 -10
- package/build/components/Spacer.js.map +1 -1
- package/build/components/Static.d.ts +5 -9
- package/build/components/Static.js +12 -33
- package/build/components/Static.js.map +1 -1
- package/build/components/StderrContext.d.ts +4 -4
- package/build/components/StderrContext.js +7 -7
- package/build/components/StderrContext.js.map +1 -1
- package/build/components/StdinContext.d.ts +4 -4
- package/build/components/StdinContext.js +8 -7
- package/build/components/StdinContext.js.map +1 -1
- package/build/components/StdoutContext.d.ts +4 -4
- package/build/components/StdoutContext.js +7 -7
- package/build/components/StdoutContext.js.map +1 -1
- package/build/components/Text.d.ts +9 -10
- package/build/components/Text.js +14 -29
- package/build/components/Text.js.map +1 -1
- package/build/components/Transform.d.ts +4 -5
- package/build/components/Transform.js +4 -11
- package/build/components/Transform.js.map +1 -1
- package/build/devtools-window-polyfill.js +3 -8
- package/build/devtools-window-polyfill.js.map +1 -1
- package/build/devtools.d.ts +1 -1
- package/build/devtools.js +6 -6
- package/build/devtools.js.map +1 -1
- package/build/dom.d.ts +14 -17
- package/build/dom.js +34 -47
- package/build/dom.js.map +1 -1
- package/build/get-max-width.d.ts +2 -2
- package/build/get-max-width.js +7 -11
- package/build/get-max-width.js.map +1 -1
- package/build/hooks/use-app.d.ts +1 -1
- package/build/hooks/use-app.js +4 -9
- package/build/hooks/use-app.js.map +1 -1
- package/build/hooks/use-focus-manager.d.ts +3 -3
- package/build/hooks/use-focus-manager.js +4 -9
- package/build/hooks/use-focus-manager.js.map +1 -1
- package/build/hooks/use-focus.d.ts +4 -4
- package/build/hooks/use-focus.js +11 -16
- package/build/hooks/use-focus.js.map +1 -1
- package/build/hooks/use-input.d.ts +5 -5
- package/build/hooks/use-input.js +13 -14
- package/build/hooks/use-input.js.map +1 -1
- package/build/hooks/use-stderr.d.ts +1 -1
- package/build/hooks/use-stderr.js +4 -9
- package/build/hooks/use-stderr.js.map +1 -1
- package/build/hooks/use-stdin.d.ts +1 -1
- package/build/hooks/use-stdin.js +4 -9
- package/build/hooks/use-stdin.js.map +1 -1
- package/build/hooks/use-stdout.d.ts +1 -1
- package/build/hooks/use-stdout.js +4 -9
- package/build/hooks/use-stdout.js.map +1 -1
- package/build/index.d.ts +27 -20
- package/build/index.js +15 -32
- package/build/index.js.map +1 -1
- package/build/ink.d.ts +4 -4
- package/build/ink.js +165 -98
- package/build/ink.js.map +1 -1
- package/build/instances.d.ts +4 -2
- package/build/instances.js +2 -3
- package/build/instances.js.map +1 -1
- package/build/log-update.d.ts +5 -6
- package/build/log-update.js +8 -12
- package/build/log-update.js.map +1 -1
- package/build/measure-element.d.ts +5 -5
- package/build/measure-element.js +5 -9
- package/build/measure-element.js.map +1 -1
- package/build/measure-text.d.ts +4 -4
- package/build/measure-text.js +7 -10
- package/build/measure-text.js.map +1 -1
- package/build/output.d.ts +3 -3
- package/build/output.js +25 -15
- package/build/output.js.map +1 -1
- package/build/reconciler.d.ts +1 -1
- package/build/reconciler.js +97 -76
- package/build/reconciler.js.map +1 -1
- package/build/render-border.d.ts +4 -4
- package/build/render-border.js +8 -12
- package/build/render-border.js.map +1 -1
- package/build/render-node-to-output.d.ts +3 -3
- package/build/render-node-to-output.js +17 -24
- package/build/render-node-to-output.js.map +1 -1
- package/build/render.d.ts +8 -8
- package/build/render.js +23 -20
- package/build/render.js.map +1 -1
- package/build/renderer.d.ts +5 -5
- package/build/renderer.js +11 -16
- package/build/renderer.js.map +1 -1
- package/build/squash-text-nodes.d.ts +1 -1
- package/build/squash-text-nodes.js +1 -3
- package/build/squash-text-nodes.js.map +1 -1
- package/build/styles.d.ts +9 -9
- package/build/styles.js +39 -45
- package/build/styles.js.map +1 -1
- package/build/wrap-text.d.ts +3 -3
- package/build/wrap-text.js +9 -12
- package/build/wrap-text.js.map +1 -1
- package/license +1 -1
- package/package.json +86 -66
- package/readme.md +91 -49
package/build/ink.js
CHANGED
|
@@ -1,104 +1,170 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const react_1 = __importDefault(require("react"));
|
|
26
|
-
const lodash_1 = require("lodash");
|
|
27
|
-
const log_update_1 = __importDefault(require("./log-update"));
|
|
28
|
-
const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
|
|
29
|
-
const is_ci_1 = __importDefault(require("is-ci"));
|
|
30
|
-
const auto_bind_1 = __importDefault(require("auto-bind"));
|
|
31
|
-
const reconciler_1 = __importDefault(require("./reconciler"));
|
|
32
|
-
const renderer_1 = __importDefault(require("./renderer"));
|
|
33
|
-
const signal_exit_1 = __importDefault(require("signal-exit"));
|
|
34
|
-
const patch_console_1 = __importDefault(require("patch-console"));
|
|
35
|
-
const dom = __importStar(require("./dom"));
|
|
36
|
-
const instances_1 = __importDefault(require("./instances"));
|
|
37
|
-
const App_1 = __importDefault(require("./components/App"));
|
|
38
|
-
const isCI = process.env.CI === 'false' ? false : is_ci_1.default;
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { throttle } from 'lodash-es';
|
|
4
|
+
import ansiEscapes from 'ansi-escapes';
|
|
5
|
+
import originalIsCi from 'is-ci';
|
|
6
|
+
import autoBind from 'auto-bind';
|
|
7
|
+
import signalExit from 'signal-exit';
|
|
8
|
+
import patchConsole from 'patch-console';
|
|
9
|
+
import reconciler from './reconciler.js';
|
|
10
|
+
import render from './renderer.js';
|
|
11
|
+
import * as dom from './dom.js';
|
|
12
|
+
import logUpdate from './log-update.js';
|
|
13
|
+
import instances from './instances.js';
|
|
14
|
+
import App from './components/App.js';
|
|
15
|
+
const isCi = process.env['CI'] === 'false' ? false : originalIsCi;
|
|
39
16
|
const noop = () => { };
|
|
40
|
-
class Ink {
|
|
17
|
+
export default class Ink {
|
|
41
18
|
constructor(options) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
19
|
+
Object.defineProperty(this, "options", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "log", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(this, "throttledLog", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
// Ignore last render after unmounting a tree to prevent empty output before exit
|
|
38
|
+
Object.defineProperty(this, "isUnmounted", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: void 0
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "lastOutput", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: void 0
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(this, "container", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: void 0
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(this, "rootNode", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
value: void 0
|
|
61
|
+
});
|
|
62
|
+
// This variable is used only in debug mode to store full static output
|
|
63
|
+
// so that it's rerendered every time, not just new static parts, like in non-debug mode
|
|
64
|
+
Object.defineProperty(this, "fullStaticOutput", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true,
|
|
68
|
+
value: void 0
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(this, "exitPromise", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
value: void 0
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(this, "restoreConsole", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
configurable: true,
|
|
79
|
+
writable: true,
|
|
80
|
+
value: void 0
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(this, "unsubscribeResize", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
configurable: true,
|
|
85
|
+
writable: true,
|
|
86
|
+
value: void 0
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(this, "resolveExitPromise", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
value: () => { }
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(this, "rejectExitPromise", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
configurable: true,
|
|
97
|
+
writable: true,
|
|
98
|
+
value: () => { }
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(this, "unsubscribeExit", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
value: () => { }
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(this, "onRender", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
configurable: true,
|
|
109
|
+
writable: true,
|
|
110
|
+
value: () => {
|
|
111
|
+
if (this.isUnmounted) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const { output, outputHeight, staticOutput } = render(this.rootNode,
|
|
115
|
+
// The 'columns' property can be undefined or 0 when not using a TTY.
|
|
116
|
+
// In that case we fall back to 80.
|
|
117
|
+
this.options.stdout.columns || 80);
|
|
118
|
+
// If <Static> output isn't empty, it means new children have been added to it
|
|
119
|
+
const hasStaticOutput = staticOutput && staticOutput !== '\n';
|
|
120
|
+
if (this.options.debug) {
|
|
121
|
+
if (hasStaticOutput) {
|
|
122
|
+
this.fullStaticOutput += staticOutput;
|
|
123
|
+
}
|
|
124
|
+
this.options.stdout.write(this.fullStaticOutput + output);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (isCi) {
|
|
128
|
+
if (hasStaticOutput) {
|
|
129
|
+
this.options.stdout.write(staticOutput);
|
|
130
|
+
}
|
|
131
|
+
this.lastOutput = output;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
56
134
|
if (hasStaticOutput) {
|
|
57
135
|
this.fullStaticOutput += staticOutput;
|
|
58
136
|
}
|
|
59
|
-
this.options.stdout.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
137
|
+
if (outputHeight >= this.options.stdout.rows) {
|
|
138
|
+
this.options.stdout.write(ansiEscapes.clearTerminal + this.fullStaticOutput + output);
|
|
139
|
+
this.lastOutput = output;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// To ensure static output is cleanly rendered before main output, clear main output first
|
|
63
143
|
if (hasStaticOutput) {
|
|
144
|
+
this.log.clear();
|
|
64
145
|
this.options.stdout.write(staticOutput);
|
|
146
|
+
this.log(output);
|
|
147
|
+
}
|
|
148
|
+
if (!hasStaticOutput && output !== this.lastOutput) {
|
|
149
|
+
this.throttledLog(output);
|
|
65
150
|
}
|
|
66
151
|
this.lastOutput = output;
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (hasStaticOutput) {
|
|
70
|
-
this.fullStaticOutput += staticOutput;
|
|
71
|
-
}
|
|
72
|
-
if (outputHeight >= this.options.stdout.rows) {
|
|
73
|
-
this.options.stdout.write(ansi_escapes_1.default.clearTerminal + this.fullStaticOutput + output);
|
|
74
|
-
this.lastOutput = output;
|
|
75
|
-
return;
|
|
76
152
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.log.clear();
|
|
80
|
-
this.options.stdout.write(staticOutput);
|
|
81
|
-
this.log(output);
|
|
82
|
-
}
|
|
83
|
-
if (!hasStaticOutput && output !== this.lastOutput) {
|
|
84
|
-
this.throttledLog(output);
|
|
85
|
-
}
|
|
86
|
-
this.lastOutput = output;
|
|
87
|
-
};
|
|
88
|
-
auto_bind_1.default(this);
|
|
153
|
+
});
|
|
154
|
+
autoBind(this);
|
|
89
155
|
this.options = options;
|
|
90
156
|
this.rootNode = dom.createNode('ink-root');
|
|
91
157
|
this.rootNode.onRender = options.debug
|
|
92
158
|
? this.onRender
|
|
93
|
-
:
|
|
159
|
+
: throttle(this.onRender, 32, {
|
|
94
160
|
leading: true,
|
|
95
161
|
trailing: true
|
|
96
162
|
});
|
|
97
163
|
this.rootNode.onImmediateRender = this.onRender;
|
|
98
|
-
this.log =
|
|
164
|
+
this.log = logUpdate.create(options.stdout);
|
|
99
165
|
this.throttledLog = options.debug
|
|
100
166
|
? this.log
|
|
101
|
-
:
|
|
167
|
+
: throttle(this.log, undefined, {
|
|
102
168
|
leading: true,
|
|
103
169
|
trailing: true
|
|
104
170
|
});
|
|
@@ -109,13 +175,14 @@ class Ink {
|
|
|
109
175
|
// This variable is used only in debug mode to store full static output
|
|
110
176
|
// so that it's rerendered every time, not just new static parts, like in non-debug mode
|
|
111
177
|
this.fullStaticOutput = '';
|
|
112
|
-
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
179
|
+
this.container = reconciler.createContainer(this.rootNode,
|
|
113
180
|
// Legacy mode
|
|
114
|
-
0, false, null);
|
|
181
|
+
0, null, false, null, 'id', () => { }, null);
|
|
115
182
|
// Unmount when process exits
|
|
116
|
-
this.unsubscribeExit =
|
|
117
|
-
if (process.env
|
|
118
|
-
|
|
183
|
+
this.unsubscribeExit = signalExit(this.unmount, { alwaysLast: false });
|
|
184
|
+
if (process.env['DEV'] === 'true') {
|
|
185
|
+
reconciler.injectIntoDevTools({
|
|
119
186
|
bundleType: 0,
|
|
120
187
|
// Reporting React DOM's version, not Ink's
|
|
121
188
|
// See https://github.com/facebook/react/issues/16666#issuecomment-532639905
|
|
@@ -126,7 +193,7 @@ class Ink {
|
|
|
126
193
|
if (options.patchConsole) {
|
|
127
194
|
this.patchConsole();
|
|
128
195
|
}
|
|
129
|
-
if (!
|
|
196
|
+
if (!isCi) {
|
|
130
197
|
options.stdout.on('resize', this.onRender);
|
|
131
198
|
this.unsubscribeResize = () => {
|
|
132
199
|
options.stdout.off('resize', this.onRender);
|
|
@@ -134,8 +201,8 @@ class Ink {
|
|
|
134
201
|
}
|
|
135
202
|
}
|
|
136
203
|
render(node) {
|
|
137
|
-
const tree = (
|
|
138
|
-
|
|
204
|
+
const tree = (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, onExit: this.unmount }, node));
|
|
205
|
+
reconciler.updateContainer(tree, this.container, null, noop);
|
|
139
206
|
}
|
|
140
207
|
writeToStdout(data) {
|
|
141
208
|
if (this.isUnmounted) {
|
|
@@ -145,7 +212,7 @@ class Ink {
|
|
|
145
212
|
this.options.stdout.write(data + this.fullStaticOutput + this.lastOutput);
|
|
146
213
|
return;
|
|
147
214
|
}
|
|
148
|
-
if (
|
|
215
|
+
if (isCi) {
|
|
149
216
|
this.options.stdout.write(data);
|
|
150
217
|
return;
|
|
151
218
|
}
|
|
@@ -162,7 +229,7 @@ class Ink {
|
|
|
162
229
|
this.options.stdout.write(this.fullStaticOutput + this.lastOutput);
|
|
163
230
|
return;
|
|
164
231
|
}
|
|
165
|
-
if (
|
|
232
|
+
if (isCi) {
|
|
166
233
|
this.options.stderr.write(data);
|
|
167
234
|
return;
|
|
168
235
|
}
|
|
@@ -170,6 +237,7 @@ class Ink {
|
|
|
170
237
|
this.options.stderr.write(data);
|
|
171
238
|
this.log(this.lastOutput);
|
|
172
239
|
}
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
173
241
|
unmount(error) {
|
|
174
242
|
if (this.isUnmounted) {
|
|
175
243
|
return;
|
|
@@ -184,15 +252,15 @@ class Ink {
|
|
|
184
252
|
}
|
|
185
253
|
// CIs don't handle erasing ansi escapes well, so it's better to
|
|
186
254
|
// only render last frame of non-static output
|
|
187
|
-
if (
|
|
255
|
+
if (isCi) {
|
|
188
256
|
this.options.stdout.write(this.lastOutput + '\n');
|
|
189
257
|
}
|
|
190
258
|
else if (!this.options.debug) {
|
|
191
259
|
this.log.done();
|
|
192
260
|
}
|
|
193
261
|
this.isUnmounted = true;
|
|
194
|
-
|
|
195
|
-
|
|
262
|
+
reconciler.updateContainer(null, this.container, null, noop);
|
|
263
|
+
instances.delete(this.options.stdout);
|
|
196
264
|
if (error instanceof Error) {
|
|
197
265
|
this.rejectExitPromise(error);
|
|
198
266
|
}
|
|
@@ -200,7 +268,7 @@ class Ink {
|
|
|
200
268
|
this.resolveExitPromise();
|
|
201
269
|
}
|
|
202
270
|
}
|
|
203
|
-
waitUntilExit() {
|
|
271
|
+
async waitUntilExit() {
|
|
204
272
|
if (!this.exitPromise) {
|
|
205
273
|
this.exitPromise = new Promise((resolve, reject) => {
|
|
206
274
|
this.resolveExitPromise = resolve;
|
|
@@ -210,7 +278,7 @@ class Ink {
|
|
|
210
278
|
return this.exitPromise;
|
|
211
279
|
}
|
|
212
280
|
clear() {
|
|
213
|
-
if (!
|
|
281
|
+
if (!isCi && !this.options.debug) {
|
|
214
282
|
this.log.clear();
|
|
215
283
|
}
|
|
216
284
|
}
|
|
@@ -218,7 +286,7 @@ class Ink {
|
|
|
218
286
|
if (this.options.debug) {
|
|
219
287
|
return;
|
|
220
288
|
}
|
|
221
|
-
this.restoreConsole =
|
|
289
|
+
this.restoreConsole = patchConsole((stream, data) => {
|
|
222
290
|
if (stream === 'stdout') {
|
|
223
291
|
this.writeToStdout(data);
|
|
224
292
|
}
|
|
@@ -231,5 +299,4 @@ class Ink {
|
|
|
231
299
|
});
|
|
232
300
|
}
|
|
233
301
|
}
|
|
234
|
-
exports.default = Ink;
|
|
235
302
|
//# sourceMappingURL=ink.js.map
|
package/build/ink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink.js","sourceRoot":"","sources":["../src/ink.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ink.js","sourceRoot":"","sources":["../src/ink.tsx"],"names":[],"mappings":"AAAA,OA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AO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAClD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC;gBAClC,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC;YACjC,CAAC,CAAC,CAAC;SACH;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACjC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;SACjB;IACF,CAAC;IAED,YAAY;QACX,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACvB,OAAO;SACP;QAED,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;YACnD,IAAI,MAAM,KAAK,QAAQ,EAAE;gBACxB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;aACzB;YAED,IAAI,MAAM,KAAK,QAAQ,EAAE;gBACxB,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;gBAEnE,IAAI,CAAC,cAAc,EAAE;oBACpB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;iBACzB;aACD;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
package/build/instances.d.ts
CHANGED
package/build/instances.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
// Store all instances of Ink (instance.js) to ensure that consecutive render() calls
|
|
4
2
|
// use the same instance of Ink and don't create a new one
|
|
5
3
|
//
|
|
6
4
|
// This map has to be stored in a separate file, because render.js creates instances,
|
|
7
5
|
// but instance.js should delete itself from the map on unmount
|
|
8
|
-
|
|
6
|
+
const instances = new WeakMap();
|
|
7
|
+
export default instances;
|
|
9
8
|
//# sourceMappingURL=instances.js.map
|
package/build/instances.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances.js","sourceRoot":"","sources":["../src/instances.ts"],"names":[],"mappings":"
|
|
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"}
|
package/build/log-update.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface LogUpdate {
|
|
1
|
+
import { type Writable } from 'node:stream';
|
|
2
|
+
export type LogUpdate = {
|
|
4
3
|
clear: () => void;
|
|
5
4
|
done: () => void;
|
|
6
5
|
(str: string): void;
|
|
7
|
-
}
|
|
8
|
-
declare const
|
|
6
|
+
};
|
|
7
|
+
declare const logUpdate: {
|
|
9
8
|
create: (stream: Writable, { showCursor }?: {
|
|
10
9
|
showCursor?: boolean | undefined;
|
|
11
10
|
}) => LogUpdate;
|
|
12
11
|
};
|
|
13
|
-
export default
|
|
12
|
+
export default logUpdate;
|
package/build/log-update.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ansi_escapes_1 = __importDefault(require("ansi-escapes"));
|
|
7
|
-
const cli_cursor_1 = __importDefault(require("cli-cursor"));
|
|
1
|
+
import ansiEscapes from 'ansi-escapes';
|
|
2
|
+
import cliCursor from 'cli-cursor';
|
|
8
3
|
const create = (stream, { showCursor = false } = {}) => {
|
|
9
4
|
let previousLineCount = 0;
|
|
10
5
|
let previousOutput = '';
|
|
11
6
|
let hasHiddenCursor = false;
|
|
12
7
|
const render = (str) => {
|
|
13
8
|
if (!showCursor && !hasHiddenCursor) {
|
|
14
|
-
|
|
9
|
+
cliCursor.hide();
|
|
15
10
|
hasHiddenCursor = true;
|
|
16
11
|
}
|
|
17
12
|
const output = str + '\n';
|
|
@@ -19,11 +14,11 @@ const create = (stream, { showCursor = false } = {}) => {
|
|
|
19
14
|
return;
|
|
20
15
|
}
|
|
21
16
|
previousOutput = output;
|
|
22
|
-
stream.write(
|
|
17
|
+
stream.write(ansiEscapes.eraseLines(previousLineCount) + output);
|
|
23
18
|
previousLineCount = output.split('\n').length;
|
|
24
19
|
};
|
|
25
20
|
render.clear = () => {
|
|
26
|
-
stream.write(
|
|
21
|
+
stream.write(ansiEscapes.eraseLines(previousLineCount));
|
|
27
22
|
previousOutput = '';
|
|
28
23
|
previousLineCount = 0;
|
|
29
24
|
};
|
|
@@ -31,11 +26,12 @@ const create = (stream, { showCursor = false } = {}) => {
|
|
|
31
26
|
previousOutput = '';
|
|
32
27
|
previousLineCount = 0;
|
|
33
28
|
if (!showCursor) {
|
|
34
|
-
|
|
29
|
+
cliCursor.show();
|
|
35
30
|
hasHiddenCursor = false;
|
|
36
31
|
}
|
|
37
32
|
};
|
|
38
33
|
return render;
|
|
39
34
|
};
|
|
40
|
-
|
|
35
|
+
const logUpdate = { create };
|
|
36
|
+
export default logUpdate;
|
|
41
37
|
//# sourceMappingURL=log-update.js.map
|
package/build/log-update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-update.js","sourceRoot":"","sources":["../src/log-update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log-update.js","sourceRoot":"","sources":["../src/log-update.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AAQnC,MAAM,MAAM,GAAG,CAAC,MAAgB,EAAE,EAAC,UAAU,GAAG,KAAK,EAAC,GAAG,EAAE,EAAa,EAAE;IACzE,IA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.js';
|
|
2
|
+
type Output = {
|
|
3
3
|
/**
|
|
4
4
|
* Element width.
|
|
5
5
|
*/
|
|
@@ -8,9 +8,9 @@ interface Output {
|
|
|
8
8
|
* Element height.
|
|
9
9
|
*/
|
|
10
10
|
height: number;
|
|
11
|
-
}
|
|
12
|
-
declare const _default: (node: DOMElement) => Output;
|
|
11
|
+
};
|
|
13
12
|
/**
|
|
14
13
|
* Measure the dimensions of a particular `<Box>` element.
|
|
15
14
|
*/
|
|
16
|
-
|
|
15
|
+
declare const measureElement: (node: DOMElement) => Output;
|
|
16
|
+
export default measureElement;
|
package/build/measure-element.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* Measure the dimensions of a particular `<Box>` element.
|
|
5
3
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
};
|
|
4
|
+
const measureElement = (node) => ({
|
|
5
|
+
width: node.yogaNode?.getComputedWidth() ?? 0,
|
|
6
|
+
height: node.yogaNode?.getComputedHeight() ?? 0
|
|
7
|
+
});
|
|
8
|
+
export default measureElement;
|
|
13
9
|
//# sourceMappingURL=measure-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure-element.js","sourceRoot":"","sources":["../src/measure-element.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"measure-element.js","sourceRoot":"","sources":["../src/measure-element.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,IAAgB,EAAU,EAAE,CAAC,CAAC;IACrD,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC;IAC7C,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;CAC/C,CAAC,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
package/build/measure-text.d.ts
CHANGED
package/build/measure-text.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const widest_line_1 = __importDefault(require("widest-line"));
|
|
1
|
+
import widestLine from 'widest-line';
|
|
7
2
|
const cache = {};
|
|
8
|
-
|
|
3
|
+
const measureText = (text) => {
|
|
9
4
|
if (text.length === 0) {
|
|
10
5
|
return {
|
|
11
6
|
width: 0,
|
|
12
7
|
height: 0
|
|
13
8
|
};
|
|
14
9
|
}
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const cachedDimensions = cache[text];
|
|
11
|
+
if (cachedDimensions) {
|
|
12
|
+
return cachedDimensions;
|
|
17
13
|
}
|
|
18
|
-
const width =
|
|
14
|
+
const width = widestLine(text);
|
|
19
15
|
const height = text.split('\n').length;
|
|
20
16
|
cache[text] = { width, height };
|
|
21
17
|
return { width, height };
|
|
22
18
|
};
|
|
19
|
+
export default measureText;
|
|
23
20
|
//# sourceMappingURL=measure-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure-text.js","sourceRoot":"","sources":["../src/measure-text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"measure-text.js","sourceRoot":"","sources":["../src/measure-text.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,MAAM,KAAK,GAA2B,EAAE,CAAC;AAOzC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE;IAC5C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO;YACN,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;SACT,CAAC;KACF;IAED,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAErC,IAAI,gBAAgB,EAAE;QACrB,OAAO,gBAAgB,CAAC;KACxB;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAC,KAAK,EAAE,MAAM,EAAC,CAAC;IAE9B,OAAO,EAAC,KAAK,EAAE,MAAM,EAAC,CAAC;AACxB,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/build/output.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OutputTransformer } from './render-node-to-output';
|
|
1
|
+
import { type OutputTransformer } from './render-node-to-output.js';
|
|
2
2
|
/**
|
|
3
3
|
* "Virtual" output class
|
|
4
4
|
*
|
|
@@ -7,10 +7,10 @@ import { OutputTransformer } from './render-node-to-output';
|
|
|
7
7
|
*
|
|
8
8
|
* Used to generate the final output of all nodes before writing it to actual output stream (e.g. stdout)
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
type Options = {
|
|
11
11
|
width: number;
|
|
12
12
|
height: number;
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
export default class Output {
|
|
15
15
|
width: number;
|
|
16
16
|
height: number;
|