@reliverse/relinka 1.3.1 → 1.3.3

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 (69) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +87 -134
  3. package/bin/deprecated/components/core/core.d.ts +2 -0
  4. package/bin/deprecated/components/core/core.js +2 -0
  5. package/{dist-npm → bin/deprecated}/components/levels/levels.d.ts +26 -26
  6. package/{dist-npm → bin/deprecated}/components/modes/basic.d.ts +20 -20
  7. package/{dist-npm → bin/deprecated}/components/modes/basic.js +5 -5
  8. package/{dist-npm → bin/deprecated}/components/modes/browser.d.ts +19 -19
  9. package/{dist-npm → bin/deprecated}/components/modes/browser.js +2 -2
  10. package/bin/deprecated/components/modes/shared.d.ts +5 -0
  11. package/bin/deprecated/components/modes/shared.js +2 -0
  12. package/bin/deprecated/components/relinka/logger.d.ts +5 -0
  13. package/bin/deprecated/components/relinka/logger.js +5 -0
  14. package/{dist-npm → bin/deprecated}/components/relinka/mod.d.ts +21 -21
  15. package/{dist-npm → bin/deprecated}/components/relinka/mod.js +3 -3
  16. package/{dist-npm → bin/deprecated}/components/relinka/relinka.d.ts +141 -140
  17. package/{dist-npm → bin/deprecated}/components/relinka/relinka.js +14 -11
  18. package/{dist-npm → bin/deprecated}/components/reporters/basic.d.ts +11 -11
  19. package/{dist-npm → bin/deprecated}/components/reporters/basic.js +10 -6
  20. package/{dist-npm → bin/deprecated}/components/reporters/browser.d.ts +10 -10
  21. package/{dist-npm → bin/deprecated}/components/reporters/fancy.d.ts +10 -10
  22. package/{dist-npm → bin/deprecated}/components/reporters/fancy.js +16 -11
  23. package/{dist-npm/main.d.ts → bin/deprecated/depd-main.d.ts} +2 -3
  24. package/{dist-npm/main.js → bin/deprecated/depd-main.js} +0 -1
  25. package/{dist-npm → bin/deprecated}/types/mod.d.ts +150 -149
  26. package/{dist-npm → bin/deprecated}/utils/box.d.ts +114 -114
  27. package/{dist-npm → bin/deprecated}/utils/box.js +1 -1
  28. package/{dist-npm → bin/deprecated}/utils/deprecatedColors.d.ts +69 -69
  29. package/{dist-npm → bin/deprecated}/utils/deprecatedColors.js +3 -9
  30. package/{dist-npm → bin/deprecated}/utils/error.d.ts +6 -6
  31. package/{dist-npm → bin/deprecated}/utils/format.d.ts +14 -14
  32. package/{dist-npm → bin/deprecated}/utils/format.js +2 -2
  33. package/{dist-npm → bin/deprecated}/utils/log.d.ts +13 -13
  34. package/bin/deprecated/utils/mod.d.ts +3 -0
  35. package/bin/deprecated/utils/mod.js +9 -0
  36. package/{dist-npm → bin/deprecated}/utils/stream.d.ts +15 -14
  37. package/{dist-npm → bin/deprecated}/utils/string.d.ts +50 -50
  38. package/{dist-npm → bin/deprecated}/utils/tree.d.ts +41 -41
  39. package/bin/main.d.ts +1 -0
  40. package/bin/main.js +1 -0
  41. package/package.json +46 -83
  42. package/dist-npm/components/core/core.d.ts +0 -2
  43. package/dist-npm/components/core/core.js +0 -2
  44. package/dist-npm/components/messages/mapping.d.ts +0 -3
  45. package/dist-npm/components/messages/mapping.js +0 -49
  46. package/dist-npm/components/messages/messages.d.ts +0 -89
  47. package/dist-npm/components/messages/messages.js +0 -314
  48. package/dist-npm/components/messages/mod.d.ts +0 -5
  49. package/dist-npm/components/messages/mod.js +0 -5
  50. package/dist-npm/components/messages/terminal.d.ts +0 -15
  51. package/dist-npm/components/messages/terminal.js +0 -57
  52. package/dist-npm/components/messages/types.d.ts +0 -12
  53. package/dist-npm/components/messages/types.js +0 -0
  54. package/dist-npm/components/messages/variants.d.ts +0 -12
  55. package/dist-npm/components/messages/variants.js +0 -52
  56. package/dist-npm/components/modes/shared.d.ts +0 -5
  57. package/dist-npm/components/modes/shared.js +0 -2
  58. package/dist-npm/components/relinka/logger.d.ts +0 -12
  59. package/dist-npm/components/relinka/logger.js +0 -52
  60. package/dist-npm/utils/mod.d.ts +0 -3
  61. package/dist-npm/utils/mod.js +0 -9
  62. /package/{dist-npm → bin/deprecated}/components/levels/levels.js +0 -0
  63. /package/{dist-npm → bin/deprecated}/components/reporters/browser.js +0 -0
  64. /package/{dist-npm → bin/deprecated}/types/mod.js +0 -0
  65. /package/{dist-npm → bin/deprecated}/utils/error.js +0 -0
  66. /package/{dist-npm → bin/deprecated}/utils/log.js +0 -0
  67. /package/{dist-npm → bin/deprecated}/utils/stream.js +0 -0
  68. /package/{dist-npm → bin/deprecated}/utils/string.js +0 -0
  69. /package/{dist-npm → bin/deprecated}/utils/tree.js +0 -0
