@listr2/manager 3.0.0-beta.3 → 3.0.1

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.
@@ -0,0 +1,39 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target, mod));
25
+
26
+ //#endregion
27
+
28
+ Object.defineProperty(exports, '__commonJS', {
29
+ enumerable: true,
30
+ get: function () {
31
+ return __commonJS;
32
+ }
33
+ });
34
+ Object.defineProperty(exports, '__toESM', {
35
+ enumerable: true,
36
+ get: function () {
37
+ return __toESM;
38
+ }
39
+ });
@@ -0,0 +1,27 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target, mod));
25
+
26
+ //#endregion
27
+ export { __commonJS, __toESM };
@@ -0,0 +1,125 @@
1
+ const require_string_width = require('./string-width-fWmCaoVR.cjs');
2
+
3
+ //#region ../../node_modules/.pnpm/is-fullwidth-code-point@4.0.0/node_modules/is-fullwidth-code-point/index.js
4
+ function isFullwidthCodePoint(codePoint) {
5
+ if (!Number.isInteger(codePoint)) return false;
6
+ return codePoint >= 4352 && (codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || 12880 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65131 || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 262141);
7
+ }
8
+
9
+ //#endregion
10
+ //#region ../../node_modules/.pnpm/slice-ansi@5.0.0/node_modules/slice-ansi/index.js
11
+ const astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/;
12
+ const ESCAPES = ["\x1B", "›"];
13
+ const wrapAnsi = (code) => `${ESCAPES[0]}[${code}m`;
14
+ const checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => {
15
+ let output = [];
16
+ ansiCodes = [...ansiCodes];
17
+ for (let ansiCode of ansiCodes) {
18
+ const ansiCodeOrigin = ansiCode;
19
+ if (ansiCode.includes(";")) ansiCode = ansiCode.split(";")[0][0] + "0";
20
+ const item = require_string_width.ansi_styles_default.codes.get(Number.parseInt(ansiCode, 10));
21
+ if (item) {
22
+ const indexEscape = ansiCodes.indexOf(item.toString());
23
+ if (indexEscape === -1) output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin));
24
+ else ansiCodes.splice(indexEscape, 1);
25
+ } else if (isEscapes) {
26
+ output.push(wrapAnsi(0));
27
+ break;
28
+ } else output.push(wrapAnsi(ansiCodeOrigin));
29
+ }
30
+ if (isEscapes) {
31
+ output = output.filter((element, index) => output.indexOf(element) === index);
32
+ if (endAnsiCode !== void 0) {
33
+ const fistEscapeCode = wrapAnsi(require_string_width.ansi_styles_default.codes.get(Number.parseInt(endAnsiCode, 10)));
34
+ output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []);
35
+ }
36
+ }
37
+ return output.join("");
38
+ };
39
+ function sliceAnsi(string, begin, end) {
40
+ const characters = [...string];
41
+ const ansiCodes = [];
42
+ let stringEnd = typeof end === "number" ? end : characters.length;
43
+ let isInsideEscape = false;
44
+ let ansiCode;
45
+ let visible = 0;
46
+ let output = "";
47
+ for (const [index, character] of characters.entries()) {
48
+ let leftEscape = false;
49
+ if (ESCAPES.includes(character)) {
50
+ const code = /\d[^m]*/.exec(string.slice(index, index + 18));
51
+ ansiCode = code && code.length > 0 ? code[0] : void 0;
52
+ if (visible < stringEnd) {
53
+ isInsideEscape = true;
54
+ if (ansiCode !== void 0) ansiCodes.push(ansiCode);
55
+ }
56
+ } else if (isInsideEscape && character === "m") {
57
+ isInsideEscape = false;
58
+ leftEscape = true;
59
+ }
60
+ if (!isInsideEscape && !leftEscape) visible++;
61
+ if (!astralRegex.test(character) && isFullwidthCodePoint(character.codePointAt())) {
62
+ visible++;
63
+ if (typeof end !== "number") stringEnd++;
64
+ }
65
+ if (visible > begin && visible <= stringEnd) output += character;
66
+ else if (visible === begin && !isInsideEscape && ansiCode !== void 0) output = checkAnsi(ansiCodes);
67
+ else if (visible >= stringEnd) {
68
+ output += checkAnsi(ansiCodes, true, ansiCode);
69
+ break;
70
+ }
71
+ }
72
+ return output;
73
+ }
74
+
75
+ //#endregion
76
+ //#region ../../node_modules/.pnpm/cli-truncate@4.0.0/node_modules/cli-truncate/index.js
77
+ function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
78
+ if (string.charAt(wantedIndex) === " ") return wantedIndex;
79
+ const direction = shouldSearchRight ? 1 : -1;
80
+ for (let index = 0; index <= 3; index++) {
81
+ const finalIndex = wantedIndex + index * direction;
82
+ if (string.charAt(finalIndex) === " ") return finalIndex;
83
+ }
84
+ return wantedIndex;
85
+ }
86
+ function cliTruncate(text, columns, options = {}) {
87
+ const { position = "end", space = false, preferTruncationOnSpace = false } = options;
88
+ let { truncationCharacter = "…" } = options;
89
+ if (typeof text !== "string") throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
90
+ if (typeof columns !== "number") throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
91
+ if (columns < 1) return "";
92
+ if (columns === 1) return truncationCharacter;
93
+ const length = require_string_width.stringWidth(text);
94
+ if (length <= columns) return text;
95
+ if (position === "start") {
96
+ if (preferTruncationOnSpace) {
97
+ const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
98
+ return truncationCharacter + sliceAnsi(text, nearestSpace, length).trim();
99
+ }
100
+ if (space === true) truncationCharacter += " ";
101
+ return truncationCharacter + sliceAnsi(text, length - columns + require_string_width.stringWidth(truncationCharacter), length);
102
+ }
103
+ if (position === "middle") {
104
+ if (space === true) truncationCharacter = ` ${truncationCharacter} `;
105
+ const half = Math.floor(columns / 2);
106
+ if (preferTruncationOnSpace) {
107
+ const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
108
+ const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
109
+ return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
110
+ }
111
+ return sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + require_string_width.stringWidth(truncationCharacter), length);
112
+ }
113
+ if (position === "end") {
114
+ if (preferTruncationOnSpace) {
115
+ const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
116
+ return sliceAnsi(text, 0, nearestSpace) + truncationCharacter;
117
+ }
118
+ if (space === true) truncationCharacter = ` ${truncationCharacter}`;
119
+ return sliceAnsi(text, 0, columns - require_string_width.stringWidth(truncationCharacter)) + truncationCharacter;
120
+ }
121
+ throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
122
+ }
123
+
124
+ //#endregion
125
+ exports.default = cliTruncate;
@@ -0,0 +1,125 @@
1
+ import { ansi_styles_default, stringWidth } from "./string-width-BnS-vObO.js";
2
+
3
+ //#region ../../node_modules/.pnpm/is-fullwidth-code-point@4.0.0/node_modules/is-fullwidth-code-point/index.js
4
+ function isFullwidthCodePoint(codePoint) {
5
+ if (!Number.isInteger(codePoint)) return false;
6
+ return codePoint >= 4352 && (codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || 12880 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65131 || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 262141);
7
+ }
8
+
9
+ //#endregion
10
+ //#region ../../node_modules/.pnpm/slice-ansi@5.0.0/node_modules/slice-ansi/index.js
11
+ const astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/;
12
+ const ESCAPES = ["\x1B", "›"];
13
+ const wrapAnsi = (code) => `${ESCAPES[0]}[${code}m`;
14
+ const checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => {
15
+ let output = [];
16
+ ansiCodes = [...ansiCodes];
17
+ for (let ansiCode of ansiCodes) {
18
+ const ansiCodeOrigin = ansiCode;
19
+ if (ansiCode.includes(";")) ansiCode = ansiCode.split(";")[0][0] + "0";
20
+ const item = ansi_styles_default.codes.get(Number.parseInt(ansiCode, 10));
21
+ if (item) {
22
+ const indexEscape = ansiCodes.indexOf(item.toString());
23
+ if (indexEscape === -1) output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin));
24
+ else ansiCodes.splice(indexEscape, 1);
25
+ } else if (isEscapes) {
26
+ output.push(wrapAnsi(0));
27
+ break;
28
+ } else output.push(wrapAnsi(ansiCodeOrigin));
29
+ }
30
+ if (isEscapes) {
31
+ output = output.filter((element, index) => output.indexOf(element) === index);
32
+ if (endAnsiCode !== void 0) {
33
+ const fistEscapeCode = wrapAnsi(ansi_styles_default.codes.get(Number.parseInt(endAnsiCode, 10)));
34
+ output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []);
35
+ }
36
+ }
37
+ return output.join("");
38
+ };
39
+ function sliceAnsi(string, begin, end) {
40
+ const characters = [...string];
41
+ const ansiCodes = [];
42
+ let stringEnd = typeof end === "number" ? end : characters.length;
43
+ let isInsideEscape = false;
44
+ let ansiCode;
45
+ let visible = 0;
46
+ let output = "";
47
+ for (const [index, character] of characters.entries()) {
48
+ let leftEscape = false;
49
+ if (ESCAPES.includes(character)) {
50
+ const code = /\d[^m]*/.exec(string.slice(index, index + 18));
51
+ ansiCode = code && code.length > 0 ? code[0] : void 0;
52
+ if (visible < stringEnd) {
53
+ isInsideEscape = true;
54
+ if (ansiCode !== void 0) ansiCodes.push(ansiCode);
55
+ }
56
+ } else if (isInsideEscape && character === "m") {
57
+ isInsideEscape = false;
58
+ leftEscape = true;
59
+ }
60
+ if (!isInsideEscape && !leftEscape) visible++;
61
+ if (!astralRegex.test(character) && isFullwidthCodePoint(character.codePointAt())) {
62
+ visible++;
63
+ if (typeof end !== "number") stringEnd++;
64
+ }
65
+ if (visible > begin && visible <= stringEnd) output += character;
66
+ else if (visible === begin && !isInsideEscape && ansiCode !== void 0) output = checkAnsi(ansiCodes);
67
+ else if (visible >= stringEnd) {
68
+ output += checkAnsi(ansiCodes, true, ansiCode);
69
+ break;
70
+ }
71
+ }
72
+ return output;
73
+ }
74
+
75
+ //#endregion
76
+ //#region ../../node_modules/.pnpm/cli-truncate@4.0.0/node_modules/cli-truncate/index.js
77
+ function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
78
+ if (string.charAt(wantedIndex) === " ") return wantedIndex;
79
+ const direction = shouldSearchRight ? 1 : -1;
80
+ for (let index = 0; index <= 3; index++) {
81
+ const finalIndex = wantedIndex + index * direction;
82
+ if (string.charAt(finalIndex) === " ") return finalIndex;
83
+ }
84
+ return wantedIndex;
85
+ }
86
+ function cliTruncate(text, columns, options = {}) {
87
+ const { position = "end", space = false, preferTruncationOnSpace = false } = options;
88
+ let { truncationCharacter = "…" } = options;
89
+ if (typeof text !== "string") throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
90
+ if (typeof columns !== "number") throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
91
+ if (columns < 1) return "";
92
+ if (columns === 1) return truncationCharacter;
93
+ const length = stringWidth(text);
94
+ if (length <= columns) return text;
95
+ if (position === "start") {
96
+ if (preferTruncationOnSpace) {
97
+ const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
98
+ return truncationCharacter + sliceAnsi(text, nearestSpace, length).trim();
99
+ }
100
+ if (space === true) truncationCharacter += " ";
101
+ return truncationCharacter + sliceAnsi(text, length - columns + stringWidth(truncationCharacter), length);
102
+ }
103
+ if (position === "middle") {
104
+ if (space === true) truncationCharacter = ` ${truncationCharacter} `;
105
+ const half = Math.floor(columns / 2);
106
+ if (preferTruncationOnSpace) {
107
+ const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
108
+ const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
109
+ return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
110
+ }
111
+ return sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + stringWidth(truncationCharacter), length);
112
+ }
113
+ if (position === "end") {
114
+ if (preferTruncationOnSpace) {
115
+ const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
116
+ return sliceAnsi(text, 0, nearestSpace) + truncationCharacter;
117
+ }
118
+ if (space === true) truncationCharacter = ` ${truncationCharacter}`;
119
+ return sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter;
120
+ }
121
+ throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
122
+ }
123
+
124
+ //#endregion
125
+ export { cliTruncate as default };