@reliverse/relinka 1.4.5 → 1.4.7

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 (47) hide show
  1. package/bin/impl.d.ts +1 -1
  2. package/bin/impl.js +8 -2
  3. package/bin/mod.d.ts +0 -22
  4. package/bin/mod.js +0 -50
  5. package/package.json +17 -17
  6. package/bin/deprecated/components/levels/levels.d.ts +0 -13
  7. package/bin/deprecated/components/levels/levels.js +0 -68
  8. package/bin/deprecated/components/modes/basic.d.ts +0 -19
  9. package/bin/deprecated/components/modes/basic.js +0 -20
  10. package/bin/deprecated/components/modes/browser.d.ts +0 -19
  11. package/bin/deprecated/components/modes/browser.js +0 -13
  12. package/bin/deprecated/components/modes/shared.d.ts +0 -2
  13. package/bin/deprecated/components/modes/shared.js +0 -1
  14. package/bin/deprecated/components/relinka-deprecated/logger.d.ts +0 -5
  15. package/bin/deprecated/components/relinka-deprecated/logger.js +0 -5
  16. package/bin/deprecated/components/relinka-deprecated/mod.d.ts +0 -20
  17. package/bin/deprecated/components/relinka-deprecated/mod.js +0 -33
  18. package/bin/deprecated/components/relinka-deprecated/relinka.d.ts +0 -140
  19. package/bin/deprecated/components/relinka-deprecated/relinka.js +0 -381
  20. package/bin/deprecated/components/reporters/basic.d.ts +0 -11
  21. package/bin/deprecated/components/reporters/basic.js +0 -53
  22. package/bin/deprecated/components/reporters/browser.d.ts +0 -10
  23. package/bin/deprecated/components/reporters/browser.js +0 -56
  24. package/bin/deprecated/components/reporters/fancy.d.ts +0 -10
  25. package/bin/deprecated/components/reporters/fancy.js +0 -104
  26. package/bin/deprecated/impl-old.d.ts +0 -0
  27. package/bin/deprecated/impl-old.js +0 -0
  28. package/bin/deprecated/types.d.ts +0 -161
  29. package/bin/deprecated/types.js +0 -0
  30. package/bin/deprecated/utils/box.d.ts +0 -114
  31. package/bin/deprecated/utils/box.js +0 -145
  32. package/bin/deprecated/utils/deprecatedColors.d.ts +0 -69
  33. package/bin/deprecated/utils/deprecatedColors.js +0 -78
  34. package/bin/deprecated/utils/error.d.ts +0 -6
  35. package/bin/deprecated/utils/error.js +0 -6
  36. package/bin/deprecated/utils/format-new.d.ts +0 -15
  37. package/bin/deprecated/utils/format-new.js +0 -13
  38. package/bin/deprecated/utils/format.d.ts +0 -14
  39. package/bin/deprecated/utils/format.js +0 -26
  40. package/bin/deprecated/utils/log.d.ts +0 -13
  41. package/bin/deprecated/utils/log.js +0 -15
  42. package/bin/deprecated/utils/stream.d.ts +0 -14
  43. package/bin/deprecated/utils/stream.js +0 -4
  44. package/bin/deprecated/utils/string.d.ts +0 -50
  45. package/bin/deprecated/utils/string.js +0 -53
  46. package/bin/deprecated/utils/tree.d.ts +0 -41
  47. package/bin/deprecated/utils/tree.js +0 -37
