@cjser/wrap-ansi 10.0.1-cjser.2 → 10.0.2-cjser.2

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.
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // packages/@cjser/wrap-ansi.tmp-26-1787070533195/index.js
29
+ // packages/@cjser/wrap-ansi.tmp-26-1790096744839/index.js
30
30
  var index_exports = {};
31
31
  __export(index_exports, {
32
32
  default: () => wrapAnsi
@@ -508,6 +508,15 @@ var exec = (string, columns, options = {}) => {
508
508
  }
509
509
  return restoreStylesAcrossRows(rows.join("\n"));
510
510
  };
511
+ var normalizeText = (string) => {
512
+ let normalizedString = "";
513
+ forEachSegment(string, (plainText) => {
514
+ normalizedString += plainText.normalize();
515
+ }, (escape) => {
516
+ normalizedString += escape;
517
+ });
518
+ return normalizedString;
519
+ };
511
520
  function wrapAnsi(string, columns, options) {
512
- return String(string).normalize().replaceAll("\r\n", "\n").split("\n").map((line) => exec(expandTabs(line), columns, options)).join("\n");
521
+ return normalizeText(String(string)).replaceAll("\r\n", "\n").split("\n").map((line) => exec(expandTabs(line), columns, options)).join("\n");
513
522
  }
package/index.js CHANGED
@@ -639,10 +639,22 @@ const exec = (string, columns, options = {}) => {
639
639
  return restoreStylesAcrossRows(rows.join('\n'));
640
640
  };
641
641
 
642
+ // Normalize the text, but not the sequences: a combining mark that follows a sequence composes with its last character and destroys it.
643
+ const normalizeText = string => {
644
+ let normalizedString = '';
645
+
646
+ forEachSegment(string, plainText => {
647
+ normalizedString += plainText.normalize();
648
+ }, escape => {
649
+ normalizedString += escape;
650
+ });
651
+
652
+ return normalizedString;
653
+ };
654
+
642
655
  // For each newline, invoke the method separately.
643
656
  export default function wrapAnsi(string, columns, options) {
644
- return String(string)
645
- .normalize()
657
+ return normalizeText(String(string))
646
658
  .replaceAll('\r\n', '\n')
647
659
  .split('\n')
648
660
  .map(line => exec(expandTabs(line), columns, options))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cjser/wrap-ansi",
3
- "version": "10.0.1-cjser.2",
3
+ "version": "10.0.2-cjser.2",
4
4
  "description": "Wordwrap a string with ANSI escape codes",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -71,11 +71,11 @@
71
71
  "types": "./index.d.ts",
72
72
  "main": "./dist-cjser/index.cjs",
73
73
  "cjser": {
74
- "sourceVersion": "10.0.1",
74
+ "sourceVersion": "10.0.2",
75
75
  "cjserVersion": 2,
76
76
  "original": {
77
77
  "name": "wrap-ansi",
78
- "version": "10.0.1",
78
+ "version": "10.0.2",
79
79
  "exports": {
80
80
  "types": "./index.d.ts",
81
81
  "default": "./index.js"