@visulima/string 1.0.4 โ†’ 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 CHANGED
@@ -1,3 +1,9 @@
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
+
1
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)
2
8
 
3
9
  ### 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)
@@ -82,6 +82,9 @@ const getCharType = /* @__PURE__ */ __name((codePoint) => {
82
82
  codePoint >= 12352 && codePoint <= 12543) {
83
83
  return "wide";
84
84
  }
85
+ if (codePoint === 8230) {
86
+ return "latin";
87
+ }
85
88
  return "other";
86
89
  }, "getCharType");
87
90
  const getCachedCharWidth = /* @__PURE__ */ __name((codePoint, config) => {
@@ -196,7 +199,6 @@ const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) =>
196
199
  limit: options.limit ?? Number.POSITIVE_INFINITY
197
200
  },
198
201
  width: {
199
- ambiguous: options.ambiguousWidth ?? 1,
200
202
  ambiguousIsNarrow: options.ambiguousIsNarrow ?? false,
201
203
  ansi: options.ansiWidth ?? 0,
202
204
  control: options.controlWidth ?? 0,
@@ -231,7 +233,6 @@ const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) =>
231
233
  const strippedLinkText = linkText.replace(constants.RE_ANSI, "");
232
234
  const linkTextWidthResult = getStringTruncatedWidth(strippedLinkText, {
233
235
  ambiguousIsNarrow: config.width.ambiguousIsNarrow,
234
- ambiguousWidth: config.width.ambiguous,
235
236
  ansiWidth: config.width.ansi,
236
237
  controlWidth: config.width.control,
237
238
  countAnsiEscapeCodes: false,
@@ -1,6 +1,5 @@
1
1
  interface StringTruncatedWidthOptions {
2
2
  ambiguousIsNarrow?: boolean;
3
- ambiguousWidth?: number;
4
3
  ansiWidth?: number;
5
4
  controlWidth?: number;
6
5
  countAnsiEscapeCodes?: boolean;
@@ -1,6 +1,5 @@
1
1
  interface StringTruncatedWidthOptions {
2
2
  ambiguousIsNarrow?: boolean;
3
- ambiguousWidth?: number;
4
3
  ansiWidth?: number;
5
4
  controlWidth?: number;
6
5
  countAnsiEscapeCodes?: boolean;
@@ -1,6 +1,5 @@
1
1
  interface StringTruncatedWidthOptions {
2
2
  ambiguousIsNarrow?: boolean;
3
- ambiguousWidth?: number;
4
3
  ansiWidth?: number;
5
4
  controlWidth?: number;
6
5
  countAnsiEscapeCodes?: boolean;
@@ -78,6 +78,9 @@ const getCharType = /* @__PURE__ */ __name((codePoint) => {
78
78
  codePoint >= 12352 && codePoint <= 12543) {
79
79
  return "wide";
80
80
  }
81
+ if (codePoint === 8230) {
82
+ return "latin";
83
+ }
81
84
  return "other";
82
85
  }, "getCharType");
83
86
  const getCachedCharWidth = /* @__PURE__ */ __name((codePoint, config) => {
@@ -192,7 +195,6 @@ const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) =>
192
195
  limit: options.limit ?? Number.POSITIVE_INFINITY
193
196
  },
194
197
  width: {
195
- ambiguous: options.ambiguousWidth ?? 1,
196
198
  ambiguousIsNarrow: options.ambiguousIsNarrow ?? false,
197
199
  ansi: options.ansiWidth ?? 0,
198
200
  control: options.controlWidth ?? 0,
@@ -227,7 +229,6 @@ const getStringTruncatedWidth = /* @__PURE__ */ __name((input, options = {}) =>
227
229
  const strippedLinkText = linkText.replace(RE_ANSI, "");
228
230
  const linkTextWidthResult = getStringTruncatedWidth(strippedLinkText, {
229
231
  ambiguousIsNarrow: config.width.ambiguousIsNarrow,
230
- ambiguousWidth: config.width.ambiguous,
231
232
  ansiWidth: config.width.ansi,
232
233
  controlWidth: config.width.control,
233
234
  countAnsiEscapeCodes: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/string",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Functions for manipulating strings.",
5
5
  "keywords": [
6
6
  "visulima",