@visulima/string 1.2.3 → 1.3.0
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.
- package/CHANGELOG.md +11 -0
- package/README.md +46 -0
- package/dist/case/camel-case.cjs +1 -59
- package/dist/case/camel-case.mjs +1 -57
- package/dist/case/capital-case.cjs +1 -51
- package/dist/case/capital-case.mjs +1 -49
- package/dist/case/constant-case.cjs +1 -11
- package/dist/case/constant-case.mjs +1 -9
- package/dist/case/dot-case.cjs +1 -11
- package/dist/case/dot-case.mjs +1 -9
- package/dist/case/flat-case.cjs +1 -11
- package/dist/case/flat-case.mjs +1 -9
- package/dist/case/flip-case.cjs +1 -61
- package/dist/case/flip-case.mjs +1 -57
- package/dist/case/identify-case.cjs +1 -69
- package/dist/case/identify-case.mjs +1 -67
- package/dist/case/index.cjs +1 -47
- package/dist/case/index.mjs +1 -20
- package/dist/case/kebab-case.cjs +1 -61
- package/dist/case/kebab-case.mjs +1 -57
- package/dist/case/lower-first.cjs +1 -13
- package/dist/case/lower-first.mjs +1 -11
- package/dist/case/no-case.cjs +1 -11
- package/dist/case/no-case.mjs +1 -9
- package/dist/case/pascal-case.cjs +1 -52
- package/dist/case/pascal-case.mjs +1 -50
- package/dist/case/pascal-snake-case.cjs +1 -32
- package/dist/case/pascal-snake-case.mjs +1 -30
- package/dist/case/path-case.cjs +1 -11
- package/dist/case/path-case.mjs +1 -9
- package/dist/case/sentence-case.cjs +1 -58
- package/dist/case/sentence-case.mjs +1 -56
- package/dist/case/snake-case.cjs +1 -11
- package/dist/case/snake-case.mjs +1 -9
- package/dist/case/split-by-case.cjs +1 -641
- package/dist/case/split-by-case.mjs +1 -637
- package/dist/case/title-case.cjs +1 -47
- package/dist/case/title-case.mjs +1 -45
- package/dist/case/train-case.cjs +1 -44
- package/dist/case/train-case.mjs +1 -42
- package/dist/case/upper-first.cjs +1 -13
- package/dist/case/upper-first.mjs +1 -11
- package/dist/get-string-truncated-width.cjs +1 -422
- package/dist/get-string-truncated-width.mjs +1 -418
- package/dist/get-string-width.cjs +1 -11
- package/dist/get-string-width.mjs +1 -7
- package/dist/index.cjs +1 -66
- package/dist/index.d.cts +12 -3
- package/dist/index.d.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.mjs +1 -29
- package/dist/outdent.cjs +1 -125
- package/dist/outdent.mjs +1 -121
- package/dist/packem_shared/LRUCache-Bjo6gsbC.mjs +1 -0
- package/dist/packem_shared/LRUCache-TYqfUYE5.cjs +1 -0
- package/dist/packem_shared/WrapMode-BL2dnSc8.cjs +8 -0
- package/dist/packem_shared/WrapMode-DxH5g69E.mjs +8 -0
- package/dist/packem_shared/alignText-BCKbnqhC.mjs +2 -0
- package/dist/packem_shared/alignText-CLZJuPP6.cjs +2 -0
- package/dist/packem_shared/constants-Cd17VNEv.mjs +1 -0
- package/dist/packem_shared/constants-D3K8u3G8.cjs +1 -0
- package/dist/packem_shared/generate-cache-key-BZf0GiMs.cjs +1 -0
- package/dist/packem_shared/generate-cache-key-DPByFaMH.mjs +1 -0
- package/dist/packem_shared/joinSegments-CDHNMXsF.cjs +1 -0
- package/dist/packem_shared/joinSegments-H7QJ7rwJ.mjs +1 -0
- package/dist/packem_shared/normalize-german-eszett-4k1qRtEP.mjs +1 -0
- package/dist/packem_shared/normalize-german-eszett-Bop4wOp9.cjs +1 -0
- package/dist/packem_shared/replaceString-Ce8TI_-L.cjs +1 -0
- package/dist/packem_shared/replaceString-D7R-5VFX.mjs +1 -0
- package/dist/packem_shared/slugify-B1vlQQO1.mjs +1 -0
- package/dist/packem_shared/slugify-CH3GI7E5.cjs +1 -0
- package/dist/packem_shared/transliterate-BXaP38Sh.mjs +5 -0
- package/dist/packem_shared/transliterate-CToQ-aeM.cjs +5 -0
- package/dist/slice.cjs +1 -419
- package/dist/slice.mjs +1 -415
- package/dist/test/utils.cjs +13 -74
- package/dist/test/utils.mjs +14 -69
- package/dist/test/vitest.cjs +1 -11
- package/dist/test/vitest.mjs +1 -7
- package/dist/truncate.cjs +1 -101
- package/dist/truncate.mjs +1 -97
- package/dist/utils.cjs +1 -65
- package/dist/utils.mjs +1 -56
- package/package.json +8 -1
- package/dist/packem_shared/LRUCache-Crb-m7cw.cjs +0 -53
- package/dist/packem_shared/LRUCache-udNErhWw.mjs +0 -51
- package/dist/packem_shared/WrapMode-BCVbMqYK.mjs +0 -545
- package/dist/packem_shared/WrapMode-DebG_Nll.cjs +0 -550
- package/dist/packem_shared/constants-6-GJ6zA-.cjs +0 -150
- package/dist/packem_shared/constants-CKdlkHVU.mjs +0 -99
- package/dist/packem_shared/generate-cache-key-D8f1auDB.cjs +0 -10
- package/dist/packem_shared/generate-cache-key-YSju5pj2.mjs +0 -8
- package/dist/packem_shared/joinSegments-BfSDBmPF.mjs +0 -46
- package/dist/packem_shared/joinSegments-HYXurfoq.cjs +0 -48
- package/dist/packem_shared/normalize-german-eszett-DJK0S2qj.cjs +0 -11
- package/dist/packem_shared/normalize-german-eszett-fpJ4lZL6.mjs +0 -9
- package/dist/packem_shared/replaceString-C7Dp5vAg.mjs +0 -200
- package/dist/packem_shared/replaceString-iYo1cDfZ.cjs +0 -202
- package/dist/packem_shared/slugify-SKjCL8DF.cjs +0 -50
- package/dist/packem_shared/slugify-pbxTlzeQ.mjs +0 -48
- package/dist/packem_shared/transliterate-4P32b49d.mjs +0 -47780
- package/dist/packem_shared/transliterate-CtOTNpLs.cjs +0 -47782
|
@@ -1,422 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
-
|
|
5
|
-
const constants = require('./packem_shared/constants-6-GJ6zA-.cjs');
|
|
6
|
-
|
|
7
|
-
var __defProp$2 = Object.defineProperty;
|
|
8
|
-
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
9
|
-
function isAmbiguous(x) {
|
|
10
|
-
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
11
|
-
}
|
|
12
|
-
__name$2(isAmbiguous, "isAmbiguous");
|
|
13
|
-
function isFullWidth(x) {
|
|
14
|
-
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
15
|
-
}
|
|
16
|
-
__name$2(isFullWidth, "isFullWidth");
|
|
17
|
-
function isWide(x) {
|
|
18
|
-
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
19
|
-
}
|
|
20
|
-
__name$2(isWide, "isWide");
|
|
21
|
-
function getCategory(x) {
|
|
22
|
-
if (isAmbiguous(x)) return "ambiguous";
|
|
23
|
-
if (isFullWidth(x)) return "fullwidth";
|
|
24
|
-
if (x === 8361 || x >= 65377 && x <= 65470 || x >= 65474 && x <= 65479 || x >= 65482 && x <= 65487 || x >= 65490 && x <= 65495 || x >= 65498 && x <= 65500 || x >= 65512 && x <= 65518) {
|
|
25
|
-
return "halfwidth";
|
|
26
|
-
}
|
|
27
|
-
if (x >= 32 && x <= 126 || x === 162 || x === 163 || x === 165 || x === 166 || x === 172 || x === 175 || x >= 10214 && x <= 10221 || x === 10629 || x === 10630) {
|
|
28
|
-
return "narrow";
|
|
29
|
-
}
|
|
30
|
-
if (isWide(x)) return "wide";
|
|
31
|
-
return "neutral";
|
|
32
|
-
}
|
|
33
|
-
__name$2(getCategory, "getCategory");
|
|
34
|
-
|
|
35
|
-
var __defProp$1 = Object.defineProperty;
|
|
36
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
37
|
-
function validate(codePoint) {
|
|
38
|
-
if (!Number.isSafeInteger(codePoint)) {
|
|
39
|
-
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
__name$1(validate, "validate");
|
|
43
|
-
function eastAsianWidthType(codePoint) {
|
|
44
|
-
validate(codePoint);
|
|
45
|
-
return getCategory(codePoint);
|
|
46
|
-
}
|
|
47
|
-
__name$1(eastAsianWidthType, "eastAsianWidthType");
|
|
48
|
-
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
49
|
-
validate(codePoint);
|
|
50
|
-
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
51
|
-
return 2;
|
|
52
|
-
}
|
|
53
|
-
return 1;
|
|
54
|
-
}
|
|
55
|
-
__name$1(eastAsianWidth, "eastAsianWidth");
|
|
56
|
-
|
|
57
|
-
var __defProp = Object.defineProperty;
|
|
58
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
59
|
-
const charWidthCache = /* @__PURE__ */ new Map();
|
|
60
|
-
const RE_LATIN_CHARS = /(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y;
|
|
61
|
-
const getCharType = /* @__PURE__ */ __name((codePoint) => {
|
|
62
|
-
if (codePoint >= 32 && codePoint <= 126) {
|
|
63
|
-
return "latin";
|
|
64
|
-
}
|
|
65
|
-
if (codePoint === 8203 || codePoint === 8204 || codePoint === 8205 || codePoint === 8288) {
|
|
66
|
-
return "zero";
|
|
67
|
-
}
|
|
68
|
-
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
69
|
-
return "control";
|
|
70
|
-
}
|
|
71
|
-
if (codePoint >= 160 && codePoint <= 255) {
|
|
72
|
-
return "latin";
|
|
73
|
-
}
|
|
74
|
-
if (codePoint >= 9472 && codePoint <= 9599) {
|
|
75
|
-
return "latin";
|
|
76
|
-
}
|
|
77
|
-
if (codePoint >= 4352 && codePoint <= 4607 || // Hangul Jamo
|
|
78
|
-
codePoint >= 11904 && codePoint <= 40959 || // CJK & radicals
|
|
79
|
-
codePoint >= 44032 && codePoint <= 55215 || // Hangul Syllables
|
|
80
|
-
codePoint >= 63744 && codePoint <= 64255 || // CJK Compatibility Ideographs
|
|
81
|
-
codePoint >= 65280 && codePoint <= 65519 && !(codePoint >= 65377 && codePoint <= 65439) || // Full-width Forms (excluding half-width katakana)
|
|
82
|
-
codePoint >= 12352 && codePoint <= 12543) {
|
|
83
|
-
return "wide";
|
|
84
|
-
}
|
|
85
|
-
if (codePoint === 8230) {
|
|
86
|
-
return "latin";
|
|
87
|
-
}
|
|
88
|
-
return "other";
|
|
89
|
-
}, "getCharType");
|
|
90
|
-
const getCachedCharWidth = /* @__PURE__ */ __name((codePoint, config) => {
|
|
91
|
-
const highBits = Math.floor(codePoint / 65536);
|
|
92
|
-
const lowBits = codePoint % 65536;
|
|
93
|
-
let lowMap = charWidthCache.get(highBits);
|
|
94
|
-
if (!lowMap) {
|
|
95
|
-
lowMap = /* @__PURE__ */ new Map();
|
|
96
|
-
charWidthCache.set(highBits, lowMap);
|
|
97
|
-
}
|
|
98
|
-
if (lowMap.has(lowBits)) {
|
|
99
|
-
return lowMap.get(lowBits);
|
|
100
|
-
}
|
|
101
|
-
let width;
|
|
102
|
-
if (getCharType(codePoint) === "latin") {
|
|
103
|
-
width = config.width.regular;
|
|
104
|
-
} else if (getCharType(codePoint) === "control") {
|
|
105
|
-
width = config.width.control;
|
|
106
|
-
} else if (getCharType(codePoint) === "wide") {
|
|
107
|
-
width = config.width.wide;
|
|
108
|
-
} else {
|
|
109
|
-
const eaw = eastAsianWidthType(codePoint);
|
|
110
|
-
switch (eaw) {
|
|
111
|
-
case "fullwidth": {
|
|
112
|
-
width = config.width.fullWidth;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
case "wide": {
|
|
116
|
-
width = config.width.wide;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case "ambiguous": {
|
|
120
|
-
width = config.width.ambiguousIsNarrow ? config.width.regular : config.width.wide;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
default: {
|
|
124
|
-
width = config.width.regular;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
lowMap.set(lowBits, width);
|
|
129
|
-
return width;
|
|
130
|
-
}, "getCachedCharWidth");
|
|
131
|
-
const isCombiningCharacter = /* @__PURE__ */ __name((codePoint) => {
|
|
132
|
-
if (codePoint >= 768 && codePoint <= 879 || // Combining Diacritical Marks
|
|
133
|
-
codePoint >= 6832 && codePoint <= 6911 || // Combining Diacritical Marks Extended
|
|
134
|
-
codePoint >= 7616 && codePoint <= 7679 || // Combining Diacritical Marks Supplement
|
|
135
|
-
codePoint >= 8400 && codePoint <= 8447 || // Combining Diacritical Marks for Symbols
|
|
136
|
-
codePoint >= 65056 && codePoint <= 65071) {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
if (codePoint >= 917760 && codePoint <= 917999 || // Variation Selectors Supplement
|
|
140
|
-
codePoint >= 65024 && codePoint <= 65039) {
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
if (codePoint >= 3633 && codePoint <= 3642 || // Thai vowel marks and tone marks
|
|
144
|
-
codePoint >= 3655 && codePoint <= 3662 || // Thai diacritics
|
|
145
|
-
codePoint >= 3761 && codePoint <= 3769 || // Lao vowel marks
|
|
146
|
-
codePoint >= 3771 && codePoint <= 3772 || // Lao vowel signs
|
|
147
|
-
codePoint >= 3784 && codePoint <= 3789) {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
if (codePoint >= 2304 && codePoint <= 2307 || // Devanagari signs
|
|
151
|
-
codePoint >= 2362 && codePoint <= 2383 || // Devanagari vowel signs and virama
|
|
152
|
-
codePoint >= 2385 && codePoint <= 2391 || // Devanagari stress marks
|
|
153
|
-
codePoint >= 2402 && codePoint <= 2403 || // Devanagari vowel signs
|
|
154
|
-
codePoint >= 2433 && codePoint <= 2435 || // Bengali signs
|
|
155
|
-
codePoint >= 2492 && codePoint <= 2500 || // Bengali vowel signs
|
|
156
|
-
codePoint >= 2509 && codePoint <= 2509 || // Bengali virama
|
|
157
|
-
codePoint >= 2561 && codePoint <= 2563 || // Gurmukhi signs
|
|
158
|
-
codePoint >= 2620 && codePoint <= 2637) {
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
if (codePoint >= 1611 && codePoint <= 1631 || // Arabic diacritics
|
|
162
|
-
codePoint >= 1648 && codePoint <= 1648 || // Arabic letter superscript alef
|
|
163
|
-
codePoint >= 1750 && codePoint <= 1773 || // Arabic small high signs
|
|
164
|
-
codePoint >= 2276 && codePoint <= 2302) {
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
if (codePoint >= 1425 && codePoint <= 1469 || // Hebrew points
|
|
168
|
-
codePoint >= 1471 && codePoint <= 1471 || // Hebrew point rafe
|
|
169
|
-
codePoint >= 1473 && codePoint <= 1474 || // Hebrew points
|
|
170
|
-
codePoint >= 1476 && codePoint <= 1477 || // Hebrew marks
|
|
171
|
-
codePoint >= 1479 && codePoint <= 1479) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
if (codePoint >= 3893 && codePoint <= 3893 || // Tibetan mark nada
|
|
175
|
-
codePoint >= 3895 && codePoint <= 3895 || // Tibetan mark nada
|
|
176
|
-
codePoint >= 3897 && codePoint <= 3897 || // Tibetan mark tsa phru
|
|
177
|
-
codePoint >= 3953 && codePoint <= 3966 || // Tibetan vowel signs
|
|
178
|
-
codePoint >= 3968 && codePoint <= 3972 || // Tibetan vowel signs and virama
|
|
179
|
-
codePoint >= 3974 && codePoint <= 3975) {
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
return codePoint >= 768 && codePoint <= 777 || // Combining diacritical marks used in Vietnamese
|
|
183
|
-
codePoint >= 803 && codePoint <= 803;
|
|
184
|
-
}, "isCombiningCharacter");
|
|
185
|
-
const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) => {
|
|
186
|
-
if (!input || input.length === 0) {
|
|
187
|
-
return { ellipsed: false, index: 0, truncated: false, width: 0 };
|
|
188
|
-
}
|
|
189
|
-
const config = {
|
|
190
|
-
truncation: {
|
|
191
|
-
countAnsiEscapeCodes: options.countAnsiEscapeCodes ?? false,
|
|
192
|
-
ellipsis: options.ellipsis ?? "",
|
|
193
|
-
ellipsisWidth: options.ellipsisWidth ?? (options.ellipsis ? getStringTruncatedWidth(options.ellipsis, {
|
|
194
|
-
...options,
|
|
195
|
-
ellipsis: "",
|
|
196
|
-
ellipsisWidth: 0,
|
|
197
|
-
limit: Number.POSITIVE_INFINITY
|
|
198
|
-
}).width : 0),
|
|
199
|
-
limit: options.limit ?? Number.POSITIVE_INFINITY
|
|
200
|
-
},
|
|
201
|
-
width: {
|
|
202
|
-
ambiguousIsNarrow: options.ambiguousIsNarrow ?? false,
|
|
203
|
-
ansi: options.ansiWidth ?? 0,
|
|
204
|
-
control: options.controlWidth ?? 0,
|
|
205
|
-
emoji: options.emojiWidth ?? 2,
|
|
206
|
-
fullWidth: options.fullWidth ?? 2,
|
|
207
|
-
halfWidth: options.halfWidth ?? 1,
|
|
208
|
-
regular: options.regularWidth ?? 1,
|
|
209
|
-
tab: options.tabWidth ?? 8,
|
|
210
|
-
wide: options.wideWidth ?? 2
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
const truncationLimit = Math.max(0, config.truncation.limit - config.truncation.ellipsisWidth);
|
|
214
|
-
const { length } = input;
|
|
215
|
-
const useCaching = length > 1e4;
|
|
216
|
-
let index = 0;
|
|
217
|
-
let width = 0;
|
|
218
|
-
let truncationIndex = length;
|
|
219
|
-
let truncationEnabled = false;
|
|
220
|
-
const hasAnsi = input.includes("\x1B") || input.includes("");
|
|
221
|
-
while (index < length) {
|
|
222
|
-
if (hasAnsi && (input[index] === "\x1B" || input[index] === "")) {
|
|
223
|
-
if (input.startsWith("\x1B]8;;", index)) {
|
|
224
|
-
const BELL = "\x07";
|
|
225
|
-
const OSC8_CLOSER = "\x1B]8;;" + BELL;
|
|
226
|
-
const OSC8_CLOSER_LEN = OSC8_CLOSER.length;
|
|
227
|
-
const endOfParametersIndex = input.indexOf(BELL, index + 5);
|
|
228
|
-
if (endOfParametersIndex === -1) ; else {
|
|
229
|
-
const startOfCloserIndex = input.indexOf(OSC8_CLOSER, endOfParametersIndex + 1);
|
|
230
|
-
if (startOfCloserIndex === -1) ; else {
|
|
231
|
-
const endOfSequenceIndex = startOfCloserIndex + OSC8_CLOSER_LEN;
|
|
232
|
-
const linkText = input.slice(endOfParametersIndex + 1, startOfCloserIndex);
|
|
233
|
-
const strippedLinkText = linkText.replace(constants.RE_ANSI, "");
|
|
234
|
-
const linkTextWidthResult = getStringTruncatedWidth(strippedLinkText, {
|
|
235
|
-
ambiguousIsNarrow: config.width.ambiguousIsNarrow,
|
|
236
|
-
ansiWidth: config.width.ansi,
|
|
237
|
-
controlWidth: config.width.control,
|
|
238
|
-
countAnsiEscapeCodes: false,
|
|
239
|
-
// Never count ANSI in link text width
|
|
240
|
-
ellipsis: config.truncation.ellipsis,
|
|
241
|
-
ellipsisWidth: config.truncation.ellipsisWidth,
|
|
242
|
-
emojiWidth: config.width.emoji,
|
|
243
|
-
fullWidth: config.width.fullWidth,
|
|
244
|
-
halfWidth: config.width.halfWidth,
|
|
245
|
-
limit: Math.max(0, truncationLimit - width),
|
|
246
|
-
regularWidth: config.width.regular,
|
|
247
|
-
tabWidth: config.width.tab,
|
|
248
|
-
wideWidth: config.width.wide
|
|
249
|
-
});
|
|
250
|
-
const textWidth = linkTextWidthResult.width;
|
|
251
|
-
if (linkTextWidthResult.truncated) {
|
|
252
|
-
truncationEnabled = true;
|
|
253
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
254
|
-
} else if (width + textWidth > truncationLimit) {
|
|
255
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
256
|
-
truncationEnabled = true;
|
|
257
|
-
if (width + textWidth > config.truncation.limit) {
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
width += textWidth;
|
|
262
|
-
index = endOfSequenceIndex;
|
|
263
|
-
if (truncationEnabled && width >= config.truncation.limit) {
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
constants.RE_ANSI.lastIndex = index;
|
|
271
|
-
if (constants.RE_ANSI.test(input)) {
|
|
272
|
-
const ansiLength = constants.RE_ANSI.lastIndex - index;
|
|
273
|
-
const ansiWidth = config.truncation.countAnsiEscapeCodes ? ansiLength : config.width.ansi;
|
|
274
|
-
if (width + ansiWidth > truncationLimit) {
|
|
275
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
276
|
-
if (width + ansiWidth > config.truncation.limit) {
|
|
277
|
-
truncationEnabled = true;
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
width += ansiWidth;
|
|
282
|
-
index = constants.RE_ANSI.lastIndex;
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
const charCode = input.codePointAt(index);
|
|
287
|
-
if (charCode === 8203 || charCode === 65279 || charCode >= 8288 && charCode <= 8292) {
|
|
288
|
-
index++;
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
if (charCode === 9) {
|
|
292
|
-
if (width + config.width.tab > truncationLimit) {
|
|
293
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
294
|
-
if (width + config.width.tab > config.truncation.limit) {
|
|
295
|
-
truncationEnabled = true;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
width += config.width.tab;
|
|
300
|
-
index++;
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
RE_LATIN_CHARS.lastIndex = index;
|
|
304
|
-
if (RE_LATIN_CHARS.test(input)) {
|
|
305
|
-
const latinLength = RE_LATIN_CHARS.lastIndex - index;
|
|
306
|
-
const latinWidth = latinLength * config.width.regular;
|
|
307
|
-
if (width + latinWidth > truncationLimit) {
|
|
308
|
-
const charsToLimit = Math.floor((truncationLimit - width) / config.width.regular);
|
|
309
|
-
truncationIndex = Math.min(truncationIndex, index + charsToLimit);
|
|
310
|
-
if (width + latinWidth > config.truncation.limit) {
|
|
311
|
-
truncationEnabled = true;
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
width += latinWidth;
|
|
316
|
-
index = RE_LATIN_CHARS.lastIndex;
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
if (charCode <= 31 || charCode >= 127 && charCode <= 159) {
|
|
320
|
-
constants.RE_CONTROL.lastIndex = index;
|
|
321
|
-
if (constants.RE_CONTROL.test(input)) {
|
|
322
|
-
const controlLength = constants.RE_CONTROL.lastIndex - index;
|
|
323
|
-
const controlWidth = controlLength * config.width.control;
|
|
324
|
-
if (width + controlWidth > truncationLimit) {
|
|
325
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / config.width.control));
|
|
326
|
-
if (width + controlWidth > config.truncation.limit) {
|
|
327
|
-
truncationEnabled = true;
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
width += controlWidth;
|
|
332
|
-
index = constants.RE_CONTROL.lastIndex;
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
constants.RE_EMOJI.lastIndex = index;
|
|
337
|
-
if (constants.RE_EMOJI.test(input)) {
|
|
338
|
-
if (width + config.width.emoji > truncationLimit) {
|
|
339
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
340
|
-
if (width + config.width.emoji > config.truncation.limit) {
|
|
341
|
-
truncationEnabled = true;
|
|
342
|
-
break;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
width += config.width.emoji;
|
|
346
|
-
index = constants.RE_EMOJI.lastIndex;
|
|
347
|
-
continue;
|
|
348
|
-
}
|
|
349
|
-
const codePoint = input.codePointAt(index) ?? 0;
|
|
350
|
-
if (isCombiningCharacter(codePoint)) {
|
|
351
|
-
index += codePoint > 65535 ? 2 : 1;
|
|
352
|
-
continue;
|
|
353
|
-
}
|
|
354
|
-
let charWidth;
|
|
355
|
-
if (useCaching) {
|
|
356
|
-
charWidth = getCachedCharWidth(codePoint, config);
|
|
357
|
-
} else {
|
|
358
|
-
const charType = getCharType(codePoint);
|
|
359
|
-
switch (charType) {
|
|
360
|
-
case "latin": {
|
|
361
|
-
charWidth = config.width.regular;
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
case "control": {
|
|
365
|
-
charWidth = config.width.control;
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
case "wide": {
|
|
369
|
-
charWidth = config.width.wide;
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
case "zero": {
|
|
373
|
-
charWidth = 0;
|
|
374
|
-
break;
|
|
375
|
-
}
|
|
376
|
-
default: {
|
|
377
|
-
const eaw = eastAsianWidthType(codePoint);
|
|
378
|
-
switch (eaw) {
|
|
379
|
-
case "fullwidth": {
|
|
380
|
-
charWidth = config.width.fullWidth;
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
case "wide": {
|
|
384
|
-
charWidth = config.width.wide;
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
case "ambiguous": {
|
|
388
|
-
charWidth = config.width.ambiguousIsNarrow ? config.width.regular : config.width.wide;
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
default: {
|
|
392
|
-
charWidth = config.width.regular;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
if (width + charWidth > truncationLimit) {
|
|
399
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
400
|
-
if (width + charWidth > config.truncation.limit) {
|
|
401
|
-
truncationEnabled = true;
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
width += charWidth;
|
|
406
|
-
index += codePoint > 65535 ? 2 : 1;
|
|
407
|
-
}
|
|
408
|
-
let finalWidth = width;
|
|
409
|
-
let ellipsed = false;
|
|
410
|
-
if (truncationEnabled && config.truncation.limit >= config.truncation.ellipsisWidth) {
|
|
411
|
-
finalWidth = config.truncation.limit;
|
|
412
|
-
ellipsed = true;
|
|
413
|
-
}
|
|
414
|
-
return {
|
|
415
|
-
ellipsed,
|
|
416
|
-
index: truncationEnabled ? truncationIndex : length,
|
|
417
|
-
truncated: truncationEnabled,
|
|
418
|
-
width: finalWidth
|
|
419
|
-
};
|
|
420
|
-
}, "getStringTruncatedWidth");
|
|
421
|
-
|
|
422
|
-
exports.getStringTruncatedWidth = getStringTruncatedWidth;
|
|
1
|
+
"use strict";var Y=Object.defineProperty;var w=(i,t)=>Y(i,"name",{value:t,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("./packem_shared/constants-D3K8u3G8.cjs");var q=Object.defineProperty,p=w((i,t)=>q(i,"name",{value:t,configurable:!0}),"E");function v(i){return i===161||i===164||i===167||i===168||i===170||i===173||i===174||i>=176&&i<=180||i>=182&&i<=186||i>=188&&i<=191||i===198||i===208||i===215||i===216||i>=222&&i<=225||i===230||i>=232&&i<=234||i===236||i===237||i===240||i===242||i===243||i>=247&&i<=250||i===252||i===254||i===257||i===273||i===275||i===283||i===294||i===295||i===299||i>=305&&i<=307||i===312||i>=319&&i<=322||i===324||i>=328&&i<=331||i===333||i===338||i===339||i===358||i===359||i===363||i===462||i===464||i===466||i===468||i===470||i===472||i===474||i===476||i===593||i===609||i===708||i===711||i>=713&&i<=715||i===717||i===720||i>=728&&i<=731||i===733||i===735||i>=768&&i<=879||i>=913&&i<=929||i>=931&&i<=937||i>=945&&i<=961||i>=963&&i<=969||i===1025||i>=1040&&i<=1103||i===1105||i===8208||i>=8211&&i<=8214||i===8216||i===8217||i===8220||i===8221||i>=8224&&i<=8226||i>=8228&&i<=8231||i===8240||i===8242||i===8243||i===8245||i===8251||i===8254||i===8308||i===8319||i>=8321&&i<=8324||i===8364||i===8451||i===8453||i===8457||i===8467||i===8470||i===8481||i===8482||i===8486||i===8491||i===8531||i===8532||i>=8539&&i<=8542||i>=8544&&i<=8555||i>=8560&&i<=8569||i===8585||i>=8592&&i<=8601||i===8632||i===8633||i===8658||i===8660||i===8679||i===8704||i===8706||i===8707||i===8711||i===8712||i===8715||i===8719||i===8721||i===8725||i===8730||i>=8733&&i<=8736||i===8739||i===8741||i>=8743&&i<=8748||i===8750||i>=8756&&i<=8759||i===8764||i===8765||i===8776||i===8780||i===8786||i===8800||i===8801||i>=8804&&i<=8807||i===8810||i===8811||i===8814||i===8815||i===8834||i===8835||i===8838||i===8839||i===8853||i===8857||i===8869||i===8895||i===8978||i>=9312&&i<=9449||i>=9451&&i<=9547||i>=9552&&i<=9587||i>=9600&&i<=9615||i>=9618&&i<=9621||i===9632||i===9633||i>=9635&&i<=9641||i===9650||i===9651||i===9654||i===9655||i===9660||i===9661||i===9664||i===9665||i>=9670&&i<=9672||i===9675||i>=9678&&i<=9681||i>=9698&&i<=9701||i===9711||i===9733||i===9734||i===9737||i===9742||i===9743||i===9756||i===9758||i===9792||i===9794||i===9824||i===9825||i>=9827&&i<=9829||i>=9831&&i<=9834||i===9836||i===9837||i===9839||i===9886||i===9887||i===9919||i>=9926&&i<=9933||i>=9935&&i<=9939||i>=9941&&i<=9953||i===9955||i===9960||i===9961||i>=9963&&i<=9969||i===9972||i>=9974&&i<=9977||i===9979||i===9980||i===9982||i===9983||i===10045||i>=10102&&i<=10111||i>=11094&&i<=11097||i>=12872&&i<=12879||i>=57344&&i<=63743||i>=65024&&i<=65039||i===65533||i>=127232&&i<=127242||i>=127248&&i<=127277||i>=127280&&i<=127337||i>=127344&&i<=127373||i===127375||i===127376||i>=127387&&i<=127404||i>=917760&&i<=917999||i>=983040&&i<=1048573||i>=1048576&&i<=1114109}w(v,"A");p(v,"isAmbiguous");function I(i){return i===12288||i>=65281&&i<=65376||i>=65504&&i<=65510}w(I,"B$1");p(I,"isFullWidth");function x(i){return i>=4352&&i<=4447||i===8986||i===8987||i===9001||i===9002||i>=9193&&i<=9196||i===9200||i===9203||i===9725||i===9726||i===9748||i===9749||i>=9776&&i<=9783||i>=9800&&i<=9811||i===9855||i>=9866&&i<=9871||i===9875||i===9889||i===9898||i===9899||i===9917||i===9918||i===9924||i===9925||i===9934||i===9940||i===9962||i===9970||i===9971||i===9973||i===9978||i===9981||i===9989||i===9994||i===9995||i===10024||i===10060||i===10062||i>=10067&&i<=10069||i===10071||i>=10133&&i<=10135||i===10160||i===10175||i===11035||i===11036||i===11088||i===11093||i>=11904&&i<=11929||i>=11931&&i<=12019||i>=12032&&i<=12245||i>=12272&&i<=12287||i>=12289&&i<=12350||i>=12353&&i<=12438||i>=12441&&i<=12543||i>=12549&&i<=12591||i>=12593&&i<=12686||i>=12688&&i<=12773||i>=12783&&i<=12830||i>=12832&&i<=12871||i>=12880&&i<=42124||i>=42128&&i<=42182||i>=43360&&i<=43388||i>=44032&&i<=55203||i>=63744&&i<=64255||i>=65040&&i<=65049||i>=65072&&i<=65106||i>=65108&&i<=65126||i>=65128&&i<=65131||i>=94176&&i<=94180||i===94192||i===94193||i>=94208&&i<=100343||i>=100352&&i<=101589||i>=101631&&i<=101640||i>=110576&&i<=110579||i>=110581&&i<=110587||i===110589||i===110590||i>=110592&&i<=110882||i===110898||i>=110928&&i<=110930||i===110933||i>=110948&&i<=110951||i>=110960&&i<=111355||i>=119552&&i<=119638||i>=119648&&i<=119670||i===126980||i===127183||i===127374||i>=127377&&i<=127386||i>=127488&&i<=127490||i>=127504&&i<=127547||i>=127552&&i<=127560||i===127568||i===127569||i>=127584&&i<=127589||i>=127744&&i<=127776||i>=127789&&i<=127797||i>=127799&&i<=127868||i>=127870&&i<=127891||i>=127904&&i<=127946||i>=127951&&i<=127955||i>=127968&&i<=127984||i===127988||i>=127992&&i<=128062||i===128064||i>=128066&&i<=128252||i>=128255&&i<=128317||i>=128331&&i<=128334||i>=128336&&i<=128359||i===128378||i===128405||i===128406||i===128420||i>=128507&&i<=128591||i>=128640&&i<=128709||i===128716||i>=128720&&i<=128722||i>=128725&&i<=128727||i>=128732&&i<=128735||i===128747||i===128748||i>=128756&&i<=128764||i>=128992&&i<=129003||i===129008||i>=129292&&i<=129338||i>=129340&&i<=129349||i>=129351&&i<=129535||i>=129648&&i<=129660||i>=129664&&i<=129673||i>=129679&&i<=129734||i>=129742&&i<=129756||i>=129759&&i<=129769||i>=129776&&i<=129784||i>=131072&&i<=196605||i>=196608&&i<=262141}w(x,"C");p(x,"isWide");function B(i){return v(i)?"ambiguous":I(i)?"fullwidth":i===8361||i>=65377&&i<=65470||i>=65474&&i<=65479||i>=65482&&i<=65487||i>=65490&&i<=65495||i>=65498&&i<=65500||i>=65512&&i<=65518?"halfwidth":i>=32&&i<=126||i===162||i===163||i===165||i===166||i===172||i===175||i>=10214&&i<=10221||i===10629||i===10630?"narrow":x(i)?"wide":"neutral"}w(B,"t$1");p(B,"getCategory");var L=Object.defineProperty,k=w((i,t)=>L(i,"name",{value:t,configurable:!0}),"t");function y(i){if(!Number.isSafeInteger(i))throw new TypeError(`Expected a code point, got \`${typeof i}\`.`)}w(y,"a");k(y,"validate");function C(i){return y(i),B(i)}w(C,"eastAsianWidthType");k(C,"eastAsianWidthType");function R(i,{ambiguousAsWide:t=!1}={}){return y(i),I(i)||x(i)||t&&v(i)?2:1}w(R,"eastAsianWidth");k(R,"eastAsianWidth");k(i=>!(I(i)||x(i)),"_isNarrowWidth");var D=Object.defineProperty,N=w((i,t)=>D(i,"name",{value:t,configurable:!0}),"d");const P=new Map,g=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,W=N(i=>i>=32&&i<=126?"latin":i===8203||i===8204||i===8205||i===8288?"zero":i<=31||i>=127&&i<=159?"control":i>=160&&i<=255||i>=9472&&i<=9599?"latin":i>=4352&&i<=4607||i>=11904&&i<=40959||i>=44032&&i<=55215||i>=63744&&i<=64255||i>=65280&&i<=65519&&!(i>=65377&&i<=65439)||i>=12352&&i<=12543?"wide":i===8230?"latin":"other","getCharType"),G=N((i,t)=>{const e=Math.floor(i/65536),l=i%65536;let h=P.get(e);if(h||(h=new Map,P.set(e,h)),h.has(l))return h.get(l);let c;if(W(i)==="latin")c=t.width.regular;else if(W(i)==="control")c=t.width.control;else if(W(i)==="wide")c=t.width.wide;else switch(C(i)){case"fullwidth":{c=t.width.fullWidth;break}case"wide":{c=t.width.wide;break}case"ambiguous":{c=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}default:c=t.width.regular}return h.set(l,c),c},"getCachedCharWidth"),H=N(i=>i>=768&&i<=879||i>=6832&&i<=6911||i>=7616&&i<=7679||i>=8400&&i<=8447||i>=65056&&i<=65071||i>=917760&&i<=917999||i>=65024&&i<=65039||i>=3633&&i<=3642||i>=3655&&i<=3662||i>=3761&&i<=3769||i>=3771&&i<=3772||i>=3784&&i<=3789||i>=2304&&i<=2307||i>=2362&&i<=2383||i>=2385&&i<=2391||i>=2402&&i<=2403||i>=2433&&i<=2435||i>=2492&&i<=2500||i>=2509&&i<=2509||i>=2561&&i<=2563||i>=2620&&i<=2637||i>=1611&&i<=1631||i>=1648&&i<=1648||i>=1750&&i<=1773||i>=2276&&i<=2302||i>=1425&&i<=1469||i>=1471&&i<=1471||i>=1473&&i<=1474||i>=1476&&i<=1477||i>=1479&&i<=1479||i>=3893&&i<=3893||i>=3895&&i<=3895||i>=3897&&i<=3897||i>=3953&&i<=3966||i>=3968&&i<=3972||i>=3974&&i<=3975?!0:i>=768&&i<=777||i>=803&&i<=803,"isCombiningCharacter"),T=N((i,t={})=>{if(!i||i.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const e={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?T(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},l=Math.max(0,e.truncation.limit-e.truncation.ellipsisWidth),{length:h}=i,c=h>1e4;let a=0,n=0,r=h,s=!1;const _=i.includes("\x1B")||i.includes("");for(;a<h;){if(_&&(i[a]==="\x1B"||i[a]==="")){if(i.startsWith("\x1B]8;;",a)){const u="\x07",m="\x1B]8;;"+u,$=m.length,M=i.indexOf(u,a+5);if(M!==-1){const j=i.indexOf(m,M+1);if(j!==-1){const z=j+$,V=i.slice(M+1,j).replace(o.c,""),S=T(V,{ambiguousIsNarrow:e.width.ambiguousIsNarrow,ansiWidth:e.width.ansi,controlWidth:e.width.control,countAnsiEscapeCodes:!1,ellipsis:e.truncation.ellipsis,ellipsisWidth:e.truncation.ellipsisWidth,emojiWidth:e.width.emoji,fullWidth:e.width.fullWidth,halfWidth:e.width.halfWidth,limit:Math.max(0,l-n),regularWidth:e.width.regular,tabWidth:e.width.tab,wideWidth:e.width.wide}),A=S.width;if(S.truncated)s=!0,r=Math.min(r,a);else if(n+A>l&&(r=Math.min(r,a),s=!0,n+A>e.truncation.limit))break;if(n+=A,a=z,s&&n>=e.truncation.limit)break;continue}}}if(o.c.lastIndex=a,o.c.test(i)){const u=o.c.lastIndex-a,m=e.truncation.countAnsiEscapeCodes?u:e.width.ansi;if(n+m>l&&(r=Math.min(r,a),n+m>e.truncation.limit)){s=!0;break}n+=m,a=o.c.lastIndex;continue}}const f=i.codePointAt(a);if(f===8203||f===65279||f>=8288&&f<=8292){a++;continue}if(f===9){if(n+e.width.tab>l&&(r=Math.min(r,a),n+e.width.tab>e.truncation.limit)){s=!0;break}n+=e.width.tab,a++;continue}if(g.lastIndex=a,g.test(i)){const u=(g.lastIndex-a)*e.width.regular;if(n+u>l){const m=Math.floor((l-n)/e.width.regular);if(r=Math.min(r,a+m),n+u>e.truncation.limit){s=!0;break}}n+=u,a=g.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&(o.N.lastIndex=a,o.N.test(i))){const u=(o.N.lastIndex-a)*e.width.control;if(n+u>l&&(r=Math.min(r,a+Math.floor((l-n)/e.width.control)),n+u>e.truncation.limit)){s=!0;break}n+=u,a=o.N.lastIndex;continue}if(o.j.lastIndex=a,o.j.test(i)){if(n+e.width.emoji>l&&(r=Math.min(r,a),n+e.width.emoji>e.truncation.limit)){s=!0;break}n+=e.width.emoji,a=o.j.lastIndex;continue}const b=i.codePointAt(a)??0;if(H(b)){a+=b>65535?2:1;continue}let d;if(c)d=G(b,e);else switch(W(b)){case"latin":{d=e.width.regular;break}case"control":{d=e.width.control;break}case"wide":{d=e.width.wide;break}case"zero":{d=0;break}default:switch(C(b)){case"fullwidth":{d=e.width.fullWidth;break}case"wide":{d=e.width.wide;break}case"ambiguous":{d=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}default:d=e.width.regular}}if(n+d>l&&(r=Math.min(r,a),n+d>e.truncation.limit)){s=!0;break}n+=d,a+=b>65535?2:1}let E=n,O=!1;return s&&e.truncation.limit>=e.truncation.ellipsisWidth&&(E=e.truncation.limit,O=!0),{ellipsed:O,index:s?r:h,truncated:s,width:E}},"getStringTruncatedWidth");exports.getStringTruncatedWidth=T;
|