@visulima/string 3.1.0 → 3.1.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE.md +55 -129
  3. package/README.md +2 -2
  4. package/dist/align-text.js +2 -2
  5. package/dist/case/camel-case.js +1 -1
  6. package/dist/case/capital-case.js +1 -1
  7. package/dist/case/constant-case.js +1 -1
  8. package/dist/case/dot-case.js +1 -1
  9. package/dist/case/flat-case.js +1 -1
  10. package/dist/case/flip-case.js +1 -1
  11. package/dist/case/identify-case.js +1 -1
  12. package/dist/case/index.js +1 -1
  13. package/dist/case/kebab-case.js +1 -1
  14. package/dist/case/lower-first.js +1 -1
  15. package/dist/case/no-case.js +1 -1
  16. package/dist/case/pascal-case.js +1 -1
  17. package/dist/case/pascal-snake-case.js +1 -1
  18. package/dist/case/path-case.js +1 -1
  19. package/dist/case/sentence-case.js +1 -1
  20. package/dist/case/snake-case.js +1 -1
  21. package/dist/case/split-by-case.js +1 -1
  22. package/dist/case/title-case.js +1 -1
  23. package/dist/case/train-case.js +1 -1
  24. package/dist/case/upper-first.js +1 -1
  25. package/dist/closest-string.js +1 -1
  26. package/dist/compare-similarity.js +1 -1
  27. package/dist/count-occurrences.js +1 -1
  28. package/dist/direction.js +1 -1
  29. package/dist/east-asian-width.d.ts +5 -1
  30. package/dist/east-asian-width.js +1 -1
  31. package/dist/excerpt.js +55 -44
  32. package/dist/get-string-truncated-width.js +1 -1
  33. package/dist/indent.d.ts +3 -1
  34. package/dist/indent.js +1 -1
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +1 -1
  37. package/dist/is-fullwidth-code-point.js +1 -1
  38. package/dist/levenshtein.js +1 -1
  39. package/dist/outdent.js +1 -1
  40. package/dist/packem_shared/{_isFullWidth-Dqc3MWgl.js → _isFullWidth-dWWDw5Is.js} +1 -1
  41. package/dist/packem_shared/ansi-state-tracker-BFhXTS-5.js +1 -0
  42. package/dist/packem_shared/closest-CSX4px2F.js +1 -0
  43. package/dist/packem_shared/constants-BGGeBKGT.js +1 -0
  44. package/dist/packem_shared/dedent-CDXp3nZQ.js +1 -0
  45. package/dist/packem_shared/eastAsianWidth-DACe9Ds2.js +1 -0
  46. package/dist/packem_shared/generate-cache-key-th9N8-CB.js +1 -0
  47. package/dist/packem_shared/indent-CY079Qyq.js +1 -0
  48. package/dist/packem_shared/joinSegments-9qx7xSy7.js +1 -0
  49. package/dist/packem_shared/{lru-cache-BtMSrYQJ.js → lru-cache-BD25OaEQ.js} +1 -1
  50. package/dist/packem_shared/normalize-german-eszett-DtW4F-Wg.js +1 -0
  51. package/dist/packem_shared/redent-lctoaAtw.js +1 -0
  52. package/dist/packem_shared/{strip-vt-control-characters-BW1RglLp.js → strip-vt-control-characters-vMeu7uFw.js} +1 -1
  53. package/dist/replace-string.js +1 -1
  54. package/dist/slice.js +1 -1
  55. package/dist/slugify.js +1 -1
  56. package/dist/test/utils.js +10 -10
  57. package/dist/transliterate.js +3 -3
  58. package/dist/truncate.js +1 -1
  59. package/dist/utilities.js +1 -1
  60. package/dist/word-similarity-sort.js +1 -1
  61. package/dist/word-wrap.js +5 -7
  62. package/package.json +1 -1
  63. package/dist/packem_shared/closest-C6YDQs4m.js +0 -1
  64. package/dist/packem_shared/constants-aPzGW29R.js +0 -1
  65. package/dist/packem_shared/dedent-CPjAYUXh.js +0 -1
  66. package/dist/packem_shared/eastAsianWidth-DJV8Kqd-.js +0 -1
  67. package/dist/packem_shared/generate-cache-key-B_0X7MKm.js +0 -1
  68. package/dist/packem_shared/indent-cz8WMI0e.js +0 -1
  69. package/dist/packem_shared/joinSegments-CaHT-45s.js +0 -1
  70. package/dist/packem_shared/normalize-german-eszett-hNMwtGjd.js +0 -1
  71. package/dist/packem_shared/redent-ByOoJ6fN.js +0 -1
