ink 5.0.0 → 5.0.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.
- package/build/apply-styles.js +175 -0
- package/build/build-layout.js +77 -0
- package/build/calculate-wrapped-text.js +53 -0
- package/build/components/App.js +2 -2
- package/build/components/App.js.map +1 -1
- package/build/components/Color.js +62 -0
- package/build/devtools-window-polyfill.js +3 -9
- package/build/devtools-window-polyfill.js.map +1 -1
- package/build/experimental/apply-style.js +140 -0
- package/build/experimental/dom.js +123 -0
- package/build/experimental/output.js +91 -0
- package/build/experimental/reconciler.js +141 -0
- package/build/experimental/renderer.js +81 -0
- package/build/hooks/useInput.js +38 -0
- package/build/ink.js +4 -6
- package/build/ink.js.map +1 -1
- package/build/instance.js +205 -0
- package/build/reconciler.js +1 -1
- package/build/reconciler.js.map +1 -1
- package/package.json +7 -7
- package/readme.md +3 -1
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash.throttle"));
|
|
11
|
+
|
|
12
|
+
var _autoBind = _interopRequireDefault(require("auto-bind"));
|
|
13
|
+
|
|
14
|
+
var _logUpdate = _interopRequireDefault(require("log-update"));
|
|
15
|
+
|
|
16
|
+
var _isCi = _interopRequireDefault(require("is-ci"));
|
|
17
|
+
|
|
18
|
+
var _signalExit = _interopRequireDefault(require("signal-exit"));
|
|
19
|
+
|
|
20
|
+
var _ansiEscapes = _interopRequireDefault(require("ansi-escapes"));
|
|
21
|
+
|
|
22
|
+
var _reconciler = _interopRequireDefault(require("./reconciler"));
|
|
23
|
+
|
|
24
|
+
var _reconciler2 = _interopRequireDefault(require("./experimental/reconciler"));
|
|
25
|
+
|
|
26
|
+
var _renderer = _interopRequireDefault(require("./renderer"));
|
|
27
|
+
|
|
28
|
+
var _renderer2 = _interopRequireDefault(require("./experimental/renderer"));
|
|
29
|
+
|
|
30
|
+
var dom = _interopRequireWildcard(require("./dom"));
|
|
31
|
+
|
|
32
|
+
var experimentalDom = _interopRequireWildcard(require("./experimental/dom"));
|
|
33
|
+
|
|
34
|
+
var _instances = _interopRequireDefault(require("./instances"));
|
|
35
|
+
|
|
36
|
+
var _App = _interopRequireDefault(require("./components/App"));
|
|
37
|
+
|
|
38
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
39
|
+
|
|
40
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
|
+
|
|
42
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
|
+
|
|
44
|
+
class Instance {
|
|
45
|
+
constructor(options) {
|
|
46
|
+
(0, _autoBind.default)(this);
|
|
47
|
+
this.options = options;
|
|
48
|
+
|
|
49
|
+
if (options.experimental) {
|
|
50
|
+
this.rootNode = experimentalDom.createNode('root');
|
|
51
|
+
this.rootNode.onRender = options.debug ? this.onRender : (0, _lodash.default)(this.onRender, 16, {
|
|
52
|
+
leading: true,
|
|
53
|
+
trailing: true
|
|
54
|
+
});
|
|
55
|
+
this.rootNode.onImmediateRender = this.onRender;
|
|
56
|
+
this.renderer = (0, _renderer2.default)({
|
|
57
|
+
terminalWidth: options.stdout.columns
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
this.rootNode = dom.createNode('root');
|
|
61
|
+
this.rootNode.onRender = this.onRender;
|
|
62
|
+
this.renderer = (0, _renderer.default)({
|
|
63
|
+
terminalWidth: options.stdout.columns
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.log = _logUpdate.default.create(options.stdout);
|
|
68
|
+
this.throttledLog = options.debug ? this.log : (0, _lodash.default)(this.log, {
|
|
69
|
+
leading: true,
|
|
70
|
+
trailing: true
|
|
71
|
+
}); // Ignore last render after unmounting a tree to prevent empty output before exit
|
|
72
|
+
|
|
73
|
+
this.isUnmounted = false; // Store last output to only rerender when needed
|
|
74
|
+
|
|
75
|
+
this.lastOutput = ''; // This variable is used only in debug mode to store full static output
|
|
76
|
+
// so that it's rerendered every time, not just new static parts, like in non-debug mode
|
|
77
|
+
|
|
78
|
+
this.fullStaticOutput = '';
|
|
79
|
+
|
|
80
|
+
if (options.experimental) {
|
|
81
|
+
this.container = _reconciler2.default.createContainer(this.rootNode, false, false);
|
|
82
|
+
} else {
|
|
83
|
+
this.container = _reconciler.default.createContainer(this.rootNode, false, false);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.exitPromise = new Promise((resolve, reject) => {
|
|
87
|
+
this.resolveExitPromise = resolve;
|
|
88
|
+
this.rejectExitPromise = reject;
|
|
89
|
+
}); // Unmount when process exits
|
|
90
|
+
|
|
91
|
+
this.unsubscribeExit = (0, _signalExit.default)(this.unmount, {
|
|
92
|
+
alwaysLast: false
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onRender() {
|
|
97
|
+
if (this.isUnmounted) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
output,
|
|
103
|
+
outputHeight,
|
|
104
|
+
staticOutput
|
|
105
|
+
} = this.renderer(this.rootNode); // If <Static> output isn't empty, it means new children have been added to it
|
|
106
|
+
|
|
107
|
+
const hasStaticOutput = staticOutput && staticOutput !== '\n';
|
|
108
|
+
|
|
109
|
+
if (this.options.debug) {
|
|
110
|
+
if (hasStaticOutput) {
|
|
111
|
+
this.fullStaticOutput += staticOutput;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this.options.stdout.write(this.fullStaticOutput + output);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (_isCi.default) {
|
|
119
|
+
if (hasStaticOutput) {
|
|
120
|
+
this.options.stdout.write(staticOutput);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.lastOutput = output;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (hasStaticOutput) {
|
|
128
|
+
this.fullStaticOutput += staticOutput;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (this.options.experimental && outputHeight >= this.options.stdout.rows) {
|
|
132
|
+
this.options.stdout.write(_ansiEscapes.default.clearTerminal + this.fullStaticOutput + output);
|
|
133
|
+
this.lastOutput = output;
|
|
134
|
+
return;
|
|
135
|
+
} // To ensure static output is cleanly rendered before main output, clear main output first
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if (hasStaticOutput) {
|
|
139
|
+
this.log.clear();
|
|
140
|
+
this.options.stdout.write(staticOutput);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (output !== this.lastOutput) {
|
|
144
|
+
if (this.options.experimental) {
|
|
145
|
+
this.throttledLog(output);
|
|
146
|
+
} else {
|
|
147
|
+
this.log(output);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
render(node) {
|
|
153
|
+
const tree = _react.default.createElement(_App.default, {
|
|
154
|
+
stdin: this.options.stdin,
|
|
155
|
+
stdout: this.options.stdout,
|
|
156
|
+
exitOnCtrlC: this.options.exitOnCtrlC,
|
|
157
|
+
onExit: this.unmount
|
|
158
|
+
}, node);
|
|
159
|
+
|
|
160
|
+
if (this.options.experimental) {
|
|
161
|
+
_reconciler2.default.updateContainer(tree, this.container);
|
|
162
|
+
} else {
|
|
163
|
+
_reconciler.default.updateContainer(tree, this.container);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
unmount(error) {
|
|
168
|
+
if (this.isUnmounted) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this.onRender();
|
|
173
|
+
this.unsubscribeExit(); // CIs don't handle erasing ansi escapes well, so it's better to
|
|
174
|
+
// only render last frame of non-static output
|
|
175
|
+
|
|
176
|
+
if (_isCi.default) {
|
|
177
|
+
this.options.stdout.write(this.lastOutput + '\n');
|
|
178
|
+
} else if (!this.options.debug) {
|
|
179
|
+
this.log.done();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
this.isUnmounted = true;
|
|
183
|
+
|
|
184
|
+
if (this.options.experimental) {
|
|
185
|
+
_reconciler2.default.updateContainer(null, this.container);
|
|
186
|
+
} else {
|
|
187
|
+
_reconciler.default.updateContainer(null, this.container);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
_instances.default.delete(this.options.stdout);
|
|
191
|
+
|
|
192
|
+
if (error instanceof Error) {
|
|
193
|
+
this.rejectExitPromise(error);
|
|
194
|
+
} else {
|
|
195
|
+
this.resolveExitPromise();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
waitUntilExit() {
|
|
200
|
+
return this.exitPromise;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
exports.default = Instance;
|
package/build/reconciler.js
CHANGED
|
@@ -38,7 +38,7 @@ const diff = (before, after) => {
|
|
|
38
38
|
const changed = {};
|
|
39
39
|
let isChanged = false;
|
|
40
40
|
for (const key of Object.keys(before)) {
|
|
41
|
-
const isDeleted = after ? !Object.
|
|
41
|
+
const isDeleted = after ? !Object.hasOwn(after, key) : true;
|
|
42
42
|
if (isDeleted) {
|
|
43
43
|
changed[key] = undefined;
|
|
44
44
|
isChanged = true;
|
package/build/reconciler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconciler.js","sourceRoot":"","sources":["../src/reconciler.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AACnE,OAAO,IAA6B,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EACN,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,YAAY,GAKZ,MAAM,UAAU,CAAC;AAClB,OAAO,WAA0B,MAAM,aAAa,CAAC;AAGrD,gEAAgE;AAChE,gDAAgD;AAChD,qDAAqD;AACrD,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC;IACnC,IAAI,CAAC;QACJ,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACrB,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;YAC3C,OAAO,CAAC,IAAI,CACX;;;;;;;KAOC,CAAC,IAAI,EAAE,GAAG,IAAI,CACf,CAAC;QACH,CAAC;aAAM,CAAC;YACP,+DAA+D;YAC/D,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;AACF,CAAC;AAID,MAAM,IAAI,GAAG,CAAC,MAAiB,EAAE,KAAgB,EAAyB,EAAE;IAC3E,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;QACtB,OAAO;IACR,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;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AAC;YAC5B,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;IACD,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO;QACvC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,WAAW,CAAC,IAAI,EAAE,UAAU;QAC3B,eAAe,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAClC,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;CACD,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ink",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "React for CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "vadimdemedes/ink",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@alcalzone/ansi-tokenize": "^0.1.3",
|
|
47
|
-
"ansi-escapes": "^
|
|
47
|
+
"ansi-escapes": "^7.0.0",
|
|
48
48
|
"ansi-styles": "^6.2.1",
|
|
49
49
|
"auto-bind": "^5.0.1",
|
|
50
50
|
"chalk": "^5.3.0",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
"@types/node": "^20.10.4",
|
|
78
78
|
"@types/react": "^18.2.43",
|
|
79
79
|
"@types/react-reconciler": "^0.28.2",
|
|
80
|
-
"@types/scheduler": "^0.
|
|
80
|
+
"@types/scheduler": "^0.23.0",
|
|
81
81
|
"@types/signal-exit": "^3.0.0",
|
|
82
|
-
"@types/sinon": "^
|
|
82
|
+
"@types/sinon": "^17.0.3",
|
|
83
83
|
"@types/stack-utils": "^2.0.2",
|
|
84
84
|
"@types/ws": "^8.5.10",
|
|
85
85
|
"@vdemedes/prettier-config": "^2.0.1",
|
|
@@ -88,18 +88,18 @@
|
|
|
88
88
|
"delay": "^6.0.0",
|
|
89
89
|
"eslint-config-xo-react": "0.27.0",
|
|
90
90
|
"eslint-plugin-react": "^7.33.2",
|
|
91
|
-
"eslint-plugin-react-hooks": "4.6.
|
|
91
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
92
92
|
"ms": "^2.1.3",
|
|
93
93
|
"node-pty": "^1.0.0",
|
|
94
94
|
"p-queue": "^8.0.0",
|
|
95
95
|
"prettier": "^3.1.1",
|
|
96
96
|
"react": "^18.0.0",
|
|
97
97
|
"react-devtools-core": "^5.0.0",
|
|
98
|
-
"sinon": "^
|
|
98
|
+
"sinon": "^18.0.0",
|
|
99
99
|
"strip-ansi": "^7.1.0",
|
|
100
100
|
"ts-node": "^10.9.2",
|
|
101
101
|
"typescript": "^5.3.3",
|
|
102
|
-
"xo": "^0.
|
|
102
|
+
"xo": "^0.58.0"
|
|
103
103
|
},
|
|
104
104
|
"peerDependencies": {
|
|
105
105
|
"@types/react": ">=18.0.0",
|
package/readme.md
CHANGED
|
@@ -97,6 +97,7 @@ Feel free to play around with the code and fork this repl at [https://repl.it/@v
|
|
|
97
97
|
- [Splash](https://github.com/Shopify/polaris-react/tree/master/scripts/splash) - Observe the splash zone of a change across the Shopify's [Polaris](https://polaris.shopify.com) component library.
|
|
98
98
|
- [emoj](https://github.com/sindresorhus/emoj) - Find relevant emojis.
|
|
99
99
|
- [emma](https://github.com/maticzav/emma-cli) - Find and install npm packages.
|
|
100
|
+
- [npm-check-extras](https://github.com/akgondber/npm-check-extras) - Check for outdated and unused dependencies, and run update/delete action over selected ones.
|
|
100
101
|
- [swiff](https://github.com/simple-integrated-marketing/swiff) - Multi-environment command line tools for time-saving web developers.
|
|
101
102
|
- [share](https://github.com/marionebl/share-cli) - Quickly share files.
|
|
102
103
|
- [Kubelive](https://github.com/ameerthehacker/kubelive) - CLI for Kubernetes to provide live data about the cluster and its resources.
|
|
@@ -116,6 +117,7 @@ Feel free to play around with the code and fork this repl at [https://repl.it/@v
|
|
|
116
117
|
- [Shopify CLI](https://github.com/Shopify/cli) - Build apps, themes, and storefronts for Shopify.
|
|
117
118
|
- [ToDesktop CLI](https://www.todesktop.com/electron) - An all-in-one platform for building Electron apps.
|
|
118
119
|
- [Walle](https://github.com/Pobepto/walle) - Full-featured crypto wallet for EVM networks.
|
|
120
|
+
- [Sudoku](https://github.com/mrozio13pl/sudoku-in-terminal) - Sudoku game.
|
|
119
121
|
|
|
120
122
|
## Contents
|
|
121
123
|
|
|
@@ -1844,7 +1846,7 @@ const Example = () => {
|
|
|
1844
1846
|
|
|
1845
1847
|
Switch focus to the next focusable component.
|
|
1846
1848
|
If there's no active component right now, focus will be given to the first focusable component.
|
|
1847
|
-
If active component is the last in the list of focusable components, focus will be switched to the first component.
|
|
1849
|
+
If active component is the last in the list of focusable components, focus will be switched to the first active component.
|
|
1848
1850
|
|
|
1849
1851
|
**Note:** Ink calls this method when user presses <kbd>Tab</kbd>.
|
|
1850
1852
|
|