@reliverse/relinka 1.1.4 → 1.1.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/dist-npm/components/anykey/index.js +77 -57
- package/dist-npm/components/block/block.js +61 -48
- package/dist-npm/components/checkbox/index.js +211 -178
- package/dist-npm/components/confirm/confirm-main.js +122 -86
- package/dist-npm/components/confirm/confirm-three.js +27 -24
- package/dist-npm/components/confirm/index.js +45 -36
- package/dist-npm/components/core/Separator.js +17 -15
- package/dist-npm/components/core/create-prompt.js +124 -101
- package/dist-npm/components/core/errors.js +15 -19
- package/dist-npm/components/core/hook-engine.js +120 -91
- package/dist-npm/components/core/index.js +12 -12
- package/dist-npm/components/core/key.js +6 -16
- package/dist-npm/components/core/lines.js +54 -45
- package/dist-npm/components/core/make-theme.js +30 -21
- package/dist-npm/components/core/position.js +23 -27
- package/dist-npm/components/core/promise-polyfill.js +14 -11
- package/dist-npm/components/core/screen-manager.js +74 -59
- package/dist-npm/components/core/theme.js +32 -22
- package/dist-npm/components/core/use-effect.js +15 -9
- package/dist-npm/components/core/use-keypress.js +23 -19
- package/dist-npm/components/core/use-memo.js +16 -10
- package/dist-npm/components/core/use-pagination.js +32 -33
- package/dist-npm/components/core/use-prefix.js +38 -40
- package/dist-npm/components/core/use-ref.js +5 -2
- package/dist-npm/components/core/use-state.js +23 -15
- package/dist-npm/components/core/useKeyPress.js +17 -14
- package/dist-npm/components/core/usePromptState.js +14 -8
- package/dist-npm/components/core/utils.js +16 -7
- package/dist-npm/components/date/date.js +204 -168
- package/dist-npm/components/editor/index.js +92 -71
- package/dist-npm/components/expand/index.js +124 -96
- package/dist-npm/components/figures/index.js +294 -283
- package/dist-npm/components/input/index.js +87 -61
- package/dist-npm/components/input/text-main.js +124 -86
- package/dist-npm/components/input/text.js +28 -24
- package/dist-npm/components/instance/basic.js +25 -17
- package/dist-npm/components/instance/browser.js +18 -14
- package/dist-npm/components/instance/reporter/basic.js +65 -46
- package/dist-npm/components/instance/reporter/browser.js +47 -44
- package/dist-npm/components/instance/reporter/fancy.js +96 -83
- package/dist-npm/components/instance/shared.js +2 -2
- package/dist-npm/components/mono/mono.js +62 -52
- package/dist-npm/components/mono/monoTwo.js +49 -35
- package/dist-npm/components/multiselect/group-multiselect.js +71 -55
- package/dist-npm/components/multiselect/multi-select-two.js +130 -98
- package/dist-npm/components/multiselect/multi-select.js +49 -43
- package/dist-npm/components/multiselect/multiselect-main.js +146 -120
- package/dist-npm/components/multiselect/num-multi-select.js +130 -98
- package/dist-npm/components/multiselect/num-multiselect-main.js +35 -24
- package/dist-npm/components/next-steps/next-steps.js +25 -24
- package/dist-npm/components/number/index.js +112 -78
- package/dist-npm/components/number/number-main.js +2 -96
- package/dist-npm/components/password/index.js +73 -54
- package/dist-npm/components/password/password-main.js +2 -120
- package/dist-npm/components/password/password-three.js +30 -26
- package/dist-npm/components/progressbar/ProgressBar.js +64 -45
- package/dist-npm/components/progressbar/helper.js +40 -33
- package/dist-npm/components/progressbar/index.js +1 -1
- package/dist-npm/components/prompts/create.js +44 -29
- package/dist-npm/components/prompts/index.js +45 -45
- package/dist-npm/components/prompts/prompt.js +260 -211
- package/dist-npm/components/prompts/promptTwo.js +605 -561
- package/dist-npm/components/prompts/relinka.js +295 -237
- package/dist-npm/components/range/range.js +294 -247
- package/dist-npm/components/rawlist/index.js +107 -87
- package/dist-npm/components/results/results.js +37 -31
- package/dist-npm/components/search/index.js +193 -148
- package/dist-npm/components/select/index.js +186 -148
- package/dist-npm/components/select/num-select-main.js +27 -27
- package/dist-npm/components/select/num-select.js +5 -125
- package/dist-npm/components/select/select-key.js +25 -24
- package/dist-npm/components/select/select-main.js +133 -109
- package/dist-npm/components/select/select-three.js +36 -32
- package/dist-npm/components/select/select-two.js +87 -95
- package/dist-npm/components/spinner/index.js +136 -107
- package/dist-npm/components/st-end/end.d.ts +1 -1
- package/dist-npm/components/st-end/end.js +26 -35
- package/dist-npm/components/st-end/start.d.ts +1 -1
- package/dist-npm/components/st-end/start.js +15 -30
- package/dist-npm/components/toggle/index.js +137 -113
- package/dist-npm/components/visual/animate/animate.js +10 -53
- package/dist-npm/components/visual/ascii-art/ascii-art.js +1 -12
- package/dist-npm/mod.js +2 -1
- package/dist-npm/testing/index.js +83 -58
- package/dist-npm/types/general.d.ts +2 -1
- package/dist-npm/types/general.js +1 -0
- package/dist-npm/types/index.js +3 -2
- package/dist-npm/types/keypress.js +36 -35
- package/dist-npm/types/readline.js +1 -0
- package/dist-npm/types/relinka.js +1 -0
- package/dist-npm/types/utils.js +1 -0
- package/dist-npm/utils/box.js +137 -135
- package/dist-npm/utils/color.js +74 -65
- package/dist-npm/utils/colorize.js +156 -124
- package/dist-npm/utils/component.js +657 -532
- package/dist-npm/utils/constants.js +63 -64
- package/dist-npm/utils/core.js +3 -2
- package/dist-npm/utils/decoder.js +223 -244
- package/dist-npm/utils/error.js +9 -4
- package/dist-npm/utils/errors.js +4 -14
- package/dist-npm/utils/format.js +24 -19
- package/dist-npm/utils/keypress.js +414 -316
- package/dist-npm/utils/log.js +15 -11
- package/dist-npm/utils/mapping.js +52 -45
- package/dist-npm/utils/messages.js +183 -183
- package/dist-npm/utils/platforms.js +20 -16
- package/dist-npm/utils/prompt-tmp.js +286 -235
- package/dist-npm/utils/prompt-two.js +286 -235
- package/dist-npm/utils/readline.js +7 -5
- package/dist-npm/utils/skeleton.js +170 -130
- package/dist-npm/utils/stream.js +2 -2
- package/dist-npm/utils/string.js +58 -44
- package/dist-npm/utils/terminal.js +34 -23
- package/dist-npm/utils/tree.js +41 -30
- package/dist-npm/utils/types.js +1 -0
- package/dist-npm/utils/utils.js +8 -8
- package/dist-npm/utils/variants.js +44 -36
- package/package.json +20 -28
|
@@ -1,49 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {colorMap} from './mapping.js';
|
|
2
|
+
|
|
3
|
+
const {isArray} = Array;
|
|
4
|
+
const maybeArray = (a) => isArray(a) ? a : [a];
|
|
5
|
+
|
|
2
6
|
export const variantMap = {
|
|
3
|
-
|
|
4
|
-
doubleBox: createDoubleBox
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
doubleBox: createDoubleBox,
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
switch (variant) {
|
|
9
|
+
export function applyVariant(lines, variant, options, borderColor) {
|
|
10
|
+
const linesArray = maybeArray(lines);
|
|
11
11
|
|
|
12
|
+
switch(variant) {
|
|
13
|
+
case 'doubleBox':
|
|
14
|
+
return createDoubleBox(linesArray, options?.limit, borderColor);
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
default:
|
|
17
|
+
return linesArray.join('\n');
|
|
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 = '';
|
|
15
25
|
|
|
26
|
+
if (borderColor === void 0) {
|
|
27
|
+
borderColor = 'viceGradient';
|
|
28
|
+
}
|
|
16
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`;
|
|
17
32
|
|
|
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');
|
|
18
39
|
|
|
19
|
-
|
|
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}
|
|
40
|
+
return `${topBorder}
|
|
37
41
|
${middle}
|
|
38
42
|
${bottomBorder}`;
|
|
39
43
|
}
|
|
44
|
+
|
|
40
45
|
function processLines(lines, limit) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const linesArray = maybeArray(lines);
|
|
47
|
+
|
|
48
|
+
return linesArray.map((line) => {
|
|
49
|
+
let truncatedLine = line;
|
|
50
|
+
|
|
51
|
+
if (limit && line.length > limit) {
|
|
52
|
+
truncatedLine = `${line.slice(0, limit - 3)}...`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return truncatedLine.padEnd(limit || truncatedLine.length);
|
|
56
|
+
});
|
|
49
57
|
}
|
package/package.json
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reliverse/relinka",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
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": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"pub:
|
|
14
|
-
"pub": "
|
|
7
|
+
"dev": "bun examples/main.ts",
|
|
8
|
+
"check": "redrun typecheck lint format attw",
|
|
9
|
+
"release": "bumpp && bun check && bun pub",
|
|
10
|
+
"build:jsr": "bun build.optim.ts --jsr",
|
|
11
|
+
"build:npm": "unbuild && bun build.optim.ts",
|
|
12
|
+
"build": "redrun build:jsr build:npm optimize",
|
|
13
|
+
"pub:jsr": "bunx jsr publish --allow-slow-types --allow-dirty",
|
|
14
|
+
"pub:dry": "bun run build:jsr && bun pub:jsr --dry-run",
|
|
15
|
+
"pub:npm": "bun publish",
|
|
16
|
+
"pub": "redrun build pub:jsr pub:npm",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
15
18
|
"lint": "eslint --cache --fix .",
|
|
19
|
+
"lint:i": "eslint --inspect-config",
|
|
16
20
|
"format": "biome check --write .",
|
|
17
21
|
"optimize": "putout dist-npm --fix",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"knip": "knip"
|
|
22
|
-
"start": "node dist-npm/mod.js",
|
|
23
|
-
"dev": "bun examples/main.ts",
|
|
24
|
-
"dex": "tsx examples/main.ts",
|
|
25
|
-
"dev:eslint": "bun eslint --inspect-config",
|
|
26
|
-
"test:tape": "tape test/*.js | tap-spec",
|
|
27
|
-
"release": "bumpp & bun pub",
|
|
28
|
-
"typecheck": "tsc --noEmit"
|
|
22
|
+
"attw": "bunx @arethetypeswrong/cli",
|
|
23
|
+
"unpub": "npm unpublish",
|
|
24
|
+
"test": "vitest",
|
|
25
|
+
"knip": "knip"
|
|
29
26
|
},
|
|
30
27
|
"publishConfig": {
|
|
31
28
|
"access": "public"
|
|
@@ -99,15 +96,14 @@
|
|
|
99
96
|
"@types/figlet": "^1.7.0",
|
|
100
97
|
"@types/fs-extra": "^11.0.4",
|
|
101
98
|
"@types/mute-stream": "^0.0.4",
|
|
102
|
-
"@types/node": "^22.9.
|
|
99
|
+
"@types/node": "^22.9.4",
|
|
103
100
|
"@types/sentencer": "^0.2.3",
|
|
104
101
|
"@types/signal-exit": "^3.0.4",
|
|
105
102
|
"@types/strip-comments": "^2.0.4",
|
|
106
|
-
"@types/tape": "^5.6.4",
|
|
107
103
|
"@types/window-size": "^1.1.4",
|
|
108
104
|
"bumpp": "^9.8.1",
|
|
109
105
|
"eslint": "^9.15.0",
|
|
110
|
-
"eslint-plugin-perfectionist": "^4.
|
|
106
|
+
"eslint-plugin-perfectionist": "^4.1.2",
|
|
111
107
|
"jiti": "^2.4.0",
|
|
112
108
|
"knip": "^5.37.2",
|
|
113
109
|
"mock-stdin": "^1.0.0",
|
|
@@ -116,12 +112,8 @@
|
|
|
116
112
|
"redrun": "^11.0.5",
|
|
117
113
|
"sentencer": "^0.2.1",
|
|
118
114
|
"strip-comments": "^2.0.1",
|
|
119
|
-
"tap-spec": "^5.0.0",
|
|
120
|
-
"tape": "^5.9.0",
|
|
121
|
-
"tshy": "^3.0.2",
|
|
122
|
-
"tsx": "^4.19.2",
|
|
123
115
|
"typescript": "^5.7.2",
|
|
124
|
-
"typescript-eslint": "^8.
|
|
116
|
+
"typescript-eslint": "^8.16.0",
|
|
125
117
|
"unbuild": "^2.0.0",
|
|
126
118
|
"vitest": "^2.1.5"
|
|
127
119
|
}
|