@visulima/string 2.0.2 → 2.0.4

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 (55) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/dist/align-text.js +32 -2
  3. package/dist/case/camel-case.js +55 -1
  4. package/dist/case/capital-case.js +47 -1
  5. package/dist/case/constant-case.js +7 -1
  6. package/dist/case/dot-case.js +7 -1
  7. package/dist/case/flat-case.js +7 -1
  8. package/dist/case/flip-case.js +76 -1
  9. package/dist/case/identify-case.js +65 -1
  10. package/dist/case/index.js +20 -1
  11. package/dist/case/kebab-case.js +55 -1
  12. package/dist/case/lower-first.js +9 -1
  13. package/dist/case/no-case.js +7 -1
  14. package/dist/case/pascal-case.js +48 -1
  15. package/dist/case/pascal-snake-case.js +28 -1
  16. package/dist/case/path-case.js +7 -1
  17. package/dist/case/sentence-case.js +54 -1
  18. package/dist/case/snake-case.js +7 -1
  19. package/dist/case/split-by-case.js +644 -1
  20. package/dist/case/title-case.js +42 -1
  21. package/dist/case/train-case.js +40 -1
  22. package/dist/case/upper-first.js +9 -1
  23. package/dist/closest-string.js +25 -1
  24. package/dist/compare-similarity.js +12 -1
  25. package/dist/get-string-truncated-width.js +363 -1
  26. package/dist/get-string-width.js +5 -1
  27. package/dist/index.js +36 -1
  28. package/dist/outdent.js +118 -1
  29. package/dist/packem_shared/LRUCache-3r3SovvR.js +46 -0
  30. package/dist/packem_shared/closest-IHuSvnSn.js +139 -0
  31. package/dist/packem_shared/closestN-BREy4E7C.js +19 -0
  32. package/dist/packem_shared/constants-CTzC6Gjg.js +95 -0
  33. package/dist/packem_shared/generate-cache-key-DdayDfjV.js +6 -0
  34. package/dist/packem_shared/joinSegments-CuU8RGpP.js +44 -0
  35. package/dist/packem_shared/normalize-german-eszett-DEB8-ZPT.js +7 -0
  36. package/dist/packem_shared/replaceString-vYvRBMfC.js +190 -0
  37. package/dist/packem_shared/transliterate-CUF6Ggy_.js +47776 -0
  38. package/dist/slice.js +413 -1
  39. package/dist/slugify.js +46 -1
  40. package/dist/test/utils.js +88 -13
  41. package/dist/test/vitest.js +5 -1
  42. package/dist/truncate.js +89 -1
  43. package/dist/utilities.js +54 -1
  44. package/dist/word-similarity-sort.js +22 -1
  45. package/dist/word-wrap.js +637 -8
  46. package/package.json +1 -1
  47. package/dist/packem_shared/LRUCache-Bjo6gsbC.js +0 -1
  48. package/dist/packem_shared/closest-uarbVSbs.js +0 -1
  49. package/dist/packem_shared/closestN-DjNxwK0t.js +0 -1
  50. package/dist/packem_shared/constants-CDcaCZKC.js +0 -1
  51. package/dist/packem_shared/generate-cache-key-DPByFaMH.js +0 -1
  52. package/dist/packem_shared/joinSegments-DTGeJBZG.js +0 -1
  53. package/dist/packem_shared/normalize-german-eszett-4k1qRtEP.js +0 -1
  54. package/dist/packem_shared/replaceString-DwIZyvoL.js +0 -1
  55. package/dist/packem_shared/transliterate-CxVHmZUa.js +0 -5
