@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.
Files changed (118) hide show
  1. package/dist-npm/components/anykey/index.js +77 -57
  2. package/dist-npm/components/block/block.js +61 -48
  3. package/dist-npm/components/checkbox/index.js +211 -178
  4. package/dist-npm/components/confirm/confirm-main.js +122 -86
  5. package/dist-npm/components/confirm/confirm-three.js +27 -24
  6. package/dist-npm/components/confirm/index.js +45 -36
  7. package/dist-npm/components/core/Separator.js +17 -15
  8. package/dist-npm/components/core/create-prompt.js +124 -101
  9. package/dist-npm/components/core/errors.js +15 -19
  10. package/dist-npm/components/core/hook-engine.js +120 -91
  11. package/dist-npm/components/core/index.js +12 -12
  12. package/dist-npm/components/core/key.js +6 -16
  13. package/dist-npm/components/core/lines.js +54 -45
  14. package/dist-npm/components/core/make-theme.js +30 -21
  15. package/dist-npm/components/core/position.js +23 -27
  16. package/dist-npm/components/core/promise-polyfill.js +14 -11
  17. package/dist-npm/components/core/screen-manager.js +74 -59
  18. package/dist-npm/components/core/theme.js +32 -22
  19. package/dist-npm/components/core/use-effect.js +15 -9
  20. package/dist-npm/components/core/use-keypress.js +23 -19
  21. package/dist-npm/components/core/use-memo.js +16 -10
  22. package/dist-npm/components/core/use-pagination.js +32 -33
  23. package/dist-npm/components/core/use-prefix.js +38 -40
  24. package/dist-npm/components/core/use-ref.js +5 -2
  25. package/dist-npm/components/core/use-state.js +23 -15
  26. package/dist-npm/components/core/useKeyPress.js +17 -14
  27. package/dist-npm/components/core/usePromptState.js +14 -8
  28. package/dist-npm/components/core/utils.js +16 -7
  29. package/dist-npm/components/date/date.js +204 -168
  30. package/dist-npm/components/editor/index.js +92 -71
  31. package/dist-npm/components/expand/index.js +124 -96
  32. package/dist-npm/components/figures/index.js +294 -283
  33. package/dist-npm/components/input/index.js +87 -61
  34. package/dist-npm/components/input/text-main.js +124 -86
  35. package/dist-npm/components/input/text.js +28 -24
  36. package/dist-npm/components/instance/basic.js +25 -17
  37. package/dist-npm/components/instance/browser.js +18 -14
  38. package/dist-npm/components/instance/reporter/basic.js +65 -46
  39. package/dist-npm/components/instance/reporter/browser.js +47 -44
  40. package/dist-npm/components/instance/reporter/fancy.js +96 -83
  41. package/dist-npm/components/instance/shared.js +2 -2
  42. package/dist-npm/components/mono/mono.js +62 -52
  43. package/dist-npm/components/mono/monoTwo.js +49 -35
  44. package/dist-npm/components/multiselect/group-multiselect.js +71 -55
  45. package/dist-npm/components/multiselect/multi-select-two.js +130 -98
  46. package/dist-npm/components/multiselect/multi-select.js +49 -43
  47. package/dist-npm/components/multiselect/multiselect-main.js +146 -120
  48. package/dist-npm/components/multiselect/num-multi-select.js +130 -98
  49. package/dist-npm/components/multiselect/num-multiselect-main.js +35 -24
  50. package/dist-npm/components/next-steps/next-steps.js +25 -24
  51. package/dist-npm/components/number/index.js +112 -78
  52. package/dist-npm/components/number/number-main.js +2 -96
  53. package/dist-npm/components/password/index.js +73 -54
  54. package/dist-npm/components/password/password-main.js +2 -120
  55. package/dist-npm/components/password/password-three.js +30 -26
  56. package/dist-npm/components/progressbar/ProgressBar.js +64 -45
  57. package/dist-npm/components/progressbar/helper.js +40 -33
  58. package/dist-npm/components/progressbar/index.js +1 -1
  59. package/dist-npm/components/prompts/create.js +44 -29
  60. package/dist-npm/components/prompts/index.js +45 -45
  61. package/dist-npm/components/prompts/prompt.js +260 -211
  62. package/dist-npm/components/prompts/promptTwo.js +605 -561
  63. package/dist-npm/components/prompts/relinka.js +295 -237
  64. package/dist-npm/components/range/range.js +294 -247
  65. package/dist-npm/components/rawlist/index.js +107 -87
  66. package/dist-npm/components/results/results.js +37 -31
  67. package/dist-npm/components/search/index.js +193 -148
  68. package/dist-npm/components/select/index.js +186 -148
  69. package/dist-npm/components/select/num-select-main.js +27 -27
  70. package/dist-npm/components/select/num-select.js +5 -125
  71. package/dist-npm/components/select/select-key.js +25 -24
  72. package/dist-npm/components/select/select-main.js +133 -109
  73. package/dist-npm/components/select/select-three.js +36 -32
  74. package/dist-npm/components/select/select-two.js +87 -95
  75. package/dist-npm/components/spinner/index.js +136 -107
  76. package/dist-npm/components/st-end/end.d.ts +1 -1
  77. package/dist-npm/components/st-end/end.js +26 -35
  78. package/dist-npm/components/st-end/start.d.ts +1 -1
  79. package/dist-npm/components/st-end/start.js +15 -30
  80. package/dist-npm/components/toggle/index.js +137 -113
  81. package/dist-npm/components/visual/animate/animate.js +10 -53
  82. package/dist-npm/components/visual/ascii-art/ascii-art.js +1 -12
  83. package/dist-npm/mod.js +2 -1
  84. package/dist-npm/testing/index.js +83 -58
  85. package/dist-npm/types/general.d.ts +2 -1
  86. package/dist-npm/types/general.js +1 -0
  87. package/dist-npm/types/index.js +3 -2
  88. package/dist-npm/types/keypress.js +36 -35
  89. package/dist-npm/types/readline.js +1 -0
  90. package/dist-npm/types/relinka.js +1 -0
  91. package/dist-npm/types/utils.js +1 -0
  92. package/dist-npm/utils/box.js +137 -135
  93. package/dist-npm/utils/color.js +74 -65
  94. package/dist-npm/utils/colorize.js +156 -124
  95. package/dist-npm/utils/component.js +657 -532
  96. package/dist-npm/utils/constants.js +63 -64
  97. package/dist-npm/utils/core.js +3 -2
  98. package/dist-npm/utils/decoder.js +223 -244
  99. package/dist-npm/utils/error.js +9 -4
  100. package/dist-npm/utils/errors.js +4 -14
  101. package/dist-npm/utils/format.js +24 -19
  102. package/dist-npm/utils/keypress.js +414 -316
  103. package/dist-npm/utils/log.js +15 -11
  104. package/dist-npm/utils/mapping.js +52 -45
  105. package/dist-npm/utils/messages.js +183 -183
  106. package/dist-npm/utils/platforms.js +20 -16
  107. package/dist-npm/utils/prompt-tmp.js +286 -235
  108. package/dist-npm/utils/prompt-two.js +286 -235
  109. package/dist-npm/utils/readline.js +7 -5
  110. package/dist-npm/utils/skeleton.js +170 -130
  111. package/dist-npm/utils/stream.js +2 -2
  112. package/dist-npm/utils/string.js +58 -44
  113. package/dist-npm/utils/terminal.js +34 -23
  114. package/dist-npm/utils/tree.js +41 -30
  115. package/dist-npm/utils/types.js +1 -0
  116. package/dist-npm/utils/utils.js +8 -8
  117. package/dist-npm/utils/variants.js +44 -36
  118. package/package.json +20 -28
