@reliverse/relinka 1.1.7 → 1.1.8
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/dist-npm/components/anykey/index.js +57 -77
- package/dist-npm/components/block/block.js +48 -61
- package/dist-npm/components/checkbox/index.js +178 -211
- package/dist-npm/components/confirm/confirm-main.js +85 -122
- package/dist-npm/components/confirm/confirm-three.js +24 -27
- package/dist-npm/components/confirm/index.js +36 -45
- package/dist-npm/components/core/Separator.js +15 -17
- package/dist-npm/components/core/create-prompt.js +101 -124
- package/dist-npm/components/core/errors.js +19 -15
- package/dist-npm/components/core/hook-engine.js +91 -120
- package/dist-npm/components/core/index.js +12 -12
- package/dist-npm/components/core/key.js +16 -6
- package/dist-npm/components/core/lines.js +45 -54
- package/dist-npm/components/core/make-theme.js +21 -30
- package/dist-npm/components/core/position.js +27 -23
- package/dist-npm/components/core/promise-polyfill.js +11 -14
- package/dist-npm/components/core/screen-manager.js +59 -74
- package/dist-npm/components/core/theme.js +22 -32
- package/dist-npm/components/core/use-effect.js +9 -15
- package/dist-npm/components/core/use-keypress.js +19 -23
- package/dist-npm/components/core/use-memo.js +10 -16
- package/dist-npm/components/core/use-pagination.js +33 -32
- package/dist-npm/components/core/use-prefix.js +40 -38
- package/dist-npm/components/core/use-ref.js +2 -5
- package/dist-npm/components/core/use-state.js +15 -23
- package/dist-npm/components/core/useKeyPress.js +14 -17
- package/dist-npm/components/core/usePromptState.js +8 -14
- package/dist-npm/components/core/utils.js +7 -16
- package/dist-npm/components/date/date.js +173 -204
- package/dist-npm/components/editor/index.js +71 -92
- package/dist-npm/components/expand/index.js +96 -124
- package/dist-npm/components/figures/index.js +283 -294
- package/dist-npm/components/input/index.js +61 -87
- package/dist-npm/components/input/text-main.js +97 -124
- package/dist-npm/components/input/text.js +24 -28
- package/dist-npm/components/instance/basic.js +17 -25
- package/dist-npm/components/instance/browser.js +14 -18
- package/dist-npm/components/instance/reporter/basic.js +46 -65
- package/dist-npm/components/instance/reporter/browser.js +44 -47
- package/dist-npm/components/instance/reporter/fancy.js +83 -96
- package/dist-npm/components/instance/shared.js +2 -2
- package/dist-npm/components/mono/mono.js +52 -62
- package/dist-npm/components/mono/monoTwo.js +35 -49
- package/dist-npm/components/multiselect/group-multiselect.js +55 -71
- package/dist-npm/components/multiselect/multi-select-two.js +97 -130
- package/dist-npm/components/multiselect/multi-select.js +43 -49
- package/dist-npm/components/multiselect/multiselect-main.d.ts +1 -0
- package/dist-npm/components/multiselect/multiselect-main.js +158 -145
- package/dist-npm/components/multiselect/num-multi-select.js +97 -130
- package/dist-npm/components/multiselect/num-multiselect-main.js +24 -35
- package/dist-npm/components/next-steps/next-steps.js +23 -25
- package/dist-npm/components/number/index.js +78 -112
- package/dist-npm/components/number/number-main.js +95 -2
- package/dist-npm/components/password/index.js +54 -73
- package/dist-npm/components/password/password-main.js +119 -2
- package/dist-npm/components/password/password-three.js +26 -30
- package/dist-npm/components/progressbar/ProgressBar.js +45 -64
- package/dist-npm/components/progressbar/helper.js +33 -40
- package/dist-npm/components/progressbar/index.js +1 -1
- package/dist-npm/components/prompts/create.js +29 -44
- package/dist-npm/components/prompts/index.d.ts +1 -0
- package/dist-npm/components/prompts/index.js +46 -45
- package/dist-npm/components/prompts/prompt.js +211 -260
- package/dist-npm/components/prompts/promptTwo.js +561 -605
- package/dist-npm/components/prompts/relinka.js +237 -295
- package/dist-npm/components/range/range.js +247 -294
- package/dist-npm/components/rawlist/index.js +87 -107
- package/dist-npm/components/results/results.js +31 -37
- package/dist-npm/components/search/index.js +148 -193
- package/dist-npm/components/select/index.js +148 -186
- package/dist-npm/components/select/num-select-main.js +27 -27
- package/dist-npm/components/select/num-select.js +124 -5
- package/dist-npm/components/select/select-key.js +24 -25
- package/dist-npm/components/select/select-main.d.ts +1 -0
- package/dist-npm/components/select/select-main.js +143 -133
- package/dist-npm/components/select/select-three.js +32 -36
- package/dist-npm/components/select/select-two.js +94 -87
- package/dist-npm/components/spinner/index.js +107 -136
- package/dist-npm/components/st-end/end.js +34 -26
- package/dist-npm/components/st-end/start.js +29 -15
- package/dist-npm/components/toggle/index.js +113 -137
- package/dist-npm/components/visual/animate/animate.js +53 -10
- package/dist-npm/components/visual/ascii-art/ascii-art.js +12 -1
- package/dist-npm/main.js +1 -0
- package/dist-npm/testing/index.js +58 -83
- package/dist-npm/types/general.d.ts +1 -1
- package/dist-npm/types/general.js +0 -1
- package/dist-npm/types/index.js +2 -3
- package/dist-npm/types/keypress.js +35 -36
- package/dist-npm/types/readline.js +0 -1
- package/dist-npm/types/relinka.js +0 -1
- package/dist-npm/types/utils.js +0 -1
- package/dist-npm/utils/box.js +135 -137
- package/dist-npm/utils/color.js +65 -74
- package/dist-npm/utils/colorize.js +124 -156
- package/dist-npm/utils/component.js +532 -657
- package/dist-npm/utils/constants.js +64 -63
- package/dist-npm/utils/core.js +2 -3
- package/dist-npm/utils/decoder.js +244 -223
- package/dist-npm/utils/error.js +4 -9
- package/dist-npm/utils/errors.js +14 -4
- package/dist-npm/utils/format.js +19 -24
- package/dist-npm/utils/keypress.js +316 -414
- package/dist-npm/utils/log.js +11 -15
- package/dist-npm/utils/mapping.js +45 -52
- package/dist-npm/utils/messages.js +196 -183
- package/dist-npm/utils/platforms.js +16 -20
- package/dist-npm/utils/prompt-tmp.js +235 -286
- package/dist-npm/utils/prompt-two.js +235 -286
- package/dist-npm/utils/readline.js +5 -7
- package/dist-npm/utils/skeleton.js +130 -170
- package/dist-npm/utils/stream.js +2 -2
- package/dist-npm/utils/string.js +44 -58
- package/dist-npm/utils/terminal.js +23 -34
- package/dist-npm/utils/tree.js +30 -41
- package/dist-npm/utils/types.js +0 -1
- package/dist-npm/utils/utils.js +8 -8
- package/dist-npm/utils/variants.js +36 -44
- package/package.json +14 -14
- package/dist-npm/mod.js +0 -2
- /package/dist-npm/{mod.d.ts → main.d.ts} +0 -0
|
@@ -1,57 +1,49 @@
|
|
|
1
|
-
import {colorMap} from
|
|
2
|
-
|
|
3
|
-
const {isArray} = Array;
|
|
4
|
-
const maybeArray = (a) => isArray(a) ? a : [a];
|
|
5
|
-
|
|
1
|
+
import { colorMap } from "./mapping.js";
|
|
6
2
|
export const variantMap = {
|
|
7
|
-
|
|
3
|
+
|
|
4
|
+
doubleBox: createDoubleBox
|
|
5
|
+
|
|
6
|
+
|
|
8
7
|
};
|
|
9
|
-
export function applyVariant(lines, variant, options, borderColor) {
|
|
10
|
-
|
|
8
|
+
export async function applyVariant(lines, variant, options, borderColor) {
|
|
9
|
+
const linesArray = Array.isArray(lines) ? lines : [lines];
|
|
10
|
+
switch (variant) {
|
|
11
11
|
|
|
12
|
-
switch(variant) {
|
|
13
|
-
case 'doubleBox':
|
|
14
|
-
return createDoubleBox(linesArray, options?.limit, borderColor);
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function createDoubleBox(lines, limit, borderColor) {
|
|
22
|
-
const processedLines = processLines(lines, limit);
|
|
23
|
-
const maxLength = Math.max(...processedLines.map((line) => line.length));
|
|
24
|
-
const indentation = '';
|
|
13
|
+
case "doubleBox":
|
|
14
|
+
return createDoubleBox(linesArray, options?.limit, borderColor);
|
|
25
15
|
|
|
26
|
-
if (borderColor === void 0) {
|
|
27
|
-
borderColor = 'viceGradient';
|
|
28
|
-
}
|
|
29
16
|
|
|
30
|
-
const topBorder = borderColor ? colorMap[borderColor](`${'\u2550'.repeat(maxLength)}\u2557`) : `${'\u2550'.repeat(maxLength)}\u2557`;
|
|
31
|
-
const bottomBorder = borderColor ? colorMap[borderColor](`${indentation}\u255A${'\u2550'.repeat(maxLength + 2)}\u255D`) : `${indentation}\u255A${'\u2550'.repeat(maxLength + 2)}\u255D`;
|
|
32
17
|
|
|
33
|
-
const middle = processedLines
|
|
34
|
-
.map((line, index) => {
|
|
35
|
-
const lineIndentation = !index ? indentation : `${indentation} `;
|
|
36
|
-
return `${lineIndentation}${borderColor ? colorMap[borderColor]('\u2551') : '\u2551'} ${colorMap[borderColor](line.padEnd(maxLength))} ${borderColor ? colorMap[borderColor]('\u2551') : '\u2551'}`;
|
|
37
|
-
})
|
|
38
|
-
.join('\n');
|
|
39
18
|
|
|
40
|
-
|
|
19
|
+
default:
|
|
20
|
+
return linesArray.join("\n");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function createDoubleBox(lines, limit, borderColor) {
|
|
24
|
+
const processedLines = processLines(lines, limit);
|
|
25
|
+
const maxLength = Math.max(...processedLines.map((line) => line.length));
|
|
26
|
+
const indentation = "";
|
|
27
|
+
if (borderColor === void 0) {
|
|
28
|
+
borderColor = "viceGradient";
|
|
29
|
+
}
|
|
30
|
+
const topBorder = borderColor ? colorMap[borderColor](`${"\u2550".repeat(maxLength)}\u2557`) : `${"\u2550".repeat(maxLength)}\u2557`;
|
|
31
|
+
const bottomBorder = borderColor ? colorMap[borderColor](`${indentation}\u255A${"\u2550".repeat(maxLength + 2)}\u255D`) : `${indentation}\u255A${"\u2550".repeat(maxLength + 2)}\u255D`;
|
|
32
|
+
const middle = processedLines.map((line, index) => {
|
|
33
|
+
const lineIndentation = index === 0 ? indentation : indentation + " ";
|
|
34
|
+
return `${lineIndentation}${borderColor ? colorMap[borderColor]("\u2551") : "\u2551"} ${colorMap[borderColor](line.padEnd(maxLength))} ${borderColor ? colorMap[borderColor]("\u2551") : "\u2551"}`;
|
|
35
|
+
}).join("\n");
|
|
36
|
+
return `${topBorder}
|
|
41
37
|
${middle}
|
|
42
38
|
${bottomBorder}`;
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
function processLines(lines, limit) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return truncatedLine.padEnd(limit || truncatedLine.length);
|
|
56
|
-
});
|
|
41
|
+
const linesArray = Array.isArray(lines) ? lines : [lines];
|
|
42
|
+
return linesArray.map((line) => {
|
|
43
|
+
let truncatedLine = line;
|
|
44
|
+
if (limit && line.length > limit) {
|
|
45
|
+
truncatedLine = `${line.slice(0, limit - 3)}...`;
|
|
46
|
+
}
|
|
47
|
+
return truncatedLine.padEnd(limit || truncatedLine.length);
|
|
48
|
+
});
|
|
57
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reliverse/relinka",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "@reliverse/relinka is a powerful library that enables seamless, typesafe, and resilient prompts for command-line applications. Crafted with simplicity and elegance, it provides developers with an intuitive and robust way to build interactive CLIs.",
|
|
6
6
|
"scripts": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"build:jsr": "bun build.optim.ts --jsr",
|
|
11
11
|
"build:npm": "unbuild && bun build.optim.ts",
|
|
12
12
|
"build": "redrun build:jsr build:npm optimize",
|
|
13
|
-
"pub:jsr": "bunx jsr publish --allow-slow-types --allow-dirty",
|
|
14
|
-
"pub:
|
|
15
|
-
"pub:
|
|
16
|
-
"pub": "redrun
|
|
13
|
+
"pub:jsr": "bun build:jsr && bunx jsr publish --allow-slow-types --allow-dirty",
|
|
14
|
+
"pub:npm": "bun build:npm && bun publish",
|
|
15
|
+
"pub:dry": "bun pub:jsr --dry-run",
|
|
16
|
+
"pub": "redrun pub:jsr pub:npm",
|
|
17
17
|
"typecheck": "tsc --noEmit",
|
|
18
18
|
"lint": "eslint --cache --fix .",
|
|
19
19
|
"lint:i": "eslint --inspect-config",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"type": "git",
|
|
32
32
|
"url": "git+https://github.com/reliverse/relinka.git"
|
|
33
33
|
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
34
|
+
"types": "./dist-npm/main.d.ts",
|
|
35
|
+
"module": "./dist-npm/main.js",
|
|
36
|
+
"main": "./dist-npm/main.js",
|
|
37
37
|
"exports": {
|
|
38
|
-
"import": "./dist-npm/
|
|
39
|
-
"types": "./dist-npm/
|
|
38
|
+
"import": "./dist-npm/main.js",
|
|
39
|
+
"types": "./dist-npm/main.d.ts"
|
|
40
40
|
},
|
|
41
41
|
"bugs": {
|
|
42
42
|
"url": "https://github.com/reliverse/relinka/issues",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"license": "MIT",
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@figliolia/chalk-animation": "^1.0.4",
|
|
51
|
-
"@sinclair/typebox": "^0.34.
|
|
51
|
+
"@sinclair/typebox": "^0.34.9",
|
|
52
52
|
"ansi-diff-stream": "^1.2.1",
|
|
53
53
|
"ansi-escapes": "^7.0.0",
|
|
54
54
|
"chalk": "^5.3.0",
|
|
@@ -90,13 +90,13 @@
|
|
|
90
90
|
"@cspell/dict-npm": "^5.1.13",
|
|
91
91
|
"@eslint/js": "^9.15.0",
|
|
92
92
|
"@types/ansi-diff-stream": "^1.2.3",
|
|
93
|
-
"@types/bun": "^1.1.
|
|
93
|
+
"@types/bun": "^1.1.14",
|
|
94
94
|
"@types/chalk-animation": "^1.6.3",
|
|
95
95
|
"@types/eslint__js": "^8.42.3",
|
|
96
96
|
"@types/figlet": "^1.7.0",
|
|
97
97
|
"@types/fs-extra": "^11.0.4",
|
|
98
98
|
"@types/mute-stream": "^0.0.4",
|
|
99
|
-
"@types/node": "^22.
|
|
99
|
+
"@types/node": "^22.10.0",
|
|
100
100
|
"@types/sentencer": "^0.2.3",
|
|
101
101
|
"@types/signal-exit": "^3.0.4",
|
|
102
102
|
"@types/strip-comments": "^2.0.4",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"eslint": "^9.15.0",
|
|
106
106
|
"eslint-plugin-perfectionist": "^4.1.2",
|
|
107
107
|
"jiti": "^2.4.0",
|
|
108
|
-
"knip": "^5.
|
|
108
|
+
"knip": "^5.38.0",
|
|
109
109
|
"mock-stdin": "^1.0.0",
|
|
110
110
|
"printj": "^1.3.1",
|
|
111
111
|
"putout": "^36.13.1",
|
package/dist-npm/mod.js
DELETED
|
File without changes
|