@peteanderson/ansi 0.3.2 → 1.0.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.
Files changed (182) hide show
  1. package/dist/ansi.d.ts +28 -37
  2. package/dist/ansi.d.ts.map +1 -0
  3. package/dist/ansi.js +29 -52
  4. package/dist/ansi.js.map +1 -0
  5. package/dist/caret.d.ts +5 -3
  6. package/dist/caret.d.ts.map +1 -0
  7. package/dist/caret.js +6 -8
  8. package/dist/caret.js.map +1 -0
  9. package/dist/erase.d.ts +5 -1
  10. package/dist/erase.d.ts.map +1 -0
  11. package/dist/erase.js +4 -2
  12. package/dist/erase.js.map +1 -0
  13. package/dist/features/build.d.ts +7 -11
  14. package/dist/features/build.d.ts.map +1 -0
  15. package/dist/features/build.js +12 -25
  16. package/dist/features/build.js.map +1 -0
  17. package/dist/features/detect.d.ts +4 -4
  18. package/dist/features/detect.d.ts.map +1 -0
  19. package/dist/features/detect.js +5 -6
  20. package/dist/features/detect.js.map +1 -0
  21. package/dist/features/features.d.ts +4 -4
  22. package/dist/features/features.d.ts.map +1 -0
  23. package/dist/features/features.js +24 -34
  24. package/dist/features/features.js.map +1 -0
  25. package/dist/features/index.d.ts +2 -2
  26. package/dist/features/index.d.ts.map +1 -0
  27. package/dist/features/index.js +17 -1
  28. package/dist/features/index.js.map +1 -0
  29. package/dist/features/types.d.ts +10 -0
  30. package/dist/features/types.d.ts.map +1 -0
  31. package/dist/features/types.js +3 -0
  32. package/dist/features/types.js.map +1 -0
  33. package/dist/index.d.ts +3 -81
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +23 -1
  36. package/dist/index.js.map +1 -0
  37. package/dist/pad.d.ts +3 -12
  38. package/dist/pad.d.ts.map +1 -0
  39. package/dist/pad.js +8 -14
  40. package/dist/pad.js.map +1 -0
  41. package/dist/patterns.d.ts +4 -3
  42. package/dist/patterns.d.ts.map +1 -0
  43. package/dist/patterns.js +6 -4
  44. package/dist/patterns.js.map +1 -0
  45. package/dist/scroll.d.ts +5 -3
  46. package/dist/scroll.d.ts.map +1 -0
  47. package/dist/scroll.js +6 -6
  48. package/dist/scroll.js.map +1 -0
  49. package/dist/sgr/color/color.d.ts +5 -9
  50. package/dist/sgr/color/color.d.ts.map +1 -0
  51. package/dist/sgr/color/color.js +22 -29
  52. package/dist/sgr/color/color.js.map +1 -0
  53. package/dist/sgr/color/index.d.ts +2 -2
  54. package/dist/sgr/color/index.d.ts.map +1 -0
  55. package/dist/sgr/color/index.js +17 -1
  56. package/dist/sgr/color/index.js.map +1 -0
  57. package/dist/sgr/color/test-rgb.d.ts +3 -0
  58. package/dist/sgr/color/test-rgb.d.ts.map +1 -0
  59. package/dist/sgr/color/test-rgb.js +149 -0
  60. package/dist/sgr/color/test-rgb.js.map +1 -0
  61. package/dist/sgr/color/types.d.ts +30 -0
  62. package/dist/sgr/color/types.d.ts.map +1 -0
  63. package/dist/sgr/color/types.js +3 -0
  64. package/dist/sgr/color/types.js.map +1 -0
  65. package/dist/sgr/color/utils.d.ts +7 -27
  66. package/dist/sgr/color/utils.d.ts.map +1 -0
  67. package/dist/sgr/color/utils.js +17 -32
  68. package/dist/sgr/color/utils.js.map +1 -0
  69. package/dist/sgr/index.d.ts +4 -9
  70. package/dist/sgr/index.d.ts.map +1 -0
  71. package/dist/sgr/index.js +18 -4
  72. package/dist/sgr/index.js.map +1 -0
  73. package/dist/sgr/reset.d.ts +2 -1
  74. package/dist/sgr/reset.d.ts.map +1 -0
  75. package/dist/sgr/reset.js +4 -1
  76. package/dist/sgr/reset.js.map +1 -0
  77. package/dist/sgr/sgr.d.ts +4 -3
  78. package/dist/sgr/sgr.d.ts.map +1 -0
  79. package/dist/sgr/sgr.js +8 -22
  80. package/dist/sgr/sgr.js.map +1 -0
  81. package/dist/sgr/style.d.ts +3 -1
  82. package/dist/sgr/style.d.ts.map +1 -0
  83. package/dist/sgr/style.js +5 -3
  84. package/dist/sgr/style.js.map +1 -0
  85. package/dist/sgr/utils.d.ts +3 -2
  86. package/dist/sgr/utils.d.ts.map +1 -0
  87. package/dist/sgr/utils.js +3 -3
  88. package/dist/sgr/utils.js.map +1 -0
  89. package/dist/simplify/atom.d.ts +4 -3
  90. package/dist/simplify/atom.d.ts.map +1 -0
  91. package/dist/simplify/atom.js +12 -9
  92. package/dist/simplify/atom.js.map +1 -0
  93. package/dist/simplify/index.d.ts +2 -2
  94. package/dist/simplify/index.d.ts.map +1 -0
  95. package/dist/simplify/index.js +17 -1
  96. package/dist/simplify/index.js.map +1 -0
  97. package/dist/simplify/lookup.d.ts +3 -5
  98. package/dist/simplify/lookup.d.ts.map +1 -0
  99. package/dist/simplify/lookup.js +9 -13
  100. package/dist/simplify/lookup.js.map +1 -0
  101. package/dist/simplify/simplify.d.ts +2 -1
  102. package/dist/simplify/simplify.d.ts.map +1 -0
  103. package/dist/simplify/simplify.js +7 -7
  104. package/dist/simplify/simplify.js.map +1 -0
  105. package/dist/simplify/state.d.ts +3 -8
  106. package/dist/simplify/state.d.ts.map +1 -0
  107. package/dist/simplify/state.js +9 -13
  108. package/dist/simplify/state.js.map +1 -0
  109. package/dist/simplify/test.d.ts +2 -0
  110. package/dist/simplify/test.d.ts.map +1 -0
  111. package/dist/simplify/test.js +64 -0
  112. package/dist/simplify/test.js.map +1 -0
  113. package/dist/simplify/types.d.ts +9 -0
  114. package/dist/simplify/types.d.ts.map +1 -0
  115. package/dist/simplify/types.js +3 -0
  116. package/dist/simplify/types.js.map +1 -0
  117. package/dist/simplify/utils.d.ts +3 -2
  118. package/dist/simplify/utils.d.ts.map +1 -0
  119. package/dist/simplify/utils.js +4 -3
  120. package/dist/simplify/utils.js.map +1 -0
  121. package/dist/slice.d.ts +21 -1
  122. package/dist/slice.d.ts.map +1 -0
  123. package/dist/slice.js +10 -22
  124. package/dist/slice.js.map +1 -0
  125. package/dist/strip.d.ts +4 -15
  126. package/dist/strip.d.ts.map +1 -0
  127. package/dist/strip.js +10 -17
  128. package/dist/strip.js.map +1 -0
  129. package/dist/terminal.d.ts +5 -1
  130. package/dist/terminal.d.ts.map +1 -0
  131. package/dist/terminal.js +4 -2
  132. package/dist/terminal.js.map +1 -0
  133. package/package.json +9 -22
  134. package/src/ansi.ts +71 -0
  135. package/src/{caret.js → caret.ts} +9 -15
  136. package/src/{erase.js → erase.ts} +7 -10
  137. package/src/features/build.ts +52 -0
  138. package/src/features/detect.ts +33 -0
  139. package/src/features/features.ts +48 -0
  140. package/src/features/index.ts +1 -0
  141. package/src/features/{types.d.ts → types.ts} +1 -1
  142. package/src/index.ts +2 -0
  143. package/src/pad.ts +7 -0
  144. package/src/{patterns.js → patterns.ts} +3 -5
  145. package/src/scroll.ts +13 -0
  146. package/src/sgr/color/{color.js → color.ts} +26 -35
  147. package/src/sgr/color/index.ts +1 -0
  148. package/src/sgr/color/{types.d.ts → types.ts} +6 -2
  149. package/src/sgr/color/utils.ts +58 -0
  150. package/src/sgr/index.ts +3 -0
  151. package/src/sgr/reset.ts +1 -0
  152. package/src/sgr/sgr.ts +68 -0
  153. package/src/sgr/{style.js → style.ts} +3 -5
  154. package/src/sgr/{utils.js → utils.ts} +3 -6
  155. package/src/simplify/{atom.js → atom.ts} +11 -13
  156. package/src/simplify/index.ts +1 -0
  157. package/src/simplify/{lookup.js → lookup.ts} +5 -14
  158. package/src/simplify/{simplify.js → simplify.ts} +4 -10
  159. package/src/simplify/state.ts +63 -0
  160. package/src/simplify/{types.d.ts → types.ts} +5 -5
  161. package/src/simplify/{utils.js → utils.ts} +4 -10
  162. package/src/{slice.js → slice.ts} +12 -26
  163. package/src/strip.ts +5 -0
  164. package/src/{terminal.js → terminal.ts} +4 -7
  165. package/LICENSE +0 -7
  166. package/README.md +0 -174
  167. package/src/ansi.js +0 -70
  168. package/src/features/build.js +0 -68
  169. package/src/features/detect.js +0 -40
  170. package/src/features/features.js +0 -53
  171. package/src/features/index.js +0 -1
  172. package/src/index.js +0 -1
  173. package/src/pad.js +0 -21
  174. package/src/scroll.js +0 -18
  175. package/src/sgr/color/index.js +0 -1
  176. package/src/sgr/color/utils.js +0 -81
  177. package/src/sgr/index.js +0 -5
  178. package/src/sgr/reset.js +0 -3
  179. package/src/sgr/sgr.js +0 -77
  180. package/src/simplify/index.js +0 -1
  181. package/src/simplify/state.js +0 -73
  182. package/src/strip.js +0 -23
