@shell-shock/preset-cli 0.9.13 → 0.9.15

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.
Files changed (56) hide show
  1. package/dist/components/command-entry.cjs +2 -5
  2. package/dist/components/command-entry.mjs +2 -5
  3. package/dist/components/command-entry.mjs.map +1 -1
  4. package/dist/components/virtual-command-entry.cjs +2 -5
  5. package/dist/components/virtual-command-entry.mjs +2 -5
  6. package/dist/components/virtual-command-entry.mjs.map +1 -1
  7. package/dist/node_modules/.pnpm/ansi-regex@6.2.2/node_modules/ansi-regex/index.cjs +8 -0
  8. package/dist/node_modules/.pnpm/ansi-regex@6.2.2/node_modules/ansi-regex/index.mjs +8 -0
  9. package/dist/node_modules/.pnpm/ansi-regex@6.2.2/node_modules/ansi-regex/index.mjs.map +1 -0
  10. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/index.cjs +14 -0
  11. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/index.mjs +15 -0
  12. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/index.mjs.map +1 -0
  13. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/lookup-data.cjs +655 -0
  14. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/lookup-data.mjs +651 -0
  15. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/lookup-data.mjs.map +1 -0
  16. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/lookup.cjs +48 -0
  17. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/lookup.mjs +47 -0
  18. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/lookup.mjs.map +1 -0
  19. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/utilities.cjs +24 -0
  20. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/utilities.mjs +24 -0
  21. package/dist/node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/utilities.mjs.map +1 -0
  22. package/dist/node_modules/.pnpm/string-width@8.2.0/node_modules/string-width/index.cjs +65 -0
  23. package/dist/node_modules/.pnpm/string-width@8.2.0/node_modules/string-width/index.mjs +66 -0
  24. package/dist/node_modules/.pnpm/string-width@8.2.0/node_modules/string-width/index.mjs.map +1 -0
  25. package/dist/node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.cjs +12 -0
  26. package/dist/node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.mjs +13 -0
  27. package/dist/node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.mjs.map +1 -0
  28. package/dist/node_modules/.pnpm/wrap-ansi@10.0.0/node_modules/wrap-ansi/index.cjs +290 -3
  29. package/dist/node_modules/.pnpm/wrap-ansi@10.0.0/node_modules/wrap-ansi/index.mjs +287 -1
  30. package/dist/node_modules/.pnpm/wrap-ansi@10.0.0/node_modules/wrap-ansi/index.mjs.map +1 -1
  31. package/dist/packages/plugin-changelog/dist/components/changelog-command.cjs +5 -5
  32. package/dist/packages/plugin-changelog/dist/components/changelog-command.mjs +5 -5
  33. package/dist/packages/plugin-changelog/dist/components/changelog-command.mjs.map +1 -1
  34. package/dist/packages/plugin-changelog/dist/helpers/resolve-changelog.cjs +51 -0
  35. package/dist/packages/plugin-changelog/dist/helpers/resolve-changelog.mjs +51 -0
  36. package/dist/packages/plugin-changelog/dist/helpers/resolve-changelog.mjs.map +1 -0
  37. package/dist/packages/plugin-changelog/dist/index.cjs +32 -20
  38. package/dist/packages/plugin-changelog/dist/index.mjs +32 -20
  39. package/dist/packages/plugin-changelog/dist/index.mjs.map +1 -1
  40. package/dist/packages/plugin-changelog/dist/types/plugin.d.cts +48 -0
  41. package/dist/packages/plugin-changelog/dist/types/plugin.d.cts.map +1 -1
  42. package/dist/packages/plugin-changelog/dist/types/plugin.d.mts +48 -0
  43. package/dist/packages/plugin-changelog/dist/types/plugin.d.mts.map +1 -1
  44. package/dist/packages/unified/dist/html-Dw6VvFHa.cjs +612 -0
  45. package/dist/packages/unified/dist/html-Dw6VvFHa.mjs +613 -0
  46. package/dist/packages/unified/dist/html-Dw6VvFHa.mjs.map +1 -0
  47. package/dist/packages/unified/dist/markdown/index.cjs +1 -1
  48. package/dist/packages/unified/dist/markdown/index.mjs +1 -1
  49. package/dist/packages/unified/dist/{markdown-BiaU4FQg.cjs → markdown-BGGlzivq.cjs} +14 -50
  50. package/dist/packages/unified/dist/{markdown-BiaU4FQg.mjs → markdown-BGGlzivq.mjs} +16 -52
  51. package/dist/packages/unified/dist/markdown-BGGlzivq.mjs.map +1 -0
  52. package/package.json +20 -16
  53. package/dist/packages/unified/dist/html-DzncQodH.cjs +0 -156
  54. package/dist/packages/unified/dist/html-DzncQodH.mjs +0 -157
  55. package/dist/packages/unified/dist/html-DzncQodH.mjs.map +0 -1
  56. package/dist/packages/unified/dist/markdown-BiaU4FQg.mjs.map +0 -1
