@alcalzone/ansi-tokenize 0.2.0 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +4 -0
- package/build/reduce.js +14 -3
- package/build/reduce.js.map +1 -1
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2025 AlCalzone
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -231,6 +231,10 @@ This automatically figures out the least amount of escape codes necessary to ach
|
|
|
231
231
|
Placeholder for next release:
|
|
232
232
|
### __WORK IN PROGRESS__
|
|
233
233
|
-->
|
|
234
|
+
### 0.2.1 (2025-10-20)
|
|
235
|
+
|
|
236
|
+
- Fix: Prevent `dim` and `bold` modifiers from canceling each other (#37)
|
|
237
|
+
|
|
234
238
|
### 0.2.0 (2025-04-24)
|
|
235
239
|
|
|
236
240
|
- Breaking: Require Node.js 18+
|
package/build/reduce.js
CHANGED
|
@@ -17,9 +17,20 @@ export function reduceAnsiCodesIncremental(codes, newCodes) {
|
|
|
17
17
|
ret = ret.filter((retCode) => retCode.endCode !== code.code);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
-
// This is a start code.
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// This is a start code. Remove codes it "overrides", then add it.
|
|
21
|
+
// If a new code has the same endCode, it "overrides" existing ones.
|
|
22
|
+
// Special case: Intensity codes (1m, 2m) can coexist (both end with 22m).
|
|
23
|
+
const isIntensityCode = code.code === ansiStyles.bold.open || code.code === ansiStyles.dim.open;
|
|
24
|
+
// Add intensity codes only if not already present
|
|
25
|
+
if (isIntensityCode) {
|
|
26
|
+
if (!ret.find((retCode) => retCode.code === code.code && retCode.endCode === code.endCode)) {
|
|
27
|
+
ret.push(code);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
ret = ret.filter((retCode) => retCode.endCode !== code.endCode);
|
|
32
|
+
ret.push(code);
|
|
33
|
+
}
|
|
23
34
|
}
|
|
24
35
|
}
|
|
25
36
|
return ret;
|
package/build/reduce.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduce.js","sourceRoot":"","sources":["../src/reduce.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,mGAAmG;AACnG,MAAM,UAAU,eAAe,CAAC,KAAiB;IAChD,OAAO,0BAA0B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AAC9C,CAA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,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;SAC7D;aAAM;YACN,kEAAkE;YAClE,oEAAoE;YACpE,0EAA0E;YAC1E,MAAM,eAAe,GACpB,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;YAEzE,kDAAkD;YAClD,IAAI,eAAe,EAAE;gBACpB,IACC,CAAC,GAAG,CAAC,IAAI,CACR,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,CAC3E,EACA;oBACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACf;aACD;iBAAM;gBACN,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACf;SACD;KACD;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alcalzone/ansi-tokenize",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Efficiently modify strings containing ANSI escape codes",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"node": ">=18"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@alcalzone/release-script": "~
|
|
31
|
-
"@alcalzone/release-script-plugin-license": "~
|
|
32
|
-
"@tsconfig/
|
|
33
|
-
"@types/node": "^
|
|
30
|
+
"@alcalzone/release-script": "~4.0.0",
|
|
31
|
+
"@alcalzone/release-script-plugin-license": "~4.0.0",
|
|
32
|
+
"@tsconfig/node18": "^18.2.4",
|
|
33
|
+
"@types/node": "^18.19.130",
|
|
34
34
|
"@typescript-eslint/eslint-plugin": "^5.55.0",
|
|
35
35
|
"@typescript-eslint/parser": "^5.55.0",
|
|
36
36
|
"ava": "^4.3.3",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"ts": "module"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"packageManager": "yarn@
|
|
63
|
-
}
|
|
62
|
+
"packageManager": "yarn@4.10.3"
|
|
63
|
+
}
|