@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
@@ -1,57 +0,0 @@
1
- import ansiEscapes from "ansi-escapes";
2
- import { cursor } from "sisteransi";
3
- import terminalSize from "terminal-size";
4
- import wrapAnsi from "wrap-ansi";
5
- export function getTerminalHeight() {
6
- return terminalSize().rows ?? 24;
7
- }
8
- export function getExactTerminalWidth() {
9
- return terminalSize().columns ?? 80;
10
- }
11
- export function getTerminalWidth(terminalWidth = 0) {
12
- if (terminalWidth === 0) {
13
- terminalWidth = getExactTerminalWidth();
14
- }
15
- if (terminalWidth > 150) {
16
- return terminalWidth - 40;
17
- } else if (terminalWidth > 120) {
18
- return terminalWidth - 30;
19
- } else if (terminalWidth > 100) {
20
- return terminalWidth - 20;
21
- }
22
- return terminalWidth;
23
- }
24
- export function breakLines(content, terminalWidth = 0) {
25
- if (terminalWidth === 0) {
26
- terminalWidth = getTerminalWidth();
27
- }
28
- return content.split("\n").flatMap(
29
- (line) => wrapAnsi(line, terminalWidth, { trim: false, hard: true }).split("\n").map((str) => str.trimEnd())
30
- ).join("\n");
31
- }
32
- export function removeCursor() {
33
- process.stdout.write(cursor.hide);
34
- }
35
- export function restoreCursor() {
36
- process.stdout.write(cursor.show);
37
- }
38
- export function deleteLastLine() {
39
- process.stdout.write(ansiEscapes.cursorUp(1) + ansiEscapes.eraseLine);
40
- }
41
- export function deleteLastLines(count) {
42
- if (count <= 0) {
43
- console.error("Count is less than or equal to 0. Nothing to delete.");
44
- return;
45
- }
46
- process.stdout.write(ansiEscapes.eraseLines(count));
47
- }
48
- export function countLines(text) {
49
- const adjustedWidth = getTerminalWidth();
50
- const lines = text.split("\n");
51
- let lineCount = 0;
52
- for (const line of lines) {
53
- const wrapped = wrapAnsi(line, adjustedWidth, { hard: true });
54
- lineCount += wrapped.split("\n").length;
55
- }
56
- return lineCount;
57
- }
@@ -1,12 +0,0 @@
1
- export type MsgType = "M_NULL" | "M_INFO_NULL" | "M_START" | "M_MIDDLE" | "M_GENERAL" | "M_GENERAL_NULL" | "M_INFO" | "M_ERROR" | "M_ERROR_NULL" | "M_END" | "M_NEWLINE" | "M_BAR";
2
- export type TypographyName = "bold" | "strikethrough" | "underline" | "italic" | "none";
3
- export type BorderColorName = "reset" | "inverse" | "dim" | "black" | "red" | "redBright" | "green" | "greenBright" | "yellow" | "yellowBright" | "blue" | "blueBright" | "magenta" | "magentaBright" | "cyan" | "cyanBright" | "bgCyan" | "bgCyanBright" | "white" | "gray";
4
- export type ColorName = BorderColorName | "gradientGradient" | "rainbowGradient" | "cristalGradient" | "mindGradient" | "passionGradient" | "viceGradient" | "retroGradient" | "none";
5
- export type MsgConfig = {
6
- symbol: string;
7
- prefix?: string;
8
- color?: (text: string) => string;
9
- newLineBefore?: boolean;
10
- newLineAfter?: boolean;
11
- suffix?: string;
12
- };
File without changes
@@ -1,12 +0,0 @@
1
- import type { ColorName } from "./types.js";
2
- export declare const variantMap: {
3
- doubleBox: typeof createDoubleBox;
4
- };
5
- type ValidVariant = keyof typeof variantMap;
6
- export type VariantName = ValidVariant | "none";
7
- export declare function isValidVariant(variant: string | undefined): variant is ValidVariant;
8
- export declare function applyVariant(lines: string[] | string, variant?: VariantName, options?: {
9
- limit?: number;
10
- }, borderColor?: ColorName): Promise<string>;
11
- declare function createDoubleBox(lines: string[], limit?: number, borderColor?: ColorName): string;
12
- export {};
@@ -1,52 +0,0 @@
1
- import { colorMap } from "./mapping.js";
2
- export const variantMap = {
3
- // box: createBox,
4
- doubleBox: createDoubleBox
5
- // banner: createBanner,
6
- // underline: createUnderline,
7
- };
8
- export function isValidVariant(variant) {
9
- return variant !== void 0 && variant !== "none" && variant in variantMap;
10
- }
11
- export async function applyVariant(lines, variant, options, borderColor) {
12
- const linesArray = Array.isArray(lines) ? lines : [lines];
13
- switch (variant) {
14
- // case "box":
15
- // return createBox(linesArray, options?.limit);
16
- case "doubleBox":
17
- return createDoubleBox(linesArray, options?.limit, borderColor);
18
- // case "banner":
19
- // return createBanner(linesArray);
20
- // case "underline":
21
- // return createUnderline(linesArray);
22
- default:
23
- return linesArray.join("\n");
24
- }
25
- }
26
- function createDoubleBox(lines, limit, borderColor) {
27
- const processedLines = processLines(lines, limit);
28
- const maxLength = Math.max(...processedLines.map((line) => line.length));
29
- const indentation = "";
30
- if (borderColor === void 0) {
31
- borderColor = "dim";
32
- }
33
- const topBorder = borderColor ? colorMap[borderColor](`${"\u2550".repeat(maxLength)}\u2557`) : `${"\u2550".repeat(maxLength)}\u2557`;
34
- const bottomBorder = borderColor ? colorMap[borderColor](`${indentation}\u255A${"\u2550".repeat(maxLength + 2)}\u255D`) : `${indentation}\u255A${"\u2550".repeat(maxLength + 2)}\u255D`;
35
- const middle = processedLines.map((line, index) => {
36
- const lineIndentation = index === 0 ? indentation : indentation + " ";
37
- return `${lineIndentation}${borderColor ? colorMap[borderColor]("\u2551") : "\u2551"} ${colorMap[borderColor](line.padEnd(maxLength))} ${borderColor ? colorMap[borderColor]("\u2551") : "\u2551"}`;
38
- }).join("\n");
39
- return `${topBorder}
40
- ${middle}
41
- ${bottomBorder}`;
42
- }
43
- function processLines(lines, limit) {
44
- const linesArray = Array.isArray(lines) ? lines : [lines];
45
- return linesArray.map((line) => {
46
- let truncatedLine = line;
47
- if (limit && line.length > limit) {
48
- truncatedLine = `${line.slice(0, limit - 3)}...`;
49
- }
50
- return truncatedLine.padEnd(limit || truncatedLine.length);
51
- });
52
- }
@@ -1,5 +0,0 @@
1
- export { LogLevels, LogTypes } from "../../components/levels/levels.js";
2
- export { RelinkaInterface } from "../../components/relinka/relinka.js";
3
- export type * from "../../types/mod.js";
4
- export type { RelinkaInstance } from "../../components/relinka/relinka.js";
5
- export type { LogLevel, LogType } from "../../components/levels/levels.js";
@@ -1,2 +0,0 @@
1
- export { LogLevels, LogTypes } from "../../components/levels/levels.js";
2
- export { RelinkaInterface } from "../../components/relinka/relinka.js";
@@ -1,12 +0,0 @@
1
- export type MessageKind = "log" | "info" | "warn" | "error" | "success";
2
- export type VerboseKind = `${MessageKind}-verbose`;
3
- export type AllKinds = MessageKind | VerboseKind;
4
- export type MessageConfig = {
5
- type: "M_INFO" | "M_ERROR";
6
- titleColor?: "retroGradient" | "viceGradient" | "yellowBright";
7
- titleTypography?: "bold";
8
- contentColor?: "dim";
9
- contentTypography?: "italic";
10
- };
11
- export declare const relinka: (kind: AllKinds, title: string, content?: string, hint?: string) => void;
12
- export declare const throwError: (error: unknown) => never;
@@ -1,52 +0,0 @@
1
- import { msg } from "../../main.js";
2
- const verboseLogging = false;
3
- const MESSAGE_CONFIGS = {
4
- log: {
5
- type: "M_INFO",
6
- titleColor: "retroGradient",
7
- titleTypography: "bold"
8
- },
9
- info: {
10
- type: "M_INFO",
11
- titleColor: "retroGradient",
12
- titleTypography: "bold"
13
- },
14
- success: {
15
- type: "M_INFO",
16
- titleColor: "viceGradient",
17
- titleTypography: "bold"
18
- },
19
- warn: {
20
- type: "M_ERROR",
21
- titleColor: "yellowBright",
22
- titleTypography: "bold"
23
- },
24
- error: {
25
- type: "M_ERROR",
26
- titleColor: "yellowBright",
27
- titleTypography: "bold"
28
- }
29
- };
30
- export const relinka = (kind, title, content, hint) => {
31
- const isVerbose = kind.endsWith("-verbose");
32
- const baseKind = isVerbose ? kind.replace("-verbose", "") : kind;
33
- if (isVerbose && !verboseLogging) {
34
- return;
35
- }
36
- const config = MESSAGE_CONFIGS[baseKind];
37
- msg({
38
- ...config,
39
- title: isVerbose ? `[debug] ${title}` : title,
40
- content: content ?? "",
41
- contentColor: "dim",
42
- contentTypography: "italic",
43
- hint: hint ?? ""
44
- });
45
- };
46
- export const throwError = (error) => {
47
- msg({
48
- type: "M_ERROR",
49
- title: error instanceof Error ? `\u{1F914} Failed to set up the project: ${error.message}` : "\u{1F914} An unknown error occurred."
50
- });
51
- process.exit(1);
52
- };
@@ -1,3 +0,0 @@
1
- export * from "../utils/box.js";
2
- export * from "../utils/deprecatedColors.js";
3
- export { stripAnsi, centerAlign, rightAlign, leftAlign, align, } from "../utils/string.js";
@@ -1,9 +0,0 @@
1
- export * from "../utils/box.js";
2
- export * from "../utils/deprecatedColors.js";
3
- export {
4
- stripAnsi,
5
- centerAlign,
6
- rightAlign,
7
- leftAlign,
8
- align
9
- } from "../utils/string.js";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes