@visulima/string 3.0.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 (117) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE.md +55 -129
  3. package/README.md +2 -2
  4. package/dist/align-text.d.ts +29 -29
  5. package/dist/align-text.js +2 -2
  6. package/dist/case/camel-case.d.ts +16 -16
  7. package/dist/case/camel-case.js +1 -1
  8. package/dist/case/capital-case.d.ts +13 -13
  9. package/dist/case/capital-case.js +1 -1
  10. package/dist/case/constant-case.d.ts +13 -13
  11. package/dist/case/constant-case.js +1 -1
  12. package/dist/case/dot-case.d.ts +13 -13
  13. package/dist/case/dot-case.js +1 -1
  14. package/dist/case/flat-case.d.ts +11 -11
  15. package/dist/case/flat-case.js +1 -1
  16. package/dist/case/flip-case.d.ts +14 -14
  17. package/dist/case/flip-case.js +1 -1
  18. package/dist/case/identify-case.d.ts +14 -14
  19. package/dist/case/identify-case.js +1 -1
  20. package/dist/case/index.d.ts +7 -7
  21. package/dist/case/index.js +1 -1
  22. package/dist/case/kebab-case.d.ts +22 -22
  23. package/dist/case/kebab-case.js +1 -1
  24. package/dist/case/lower-first.d.ts +12 -12
  25. package/dist/case/lower-first.js +1 -1
  26. package/dist/case/no-case.d.ts +13 -13
  27. package/dist/case/no-case.js +1 -1
  28. package/dist/case/pascal-case.d.ts +16 -16
  29. package/dist/case/pascal-case.js +1 -1
  30. package/dist/case/pascal-snake-case.d.ts +13 -13
  31. package/dist/case/pascal-snake-case.js +1 -1
  32. package/dist/case/path-case.d.ts +13 -13
  33. package/dist/case/path-case.js +1 -1
  34. package/dist/case/sentence-case.d.ts +13 -13
  35. package/dist/case/sentence-case.js +1 -1
  36. package/dist/case/snake-case.d.ts +13 -13
  37. package/dist/case/snake-case.js +1 -1
  38. package/dist/case/split-by-case.d.ts +20 -20
  39. package/dist/case/split-by-case.js +1 -1
  40. package/dist/case/title-case.d.ts +11 -11
  41. package/dist/case/title-case.js +1 -1
  42. package/dist/case/train-case.d.ts +13 -13
  43. package/dist/case/train-case.js +1 -1
  44. package/dist/case/upper-first.d.ts +12 -12
  45. package/dist/case/upper-first.js +1 -1
  46. package/dist/closest-string.d.ts +28 -28
  47. package/dist/closest-string.js +1 -1
  48. package/dist/compare-similarity.d.ts +33 -33
  49. package/dist/compare-similarity.js +1 -1
  50. package/dist/count-occurrences.d.ts +6 -6
  51. package/dist/count-occurrences.js +1 -1
  52. package/dist/direction.d.ts +4 -4
  53. package/dist/direction.js +1 -1
  54. package/dist/east-asian-width.d.ts +25 -15
  55. package/dist/east-asian-width.js +1 -1
  56. package/dist/excerpt.d.ts +18 -18
  57. package/dist/excerpt.js +55 -44
  58. package/dist/get-string-truncated-width.d.ts +131 -131
  59. package/dist/get-string-truncated-width.js +1 -1
  60. package/dist/get-string-width.d.ts +56 -56
  61. package/dist/indent.d.ts +11 -8
  62. package/dist/indent.js +1 -1
  63. package/dist/index.d.ts +4 -4
  64. package/dist/index.js +1 -1
  65. package/dist/is-fullwidth-code-point.d.ts +4 -4
  66. package/dist/is-fullwidth-code-point.js +1 -1
  67. package/dist/levenshtein.d.ts +19 -19
  68. package/dist/levenshtein.js +1 -1
  69. package/dist/native-string-types.d.ts +212 -228
  70. package/dist/outdent.d.ts +64 -64
  71. package/dist/outdent.js +1 -1
  72. package/dist/packem_shared/{_isFullWidth-Dqc3MWgl.js → _isFullWidth-dWWDw5Is.js} +1 -1
  73. package/dist/packem_shared/ansi-state-tracker-BFhXTS-5.js +1 -0
  74. package/dist/packem_shared/closest-CSX4px2F.js +1 -0
  75. package/dist/packem_shared/constants-BGGeBKGT.js +1 -0
  76. package/dist/packem_shared/dedent-CDXp3nZQ.js +1 -0
  77. package/dist/packem_shared/eastAsianWidth-DACe9Ds2.js +1 -0
  78. package/dist/packem_shared/generate-cache-key-th9N8-CB.js +1 -0
  79. package/dist/packem_shared/indent-CY079Qyq.js +1 -0
  80. package/dist/packem_shared/joinSegments-9qx7xSy7.js +1 -0
  81. package/dist/packem_shared/{lru-cache-BtMSrYQJ.js → lru-cache-BD25OaEQ.js} +1 -1
  82. package/dist/packem_shared/normalize-german-eszett-DtW4F-Wg.js +1 -0
  83. package/dist/packem_shared/redent-lctoaAtw.js +1 -0
  84. package/dist/packem_shared/strip-vt-control-characters-vMeu7uFw.js +1 -0
  85. package/dist/packem_shared/types.d-CMNqA5bi.d.ts +402 -0
  86. package/dist/packem_shared/types.d-LgsTR37y.d.ts +360 -0
  87. package/dist/replace-string.d.ts +7 -7
  88. package/dist/replace-string.js +1 -1
  89. package/dist/slice.d.ts +38 -38
  90. package/dist/slice.js +1 -1
  91. package/dist/slugify.d.ts +9 -9
  92. package/dist/slugify.js +1 -1
  93. package/dist/test/utils.d.ts +14 -14
  94. package/dist/test/utils.js +11 -11
  95. package/dist/test/vitest.d.ts +2 -2
  96. package/dist/transliterate.d.ts +7 -7
  97. package/dist/transliterate.js +3 -3
  98. package/dist/truncate.d.ts +37 -37
  99. package/dist/truncate.js +1 -1
  100. package/dist/utilities.d.ts +23 -23
  101. package/dist/utilities.js +1 -1
  102. package/dist/word-similarity-sort.d.ts +32 -32
  103. package/dist/word-similarity-sort.js +1 -1
  104. package/dist/word-wrap.d.ts +33 -33
  105. package/dist/word-wrap.js +5 -7
  106. package/package.json +1 -1
  107. package/dist/packem_shared/closest-C6YDQs4m.js +0 -1
  108. package/dist/packem_shared/constants-aPzGW29R.js +0 -1
  109. package/dist/packem_shared/dedent-CPjAYUXh.js +0 -1
  110. package/dist/packem_shared/eastAsianWidth-DJV8Kqd-.js +0 -1
  111. package/dist/packem_shared/generate-cache-key-BqU1Cqwm.js +0 -1
  112. package/dist/packem_shared/indent-cz8WMI0e.js +0 -1
  113. package/dist/packem_shared/joinSegments-CaHT-45s.js +0 -1
  114. package/dist/packem_shared/normalize-german-eszett-hNMwtGjd.js +0 -1
  115. package/dist/packem_shared/redent-ByOoJ6fN.js +0 -1
  116. package/dist/packem_shared/types.d-CmNvyl4l.d.ts +0 -360
  117. package/dist/packem_shared/types.d-fhe030jX.d.ts +0 -402