@@ -1,49 +1,57 @@
1
- import { colorMap } from "./mapping.js";
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 async function applyVariant(lines, variant, options, borderColor) {
9
- const linesArray = Array.isArray(lines) ? lines : [lines];
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
- case "doubleBox":
14
- return createDoubleBox(linesArray, options?.limit, borderColor);
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
- 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}
40
+ return `${topBorder}
37
41
  ${middle}
38
42
  ${bottomBorder}`;
39
43
  }
44
+
40
45
  function processLines(lines, limit) {
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
- });
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.4",
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
- "appts": "bun typecheck && bun lint && bun format && bun optimize",
8
- "build": "unbuild && bun build.optim.ts",
9
- "unpub": "npm unpublish",
10
- "bunp": "bun publish",
11
- "pub:jsr": "bun build.optim.ts --jsr && bunx jsr publish --allow-slow-types --allow-dirty",
12
- "pub:jsr-dry": "bun pub:jsr --dry-run",
13
- "pub:npm": "redrun build bunp",
14
- "pub": "redrun pub:jsr pub:npm",
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
- "check": "bun test",
19
- "attw": "attw --pack",
20
- "tsc": "tshy",
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.3",
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.0.3",
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.15.0",
116
+ "typescript-eslint": "^8.16.0",
125
117
  "unbuild": "^2.0.0",
126
118
  "vitest": "^2.1.5"
127
119
  }