@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.
- package/build/colorize.d.ts +3 -0
- package/build/colorize.js +48 -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 +59 -0
- package/build/components/App.js +286 -0
- package/build/components/App.js.map +1 -0
- package/build/components/AppContext.d.ts +11 -0
- package/build/components/AppContext.js +11 -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 +117 -0
- package/build/components/Box.js +34 -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 +17 -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 +28 -0
- package/build/components/Static.js.map +1 -0
- package/build/components/StderrContext.d.ts +15 -0
- package/build/components/StderrContext.js +13 -0
- package/build/components/StderrContext.js.map +1 -0
- package/build/components/StdinContext.d.ts +22 -0
- package/build/components/StdinContext.js +19 -0
- package/build/components/StdinContext.js.map +1 -0
- package/build/components/StdoutContext.d.ts +15 -0
- package/build/components/StdoutContext.js +13 -0
- package/build/components/StdoutContext.js.map +1 -0
- package/build/components/Text.d.ts +55 -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/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 +11 -0
- package/build/devtools.js.map +1 -0
- package/build/dom.d.ts +56 -0
- package/build/dom.js +123 -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 +93 -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 +28 -0
- package/build/index.js +17 -0
- package/build/index.js.map +1 -0
- package/build/ink.d.ts +54 -0
- package/build/ink.js +309 -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/log-to-file.d.ts +49 -0
- package/build/log-to-file.js +83 -0
- package/build/log-to-file.js.map +1 -0
- package/build/log-update.d.ts +14 -0
- package/build/log-update.js +116 -0
- package/build/log-update.js.map +1 -0
- package/build/measure-element.d.ts +16 -0
- package/build/measure-element.js +9 -0
- package/build/measure-element.js.map +1 -0
- package/build/measure-text.d.ts +6 -0
- package/build/measure-text.js +21 -0
- package/build/measure-text.js.map +1 -0
- package/build/output.d.ts +34 -0
- package/build/output.js +150 -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 +254 -0
- package/build/reconciler.js.map +1 -0
- package/build/render-background.d.ts +4 -0
- package/build/render-background.js +25 -0
- package/build/render-background.js.map +1 -0
- package/build/render-border.d.ts +4 -0
- package/build/render-border.js +73 -0
- package/build/render-border.js.map +1 -0
- package/build/render-node-to-output.d.ts +14 -0
- package/build/render-node-to-output.js +147 -0
- package/build/render-node-to-output.js.map +1 -0
- package/build/render.d.ts +88 -0
- package/build/render.js +50 -0
- package/build/render.js.map +1 -0
- package/build/renderer.d.ts +8 -0
- package/build/renderer.js +55 -0
- package/build/renderer.js.map +1 -0
- package/build/squash-text-nodes.d.ts +3 -0
- package/build/squash-text-nodes.js +35 -0
- package/build/squash-text-nodes.js.map +1 -0
- package/build/styles.d.ts +240 -0
- package/build/styles.js +232 -0
- package/build/styles.js.map +1 -0
- package/build/wrap-text.d.ts +3 -0
- package/build/wrap-text.js +31 -0
- package/build/wrap-text.js.map +1 -0
- package/license +10 -0
- package/package.json +195 -0
- package/readme.md +2356 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import wrapAnsi from 'wrap-ansi';
|
|
2
|
+
import cliTruncate from 'cli-truncate';
|
|
3
|
+
const cache = {};
|
|
4
|
+
const wrapText = (text, maxWidth, wrapType) => {
|
|
5
|
+
const cacheKey = text + String(maxWidth) + String(wrapType);
|
|
6
|
+
const cachedText = cache[cacheKey];
|
|
7
|
+
if (cachedText) {
|
|
8
|
+
return cachedText;
|
|
9
|
+
}
|
|
10
|
+
let wrappedText = text;
|
|
11
|
+
if (wrapType === 'wrap') {
|
|
12
|
+
wrappedText = wrapAnsi(text, maxWidth, {
|
|
13
|
+
trim: false,
|
|
14
|
+
hard: true,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (wrapType.startsWith('truncate')) {
|
|
18
|
+
let position = 'end';
|
|
19
|
+
if (wrapType === 'truncate-middle') {
|
|
20
|
+
position = 'middle';
|
|
21
|
+
}
|
|
22
|
+
if (wrapType === 'truncate-start') {
|
|
23
|
+
position = 'start';
|
|
24
|
+
}
|
|
25
|
+
wrappedText = cliTruncate(text, maxWidth, { position });
|
|
26
|
+
}
|
|
27
|
+
cache[cacheKey] = wrappedText;
|
|
28
|
+
return wrappedText;
|
|
29
|
+
};
|
|
30
|
+
export default wrapText;
|
|
31
|
+
//# sourceMappingURL=wrap-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap-text.js","sourceRoot":"","sources":["../src/wrap-text.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,WAAW,MAAM,cAAc,CAAC;AAGvC,MAAM,KAAK,GAA2B,EAAE,CAAC;AAEzC,MAAM,QAAQ,GAAG,CAChB,IAAY,EACZ,QAAgB,EAChB,QAA4B,EACnB,EAAE;IACX,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnC,IAAI,UAAU,EAAE,CAAC;QAChB,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,IAAI,WAAW,GAAG,IAAI,CAAC;IAEvB,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACzB,WAAW,GAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE;YACtC,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,IAAI;SACV,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,QAAS,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,IAAI,QAAQ,GAA+B,KAAK,CAAC;QAEjD,IAAI,QAAQ,KAAK,iBAAiB,EAAE,CAAC;YACpC,QAAQ,GAAG,QAAQ,CAAC;QACrB,CAAC;QAED,IAAI,QAAQ,KAAK,gBAAgB,EAAE,CAAC;YACnC,QAAQ,GAAG,OAAO,CAAC;QACpB,CAAC;QAED,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAC,QAAQ,EAAC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC;IAE9B,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/license
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Vadym Demedes <vadimdemedes@hey.com> (https://github.com/vadimdemedes)
|
|
4
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nuvin/ink",
|
|
3
|
+
"version": "6.5.1",
|
|
4
|
+
"description": "React for CLI",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "nuvin/ink",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Vadim Demedes",
|
|
9
|
+
"email": "vadimdemedes@hey.com",
|
|
10
|
+
"url": "https://github.com/vadimdemedes"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
"types": "./build/index.d.ts",
|
|
15
|
+
"default": "./build/index.js"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "tsc --watch",
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"prepare": "npm run build",
|
|
24
|
+
"test": "tsc --noEmit && xo && FORCE_COLOR=true ava",
|
|
25
|
+
"example": "NODE_NO_WARNINGS=1 node --loader ts-node/esm",
|
|
26
|
+
"benchmark": "NODE_NO_WARNINGS=1 node --loader ts-node/esm"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"build"
|
|
30
|
+
],
|
|
31
|
+
"keywords": [
|
|
32
|
+
"react",
|
|
33
|
+
"cli",
|
|
34
|
+
"jsx",
|
|
35
|
+
"stdout",
|
|
36
|
+
"components",
|
|
37
|
+
"command-line",
|
|
38
|
+
"preact",
|
|
39
|
+
"redux",
|
|
40
|
+
"print",
|
|
41
|
+
"render",
|
|
42
|
+
"colors",
|
|
43
|
+
"text"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@alcalzone/ansi-tokenize": "^0.2.1",
|
|
47
|
+
"ansi-escapes": "^7.2.0",
|
|
48
|
+
"ansi-styles": "^6.2.1",
|
|
49
|
+
"auto-bind": "^5.0.1",
|
|
50
|
+
"chalk": "^5.6.0",
|
|
51
|
+
"cli-boxes": "^3.0.0",
|
|
52
|
+
"cli-cursor": "^4.0.0",
|
|
53
|
+
"cli-truncate": "^5.1.1",
|
|
54
|
+
"code-excerpt": "^4.0.0",
|
|
55
|
+
"es-toolkit": "^1.39.10",
|
|
56
|
+
"indent-string": "^5.0.0",
|
|
57
|
+
"is-in-ci": "^2.0.0",
|
|
58
|
+
"patch-console": "^2.0.0",
|
|
59
|
+
"react-reconciler": "^0.33.0",
|
|
60
|
+
"signal-exit": "^3.0.7",
|
|
61
|
+
"slice-ansi": "^7.1.0",
|
|
62
|
+
"stack-utils": "^2.0.6",
|
|
63
|
+
"string-width": "^8.1.0",
|
|
64
|
+
"type-fest": "^4.27.0",
|
|
65
|
+
"widest-line": "^5.0.0",
|
|
66
|
+
"wrap-ansi": "^9.0.0",
|
|
67
|
+
"ws": "^8.18.0",
|
|
68
|
+
"yoga-layout": "~3.2.1"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@faker-js/faker": "^9.8.0",
|
|
72
|
+
"@sindresorhus/tsconfig": "^7.0.0",
|
|
73
|
+
"@sinonjs/fake-timers": "^14.0.0",
|
|
74
|
+
"@types/ms": "^2.1.0",
|
|
75
|
+
"@types/node": "^24.10.0",
|
|
76
|
+
"@types/react": "^19.1.5",
|
|
77
|
+
"@types/react-reconciler": "^0.32.2",
|
|
78
|
+
"@types/signal-exit": "^3.0.0",
|
|
79
|
+
"@types/sinon": "^17.0.3",
|
|
80
|
+
"@types/stack-utils": "^2.0.2",
|
|
81
|
+
"@types/ws": "^8.18.1",
|
|
82
|
+
"@vdemedes/prettier-config": "^2.0.1",
|
|
83
|
+
"ava": "^5.1.1",
|
|
84
|
+
"boxen": "^8.0.1",
|
|
85
|
+
"delay": "^7.0.0",
|
|
86
|
+
"eslint-config-xo-react": "0.27.0",
|
|
87
|
+
"eslint-plugin-react": "^7.37.5",
|
|
88
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
89
|
+
"ms": "^2.1.3",
|
|
90
|
+
"node-pty": "^1.0.0",
|
|
91
|
+
"p-queue": "^9.0.0",
|
|
92
|
+
"prettier": "^3.3.3",
|
|
93
|
+
"react": "^19.1.0",
|
|
94
|
+
"react-devtools-core": "^7.0.1",
|
|
95
|
+
"sinon": "^21.0.0",
|
|
96
|
+
"strip-ansi": "^7.1.0",
|
|
97
|
+
"ts-node": "^10.9.2",
|
|
98
|
+
"typescript": "^5.8.3",
|
|
99
|
+
"xo": "^0.59.3"
|
|
100
|
+
},
|
|
101
|
+
"peerDependencies": {
|
|
102
|
+
"@types/react": ">=19.0.0",
|
|
103
|
+
"react": ">=19.0.0",
|
|
104
|
+
"react-devtools-core": "^6.1.2"
|
|
105
|
+
},
|
|
106
|
+
"peerDependenciesMeta": {
|
|
107
|
+
"@types/react": {
|
|
108
|
+
"optional": true
|
|
109
|
+
},
|
|
110
|
+
"react-devtools-core": {
|
|
111
|
+
"optional": true
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"ava": {
|
|
115
|
+
"workerThreads": false,
|
|
116
|
+
"serial": true,
|
|
117
|
+
"files": [
|
|
118
|
+
"test/**/*",
|
|
119
|
+
"!test/helpers/**/*",
|
|
120
|
+
"!test/fixtures/**/*"
|
|
121
|
+
],
|
|
122
|
+
"extensions": {
|
|
123
|
+
"ts": "module",
|
|
124
|
+
"tsx": "module"
|
|
125
|
+
},
|
|
126
|
+
"nodeArguments": [
|
|
127
|
+
"--loader=ts-node/esm"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"xo": {
|
|
131
|
+
"extends": [
|
|
132
|
+
"xo-react"
|
|
133
|
+
],
|
|
134
|
+
"plugins": [
|
|
135
|
+
"react"
|
|
136
|
+
],
|
|
137
|
+
"prettier": true,
|
|
138
|
+
"rules": {
|
|
139
|
+
"react/no-unescaped-entities": "off",
|
|
140
|
+
"react/state-in-constructor": "off",
|
|
141
|
+
"react/jsx-indent": "off",
|
|
142
|
+
"react/prop-types": "off",
|
|
143
|
+
"unicorn/import-index": "off",
|
|
144
|
+
"import/no-useless-path-segments": "off",
|
|
145
|
+
"react-hooks/exhaustive-deps": "off",
|
|
146
|
+
"complexity": "off"
|
|
147
|
+
},
|
|
148
|
+
"ignores": [
|
|
149
|
+
"src/parse-keypress.ts"
|
|
150
|
+
],
|
|
151
|
+
"overrides": [
|
|
152
|
+
{
|
|
153
|
+
"files": [
|
|
154
|
+
"src/**/*.{ts,tsx}",
|
|
155
|
+
"test/**/*.{ts,tsx}"
|
|
156
|
+
],
|
|
157
|
+
"rules": {
|
|
158
|
+
"no-unused-expressions": "off",
|
|
159
|
+
"camelcase": [
|
|
160
|
+
"error",
|
|
161
|
+
{
|
|
162
|
+
"allow": [
|
|
163
|
+
"^unstable__",
|
|
164
|
+
"^internal_"
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
"unicorn/filename-case": "off",
|
|
169
|
+
"react/default-props-match-prop-types": "off",
|
|
170
|
+
"unicorn/prevent-abbreviations": "off",
|
|
171
|
+
"react/require-default-props": "off",
|
|
172
|
+
"react/jsx-curly-brace-presence": "off",
|
|
173
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
174
|
+
"@typescript-eslint/promise-function-async": "warn",
|
|
175
|
+
"@typescript-eslint/explicit-function-return": "off",
|
|
176
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
177
|
+
"dot-notation": "off",
|
|
178
|
+
"react/boolean-prop-naming": "off",
|
|
179
|
+
"unicorn/prefer-dom-node-remove": "off",
|
|
180
|
+
"unicorn/prefer-event-target": "off"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"files": [
|
|
185
|
+
"examples/**/*.{ts,tsx}",
|
|
186
|
+
"benchmark/**/*.{ts,tsx}"
|
|
187
|
+
],
|
|
188
|
+
"rules": {
|
|
189
|
+
"import/no-unassigned-import": "off"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
"prettier": "@vdemedes/prettier-config"
|
|
195
|
+
}
|