@visulima/string 1.0.3 โ 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +0 -1
- package/dist/get-string-truncated-width.cjs +6 -2
- package/dist/get-string-truncated-width.d.cts +0 -1
- package/dist/get-string-truncated-width.d.mts +0 -1
- package/dist/get-string-truncated-width.d.ts +0 -1
- package/dist/get-string-truncated-width.mjs +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## @visulima/string [1.0.5](https://github.com/visulima/visulima/compare/@visulima/string@1.0.4...@visulima/string@1.0.5) (2025-05-02)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **string:** update string width calculations for ellipsis and control characters, remove ambiguousWidth ([bf8a2de](https://github.com/visulima/visulima/commit/bf8a2de06429a229b5bdb17cadd8239243a55e0d))
|
|
6
|
+
|
|
7
|
+
## @visulima/string [1.0.4](https://github.com/visulima/visulima/compare/@visulima/string@1.0.3...@visulima/string@1.0.4) (2025-05-01)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **string:** enhance handling of box-drawing characters in string width calculations ([6d1d83a](https://github.com/visulima/visulima/commit/6d1d83a6823d90f9104363a91e8add7e0557fc27))
|
|
12
|
+
|
|
1
13
|
## @visulima/string [1.0.3](https://github.com/visulima/visulima/compare/@visulima/string@1.0.2...@visulima/string@1.0.3) (2025-04-29)
|
|
2
14
|
|
|
3
15
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -447,7 +447,6 @@ getStringWidth("๐จโ๐ฉโ๐งโ๐ฆ"); // => 2 (family emoji with ZWJ sequ
|
|
|
447
447
|
```typescript
|
|
448
448
|
interface StringWidthOptions {
|
|
449
449
|
ambiguousIsNarrow?: boolean; // Treat ambiguous-width characters as narrow
|
|
450
|
-
ambiguousWidth?: number; // Width of ambiguous-width characters (default: 1)
|
|
451
450
|
ansiWidth?: number; // Width of ANSI escape sequences (default: 0)
|
|
452
451
|
controlWidth?: number; // Width of control characters (default: 0)
|
|
453
452
|
countAnsiEscapeCodes?: boolean; // Include ANSI escape codes in width (default: false)
|
|
@@ -71,6 +71,9 @@ const getCharType = /* @__PURE__ */ __name((codePoint) => {
|
|
|
71
71
|
if (codePoint >= 160 && codePoint <= 255) {
|
|
72
72
|
return "latin";
|
|
73
73
|
}
|
|
74
|
+
if (codePoint >= 9472 && codePoint <= 9599) {
|
|
75
|
+
return "latin";
|
|
76
|
+
}
|
|
74
77
|
if (codePoint >= 4352 && codePoint <= 4607 || // Hangul Jamo
|
|
75
78
|
codePoint >= 11904 && codePoint <= 40959 || // CJK & radicals
|
|
76
79
|
codePoint >= 44032 && codePoint <= 55215 || // Hangul Syllables
|
|
@@ -79,6 +82,9 @@ const getCharType = /* @__PURE__ */ __name((codePoint) => {
|
|
|
79
82
|
codePoint >= 12352 && codePoint <= 12543) {
|
|
80
83
|
return "wide";
|
|
81
84
|
}
|
|
85
|
+
if (codePoint === 8230) {
|
|
86
|
+
return "latin";
|
|
87
|
+
}
|
|
82
88
|
return "other";
|
|
83
89
|
}, "getCharType");
|
|
84
90
|
const getCachedCharWidth = /* @__PURE__ */ __name((codePoint, config) => {
|
|
@@ -193,7 +199,6 @@ const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) =>
|
|
|
193
199
|
limit: options.limit ?? Number.POSITIVE_INFINITY
|
|
194
200
|
},
|
|
195
201
|
width: {
|
|
196
|
-
ambiguous: options.ambiguousWidth ?? 1,
|
|
197
202
|
ambiguousIsNarrow: options.ambiguousIsNarrow ?? false,
|
|
198
203
|
ansi: options.ansiWidth ?? 0,
|
|
199
204
|
control: options.controlWidth ?? 0,
|
|
@@ -228,7 +233,6 @@ const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) =>
|
|
|
228
233
|
const strippedLinkText = linkText.replace(constants.RE_ANSI, "");
|
|
229
234
|
const linkTextWidthResult = getStringTruncatedWidth(strippedLinkText, {
|
|
230
235
|
ambiguousIsNarrow: config.width.ambiguousIsNarrow,
|
|
231
|
-
ambiguousWidth: config.width.ambiguous,
|
|
232
236
|
ansiWidth: config.width.ansi,
|
|
233
237
|
controlWidth: config.width.control,
|
|
234
238
|
countAnsiEscapeCodes: false,
|
|
@@ -67,6 +67,9 @@ const getCharType = /* @__PURE__ */ __name((codePoint) => {
|
|
|
67
67
|
if (codePoint >= 160 && codePoint <= 255) {
|
|
68
68
|
return "latin";
|
|
69
69
|
}
|
|
70
|
+
if (codePoint >= 9472 && codePoint <= 9599) {
|
|
71
|
+
return "latin";
|
|
72
|
+
}
|
|
70
73
|
if (codePoint >= 4352 && codePoint <= 4607 || // Hangul Jamo
|
|
71
74
|
codePoint >= 11904 && codePoint <= 40959 || // CJK & radicals
|
|
72
75
|
codePoint >= 44032 && codePoint <= 55215 || // Hangul Syllables
|
|
@@ -75,6 +78,9 @@ const getCharType = /* @__PURE__ */ __name((codePoint) => {
|
|
|
75
78
|
codePoint >= 12352 && codePoint <= 12543) {
|
|
76
79
|
return "wide";
|
|
77
80
|
}
|
|
81
|
+
if (codePoint === 8230) {
|
|
82
|
+
return "latin";
|
|
83
|
+
}
|
|
78
84
|
return "other";
|
|
79
85
|
}, "getCharType");
|
|
80
86
|
const getCachedCharWidth = /* @__PURE__ */ __name((codePoint, config) => {
|
|
@@ -189,7 +195,6 @@ const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) =>
|
|
|
189
195
|
limit: options.limit ?? Number.POSITIVE_INFINITY
|
|
190
196
|
},
|
|
191
197
|
width: {
|
|
192
|
-
ambiguous: options.ambiguousWidth ?? 1,
|
|
193
198
|
ambiguousIsNarrow: options.ambiguousIsNarrow ?? false,
|
|
194
199
|
ansi: options.ansiWidth ?? 0,
|
|
195
200
|
control: options.controlWidth ?? 0,
|
|
@@ -224,7 +229,6 @@ const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) =>
|
|
|
224
229
|
const strippedLinkText = linkText.replace(RE_ANSI, "");
|
|
225
230
|
const linkTextWidthResult = getStringTruncatedWidth(strippedLinkText, {
|
|
226
231
|
ambiguousIsNarrow: config.width.ambiguousIsNarrow,
|
|
227
|
-
ambiguousWidth: config.width.ambiguous,
|
|
228
232
|
ansiWidth: config.width.ansi,
|
|
229
233
|
controlWidth: config.width.control,
|
|
230
234
|
countAnsiEscapeCodes: false,
|