@depup/string-width 8.2.2-depup.7 → 8.3.0-depup.0
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/README.md +3 -3
- package/changes.json +2 -2
- package/index.js +9 -13
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/string-width
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [string-width](https://www.npmjs.com/package/string-width) @ 8.
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [string-width](https://www.npmjs.com/package/string-width) @ 8.3.0 |
|
|
17
|
+
| Processed | 2026-09-27 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
19
|
| Deps updated | 2 |
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ npm install @depup/string-width
|
|
|
22
22
|
|
|
23
23
|
| Dependency | From | To |
|
|
24
24
|
|------------|------|-----|
|
|
25
|
-
| get-east-asian-width | ^1.5.0 | ^1.
|
|
25
|
+
| get-east-asian-width | ^1.5.0 | ^1.7.0 |
|
|
26
26
|
| strip-ansi | ^7.1.2 | ^7.2.0 |
|
|
27
27
|
|
|
28
28
|
---
|
package/changes.json
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"bumped": {
|
|
3
3
|
"get-east-asian-width": {
|
|
4
4
|
"from": "^1.5.0",
|
|
5
|
-
"to": "^1.
|
|
5
|
+
"to": "^1.7.0"
|
|
6
6
|
},
|
|
7
7
|
"strip-ansi": {
|
|
8
8
|
"from": "^7.1.2",
|
|
9
9
|
"to": "^7.2.0"
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
|
-
"timestamp": "2026-
|
|
12
|
+
"timestamp": "2026-09-27T01:04:23.363Z",
|
|
13
13
|
"totalUpdated": 2
|
|
14
14
|
}
|
package/index.js
CHANGED
|
@@ -15,11 +15,9 @@ Logic:
|
|
|
15
15
|
|
|
16
16
|
const segmenter = new Intl.Segmenter();
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Pick the base scalar if the cluster starts with Prepend/Format/Marks
|
|
22
|
-
const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v;
|
|
18
|
+
// Matches a visible (printing) character. Used to find the base scalar of a cluster (skipping leading Prepend/Format/Marks) and to detect whole-cluster zero-width.
|
|
19
|
+
// Intentionally a single negated class without a quantifier: a repeated pattern like `^(?:…|…)+$` backtracks exponentially on overlapping properties, and even `^[…]+$` overflows V8's backtrack stack (RangeError) on clusters with millions of marks.
|
|
20
|
+
const visibleCharacterRegex = /[^\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]/v;
|
|
23
21
|
const spacingMarkRegex = /\p{Spacing_Mark}/v;
|
|
24
22
|
|
|
25
23
|
// RGI emoji sequences
|
|
@@ -48,12 +46,10 @@ function isDoubleWidthNonRgiEmojiSequence(segment) {
|
|
|
48
46
|
return false;
|
|
49
47
|
}
|
|
50
48
|
|
|
49
|
+
// Returns the cluster starting at its first visible character, or `undefined` if the whole cluster is zero-width.
|
|
51
50
|
function baseVisible(segment) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
function isZeroWidthCluster(segment) {
|
|
56
|
-
return zeroWidthClusterRegex.test(segment);
|
|
51
|
+
const index = segment.search(visibleCharacterRegex);
|
|
52
|
+
return index === -1 ? undefined : segment.slice(index);
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
function isHangulLeadingJamo(codePoint) {
|
|
@@ -81,7 +77,7 @@ function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
|
|
|
81
77
|
const codePoints = [];
|
|
82
78
|
|
|
83
79
|
for (const character of visibleSegment) {
|
|
84
|
-
if (
|
|
80
|
+
if (!visibleCharacterRegex.test(character)) {
|
|
85
81
|
continue;
|
|
86
82
|
}
|
|
87
83
|
|
|
@@ -178,7 +174,8 @@ export default function stringWidth(input, options = {}) {
|
|
|
178
174
|
|
|
179
175
|
for (const {segment} of segmenter.segment(string)) {
|
|
180
176
|
// Zero-width / non-printing clusters
|
|
181
|
-
|
|
177
|
+
const visibleSegment = baseVisible(segment);
|
|
178
|
+
if (visibleSegment === undefined) {
|
|
182
179
|
continue;
|
|
183
180
|
}
|
|
184
181
|
|
|
@@ -188,7 +185,6 @@ export default function stringWidth(input, options = {}) {
|
|
|
188
185
|
continue;
|
|
189
186
|
}
|
|
190
187
|
|
|
191
|
-
const visibleSegment = baseVisible(segment);
|
|
192
188
|
const hangulWidth = hangulClusterWidth(visibleSegment, eastAsianWidthOptions);
|
|
193
189
|
if (hangulWidth !== undefined) {
|
|
194
190
|
width += hangulWidth;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/string-width",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0-depup.0",
|
|
4
4
|
"description": "Get the visual width of a string - the number of columns required to display it (with updated dependencies)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/string-width",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"east-asian-width"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"get-east-asian-width": "^1.
|
|
65
|
+
"get-east-asian-width": "^1.7.0",
|
|
66
66
|
"strip-ansi": "^7.2.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"changes": {
|
|
75
75
|
"get-east-asian-width": {
|
|
76
76
|
"from": "^1.5.0",
|
|
77
|
-
"to": "^1.
|
|
77
|
+
"to": "^1.7.0"
|
|
78
78
|
},
|
|
79
79
|
"strip-ansi": {
|
|
80
80
|
"from": "^7.1.2",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
},
|
|
84
84
|
"depsUpdated": 2,
|
|
85
85
|
"originalPackage": "string-width",
|
|
86
|
-
"originalVersion": "8.
|
|
87
|
-
"processedAt": "2026-
|
|
86
|
+
"originalVersion": "8.3.0",
|
|
87
|
+
"processedAt": "2026-09-27T01:04:30.506Z",
|
|
88
88
|
"smokeTest": "passed"
|
|
89
89
|
}
|
|
90
90
|
}
|