@@ -1 +1,42 @@
1
- var s=Object.defineProperty;var n=(r,o)=>s(r,"name",{value:o,configurable:!0});import c from"../packem_shared/LRUCache-Bjo6gsbC.js";import{splitByCase as m}from"./split-by-case.js";import p from"./upper-first.js";import{a as f}from"../packem_shared/generate-cache-key-DPByFaMH.js";import{l as d}from"../packem_shared/normalize-german-eszett-4k1qRtEP.js";var h=Object.defineProperty,u=n((r,o)=>h(r,"name",{value:o,configurable:!0}),"n");const j=new c(1e3);function A(r,o){if(typeof r!="string")return"";const a=o?.cache??!1,i=o?.cacheStore??j;let t;if(a&&(t=f(r,o)),a&&t&&i.has(t))return i.get(t);const l=m(r,{handleAnsi:o?.handleAnsi,handleEmoji:o?.handleEmoji,knownAcronyms:o?.knownAcronyms,locale:o?.locale,normalize:o?.normalize,separators:void 0,stripAnsi:o?.stripAnsi,stripEmoji:o?.stripEmoji}).map(e=>(o?.locale?.startsWith("de")&&(e=d(e)),p(o?.locale?e.toLocaleLowerCase(o.locale):e.toLowerCase(),{locale:o?.locale}))).join(" ");return a&&t&&i.set(t,l),l}n(A,"d");u(A,"titleCase");export{A as default};
1
+ import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
2
+ import { splitByCase } from './split-by-case.js';
3
+ import upperFirst from './upper-first.js';
4
+ import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
5
+ import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-DEB8-ZPT.js';
6
+
7
+ const defaultCacheStore = new LRUCache(1e3);
8
+ function titleCase(value, options) {
9
+ if (typeof value !== "string") {
10
+ return "";
11
+ }
12
+ const shouldCache = options?.cache ?? false;
13
+ const cacheStore = options?.cacheStore ?? defaultCacheStore;
14
+ let cacheKey;
15
+ if (shouldCache) {
16
+ cacheKey = generateCacheKey(value, options);
17
+ }
18
+ if (shouldCache && cacheKey && cacheStore.has(cacheKey)) {
19
+ return cacheStore.get(cacheKey);
20
+ }
21
+ const result = splitByCase(value, {
22
+ handleAnsi: options?.handleAnsi,
23
+ handleEmoji: options?.handleEmoji,
24
+ knownAcronyms: options?.knownAcronyms,
25
+ locale: options?.locale,
26
+ normalize: options?.normalize,
27
+ separators: void 0,
28
+ stripAnsi: options?.stripAnsi,
29
+ stripEmoji: options?.stripEmoji
30
+ }).map((word) => {
31
+ if (options?.locale?.startsWith("de")) {
32
+ word = normalizeGermanEszett(word);
33
+ }
34
+ return upperFirst(options?.locale ? word.toLocaleLowerCase(options.locale) : word.toLowerCase(), { locale: options?.locale });
35
+ }).join(" ");
36
+ if (shouldCache && cacheKey) {
37
+ cacheStore.set(cacheKey, result);
38
+ }
39
+ return result;
40
+ }
41
+
42
+ export { titleCase as default };
@@ -1 +1,40 @@
1
- var m=Object.defineProperty;var e=(o,r)=>m(o,"name",{value:r,configurable:!0});import l from"../packem_shared/LRUCache-Bjo6gsbC.js";import{splitByCase as p}from"./split-by-case.js";import c from"./upper-first.js";import{a as f}from"../packem_shared/generate-cache-key-DPByFaMH.js";import d from"../packem_shared/joinSegments-DTGeJBZG.js";var h=Object.defineProperty,u=e((o,r)=>h(o,"name",{value:r,configurable:!0}),"i");const A=new l(1e3),b=u((o,r)=>{if(typeof o!="string")return"";const n=r?.cache??!1,i=r?.cacheStore??A;let t;if(n&&(t=f(o,r)),n&&t&&i.has(t))return i.get(t);const a=d(p(o,{handleAnsi:r?.handleAnsi,handleEmoji:r?.handleEmoji,knownAcronyms:r?.knownAcronyms,locale:r?.locale,normalize:r?.normalize,separators:void 0,stripAnsi:r?.stripAnsi,stripEmoji:r?.stripEmoji}).map(s=>c(s,{locale:r?.locale})),"-");return n&&t&&i.set(t,a),a},"trainCase");export{b as default};
1
+ import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
2
+ import { splitByCase } from './split-by-case.js';
3
+ import upperFirst from './upper-first.js';
4
+ import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
5
+ import joinSegments from '../packem_shared/joinSegments-CuU8RGpP.js';
6
+
7
+ const defaultCacheStore = new LRUCache(1e3);
8
+ const trainCase = (value, options) => {
9
+ if (typeof value !== "string") {
10
+ return "";
11
+ }
12
+ const shouldCache = options?.cache ?? false;
13
+ const cacheStore = options?.cacheStore ?? defaultCacheStore;
14
+ let cacheKey;
15
+ if (shouldCache) {
16
+ cacheKey = generateCacheKey(value, options);
17
+ }
18
+ if (shouldCache && cacheKey && cacheStore.has(cacheKey)) {
19
+ return cacheStore.get(cacheKey);
20
+ }
21
+ const result = joinSegments(
22
+ splitByCase(value, {
23
+ handleAnsi: options?.handleAnsi,
24
+ handleEmoji: options?.handleEmoji,
25
+ knownAcronyms: options?.knownAcronyms,
26
+ locale: options?.locale,
27
+ normalize: options?.normalize,
28
+ separators: void 0,
29
+ stripAnsi: options?.stripAnsi,
30
+ stripEmoji: options?.stripEmoji
31
+ }).map((p) => upperFirst(p, { locale: options?.locale })),
32
+ "-"
33
+ );
34
+ if (shouldCache && cacheKey) {
35
+ cacheStore.set(cacheKey, result);
36
+ }
37
+ return result;
38
+ };
39
+
40
+ export { trainCase as default };
@@ -1 +1,9 @@
1
- var p=Object.defineProperty;var o=(e,a)=>p(e,"name",{value:a,configurable:!0});var t=Object.defineProperty,l=o((e,a)=>t(e,"name",{value:a,configurable:!0}),"s");const s=l((e,a)=>typeof e!="string"||e===""?"":(a?.locale?e[0].toLocaleUpperCase(a.locale):e[0].toUpperCase())+e.slice(1),"upperFirst");export{s as default};
1
+ const upperFirst = (value, options) => {
2
+ if (typeof value !== "string" || value === "") {
3
+ return "";
4
+ }
5
+ const firstChar = options?.locale ? value[0].toLocaleUpperCase(options.locale) : value[0].toUpperCase();
6
+ return firstChar + value.slice(1);
7
+ };
8
+
9
+ export { upperFirst as default };
@@ -1 +1,25 @@
1
- var f=Object.defineProperty;var c=(e,o)=>f(e,"name",{value:o,configurable:!0});import{distance as g}from"./packem_shared/closest-uarbVSbs.js";var p=Object.defineProperty,u=c((e,o)=>p(e,"name",{value:o,configurable:!0}),"c");const v=u((e,o,l)=>{if(o.length===0)throw new TypeError("When using closestString(), the possibleWords array must contain at least one word");const{caseSensitive:t,compareFn:s=g}={...l};t||(e=e.toLowerCase());let n=o[0]??void 0,a=1/0;for(const r of o){const i=t?s(e,r):s(e,r.toLowerCase());i<a&&(n=r,a=i)}return n},"closestString");export{v as closestString};
1
+ import { distance } from './packem_shared/closest-IHuSvnSn.js';
2
+
3
+ const closestString = (givenWord, possibleWords, options) => {
4
+ if (possibleWords.length === 0) {
5
+ throw new TypeError(
6
+ "When using closestString(), the possibleWords array must contain at least one word"
7
+ );
8
+ }
9
+ const { caseSensitive, compareFn: compareFunction = distance } = { ...options };
10
+ if (!caseSensitive) {
11
+ givenWord = givenWord.toLowerCase();
12
+ }
13
+ let nearestWord = possibleWords[0] ?? void 0;
14
+ let closestStringDistance = Infinity;
15
+ for (const each of possibleWords) {
16
+ const distance = caseSensitive ? compareFunction(givenWord, each) : compareFunction(givenWord, each.toLowerCase());
17
+ if (distance < closestStringDistance) {
18
+ nearestWord = each;
19
+ closestStringDistance = distance;
20
+ }
21
+ }
22
+ return nearestWord;
23
+ };
24
+
25
+ export { closestString };
@@ -1 +1,12 @@
1
- var t=Object.defineProperty;var s=(e,r)=>t(e,"name",{value:r,configurable:!0});import{distance as c}from"./packem_shared/closest-uarbVSbs.js";var n=Object.defineProperty,m=s((e,r)=>n(e,"name",{value:r,configurable:!0}),"s");const u=m((e,r)=>{const{compareFn:a=c}={...r};return r?.caseSensitive?(o,i)=>a(e,o)-a(e,i):(e=e.toLowerCase(),(o,i)=>a(e,o.toLowerCase())-a(e,i.toLowerCase()))},"compareSimilarity");export{u as compareSimilarity};
1
+ import { distance } from './packem_shared/closest-IHuSvnSn.js';
2
+
3
+ const compareSimilarity = (givenWord, options) => {
4
+ const { compareFn: compareFunction = distance } = { ...options };
5
+ if (options?.caseSensitive) {
6
+ return (a, b) => compareFunction(givenWord, a) - compareFunction(givenWord, b);
7
+ }
8
+ givenWord = givenWord.toLowerCase();
9
+ return (a, b) => compareFunction(givenWord, a.toLowerCase()) - compareFunction(givenWord, b.toLowerCase());
10
+ };
11
+
12
+ export { compareSimilarity };
@@ -1 +1,363 @@
1
- var L=Object.defineProperty;var c=(i,a)=>L(i,"name",{value:a,configurable:!0});import{c as b,N as g,j as E}from"./packem_shared/constants-CDcaCZKC.js";var V=Object.defineProperty,I=c((i,a)=>V(i,"name",{value:a,configurable:!0}),"E$1");function M(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}c(M,"A");I(M,"isAmbiguous");function C(i){return i===12288||i>=65281&&i<=65376||i>=65504&&i<=65510}c(C,"D$1");I(C,"isFullWidth");function T(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<=94198||i>=94208&&i<=101589||i>=101631&&i<=101662||i>=101760&&i<=101874||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<=128728||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<=129674||i>=129678&&i<=129734||i===129736||i>=129741&&i<=129756||i>=129759&&i<=129770||i>=129775&&i<=129784||i>=131072&&i<=196605||i>=196608&&i<=262141}c(T,"C");I(T,"isWide");function R(i){return M(i)?"ambiguous":C(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":T(i)?"wide":"neutral"}c(R,"t");I(R,"getCategory");var Y=Object.defineProperty,j=c((i,a)=>Y(i,"name",{value:a,configurable:!0}),"e");function O(i){if(!Number.isSafeInteger(i))throw new TypeError(`Expected a code point, got \`${typeof i}\`.`)}c(O,"r");j(O,"validate");function v(i){return O(i),R(i)}c(v,"eastAsianWidthType");j(v,"eastAsianWidthType");function J(i,{ambiguousAsWide:a=!1}={}){return O(i),C(i)||T(i)||a&&M(i)?2:1}c(J,"eastAsianWidth");j(J,"eastAsianWidth");var q=Object.defineProperty,x=c((i,a)=>q(i,"name",{value:a,configurable:!0}),"b");const _=new Map,W=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,p=x(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=x((i,a)=>{const e=Math.floor(i/65536),l=i%65536;let u=_.get(e);if(u||(u=new Map,_.set(e,u)),u.has(l))return u.get(l);let h;if(p(i)==="latin")h=a.width.regular;else if(p(i)==="control")h=a.width.control;else if(p(i)==="wide")h=a.width.wide;else switch(v(i)){case"ambiguous":{h=a.width.ambiguousIsNarrow?a.width.regular:a.width.wide;break}case"fullwidth":{h=a.width.fullWidth;break}case"wide":{h=a.width.wide;break}default:h=a.width.regular}return u.set(l,h),h},"getCachedCharWidth"),H=x(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"),B=x((i,a={})=>{if(!i||i.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const e={truncation:{countAnsiEscapeCodes:a.countAnsiEscapeCodes??!1,ellipsis:a.ellipsis??"",ellipsisWidth:a.ellipsisWidth??(a.ellipsis?B(a.ellipsis,{...a,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:a.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:a.ambiguousIsNarrow??!1,ansi:a.ansiWidth??0,control:a.controlWidth??0,emoji:a.emojiWidth??2,fullWidth:a.fullWidth??2,halfWidth:a.halfWidth??1,regular:a.regularWidth??1,tab:a.tabWidth??8,wide:a.wideWidth??2}},l=Math.max(0,e.truncation.limit-e.truncation.ellipsisWidth),{length:u}=i,h=u>1e4;let t=0,n=0,r=u,s=!1;const $=i.includes("\x1B")||i.includes("›");for(;t<u;){if($&&(i[t]==="\x1B"||i[t]==="›")){if(i.startsWith("\x1B]8;;",t)){const o="\x1B]8;;\x07",f=o.length,k=i.indexOf("\x07",t+5);if(k!==-1){const N=i.indexOf(o,k+1);if(N!==-1){const z=N+f,D=i.slice(k+1,N).replace(b,""),S=B(D,{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,t);else if(n+A>l&&(r=Math.min(r,t),s=!0,n+A>e.truncation.limit))break;if(n+=A,t=z,s&&n>=e.truncation.limit)break;continue}}}if(b.lastIndex=t,b.test(i)){const o=b.lastIndex-t,f=e.truncation.countAnsiEscapeCodes?o:e.width.ansi;if(n+f>l&&(r=Math.min(r,t),n+f>e.truncation.limit)){s=!0;break}n+=f,t=b.lastIndex;continue}}const w=i.codePointAt(t);if(w===8203||w===65279||w>=8288&&w<=8292){t+=1;continue}if(w===9){if(n+e.width.tab>l&&(r=Math.min(r,t),n+e.width.tab>e.truncation.limit)){s=!0;break}n+=e.width.tab,t+=1;continue}if(W.lastIndex=t,W.test(i)){const o=(W.lastIndex-t)*e.width.regular;if(n+o>l){const f=Math.floor((l-n)/e.width.regular);if(r=Math.min(r,t+f),n+o>e.truncation.limit){s=!0;break}}n+=o,t=W.lastIndex;continue}if((w<=31||w>=127&&w<=159)&&(g.lastIndex=t,g.test(i))){const o=(g.lastIndex-t)*e.width.control;if(n+o>l&&(r=Math.min(r,t+Math.floor((l-n)/e.width.control)),n+o>e.truncation.limit)){s=!0;break}n+=o,t=g.lastIndex;continue}if(E.lastIndex=t,E.test(i)){if(n+e.width.emoji>l&&(r=Math.min(r,t),n+e.width.emoji>e.truncation.limit)){s=!0;break}n+=e.width.emoji,t=E.lastIndex;continue}const m=i.codePointAt(t)??0;if(H(m)){t+=m>65535?2:1;continue}let d;if(h)d=G(m,e);else switch(p(m)){case"control":{d=e.width.control;break}case"latin":{d=e.width.regular;break}case"wide":{d=e.width.wide;break}case"zero":{d=0;break}default:switch(v(m)){case"ambiguous":{d=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{d=e.width.fullWidth;break}case"wide":{d=e.width.wide;break}default:d=e.width.regular}}if(n+d>l&&(r=Math.min(r,t),n+d>e.truncation.limit)){s=!0;break}n+=d,t+=m>65535?2:1}let y=n,P=!1;return s&&e.truncation.limit>=e.truncation.ellipsisWidth&&(y=e.truncation.limit,P=!0),{ellipsed:P,index:s?r:u,truncated:s,width:y}},"getStringTruncatedWidth");export{B as getStringTruncatedWidth};
1
+ import { c as RE_ANSI, N as RE_CONTROL, j as RE_EMOJI } from './packem_shared/constants-CTzC6Gjg.js';
2
+
3
+ function isAmbiguous(x) {
4
+ 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;
5
+ }
6
+ function isFullWidth(x) {
7
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
8
+ }
9
+ function isWide(x) {
10
+ 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 <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || 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 <= 128728 || 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 <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
11
+ }
12
+ function getCategory(x) {
13
+ if (isAmbiguous(x)) return "ambiguous";
14
+ if (isFullWidth(x)) return "fullwidth";
15
+ 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) {
16
+ return "halfwidth";
17
+ }
18
+ 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) {
19
+ return "narrow";
20
+ }
21
+ if (isWide(x)) return "wide";
22
+ return "neutral";
23
+ }
24
+
25
+ function validate(codePoint) {
26
+ if (!Number.isSafeInteger(codePoint)) {
27
+ throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
28
+ }
29
+ }
30
+ function eastAsianWidthType(codePoint) {
31
+ validate(codePoint);
32
+ return getCategory(codePoint);
33
+ }
34
+
35
+ const charWidthCache = /* @__PURE__ */ new Map();
36
+ const RE_LATIN_CHARS = /(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y;
37
+ const getCharType = (codePoint) => {
38
+ if (codePoint >= 32 && codePoint <= 126) {
39
+ return "latin";
40
+ }
41
+ if (codePoint === 8203 || codePoint === 8204 || codePoint === 8205 || codePoint === 8288) {
42
+ return "zero";
43
+ }
44
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
45
+ return "control";
46
+ }
47
+ if (codePoint >= 160 && codePoint <= 255) {
48
+ return "latin";
49
+ }
50
+ if (codePoint >= 9472 && codePoint <= 9599) {
51
+ return "latin";
52
+ }
53
+ if (codePoint >= 4352 && codePoint <= 4607 || codePoint >= 11904 && codePoint <= 40959 || codePoint >= 44032 && codePoint <= 55215 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65280 && codePoint <= 65519 && !(codePoint >= 65377 && codePoint <= 65439) || codePoint >= 12352 && codePoint <= 12543) {
54
+ return "wide";
55
+ }
56
+ if (codePoint === 8230) {
57
+ return "latin";
58
+ }
59
+ return "other";
60
+ };
61
+ const getCachedCharWidth = (codePoint, config) => {
62
+ const highBits = Math.floor(codePoint / 65536);
63
+ const lowBits = codePoint % 65536;
64
+ let lowMap = charWidthCache.get(highBits);
65
+ if (!lowMap) {
66
+ lowMap = /* @__PURE__ */ new Map();
67
+ charWidthCache.set(highBits, lowMap);
68
+ }
69
+ if (lowMap.has(lowBits)) {
70
+ return lowMap.get(lowBits);
71
+ }
72
+ let width;
73
+ if (getCharType(codePoint) === "latin") {
74
+ width = config.width.regular;
75
+ } else if (getCharType(codePoint) === "control") {
76
+ width = config.width.control;
77
+ } else if (getCharType(codePoint) === "wide") {
78
+ width = config.width.wide;
79
+ } else {
80
+ const eaw = eastAsianWidthType(codePoint);
81
+ switch (eaw) {
82
+ case "ambiguous": {
83
+ width = config.width.ambiguousIsNarrow ? config.width.regular : config.width.wide;
84
+ break;
85
+ }
86
+ case "fullwidth": {
87
+ width = config.width.fullWidth;
88
+ break;
89
+ }
90
+ case "wide": {
91
+ width = config.width.wide;
92
+ break;
93
+ }
94
+ default: {
95
+ width = config.width.regular;
96
+ }
97
+ }
98
+ }
99
+ lowMap.set(lowBits, width);
100
+ return width;
101
+ };
102
+ const isCombiningCharacter = (codePoint) => {
103
+ if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
104
+ return true;
105
+ }
106
+ if (codePoint >= 917760 && codePoint <= 917999 || codePoint >= 65024 && codePoint <= 65039) {
107
+ return true;
108
+ }
109
+ if (codePoint >= 3633 && codePoint <= 3642 || codePoint >= 3655 && codePoint <= 3662 || codePoint >= 3761 && codePoint <= 3769 || codePoint >= 3771 && codePoint <= 3772 || codePoint >= 3784 && codePoint <= 3789) {
110
+ return true;
111
+ }
112
+ if (codePoint >= 2304 && codePoint <= 2307 || codePoint >= 2362 && codePoint <= 2383 || codePoint >= 2385 && codePoint <= 2391 || codePoint >= 2402 && codePoint <= 2403 || codePoint >= 2433 && codePoint <= 2435 || codePoint >= 2492 && codePoint <= 2500 || codePoint >= 2509 && codePoint <= 2509 || codePoint >= 2561 && codePoint <= 2563 || codePoint >= 2620 && codePoint <= 2637) {
113
+ return true;
114
+ }
115
+ if (codePoint >= 1611 && codePoint <= 1631 || codePoint >= 1648 && codePoint <= 1648 || codePoint >= 1750 && codePoint <= 1773 || codePoint >= 2276 && codePoint <= 2302) {
116
+ return true;
117
+ }
118
+ if (codePoint >= 1425 && codePoint <= 1469 || codePoint >= 1471 && codePoint <= 1471 || codePoint >= 1473 && codePoint <= 1474 || codePoint >= 1476 && codePoint <= 1477 || codePoint >= 1479 && codePoint <= 1479) {
119
+ return true;
120
+ }
121
+ if (codePoint >= 3893 && codePoint <= 3893 || codePoint >= 3895 && codePoint <= 3895 || codePoint >= 3897 && codePoint <= 3897 || codePoint >= 3953 && codePoint <= 3966 || codePoint >= 3968 && codePoint <= 3972 || codePoint >= 3974 && codePoint <= 3975) {
122
+ return true;
123
+ }
124
+ return codePoint >= 768 && codePoint <= 777 || codePoint >= 803 && codePoint <= 803;
125
+ };
126
+ const getStringTruncatedWidth = (input, options = {}) => {
127
+ if (!input || input.length === 0) {
128
+ return { ellipsed: false, index: 0, truncated: false, width: 0 };
129
+ }
130
+ const config = {
131
+ truncation: {
132
+ countAnsiEscapeCodes: options.countAnsiEscapeCodes ?? false,
133
+ ellipsis: options.ellipsis ?? "",
134
+ ellipsisWidth: options.ellipsisWidth ?? (options.ellipsis ? getStringTruncatedWidth(options.ellipsis, {
135
+ ...options,
136
+ ellipsis: "",
137
+ ellipsisWidth: 0,
138
+ limit: Number.POSITIVE_INFINITY
139
+ }).width : 0),
140
+ limit: options.limit ?? Number.POSITIVE_INFINITY
141
+ },
142
+ width: {
143
+ ambiguousIsNarrow: options.ambiguousIsNarrow ?? false,
144
+ ansi: options.ansiWidth ?? 0,
145
+ control: options.controlWidth ?? 0,
146
+ emoji: options.emojiWidth ?? 2,
147
+ fullWidth: options.fullWidth ?? 2,
148
+ halfWidth: options.halfWidth ?? 1,
149
+ regular: options.regularWidth ?? 1,
150
+ tab: options.tabWidth ?? 8,
151
+ wide: options.wideWidth ?? 2
152
+ }
153
+ };
154
+ const truncationLimit = Math.max(0, config.truncation.limit - config.truncation.ellipsisWidth);
155
+ const { length } = input;
156
+ const useCaching = length > 1e4;
157
+ let index = 0;
158
+ let width = 0;
159
+ let truncationIndex = length;
160
+ let truncationEnabled = false;
161
+ const hasAnsi = input.includes("\x1B") || input.includes("›");
162
+ while (index < length) {
163
+ if (hasAnsi && (input[index] === "\x1B" || input[index] === "›")) {
164
+ if (input.startsWith("\x1B]8;;", index)) {
165
+ const BELL = "\x07";
166
+ const OSC8_CLOSER = `\x1B]8;;${BELL}`;
167
+ const OSC8_CLOSER_LEN = OSC8_CLOSER.length;
168
+ const endOfParametersIndex = input.indexOf(BELL, index + 5);
169
+ if (endOfParametersIndex === -1) ; else {
170
+ const startOfCloserIndex = input.indexOf(OSC8_CLOSER, endOfParametersIndex + 1);
171
+ if (startOfCloserIndex === -1) ; else {
172
+ const endOfSequenceIndex = startOfCloserIndex + OSC8_CLOSER_LEN;
173
+ const linkText = input.slice(endOfParametersIndex + 1, startOfCloserIndex);
174
+ const strippedLinkText = linkText.replace(RE_ANSI, "");
175
+ const linkTextWidthResult = getStringTruncatedWidth(strippedLinkText, {
176
+ ambiguousIsNarrow: config.width.ambiguousIsNarrow,
177
+ ansiWidth: config.width.ansi,
178
+ controlWidth: config.width.control,
179
+ countAnsiEscapeCodes: false,
180
+ // Never count ANSI in link text width
181
+ ellipsis: config.truncation.ellipsis,
182
+ ellipsisWidth: config.truncation.ellipsisWidth,
183
+ emojiWidth: config.width.emoji,
184
+ fullWidth: config.width.fullWidth,
185
+ halfWidth: config.width.halfWidth,
186
+ limit: Math.max(0, truncationLimit - width),
187
+ regularWidth: config.width.regular,
188
+ tabWidth: config.width.tab,
189
+ wideWidth: config.width.wide
190
+ });
191
+ const textWidth = linkTextWidthResult.width;
192
+ if (linkTextWidthResult.truncated) {
193
+ truncationEnabled = true;
194
+ truncationIndex = Math.min(truncationIndex, index);
195
+ } else if (width + textWidth > truncationLimit) {
196
+ truncationIndex = Math.min(truncationIndex, index);
197
+ truncationEnabled = true;
198
+ if (width + textWidth > config.truncation.limit) {
199
+ break;
200
+ }
201
+ }
202
+ width += textWidth;
203
+ index = endOfSequenceIndex;
204
+ if (truncationEnabled && width >= config.truncation.limit) {
205
+ break;
206
+ }
207
+ continue;
208
+ }
209
+ }
210
+ }
211
+ RE_ANSI.lastIndex = index;
212
+ if (RE_ANSI.test(input)) {
213
+ const ansiLength = RE_ANSI.lastIndex - index;
214
+ const ansiWidth = config.truncation.countAnsiEscapeCodes ? ansiLength : config.width.ansi;
215
+ if (width + ansiWidth > truncationLimit) {
216
+ truncationIndex = Math.min(truncationIndex, index);
217
+ if (width + ansiWidth > config.truncation.limit) {
218
+ truncationEnabled = true;
219
+ break;
220
+ }
221
+ }
222
+ width += ansiWidth;
223
+ index = RE_ANSI.lastIndex;
224
+ continue;
225
+ }
226
+ }
227
+ const charCode = input.codePointAt(index);
228
+ if (charCode === 8203 || charCode === 65279 || charCode >= 8288 && charCode <= 8292) {
229
+ index += 1;
230
+ continue;
231
+ }
232
+ if (charCode === 9) {
233
+ if (width + config.width.tab > truncationLimit) {
234
+ truncationIndex = Math.min(truncationIndex, index);
235
+ if (width + config.width.tab > config.truncation.limit) {
236
+ truncationEnabled = true;
237
+ break;
238
+ }
239
+ }
240
+ width += config.width.tab;
241
+ index += 1;
242
+ continue;
243
+ }
244
+ RE_LATIN_CHARS.lastIndex = index;
245
+ if (RE_LATIN_CHARS.test(input)) {
246
+ const latinLength = RE_LATIN_CHARS.lastIndex - index;
247
+ const latinWidth = latinLength * config.width.regular;
248
+ if (width + latinWidth > truncationLimit) {
249
+ const charsToLimit = Math.floor((truncationLimit - width) / config.width.regular);
250
+ truncationIndex = Math.min(truncationIndex, index + charsToLimit);
251
+ if (width + latinWidth > config.truncation.limit) {
252
+ truncationEnabled = true;
253
+ break;
254
+ }
255
+ }
256
+ width += latinWidth;
257
+ index = RE_LATIN_CHARS.lastIndex;
258
+ continue;
259
+ }
260
+ if (charCode <= 31 || charCode >= 127 && charCode <= 159) {
261
+ RE_CONTROL.lastIndex = index;
262
+ if (RE_CONTROL.test(input)) {
263
+ const controlLength = RE_CONTROL.lastIndex - index;
264
+ const controlWidth = controlLength * config.width.control;
265
+ if (width + controlWidth > truncationLimit) {
266
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / config.width.control));
267
+ if (width + controlWidth > config.truncation.limit) {
268
+ truncationEnabled = true;
269
+ break;
270
+ }
271
+ }
272
+ width += controlWidth;
273
+ index = RE_CONTROL.lastIndex;
274
+ continue;
275
+ }
276
+ }
277
+ RE_EMOJI.lastIndex = index;
278
+ if (RE_EMOJI.test(input)) {
279
+ if (width + config.width.emoji > truncationLimit) {
280
+ truncationIndex = Math.min(truncationIndex, index);
281
+ if (width + config.width.emoji > config.truncation.limit) {
282
+ truncationEnabled = true;
283
+ break;
284
+ }
285
+ }
286
+ width += config.width.emoji;
287
+ index = RE_EMOJI.lastIndex;
288
+ continue;
289
+ }
290
+ const codePoint = input.codePointAt(index) ?? 0;
291
+ if (isCombiningCharacter(codePoint)) {
292
+ index += codePoint > 65535 ? 2 : 1;
293
+ continue;
294
+ }
295
+ let charWidth;
296
+ if (useCaching) {
297
+ charWidth = getCachedCharWidth(codePoint, config);
298
+ } else {
299
+ const charType = getCharType(codePoint);
300
+ switch (charType) {
301
+ case "control": {
302
+ charWidth = config.width.control;
303
+ break;
304
+ }
305
+ case "latin": {
306
+ charWidth = config.width.regular;
307
+ break;
308
+ }
309
+ case "wide": {
310
+ charWidth = config.width.wide;
311
+ break;
312
+ }
313
+ case "zero": {
314
+ charWidth = 0;
315
+ break;
316
+ }
317
+ default: {
318
+ const eaw = eastAsianWidthType(codePoint);
319
+ switch (eaw) {
320
+ case "ambiguous": {
321
+ charWidth = config.width.ambiguousIsNarrow ? config.width.regular : config.width.wide;
322
+ break;
323
+ }
324
+ case "fullwidth": {
325
+ charWidth = config.width.fullWidth;
326
+ break;
327
+ }
328
+ case "wide": {
329
+ charWidth = config.width.wide;
330
+ break;
331
+ }
332
+ default: {
333
+ charWidth = config.width.regular;
334
+ }
335
+ }
336
+ }
337
+ }
338
+ }
339
+ if (width + charWidth > truncationLimit) {
340
+ truncationIndex = Math.min(truncationIndex, index);
341
+ if (width + charWidth > config.truncation.limit) {
342
+ truncationEnabled = true;
343
+ break;
344
+ }
345
+ }
346
+ width += charWidth;
347
+ index += codePoint > 65535 ? 2 : 1;
348
+ }
349
+ let finalWidth = width;
350
+ let ellipsed = false;
351
+ if (truncationEnabled && config.truncation.limit >= config.truncation.ellipsisWidth) {
352
+ finalWidth = config.truncation.limit;
353
+ ellipsed = true;
354
+ }
355
+ return {
356
+ ellipsed,
357
+ index: truncationEnabled ? truncationIndex : length,
358
+ truncated: truncationEnabled,
359
+ width: finalWidth
360
+ };
361
+ };
362
+
363
+ export { getStringTruncatedWidth };
@@ -1 +1,5 @@
1
- var r=Object.defineProperty;var e=(t,i)=>r(t,"name",{value:i,configurable:!0});import{getStringTruncatedWidth as n}from"./get-string-truncated-width.js";var d=Object.defineProperty,g=e((t,i)=>d(t,"name",{value:i,configurable:!0}),"r");const o=g((t,i={})=>n(t,{...i,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");export{o as getStringWidth};
1
+ import { getStringTruncatedWidth } from './get-string-truncated-width.js';
2
+
3
+ const getStringWidth = (input, options = {}) => getStringTruncatedWidth(input, { ...options, ellipsis: "", ellipsisWidth: 0, limit: Number.POSITIVE_INFINITY }).width;
4
+
5
+ export { getStringWidth };
package/dist/index.js CHANGED
@@ -1 +1,36 @@
1
- import{alignText as t}from"./align-text.js";import{default as o}from"./case/camel-case.js";import{default as s}from"./case/capital-case.js";import{default as m}from"./case/constant-case.js";import{default as x}from"./case/dot-case.js";import{default as d}from"./case/flat-case.js";import{flipCase as u}from"./case/flip-case.js";import{default as C}from"./case/identify-case.js";import{kebabCase as S}from"./case/kebab-case.js";import{default as y}from"./case/lower-first.js";import{default as k}from"./case/no-case.js";import{default as b}from"./case/pascal-case.js";import{default as O}from"./case/pascal-snake-case.js";import{default as T}from"./case/path-case.js";import{default as B}from"./case/sentence-case.js";import{default as M}from"./case/snake-case.js";import{splitByCase as P}from"./case/split-by-case.js";import{default as v}from"./case/title-case.js";import{default as A}from"./case/train-case.js";import{default as G}from"./case/upper-first.js";import{default as I}from"./packem_shared/joinSegments-DTGeJBZG.js";import{closestString as K}from"./closest-string.js";import{compareSimilarity as Q}from"./compare-similarity.js";import{getStringTruncatedWidth as V}from"./get-string-truncated-width.js";import{getStringWidth as Y}from"./get-string-width.js";import{closest as _,distance as $}from"./packem_shared/closest-uarbVSbs.js";import{closestN as re}from"./packem_shared/closestN-DjNxwK0t.js";import{outdent as ae}from"./outdent.js";import{default as fe}from"./packem_shared/replaceString-DwIZyvoL.js";import{slice as pe}from"./slice.js";import{default as le}from"./slugify.js";import{default as ie}from"./packem_shared/transliterate-CxVHmZUa.js";import{truncate as ne}from"./truncate.js";import{escapeRegExp as ce,findStringOccurrences as Ce,hasChinese as ge,hasPunctuationOrSpace as Se,inRange as he}from"./utilities.js";import{wordSimilaritySort as We}from"./word-similarity-sort.js";import{WrapMode as we,wordWrap as be}from"./word-wrap.js";export{we as WrapMode,t as alignText,o as camelCase,s as capitalCase,_ as closest,re as closestN,K as closestString,Q as compareSimilarity,m as constantCase,$ as distance,x as dotCase,ce as escapeRegExp,Ce as findStringOccurrences,d as flatCase,u as flipCase,V as getStringTruncatedWidth,Y as getStringWidth,ge as hasChinese,Se as hasPunctuationOrSpace,C as identifyCase,he as inRange,I as joinSegments,S as kebabCase,y as lowerFirst,k as noCase,ae as outdent,b as pascalCase,O as pascalSnakeCase,T as pathCase,fe as replaceString,B as sentenceCase,pe as slice,le as slugify,M as snakeCase,P as splitByCase,v as titleCase,A as trainCase,ie as transliterate,ne as truncate,G as upperFirst,We as wordSimilaritySort,be as wordWrap};
1
+ export { alignText } from './align-text.js';
2
+ export { default as camelCase } from './case/camel-case.js';
3
+ export { default as capitalCase } from './case/capital-case.js';
4
+ export { default as constantCase } from './case/constant-case.js';
5
+ export { default as dotCase } from './case/dot-case.js';
6
+ export { default as flatCase } from './case/flat-case.js';
7
+ export { flipCase } from './case/flip-case.js';
8
+ export { default as identifyCase } from './case/identify-case.js';
9
+ export { kebabCase } from './case/kebab-case.js';
10
+ export { default as lowerFirst } from './case/lower-first.js';
11
+ export { default as noCase } from './case/no-case.js';
12
+ export { default as pascalCase } from './case/pascal-case.js';
13
+ export { default as pascalSnakeCase } from './case/pascal-snake-case.js';
14
+ export { default as pathCase } from './case/path-case.js';
15
+ export { default as sentenceCase } from './case/sentence-case.js';
16
+ export { default as snakeCase } from './case/snake-case.js';
17
+ export { splitByCase } from './case/split-by-case.js';
18
+ export { default as titleCase } from './case/title-case.js';
19
+ export { default as trainCase } from './case/train-case.js';
20
+ export { default as upperFirst } from './case/upper-first.js';
21
+ export { default as joinSegments } from './packem_shared/joinSegments-CuU8RGpP.js';
22
+ export { closestString } from './closest-string.js';
23
+ export { compareSimilarity } from './compare-similarity.js';
24
+ export { getStringTruncatedWidth } from './get-string-truncated-width.js';
25
+ export { getStringWidth } from './get-string-width.js';
26
+ export { closestN } from './packem_shared/closestN-BREy4E7C.js';
27
+ export { outdent } from './outdent.js';
28
+ export { default as replaceString } from './packem_shared/replaceString-vYvRBMfC.js';
29
+ export { slice } from './slice.js';
30
+ export { default as slugify } from './slugify.js';
31
+ export { default as transliterate } from './packem_shared/transliterate-CUF6Ggy_.js';
32
+ export { truncate } from './truncate.js';
33
+ export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange } from './utilities.js';
34
+ export { wordSimilaritySort } from './word-similarity-sort.js';
35
+ export { WrapMode, wordWrap } from './word-wrap.js';
36
+ export { closest, distance } from './packem_shared/closest-IHuSvnSn.js';