@@ -1,174 +1,174 @@
1
1
  /**
2
- * Configuration options for string width calculation and truncation.
3
- * @example
4
- * ```typescript
5
- * // Basic usage with defaults
6
- * const options: StringTruncatedWidthOptions = {};
7
- *
8
- * // Custom character widths
9
- * const options: StringTruncatedWidthOptions = {
10
- * regularWidth: 2,
11
- * emojiWidth: 3,
12
- * tabWidth: 4
13
- * };
14
- *
15
- * // Truncation settings
16
- * const options: StringTruncatedWidthOptions = {
17
- * limit: 10,
18
- * ellipsis: '...',
19
- * ellipsisWidth: 3
20
- * };
21
- * ```
22
- */
2
+ * Configuration options for string width calculation and truncation.
3
+ * @example
4
+ * ```typescript
5
+ * // Basic usage with defaults
6
+ * const options: StringTruncatedWidthOptions = {};
7
+ *
8
+ * // Custom character widths
9
+ * const options: StringTruncatedWidthOptions = {
10
+ * regularWidth: 2,
11
+ * emojiWidth: 3,
12
+ * tabWidth: 4
13
+ * };
14
+ *
15
+ * // Truncation settings
16
+ * const options: StringTruncatedWidthOptions = {
17
+ * limit: 10,
18
+ * ellipsis: '...',
19
+ * ellipsisWidth: 3
20
+ * };
21
+ * ```
22
+ */
23
23
  interface StringTruncatedWidthOptions {
24
24
  /**
25
- * Count [ambiguous width characters](https://www.unicode.org/reports/tr11/#Ambiguous) as having narrow width (count of 1 (regular)) instead of wide width (count of 2 (wide)).
26
- * @default false
27
- */
25
+ * Count [ambiguous width characters](https://www.unicode.org/reports/tr11/#Ambiguous) as having narrow width (count of 1 (regular)) instead of wide width (count of 2 (wide)).
26
+ * @default false
27
+ */
28
28
  ambiguousIsNarrow?: boolean;
29
29
  /**
30
- * Width of ANSI escape sequences
31
- * @default 0
32
- */
30
+ * Width of ANSI escape sequences
31
+ * @default 0
32
+ */
33
33
  ansiWidth?: number;
34
34
  /**
35
- * Width of control characters
36
- * @default 0
37
- */
35
+ * Width of control characters
36
+ * @default 0
37
+ */
38
38
  controlWidth?: number;
39
39
  /**
40
- * Whether to count ANSI escape codes in width calculation
41
- * @default false
42
- */
40
+ * Whether to count ANSI escape codes in width calculation
41
+ * @default false
42
+ */
43
43
  countAnsiEscapeCodes?: boolean;
44
44
  /**
45
- * Text appended to the string when it is truncated
46
- * @default ''
47
- */
45
+ * Text appended to the string when it is truncated
46
+ * @default ''
47
+ */
48
48
  ellipsis?: string;
49
49
  /**
50
- * Width of the ellipsis string
51
- * If not provided, it will be calculated using getStringTruncatedWidth
52
- */
50
+ * Width of the ellipsis string
51
+ * If not provided, it will be calculated using getStringTruncatedWidth
52
+ */
53
53
  ellipsisWidth?: number;
54
54
  /**
55
- * Width of emoji characters
56
- * @default 2
57
- */
55
+ * Width of emoji characters
56
+ * @default 2
57
+ */
58
58
  emojiWidth?: number;
59
59
  /**
60
- * Width of full-width characters
61
- * @default 2
62
- */
60
+ * Width of full-width characters
61
+ * @default 2
62
+ */
63
63
  fullWidth?: number;
64
64
  /**
65
- * Width of half-width characters
66
- * @default 1
67
- */
65
+ * Width of half-width characters
66
+ * @default 1
67
+ */
68
68
  halfWidth?: number;
69
69
  /**
70
- * Maximum width limit for the string
71
- * @default Infinity
72
- */
70
+ * Maximum width limit for the string
71
+ * @default Infinity
72
+ */
73
73
  limit?: number;
74
74
  /**
75
- * Width of regular characters
76
- * @default 1
77
- */
75
+ * Width of regular characters
76
+ * @default 1
77
+ */
78
78
  regularWidth?: number;
79
79
  /**
80
- * Width of tab characters
81
- * @default 8
82
- */
80
+ * Width of tab characters
81
+ * @default 8
82
+ */
83
83
  tabWidth?: number;
84
84
  /**
85
- * Width of wide characters
86
- * @default 2
87
- */
85
+ * Width of wide characters
86
+ * @default 2
87
+ */
88
88
  wideWidth?: number;
89
89
  }
90
90
  /**
91
- * Result object returned by getStringTruncatedWidth containing width calculation and the truncation details.
92
- * @example
93
- * ```typescript
94
- * // No truncation
95
- * const result: StringTruncatedWidthResult = {
96
- * width: 5, // Total visual width
97
- * truncated: false, // String was not truncated
98
- * ellipsed: false, // No ellipsis added
99
- * index: 5, // Full string length
100
- * };
101
- *
102
- * // With truncation
103
- * const result: StringTruncatedWidthResult = {
104
- * width: 8, // Width including ellipsis
105
- * truncated: true, // String was truncated
106
- * ellipsed: true, // Ellipsis was added
107
- * index: 5, // Truncation point
108
- * };
109
- * ```
110
- */
91
+ * Result object returned by getStringTruncatedWidth containing width calculation and the truncation details.
92
+ * @example
93
+ * ```typescript
94
+ * // No truncation
95
+ * const result: StringTruncatedWidthResult = {
96
+ * width: 5, // Total visual width
97
+ * truncated: false, // String was not truncated
98
+ * ellipsed: false, // No ellipsis added
99
+ * index: 5, // Full string length
100
+ * };
101
+ *
102
+ * // With truncation
103
+ * const result: StringTruncatedWidthResult = {
104
+ * width: 8, // Width including ellipsis
105
+ * truncated: true, // String was truncated
106
+ * ellipsed: true, // Ellipsis was added
107
+ * index: 5, // Truncation point
108
+ * };
109
+ * ```
110
+ */
111
111
  interface StringTruncatedWidthResult {
112
112
  /**
113
- * Whether an ellipsis was added
114
- */
113
+ * Whether an ellipsis was added
114
+ */
115
115
  ellipsed: boolean;
116
116
  /**
117
- * The index at which truncation occurred (if any)
118
- */
117
+ * The index at which truncation occurred (if any)
118
+ */
119
119
  index: number;
120
120
  /**
121
- * Whether the string was truncated
122
- */
121
+ * Whether the string was truncated
122
+ */
123
123
  truncated: boolean;
124
124
  /**
125
- * The calculated width of the string
126
- */
125
+ * The calculated width of the string
126
+ */
127
127
  width: number;
128
128
  }
129
129
  /**
130
- * Calculate the visual width of a string with optional truncation, handling various Unicode character types.
131
- * @example
132
- * ```typescript
133
- * // Basic width calculation
134
- * getStringTruncatedWidth('hello');
135
- * // => { width: 5, truncated: false, ellipsed: false, index: 5 }
136
- *
137
- * // With truncation
138
- * getStringTruncatedWidth('hello world', {
139
- * limit: 8,
140
- * ellipsis: '...'
141
- * });
142
- * // => { width: 8, truncated: true, ellipsed: true, index: 5 }
143
- *
144
- * // With custom character widths
145
- * getStringTruncatedWidth('あいう', {
146
- * fullWidth: 2,
147
- * ambiguousIsNarrow: true
148
- * });
149
- * // => { width: 6, truncated: false, ellipsed: false, index: 3 }
150
- *
151
- * // With combining characters
152
- * getStringTruncatedWidth('e\u0301'); // Latin e with acute
153
- * // => { width: 1, truncated: false, ellipsed: false, index: 2 }
154
- *
155
- * getStringTruncatedWidth('ก\u0e31'); // Thai character with vowel mark
156
- * // => { width: 1, truncated: false, ellipsed: false, index: 2 }
157
- * ```
158
- *
159
- * Features:
160
- * - Full Unicode support including combining marks from various scripts
161
- * - Accurate width calculation for emoji sequences
162
- * - ANSI escape code handling
163
- * - Customizable character widths
164
- * - Optional string truncation with ellipsis
165
- * @param input The string to calculate the width for
166
- * @param options Configuration options for width calculation and truncation
167
- * @returns Result object containing:
168
- * - width: The calculated visual width of the string
169
- * - truncated: Whether the string was truncated
170
- * - ellipsed: Whether an ellipsis was added
171
- * - index: The index at which truncation occurred (if any)
172
- */
130
+ * Calculate the visual width of a string with optional truncation, handling various Unicode character types.
131
+ * @example
132
+ * ```typescript
133
+ * // Basic width calculation
134
+ * getStringTruncatedWidth('hello');
135
+ * // => { width: 5, truncated: false, ellipsed: false, index: 5 }
136
+ *
137
+ * // With truncation
138
+ * getStringTruncatedWidth('hello world', {
139
+ * limit: 8,
140
+ * ellipsis: '...'
141
+ * });
142
+ * // => { width: 8, truncated: true, ellipsed: true, index: 5 }
143
+ *
144
+ * // With custom character widths
145
+ * getStringTruncatedWidth('あいう', {
146
+ * fullWidth: 2,
147
+ * ambiguousIsNarrow: true
148
+ * });
149
+ * // => { width: 6, truncated: false, ellipsed: false, index: 3 }
150
+ *
151
+ * // With combining characters
152
+ * getStringTruncatedWidth('e\u0301'); // Latin e with acute
153
+ * // => { width: 1, truncated: false, ellipsed: false, index: 2 }
154
+ *
155
+ * getStringTruncatedWidth('ก\u0e31'); // Thai character with vowel mark
156
+ * // => { width: 1, truncated: false, ellipsed: false, index: 2 }
157
+ * ```
158
+ *
159
+ * Features:
160
+ * - Full Unicode support including combining marks from various scripts
161
+ * - Accurate width calculation for emoji sequences
162
+ * - ANSI escape code handling
163
+ * - Customizable character widths
164
+ * - Optional string truncation with ellipsis
165
+ * @param input The string to calculate the width for
166
+ * @param options Configuration options for width calculation and truncation
167
+ * @returns Result object containing:
168
+ * - width: The calculated visual width of the string
169
+ * - truncated: Whether the string was truncated
170
+ * - ellipsed: Whether an ellipsis was added
171
+ * - index: The index at which truncation occurred (if any)
172
+ */
173
173
  declare const getStringTruncatedWidth: (input: string, options?: StringTruncatedWidthOptions) => StringTruncatedWidthResult;
174
174
  export { StringTruncatedWidthOptions, StringTruncatedWidthResult, getStringTruncatedWidth };
@@ -1 +1 @@
1
- import{eastAsianWidthType as j}from"./packem_shared/eastAsianWidth-DJV8Kqd-.js";import{R as m,a as b,b as x}from"./packem_shared/constants-aPzGW29R.js";const E=new Map,R=i=>[i.ambiguousIsNarrow?1:0,i.control,i.fullWidth,i.regular,i.wide].join("|"),_=i=>{const t=R(i.width);let e=E.get(t);return e||(e=new Map,E.set(t,e)),e},W=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,O=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=_(t),s=Math.floor(i/65536),h=i%65536;let u=e.get(s);if(u||(u=new Map,e.set(s,u)),u.has(h))return u.get(h);let a;switch(O(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 u.set(h,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:h}=i,u=h>1e4;let a=0,n=0,l=h,r=!1;const T=i.includes("\x1B")||i.includes("›");for(;a<h;){if(T&&(i[a]==="\x1B"||i[a]==="›")){if(i.startsWith("\x1B]8;;",a)){const o="\x1B]8;;\x07",w=o.length,g=i.indexOf("\x07",a+5);if(g!==-1){const I=i.indexOf(o,g+1);if(I!==-1){const C=I+w,F=i.slice(g+1,I).replace(m,""),N=A(F,{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}),p=N.width;if(N.truncated)r=!0,l=Math.min(l,a);else if(n+p>s&&(l=Math.min(l,a),r=!0,n+p>e.truncation.limit))break;if(n+=p,a=C,r&&n>=e.truncation.limit)break;continue}}}if(m.lastIndex=a,m.test(i)){const o=m.lastIndex-a,w=e.truncation.countAnsiEscapeCodes?o:e.width.ansi;if(n+w>s&&(l=Math.min(l,a),n+w>e.truncation.limit)){r=!0;break}n+=w,a=m.lastIndex;continue}}const c=i.codePointAt(a);if(c===8203||c===65279||c>=8288&&c<=8292){a+=1;continue}if(c===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(W.lastIndex=a,W.test(i)){const o=(W.lastIndex-a)*e.width.regular;if(n+o>s){const w=Math.floor((s-n)/e.width.regular);if(l=Math.min(l,a+w),n+o>e.truncation.limit){r=!0;break}}n+=o,a=W.lastIndex;continue}if((c<=31||c>=127&&c<=159)&&(b.lastIndex=a,b.test(i))){const o=(b.lastIndex-a)*e.width.control;if(n+o>s&&(l=Math.min(l,a+Math.floor((s-n)/e.width.control)),n+o>e.truncation.limit)){r=!0;break}n+=o,a=b.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(u)d=B(f,e);else switch(O(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:h,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};
@@ -1,62 +1,62 @@
1
1
  import { StringTruncatedWidthOptions } from "./get-string-truncated-width.js";
2
2
  /**
3
- * Configuration options for string width calculation without truncation support.
4
- * This type excludes truncation-related options from StringTruncatedWidthOptions.
5
- * @example
6
- * ```typescript
7
- * // Basic usage with defaults
8
- * const options: StringWidthOptions = {};
9
- *
10
- * // Custom character widths
11
- * const options: StringWidthOptions = {
12
- * regularWidth: 2,
13
- * emojiWidth: 3,
14
- * tabWidth: 4
15
- * };
16
- *
17
- * // Unicode handling options
18
- * const options: StringWidthOptions = {
19
- * ambiguousIsNarrow: true,
20
- * fullWidth: 2,
21
- * wideWidth: 2
22
- * };
23
- * ```
24
- */
3
+ * Configuration options for string width calculation without truncation support.
4
+ * This type excludes truncation-related options from StringTruncatedWidthOptions.
5
+ * @example
6
+ * ```typescript
7
+ * // Basic usage with defaults
8
+ * const options: StringWidthOptions = {};
9
+ *
10
+ * // Custom character widths
11
+ * const options: StringWidthOptions = {
12
+ * regularWidth: 2,
13
+ * emojiWidth: 3,
14
+ * tabWidth: 4
15
+ * };
16
+ *
17
+ * // Unicode handling options
18
+ * const options: StringWidthOptions = {
19
+ * ambiguousIsNarrow: true,
20
+ * fullWidth: 2,
21
+ * wideWidth: 2
22
+ * };
23
+ * ```
24
+ */
25
25
  type StringWidthOptions = Omit<StringTruncatedWidthOptions, "ellipsis" | "ellipsisWidth" | "limit">;
26
26
  /**
27
- * Calculate the visual width of a string, taking into account Unicode characters, emojis, and ANSI escape codes.
28
- * @example
29
- * ```typescript
30
- * // Basic usage
31
- * getStringWidth('hello');
32
- * // => 5
33
- *
34
- * getStringWidth('👋 hello');
35
- * // => 7
36
- *
37
- * // With custom character widths
38
- * getStringWidth('hello', { regularWidth: 2 });
39
- * // => 10
40
- *
41
- * getStringWidth('あいう', { ambiguousIsNarrow: true });
42
- * // => 3
43
- *
44
- * // With combining characters
45
- * getStringWidth('e\u0301'); // Latin e with acute
46
- * // => 1
47
- *
48
- * getStringWidth('\u0e01\u0e31'); // Thai character with vowel mark
49
- * // => 1
50
- * ```
51
- *
52
- * Features:
53
- * - Full Unicode support including combining marks
54
- * - Accurate width calculation for emoji sequences
55
- * - ANSI escape code handling
56
- * - Customizable character widths
57
- * @param input The string to calculate the width for
58
- * @param options Configuration options for width calculation
59
- * @returns The calculated visual width of the string
60
- */
27
+ * Calculate the visual width of a string, taking into account Unicode characters, emojis, and ANSI escape codes.
28
+ * @example
29
+ * ```typescript
30
+ * // Basic usage
31
+ * getStringWidth('hello');
32
+ * // => 5
33
+ *
34
+ * getStringWidth('👋 hello');
35
+ * // => 7
36
+ *
37
+ * // With custom character widths
38
+ * getStringWidth('hello', { regularWidth: 2 });
39
+ * // => 10
40
+ *
41
+ * getStringWidth('あいう', { ambiguousIsNarrow: true });
42
+ * // => 3
43
+ *
44
+ * // With combining characters
45
+ * getStringWidth('e\u0301'); // Latin e with acute
46
+ * // => 1
47
+ *
48
+ * getStringWidth('\u0e01\u0e31'); // Thai character with vowel mark
49
+ * // => 1
50
+ * ```
51
+ *
52
+ * Features:
53
+ * - Full Unicode support including combining marks
54
+ * - Accurate width calculation for emoji sequences
55
+ * - ANSI escape code handling
56
+ * - Customizable character widths
57
+ * @param input The string to calculate the width for
58
+ * @param options Configuration options for width calculation
59
+ * @returns The calculated visual width of the string
60
+ */
61
61
  declare const getStringWidth: (input: string, options?: StringWidthOptions) => number;
62
62
  export { StringWidthOptions, getStringWidth };
package/dist/indent.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  interface Options {
2
2
  /**
3
- The string to use for the indent.
4
- @default ' '
5
- */
6
- readonly indent?: string;
3
+ The string to use for the indent.
7
4
 
5
+ @default ' '
6
+ */
7
+ readonly indent?: string;
8
8
  /**
9
- Also indent empty lines.
10
- @default false
11
- */
9
+ Also indent empty lines.
10
+
11
+ @default false
12
+ */
12
13
  readonly includeEmptyLines?: boolean;
13
14
  }
14
15
  /**
@@ -84,4 +85,6 @@ dedent(`
84
85
  ```
85
86
  */
86
87
  declare function dedent(string: string): string;
87
- 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
@@ -17,18 +17,16 @@ export { default as snakeCase } from "./case/snake-case.js";
17
17
  export { type SplitOptions, splitByCase } from "./case/split-by-case.js";
18
18
  export { default as titleCase } from "./case/title-case.js";
19
19
  export { default as trainCase } from "./case/train-case.js";
20
- export type { C as CamelCase, a as CapitalCase, b as CaseOptions, c as ConstantCase, D as DotCase, F as FlatCase, d as FlipCase, I as IdentifyCase, K as KebabCase, L as LocaleOptions, e as LowerFirst, N as NoCase, P as PascalCase, f as PascalSnakeCase, g as PathCase, S as SentenceCase, h as SnakeCase, i as SplitByCase, T as TitleCase, j as TrainCase, U as UpperFirst } from "./packem_shared/types.d-fhe030jX.js";
20
+ export type { C as CamelCase, a as CapitalCase, b as CaseOptions, c as ConstantCase, D as DotCase, F as FlatCase, d as FlipCase, I as IdentifyCase, K as KebabCase, L as LocaleOptions, e as LowerFirst, N as NoCase, P as PascalCase, f as PascalSnakeCase, g as PathCase, S as SentenceCase, h as SnakeCase, i as SplitByCase, T as TitleCase, j as TrainCase, U as UpperFirst } from "./packem_shared/types.d-CMNqA5bi.js";
21
21
  export { default as upperFirst } from "./case/upper-first.js";
22
22
  export { joinSegments } from "./case/index.js";
23
23
  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";
@@ -37,7 +35,9 @@ export { type SliceOptions, slice } from "./slice.js";
37
35
  export { default as slugify } from "./slugify.js";
38
36
  export { default as transliterate } from "./transliterate.js";
39
37
  export { type TruncateOptions, truncate } from "./truncate.js";
40
- export type { A as All, a as Any, C as CharAt, b as Charmap, c as Concat, E as EndsWith, I as Includes, d as Interval, e as IntervalArray, f as IsBooleanLiteral, g as IsNumberLiteral, h as IsStringLiteral, i as IsStringLiteralArray, J as Join, L as Length, M as Math, N as NodeLocale, O as OptionReplaceArray, j as OptionReplaceCombined, k as OptionReplaceObject, l as OptionsTransliterate, P as PadEnd, m as PadStart, R as Repeat, n as Replace, o as ReplaceAll, p as Reverse, S as Slice, q as SlugifyOptions, r as Split, s as StartsWith, T as ToLowerCase, t as ToUpperCase, u as Trim, v as TrimEnd, w as TrimStart } from "./packem_shared/types.d-CmNvyl4l.js";
38
+ export type { A as All, a as Any, C as CharAt, b as Charmap, c as Concat, E as EndsWith, I as Includes, d as Interval, e as IntervalArray, f as IsBooleanLiteral, g as IsNumberLiteral, h as IsStringLiteral, i as IsStringLiteralArray, J as Join, L as Length, M as Math, N as NodeLocale, O as OptionReplaceArray, j as OptionReplaceCombined, k as OptionReplaceObject, l as OptionsTransliterate, P as PadEnd, m as PadStart, R as Repeat, n as Replace, o as ReplaceAll, p as Reverse, S as Slice, q as SlugifyOptions, r as Split, s as StartsWith, T as ToLowerCase, t as ToUpperCase, u as Trim, v as TrimEnd, w as TrimStart } from "./packem_shared/types.d-LgsTR37y.js";
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,7 +1,7 @@
1
1
  /**
2
- * Check if the given code point is a fullwidth character.
3
- * @param codePoint The code point to check.
4
- * @returns Whether the code point is a fullwidth character.
5
- */
2
+ * Check if the given code point is a fullwidth character.
3
+ * @param codePoint The code point to check.
4
+ * @returns Whether the code point is a fullwidth character.
5
+ */
6
6
  declare const isFullwidthCodePoint: (codePoint: number) => boolean;
7
7
  export { isFullwidthCodePoint as default };
@@ -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};
@@ -2,24 +2,24 @@ declare const distance: (a: string, b: string) => number;
2
2
  declare const closest: (str: string, arr: readonly string[]) => string;
3
3
  declare const closestN: (string_: string, array: ReadonlyArray<string>, n: number) => (string | undefined)[];
4
4
  /**
5
- * Computes a normalized similarity score between two strings in the range `[0, 1]`,
6
- * where `1` means the strings are identical and `0` means maximally different.
7
- *
8
- * The score is derived from the Levenshtein edit distance, normalized by the
9
- * length of the longer string: `1 - distance(a, b) / max(a.length, b.length)`.
10
- * Two empty strings are considered identical (`1`).
11
- *
12
- * This is convenient for threshold-based "did you mean?" UX, complementing the
13
- * raw {@link distance} and the sort-based helpers.
14
- * @example
15
- * ```typescript
16
- * similarity("kitten", "sitting"); // => ~0.571
17
- * similarity("foo", "foo"); // => 1
18
- * similarity("", ""); // => 1
19
- * ```
20
- * @param a The first string.
21
- * @param b The second string.
22
- * @returns A similarity score between 0 and 1 (inclusive).
23
- */
5
+ * Computes a normalized similarity score between two strings in the range `[0, 1]`,
6
+ * where `1` means the strings are identical and `0` means maximally different.
7
+ *
8
+ * The score is derived from the Levenshtein edit distance, normalized by the
9
+ * length of the longer string: `1 - distance(a, b) / max(a.length, b.length)`.
10
+ * Two empty strings are considered identical (`1`).
11
+ *
12
+ * This is convenient for threshold-based "did you mean?" UX, complementing the
13
+ * raw {@link distance} and the sort-based helpers.
14
+ * @example
15
+ * ```typescript
16
+ * similarity("kitten", "sitting"); // => ~0.571
17
+ * similarity("foo", "foo"); // => 1
18
+ * similarity("", ""); // => 1
19
+ * ```
20
+ * @param a The first string.
21
+ * @param b The second string.
22
+ * @returns A similarity score between 0 and 1 (inclusive).
23
+ */
24
24
  declare const similarity: (a: string, b: string) => number;
25
25
  export { closest, closestN, distance, similarity };
@@ -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};