@@ -0,0 +1,47 @@
1
+ import { ambiguousRanges, fullwidthRanges, halfwidthRanges, narrowRanges, wideRanges } from "./lookup-data.mjs";
2
+ import { isInRange } from "./utilities.mjs";
3
+
4
+ //#region ../../node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/lookup.js
5
+ const minimumAmbiguousCodePoint = ambiguousRanges[0];
6
+ const maximumAmbiguousCodePoint = ambiguousRanges.at(-1);
7
+ const minimumFullWidthCodePoint = fullwidthRanges[0];
8
+ const maximumFullWidthCodePoint = fullwidthRanges.at(-1);
9
+ const minimumHalfWidthCodePoint = halfwidthRanges[0];
10
+ const maximumHalfWidthCodePoint = halfwidthRanges.at(-1);
11
+ const minimumNarrowCodePoint = narrowRanges[0];
12
+ const maximumNarrowCodePoint = narrowRanges.at(-1);
13
+ const minimumWideCodePoint = wideRanges[0];
14
+ const maximumWideCodePoint = wideRanges.at(-1);
15
+ const commonCjkCodePoint = 19968;
16
+ const [wideFastPathStart, wideFastPathEnd] = findWideFastPathRange(wideRanges);
17
+ function findWideFastPathRange(ranges) {
18
+ let fastPathStart = ranges[0];
19
+ let fastPathEnd = ranges[1];
20
+ for (let index = 0; index < ranges.length; index += 2) {
21
+ const start = ranges[index];
22
+ const end = ranges[index + 1];
23
+ if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) return [start, end];
24
+ if (end - start > fastPathEnd - fastPathStart) {
25
+ fastPathStart = start;
26
+ fastPathEnd = end;
27
+ }
28
+ }
29
+ return [fastPathStart, fastPathEnd];
30
+ }
31
+ const isAmbiguous = (codePoint) => {
32
+ if (codePoint < minimumAmbiguousCodePoint || codePoint > maximumAmbiguousCodePoint) return false;
33
+ return isInRange(ambiguousRanges, codePoint);
34
+ };
35
+ const isFullWidth = (codePoint) => {
36
+ if (codePoint < minimumFullWidthCodePoint || codePoint > maximumFullWidthCodePoint) return false;
37
+ return isInRange(fullwidthRanges, codePoint);
38
+ };
39
+ const isWide = (codePoint) => {
40
+ if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) return true;
41
+ if (codePoint < minimumWideCodePoint || codePoint > maximumWideCodePoint) return false;
42
+ return isInRange(wideRanges, codePoint);
43
+ };
44
+
45
+ //#endregion
46
+ export { isAmbiguous, isFullWidth, isWide };
47
+ //# sourceMappingURL=lookup.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/lookup.js"],"sourcesContent":["import {\n\tambiguousRanges,\n\tfullwidthRanges,\n\thalfwidthRanges,\n\tnarrowRanges,\n\twideRanges,\n} from './lookup-data.js';\nimport {isInRange} from './utilities.js';\n\nconst minimumAmbiguousCodePoint = ambiguousRanges[0];\nconst maximumAmbiguousCodePoint = ambiguousRanges.at(-1);\nconst minimumFullWidthCodePoint = fullwidthRanges[0];\nconst maximumFullWidthCodePoint = fullwidthRanges.at(-1);\nconst minimumHalfWidthCodePoint = halfwidthRanges[0];\nconst maximumHalfWidthCodePoint = halfwidthRanges.at(-1);\nconst minimumNarrowCodePoint = narrowRanges[0];\nconst maximumNarrowCodePoint = narrowRanges.at(-1);\nconst minimumWideCodePoint = wideRanges[0];\nconst maximumWideCodePoint = wideRanges.at(-1);\n\nconst commonCjkCodePoint = 0x4E_00;\nconst [wideFastPathStart, wideFastPathEnd] = findWideFastPathRange(wideRanges);\n\n// Use a hot-path range so common `isWide` calls can skip binary search.\n// The range containing U+4E00 covers common CJK ideographs;\n// fallback to the largest range for resilience to Unicode table changes.\nfunction findWideFastPathRange(ranges) {\n\tlet fastPathStart = ranges[0];\n\tlet fastPathEnd = ranges[1];\n\n\tfor (let index = 0; index < ranges.length; index += 2) {\n\t\tconst start = ranges[index];\n\t\tconst end = ranges[index + 1];\n\n\t\tif (\n\t\t\tcommonCjkCodePoint >= start\n\t\t\t&& commonCjkCodePoint <= end\n\t\t) {\n\t\t\treturn [start, end];\n\t\t}\n\n\t\tif ((end - start) > (fastPathEnd - fastPathStart)) {\n\t\t\tfastPathStart = start;\n\t\t\tfastPathEnd = end;\n\t\t}\n\t}\n\n\treturn [fastPathStart, fastPathEnd];\n}\n\nexport const isAmbiguous = codePoint => {\n\tif (\n\t\tcodePoint < minimumAmbiguousCodePoint\n\t\t|| codePoint > maximumAmbiguousCodePoint\n\t) {\n\t\treturn false;\n\t}\n\n\treturn isInRange(ambiguousRanges, codePoint);\n};\n\nexport const isFullWidth = codePoint => {\n\tif (\n\t\tcodePoint < minimumFullWidthCodePoint\n\t\t|| codePoint > maximumFullWidthCodePoint\n\t) {\n\t\treturn false;\n\t}\n\n\treturn isInRange(fullwidthRanges, codePoint);\n};\n\nconst isHalfWidth = codePoint => {\n\tif (\n\t\tcodePoint < minimumHalfWidthCodePoint\n\t\t|| codePoint > maximumHalfWidthCodePoint\n\t) {\n\t\treturn false;\n\t}\n\n\treturn isInRange(halfwidthRanges, codePoint);\n};\n\nconst isNarrow = codePoint => {\n\tif (\n\t\tcodePoint < minimumNarrowCodePoint\n\t\t|| codePoint > maximumNarrowCodePoint\n\t) {\n\t\treturn false;\n\t}\n\n\treturn isInRange(narrowRanges, codePoint);\n};\n\nexport const isWide = codePoint => {\n\tif (\n\t\tcodePoint >= wideFastPathStart\n\t\t&& codePoint <= wideFastPathEnd\n\t) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\tcodePoint < minimumWideCodePoint\n\t\t|| codePoint > maximumWideCodePoint\n\t) {\n\t\treturn false;\n\t}\n\n\treturn isInRange(wideRanges, codePoint);\n};\n\nexport function getCategory(codePoint) {\n\tif (isAmbiguous(codePoint)) {\n\t\treturn 'ambiguous';\n\t}\n\n\tif (isFullWidth(codePoint)) {\n\t\treturn 'fullwidth';\n\t}\n\n\tif (isHalfWidth(codePoint)) {\n\t\treturn 'halfwidth';\n\t}\n\n\tif (isNarrow(codePoint)) {\n\t\treturn 'narrow';\n\t}\n\n\tif (isWide(codePoint)) {\n\t\treturn 'wide';\n\t}\n\n\treturn 'neutral';\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;AASA,MAAM,4BAA4B,gBAAgB;AAClD,MAAM,4BAA4B,gBAAgB,GAAG,GAAG;AACxD,MAAM,4BAA4B,gBAAgB;AAClD,MAAM,4BAA4B,gBAAgB,GAAG,GAAG;AACxD,MAAM,4BAA4B,gBAAgB;AAClD,MAAM,4BAA4B,gBAAgB,GAAG,GAAG;AACxD,MAAM,yBAAyB,aAAa;AAC5C,MAAM,yBAAyB,aAAa,GAAG,GAAG;AAClD,MAAM,uBAAuB,WAAW;AACxC,MAAM,uBAAuB,WAAW,GAAG,GAAG;AAE9C,MAAM,qBAAqB;AAC3B,MAAM,CAAC,mBAAmB,mBAAmB,sBAAsB,WAAW;AAK9E,SAAS,sBAAsB,QAAQ;CACtC,IAAI,gBAAgB,OAAO;CAC3B,IAAI,cAAc,OAAO;AAEzB,MAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS,GAAG;EACtD,MAAM,QAAQ,OAAO;EACrB,MAAM,MAAM,OAAO,QAAQ;AAE3B,MACC,sBAAsB,SACnB,sBAAsB,IAEzB,QAAO,CAAC,OAAO,IAAI;AAGpB,MAAK,MAAM,QAAU,cAAc,eAAgB;AAClD,mBAAgB;AAChB,iBAAc;;;AAIhB,QAAO,CAAC,eAAe,YAAY;;AAGpC,MAAa,eAAc,cAAa;AACvC,KACC,YAAY,6BACT,YAAY,0BAEf,QAAO;AAGR,QAAO,UAAU,iBAAiB,UAAU;;AAG7C,MAAa,eAAc,cAAa;AACvC,KACC,YAAY,6BACT,YAAY,0BAEf,QAAO;AAGR,QAAO,UAAU,iBAAiB,UAAU;;AAyB7C,MAAa,UAAS,cAAa;AAClC,KACC,aAAa,qBACV,aAAa,gBAEhB,QAAO;AAGR,KACC,YAAY,wBACT,YAAY,qBAEf,QAAO;AAGR,QAAO,UAAU,YAAY,UAAU"}
@@ -0,0 +1,24 @@
1
+
2
+ //#region ../../node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/utilities.js
3
+ /**
4
+ Binary search on a sorted flat array of [start, end] pairs.
5
+
6
+ @param {number[]} ranges - Flat array of inclusive [start, end] range pairs, e.g. [0, 5, 10, 20].
7
+ @param {number} codePoint - The value to search for.
8
+ @returns {boolean} Whether the value falls within any of the ranges.
9
+ */
10
+ const isInRange = (ranges, codePoint) => {
11
+ let low = 0;
12
+ let high = Math.floor(ranges.length / 2) - 1;
13
+ while (low <= high) {
14
+ const mid = Math.floor((low + high) / 2);
15
+ const i = mid * 2;
16
+ if (codePoint < ranges[i]) high = mid - 1;
17
+ else if (codePoint > ranges[i + 1]) low = mid + 1;
18
+ else return true;
19
+ }
20
+ return false;
21
+ };
22
+
23
+ //#endregion
24
+ exports.isInRange = isInRange;
@@ -0,0 +1,24 @@
1
+ //#region ../../node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/utilities.js
2
+ /**
3
+ Binary search on a sorted flat array of [start, end] pairs.
4
+
5
+ @param {number[]} ranges - Flat array of inclusive [start, end] range pairs, e.g. [0, 5, 10, 20].
6
+ @param {number} codePoint - The value to search for.
7
+ @returns {boolean} Whether the value falls within any of the ranges.
8
+ */
9
+ const isInRange = (ranges, codePoint) => {
10
+ let low = 0;
11
+ let high = Math.floor(ranges.length / 2) - 1;
12
+ while (low <= high) {
13
+ const mid = Math.floor((low + high) / 2);
14
+ const i = mid * 2;
15
+ if (codePoint < ranges[i]) high = mid - 1;
16
+ else if (codePoint > ranges[i + 1]) low = mid + 1;
17
+ else return true;
18
+ }
19
+ return false;
20
+ };
21
+
22
+ //#endregion
23
+ export { isInRange };
24
+ //# sourceMappingURL=utilities.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/get-east-asian-width@1.5.0/node_modules/get-east-asian-width/utilities.js"],"sourcesContent":["/**\nBinary search on a sorted flat array of [start, end] pairs.\n\n@param {number[]} ranges - Flat array of inclusive [start, end] range pairs, e.g. [0, 5, 10, 20].\n@param {number} codePoint - The value to search for.\n@returns {boolean} Whether the value falls within any of the ranges.\n*/\nexport const isInRange = (ranges, codePoint) => {\n\tlet low = 0;\n\tlet high = Math.floor(ranges.length / 2) - 1;\n\twhile (low <= high) {\n\t\tconst mid = Math.floor((low + high) / 2);\n\t\tconst i = mid * 2;\n\t\tif (codePoint < ranges[i]) {\n\t\t\thigh = mid - 1;\n\t\t} else if (codePoint > ranges[i + 1]) {\n\t\t\tlow = mid + 1;\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAOA,MAAa,aAAa,QAAQ,cAAc;CAC/C,IAAI,MAAM;CACV,IAAI,OAAO,KAAK,MAAM,OAAO,SAAS,EAAE,GAAG;AAC3C,QAAO,OAAO,MAAM;EACnB,MAAM,MAAM,KAAK,OAAO,MAAM,QAAQ,EAAE;EACxC,MAAM,IAAI,MAAM;AAChB,MAAI,YAAY,OAAO,GACtB,QAAO,MAAM;WACH,YAAY,OAAO,IAAI,GACjC,OAAM,MAAM;MAEZ,QAAO;;AAIT,QAAO"}
@@ -0,0 +1,65 @@
1
+ const require_index = require('../../../strip-ansi@7.2.0/node_modules/strip-ansi/index.cjs');
2
+ const require_index$1 = require('../../../get-east-asian-width@1.5.0/node_modules/get-east-asian-width/index.cjs');
3
+
4
+ //#region ../../node_modules/.pnpm/string-width@8.2.0/node_modules/string-width/index.js
5
+ /**
6
+ Logic:
7
+ - Segment graphemes to match how terminals render clusters.
8
+ - Width rules:
9
+ 1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates). Tabs are ignored by design.
10
+ 2. RGI emoji clusters (\p{RGI_Emoji}) are double-width.
11
+ 3. Minimally-qualified/unqualified emoji clusters (ZWJ sequences with 2+ Extended_Pictographic, or keycap sequences) are double-width.
12
+ 4. Otherwise use East Asian Width of the cluster's first visible code point, and add widths for trailing Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark).
13
+ */
14
+ const segmenter = new Intl.Segmenter();
15
+ const zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Mark}|\p{Surrogate})+$/v;
16
+ const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
17
+ const rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
18
+ const unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
19
+ const extendedPictographicRegex = /\p{Extended_Pictographic}/gu;
20
+ function isDoubleWidthNonRgiEmojiSequence(segment) {
21
+ if (segment.length > 50) return false;
22
+ if (unqualifiedKeycapRegex.test(segment)) return true;
23
+ if (segment.includes("‍")) {
24
+ const pictographics = segment.match(extendedPictographicRegex);
25
+ return pictographics !== null && pictographics.length >= 2;
26
+ }
27
+ return false;
28
+ }
29
+ function baseVisible(segment) {
30
+ return segment.replace(leadingNonPrintingRegex, "");
31
+ }
32
+ function isZeroWidthCluster(segment) {
33
+ return zeroWidthClusterRegex.test(segment);
34
+ }
35
+ function trailingHalfwidthWidth(segment, eastAsianWidthOptions) {
36
+ let extra = 0;
37
+ if (segment.length > 1) {
38
+ for (const char of segment.slice(1)) if (char >= "＀" && char <= "￯") extra += require_index$1.eastAsianWidth(char.codePointAt(0), eastAsianWidthOptions);
39
+ }
40
+ return extra;
41
+ }
42
+ function stringWidth(input, options = {}) {
43
+ if (typeof input !== "string" || input.length === 0) return 0;
44
+ const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
45
+ let string = input;
46
+ if (!countAnsiEscapeCodes && (string.includes("\x1B") || string.includes("›"))) string = require_index.default(string);
47
+ if (string.length === 0) return 0;
48
+ if (/^[\u0020-\u007E]*$/.test(string)) return string.length;
49
+ let width = 0;
50
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
51
+ for (const { segment } of segmenter.segment(string)) {
52
+ if (isZeroWidthCluster(segment)) continue;
53
+ if (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {
54
+ width += 2;
55
+ continue;
56
+ }
57
+ const codePoint = baseVisible(segment).codePointAt(0);
58
+ width += require_index$1.eastAsianWidth(codePoint, eastAsianWidthOptions);
59
+ width += trailingHalfwidthWidth(segment, eastAsianWidthOptions);
60
+ }
61
+ return width;
62
+ }
63
+
64
+ //#endregion
65
+ exports.default = stringWidth;
@@ -0,0 +1,66 @@
1
+ import stripAnsi from "../../../strip-ansi@7.2.0/node_modules/strip-ansi/index.mjs";
2
+ import { eastAsianWidth } from "../../../get-east-asian-width@1.5.0/node_modules/get-east-asian-width/index.mjs";
3
+
4
+ //#region ../../node_modules/.pnpm/string-width@8.2.0/node_modules/string-width/index.js
5
+ /**
6
+ Logic:
7
+ - Segment graphemes to match how terminals render clusters.
8
+ - Width rules:
9
+ 1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates). Tabs are ignored by design.
10
+ 2. RGI emoji clusters (\p{RGI_Emoji}) are double-width.
11
+ 3. Minimally-qualified/unqualified emoji clusters (ZWJ sequences with 2+ Extended_Pictographic, or keycap sequences) are double-width.
12
+ 4. Otherwise use East Asian Width of the cluster's first visible code point, and add widths for trailing Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark).
13
+ */
14
+ const segmenter = new Intl.Segmenter();
15
+ const zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Mark}|\p{Surrogate})+$/v;
16
+ const leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
17
+ const rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
18
+ const unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
19
+ const extendedPictographicRegex = /\p{Extended_Pictographic}/gu;
20
+ function isDoubleWidthNonRgiEmojiSequence(segment) {
21
+ if (segment.length > 50) return false;
22
+ if (unqualifiedKeycapRegex.test(segment)) return true;
23
+ if (segment.includes("‍")) {
24
+ const pictographics = segment.match(extendedPictographicRegex);
25
+ return pictographics !== null && pictographics.length >= 2;
26
+ }
27
+ return false;
28
+ }
29
+ function baseVisible(segment) {
30
+ return segment.replace(leadingNonPrintingRegex, "");
31
+ }
32
+ function isZeroWidthCluster(segment) {
33
+ return zeroWidthClusterRegex.test(segment);
34
+ }
35
+ function trailingHalfwidthWidth(segment, eastAsianWidthOptions) {
36
+ let extra = 0;
37
+ if (segment.length > 1) {
38
+ for (const char of segment.slice(1)) if (char >= "＀" && char <= "￯") extra += eastAsianWidth(char.codePointAt(0), eastAsianWidthOptions);
39
+ }
40
+ return extra;
41
+ }
42
+ function stringWidth(input, options = {}) {
43
+ if (typeof input !== "string" || input.length === 0) return 0;
44
+ const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
45
+ let string = input;
46
+ if (!countAnsiEscapeCodes && (string.includes("\x1B") || string.includes("›"))) string = stripAnsi(string);
47
+ if (string.length === 0) return 0;
48
+ if (/^[\u0020-\u007E]*$/.test(string)) return string.length;
49
+ let width = 0;
50
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
51
+ for (const { segment } of segmenter.segment(string)) {
52
+ if (isZeroWidthCluster(segment)) continue;
53
+ if (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {
54
+ width += 2;
55
+ continue;
56
+ }
57
+ const codePoint = baseVisible(segment).codePointAt(0);
58
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
59
+ width += trailingHalfwidthWidth(segment, eastAsianWidthOptions);
60
+ }
61
+ return width;
62
+ }
63
+
64
+ //#endregion
65
+ export { stringWidth as default };
66
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/string-width@8.2.0/node_modules/string-width/index.js"],"sourcesContent":["import stripAnsi from 'strip-ansi';\nimport {eastAsianWidth} from 'get-east-asian-width';\n\n/**\nLogic:\n- Segment graphemes to match how terminals render clusters.\n- Width rules:\n\t1. Skip non-printing clusters (Default_Ignorable, Control, pure Mark, lone Surrogates). Tabs are ignored by design.\n\t2. RGI emoji clusters (\\p{RGI_Emoji}) are double-width.\n\t3. Minimally-qualified/unqualified emoji clusters (ZWJ sequences with 2+ Extended_Pictographic, or keycap sequences) are double-width.\n\t4. Otherwise use East Asian Width of the cluster's first visible code point, and add widths for trailing Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark).\n*/\n\nconst segmenter = new Intl.Segmenter();\n\n// Whole-cluster zero-width\nconst zeroWidthClusterRegex = /^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$/v;\n\n// Pick the base scalar if the cluster starts with Prepend/Format/Marks\nconst leadingNonPrintingRegex = /^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+/v;\n\n// RGI emoji sequences\nconst rgiEmojiRegex = /^\\p{RGI_Emoji}$/v;\n\n// Detect minimally-qualified/unqualified emoji sequences (missing VS16 but still render as double-width)\nconst unqualifiedKeycapRegex = /^[\\d#*]\\u20E3$/;\nconst extendedPictographicRegex = /\\p{Extended_Pictographic}/gu;\n\nfunction isDoubleWidthNonRgiEmojiSequence(segment) {\n\t// Real emoji clusters are < 30 chars; guard against pathological input\n\tif (segment.length > 50) {\n\t\treturn false;\n\t}\n\n\tif (unqualifiedKeycapRegex.test(segment)) {\n\t\treturn true;\n\t}\n\n\t// ZWJ sequences with 2+ Extended_Pictographic\n\tif (segment.includes('\\u200D')) {\n\t\tconst pictographics = segment.match(extendedPictographicRegex);\n\t\treturn pictographics !== null && pictographics.length >= 2;\n\t}\n\n\treturn false;\n}\n\nfunction baseVisible(segment) {\n\treturn segment.replace(leadingNonPrintingRegex, '');\n}\n\nfunction isZeroWidthCluster(segment) {\n\treturn zeroWidthClusterRegex.test(segment);\n}\n\nfunction trailingHalfwidthWidth(segment, eastAsianWidthOptions) {\n\tlet extra = 0;\n\tif (segment.length > 1) {\n\t\tfor (const char of segment.slice(1)) {\n\t\t\tif (char >= '\\uFF00' && char <= '\\uFFEF') {\n\t\t\t\textra += eastAsianWidth(char.codePointAt(0), eastAsianWidthOptions);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn extra;\n}\n\nexport default function stringWidth(input, options = {}) {\n\tif (typeof input !== 'string' || input.length === 0) {\n\t\treturn 0;\n\t}\n\n\tconst {\n\t\tambiguousIsNarrow = true,\n\t\tcountAnsiEscapeCodes = false,\n\t} = options;\n\n\tlet string = input;\n\n\t// Avoid calling stripAnsi when there are no ANSI escape sequences (ESC = 0x1B, CSI = 0x9B)\n\tif (!countAnsiEscapeCodes && (string.includes('\\u001B') || string.includes('\\u009B'))) {\n\t\tstring = stripAnsi(string);\n\t}\n\n\tif (string.length === 0) {\n\t\treturn 0;\n\t}\n\n\t// Fast path: printable ASCII (0x20–0x7E) needs no segmenter, regex, or EAW lookup — width equals length.\n\tif (/^[\\u0020-\\u007E]*$/.test(string)) {\n\t\treturn string.length;\n\t}\n\n\tlet width = 0;\n\tconst eastAsianWidthOptions = {ambiguousAsWide: !ambiguousIsNarrow};\n\n\tfor (const {segment} of segmenter.segment(string)) {\n\t\t// Zero-width / non-printing clusters\n\t\tif (isZeroWidthCluster(segment)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Emoji width logic\n\t\tif (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {\n\t\t\twidth += 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Everything else: EAW of the cluster’s first visible scalar\n\t\tconst codePoint = baseVisible(segment).codePointAt(0);\n\t\twidth += eastAsianWidth(codePoint, eastAsianWidthOptions);\n\n\t\t// Add width for trailing Halfwidth and Fullwidth Forms (e.g., ゙, ゚, ー)\n\t\twidth += trailingHalfwidthWidth(segment, eastAsianWidthOptions);\n\t}\n\n\treturn width;\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;AAaA,MAAM,YAAY,IAAI,KAAK,WAAW;AAGtC,MAAM,wBAAwB;AAG9B,MAAM,0BAA0B;AAGhC,MAAM,gBAAgB;AAGtB,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B;AAElC,SAAS,iCAAiC,SAAS;AAElD,KAAI,QAAQ,SAAS,GACpB,QAAO;AAGR,KAAI,uBAAuB,KAAK,QAAQ,CACvC,QAAO;AAIR,KAAI,QAAQ,SAAS,IAAS,EAAE;EAC/B,MAAM,gBAAgB,QAAQ,MAAM,0BAA0B;AAC9D,SAAO,kBAAkB,QAAQ,cAAc,UAAU;;AAG1D,QAAO;;AAGR,SAAS,YAAY,SAAS;AAC7B,QAAO,QAAQ,QAAQ,yBAAyB,GAAG;;AAGpD,SAAS,mBAAmB,SAAS;AACpC,QAAO,sBAAsB,KAAK,QAAQ;;AAG3C,SAAS,uBAAuB,SAAS,uBAAuB;CAC/D,IAAI,QAAQ;AACZ,KAAI,QAAQ,SAAS,GACpB;OAAK,MAAM,QAAQ,QAAQ,MAAM,EAAE,CAClC,KAAI,QAAQ,OAAY,QAAQ,IAC/B,UAAS,eAAe,KAAK,YAAY,EAAE,EAAE,sBAAsB;;AAKtE,QAAO;;AAGR,SAAwB,YAAY,OAAO,UAAU,EAAE,EAAE;AACxD,KAAI,OAAO,UAAU,YAAY,MAAM,WAAW,EACjD,QAAO;CAGR,MAAM,EACL,oBAAoB,MACpB,uBAAuB,UACpB;CAEJ,IAAI,SAAS;AAGb,KAAI,CAAC,yBAAyB,OAAO,SAAS,OAAS,IAAI,OAAO,SAAS,IAAS,EACnF,UAAS,UAAU,OAAO;AAG3B,KAAI,OAAO,WAAW,EACrB,QAAO;AAIR,KAAI,qBAAqB,KAAK,OAAO,CACpC,QAAO,OAAO;CAGf,IAAI,QAAQ;CACZ,MAAM,wBAAwB,EAAC,iBAAiB,CAAC,mBAAkB;AAEnE,MAAK,MAAM,EAAC,aAAY,UAAU,QAAQ,OAAO,EAAE;AAElD,MAAI,mBAAmB,QAAQ,CAC9B;AAID,MAAI,cAAc,KAAK,QAAQ,IAAI,iCAAiC,QAAQ,EAAE;AAC7E,YAAS;AACT;;EAID,MAAM,YAAY,YAAY,QAAQ,CAAC,YAAY,EAAE;AACrD,WAAS,eAAe,WAAW,sBAAsB;AAGzD,WAAS,uBAAuB,SAAS,sBAAsB;;AAGhE,QAAO"}
@@ -0,0 +1,12 @@
1
+ const require_index = require('../../../ansi-regex@6.2.2/node_modules/ansi-regex/index.cjs');
2
+
3
+ //#region ../../node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.js
4
+ const regex = require_index.default();
5
+ function stripAnsi(string) {
6
+ if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
7
+ if (!string.includes("\x1B") && !string.includes("›")) return string;
8
+ return string.replace(regex, "");
9
+ }
10
+
11
+ //#endregion
12
+ exports.default = stripAnsi;
@@ -0,0 +1,13 @@
1
+ import ansiRegex from "../../../ansi-regex@6.2.2/node_modules/ansi-regex/index.mjs";
2
+
3
+ //#region ../../node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.js
4
+ const regex = ansiRegex();
5
+ function stripAnsi(string) {
6
+ if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
7
+ if (!string.includes("\x1B") && !string.includes("›")) return string;
8
+ return string.replace(regex, "");
9
+ }
10
+
11
+ //#endregion
12
+ export { stripAnsi as default };
13
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../node_modules/.pnpm/strip-ansi@7.2.0/node_modules/strip-ansi/index.js"],"sourcesContent":["import ansiRegex from 'ansi-regex';\n\nconst regex = ansiRegex();\n\nexport default function stripAnsi(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError(`Expected a \\`string\\`, got \\`${typeof string}\\``);\n\t}\n\n\t// Fast path: ANSI codes require ESC (7-bit) or CSI (8-bit) introducer\n\tif (!string.includes('\\u001B') && !string.includes('\\u009B')) {\n\t\treturn string;\n\t}\n\n\t// Even though the regex is global, we don't need to reset the `.lastIndex`\n\t// because unlike `.exec()` and `.test()`, `.replace()` does it automatically\n\t// and doing it manually has a performance penalty.\n\treturn string.replace(regex, '');\n}\n"],"x_google_ignoreList":[0],"mappings":";;;AAEA,MAAM,QAAQ,WAAW;AAEzB,SAAwB,UAAU,QAAQ;AACzC,KAAI,OAAO,WAAW,SACrB,OAAM,IAAI,UAAU,gCAAgC,OAAO,OAAO,IAAI;AAIvE,KAAI,CAAC,OAAO,SAAS,OAAS,IAAI,CAAC,OAAO,SAAS,IAAS,CAC3D,QAAO;AAMR,QAAO,OAAO,QAAQ,OAAO,GAAG"}
@@ -1,15 +1,302 @@
1
- const require_index = require('../../../ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs');
1
+ const require_index = require('../../../strip-ansi@7.2.0/node_modules/strip-ansi/index.cjs');
2
+ const require_index$1 = require('../../../string-width@8.2.0/node_modules/string-width/index.cjs');
3
+ const require_index$2 = require('../../../ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs');
2
4
 
3
5
  //#region ../../node_modules/.pnpm/wrap-ansi@10.0.0/node_modules/wrap-ansi/index.js
6
+ const ANSI_ESCAPE = "\x1B";
7
+ const ANSI_ESCAPE_CSI = "›";
8
+ const ESCAPES = new Set([ANSI_ESCAPE, ANSI_ESCAPE_CSI]);
9
+ const ANSI_ESCAPE_BELL = "\x07";
4
10
  const ANSI_CSI = "[";
5
11
  const ANSI_OSC = "]";
6
12
  const ANSI_SGR_TERMINATOR = "m";
7
13
  const ANSI_SGR_RESET = 0;
14
+ const ANSI_SGR_RESET_FOREGROUND = 39;
15
+ const ANSI_SGR_RESET_BACKGROUND = 49;
16
+ const ANSI_SGR_RESET_UNDERLINE_COLOR = 59;
17
+ const ANSI_SGR_FOREGROUND_EXTENDED = 38;
18
+ const ANSI_SGR_BACKGROUND_EXTENDED = 48;
19
+ const ANSI_SGR_UNDERLINE_COLOR_EXTENDED = 58;
20
+ const ANSI_SGR_COLOR_MODE_256 = 5;
21
+ const ANSI_SGR_COLOR_MODE_RGB = 2;
8
22
  const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
9
23
  const ANSI_ESCAPE_REGEX = new RegExp(`^\\u001B(?:\\${ANSI_CSI}(?<sgr>[0-9;]*)${ANSI_SGR_TERMINATOR}|${ANSI_ESCAPE_LINK}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`);
10
24
  const ANSI_ESCAPE_CSI_REGEX = new RegExp(`^\\u009B(?<sgr>[0-9;]*)${ANSI_SGR_TERMINATOR}`);
11
- const ANSI_SGR_MODIFIER_CLOSE_CODES = new Set(require_index.default.codes.values());
25
+ const ANSI_SGR_MODIFIER_CLOSE_CODES = new Set(require_index$2.default.codes.values());
12
26
  ANSI_SGR_MODIFIER_CLOSE_CODES.delete(ANSI_SGR_RESET);
13
27
  const segmenter = new Intl.Segmenter();
28
+ const getGraphemes = (string) => Array.from(segmenter.segment(string), ({ segment }) => segment);
29
+ const TAB_SIZE = 8;
30
+ const wrapAnsiCode = (code) => `${ANSI_ESCAPE}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
31
+ const wrapAnsiHyperlink = (url) => `${ANSI_ESCAPE}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
32
+ const getSgrTokens = (sgrParameters) => {
33
+ const codes = sgrParameters.split(";").map((sgrParameter) => sgrParameter === "" ? ANSI_SGR_RESET : Number.parseInt(sgrParameter, 10));
34
+ const sgrTokens = [];
35
+ for (let index = 0; index < codes.length; index++) {
36
+ const code = codes[index];
37
+ if (!Number.isFinite(code)) continue;
38
+ if (code === ANSI_SGR_FOREGROUND_EXTENDED || code === ANSI_SGR_BACKGROUND_EXTENDED || code === ANSI_SGR_UNDERLINE_COLOR_EXTENDED) {
39
+ if (index + 1 >= codes.length) break;
40
+ const mode = codes[index + 1];
41
+ if (mode === ANSI_SGR_COLOR_MODE_256 && Number.isFinite(codes[index + 2])) {
42
+ sgrTokens.push([
43
+ code,
44
+ mode,
45
+ codes[index + 2]
46
+ ]);
47
+ index += 2;
48
+ continue;
49
+ }
50
+ const red = codes[index + 2];
51
+ const green = codes[index + 3];
52
+ const blue = codes[index + 4];
53
+ if (mode === ANSI_SGR_COLOR_MODE_RGB && Number.isFinite(red) && Number.isFinite(green) && Number.isFinite(blue)) {
54
+ sgrTokens.push([
55
+ code,
56
+ mode,
57
+ red,
58
+ green,
59
+ blue
60
+ ]);
61
+ index += 4;
62
+ continue;
63
+ }
64
+ break;
65
+ }
66
+ sgrTokens.push([code]);
67
+ }
68
+ return sgrTokens;
69
+ };
70
+ const removeActiveStyle = (activeStyles, family) => {
71
+ const activeStyleIndex = activeStyles.findIndex((activeStyle) => activeStyle.family === family);
72
+ if (activeStyleIndex !== -1) activeStyles.splice(activeStyleIndex, 1);
73
+ };
74
+ const upsertActiveStyle = (activeStyles, nextActiveStyle) => {
75
+ removeActiveStyle(activeStyles, nextActiveStyle.family);
76
+ activeStyles.push(nextActiveStyle);
77
+ };
78
+ const removeModifierStylesByClose = (activeStyles, closeCode) => {
79
+ for (let index = activeStyles.length - 1; index >= 0; index--) {
80
+ const activeStyle = activeStyles[index];
81
+ if (activeStyle.family.startsWith("modifier-") && activeStyle.close === closeCode) activeStyles.splice(index, 1);
82
+ }
83
+ };
84
+ const getColorStyle = (code, sgrToken) => {
85
+ if (code >= 30 && code <= 37 || code >= 90 && code <= 97 || code === ANSI_SGR_FOREGROUND_EXTENDED && sgrToken.length > 1) return {
86
+ family: "foreground",
87
+ open: sgrToken.join(";"),
88
+ close: ANSI_SGR_RESET_FOREGROUND
89
+ };
90
+ if (code >= 40 && code <= 47 || code >= 100 && code <= 107 || code === ANSI_SGR_BACKGROUND_EXTENDED && sgrToken.length > 1) return {
91
+ family: "background",
92
+ open: sgrToken.join(";"),
93
+ close: ANSI_SGR_RESET_BACKGROUND
94
+ };
95
+ if (code === ANSI_SGR_UNDERLINE_COLOR_EXTENDED && sgrToken.length > 1) return {
96
+ family: "underlineColor",
97
+ open: sgrToken.join(";"),
98
+ close: ANSI_SGR_RESET_UNDERLINE_COLOR
99
+ };
100
+ };
101
+ const applySgrResetCode = (code, activeStyles) => {
102
+ if (code === ANSI_SGR_RESET) {
103
+ activeStyles.length = 0;
104
+ return true;
105
+ }
106
+ if (code === ANSI_SGR_RESET_FOREGROUND) {
107
+ removeActiveStyle(activeStyles, "foreground");
108
+ return true;
109
+ }
110
+ if (code === ANSI_SGR_RESET_BACKGROUND) {
111
+ removeActiveStyle(activeStyles, "background");
112
+ return true;
113
+ }
114
+ if (code === ANSI_SGR_RESET_UNDERLINE_COLOR) {
115
+ removeActiveStyle(activeStyles, "underlineColor");
116
+ return true;
117
+ }
118
+ if (ANSI_SGR_MODIFIER_CLOSE_CODES.has(code)) {
119
+ removeModifierStylesByClose(activeStyles, code);
120
+ return true;
121
+ }
122
+ return false;
123
+ };
124
+ const applySgrToken = (sgrToken, activeStyles) => {
125
+ const [code] = sgrToken;
126
+ if (applySgrResetCode(code, activeStyles)) return;
127
+ const colorStyle = getColorStyle(code, sgrToken);
128
+ if (colorStyle) {
129
+ upsertActiveStyle(activeStyles, colorStyle);
130
+ return;
131
+ }
132
+ const close = require_index$2.default.codes.get(code);
133
+ if (close !== void 0 && close !== ANSI_SGR_RESET) upsertActiveStyle(activeStyles, {
134
+ family: `modifier-${code}`,
135
+ open: sgrToken.join(";"),
136
+ close
137
+ });
138
+ };
139
+ const applySgrParameters = (sgrParameters, activeStyles) => {
140
+ for (const sgrToken of getSgrTokens(sgrParameters)) applySgrToken(sgrToken, activeStyles);
141
+ };
142
+ const applySgrResets = (sgrParameters, activeStyles) => {
143
+ for (const sgrToken of getSgrTokens(sgrParameters)) {
144
+ const [code] = sgrToken;
145
+ applySgrResetCode(code, activeStyles);
146
+ }
147
+ };
148
+ const applyLeadingSgrResets = (string, activeStyles) => {
149
+ let remainder = string;
150
+ while (remainder.length > 0) {
151
+ if (remainder.startsWith(ANSI_ESCAPE) && remainder[1] !== "\\") {
152
+ const match = ANSI_ESCAPE_REGEX.exec(remainder);
153
+ if (!match) break;
154
+ if (match.groups.sgr !== void 0) applySgrResets(match.groups.sgr, activeStyles);
155
+ remainder = remainder.slice(match[0].length);
156
+ continue;
157
+ }
158
+ if (remainder.startsWith(ANSI_ESCAPE_CSI)) {
159
+ const match = ANSI_ESCAPE_CSI_REGEX.exec(remainder);
160
+ if (!match || match.groups.sgr === void 0) break;
161
+ applySgrResets(match.groups.sgr, activeStyles);
162
+ remainder = remainder.slice(match[0].length);
163
+ continue;
164
+ }
165
+ break;
166
+ }
167
+ };
168
+ const getClosingSgrSequence = (activeStyles) => [...activeStyles].reverse().map((activeStyle) => wrapAnsiCode(activeStyle.close)).join("");
169
+ const getOpeningSgrSequence = (activeStyles) => activeStyles.map((activeStyle) => wrapAnsiCode(activeStyle.open)).join("");
170
+ const wordLengths = (string) => string.split(" ").map((word) => require_index$1.default(word));
171
+ const wrapWord = (rows, word, columns) => {
172
+ const characters = getGraphemes(word);
173
+ let isInsideEscape = false;
174
+ let isInsideLinkEscape = false;
175
+ let visible = require_index$1.default(require_index.default(rows.at(-1)));
176
+ for (const [index, character] of characters.entries()) {
177
+ const characterLength = require_index$1.default(character);
178
+ if (visible + characterLength <= columns) rows[rows.length - 1] += character;
179
+ else {
180
+ rows.push(character);
181
+ visible = 0;
182
+ }
183
+ if (ESCAPES.has(character) && !(isInsideLinkEscape && character === ANSI_ESCAPE && characters[index + 1] === "\\")) {
184
+ isInsideEscape = true;
185
+ isInsideLinkEscape = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("") === ANSI_ESCAPE_LINK;
186
+ }
187
+ if (isInsideEscape) {
188
+ if (isInsideLinkEscape) {
189
+ if (character === ANSI_ESCAPE_BELL || character === "\\" && index > 0 && characters[index - 1] === ANSI_ESCAPE) {
190
+ isInsideEscape = false;
191
+ isInsideLinkEscape = false;
192
+ }
193
+ } else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
194
+ continue;
195
+ }
196
+ visible += characterLength;
197
+ if (visible === columns && index < characters.length - 1) {
198
+ rows.push("");
199
+ visible = 0;
200
+ }
201
+ }
202
+ if (!visible && rows.at(-1).length > 0 && rows.length > 1) rows[rows.length - 2] += rows.pop();
203
+ };
204
+ const stringVisibleTrimSpacesRight = (string) => {
205
+ const words = string.split(" ");
206
+ let last = words.length;
207
+ while (last > 0) {
208
+ if (require_index$1.default(words[last - 1]) > 0) break;
209
+ last--;
210
+ }
211
+ if (last === words.length) return string;
212
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
213
+ };
214
+ const expandTabs = (line) => {
215
+ if (!line.includes(" ")) return line;
216
+ const segments = line.split(" ");
217
+ let visible = 0;
218
+ let expandedLine = "";
219
+ for (const [index, segment] of segments.entries()) {
220
+ expandedLine += segment;
221
+ visible += require_index$1.default(segment);
222
+ if (index < segments.length - 1) {
223
+ const spaces = TAB_SIZE - visible % TAB_SIZE;
224
+ expandedLine += " ".repeat(spaces);
225
+ visible += spaces;
226
+ }
227
+ }
228
+ return expandedLine;
229
+ };
230
+ const exec = (string, columns, options = {}) => {
231
+ if (options.trim !== false && string.trim() === "") return "";
232
+ let returnValue = "";
233
+ let escapeUrl;
234
+ const activeStyles = [];
235
+ const lengths = wordLengths(string);
236
+ let rows = [""];
237
+ for (const [index, word] of string.split(" ").entries()) {
238
+ if (options.trim !== false) rows[rows.length - 1] = rows.at(-1).trimStart();
239
+ let rowLength = require_index$1.default(rows.at(-1));
240
+ if (index !== 0) {
241
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
242
+ rows.push("");
243
+ rowLength = 0;
244
+ }
245
+ if (rowLength > 0 || options.trim === false) {
246
+ rows[rows.length - 1] += " ";
247
+ rowLength++;
248
+ }
249
+ }
250
+ if (options.hard && options.wordWrap !== false && lengths[index] > columns) {
251
+ const remainingColumns = columns - rowLength;
252
+ const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
253
+ if (Math.floor((lengths[index] - 1) / columns) < breaksStartingThisLine) rows.push("");
254
+ wrapWord(rows, word, columns);
255
+ continue;
256
+ }
257
+ if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
258
+ if (options.wordWrap === false && rowLength < columns) {
259
+ wrapWord(rows, word, columns);
260
+ continue;
261
+ }
262
+ rows.push("");
263
+ }
264
+ if (rowLength + lengths[index] > columns && options.wordWrap === false) {
265
+ wrapWord(rows, word, columns);
266
+ continue;
267
+ }
268
+ rows[rows.length - 1] += word;
269
+ }
270
+ if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
271
+ const preString = rows.join("\n");
272
+ const pre = getGraphemes(preString);
273
+ let preStringIndex = 0;
274
+ for (const [index, character] of pre.entries()) {
275
+ returnValue += character;
276
+ if (character === ANSI_ESCAPE && pre[index + 1] !== "\\") {
277
+ const { groups } = ANSI_ESCAPE_REGEX.exec(preString.slice(preStringIndex)) || { groups: {} };
278
+ if (groups.sgr !== void 0) applySgrParameters(groups.sgr, activeStyles);
279
+ else if (groups.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
280
+ } else if (character === ANSI_ESCAPE_CSI) {
281
+ const { groups } = ANSI_ESCAPE_CSI_REGEX.exec(preString.slice(preStringIndex)) || { groups: {} };
282
+ if (groups.sgr !== void 0) applySgrParameters(groups.sgr, activeStyles);
283
+ }
284
+ if (pre[index + 1] === "\n") {
285
+ if (escapeUrl) returnValue += wrapAnsiHyperlink("");
286
+ returnValue += getClosingSgrSequence(activeStyles);
287
+ } else if (character === "\n") {
288
+ const openingStyles = [...activeStyles];
289
+ applyLeadingSgrResets(preString.slice(preStringIndex + 1), openingStyles);
290
+ returnValue += getOpeningSgrSequence(openingStyles);
291
+ if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
292
+ }
293
+ preStringIndex += character.length;
294
+ }
295
+ return returnValue;
296
+ };
297
+ function wrapAnsi(string, columns, options) {
298
+ return String(string).normalize().replaceAll("\r\n", "\n").split("\n").map((line) => exec(expandTabs(line), columns, options)).join("\n");
299
+ }
14
300
 
15
- //#endregion
301
+ //#endregion
302
+ exports.default = wrapAnsi;