@@ -1,27 +1,7 @@
1
- export type Code = import("../sgr").Code;
2
- export function rgbToX256(r: number, g: number, b: number): number;
3
- export function x256ToRgb(code: number): [number, number, number];
4
- export function rgbToX16(r: number, g: number, b: number): number;
5
- export function rgbToX8(r: number, g: number, b: number): number;
6
- /**
7
- * @overload
8
- * @param {number} x
9
- * @returns {number}
10
- * @overload
11
- * @param {number} r
12
- * @param {number} g
13
- * @param {number} b
14
- * @returns {[number, number, number]}
15
- */
16
- export function clip(x: number): number;
17
- /**
18
- * @overload
19
- * @param {number} x
20
- * @returns {number}
21
- * @overload
22
- * @param {number} r
23
- * @param {number} g
24
- * @param {number} b
25
- * @returns {[number, number, number]}
26
- */
27
- export function clip(r: number, g: number, b: number): [number, number, number];
1
+ export declare function rgbToX256(r: number, g: number, b: number): number;
2
+ export declare function x256ToRgb(code: number): [number, number, number];
3
+ export declare function rgbToX16(r: number, g: number, b: number): number;
4
+ export declare function rgbToX8(r: number, g: number, b: number): number;
5
+ export declare function clip(x: number): number;
6
+ export declare function clip(r: number, g: number, b: number): [number, number, number];
7
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/sgr/color/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAUjE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAWhE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYhE;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAM/D;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;AACxC,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -1,21 +1,20 @@
1
1
  "use strict";