package/package.json CHANGED
@@ -1,71 +1,16 @@
1
1
  {
2
- "name": "@reliverse/relinka",
3
- "version": "1.3.1",
4
- "author": "blefnk",
5
- "type": "module",
6
- "description": "@reliverse/relinka is a powerful logger for your terminal.",
7
- "scripts": {
8
- "dev": "bun examples/main.ts",
9
- "check": "bun typecheck && bun lint && bun format",
10
- "build:npm": "unbuild && bun build.optim.ts",
11
- "build:jsr": "bun build.optim.ts --jsr",
12
- "build": "bun build:npm && bun build:jsr",
13
- "pub:npm": "bun build.publish.ts",
14
- "pub:jsr": "bun build.publish.ts --jsr",
15
- "pub:dry": "bun build.publish.ts --dry-run",
16
- "pub": "bun publish.ts",
17
- "typecheck": "tsc --noEmit",
18
- "lint": "eslint --cache --fix .",
19
- "lint:i": "eslint --inspect-config",
20
- "format": "biome check --write .",
21
- "attw": "bunx @arethetypeswrong/cli",
22
- "unpub": "npm unpublish",
23
- "test": "vitest",
24
- "knip": "knip",
25
- "latest": "bun update --latest"
26
- },
27
- "publishConfig": {
28
- "access": "public"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/reliverse/relinka.git"
33
- },
34
- "types": "./dist-npm/main.d.ts",
35
- "module": "./dist-npm/main.js",
36
- "main": "./dist-npm/main.js",
37
- "exports": {
38
- "import": "./dist-npm/main.js",
39
- "types": "./dist-npm/main.d.ts"
40
- },
41
- "bugs": {
42
- "url": "https://github.com/reliverse/relinka/issues",
43
- "email": "blefnk@gmail.com"
44
- },
45
- "files": [
46
- "package.json",
47
- "README.md",
48
- "LICENSE.md",
49
- "dist-npm"
50
- ],
51
- "homepage": "https://github.com/reliverse/relinka",
52
- "keywords": [
53
- "cli",
54
- "reliverse"
55
- ],
56
- "license": "MIT",
57
2
  "dependencies": {
58
3
  "@figliolia/chalk-animation": "^1.0.4",
59
- "@reliverse/relico": "^1.0.1",
60
- "@reliverse/runtime": "^1.0.2",
61
- "@sinclair/typebox": "^0.34.14",
4
+ "@reliverse/relico": "^1.0.2",
5
+ "@reliverse/runtime": "^1.0.3",
6
+ "@sinclair/typebox": "^0.34.31",
62
7
  "ansi-diff-stream": "^1.2.1",
63
8
  "ansi-escapes": "^7.0.0",
64
9
  "chalk": "^5.4.1",
65
10
  "cli-spinners": "^3.2.0",
66
11
  "cli-styles": "^1.0.0",
67
12
  "cli-width": "^4.1.0",
68
- "confbox": "^0.1.8",
13
+ "confbox": "^0.2.1",
69
14
  "defu": "^6.1.4",
70
15
  "destr": "^2.0.3",
71
16
  "detect-package-manager": "^3.0.2",
@@ -74,21 +19,21 @@
74
19
  "figlet": "^1.8.0",
75
20
  "fs-extra": "^11.3.0",
76
21
  "get-pixels": "^3.3.3",
77
- "globby": "^14.0.2",
22
+ "globby": "^14.1.0",
78
23
  "gradient-string": "^3.0.0",
79
24
  "kleur": "^4.1.5",
80
25
  "log-update": "^6.1.0",
81
26
  "mri": "^1.2.0",
82
27
  "mute-stream": "^2.0.0",
83
28
  "node-emoji": "^2.2.0",
84
- "nypm": "^0.5.0",
85
- "ora": "^8.1.1",
86
- "pathe": "^2.0.2",
29
+ "nypm": "^0.6.0",
30
+ "ora": "^8.2.0",
31
+ "pathe": "^2.0.3",
87
32
  "precision": "^1.0.1",
88
33
  "seventh": "^0.9.2",
89
34
  "signal-exit": "^4.1.0",
90
35
  "sisteransi": "^1.0.5",
91
- "std-env": "^3.8.0",
36
+ "std-env": "^3.8.1",
92
37
  "string-width": "^7.2.0",
93
38
  "strip-ansi": "^7.1.0",
94
39
  "terminal-size": "^4.0.0",
@@ -96,41 +41,59 @@
96
41
  "window-size": "^1.1.1",
97
42
  "wrap-ansi": "^9.0.0"
98
43
  },
44
+ "homepage": "https://docs.reliverse.org",
45
+ "license": "MIT",
46
+ "name": "@reliverse/relinka",
47
+ "type": "module",
48
+ "version": "1.3.3",
99
49
  "devDependencies": {
100
- "@arethetypeswrong/cli": "^0.17.3",
50
+ "@arethetypeswrong/cli": "^0.17.4",
101
51
  "@biomejs/biome": "1.9.4",
102
- "@cspell/dict-npm": "^5.1.23",
103
- "@eslint/js": "^9.19.0",
104
- "@eslint/json": "^0.10.0",
105
- "@eslint/markdown": "^6.2.2",
106
- "@stylistic/eslint-plugin": "^3.0.0",
52
+ "@cspell/dict-npm": "^5.1.32",
53
+ "@eslint/js": "^9.23.0",
54
+ "@reliverse/relidler-cfg": "^1.1.3",
55
+ "@stylistic/eslint-plugin": "^4.2.0",
107
56
  "@types/ansi-diff-stream": "^1.2.3",
108
- "@types/bun": "^1.2.0",
57
+ "@types/bun": "^1.2.8",
109
58
  "@types/chalk-animation": "^1.6.3",
110
- "@types/eslint__js": "^8.42.3",
111
59
  "@types/figlet": "^1.7.0",
112
60
  "@types/fs-extra": "^11.0.4",
113
61
  "@types/mute-stream": "^0.0.4",
114
- "@types/node": "^22.10.10",
62
+ "@types/node": "^22.13.16",
115
63
  "@types/sentencer": "^0.2.3",
116
- "@types/signal-exit": "^3.0.4",
64
+ "@types/signal-exit": "^4.0.0",
117
65
  "@types/strip-comments": "^2.0.4",
118
66
  "@types/window-size": "^1.1.4",
119
- "c12": "^2.0.1",
67
+ "c12": "^3.0.2",
120
68
  "citty": "^0.1.6",
121
- "eslint": "^9.19.0",
122
- "eslint-plugin-perfectionist": "^4.7.0",
69
+ "eslint": "^9.23.0",
70
+ "eslint-plugin-no-relative-import-paths": "^1.6.1",
71
+ "eslint-plugin-perfectionist": "^4.10.1",
123
72
  "execa": "^9.5.2",
124
73
  "jiti": "^2.4.2",
125
- "knip": "^5.43.3",
74
+ "knip": "^5.46.4",
126
75
  "mock-stdin": "^1.0.0",
127
76
  "printj": "^1.3.1",
128
77
  "sentencer": "^0.2.1",
129
78
  "strip-comments": "^2.0.1",
130
- "tsx": "^4.19.2",
131
- "typescript": "^5.7.3",
132
- "typescript-eslint": "^8.21.0",
133
- "unbuild": "^3.3.1",
134
- "vitest": "^3.0.4"
79
+ "tsx": "^4.19.3",
80
+ "typescript": "^5.8.2",
81
+ "typescript-eslint": "^8.29.0",
82
+ "unbuild": "^3.5.0",
83
+ "vitest": "^3.1.1"
84
+ },
85
+ "exports": {
86
+ ".": "./bin/main.js"
87
+ },
88
+ "files": [
89
+ "bin",
90
+ "package.json",
91
+ "README.md",
92
+ "LICENSE"
93
+ ],
94
+ "main": "./bin/main.js",
95
+ "module": "./bin/main.js",
96
+ "publishConfig": {
97
+ "access": "public"
135
98
  }
136
99
  }