@@ -1 +1 @@
1
- import{eastAsianWidthType as j}from"./packem_shared/eastAsianWidth-DJV8Kqd-.js";import{R as O,a as m,b as _}from"./packem_shared/constants-aPzGW29R.js";const E=new Map,y=i=>[i.ambiguousIsNarrow?1:0,i.control,i.fullWidth,i.regular,i.wide].join("|"),z=i=>{const t=y(i.width);let e=E.get(t);return e||(e=new Map,E.set(t,e)),e},b=new RegExp(O.source,"y"),x=new RegExp(_.source,"uy"),g=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,R=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",B=(i,t)=>{const e=z(t),s=Math.floor(i/65536),u=i%65536;let c=e.get(s);if(c||(c=new Map,e.set(s,c)),c.has(u))return c.get(u);let a;switch(R(i)){case"control":{a=t.width.control;break}case"latin":{a=t.width.regular;break}case"wide":{a=t.width.wide;break}case"zero":{a=0;break}default:switch(j(i)){case"ambiguous":{a=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{a=t.width.fullWidth;break}case"wide":{a=t.width.wide;break}default:a=t.width.regular}}return c.set(u,a),a},P=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,A=(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?A(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}},s=Math.max(0,e.truncation.limit-e.truncation.ellipsisWidth),{length:u}=i,c=u>1e4;let a=0,n=0,l=u,r=!1;const T=i.includes("\x1B")||i.includes("›");for(;a<u;){if(T&&(i[a]==="\x1B"||i[a]==="›")){if(i.startsWith("\x1B]8;;",a)){const o="\x1B]8;;\x07",h=o.length,W=i.indexOf("\x07",a+5);if(W!==-1){const p=i.indexOf(o,W+1);if(p!==-1){const F=p+h,C=i.slice(W+1,p).replace(O,""),N=A(C,{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,s-n),regularWidth:e.width.regular,tabWidth:e.width.tab,wideWidth:e.width.wide}),I=N.width;if(N.truncated)r=!0,l=Math.min(l,a);else if(n+I>s&&(l=Math.min(l,a),r=!0,n+I>e.truncation.limit))break;if(n+=I,a=F,r&&n>=e.truncation.limit)break;continue}}}if(b.lastIndex=a,b.test(i)){const o=b.lastIndex-a,h=e.truncation.countAnsiEscapeCodes?o:e.width.ansi;if(n+h>s&&(l=Math.min(l,a),n+h>e.truncation.limit)){r=!0;break}n+=h,a=b.lastIndex;continue}}const w=i.codePointAt(a);if(w===8203||w===65279||w>=8288&&w<=8292){a+=1;continue}if(w===9){if(n+e.width.tab>s&&(l=Math.min(l,a),n+e.width.tab>e.truncation.limit)){r=!0;break}n+=e.width.tab,a+=1;continue}if(g.lastIndex=a,g.test(i)){const o=(g.lastIndex-a)*e.width.regular;if(n+o>s){const h=e.width.regular>0?Math.floor((s-n)/e.width.regular):0;if(l=Math.min(l,a+h),n+o>e.truncation.limit){r=!0;break}}n+=o,a=g.lastIndex;continue}if((w<=31||w>=127&&w<=159)&&(m.lastIndex=a,m.test(i))){const o=(m.lastIndex-a)*e.width.control;if(n+o>s){const h=e.width.control>0?Math.floor((s-n)/e.width.control):0;if(l=Math.min(l,a+h),n+o>e.truncation.limit){r=!0;break}}n+=o,a=m.lastIndex;continue}if(x.lastIndex=a,x.test(i)){if(n+e.width.emoji>s&&(l=Math.min(l,a),n+e.width.emoji>e.truncation.limit)){r=!0;break}n+=e.width.emoji,a=x.lastIndex;continue}const f=i.codePointAt(a)??0;if(P(f)){a+=f>65535?2:1;continue}let d;if(c)d=B(f,e);else switch(R(f)){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(j(f)){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>s&&(l=Math.min(l,a),n+d>e.truncation.limit)){r=!0;break}n+=d,a+=f>65535?2:1}let k=n,M=!1;return r&&e.truncation.limit>=e.truncation.ellipsisWidth&&(k=e.truncation.limit,M=!0),{ellipsed:M,index:r?l:u,truncated:r,width:k}};export{A as getStringTruncatedWidth};
1
+ import{eastAsianWidthType as R}from"./packem_shared/eastAsianWidth-DACe9Ds2.js";import{R as j,a as S,b as g}from"./packem_shared/constants-BGGeBKGT.js";const N=new Map,p=t=>[t.ambiguousIsNarrow?1:0,t.control,t.fullWidth,t.regular,t.wide].join("|"),F=t=>{const i=p(t.width);let a=N.get(i);return a||(a=new Map,N.set(i,a)),a},I=new RegExp(S.source,"y"),E=new RegExp(j.source,"uy"),x=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,_=t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other",Y=(t,i)=>{const a=F(i),h=Math.floor(t/65536),w=t%65536;let f=a.get(h);if(f||(f=new Map,a.set(h,f)),f.has(w))return f.get(w);let r;switch(_(t)){case"control":{r=i.width.control;break}case"latin":{r=i.width.regular;break}case"wide":{r=i.width.wide;break}case"zero":{r=0;break}default:switch(R(t)){case"ambiguous":{r=i.width.ambiguousIsNarrow?i.width.regular:i.width.wide;break}case"fullwidth":{r=i.width.fullWidth;break}case"wide":{r=i.width.wide;break}default:r=i.width.regular}}return f.set(w,r),r},z=t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,O=(t,i={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const a={truncation:{countAnsiEscapeCodes:i.countAnsiEscapeCodes??!1,ellipsis:i.ellipsis??"",ellipsisWidth:i.ellipsisWidth??(i.ellipsis?O(i.ellipsis,{...i,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:i.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:i.ambiguousIsNarrow??!1,ansi:i.ansiWidth??0,control:i.controlWidth??0,emoji:i.emojiWidth??2,fullWidth:i.fullWidth??2,halfWidth:i.halfWidth??1,regular:i.regularWidth??1,tab:i.tabWidth??8,wide:i.wideWidth??2}},h=Math.max(0,a.truncation.limit-a.truncation.ellipsisWidth),{length:w}=t,f=w>1e4;let r=0,e=0,s=w,u=!1;const A=t.includes("\x1B")||t.includes("›");for(;r<w;){if(A&&(t[r]==="\x1B"||t[r]==="›")){if(t.startsWith("\x1B]8;;",r)){const l="\x1B]8;;\x07",b=l.length,c=t.indexOf("\x07",r+5);if(c!==-1){const k=t.indexOf(l,c+1);if(k!==-1){const y=k+b,B=t.slice(c+1,k).replace(S,""),M=O(B,{ambiguousIsNarrow:a.width.ambiguousIsNarrow,ansiWidth:a.width.ansi,controlWidth:a.width.control,countAnsiEscapeCodes:!1,ellipsis:a.truncation.ellipsis,ellipsisWidth:a.truncation.ellipsisWidth,emojiWidth:a.width.emoji,fullWidth:a.width.fullWidth,halfWidth:a.width.halfWidth,limit:Math.max(0,h-e),regularWidth:a.width.regular,tabWidth:a.width.tab,wideWidth:a.width.wide}),C=M.width;if(M.truncated)u=!0,s=Math.min(s,r);else if(e+C>h&&(s=Math.min(s,r),u=!0,e+C>a.truncation.limit))break;if(e+=C,r=y,u&&e>=a.truncation.limit)break;continue}}}if(I.lastIndex=r,I.test(t)){const W=I.lastIndex-r,l=a.truncation.countAnsiEscapeCodes?W:a.width.ansi;if(e+l>h&&(s=Math.min(s,r),e+l>a.truncation.limit)){u=!0;break}e+=l,r=I.lastIndex;continue}}const m=t.codePointAt(r);if(m===8203||m===65279||m>=8288&&m<=8292){r+=1;continue}if(m===9){if(e+a.width.tab>h&&(s=Math.min(s,r),e+a.width.tab>a.truncation.limit)){u=!0;break}e+=a.width.tab,r+=1;continue}if(x.lastIndex=r,x.test(t)){const l=(x.lastIndex-r)*a.width.regular;if(e+l>h){const b=a.width.regular>0?Math.floor((h-e)/a.width.regular):0;if(s=Math.min(s,r+b),e+l>a.truncation.limit){u=!0;break}}e+=l,r=x.lastIndex;continue}if((m<=31||m>=127&&m<=159)&&(g.lastIndex=r,g.test(t))){const l=(g.lastIndex-r)*a.width.control;if(e+l>h){const b=a.width.control>0?Math.floor((h-e)/a.width.control):0;if(s=Math.min(s,r+b),e+l>a.truncation.limit){u=!0;break}}e+=l,r=g.lastIndex;continue}if(E.lastIndex=r,E.test(t)){if(e+a.width.emoji>h&&(s=Math.min(s,r),e+a.width.emoji>a.truncation.limit)){u=!0;break}e+=a.width.emoji,r=E.lastIndex;continue}const d=t.codePointAt(r)??0;if(z(d)){r+=d>65535?2:1;continue}let n;if(f)n=Y(d,a);else switch(_(d)){case"control":{n=a.width.control;break}case"latin":{n=a.width.regular;break}case"wide":{n=a.width.wide;break}case"zero":{n=0;break}default:switch(R(d)){case"ambiguous":{n=a.width.ambiguousIsNarrow?a.width.regular:a.width.wide;break}case"fullwidth":{n=a.width.fullWidth;break}case"wide":{n=a.width.wide;break}default:n=a.width.regular}}if(e+n>h&&(s=Math.min(s,r),e+n>a.truncation.limit)){u=!0;break}e+=n,r+=d>65535?2:1}let T=e,L=!1;return u&&a.truncation.limit>=a.truncation.ellipsisWidth&&(T=a.truncation.limit,L=!0),{ellipsed:L,index:u?s:w,truncated:u,width:T}};export{O as getStringTruncatedWidth};
package/dist/indent.d.ts CHANGED
@@ -85,4 +85,6 @@ dedent(`
85
85
  ```
86
86
  */
87
87
  declare function dedent(string: string): string;
88
- export { type Options as IndentOptions, dedent, indentString as indent, redent, stripIndent };
88
+ export {
89
+
90
+ type Options as IndentOptions, dedent, indentString as indent, redent, stripIndent };
package/dist/indent.js CHANGED
@@ -1 +1 @@
1
- import{default as d}from"./packem_shared/indent-cz8WMI0e.js";import{default as a}from"./packem_shared/redent-ByOoJ6fN.js";import{dedent as n,default as o}from"./packem_shared/dedent-CPjAYUXh.js";export{n as dedent,d as indent,a as redent,o as stripIndent};
1
+ import{default as d}from"./packem_shared/indent-CY079Qyq.js";import{default as a}from"./packem_shared/redent-lctoaAtw.js";import{dedent as n,default as o}from"./packem_shared/dedent-CDXp3nZQ.js";export{n as dedent,d as indent,a as redent,o as stripIndent};
package/dist/index.d.ts CHANGED
@@ -24,11 +24,9 @@ export { type ClosestStringOptions, closestString } from "./closest-string.js";
24
24
  export { type CompareSimilarityOptions, compareSimilarity } from "./compare-similarity.js";
25
25
  export { countOccurrences } from "./count-occurrences.js";
26
26
  export { direction } from "./direction.js";
27
- export { type EastAsianWidthOptions, type EastAsianWidthType, eastAsianWidth, eastAsianWidthType } from "./east-asian-width.js";
28
27
  export { type ExcerptOptions, excerpt } from "./excerpt.js";
29
28
  export { type StringTruncatedWidthOptions, type StringTruncatedWidthResult, getStringTruncatedWidth } from "./get-string-truncated-width.js";
30
29
  export { type StringWidthOptions, getStringWidth } from "./get-string-width.js";
31
- export { type IndentOptions, dedent, indent, redent, stripIndent } from "./indent.js";
32
30
  export { default as isFullwidthCodePoint } from "./is-fullwidth-code-point.js";
33
31
  export { closest, closestN, distance, similarity } from "./levenshtein.js";
34
32
  export { type Outdent, type Options as OutdentOptions, outdent } from "./outdent.js";
@@ -41,3 +39,5 @@ export type { A as All, a as Any, C as CharAt, b as Charmap, c as Concat, E as E
41
39
  export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange } from "./utilities.js";
42
40
  export { type WordSimilaritySortOptions, wordSimilaritySort } from "./word-similarity-sort.js";
43
41
  export { type WordWrapOptions, WrapMode, wordWrap } from "./word-wrap.js";
42
+ export { type EastAsianWidthOptions, type EastAsianWidthType, eastAsianWidth, eastAsianWidthType } from "./east-asian-width.js";
43
+ export { type IndentOptions, dedent, indent, redent, stripIndent } from "./indent.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{alignText as r}from"./align-text.js";import{default as a}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 i}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 w}from"./case/no-case.js";import{default as F}from"./case/pascal-case.js";import{default as T}from"./case/pascal-snake-case.js";import{default as A}from"./case/path-case.js";import{default as R}from"./case/sentence-case.js";import{default as B}from"./case/snake-case.js";import{splitByCase as I}from"./case/split-by-case.js";import{default as N}from"./case/title-case.js";import{default as v}from"./case/train-case.js";import{default as D}from"./case/upper-first.js";import{default as H}from"./packem_shared/joinSegments-CaHT-45s.js";import{closestString as K}from"./closest-string.js";import{compareSimilarity as Q}from"./compare-similarity.js";import{countOccurrences as V}from"./count-occurrences.js";import{direction as Y}from"./direction.js";import{excerpt as _}from"./excerpt.js";import{getStringTruncatedWidth as ee}from"./get-string-truncated-width.js";import{getStringWidth as re}from"./get-string-width.js";import{default as ae}from"./is-fullwidth-code-point.js";import{closestN as se,similarity as pe}from"./levenshtein.js";import{outdent as xe}from"./outdent.js";import{default as le}from"./replace-string.js";import{slice as ne}from"./slice.js";import{default as ce}from"./slugify.js";import{default as ge}from"./transliterate.js";import{truncate as he}from"./truncate.js";import{escapeRegExp as We,findStringOccurrences as we,hasChinese as ke,hasPunctuationOrSpace as Fe,inRange as Oe}from"./utilities.js";import{wordSimilaritySort as be}from"./word-similarity-sort.js";import{WrapMode as Pe,wordWrap as Re}from"./word-wrap.js";import{default as Be}from"./packem_shared/indent-cz8WMI0e.js";import{default as Ie}from"./packem_shared/redent-ByOoJ6fN.js";import{dedent as Ne,default as qe}from"./packem_shared/dedent-CPjAYUXh.js";import{closest as ze,distance as De}from"./packem_shared/closest-C6YDQs4m.js";import{eastAsianWidth as He,eastAsianWidthType as Je}from"./packem_shared/eastAsianWidth-DJV8Kqd-.js";export{Pe as WrapMode,r as alignText,a as camelCase,s as capitalCase,ze as closest,se as closestN,K as closestString,Q as compareSimilarity,m as constantCase,V as countOccurrences,Ne as dedent,Y as direction,De as distance,i as dotCase,He as eastAsianWidth,Je as eastAsianWidthType,We as escapeRegExp,_ as excerpt,we as findStringOccurrences,d as flatCase,u as flipCase,ee as getStringTruncatedWidth,re as getStringWidth,ke as hasChinese,Fe as hasPunctuationOrSpace,C as identifyCase,Oe as inRange,Be as indent,ae as isFullwidthCodePoint,H as joinSegments,S as kebabCase,y as lowerFirst,w as noCase,xe as outdent,F as pascalCase,T as pascalSnakeCase,A as pathCase,Ie as redent,le as replaceString,R as sentenceCase,pe as similarity,ne as slice,ce as slugify,B as snakeCase,I as splitByCase,qe as stripIndent,N as titleCase,v as trainCase,ge as transliterate,he as truncate,D as upperFirst,be as wordSimilaritySort,Re as wordWrap};
1
+ import{alignText as r}from"./align-text.js";import{default as a}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 i}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 w}from"./case/no-case.js";import{default as F}from"./case/pascal-case.js";import{default as T}from"./case/pascal-snake-case.js";import{default as A}from"./case/path-case.js";import{default as R}from"./case/sentence-case.js";import{default as B}from"./case/snake-case.js";import{splitByCase as I}from"./case/split-by-case.js";import{default as N}from"./case/title-case.js";import{default as v}from"./case/train-case.js";import{default as D}from"./case/upper-first.js";import{default as H}from"./packem_shared/joinSegments-9qx7xSy7.js";import{closestString as K}from"./closest-string.js";import{compareSimilarity as Q}from"./compare-similarity.js";import{countOccurrences as V}from"./count-occurrences.js";import{direction as Y}from"./direction.js";import{excerpt as _}from"./excerpt.js";import{getStringTruncatedWidth as ee}from"./get-string-truncated-width.js";import{getStringWidth as re}from"./get-string-width.js";import{default as ae}from"./is-fullwidth-code-point.js";import{closestN as se,similarity as pe}from"./levenshtein.js";import{outdent as xe}from"./outdent.js";import{default as le}from"./replace-string.js";import{slice as ne}from"./slice.js";import{default as ce}from"./slugify.js";import{default as ge}from"./transliterate.js";import{truncate as he}from"./truncate.js";import{escapeRegExp as We,findStringOccurrences as we,hasChinese as ke,hasPunctuationOrSpace as Fe,inRange as Oe}from"./utilities.js";import{wordSimilaritySort as be}from"./word-similarity-sort.js";import{WrapMode as Pe,wordWrap as Re}from"./word-wrap.js";import{default as Be}from"./packem_shared/indent-CY079Qyq.js";import{default as Ie}from"./packem_shared/redent-lctoaAtw.js";import{dedent as Ne,default as qe}from"./packem_shared/dedent-CDXp3nZQ.js";import{closest as ze,distance as De}from"./packem_shared/closest-CSX4px2F.js";import{eastAsianWidth as He,eastAsianWidthType as Je}from"./packem_shared/eastAsianWidth-DACe9Ds2.js";export{Pe as WrapMode,r as alignText,a as camelCase,s as capitalCase,ze as closest,se as closestN,K as closestString,Q as compareSimilarity,m as constantCase,V as countOccurrences,Ne as dedent,Y as direction,De as distance,i as dotCase,He as eastAsianWidth,Je as eastAsianWidthType,We as escapeRegExp,_ as excerpt,we as findStringOccurrences,d as flatCase,u as flipCase,ee as getStringTruncatedWidth,re as getStringWidth,ke as hasChinese,Fe as hasPunctuationOrSpace,C as identifyCase,Oe as inRange,Be as indent,ae as isFullwidthCodePoint,H as joinSegments,S as kebabCase,y as lowerFirst,w as noCase,xe as outdent,F as pascalCase,T as pascalSnakeCase,A as pathCase,Ie as redent,le as replaceString,R as sentenceCase,pe as similarity,ne as slice,ce as slugify,B as snakeCase,I as splitByCase,qe as stripIndent,N as titleCase,v as trainCase,ge as transliterate,he as truncate,D as upperFirst,be as wordSimilaritySort,Re as wordWrap};
@@ -1 +1 @@
1
- import{isFullWidth as i,isWide as t}from"./packem_shared/_isFullWidth-Dqc3MWgl.js";const r=s=>Number.isInteger(s)?i(s)||t(s):!1;export{r as default};
1
+ import{isFullWidth as e,isWide as i}from"./packem_shared/_isFullWidth-dWWDw5Is.js";const s=r=>Number.isInteger(r)?e(r)||i(r):!1;export{s as default};
@@ -1 +1 @@
1
- import{distance as c}from"./packem_shared/closest-C6YDQs4m.js";import{closest as y}from"./packem_shared/closest-C6YDQs4m.js";const u=(r,s,o)=>{const e=Array.from({length:o}).fill(1/0),n=Array.from({length:o}).fill(void 0);for(const a of s){const f=a;let l=c(r,f),i=f;for(let t=0;t<o;t+=1)if(l<e[t]){const m=e[t],h=n[t];e[t]=l,n[t]=i,l=m,i=h}}return n},d=(r,s)=>{if(r===s)return 1;const o=Math.max(r.length,s.length);return o===0?1:1-c(r,s)/o};export{y as closest,u as closestN,c as distance,d as similarity};
1
+ import{distance as a}from"./packem_shared/closest-CSX4px2F.js";import{closest as x}from"./packem_shared/closest-CSX4px2F.js";const h=(r,n,e)=>{const o=Array.from({length:e}).fill(1/0),s=Array.from({length:e}).fill(void 0);for(const f of n){const c=f;let l=a(r,c),i=c;for(let t=0;t<e;t+=1)if(l<o[t]){const m=o[t],u=s[t];o[t]=l,s[t]=i,l=m,i=u}}return s},y=(r,n)=>{if(r===n)return 1;const e=Math.max(r.length,n.length);return e===0?1:1-a(r,n)/e};export{x as closest,h as closestN,a as distance,y as similarity};
package/dist/outdent.js CHANGED
@@ -1 +1 @@
1
- import{f as A,g as R,h as p,i as S,j as W,k as m}from"./packem_shared/constants-aPzGW29R.js";const I=(e,r)=>Object.hasOwn(e,r),T=(e,r)=>Object.assign(e,r),h=(e,r,n)=>{if(e.length===0)return[];let t=0;const s=m.exec(e[0]);s&&(t=s[1].length);const i=String.raw`(\r\n|\r|\n).{0,${t}}`,g=new RegExp(i,"g"),l=r?e.slice(1):e,{newline:N,trimLeadingNewline:_,trimTrailingNewline:o}=n,f=typeof N=="string",E=l.length,u=Array.from({length:E});for(let c=0;c<E;c++){let a=l[c];a=a.replace(g,"$1"),c===0&&_&&(a=a.replace(A,"")),c===E-1&&o&&(a=a.replace(R,"")),f&&(a=a.replaceAll(W,N)),u[c]=a}return u},O=(e,r)=>{const n=Array.from({length:e.length+r.length});let t=0;const s=e.length;for(;t<s-1;t++)n[t*2]=e[t],n[t*2+1]=String(r[t]);return n[t*2]=e[t],n.join("")},d=e=>I(e,"raw")&&I(e,"length"),j=new WeakMap,w=e=>{const r=e.cache!==!1,n=r?e.cacheStore??j:void 0,t=e.newline!==void 0;function s(i,...g){if(d(i)){const l=i,N=g.length;if(l.length===1&&l[0]==="")return"";if(N===0){if(r&&n&&!t){const E=n.get(l);if(E)return E[0]}const f=h(l,!1,e);return r&&n&&n.set(l,f),f[0]}const _=(g[0]===s||g[0]===L)&&p.test(l[0])&&S.test(l[1]);let o;return r&&n&&!t&&(o=n.get(l)),o||(o=h(l,_,e),r&&n&&n.set(l,o)),O(o,_?g.slice(1):g)}return w(T(T({},e),i))}return T(s,{string(i){return i===""||!i?"":h([i],!1,e)[0]}})},L=w({cache:!0,newline:null,trimLeadingNewline:!0,trimTrailingNewline:!0}),b=L;export{b as outdent};
1
+ import{f as S,g as w,h as L,i as m,j as R,k as W}from"./packem_shared/constants-BGGeBKGT.js";const _=(e,n)=>Object.hasOwn(e,n),N=(e,n)=>Object.assign(e,n),g=(e,n,t)=>{if(e.length===0)return[];let r=0;const i=R.exec(e[0]);i&&(r=i[1].length);const l=String.raw`(\r\n|\r|\n).{0,${r}}`,s=new RegExp(l,"g"),c=n?e.slice(1):e,{newline:E,trimLeadingNewline:I,trimTrailingNewline:d}=t,o=typeof E=="string",f=c.length,h=Array.from({length:f});for(let u=0;u<f;u++){let a=c[u];a=a.replace(s,"$1"),u===0&&I&&(a=a.replace(S,"")),u===f-1&&d&&(a=a.replace(w,"")),o&&(a=a.replaceAll(W,E)),h[u]=a}return h},O=(e,n)=>{const t=Array.from({length:e.length+n.length});let r=0;const i=e.length;for(;r<i-1;r++)t[r*2]=e[r],t[r*2+1]=String(n[r]);return t[r*2]=e[r],t.join("")},p=e=>_(e,"raw")&&_(e,"length"),x=new WeakMap,T=e=>{const n=e.cache!==!1,t=n?e.cacheStore??x:void 0,r=e.newline!==void 0;function i(l,...s){if(p(l)){const c=l,E=s.length;if(c.length===1&&c[0]==="")return"";if(E===0){if(n&&t&&!r){const h=t.get(c);if(h)return h[0]}const f=g(c,!1,e);return n&&t&&t.set(c,f),f[0]}const d=(s[0]===i||s[0]===A)&&L.test(c[0])&&m.test(c[1]);let o;return n&&t&&!r&&(o=t.get(c)),o||(o=g(c,d,e),n&&t&&t.set(c,o)),O(o,d?s.slice(1):s)}return T(N(N({},e),l))}return N(i,{string(l){return l===""||!l?"":g([l],!1,e)[0]}})},A=T({cache:!0,newline:null,trimLeadingNewline:!0,trimTrailingNewline:!0}),C=A;export{C as outdent};
@@ -1 +1 @@
1
- const r=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],d=12288,m=65510,f=[12288,12288,65281,65376,65504,65510],g=8361,h=65518,w=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],M=32,C=10630,P=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],c=4352,b=262141,t=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],u=(i,l)=>{let e=0,o=Math.floor(i.length/2)-1;for(;e<=o;){const n=Math.floor((e+o)/2),a=n*2;if(l<i[a])o=n-1;else if(l>i[a+1])e=n+1;else return!0}return!1},s=19968,[x,R]=W(t);function W(i){let l=i[0],e=i[1];for(let o=0;o<i.length;o+=2){const n=i[o],a=i[o+1];if(s>=n&&s<=a)return[n,a];a-n>e-l&&(l=n,e=a)}return[l,e]}const j=i=>i<161||i>1114109?!1:u(r,i),k=i=>i<d||i>m?!1:u(f,i),p=i=>i<g||i>h?!1:u(w,i),y=i=>i<M||i>C?!1:u(P,i),A=i=>i>=x&&i<=R?!0:i<c||i>b?!1:u(t,i);function E(i){return j(i)?"ambiguous":k(i)?"fullwidth":p(i)?"halfwidth":y(i)?"narrow":A(i)?"wide":"neutral"}export{E as getCategory,j as isAmbiguous,k as isFullWidth,A as isWide};
1
+ const l=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],f=12288,m=65510,h=[12288,12288,65281,65376,65504,65510],w=8361,d=65518,C=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],M=32,c=10630,g=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],x=4352,b=262141,o=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],e=(t,a)=>{let r=0,n=Math.floor(t.length/2)-1;for(;r<=n;){const i=Math.floor((r+n)/2),s=i*2;if(a<t[s])n=i-1;else if(a>t[s+1])r=i+1;else return!0}return!1},u=19968,[R,F]=W(o);function W(t){let a=t[0],r=t[1];for(let n=0;n<t.length;n+=2){const i=t[n],s=t[n+1];if(u>=i&&u<=s)return[i,s];s-i>r-a&&(a=i,r=s)}return[a,r]}const E=t=>t<161||t>1114109?!1:e(l,t),S=t=>t<f||t>m?!1:e(h,t),j=t=>t<w||t>d?!1:e(C,t),k=t=>t<M||t>c?!1:e(g,t),p=t=>t>=R&&t<=F?!0:t<x||t>b?!1:e(o,t);function y(t){return E(t)?"ambiguous":S(t)?"fullwidth":j(t)?"halfwidth":k(t)?"narrow":p(t)?"wide":"neutral"}export{y as getCategory,E as isAmbiguous,S as isFullWidth,p as isWide};
@@ -0,0 +1 @@
1
+ const g=/^(?:\u001B\[|\u009B)([\d:;]*)m$/,c=new Map([[1,22],[2,22],[3,23],[4,24],[5,25],[6,25],[7,27],[8,28],[9,29],[21,24],[53,55]]),p=new Set(c.values()),l=i=>{const t=i.split(";"),e=[];for(let s=0;s<t.length;s+=1){const r=t[s];if(r.includes(":")){e.push([r]);continue}const o=r===""?0:Number.parseInt(r,10);if(o===38||o===48||o===58){const a=t[s+1];let n=0;a==="5"?n=2:a==="2"?n=4:a?.includes(":")&&(n=1),e.push(t.slice(s,s+1+n)),s+=n;continue}e.push([r])}return e},u=i=>{const t=i[0],e=t.indexOf(":"),s=e===-1?t:t.slice(0,e);return s===""?0:Number.parseInt(s,10)},v=i=>i===38||i>=30&&i<=37||i>=90&&i<=97,h=i=>i===48||i>=40&&i<=47||i>=100&&i<=107,d=i=>{const t=l(i);if(t.length!==1)return;const e=u(t[0]);return v(e)?"foreground":h(e)?"background":void 0};class f{activeForeground=void 0;activeBackground=void 0;activeUnderlineColor=void 0;activeAttributes=new Map;processEscape(t){const e=g.exec(t);if(e)for(const s of l(e[1])){const r=u(s);switch(r){case 0:{this.resetAll();break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}case 59:{this.activeUnderlineColor=void 0;break}default:this.applyParameter(r,`\x1B[${s.join(";")}m`)}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,this.activeUnderlineColor,...this.activeAttributes.values()].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[...this.activeAttributes.keys()].toReversed().map(e=>`\x1B[${String(e)}m`);return this.activeUnderlineColor&&t.push("\x1B[59m"),this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}resetAll(){this.activeForeground=void 0,this.activeBackground=void 0,this.activeUnderlineColor=void 0,this.activeAttributes.clear()}applyParameter(t,e){if(!((t===38||t===48||t===58)&&!e.includes(";")&&!e.includes(":")))if(v(t))this.activeForeground=e;else if(h(t))this.activeBackground=e;else if(t===58)this.activeUnderlineColor=e;else if(p.has(t))this.activeAttributes.delete(t);else{const s=c.get(t);s!==void 0&&this.activeAttributes.set(s,e)}}}export{f as A,d as s};
@@ -0,0 +1 @@
1
+ const g=new Uint32Array(65536),z=(n,o)=>{const l=n.length,h=o.length,r=1<<l-1;let c=-1,m=0,a=l,s=l;for(;s--;)g[n.charCodeAt(s)]|=1<<s;for(s=0;s<h;s++){let d=g[o.charCodeAt(s)];const v=d|m;d|=(d&c)+c^c,m|=~(d|c),c&=d,m&r&&a++,c&r&&a--,m=m<<1|1,c=c<<1|~(v|m),m&=v}for(s=l;s--;)g[n.charCodeAt(s)]=0;return a},j=(n,o)=>{const l=o.length,h=n.length,r=[],c=[],m=Math.ceil(l/32),a=Math.ceil(h/32);for(let t=0;t<m;t++)c[t]=-1,r[t]=0;let s=0;for(;s<a-1;s++){let t=0,i=-1;const C=s*32,A=Math.min(32,h)+C;for(let e=C;e<A;e++)g[n.charCodeAt(e)]|=1<<e;for(let e=0;e<l;e++){const x=g[o.charCodeAt(e)],p=c[e/32|0]>>>e&1,f=r[e/32|0]>>>e&1,_=x|t,w=((x|f)&i)+i^i|x|f;let u=t|~(w|i),q=i&w;u>>>31^p&&(c[e/32|0]^=1<<e),q>>>31^f&&(r[e/32|0]^=1<<e),u=u<<1|p,q=q<<1|f,i=q|~(_|u),t=u&_}for(let e=C;e<A;e++)g[n.charCodeAt(e)]=0}let d=0,v=-1;const k=s*32,M=Math.min(32,h-k)+k;for(let t=k;t<M;t++)g[n.charCodeAt(t)]|=1<<t;let y=h;for(let t=0;t<l;t++){const i=g[o.charCodeAt(t)],C=c[t/32|0]>>>t&1,A=r[t/32|0]>>>t&1,e=i|d,x=((i|A)&v)+v^v|i|A;let p=d|~(x|v),f=v&x;y+=p>>>h-1&1,y-=f>>>h-1&1,p>>>31^C&&(c[t/32|0]^=1<<t),f>>>31^A&&(r[t/32|0]^=1<<t),p=p<<1|C,f=f<<1|A,v=f|~(e|p),d=p&e}for(let t=k;t<M;t++)g[n.charCodeAt(t)]=0;return y},I=(n,o)=>{if(n.length<o.length){const l=o;o=n,n=l}return o.length===0?n.length:n.length<=32?z(n,o):j(n,o)},U=(n,o)=>{let l=1/0,h=0;for(let r=0;r<o.length;r++){const c=I(n,o[r]);c<l&&(l=c,h=r)}return o[h]};export{U as closest,I as distance};
@@ -0,0 +1 @@
1
+ const n=String.raw,E=n`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,t=()=>new RegExp(n`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${E}(?:\u200D${E})*`,"gu"),p=new Set(["\x1B","›"]),a="\x07",c="]8;;",u=/[\u200B\uFEFF\u2060-\u2064]/g,e=/^[ \t]*(?:\r\n|\r|\n)/,_=/(?:\r\n|\r|\n)[ \t]*$/,r=/^(?:[\r\n]|$)/,A=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,o=/^[ \t]*[\r\n][ \t\r\n]*$/,S=/\r\n|\n|\r/g,i=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\)|\][^\u0007\u001B]{0,1000}(?:\u0007|\u001B\\))/g,I=/\u001B\[[\d;]*m[^\u001B]*(?:\u001B\[[\d;]*m|$)/g,g=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)[^\u001B]*\u001B\]8;;(?:\u0007|\u001B\\)/g,N=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,R=t(),L=/[-_./\s]+/g,T=/(\u001B\[[0-9;]*[a-z])/i,x=new RegExp("\\p{Script=Arabic}","u"),w=new RegExp("\\p{Script=Bengali}","u"),B=new RegExp("\\p{Script=Cyrillic}","u"),H=new RegExp("\\p{Script=Devanagari}","u"),G=new RegExp("\\p{Script=Ethiopic}","u"),O=new RegExp("\\p{Script=Greek}","u"),K=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),M=new RegExp("\\p{Script=Gujarati}","u"),C=new RegExp("\\p{Script=Gurmukhi}","u"),F=new RegExp("\\p{Script=Hangul}","u"),D=new RegExp("\\p{Script=Hebrew}","u"),l=new RegExp("\\p{Script=Hiragana}","u"),m=new RegExp("\\p{Script=Han}","u"),P=new RegExp("\\p{Script=Kannada}","u"),W=new RegExp("\\p{Script=Katakana}","u"),d=new RegExp("\\p{Script=Khmer}","u"),y=new RegExp("\\p{Script=Lao}","u"),U=new RegExp("\\p{Script=Latin}","u"),Y=new RegExp("\\p{Script=Malayalam}","u"),$=new RegExp("\\p{Script=Myanmar}","u"),h=new RegExp("\\p{Script=Oriya}","u"),k=new RegExp("\\p{Script=Sinhala}","u"),j=new RegExp("\\p{Script=Tamil}","u"),b=new RegExp("\\p{Script=Telugu}","u"),J=new RegExp("\\p{Script=Thai}","u"),V=new RegExp("\\p{Script=Tibetan}","u"),Z=/[\u02BB\u02BC\u0027]/u,f=s=>s.replace(R,"");export{M as A,C as B,P as C,j as D,b as E,Y as F,k as G,J as H,y as I,V as J,$ as K,G as L,d as M,h as N,p as O,c as P,a as Q,R,u as S,i as a,N as b,T as c,I as d,g as e,e as f,_ as g,o as h,r as i,A as j,S as k,B as l,U as m,O as n,K as o,Z as p,W as q,m as r,f as s,l as t,F as u,D as v,x as w,L as x,H as y,w as z};
@@ -0,0 +1 @@
1
+ function I(t){const n=t.match(/^[ \t]*(?=\S)/gm);if(!n)return t;let e=Number.POSITIVE_INFINITY;for(const r of n)e=Math.min(e,r.length);return e===0||e===Number.POSITIVE_INFINITY?t:t.replace(new RegExp(`^[ \\t]{${e}}`,"gm"),"")}function m(t){const n=t.replace(/^(?:[ \t]*\r?\n)+|(?:\r?\n[ \t]*)+$/g,"");return I(n)}export{m as dedent,I as default};
@@ -0,0 +1 @@
1
+ import{isFullWidth as r,isWide as s,isAmbiguous as a,getCategory as u}from"./_isFullWidth-dWWDw5Is.js";function i(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function n(e){return i(e),u(e)}function p(e,{ambiguousAsWide:t=!1}={}){return i(e),r(e)||s(e)||t&&a(e)?2:1}export{r as _isFullWidth,s as _isWide,p as eastAsianWidth,n as eastAsianWidthType};
@@ -0,0 +1 @@
1
+ const r=(a,e)=>`${a}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}::${e?.stripAnsi?"true":"false"}::${e?.stripEmoji?"true":"false"}::${e?.handleAnsi?"true":"false"}::${e?.handleEmoji?"true":"false"}`;export{r as g};
@@ -0,0 +1 @@
1
+ function i(t,e=1,o={}){const{indent:r=" ",includeEmptyLines:n=!1}=o;if(typeof t!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``);if(typeof e!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if(e<0)throw new RangeError(`Expected \`count\` to be at least 0, got \`${e}\``);if(typeof r!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r}\``);if(e===0)return t;const p=n?/^/gm:/^(?!\s*$)/gm;return t.replace(p,r.repeat(e))}export{i as default};
@@ -0,0 +1 @@
1
+ import{c as l}from"./constants-BGGeBKGT.js";const c=(i,r)=>{const{length:f}=i;if(f===0)return"";if(f===1)return i[0];const t=[];let e="",n="";for(let u=0;u<f;u++){const s=i[u];if(l.test(s)){e?(t.push(e+n+s),e="",n=""):(t.length>0&&t.push(r),e=s);continue}e?(n&&(n+=r),n+=s):(t.length>0&&t.push(r),t.push(s))}return t.join("")};export{c as default};
@@ -1 +1 @@
1
- class s{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const c=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,c),c}has(e){return this.cache.has(e)}set(e,c){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t!==void 0&&this.cache.delete(t)}this.cache.set(e,c)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}}export{s as i};
1
+ class s{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const c=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,c),c}has(e){return this.cache.has(e)}set(e,c){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t!==void 0&&this.cache.delete(t)}this.cache.set(e,c)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}}export{s as L};
@@ -0,0 +1 @@
1
+ const e=/(?<![a-zß])SS(?![a-z])/g,n=a=>a.replaceAll(e,"ß");export{n};
@@ -0,0 +1 @@
1
+ import e from"./indent-CY079Qyq.js";import i from"./dedent-CDXp3nZQ.js";function f(t,r=0,n={}){return e(i(t),r,n)}export{f as default};
@@ -1 +1 @@
1
- const r=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),t=e=>{if(typeof e!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof e}`);return e.replaceAll(r,"")};export{t as r};
1
+ const r=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),t=e=>{if(typeof e!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof e}`);return e.replaceAll(r,"")};export{t as s};
@@ -1 +1 @@
1
- const B=/\$([\d&$`'])/g,b=/\$(\d+|&|\$)/g,S=l=>{if(l.length===0)return[];const u=[];let d=[...l[0]];for(let c=1;c<l.length;c++){const p=l[c];p&&p[0]<=d[1]+1?d[1]=Math.max(d[1],p[1]):(u.push(d),d=[...p])}return u.push(d),u},y=(l,u,d)=>{if(!l)return"";const c=[];let p=0;for(const n of u){const[e,r]=n;if(r!==void 0)try{if(e instanceof RegExp){const t=new RegExp(e.source,`${e.flags.replace("g","")}g`);let i;for(;(i=t.exec(l))!==null;){const s=i.index,f=i[0];f.length===0&&t.lastIndex===i.index&&(t.lastIndex+=1);const I=s+f.length-1,M=r.replaceAll(B,(R,o)=>{if(o==="&")return f;if(o==="$")return"$";if(o==="`")return l.slice(0,Math.max(0,s));if(o==="'")return l.slice(Math.max(0,s+f.length));const h=Number.parseInt(o,10);return i&&h>0&&h<i.length?i[h]??"":R});c.push({end:I,id:p++,original:f,replacement:M,start:s}),f.length===0&&t.lastIndex===s&&(t.lastIndex+=1)}}else if(typeof e=="string"&&e.length>0)for(let t=0;(t=l.indexOf(e,t))!==-1;t++){const i=t,s=e,f=i+s.length-1,I=Object.assign([s],{index:i,input:l}),M=r.replaceAll(b,(R,o)=>{if(o==="&")return s;if(o==="$")return"$";const h=Number.parseInt(o,10);return h>0&&h<I.length?I[h]??"":R});c.push({end:f,id:p++,original:s,replacement:M,start:i})}else continue}catch{continue}}c.sort((n,e)=>n.start!==e.start?n.start-e.start:e.end-n.end);const $=d.toSorted((n,e)=>n[0]-e[0]),v=S($),a=l.split("").map((n,e)=>({appliedMatchId:void 0,char:n,index:e,insertBeforeReplacement:void 0,isIgnored:!1,isMatchStart:!1,matchReplacement:void 0}));for(const n of v){const e=n;for(let r=e[0];r<=e[1];r++)a[r]&&(a[r].isIgnored=!0)}let x="";for(const n of c){const e=n;if(e.original.length===0&&e.start>=0&&e.start<=a.length){const r=e.start;if(a[r]){const t=a[r];t.isIgnored||(t.insertBeforeReplacement=(t.insertBeforeReplacement??"")+e.replacement)}else r===a.length&&(x+=e.replacement)}}for(const n of c){const e=n;if(e.original.length===0)continue;let r=!0;for(let t=e.start;t<=e.end;t++)if(!a[t]||a[t].isIgnored||a[t].appliedMatchId!==void 0){r=!1;break}if(r&&e.start>=0&&e.start<a.length){for(let t=e.start;t<=e.end;t++)a[t]&&(a[t].appliedMatchId=e.id);a[e.start]&&(a[e.start].isMatchStart=!0,a[e.start].matchReplacement=e.replacement)}}let m="",g=0;for(;g<a.length;){const n=a[g];if(n.insertBeforeReplacement!==void 0&&(m+=n.insertBeforeReplacement),n.isMatchStart&&n.appliedMatchId!==void 0){m+=n.matchReplacement??"";let e=g;for(let r=g+1;r<a.length&&a[r]?.appliedMatchId===n.appliedMatchId;r++)e=r;g=e+1}else n.appliedMatchId===void 0&&(m+=n.char),g+=1}return x.length>0&&(m+=x),m};export{y as default};
1
+ const v=/\$([\d&$`'])/g,A=/\$(\d+|&|\$)/g,C=l=>{if(l.length===0)return[];const m=[];let f=[...l[0]];for(let c=1;c<l.length;c++){const h=l[c];h&&h[0]<=f[1]+1?f[1]=Math.max(f[1],h[1]):(m.push(f),f=[...h])}return m.push(f),m},B=(l,m,f)=>{if(!l)return"";const c=[];let h=0;for(const n of m){const[e,r]=n;if(r!==void 0)try{if(e instanceof RegExp){const t=new RegExp(e.source,`${e.flags.replace("g","")}g`);let s;for(;(s=t.exec(l))!==null;){const i=s.index,d=s[0];d.length===0&&t.lastIndex===s.index&&(t.lastIndex+=1);const I=i+d.length-1,M=r.replaceAll(v,(R,o)=>{if(o==="&")return d;if(o==="$")return"$";if(o==="`")return l.slice(0,Math.max(0,i));if(o==="'")return l.slice(Math.max(0,i+d.length));const g=Number.parseInt(o,10);return s&&g>0&&g<s.length?s[g]??"":R});c.push({end:I,id:h++,original:d,replacement:M,start:i}),d.length===0&&t.lastIndex===i&&(t.lastIndex+=1)}}else if(typeof e=="string"&&e.length>0)for(let t=0;(t=l.indexOf(e,t))!==-1;t++){const s=t,i=e,d=s+i.length-1,I=Object.assign([i],{index:s,input:l}),M=r.replaceAll(A,(R,o)=>{if(o==="&")return i;if(o==="$")return"$";const g=Number.parseInt(o,10);return g>0&&g<I.length?I[g]??"":R});c.push({end:d,id:h++,original:i,replacement:M,start:s})}else continue}catch{continue}}c.sort((n,e)=>n.start!==e.start?n.start-e.start:e.end-n.end);const E=f.toSorted((n,e)=>n[0]-e[0]),$=C(E),a=l.split("").map((n,e)=>({appliedMatchId:void 0,char:n,index:e,insertBeforeReplacement:void 0,isIgnored:!1,isMatchStart:!1,matchReplacement:void 0}));for(const n of $){const e=n;for(let r=e[0];r<=e[1];r++)a[r]&&(a[r].isIgnored=!0)}let x="";for(const n of c){const e=n;if(e.original.length===0&&e.start>=0&&e.start<=a.length){const r=e.start;if(a[r]){const t=a[r];t.isIgnored||(t.insertBeforeReplacement=(t.insertBeforeReplacement??"")+e.replacement)}else r===a.length&&(x+=e.replacement)}}for(const n of c){const e=n;if(e.original.length===0)continue;let r=!0;for(let t=e.start;t<=e.end;t++)if(!a[t]||a[t].isIgnored||a[t].appliedMatchId!==void 0){r=!1;break}if(r&&e.start>=0&&e.start<a.length){for(let t=e.start;t<=e.end;t++)a[t]&&(a[t].appliedMatchId=e.id);a[e.start]&&(a[e.start].isMatchStart=!0,a[e.start].matchReplacement=e.replacement)}}let u="",p=0;for(;p<a.length;){const n=a[p];if(n.insertBeforeReplacement!==void 0&&(u+=n.insertBeforeReplacement),n.isMatchStart&&n.appliedMatchId!==void 0){u+=n.matchReplacement??"";let e=p;for(let r=p+1;r<a.length&&a[r]?.appliedMatchId===n.appliedMatchId;r++)e=r;p=e+1}else n.appliedMatchId===void 0&&(u+=n.char),p+=1}return x.length>0&&(u+=x),u};export{B as default};
package/dist/slice.js CHANGED
@@ -1 +1 @@
1
- import{d as k,e as R,R as v}from"./packem_shared/constants-aPzGW29R.js";import{getStringWidth as I}from"./get-string-width.js";import{i as O}from"./packem_shared/lru-cache-BtMSrYQJ.js";const y=new O(100),_=new Intl.Segmenter("en",{granularity:"grapheme"}),$=/^[\u0000-\u007F]*$/,j=new Set(["0","22","23","24","27","28","29","39","49"]),M=new Set(["1","3","4","7","8","9"]),A=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),w=t=>t>="30"&&t<="37"||t>="90"&&t<="97"||t.startsWith("38;"),S=t=>t>="40"&&t<="47"||t>="100"&&t<="107"||t.startsWith("48;"),F=[{close:"\x1B[22m",open:"\x1B[1m"},{close:"\x1B[23m",open:"\x1B[3m"},{close:"\x1B[24m",open:"\x1B[4m"},{close:"\x1B[27m",open:"\x1B[7m"},{close:"\x1B[28m",open:"\x1B[8m"},{close:"\x1B[29m",open:"\x1B[9m"}],E=(t,x)=>{let f=-1;for(const p of x){const h=t.indexOf(p);h!==-1&&(f===-1||h<f)&&(f=h)}return f},P=(t,x)=>{if(!t.includes("\x1B"))return[{after:"",before:"",content:t,visibleLength:I(t,x.width)}];const f=`${JSON.stringify(x.width??void 0)}\0${t}`,p=y.get(f);if(p)return p;const h=[],g=[];let m=0,u;for(v.lastIndex=0;(u=v.exec(t))!==null;){const n=u[0];h.push(t.slice(m,u.index)),g.push(n),m=u.index+n.length}m<t.length&&h.push(t.slice(m));const c=[];for(const n of g){if(n==="\x1B[0m"||n==="\x1B]8;;\x07"){c.push(n);continue}if(n.startsWith("\x1B[")&&n.endsWith("m")){const B=n.slice(2,-1);if(j.has(B)){c.push(n);continue}}}const e=new Set,W=[];for(const[n,B]of h.entries()){if(n>0&&g[n-1]){const i=g[n-1];if(i==="\x1B[0m")e.clear();else if(i==="\x1B]8;;\x07"){for(const o of e)if(o.startsWith("\x1B]8;;")&&!o.endsWith("\x1B]8;;\x07")){e.delete(o);break}}else if(i.startsWith("\x1B[")&&i.endsWith("m")){const o=i.slice(2,-1);if(o==="39"){for(const s of e)if(s.startsWith("\x1B[")&&s.endsWith("m")){const l=s.slice(2,-1);if(w(l)){e.delete(s);break}}}else if(o==="49"){for(const s of e)if(s.startsWith("\x1B[")&&s.endsWith("m")){const l=s.slice(2,-1);if(S(l)){e.delete(s);break}}}else if(A.has(o)){const s=A.get(o);for(const l of e)if(l===`\x1B[${s}m`){e.delete(l);break}}else{if(w(o)){for(const s of e)if(s.startsWith("\x1B[")&&s.endsWith("m")){const l=s.slice(2,-1);if(w(l)){e.delete(s);break}}}else if(S(o)){for(const s of e)if(s.startsWith("\x1B[")&&s.endsWith("m")){const l=s.slice(2,-1);if(S(l)){e.delete(s);break}}}else if(M.has(o)){const s=`\x1B[${o}m`;e.has(s)&&e.delete(s)}e.add(i)}}else if(i.startsWith("\x1B]8;;")&&!i.endsWith("\x1B]8;;\x07")){for(const o of e)if(o.startsWith("\x1B]8;;")&&!o.endsWith("\x1B]8;;\x07")){e.delete(o);break}e.add(i)}}if(B==="")continue;let a="";if(e.size>0)if(c.includes("\x1B[0m"))a="\x1B[0m";else{const i=[];let o=!1;for(const r of e)if(r.startsWith("\x1B]8;;")&&!r.endsWith("\x1B]8;;\x07")){o=!0;break}o&&c.includes("\x1B]8;;\x07")&&i.push("\x1B]8;;\x07");let s=!1,l=!1;for(const r of e)if(r.startsWith("\x1B[")&&r.endsWith("m")){const d=r.slice(2,-1);w(d)?s=!0:S(d)&&(l=!0)}if(s&&l){const r=E(t,["\x1B[3","\x1B[9","\x1B[38;"]),d=E(t,["\x1B[4","\x1B[10","\x1B[48;"]);r>=0&&d>=0?r>d?i.push("\x1B[39m","\x1B[49m"):i.push("\x1B[49m","\x1B[39m"):i.push("\x1B[39m","\x1B[49m")}else s&&i.push("\x1B[39m"),l&&i.push("\x1B[49m");s&&l&&t.includes("\x1B[39m")&&t.includes("\x1B[49m")&&(t.indexOf("\x1B[39m")<t.indexOf("\x1B[49m")?(i.length-=2,i.push("\x1B[39m","\x1B[49m")):t.indexOf("\x1B[49m")<t.indexOf("\x1B[39m")&&(i.length-=2,i.push("\x1B[49m","\x1B[39m")));const N=F.filter(r=>e.has(r.open)).map(r=>({position:t.indexOf(r.open),style:r})).filter(r=>r.position>=0).toSorted((r,d)=>d.position-r.position);for(const r of N){const d=r;c.includes(d.style.close)&&i.push(d.style.close)}a=i.join("")}const b=[...e].join("");W.push({after:a,before:b,content:B,visibleLength:I(B,x.width)})}return y.set(f,W),W},L=(t,x,f,p)=>{const h=[...p.segmenter.segment(t)],g=[];let m=0,u=!1;for(const c of h){const e=I(c.segment,p.width),W=m,n=m+e;if(!u)if(W<x){m=n;continue}else u=!0;if(W>=f||n>f)break;g.push(c.segment),m=n}return g.join("")},z=(t,x=0,f=Number.MAX_SAFE_INTEGER,p={})=>{const h={segmenter:_,...p};if(x>=f||t==="")return"";const g=I(t,h.width);if(x===0&&f>=g)return t;if(x<0||f<0)throw new RangeError("Negative indices aren't supported");if(!t.includes("\x1B"))return $.test(t)?t.slice(x,f):L(t,x,f,h);if(k.lastIndex=0,R.lastIndex=0,!k.test(t)&&!R.test(t))return t;const m=P(t,h);if(m.length===0)return"";let u=0;const c=[];for(const[n,B]of m.entries()){const a=u,b=u+B.visibleLength;if(b>x&&a<f){const i=Math.max(0,x-a),o=Math.min(B.visibleLength,f-a);c.push({end:o,index:n,segment:B,start:i})}u=b}if(c.length===0)return"";const e=[],W=c[0].segment;e.push(W.before);for(let n=0;n<c.length;n++){const{end:B,segment:a,start:b}=c[n];if(b===0&&B===a.visibleLength?e.push(a.content):e.push(L(a.content,b,B,h)),n<c.length-1){const i=c[n+1].segment,o=a.after,s=i.before;o!==s&&(o||s)&&e.push(o,s)}}return e.push(c.at(-1).segment.after),e.join("")};export{z as slice};
1
+ import{d as C,e as O,a as _}from"./packem_shared/constants-BGGeBKGT.js";import{getStringWidth as E}from"./get-string-width.js";import{s as R}from"./packem_shared/ansi-state-tracker-BFhXTS-5.js";import{L as F}from"./packem_shared/lru-cache-BD25OaEQ.js";const k=new F(100),N=new Intl.Segmenter("en",{granularity:"grapheme"}),P=/^[\u0000-\u007F]*$/,T=new Set(["0","22","23","24","27","28","29","39","49"]),M=new Set(["1","3","4","7","8","9"]),v=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),y=e=>R(e)==="foreground",W=e=>R(e)==="background",D=[{close:"\x1B[22m",open:"\x1B[1m"},{close:"\x1B[23m",open:"\x1B[3m"},{close:"\x1B[24m",open:"\x1B[4m"},{close:"\x1B[27m",open:"\x1B[7m"},{close:"\x1B[28m",open:"\x1B[8m"},{close:"\x1B[29m",open:"\x1B[9m"}],w=(e,l)=>{let c=-1;for(const u of l){const m=e.indexOf(u);m!==-1&&(c===-1||m<c)&&(c=m)}return c},$=(e,l)=>{if(!e.includes("\x1B"))return[{after:"",before:"",content:e,visibleLength:E(e,l.width)}];const c=`${JSON.stringify(l.width??void 0)}\0${e}`,u=k.get(c);if(u)return u;const m=[],S=[];let h=0,d;for(_.lastIndex=0;(d=_.exec(e))!==null;){const o=d[0];m.push(e.slice(h,d.index)),S.push(o),h=d.index+o.length}h<e.length&&m.push(e.slice(h));const f=[];for(const o of S){if(o==="\x1B[0m"||o==="\x1B]8;;\x07"){f.push(o);continue}if(o.startsWith("\x1B[")&&o.endsWith("m")){const x=o.slice(2,-1);if(T.has(x)){f.push(o);continue}}}const s=new Set,p=[];for(const[o,x]of m.entries()){if(o>0&&S[o-1]){const n=S[o-1];if(n==="\x1B[0m")s.clear();else if(n==="\x1B]8;;\x07"){for(const i of s)if(i.startsWith("\x1B]8;;")&&!i.endsWith("\x1B]8;;\x07")){s.delete(i);break}}else if(n.startsWith("\x1B[")&&n.endsWith("m")){const i=n.slice(2,-1);if(i==="39"){for(const t of s)if(t.startsWith("\x1B[")&&t.endsWith("m")){const a=t.slice(2,-1);if(y(a)){s.delete(t);break}}}else if(i==="49"){for(const t of s)if(t.startsWith("\x1B[")&&t.endsWith("m")){const a=t.slice(2,-1);if(W(a)){s.delete(t);break}}}else if(v.has(i)){const t=v.get(i);for(const a of s)if(a===`\x1B[${t}m`){s.delete(a);break}}else{if(y(i)){for(const t of s)if(t.startsWith("\x1B[")&&t.endsWith("m")){const a=t.slice(2,-1);if(y(a)){s.delete(t);break}}}else if(W(i)){for(const t of s)if(t.startsWith("\x1B[")&&t.endsWith("m")){const a=t.slice(2,-1);if(W(a)){s.delete(t);break}}}else if(M.has(i)){const t=`\x1B[${i}m`;s.has(t)&&s.delete(t)}s.add(n)}}else if(n.startsWith("\x1B]8;;")&&!n.endsWith("\x1B]8;;\x07")){for(const i of s)if(i.startsWith("\x1B]8;;")&&!i.endsWith("\x1B]8;;\x07")){s.delete(i);break}s.add(n)}}if(x==="")continue;let B="";if(s.size>0)if(f.includes("\x1B[0m"))B="\x1B[0m";else{const n=[];let i=!1;for(const r of s)if(r.startsWith("\x1B]8;;")&&!r.endsWith("\x1B]8;;\x07")){i=!0;break}i&&f.includes("\x1B]8;;\x07")&&n.push("\x1B]8;;\x07");let t=!1,a=!1;for(const r of s)if(r.startsWith("\x1B[")&&r.endsWith("m")){const g=r.slice(2,-1);y(g)?t=!0:W(g)&&(a=!0)}if(t&&a){const r=w(e,["\x1B[3","\x1B[9","\x1B[38;"]),g=w(e,["\x1B[4","\x1B[10","\x1B[48;"]);r>=0&&g>=0?r>g?n.push("\x1B[39m","\x1B[49m"):n.push("\x1B[49m","\x1B[39m"):n.push("\x1B[39m","\x1B[49m")}else t&&n.push("\x1B[39m"),a&&n.push("\x1B[49m");t&&a&&e.includes("\x1B[39m")&&e.includes("\x1B[49m")&&(e.indexOf("\x1B[39m")<e.indexOf("\x1B[49m")?(n.length-=2,n.push("\x1B[39m","\x1B[49m")):e.indexOf("\x1B[49m")<e.indexOf("\x1B[39m")&&(n.length-=2,n.push("\x1B[49m","\x1B[39m")));const L=D.filter(r=>s.has(r.open)).map(r=>({position:e.indexOf(r.open),style:r})).filter(r=>r.position>=0).toSorted((r,g)=>g.position-r.position);for(const r of L){const g=r;f.includes(g.style.close)&&n.push(g.style.close)}B=n.join("")}const b=[...s].join("");p.push({after:B,before:b,content:x,visibleLength:E(x,l.width)})}return k.set(c,p),p},A=(e,l,c,u)=>{const m=[...u.segmenter.segment(e)],S=[];let h=0,d=!1;for(const f of m){const s=E(f.segment,u.width),p=h,o=h+s;if(!d)if(p<l){h=o;continue}else d=!0;if(p>=c||o>c)break;S.push(f.segment),h=o}return S.join("")},H=(e,l=0,c=Number.MAX_SAFE_INTEGER,u={})=>{const m={segmenter:N,...u};if(l>=c||e==="")return"";const S=E(e,m.width);if(l===0&&c>=S)return e;if(l<0||c<0)throw new RangeError("Negative indices aren't supported");if(!e.includes("\x1B"))return P.test(e)?e.slice(l,c):A(e,l,c,m);if(C.lastIndex=0,O.lastIndex=0,!C.test(e)&&!O.test(e))return e;const h=$(e,m);if(h.length===0)return"";let d=0;const f=[];for(const[o,x]of h.entries()){const B=d,b=d+x.visibleLength;if(b>l&&B<c){const n=Math.max(0,l-B),i=Math.min(x.visibleLength,c-B);f.push({end:i,index:o,segment:x,start:n})}d=b}if(f.length===0)return"";const s=[],p=f[0].segment;s.push(p.before);for(let o=0;o<f.length;o++){const{end:x,segment:B,start:b}=f[o];if(b===0&&x===B.visibleLength?s.push(B.content):s.push(A(B.content,b,x,m)),o<f.length-1){const n=f[o+1].segment,i=B.after,t=n.before;i!==t&&(i||t)&&s.push(i,t)}}return s.push(f.at(-1).segment.after),s.join("")};export{H as slice};
package/dist/slugify.js CHANGED
@@ -1 +1 @@
1
- import c from"./transliterate.js";import{escapeRegExp as t}from"./utilities.js";const p={da:{Å:"AA",å:"aa",Æ:"AE",æ:"ae",Ø:"OE",ø:"oe"},de:{Ä:"AE",ä:"ae",Ö:"OE",ö:"oe",ß:"ss",Ü:"UE",ü:"ue"},nb:{Å:"AA",å:"aa",Æ:"AE",æ:"ae",Ø:"OE",ø:"oe"},sr:{Ć:"C",ć:"c",Č:"C",č:"c",Đ:"DJ",đ:"dj",Š:"S",š:"s",Ž:"Z",ž:"z"},tr:{Ç:"C",ç:"c",Ğ:"G",ğ:"g",I:"I",İ:"I",ı:"i",Ö:"O",ö:"o",Ş:"S",ş:"s",Ü:"U",ü:"u"},vi:{Đ:"D",đ:"d"}},n=a=>{const s=a.split("-")[0]?.toLowerCase()??"",e=p[s];return e?Object.entries(e):[]},i=(a,s)=>{const e=a?n(a):[],r=Array.isArray(s)?s:Object.entries(s??{});return[...e,...r]},u=(a,s,e)=>{const r=t(s).replaceAll(String.raw`\-`,"-"),o=new RegExp(`[^${r}]`,"g");return a.replaceAll(o,e)},f=(a,s)=>{const e={allowedChars:"a-zA-Z0-9-_.~",fixChineseSpacing:!0,ignore:[],lowercase:!0,replaceAfter:[],replaceBefore:[],separator:"-",transliterate:!0,trim:!1,unknown:"",uppercase:!1,...s};if(e.lowercase&&e.uppercase)throw new TypeError("slugify: The `lowercase` and `uppercase` options are mutually exclusive; enable at most one.");e.replaceBefore=i(e.locale??"",e.replaceBefore);let r=e.transliterate?c(a,e):a.normalize("NFC");e.lowercase?r=r.toLowerCase():e.uppercase&&(r=r.toUpperCase()),r=u(r,e.allowedChars,e.separator);const o=t(e.separator);if(o){const l=new RegExp(`${o}+`,"g");r=r.replace(l,e.separator)}return o?r.replaceAll(new RegExp(`^${o}+|${o}+$`,"g"),""):r};export{f as default};
1
+ import c from"./transliterate.js";import{escapeRegExp as o}from"./utilities.js";const n={da:{Å:"AA",å:"aa",Æ:"AE",æ:"ae",Ø:"OE",ø:"oe"},de:{Ä:"AE",ä:"ae",Ö:"OE",ö:"oe",ß:"ss",Ü:"UE",ü:"ue"},nb:{Å:"AA",å:"aa",Æ:"AE",æ:"ae",Ø:"OE",ø:"oe"},sr:{Ć:"C",ć:"c",Č:"C",č:"c",Đ:"DJ",đ:"dj",Š:"S",š:"s",Ž:"Z",ž:"z"},tr:{Ç:"C",ç:"c",Ğ:"G",ğ:"g",I:"I",İ:"I",ı:"i",Ö:"O",ö:"o",Ş:"S",ş:"s",Ü:"U",ü:"u"},vi:{Đ:"D",đ:"d"}},p=a=>{const s=a.split("-")[0]?.toLowerCase()??"",e=n[s];return e?Object.entries(e):[]},i=(a,s)=>{const e=a?p(a):[],r=Array.isArray(s)?s:Object.entries(s??{});return[...e,...r]},u=(a,s,e)=>{const r=o(s).replaceAll(String.raw`\-`,"-"),t=new RegExp(`[^${r}]`,"g");return a.replaceAll(t,e)},w=(a,s)=>{const e={allowedChars:"a-zA-Z0-9-_.~",fixChineseSpacing:!0,ignore:[],lowercase:!0,replaceAfter:[],replaceBefore:[],separator:"-",transliterate:!0,trim:!1,unknown:"",uppercase:!1,...s};if(e.lowercase&&e.uppercase)throw new TypeError("slugify: The `lowercase` and `uppercase` options are mutually exclusive; enable at most one.");e.replaceBefore=i(e.locale??"",e.replaceBefore);let r=e.transliterate?c(a,e):a.normalize("NFC");e.lowercase?r=r.toLowerCase():e.uppercase&&(r=r.toUpperCase()),r=u(r,e.allowedChars,e.separator);const t=o(e.separator);if(t){const l=new RegExp(`${t}+`,"g");r=r.replace(l,e.separator)}return t?r.replaceAll(new RegExp(`^${t}+|${t}+$`,"g"),""):r};export{w as default};
@@ -1,16 +1,16 @@
1
- import{r as c}from"../packem_shared/strip-vt-control-characters-BW1RglLp.js";import{getStringWidth as a}from"../get-string-width.js";const r=e=>{const t=c(e);return{ansi:e,json:JSON.stringify(e),lengthDifference:e.length-t.length,stripped:t,visible:e.replaceAll("\x1B",String.raw`\u001B`)}},g=(e,t)=>{const i=r(e),n=r(t);return{message:()=>{if(e===t)return"ANSI strings are identical";const s=i.stripped===n.stripped;return`ANSI string comparison failed:
1
+ import{s as c}from"../packem_shared/strip-vt-control-characters-vMeu7uFw.js";import{getStringWidth as o}from"../get-string-width.js";const r=t=>{const e=c(t);return{ansi:t,json:JSON.stringify(t),lengthDifference:t.length-e.length,stripped:e,visible:t.replaceAll("\x1B",String.raw`\u001B`)}},l=(t,e)=>{const s=r(t),i=r(e);return{message:()=>{if(t===e)return"ANSI strings are identical";const n=s.stripped===i.stripped;return`ANSI string comparison failed:
2
2
 
3
3
  Actual:
4
+ - Visible content: ${s.stripped}
5
+ - With escape codes: ${s.visible}
6
+ - JSON: ${s.json}
7
+ - Length: ${String(o(s.ansi))}
8
+
9
+ Expected:
4
10
  - Visible content: ${i.stripped}
5
11
  - With escape codes: ${i.visible}
6
12
  - JSON: ${i.json}
7
- - Length: ${String(a(i.ansi))}
8
-
9
- Expected:
10
- - Visible content: ${n.stripped}
11
- - With escape codes: ${n.visible}
12
- - JSON: ${n.json}
13
- - Length: ${String(a(n.ansi))}
13
+ - Length: ${String(o(i.ansi))}
14
14
 
15
- ${s?"✓ Visible content is identical, but escape codes differ":"✗ Visible content differs"}
16
- `},pass:e===t}},o=(e,t)=>{const i=r(e),n=r(t),s=i.stripped===n.stripped,p=e===t;return{actual:i,ansiEqual:p,expected:n,strippedEqual:s,summary:{actualLength:e.length,actualStrippedLength:i.stripped.length,ansiEqual:p,expectedLength:t.length,expectedStrippedLength:n.stripped.length,strippedEqual:s}}};export{o as compareAnsiStrings,g as expectAnsiStrings,r as formatAnsiString};
15
+ ${n?"✓ Visible content is identical, but escape codes differ":"✗ Visible content differs"}
16
+ `},pass:t===e}},g=(t,e)=>{const s=r(t),i=r(e),n=s.stripped===i.stripped,p=t===e;return{actual:s,ansiEqual:p,expected:i,strippedEqual:n,summary:{actualLength:t.length,actualStrippedLength:s.stripped.length,ansiEqual:p,expectedLength:e.length,expectedStrippedLength:i.stripped.length,strippedEqual:n}}};export{g as compareAnsiStrings,l as expectAnsiStrings,r as formatAnsiString};