2
- /** @typedef {import("../sgr").Code} Code */
3
- /** @type {(r: number, g: number, b: number) => number} */
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rgbToX256 = rgbToX256;
4
+ exports.x256ToRgb = x256ToRgb;
5
+ exports.rgbToX16 = rgbToX16;
6
+ exports.rgbToX8 = rgbToX8;
7
+ exports.clip = clip;
4
8
  function rgbToX256(r, g, b) {
5
- if (r === g && g === b) {
6
- // grayscale
9
+ if (r === g && g === b)
7
10
  return 232 + Math.floor(r * 24 / 256);
8
- }
9
- // 6x6x6 color cube
10
11
  return (16 +
11
12
  Math.floor(r * 6 / 256) * 36 +
12
13
  Math.floor(g * 6 / 256) * 6 +
13
14
  Math.floor(b * 6 / 256));
14
15
  }
15
- /** @type {(code: number) => [number, number, number]} */
16
16
  function x256ToRgb(code) {
17
17
  if (code >= 232) {
18
- // grayscale
19
18
  const gray = Math.round((code - 232) * 255 / 24);
20
19
  return [gray, gray, gray];
21
20
  }
@@ -25,43 +24,29 @@ function x256ToRgb(code) {
25
24
  const b = (code % 6) * 51;
26
25
  return [r, g, b];
27
26
  }
28
- /** @type {(r: number, g: number, b: number) => number} */
29
27
  function rgbToX16(r, g, b) {
30
- // First calculate it as a 4x4x4 cube.
31
28
  r = Math.min(2, Math.floor(r / 85));
32
29
  g = Math.min(2, Math.floor(g / 85));
33
30
  b = Math.min(2, Math.floor(b / 85));
34
- // Which channels are "on" determines the hue (ANSI color index 0–7).
35
31
  const index = (r ? 1 : 0) | (g ? 2 : 0) | (b ? 4 : 0);
36
- // The bright bit is derived from the max channel level across all three.
37
32
  const twos = (r === 2 ? 1 : 0) + (g === 2 ? 1 : 0) + (b === 2 ? 1 : 0);
38
33
  const ones = (r === 1 ? 1 : 0) + (g === 1 ? 1 : 0) + (b === 1 ? 1 : 0);
39
34
  const bright = twos > 0 && twos >= ones;
40
- // Return value uses the SGR offset scheme: 0–7 for normal, 60–67 for bright.
41
35
  return index + (bright ? 60 : 0);
42
36
  }
43
- /** @type {(r: number, g: number, b: number) => number} */
44
37
  function rgbToX8(r, g, b) {
45
38
  r = r >= 128 ? 1 : 0;
46
39
  g = g >= 128 ? 1 : 0;
47
40
  b = b >= 128 ? 1 : 0;
48
41
  return (r ? 1 : 0) | (g ? 2 : 0) | (b ? 4 : 0);
49
42
  }
50
- /**
51
- * @overload
52
- * @param {number} x
53
- * @returns {number}
54
- * @overload
55
- * @param {number} r
56
- * @param {number} g
57
- * @param {number} b
58
- * @returns {[number, number, number]}
59
- */ /** @param {[number] | [number, number, number]} args */
60
- const clip = (...args) => args.length === 1 ?
61
- Math.max(0, Math.min(255, Math.floor(args[0]))) :
62
- [
63
- Math.max(0, Math.min(255, Math.floor(args[0]))),
64
- Math.max(0, Math.min(255, Math.floor(args[1]))),
65
- Math.max(0, Math.min(255, Math.floor(args[2]))),
66
- ];
67
- module.exports = { rgbToX256, x256ToRgb, rgbToX16, rgbToX8, clip };
43
+ function clip(...args) {
44
+ return args.length === 1
45
+ ? Math.max(0, Math.min(255, Math.floor(args[0])))
46
+ : [
47
+ Math.max(0, Math.min(255, Math.floor(args[0]))),
48
+ Math.max(0, Math.min(255, Math.floor(args[1]))),
49
+ Math.max(0, Math.min(255, Math.floor(args[2]))),
50
+ ];
51
+ }
52
+ //# sourceMappingURL=utils.js.map
@@ -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AC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/C,CAAC;AACJ,CAAC"}
@@ -1,9 +1,4 @@
1
- declare const _exports: {
2
- makeColor: (colorDepth: ColorDepth) => {
3
- fg: Channel;
4
- bg: Channel;
5
- };
6
- makeStyle: typeof import("./style").makeStyle;
7
- makeReset: (enabled?: boolean) => "" | "\u001B[0m";
8
- };
9
- export = _exports;
1
+ export * from "./reset";
2
+ export * from "./style";
3
+ export * from "./color";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sgr/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/sgr/index.js CHANGED
@@ -1,6 +1,20 @@
1
1
  "use strict";
2
- module.exports = {
3
- ...require("./reset"),
4
- ...require("./style"),
5
- ...require("./color"),
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6
15
  };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./reset"), exports);
18
+ __exportStar(require("./style"), exports);
19
+ __exportStar(require("./color"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sgr/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,0CAAwB;AACxB,0CAAwB"}
@@ -1 +1,2 @@
1
- export function makeReset(enabled?: boolean): "" | "\u001B[0m";
1
+ export declare const makeReset: (enabled?: boolean) => string;
2
+ //# sourceMappingURL=reset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../src/sgr/reset.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,iBAAc,KAAG,MAAkC,CAAC"}
package/dist/sgr/reset.js CHANGED
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeReset = void 0;
2
4
  const makeReset = (enabled = true) => enabled ? "\x1b[0m" : "";
3
- module.exports = { makeReset };
5
+ exports.makeReset = makeReset;
6
+ //# sourceMappingURL=reset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.js","sourceRoot":"","sources":["../../src/sgr/reset.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,OAAO,GAAG,IAAI,EAAU,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;AAAjE,QAAA,SAAS,aAAwD"}
package/dist/sgr/sgr.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type Code = number | number[];
2
- export type SGR = {
2
+ export interface SGR {
3
3
  (text: string): string;
4
4
  open: string;
5
5
  close: string;
@@ -8,7 +8,8 @@ export type SGR = {
8
8
  close: Code;
9
9
  };
10
10
  combine: (...styles: SGR[]) => SGR;
11
- };
12
- export function makeSGR(enabled?: boolean): typeof sgr;
11
+ }
13
12
  declare function sgr(open: Code, close: Code, reset?: boolean): SGR;
13
+ export declare const makeSGR: (enabled?: boolean) => typeof sgr;
14
14
  export {};
15
+ //# sourceMappingURL=sgr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sgr.d.ts","sourceRoot":"","sources":["../../src/sgr/sgr.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAErC,MAAM,WAAW,GAAG;IACnB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,EAAM,MAAM,CAAC;IACjB,KAAK,EAAK,MAAM,CAAC;IACjB,KAAK,EAAK;QAAC,IAAI,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,IAAI,CAAA;KAAC,CAAC;IACpC,OAAO,EAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;CACpC;AAoBD,iBAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,UAAQ,GAAG,GAAG,CAwBxD;AAeD,eAAO,MAAM,OAAO,GAAI,iBAAc,KAAG,OAAO,GAA+B,CAAC"}
package/dist/sgr/sgr.js CHANGED
@@ -1,15 +1,6 @@
1
1
  "use strict";
2
- /**
3
- @typedef {number | number[]} Code
4
- @typedef {{
5
- (text: string): string;
6
- open : string;
7
- close : string;
8
- codes : {open: Code, close: Code};
9
- combine : (...styles: SGR[]) => SGR;
10
- }} SGR
11
- */
12
- /** @type {(code: Code, codes: Code[]) => Code} */
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeSGR = void 0;
13
4
  function combine(code, codes) {
14
5
  if (!codes.length)
15
6
  return code;
@@ -22,9 +13,7 @@ function combine(code, codes) {
22
13
  }
23
14
  return rtn;
24
15
  }
25
- /** @type {(code: Code) => string | number} */
26
- const codeSequence = code => Array.isArray(code) ? code.join(';') : code;
27
- /** @type {(open: Code, close: Code, reset?: boolean) => SGR} */
16
+ const codeSequence = (code) => Array.isArray(code) ? code.join(";") : code;
28
17
  function sgr(open, close, reset = false) {
29
18
  const openCode = codeSequence(open);
30
19
  const closeCode = codeSequence(close);
@@ -33,25 +22,22 @@ function sgr(open, close, reset = false) {
33
22
  const reopenCode = reset ? `${closeCode};${openCode}` : openCode;
34
23
  const rxClose = new RegExp(`(?<start>\\x1b\\[(?:\\d+;)*)${closeCode}(?<end>(?:;\\d+)*m)`, "g");
35
24
  const replace = `$<start>${reopenCode}$<end>`;
36
- /** @type {(text: string) => string} */
37
- const func = s => openSequence + s.replace(rxClose, replace) + closeSequence;
25
+ const func = (s) => s ? openSequence + s.replace(rxClose, replace) + closeSequence : s;
38
26
  return Object.assign(func, {
39
27
  codes: { open, close },
40
28
  open: openSequence,
41
29
  close: closeSequence,
42
- /** @type {(...styles: SGR[]) => SGR} */
43
30
  combine: (...styles) => sgr(combine(open, styles.map(s => s.codes.open)), combine(close, styles.map(s => s.codes.close))),
44
31
  });
45
32
  }
46
- ;
47
- /** @type {SGR} */
48
- const disabledSGR = Object.assign(/** @type {(text: string) => string} */ /** @type {(text: string) => string} */ s => s, {
33
+ let disabledSGR = null;
34
+ disabledSGR = Object.assign((s) => s, {
49
35
  codes: { open: 0, close: 0 },
50
36
  open: "",
51
37
  close: "",
52
38
  combine: () => disabledSGR,
53
39
  });
54
- /** @type {typeof sgr} */
55
40
  const disabled = () => disabledSGR;
56
41
  const makeSGR = (enabled = true) => enabled ? sgr : disabled;
57
- module.exports = { makeSGR };
42
+ exports.makeSGR = makeSGR;
43
+ //# sourceMappingURL=sgr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sgr.js","sourceRoot":"","sources":["../../src/sgr/sgr.ts"],"names":[],"mappings":";;;AAUA,SAAS,OAAO,CAAC,IAAU,EAAE,KAAa;IACzC,IAAI,CAAC,KAAK,CAAC,MAAM;QAChB,OAAO,IAAI,CAAC;IAEb,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,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F,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1B,KAAK,EAAK,EAAC,IAAI,EAAE,KAAK,EAAC;QACvB,IAAI,EAAM,YAAY;QACtB,KAAK,EAAK,aAAa;QACvB,OAAO,EAAG,CAAC,GAAG,MAAa,EAAE,EAAE,CAAC,GAAG,CAClC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAC5C,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAC9C;KACD,CAAC,CAAC;AACJ,CAAC;AAED,IAAI,WAAW,GAAG,IAAsB,CAAC;AACzC,WAAW,GAAG,MAAM,CAAC,MAAM,CAC1B,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,EAChB;IACC,KAAK,EAAK,EAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAC;IAC7B,IAAI,EAAM,EAAE;IACZ,KAAK,EAAK,EAAE;IACZ,OAAO,EAAG,GAAQ,EAAE,CAAC,WAAW;CAChC,CACD,CAAC;AAEF,MAAM,QAAQ,GAAG,GAAQ,EAAE,CAAC,WAAW,CAAC;AAEjC,MAAM,OAAO,GAAG,CAAC,OAAO,GAAG,IAAI,EAAc,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;AAAnE,QAAA,OAAO,WAA4D"}
@@ -1,4 +1,4 @@
1
- export function makeStyle(enabled?: boolean): {
1
+ export declare function makeStyle(enabled?: boolean): {
2
2
  bold: import("./sgr").SGR;
3
3
  dim: import("./sgr").SGR;
4
4
  italic: import("./sgr").SGR;
@@ -11,3 +11,5 @@ export function makeStyle(enabled?: boolean): {
11
11
  encircle: import("./sgr").SGR;
12
12
  overline: import("./sgr").SGR;
13
13
  };
14
+ export type Style = ReturnType<typeof makeStyle>;
15
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/sgr/style.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,OAAO,UAAO;;;;;;;;;;;;EAgBvC;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC"}
package/dist/sgr/style.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
- const { makeSGR } = require("./sgr");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeStyle = makeStyle;
4
+ const sgr_1 = require("./sgr");
3
5
  function makeStyle(enabled = true) {
4
- const sgr = makeSGR(enabled);
6
+ const sgr = (0, sgr_1.makeSGR)(enabled);
5
7
  return {
6
8
  bold: sgr(1, 22, true),
7
9
  dim: sgr(2, 22, true),
@@ -16,4 +18,4 @@ function makeStyle(enabled = true) {
16
18
  overline: sgr(53, 55),
17
19
  };
18
20
  }
19
- module.exports = { makeStyle };
21
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/sgr/style.ts"],"names":[],"mappings":";;AAEA,8BAgBC;AAlBD,+BAA8B;AAE9B,SAAgB,SAAS,CAAC,OAAO,GAAG,IAAI;IACvC,MAAM,GAAG,GAAG,IAAA,aAAO,EAAC,OAAO,CAAC,CAAC;IAE7B,OAAO;QACN,IAAI,EAAc,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC;QAClC,GAAG,EAAe,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC;QAClC,MAAM,EAAY,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5B,SAAS,EAAS,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5B,OAAO,EAAW,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,EAAY,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5B,aAAa,EAAK,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5B,eAAe,EAAG,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;QAC7B,KAAK,EAAa,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;QAC7B,QAAQ,EAAU,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;QAC7B,QAAQ,EAAU,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;KAC7B,CAAC;AACH,CAAC"}
@@ -1,2 +1,3 @@
1
- export type Code = number | number[];
2
- export function combine(code: Code, codes: Code[]): Code;
1
+ import type { Code } from "./sgr";
2
+ export declare function combine(code: Code, codes: Code[]): Code;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sgr/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,OAAO,CAAC;AAEhC,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAcvD"}
package/dist/sgr/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- /** @typedef {number | number[]} Code */
3
- /** @type {(code: Code, codes: Code[]) => Code} */
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.combine = combine;
4
4
  function combine(code, codes) {
5
5
  if (!codes.length)
6
6
  return code;
@@ -13,4 +13,4 @@ function combine(code, codes) {
13
13
  }
14
14
  return rtn;
15
15
  }
16
- module.exports = { combine };
16
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/sgr/utils.ts"],"names":[],"mappings":";;AAEA,0BAcC;AAdD,SAAgB,OAAO,CAAC,IAAU,EAAE,KAAa;IAChD,IAAI,CAAC,KAAK,CAAC,MAAM;QAChB,OAAO,IAAI,CAAC;IAEb,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YACnB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;YAEf,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -1,3 +1,4 @@
1
- export type BuildAtom = import("./types").BuildAtom;
2
- export function buildExtendedColorAtom(attribute: import("./types").Attribute, codes: number[], index: number, state: import("./types").AttributeMap): import("./types").Atom;
3
- export function buildIntensityAtom(attribute: import("./types").Attribute, codes: number[], index: number, state: import("./types").AttributeMap): import("./types").Atom;
1
+ import type { BuildAtom } from "./types";
2
+ export declare const buildExtendedColorAtom: BuildAtom;
3
+ export declare const buildIntensityAtom: BuildAtom;
4
+ //# sourceMappingURL=atom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom.d.ts","sourceRoot":"","sources":["../../src/simplify/atom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,SAAS,EAAC,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,sBAAsB,EAAE,SAapC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAchC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- /** @typedef {import("./types").BuildAtom} BuildAtom */
3
- /** @type {BuildAtom} */
4
- function buildExtendedColorAtom(attribute, codes, index) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildIntensityAtom = exports.buildExtendedColorAtom = void 0;
4
+ const buildExtendedColorAtom = (attribute, codes, index) => {
5
5
  switch (codes[index + 1]) {
6
6
  case 2:
7
7
  if (index + 5 >= codes.length)
@@ -14,15 +14,18 @@ function buildExtendedColorAtom(attribute, codes, index) {
14
14
  default:
15
15
  return { attribute, code: codes.slice(index, index + 2), skip: 1 };
16
16
  }
17
- }
18
- /** @type {BuildAtom} */
19
- function buildIntensityAtom(attribute, codes, index, state) {
17
+ };
18
+ exports.buildExtendedColorAtom = buildExtendedColorAtom;
19
+ const buildIntensityAtom = (attribute, codes, index, state) => {
20
20
  const code = codes[index];
21
21
  if (code === 22)
22
22
  return { attribute, code: [code] };
23
23
  const current = state.get("intensity");
24
- if (!current || current.length == 1 && current[0] === code || current[0] === 22)
24
+ if (!current ||
25
+ current[0] === 22 ||
26
+ current.length === 1 && current[0] === code)
25
27
  return { attribute, code: [code] };
26
28
  return { attribute, code: [1, 2] };
27
- }
28
- module.exports = { buildExtendedColorAtom, buildIntensityAtom };
29
+ };
30
+ exports.buildIntensityAtom = buildIntensityAtom;
31
+ //# sourceMappingURL=atom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom.js","sourceRoot":"","sources":["../../src/simplify/atom.ts"],"names":[],"mappings":";;;AAEO,MAAM,sBAAsB,GAAc,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IAC5E,QAAQ,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1B,KAAK,CAAC;YACL,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM;gBAC5B,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,EAAC,CAAC;YAC9E,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC;QAClE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2 @@
1
- declare const _exports: typeof import("./simplify");
2
- export = _exports;
1
+ export * from "./simplify";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simplify/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -1,2 +1,18 @@
1
1
  "use strict";
2
- module.exports = require("./simplify");
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./simplify"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simplify/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
@@ -1,5 +1,3 @@
1
- export type Atom = import("./types").Atom;
2
- export type Attribute = import("./types").Attribute;
3
- export type AttributeMap = import("./types").AttributeMap;
4
- export type BuildAtom = import("./types").BuildAtom;
5
- export function lookUpAtom(codes: number[], index: number, state: AttributeMap): Atom;
1
+ import type { Atom, AttributeMap } from "./types";
2
+ export declare function lookUpAtom(codes: number[], index: number, state: AttributeMap): Atom;
3
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/simplify/lookup.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAa,YAAY,EAAY,MAAM,SAAS,CAAC;AA6DtE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAapF"}
@@ -1,21 +1,18 @@
1
1
  "use strict";
2
- const { buildExtendedColorAtom, buildIntensityAtom } = require("./atom");
3
- /** @typedef {import("./types").Atom} Atom */
4
- /** @typedef {import("./types").Attribute} Attribute */
5
- /** @typedef {import("./types").AttributeMap} AttributeMap */
6
- /** @typedef {import("./types").BuildAtom} BuildAtom */
7
- /** @type {Record<number, [attribute: Attribute, buildAtom?: BuildAtom]>} */
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lookUpAtom = lookUpAtom;
4
+ const atom_1 = require("./atom");
8
5
  const codeMap = {
9
6
  0: ["reset"],
10
- 1: ["intensity", buildIntensityAtom],
11
- 2: ["intensity", buildIntensityAtom],
7
+ 1: ["intensity", atom_1.buildIntensityAtom],
8
+ 2: ["intensity", atom_1.buildIntensityAtom],
12
9
  3: ["italic"],
13
10
  4: ["underline"],
14
11
  7: ["inverse"],
15
12
  8: ["hidden"],
16
13
  9: ["strikethrough"],
17
14
  21: ["underline"],
18
- 22: ["intensity", buildIntensityAtom],
15
+ 22: ["intensity", atom_1.buildIntensityAtom],
19
16
  23: ["italic"],
20
17
  24: ["underline"],
21
18
  27: ["inverse"],
@@ -29,7 +26,7 @@ const codeMap = {
29
26
  35: ["fg"],
30
27
  36: ["fg"],
31
28
  37: ["fg"],
32
- 38: ["fg", buildExtendedColorAtom],
29
+ 38: ["fg", atom_1.buildExtendedColorAtom],
33
30
  39: ["fg"],
34
31
  40: ["bg"],
35
32
  41: ["bg"],
@@ -39,7 +36,7 @@ const codeMap = {
39
36
  45: ["bg"],
40
37
  46: ["bg"],
41
38
  47: ["bg"],
42
- 48: ["bg", buildExtendedColorAtom],
39
+ 48: ["bg", atom_1.buildExtendedColorAtom],
43
40
  49: ["bg"],
44
41
  51: ["frame"],
45
42
  52: ["frame"],
@@ -63,7 +60,6 @@ const codeMap = {
63
60
  106: ["bg"],
64
61
  107: ["bg"],
65
62
  };
66
- /** @type {(codes: number[], index: number, state: AttributeMap) => Atom} */
67
63
  function lookUpAtom(codes, index, state) {
68
64
  const code = codes[index];
69
65
  const entry = codeMap[code];
@@ -74,4 +70,4 @@ function lookUpAtom(codes, index, state) {
74
70
  return buildAtom(attribute, codes, index, state);
75
71
  return { attribute, code: [code] };
76
72
  }
77
- module.exports = { lookUpAtom };
73
+ //# sourceMappingURL=lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/simplify/lookup.ts"],"names":[],"mappings":";;AA+DA,gCAaC;AA5ED,iCAAkE;AAIlE,MAAM,OAAO,GAAkE;IAC9E,CAAC,EAAK,CAAC,OAAO,CAAC;IACf,CAAC,EAAK,CAAC,WAAW,EAAE,yBAAkB,CAAC;IACvC,CAAC,EAAK,CAAC,WAAW,EAAE,yBAAkB,CAAC;IACvC,CAAC,EAAK,CAAC,QAAQ,CAAC;IAChB,CAAC,EAAK,CAAC,WAAW,CAAC;IACnB,CAAC,EAAK,CAAC,SAAS,CAAC;IACjB,CAAC,EAAK,CAAC,QAAQ,CAAC;IAChB,CAAC,EAAK,CAAC,eAAe,CAAC;IACvB,EAAE,EAAI,CAAC,WAAW,CAAC;IACnB,EAAE,EAAI,CAAC,WAAW,EAAE,yBAAkB,CAAC;IACvC,EAAE,EAAI,CAAC,QAAQ,CAAC;IAChB,EAAE,EAAI,CAAC,WAAW,CAAC;IACnB,EAAE,EAAI,CAAC,SAAS,CAAC;IACjB,EAAE,EAAI,CAAC,QAAQ,CAAC;IAChB,EAAE,EAAI,CAAC,eAAe,CAAC;IACvB,EAAE,EAAI,CAAC,IAAI,CAAC;IACZ,EAAE,EAAI,CAAC,IAAI,CAAC;IAC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CAAC,IAAI,CAAC;IACZ,GAAG,EAAG,CAAC,IAAI,CAAC;IACZ,GAAG,EAAG,CAAC,IAAI,CAAC;IACZ,GAAG,EAAG,CAAC,IAAI,CAAC;IACZ,GAAG,EAAG,CAAC,IAAI,CAAC;IACZ,GAAG,EAAG,CAAC,IAAI,CAAC;CACZ,CAAC;AAEF,SAAgB,UAAU,CAAC,KAAe,EAAE,KAAa,EAAE,KAAmB;IAC7E,MAAM,IAAI,GAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,IAAI,CAAC,KAAK;QACT,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAC,CAAC;IAExC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IAErC,IAAI,SAAS;QACZ,OAAO,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAElD,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAC,CAAC;AAClC,CAAC"}
@@ -1 +1,2 @@
1
- export function simplify(text: string): string;
1
+ export declare function simplify(text: string): string;
2
+ //# sourceMappingURL=simplify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simplify.d.ts","sourceRoot":"","sources":["../../src/simplify/simplify.ts"],"names":[],"mappings":"AAGA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuB7C"}
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
- const { rxSGR } = require("../patterns");
3
- const { State } = require("./state");
4
- /** @type {(text: string) => string} */
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.simplify = simplify;
4
+ const patterns_1 = require("../patterns");
5
+ const state_1 = require("./state");
5
6
  function simplify(text) {
6
7
  // `.split` doesn't modify `lastIndex`, so no clone is necessary here.
7
- const parts = text.split(rxSGR);
8
- const state = new State();
8
+ const parts = text.split(patterns_1.rxSGR);
9
+ const state = new state_1.State();
9
10
  let result = parts[0];
10
11
  for (let i = 1; i < parts.length;) {
11
12
  let codes = parts[i++].split(";").map(Number);
12
13
  let chunk = parts[i++];
13
14
  while (!chunk && i < parts.length) {
14
- // Merge consecutive SGR sequences.
15
15
  codes.push(...parts[i++].split(";").map(Number));
16
16
  chunk = parts[i++];
17
17
  }
@@ -22,4 +22,4 @@ function simplify(text) {
22
22
  }
23
23
  return result;
24
24
  }
25
- module.exports = { simplify };
25
+ //# sourceMappingURL=simplify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simplify.js","sourceRoot":"","sources":["../../src/simplify/simplify.ts"],"names":[],"mappings":";;AAGA,4BAuBC;AA1BD,0CAAkC;AAClC,mCAA8B;AAE9B,SAAgB,QAAQ,CAAC,IAAY;IACpC,sEAAsE;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAK,CAAC,CAAC;IAEhC,MAAM,KAAK,GAAI,IAAI,aAAK,EAAE,CAAC;IAC3B,IAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAI,CAAC;QACpC,IAAI,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QAEvB,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YACnC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;YACjD,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;QAED,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,KAAK,CAAC,MAAM;YACf,MAAM,IAAI,QAAQ,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1,10 +1,5 @@
1
- export type Attribute = import("./types").Attribute;
2
- export type AttributeMap = import("./types").AttributeMap;
3
- /** @type {AttributeMap} */
4
- export class State extends Map<any, any> {
5
- constructor();
6
- constructor(entries?: readonly (readonly [any, any])[] | null | undefined);
7
- constructor();
8
- constructor(iterable?: Iterable<readonly [any, any]> | null | undefined);
1
+ import type { Attribute, AttributeMap } from "./types";
2
+ export declare class State extends Map<Attribute, number[]> implements AttributeMap {
9
3
  update(codes: number[]): number[];
10
4
  }
5
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/simplify/state.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,SAAS,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AAerD,qBAAa,KAAM,SAAQ,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,CAAE,YAAW,YAAY;IAC1E,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;CA2CjC"}