@@ -1,2 +0,0 @@
1
- export { createRelinka } from "../../components/relinka/relinka.js";
2
- export * from "../../components/modes/shared.js";
@@ -1,2 +0,0 @@
1
- export { createRelinka } from "../../components/relinka/relinka.js";
2
- export * from "../../components/modes/shared.js";
@@ -1,3 +0,0 @@
1
- import type { ColorName, TypographyName } from "./types.js";
2
- export declare const colorMap: Record<ColorName, (text: string) => string>;
3
- export declare const typographyMap: Record<TypographyName, (text: string) => string>;
@@ -1,49 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import gradient, { cristal, mind, passion, retro, vice } from "gradient-string";
3
- import { rainbow } from "gradient-string";
4
- export const colorMap = {
5
- // @reliverse/relico
6
- none: (text) => text,
7
- reset: re.reset,
8
- bgCyan: re.bgCyan,
9
- bgCyanBright: re.bgCyanBright,
10
- black: re.black,
11
- blue: re.blue,
12
- blueBright: re.blueBright,
13
- cyan: re.cyan,
14
- cyanBright: re.cyanBright,
15
- dim: re.dim,
16
- gray: re.gray,
17
- green: re.green,
18
- greenBright: re.greenBright,
19
- inverse: (text) => re.bold(re.inverse(text)),
20
- magenta: re.magenta,
21
- magentaBright: re.magentaBright,
22
- red: re.red,
23
- redBright: re.redBright,
24
- white: re.white,
25
- yellow: re.yellow,
26
- yellowBright: re.yellowBright,
27
- // gradient-string
28
- cristalGradient: cristal,
29
- gradientGradient: gradient([
30
- "red",
31
- "yellow",
32
- "green",
33
- "cyan",
34
- "blue",
35
- "magenta"
36
- ]),
37
- mindGradient: mind,
38
- passionGradient: passion,
39
- rainbowGradient: rainbow,
40
- retroGradient: retro,
41
- viceGradient: vice
42
- };
43
- export const typographyMap = {
44
- none: (text) => text,
45
- bold: re.bold,
46
- italic: re.italic,
47
- strikethrough: re.strikethrough,
48
- underline: re.underline
49
- };
@@ -1,89 +0,0 @@
1
- import type { TypographyName } from "./types.js";
2
- import type { ColorName, MsgType } from "./types.js";
3
- import { type VariantName } from "./variants.js";
4
- /**
5
- * Known symbol names that will have IntelliSense support
6
- */
7
- export type SymbolName = "pointer" | "start" | "middle" | "end" | "line" | "corner_top_right" | "step_active" | "step_error" | "info" | "success";
8
- export type FmtMsgOptions = {
9
- type: MsgType;
10
- title?: string;
11
- titleAfterAnim?: string;
12
- content?: string | undefined;
13
- titleColor?: ColorName;
14
- titleTypography?: TypographyName;
15
- titleVariant?: VariantName;
16
- contentColor?: ColorName;
17
- contentTypography?: TypographyName;
18
- contentVariant?: VariantName;
19
- hint?: string;
20
- hintPlaceholderColor?: ColorName;
21
- hintTypography?: TypographyName;
22
- border?: boolean;
23
- borderColor?: ColorName;
24
- dontRemoveBar?: boolean;
25
- variantOptions?: {
26
- box?: {
27
- limit?: number;
28
- };
29
- };
30
- errorMessage?: string;
31
- addNewLineBefore?: boolean;
32
- addNewLineAfter?: boolean;
33
- placeholder?: string;
34
- horizontalLine?: boolean;
35
- horizontalLineLength?: number;
36
- terminalWidth?: number;
37
- instructions?: string;
38
- wrapTitle?: boolean;
39
- wrapContent?: boolean;
40
- symbol?: SymbolName;
41
- customSymbol?: string;
42
- symbolColor?: ColorName;
43
- noNewLine?: boolean;
44
- };
45
- export declare const symbols: {
46
- readonly pointer: string;
47
- readonly start: string;
48
- readonly middle: string;
49
- readonly end: string;
50
- readonly line: string;
51
- readonly corner_top_right: string;
52
- readonly step_active: string;
53
- readonly step_error: string;
54
- readonly info: string;
55
- readonly success: string;
56
- };
57
- /**
58
- * Returns a colored vertical bar symbol. Prevents gradient colors for bars.
59
- */
60
- export declare const bar: ({ borderColor, }?: {
61
- borderColor?: ColorName;
62
- }) => string;
63
- /**
64
- * Main formatter function: builds the final text output based on FmtMsgOptions.
65
- */
66
- export declare function fmt(opts: FmtMsgOptions): {
67
- text: string;
68
- lineCount: number;
69
- };
70
- /**
71
- * Logs a formatted message to the console and records how many lines it occupies.
72
- */
73
- export declare function msg(opts: FmtMsgOptions): void;
74
- /**
75
- * Undo the last printed message by deleting its lines from the terminal.
76
- * @param count How many messages to undo. Defaults to 1.
77
- */
78
- export declare function msgUndo(count?: number): void;
79
- /**
80
- * Undo all printed messages so far.
81
- */
82
- export declare function msgUndoAll(): void;
83
- /**
84
- * Prints: "│ <text>" (two spaces after the bar).
85
- * If text is empty, it just prints "│".
86
- * If indent is 1, it prints "│ <text>" (one space).
87
- * If indent is 2, it prints "│ <text>" (two spaces), etc.
88
- */
89
- export declare function printLineBar(text: string, indent?: number): void;
@@ -1,314 +0,0 @@
1
- import { re } from "@reliverse/relico";
2
- import { isUnicodeSupported } from "@reliverse/runtime";
3
- import wrapAnsi from "wrap-ansi";
4
- import { colorMap, typographyMap } from "./mapping.js";
5
- import {
6
- deleteLastLines,
7
- getExactTerminalWidth,
8
- getTerminalWidth
9
- } from "./terminal.js";
10
- import { isValidVariant, variantMap } from "./variants.js";
11
- const unicode = isUnicodeSupported();
12
- const u = (c, fallback) => unicode ? c : fallback;
13
- export const symbols = {
14
- pointer: u("\u{1F449}", ">"),
15
- start: u("\u256D", "*"),
16
- middle: u("\u2502", "|"),
17
- end: u("\u2570", "*"),
18
- line: u("\u2500", "\u2014"),
19
- corner_top_right: u("\u256D", "*"),
20
- step_active: u("\u25C6", "\u2666"),
21
- step_error: u("\u{1F5F4}", "x"),
22
- info: u("\u2139", "i"),
23
- success: u("\u2705", "\u2713")
24
- };
25
- function wrapThenStyle(input, wrap, typographyName, colorName, variantName, borderColor) {
26
- if (!input) return "";
27
- const width = getTerminalWidth();
28
- const wrappedText = wrap ? wrapAnsi(input, width, { hard: false, trim: true }) : input;
29
- return wrappedText.split("\n").map(
30
- (line) => applyStyles(line, colorName, typographyName, variantName, borderColor)
31
- ).join("\n");
32
- }
33
- function applyStyles(text, colorName, typographyName, variantName, borderColor) {
34
- let styledText = text;
35
- if (variantName && isValidVariant(variantName)) {
36
- styledText = variantMap[variantName](
37
- [styledText],
38
- void 0,
39
- borderColor
40
- ).toString();
41
- return styledText;
42
- }
43
- if (colorName && colorMap[colorName]) {
44
- styledText = colorMap[colorName](styledText);
45
- }
46
- if (typographyName && typographyMap[typographyName]) {
47
- styledText = typographyMap[typographyName](styledText);
48
- }
49
- return styledText;
50
- }
51
- export const bar = ({
52
- borderColor = "dim"
53
- } = {}) => {
54
- if (borderColor.endsWith("Gradient")) {
55
- console.error(
56
- "Gradient colors are not supported for bars. Please use a solid color instead."
57
- );
58
- return colorMap.dim(symbols.middle);
59
- }
60
- return colorMap[borderColor](symbols.middle);
61
- };
62
- function countLines(text) {
63
- return text.split("\n").length;
64
- }
65
- function getColoredSymbol(customSymbol, symbolName, symbolColor) {
66
- if (customSymbol) {
67
- return symbolColor && colorMap[symbolColor] ? colorMap[symbolColor](customSymbol) : customSymbol;
68
- }
69
- if (symbolName && symbols[symbolName]) {
70
- return symbolColor && colorMap[symbolColor] ? colorMap[symbolColor](symbols[symbolName]) : symbols[symbolName];
71
- }
72
- return void 0;
73
- }
74
- function formatTitle(opts, borderTwoSpaces, borderError) {
75
- let formattedTitle = "";
76
- if (!opts.title) return formattedTitle;
77
- const wrappedOrStyledTitle = wrapThenStyle(
78
- opts.title,
79
- opts.wrapTitle ?? true,
80
- opts.titleTypography ?? "bold",
81
- opts.titleColor ?? "cyan",
82
- opts.titleVariant,
83
- opts.borderColor
84
- );
85
- formattedTitle += wrappedOrStyledTitle;
86
- if (opts.hint) {
87
- const hintColor = opts.hintPlaceholderColor ?? "blue";
88
- const wrappedHint = wrapThenStyle(
89
- opts.hint,
90
- opts.wrapTitle ?? true,
91
- // same wrap logic as title by default
92
- opts.hintTypography ?? "italic",
93
- hintColor,
94
- void 0,
95
- opts.borderColor
96
- );
97
- formattedTitle += `
98
- ${borderTwoSpaces}${wrappedHint}`;
99
- }
100
- if (opts.placeholder && opts.type === "M_GENERAL") {
101
- const placeHolderColor = opts.hintPlaceholderColor ?? "blue";
102
- formattedTitle += `
103
- ${borderTwoSpaces}${colorMap[placeHolderColor](opts.placeholder)}`;
104
- }
105
- if (opts.errorMessage) {
106
- const formattedError = applyStyles(
107
- opts.errorMessage,
108
- "red",
109
- "bold",
110
- void 0,
111
- opts.borderColor
112
- );
113
- formattedTitle += `
114
- ${borderError} ${formattedError}`;
115
- }
116
- return formattedTitle;
117
- }
118
- function formatContent(opts) {
119
- if (!opts.content) return "";
120
- return wrapThenStyle(
121
- opts.content,
122
- opts.wrapContent ?? true,
123
- opts.contentTypography ?? "italic",
124
- opts.contentColor ?? "dim",
125
- opts.contentVariant,
126
- opts.borderColor
127
- );
128
- }
129
- export function fmt(opts) {
130
- if (!opts.borderColor) {
131
- opts.borderColor = "dim";
132
- }
133
- const borderColored = applyStyles(symbols.middle, opts.borderColor);
134
- const borderError = applyStyles(symbols.middle, "red");
135
- const borderTwoSpaces = `${borderColored} `;
136
- const prefixStartLine = opts.borderColor ? colorMap[opts.borderColor](symbols.start + symbols.line) : symbols.start + symbols.line;
137
- const prefixEndLine = opts.borderColor ? colorMap[opts.borderColor](symbols.end + symbols.line) : symbols.end + symbols.line;
138
- const lineLength = opts.horizontalLineLength === 0 ? getExactTerminalWidth() - 3 : opts.horizontalLineLength ?? getExactTerminalWidth() - 3;
139
- const suffixStartLine = opts.borderColor ? colorMap[opts.borderColor](`${symbols.line.repeat(lineLength)}\u22B1`) : `${symbols.line.repeat(lineLength)}\u22B1`;
140
- const suffixEndLine = opts.borderColor ? colorMap[opts.borderColor](`${symbols.line.repeat(lineLength)}\u22B1`) : `${symbols.line.repeat(lineLength)}\u22B1`;
141
- const computedSymbol = getColoredSymbol(opts.customSymbol, opts.symbol, opts.symbolColor) ?? re.green(symbols.step_active);
142
- const MESSAGE_CONFIG_MAP = {
143
- M_NULL: {
144
- symbol: "",
145
- prefix: borderTwoSpaces,
146
- suffix: "",
147
- newLineBefore: opts.addNewLineBefore ?? false,
148
- newLineAfter: opts.addNewLineAfter ?? false
149
- },
150
- M_BAR: {
151
- symbol: "",
152
- prefix: "",
153
- suffix: "",
154
- newLineBefore: false,
155
- newLineAfter: false
156
- },
157
- M_INFO_NULL: {
158
- symbol: "",
159
- prefix: borderTwoSpaces,
160
- suffix: "",
161
- newLineBefore: opts.addNewLineBefore ?? false,
162
- newLineAfter: opts.addNewLineAfter ?? false
163
- },
164
- M_START: {
165
- symbol: "",
166
- prefix: "",
167
- suffix: `
168
- ${borderTwoSpaces}`,
169
- newLineBefore: opts.addNewLineBefore ?? false,
170
- newLineAfter: opts.addNewLineAfter ?? false
171
- },
172
- M_MIDDLE: {
173
- symbol: "",
174
- prefix: borderTwoSpaces,
175
- suffix: "",
176
- newLineBefore: opts.addNewLineBefore ?? false,
177
- newLineAfter: opts.addNewLineAfter ?? false
178
- },
179
- M_GENERAL: {
180
- symbol: computedSymbol,
181
- prefix: borderTwoSpaces,
182
- suffix: "",
183
- newLineBefore: opts.addNewLineBefore ?? false,
184
- newLineAfter: opts.addNewLineAfter ?? false
185
- },
186
- M_GENERAL_NULL: {
187
- symbol: "",
188
- prefix: borderTwoSpaces,
189
- suffix: opts.placeholder ? colorMap[opts.hintPlaceholderColor ?? "blue"](opts.placeholder) : "",
190
- newLineBefore: opts.addNewLineBefore ?? false,
191
- newLineAfter: opts.addNewLineAfter ?? false
192
- },
193
- M_INFO: {
194
- symbol: computedSymbol || re.green(symbols.info),
195
- prefix: borderTwoSpaces,
196
- suffix: "",
197
- newLineBefore: opts.addNewLineBefore ?? false,
198
- newLineAfter: opts.addNewLineAfter ?? true
199
- },
200
- M_ERROR: {
201
- symbol: computedSymbol || re.redBright(symbols.step_error),
202
- prefix: borderTwoSpaces,
203
- suffix: "",
204
- newLineBefore: opts.addNewLineBefore ?? false,
205
- newLineAfter: opts.addNewLineAfter ?? false
206
- },
207
- M_ERROR_NULL: {
208
- symbol: "",
209
- prefix: borderTwoSpaces,
210
- suffix: "",
211
- newLineBefore: opts.addNewLineBefore ?? false,
212
- newLineAfter: opts.addNewLineAfter ?? false
213
- },
214
- M_END: {
215
- symbol: "",
216
- prefix: "",
217
- suffix: "",
218
- newLineBefore: opts.addNewLineBefore ?? false,
219
- newLineAfter: opts.addNewLineAfter ?? false
220
- },
221
- M_NEWLINE: {
222
- symbol: "",
223
- prefix: borderTwoSpaces,
224
- suffix: "",
225
- newLineBefore: opts.addNewLineBefore ?? false,
226
- newLineAfter: opts.addNewLineAfter ?? false
227
- }
228
- };
229
- const config = MESSAGE_CONFIG_MAP[opts.type];
230
- if (!config) {
231
- throw new Error(`Invalid message type: ${opts.type}`);
232
- }
233
- const { symbol, suffix, newLineBefore, newLineAfter } = config;
234
- const finalTitle = formatTitle(opts, borderTwoSpaces, borderError);
235
- const finalContent = formatContent(opts);
236
- let text = "";
237
- if (opts.type === "M_BAR") {
238
- text = bar({ borderColor: opts.borderColor });
239
- } else {
240
- text = [finalTitle, finalContent].filter(Boolean).join("\n");
241
- }
242
- const fullText = [
243
- newLineBefore ? `
244
- ${borderTwoSpaces}` : "",
245
- text,
246
- newLineAfter ? `
247
- ${borderTwoSpaces}` : "",
248
- suffix
249
- ].filter(Boolean).join("");
250
- const lines = fullText.split("\n").map((line, index) => {
251
- if (opts.type === "M_START") {
252
- if (index === 0) {
253
- return `${prefixStartLine} ${line} ${suffixStartLine}`;
254
- }
255
- if (index === 1) {
256
- return borderTwoSpaces;
257
- }
258
- }
259
- if (opts.type === "M_END" && opts.border && index === 0) {
260
- if (!opts.title) return "";
261
- return `${bar({ borderColor: opts.borderColor ?? "dim" })} ${line}`;
262
- }
263
- if (!line.trim() || line.includes(symbols.middle)) {
264
- return line;
265
- }
266
- if (index === 0 && symbol) {
267
- return `${symbol} ${line}`;
268
- }
269
- return `${config.prefix}${line}`;
270
- });
271
- if (opts.type === "M_END" && opts.border) {
272
- lines.push(`${prefixEndLine}${suffixEndLine}
273
- `);
274
- }
275
- const finalText = lines.join("\n");
276
- const lineCount = countLines(finalText);
277
- return { text: finalText, lineCount };
278
- }
279
- const printedLineStack = [];
280
- export function msg(opts) {
281
- const { text, lineCount } = fmt(opts);
282
- if (opts.type === "M_BAR" && opts.noNewLine) {
283
- process.stdout.write(text);
284
- } else {
285
- process.stdout.write(`${text}
286
- `);
287
- }
288
- printedLineStack.push(
289
- opts.type === "M_BAR" && opts.noNewLine ? lineCount : lineCount + 1
290
- );
291
- }
292
- export function msgUndo(count = 1) {
293
- for (let i = 0; i < count; i++) {
294
- const linesToDelete = printedLineStack.pop();
295
- if (typeof linesToDelete === "number" && linesToDelete > 0) {
296
- deleteLastLines(linesToDelete);
297
- }
298
- }
299
- }
300
- export function msgUndoAll() {
301
- while (printedLineStack.length > 0) {
302
- const linesToDelete = printedLineStack.pop();
303
- if (typeof linesToDelete === "number" && linesToDelete > 0) {
304
- deleteLastLines(linesToDelete);
305
- }
306
- }
307
- }
308
- export function printLineBar(text, indent = 2) {
309
- if (text === "") {
310
- console.log(re.dim("\u2502"));
311
- } else {
312
- console.log(`${re.dim("\u2502")}${" ".repeat(indent)}${text}`);
313
- }
314
- }
@@ -1,5 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./terminal.js";
3
- export * from "./mapping.js";
4
- export * from "./variants.js";
5
- export * from "./messages.js";
@@ -1,5 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./terminal.js";
3
- export * from "./mapping.js";
4
- export * from "./variants.js";
5
- export * from "./messages.js";
@@ -1,15 +0,0 @@
1
- export declare function getTerminalHeight(): number;
2
- export declare function getExactTerminalWidth(): number;
3
- export declare function getTerminalWidth(terminalWidth?: number): number;
4
- /**
5
- * Force line returns at specific width. This function is ANSI code friendly and it'll
6
- * ignore invisible codes during width calculation.
7
- * @param {string} content
8
- * @return {string}
9
- */
10
- export declare function breakLines(content: string, terminalWidth?: number): string;
11
- export declare function removeCursor(): void;
12
- export declare function restoreCursor(): void;
13
- export declare function deleteLastLine(): void;
14
- export declare function deleteLastLines(count: number): void;
15
- export declare function countLines(text: string): number;