@@ -1,14 +0,0 @@
1
- /**
2
- * Writes data to a specified NodeJS writable stream. This function supports streams that have a custom
3
- * `__write' method, and will fall back to the default `write' method if `__write' is not present.
4
- *
5
- * @param {any} data - The data to write to the stream. This can be a string, a buffer, or any data type
6
- * supported by the stream's `write' or `__write' method.
7
- * @param {NodeJS.WriteStream} stream - The writable stream to write the data to. This stream
8
- * must implement the `write' method, and can optionally implement a custom `__write' method.
9
- * @returns {boolean} `true` if the data has been completely processed by the write operation,
10
- * indicating that further writes can be performed immediately. Returns `false` if the data is
11
- * buffered by the stream, indicating that the `drain` event should be waited for before writing
12
- * more data.
13
- */
14
- export declare function writeStream(data: any, stream: NodeJS.WriteStream): any;
@@ -1,4 +0,0 @@
1
- export function writeStream(data, stream) {
2
- const write = stream.__write || stream.write;
3
- return write.call(stream, data);
4
- }
@@ -1,50 +0,0 @@
1
- /**
2
- * Removes ANSI escape codes from a given string. This is particularly useful for
3
- * processing text that contains formatting codes, such as colors or styles, so that the
4
- * the raw text without any visual formatting.
5
- *
6
- * @param {string} text - The text string from which to strip the ANSI escape codes.
7
- * @returns {string} The text without ANSI escape codes.
8
- */
9
- export declare function stripAnsi(text: string): string;
10
- /**
11
- * Centers a string within a specified total width, padding it with spaces or another specified character.
12
- * If the string is longer than the total width, it is returned as is.
13
- *
14
- * @param {string} str - The string to centre.
15
- * @param {number} len - The total width in which to centre the string.
16
- * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
17
- * @returns {string} The centred string.
18
- */
19
- export declare function centerAlign(str: string, len: number, space?: string): string;
20
- /**
21
- * Right-justifies a string within a given total width, padding it with whitespace or another specified character.
22
- * If the string is longer than the total width, it is returned as is.
23
- *
24
- * @param {string} str - The string to right-justify.
25
- * @param {number} len - The total width to align the string.
26
- * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
27
- * @returns {string} The right-justified string.
28
- */
29
- export declare function rightAlign(str: string, len: number, space?: string): string;
30
- /**
31
- * Left-aligns a string within a given total width, padding it with whitespace or another specified character on the right.
32
- * If the string is longer than the total width, it is returned as is.
33
- *
34
- * @param {string} str - The string to align left.
35
- * @param {number} len - The total width to align the string.
36
- * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
37
- * @returns {string} The left-justified string.
38
- */
39
- export declare function leftAlign(str: string, len: number, space?: string): string;
40
- /**
41
- * Aligns a string (left, right, or centre) within a given total width, padding it with spaces or another specified character.
42
- * If the string is longer than the total width, it is returned as is. This function acts as a wrapper for individual alignment functions.
43
- *
44
- * @param {"left" | "right" | "centre"} alignment - The desired alignment of the string.
45
- * @param {string} str - The string to align.
46
- * @param {number} len - The total width in which to align the string.
47
- * @param {string} [space=" "] - The character to use for padding. Defaults to a space.
48
- * @returns {string} The aligned string, according to the given alignment.
49
- */
50
- export declare function align(alignment: "left" | "right" | "center", str: string, len: number, space?: string): string;
@@ -1,53 +0,0 @@
1
- const ansiRegex = [
2
- String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
3
- String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
4
- ].join("|");
5
- export function stripAnsi(text) {
6
- return text.replace(new RegExp(ansiRegex, "g"), "");
7
- }
8
- export function centerAlign(str, len, space = " ") {
9
- const free = len - str.length;
10
- if (free <= 0) {
11
- return str;
12
- }
13
- const freeLeft = Math.floor(free / 2);
14
- let _str = "";
15
- for (let i = 0; i < len; i++) {
16
- _str += i < freeLeft || i >= freeLeft + str.length ? space : str[i - freeLeft];
17
- }
18
- return _str;
19
- }
20
- export function rightAlign(str, len, space = " ") {
21
- const free = len - str.length;
22
- if (free <= 0) {
23
- return str;
24
- }
25
- let _str = "";
26
- for (let i = 0; i < len; i++) {
27
- _str += i < free ? space : str[i - free];
28
- }
29
- return _str;
30
- }
31
- export function leftAlign(str, len, space = " ") {
32
- let _str = "";
33
- for (let i = 0; i < len; i++) {
34
- _str += i < str.length ? str[i] : space;
35
- }
36
- return _str;
37
- }
38
- export function align(alignment, str, len, space = " ") {
39
- switch (alignment) {
40
- case "left": {
41
- return leftAlign(str, len, space);
42
- }
43
- case "right": {
44
- return rightAlign(str, len, space);
45
- }
46
- case "center": {
47
- return centerAlign(str, len, space);
48
- }
49
- default: {
50
- return str;
51
- }
52
- }
53
- }
@@ -1,41 +0,0 @@
1
- import { type ColorName } from "./deprecatedColors.js";
2
- export type TreeItemObject = {
3
- /**
4
- * Text of the item
5
- */
6
- text: string;
7
- /**
8
- * Children of the item
9
- */
10
- children?: TreeItem[];
11
- /**
12
- * Color of the item
13
- */
14
- color?: ColorName;
15
- };
16
- export type TreeItem = string | TreeItemObject;
17
- export type TreeOptions = {
18
- /**
19
- * Color of the tree
20
- */
21
- color?: ColorName;
22
- /**
23
- * Prefix of the tree
24
- *
25
- * @default " "
26
- */
27
- prefix?: string;
28
- };
29
- /**
30
- * Formats a hierarchical list of items into a string representing a tree structure.
31
- * Each item in the tree can be a simple string or an object defining the text of the item,
32
- * optional children, and color. The tree structure can be customized with options
33
- * Specify the overall color and the prefix used for indentation and tree lines.
34
- *
35
- * @param {TreeItem[]} items - An array of items to include in the tree. Each item can be
36
- * either a string or an object with `text', `children' and `color' properties.
37
- * @param {TreeOptions} [options] - Optional settings to customize the appearance of the tree, including
38
- * the color of the tree text and the prefix for branches. See {@link TreeOptions}.
39
- * @returns {string} The formatted tree as a string, ready for printing to the console or elsewhere.
40
- */
41
- export declare function formatTree(items: TreeItem[], options?: TreeOptions): string;
@@ -1,37 +0,0 @@
1
- import { colorize } from "./deprecatedColors.js";
2
- export function formatTree(items, options) {
3
- options = {
4
- prefix: " ",
5
- ...options
6
- };
7
- const tree = _buildTree(items, options).join("");
8
- if (options?.color) {
9
- return colorize(options.color, tree);
10
- }
11
- return tree;
12
- }
13
- function _buildTree(items, options) {
14
- const chunks = [];
15
- const total = items.length - 1;
16
- for (let i = 0; i <= total; i++) {
17
- const item = items[i];
18
- const isLast = i === total;
19
- const prefix = isLast ? `${options?.prefix}\u2514\u2500` : `${options?.prefix}\u251C\u2500`;
20
- if (typeof item === "string") {
21
- chunks.push(`${prefix}${item}
22
- `);
23
- } else {
24
- const log = `${prefix}${item.text}
25
- `;
26
- chunks.push(item.color ? colorize(item.color, log) : log);
27
- if (item.children) {
28
- const _tree = _buildTree(item.children, {
29
- ...options,
30
- prefix: `${options?.prefix}${isLast ? " " : "\u2502 "}`
31
- });
32
- chunks.push(..._tree);
33
- }
34
- }
35
- }
36
- return chunks;
37
- }