@peteanderson/ansi 0.3.3 → 1.0.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.
Files changed (169) 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 +17 -28
  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 -4
  38. package/dist/pad.d.ts.map +1 -0
  39. package/dist/pad.js +8 -6
  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/types.d.ts +30 -0
  58. package/dist/sgr/color/types.d.ts.map +1 -0
  59. package/dist/sgr/color/types.js +3 -0
  60. package/dist/sgr/color/types.js.map +1 -0
  61. package/dist/sgr/color/utils.d.ts +7 -27
  62. package/dist/sgr/color/utils.d.ts.map +1 -0
  63. package/dist/sgr/color/utils.js +16 -23
  64. package/dist/sgr/color/utils.js.map +1 -0
  65. package/dist/sgr/index.d.ts +4 -9
  66. package/dist/sgr/index.d.ts.map +1 -0
  67. package/dist/sgr/index.js +18 -4
  68. package/dist/sgr/index.js.map +1 -0
  69. package/dist/sgr/reset.d.ts +2 -1
  70. package/dist/sgr/reset.d.ts.map +1 -0
  71. package/dist/sgr/reset.js +4 -1
  72. package/dist/sgr/reset.js.map +1 -0
  73. package/dist/sgr/sgr.d.ts +4 -3
  74. package/dist/sgr/sgr.d.ts.map +1 -0
  75. package/dist/sgr/sgr.js +14 -27
  76. package/dist/sgr/sgr.js.map +1 -0
  77. package/dist/sgr/style.d.ts +3 -1
  78. package/dist/sgr/style.d.ts.map +1 -0
  79. package/dist/sgr/style.js +5 -3
  80. package/dist/sgr/style.js.map +1 -0
  81. package/dist/sgr/utils.d.ts +3 -2
  82. package/dist/sgr/utils.d.ts.map +1 -0
  83. package/dist/sgr/utils.js +3 -3
  84. package/dist/sgr/utils.js.map +1 -0
  85. package/dist/simplify/atom.d.ts +4 -3
  86. package/dist/simplify/atom.d.ts.map +1 -0
  87. package/dist/simplify/atom.js +9 -8
  88. package/dist/simplify/atom.js.map +1 -0
  89. package/dist/simplify/index.d.ts +2 -2
  90. package/dist/simplify/index.d.ts.map +1 -0
  91. package/dist/simplify/index.js +17 -1
  92. package/dist/simplify/index.js.map +1 -0
  93. package/dist/simplify/lookup.d.ts +3 -5
  94. package/dist/simplify/lookup.d.ts.map +1 -0
  95. package/dist/simplify/lookup.js +9 -13
  96. package/dist/simplify/lookup.js.map +1 -0
  97. package/dist/simplify/simplify.d.ts +2 -1
  98. package/dist/simplify/simplify.d.ts.map +1 -0
  99. package/dist/simplify/simplify.js +7 -7
  100. package/dist/simplify/simplify.js.map +1 -0
  101. package/dist/simplify/state.d.ts +3 -8
  102. package/dist/simplify/state.d.ts.map +1 -0
  103. package/dist/simplify/state.js +9 -13
  104. package/dist/simplify/state.js.map +1 -0
  105. package/dist/simplify/types.d.ts +9 -0
  106. package/dist/simplify/types.d.ts.map +1 -0
  107. package/dist/simplify/types.js +3 -0
  108. package/dist/simplify/types.js.map +1 -0
  109. package/dist/simplify/utils.d.ts +3 -2
  110. package/dist/simplify/utils.d.ts.map +1 -0
  111. package/dist/simplify/utils.js +4 -3
  112. package/dist/simplify/utils.js.map +1 -0
  113. package/dist/slice.d.ts +21 -1
  114. package/dist/slice.d.ts.map +1 -0
  115. package/dist/slice.js +10 -21
  116. package/dist/slice.js.map +1 -0
  117. package/dist/strip.d.ts +7 -15
  118. package/dist/strip.d.ts.map +1 -0
  119. package/dist/strip.js +13 -17
  120. package/dist/strip.js.map +1 -0
  121. package/dist/terminal.d.ts +5 -1
  122. package/dist/terminal.d.ts.map +1 -0
  123. package/dist/terminal.js +4 -2
  124. package/dist/terminal.js.map +1 -0
  125. package/package.json +8 -6
  126. package/src/ansi.ts +71 -0
  127. package/src/{caret.js → caret.ts} +9 -15
  128. package/src/{erase.js → erase.ts} +7 -10
  129. package/src/features/build.ts +53 -0
  130. package/src/features/detect.ts +36 -0
  131. package/src/features/{features.js → features.ts} +9 -18
  132. package/src/features/index.ts +1 -0
  133. package/src/index.ts +2 -0
  134. package/src/{pad.js → pad.ts} +4 -10
  135. package/src/{patterns.js → patterns.ts} +3 -5
  136. package/src/scroll.ts +13 -0
  137. package/src/sgr/color/{color.js → color.ts} +26 -35
  138. package/src/sgr/color/index.ts +1 -0
  139. package/src/sgr/color/{types.d.ts → types.ts} +6 -2
  140. package/src/sgr/color/{utils.js → utils.ts} +17 -30
  141. package/src/sgr/index.ts +3 -0
  142. package/src/sgr/reset.ts +1 -0
  143. package/src/sgr/sgr.ts +65 -0
  144. package/src/sgr/{style.js → style.ts} +3 -5
  145. package/src/sgr/{utils.js → utils.ts} +3 -6
  146. package/src/simplify/{atom.js → atom.ts} +5 -11
  147. package/src/simplify/index.ts +1 -0
  148. package/src/simplify/{lookup.js → lookup.ts} +5 -14
  149. package/src/simplify/{simplify.js → simplify.ts} +4 -10
  150. package/src/simplify/state.ts +63 -0
  151. package/src/simplify/{types.d.ts → types.ts} +5 -5
  152. package/src/simplify/{utils.js → utils.ts} +4 -10
  153. package/src/{slice.js → slice.ts} +12 -25
  154. package/src/strip.ts +10 -0
  155. package/src/{terminal.js → terminal.ts} +4 -7
  156. package/src/ansi.js +0 -70
  157. package/src/features/build.js +0 -68
  158. package/src/features/detect.js +0 -40
  159. package/src/features/index.js +0 -1
  160. package/src/index.js +0 -1
  161. package/src/scroll.js +0 -18
  162. package/src/sgr/color/index.js +0 -1
  163. package/src/sgr/index.js +0 -5
  164. package/src/sgr/reset.js +0 -3
  165. package/src/sgr/sgr.js +0 -77
  166. package/src/simplify/index.js +0 -1
  167. package/src/simplify/state.js +0 -73
  168. package/src/strip.js +0 -23
  169. /package/src/features/{types.d.ts → types.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,81 +1,3 @@
1
- declare const _exports: ((...args: Args) => Ansi) & {
2
- fg: Channel;
3
- bg: Channel;
4
- } & {
5
- caret: ReturnType<(enabled?: boolean) => {
6
- up: (count?: number) => string;
7
- down: (count?: number) => string;
8
- forward: (count?: number) => string;
9
- backward: (count?: number) => string;
10
- nextLine: (count?: number) => string;
11
- prevLine: (count?: number) => string;
12
- x: (x: number) => string;
13
- save: string;
14
- restore: string;
15
- hide: string;
16
- show: string;
17
- position: {
18
- get: string;
19
- set: (x: number, y: number) => string;
20
- };
21
- shape: {
22
- steadyBlock: string;
23
- steadyBar: string;
24
- steadyUnderline: string;
25
- blinkingBlock: string;
26
- blinkingBar: string;
27
- blinkingUnderline: string;
28
- default: string;
29
- };
30
- }>;
31
- erase: ReturnType<(enabled?: boolean) => {
32
- line: {
33
- toStart: string;
34
- toEnd: string;
35
- full: string;
36
- };
37
- screen: {
38
- toStart: string;
39
- toEnd: string;
40
- full: string;
41
- scrollback: string;
42
- };
43
- }>;
44
- scroll: ReturnType<(enabled?: boolean) => {
45
- up: (lines?: number) => string;
46
- down: (lines?: number) => string;
47
- }>;
48
- reset: string;
49
- style: ReturnType<typeof import("./sgr/style").makeStyle>;
50
- terminal: ReturnType<(enabled?: boolean) => {
51
- focusReporting: {
52
- enable: string;
53
- disable: string;
54
- focus: string;
55
- blur: string;
56
- };
57
- alternateScreen: {
58
- enable: string;
59
- disable: string;
60
- legacy: {
61
- enable: string;
62
- disable: string;
63
- };
64
- };
65
- bracketedPaste: {
66
- enable: string;
67
- disable: string;
68
- start: string;
69
- end: string;
70
- };
71
- }>;
72
- padEnd: (text: string, targetLength: number, fillString?: string) => string;
73
- padStart: (text: string, targetLength: number, fillString?: string) => string;
74
- strip: (text: string) => string;
75
- visibleLength: (text: string) => number;
76
- sanitize: (text: string) => string;
77
- slice: typeof import("./slice").slice;
78
- simplify: typeof import("./simplify/simplify").simplify;
79
- features: ReturnType<typeof import("./features/features").getFeatures>;
80
- };
81
- export = _exports;
1
+ export { default } from "./ansi";
2
+ export * from "./ansi";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,QAAQ,CAAC;AAC/B,cAAsB,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,24 @@
1
1
  "use strict";
2
- module.exports = require("./ansi");
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.default = void 0;
21
+ var ansi_1 = require("./ansi");
22
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ansi_1).default; } });
23
+ __exportStar(require("./ansi"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,+BAA+B;AAAvB,gHAAA,OAAO,OAAA;AACf,yCAA+B"}
package/dist/pad.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * Pad the given text at the end with the specified fill string to the target visible length without
3
3
  * counting ANSI escape codes.
4
- * @type {(text: string, targetLength: number, fillString?: string) => string}
5
4
  */
6
- export const padEnd: (text: string, targetLength: number, fillString?: string) => string;
5
+ export declare const padEnd: (text: string, targetLength: number, fillString?: string) => string;
7
6
  /**
8
7
  * Pad the given text at the start with the specified fill string to the target visible length
9
8
  * without counting ANSI escape codes.
10
- * @type {(text: string, targetLength: number, fillString?: string) => string}
11
9
  */
12
- export const padStart: (text: string, targetLength: number, fillString?: string) => string;
10
+ export declare const padStart: (text: string, targetLength: number, fillString?: string) => string;
11
+ //# sourceMappingURL=pad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pad.d.ts","sourceRoot":"","sources":["../src/pad.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,cAAc,MAAM,EAAE,mBAAgB,KAAG,MACgB,CAAC;AAE/F;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,EAAE,cAAc,MAAM,EAAE,mBAAgB,KAAG,MACc,CAAC"}
package/dist/pad.js CHANGED
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
- const { visibleLength } = require("./strip");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.padStart = exports.padEnd = void 0;
4
+ const strip_1 = require("./strip");
3
5
  /**
4
6
  * Pad the given text at the end with the specified fill string to the target visible length without
5
7
  * counting ANSI escape codes.
6
- * @type {(text: string, targetLength: number, fillString?: string) => string}
7
8
  */
8
- const padEnd = (text, targetLength, fillString = " ") => text + fillString.repeat(Math.max(0, targetLength - visibleLength(text)) / fillString.length);
9
+ const padEnd = (text, targetLength, fillString = " ") => text + fillString.repeat(Math.max(0, targetLength - (0, strip_1.visibleLength)(text)) / fillString.length);
10
+ exports.padEnd = padEnd;
9
11
  /**
10
12
  * Pad the given text at the start with the specified fill string to the target visible length
11
13
  * without counting ANSI escape codes.
12
- * @type {(text: string, targetLength: number, fillString?: string) => string}
13
14
  */
14
- const padStart = (text, targetLength, fillString = " ") => fillString.repeat(Math.max(0, targetLength - visibleLength(text)) / fillString.length) + text;
15
- module.exports = { padEnd, padStart };
15
+ const padStart = (text, targetLength, fillString = " ") => fillString.repeat(Math.max(0, targetLength - (0, strip_1.visibleLength)(text)) / fillString.length) + text;
16
+ exports.padStart = padStart;
17
+ //# sourceMappingURL=pad.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pad.js","sourceRoot":"","sources":["../src/pad.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC;;;GAGG;AACI,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,YAAoB,EAAE,UAAU,GAAG,GAAG,EAAU,EAAE,CACtF,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,IAAA,qBAAa,EAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AADlF,QAAA,MAAM,UAC4E;AAE/F;;;GAGG;AACI,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,YAAoB,EAAE,UAAU,GAAG,GAAG,EAAU,EAAE,CACxF,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,IAAA,qBAAa,EAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AADlF,QAAA,QAAQ,YAC0E"}
@@ -1,3 +1,4 @@
1
- export const rxSGR: Readonly<RegExp>;
2
- export const rxCSI: Readonly<RegExp>;
3
- export const rxUnsafe: Readonly<RegExp>;
1
+ export declare const rxSGR: Readonly<RegExp>;
2
+ export declare const rxCSI: Readonly<RegExp>;
3
+ export declare const rxUnsafe: Readonly<RegExp>;
4
+ //# sourceMappingURL=patterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":"AAuCA,eAAO,MAAM,KAAK,kBAAqC,CAAC;AACxD,eAAO,MAAM,KAAK,kBAA+C,CAAC;AAClE,eAAO,MAAM,QAAQ,kBAA+C,CAAC"}
package/dist/patterns.js CHANGED
@@ -37,7 +37,9 @@ timeit(() => long .replace(new RegExp(rxSGR.source, "g"), ""), {description: "lo
37
37
  // long - clone source : 46.491 ųs (21,510 in 1.000026492 s)
38
38
  ```
39
39
  */
40
- const rxSGR = Object.freeze(/\x1b\[[\d;]*m/g);
41
- const rxCSI = Object.freeze(/\x1b\[[0-?]*[ -/]*[@-~]/g);
42
- const rxUnsafe = Object.freeze(/\x1b\[[0-?]*[ -/]*[@-ln-~]/g); // Everything except SGR codes (m).
43
- module.exports = { rxSGR, rxCSI, rxUnsafe };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.rxUnsafe = exports.rxCSI = exports.rxSGR = void 0;
42
+ exports.rxSGR = Object.freeze(/\x1b\[[\d;]*m/g);
43
+ exports.rxCSI = Object.freeze(/\x1b\[[0-?]*[ -/]*[@-~]/g);
44
+ exports.rxUnsafe = Object.freeze(/\x1b\[[0-?]*[ -/]*[@-ln-~]/g); // Everything except SGR codes (m).
45
+ //# sourceMappingURL=patterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patterns.js","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCE;;;AAEW,QAAA,KAAK,GAAM,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC3C,QAAA,KAAK,GAAM,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;AACrD,QAAA,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC,CAAC,mCAAmC"}
package/dist/scroll.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- export function makeScroll(enabled?: boolean): {
2
- /** @type {(lines?: number) => string} */
1
+ declare const scroll: {
3
2
  up: (lines?: number) => string;
4
- /** @type {(lines?: number) => string} */
5
3
  down: (lines?: number) => string;
6
4
  };
5
+ export type Scroll = typeof scroll;
6
+ export declare const makeScroll: (enabled?: boolean) => Scroll;
7
+ export {};
8
+ //# sourceMappingURL=scroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../src/scroll.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM;iBACK,MAAM,KAAG,MAAM;mBACf,MAAM,KAAG,MAAM;CAC/B,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAOnC,eAAO,MAAM,UAAU,GAAI,iBAAc,KAAG,MAAqC,CAAC"}
package/dist/scroll.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeScroll = void 0;
2
4
  const scroll = {
3
- /** @type {(lines?: number) => string} */
4
- up: lines => `\x1b[${lines ?? 1}S`,
5
- /** @type {(lines?: number) => string} */
6
- down: lines => `\x1b[${lines ?? 1}T`,
5
+ up: (lines) => `\x1b[${lines ?? 1}S`,
6
+ down: (lines) => `\x1b[${lines ?? 1}T`,
7
7
  };
8
- /** @type {typeof scroll} */
9
8
  const disabled = {
10
9
  up: () => "",
11
10
  down: () => "",
12
11
  };
13
12
  const makeScroll = (enabled = true) => enabled ? scroll : disabled;
14
- module.exports = { makeScroll };
13
+ exports.makeScroll = makeScroll;
14
+ //# sourceMappingURL=scroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll.js","sourceRoot":"","sources":["../src/scroll.ts"],"names":[],"mappings":";;;AAAA,MAAM,MAAM,GAAG;IACd,EAAE,EAAK,CAAC,KAAc,EAAU,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC,GAAG;IACxD,IAAI,EAAG,CAAC,KAAc,EAAU,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC,GAAG;CACxD,CAAC;AAIF,MAAM,QAAQ,GAAW;IACxB,EAAE,EAAK,GAAG,EAAE,CAAC,EAAE;IACf,IAAI,EAAG,GAAG,EAAE,CAAC,EAAE;CACf,CAAC;AAEK,MAAM,UAAU,GAAG,CAAC,OAAO,GAAG,IAAI,EAAU,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;AAArE,QAAA,UAAU,cAA2D"}
@@ -1,9 +1,5 @@
1
- export type Code = import("../sgr").Code;
2
- export type ColorDepth = import("../../features/types").ColorDepth;
3
- export type SGR = import("../sgr").SGR;
4
- export type Channel = import("./types").Channel;
5
- /** @type {(colorDepth: ColorDepth) => {fg: Channel, bg: Channel}} */
6
- export const makeColor: (colorDepth: ColorDepth) => {
7
- fg: Channel;
8
- bg: Channel;
9
- };
1
+ import type { ColorDepth } from "../../features/types";
2
+ import type { Color } from "./types";
3
+ export type { Color } from "./types";
4
+ export declare const makeColor: (colorDepth?: ColorDepth) => Color;
5
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/sgr/color/color.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAU,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAU,KAAK,EAAC,MAAM,SAAS,CAAC;AAE5C,YAAY,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAkFnC,eAAO,MAAM,SAAS,GAAI,aAAY,UAAc,KAAG,KAIpD,CAAC"}
@@ -1,27 +1,21 @@
1
1
  "use strict";
2
- const { makeSGR } = require("../sgr");
3
- const { makeStyle } = require("../style");
4
- const { clip, rgbToX256, rgbToX16, rgbToX8, x256ToRgb } = require("./utils");
5
- /** @typedef {import("../sgr").Code} Code */
6
- /** @typedef {import("../../features/types").ColorDepth} ColorDepth */
7
- /** @typedef {import("../sgr").SGR} SGR */
8
- /** @typedef {import("./types").Channel} Channel */
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeColor = void 0;
4
+ const sgr_1 = require("../sgr");
5
+ const style_1 = require("../style");
6
+ const utils_1 = require("./utils");
9
7
  const fgOpen = 30, fgClose = 39;
10
8
  const bgOpen = 40, bgClose = 49;
11
- /** @type {(colorDepth: ColorDepth, open: number, close: number) => Channel} */
12
9
  function makeChannel(colorDepth, open, close) {
13
- const sgrBase = makeSGR(colorDepth > 1);
14
- const style = makeStyle(colorDepth > 1);
15
- /** @type {(code: Code) => SGR} */
16
- const sgr = code => sgrBase(code, close);
17
- /** @type {(index: number) => SGR} */
10
+ const sgrBase = (0, sgr_1.makeSGR)(colorDepth > 1);
11
+ const style = (0, style_1.makeStyle)(colorDepth > 1);
12
+ const sgr = (code) => sgrBase(code, close);
18
13
  const bright = colorDepth >= 4 ? index => sgr(open + 60 + index) :
19
14
  colorDepth === 3 ?
20
15
  open === fgOpen ?
21
16
  index => style.bold.combine(sgr(open + index)) :
22
17
  index => sgr(open + index) :
23
18
  () => sgr(0);
24
- /** @type {(code: number) => SGR} */
25
19
  const x16ToX8 = open === fgOpen ?
26
20
  code => code >= 60 ? style.bold.combine(sgr(open + code - 60)) : sgr(open + code) :
27
21
  code => code >= 60 ? sgr(open + code - 60) : sgr(open + code);
@@ -42,35 +36,34 @@ function makeChannel(colorDepth, open, close) {
42
36
  brightMagenta: bright(5),
43
37
  brightCyan: bright(6),
44
38
  brightWhite: bright(7),
45
- rgb: colorDepth >= 24 ? (r, g, b) => sgr([open + 8, 2, ...clip(r, g, b)]) :
46
- colorDepth >= 8 ? (r, g, b) => sgr([open + 8, 5, rgbToX256(...clip(r, g, b))]) :
47
- colorDepth >= 4 ? (r, g, b) => sgr(open + rgbToX16(...clip(r, g, b))) :
39
+ rgb: colorDepth >= 24 ? (r, g, b) => sgr([open + 8, 2, ...(0, utils_1.clip)(r, g, b)]) :
40
+ colorDepth >= 8 ? (r, g, b) => sgr([open + 8, 5, (0, utils_1.rgbToX256)(...(0, utils_1.clip)(r, g, b))]) :
41
+ colorDepth >= 4 ? (r, g, b) => sgr(open + (0, utils_1.rgbToX16)(...(0, utils_1.clip)(r, g, b))) :
48
42
  colorDepth === 3 ?
49
43
  open === fgOpen ?
50
- (r, g, b) => x16ToX8(rgbToX16(...clip(r, g, b))) :
51
- (r, g, b) => sgr(open + rgbToX8(...clip(r, g, b))) :
44
+ (r, g, b) => x16ToX8((0, utils_1.rgbToX16)(...(0, utils_1.clip)(r, g, b))) :
45
+ (r, g, b) => sgr(open + (0, utils_1.rgbToX8)(...(0, utils_1.clip)(r, g, b))) :
52
46
  () => sgr(0),
53
- /** @type {(...args: [number] | [number, number, number]) => SGR} */
54
47
  x256: colorDepth >= 8 ?
55
- (...args) => sgr([open + 8, 5, args.length === 3 ? rgbToX256(...clip(...args)) : clip(args[0])]) :
48
+ (...args) => sgr([open + 8, 5, args.length === 3 ? (0, utils_1.rgbToX256)(...(0, utils_1.clip)(...args)) : (0, utils_1.clip)(args[0])]) :
56
49
  colorDepth >= 4 ?
57
50
  (...args) => sgr(open +
58
- rgbToX16(...(args.length === 3 ? clip(...args) : x256ToRgb(clip(args[0]))))) :
51
+ (0, utils_1.rgbToX16)(...(args.length === 3 ? (0, utils_1.clip)(...args) : (0, utils_1.x256ToRgb)((0, utils_1.clip)(args[0]))))) :
59
52
  colorDepth === 3 ?
60
53
  open === fgOpen ?
61
- (...args) => x16ToX8(args.length === 3 ?
62
- rgbToX16(...clip(...args)) :
63
- rgbToX16(...x256ToRgb(clip(args[0])))) :
64
- (...args) => sgr(open + rgbToX8(...args.length === 3 ? clip(...args) : x256ToRgb(clip(args[0])))) :
54
+ (...args) => x16ToX8(args.length === 3
55
+ ? (0, utils_1.rgbToX16)(...(0, utils_1.clip)(...args))
56
+ : (0, utils_1.rgbToX16)(...(0, utils_1.x256ToRgb)((0, utils_1.clip)(args[0])))) :
57
+ (...args) => sgr(open +
58
+ (0, utils_1.rgbToX8)(...args.length === 3 ? (0, utils_1.clip)(...args) : (0, utils_1.x256ToRgb)((0, utils_1.clip)(args[0])))) :
65
59
  () => sgr(0),
66
60
  default: colorDepth > 1 ? `\x1b[${close}m` : "",
67
61
  };
68
62
  }
69
- /** @type {Partial<Record<ColorDepth, {fg: Channel, bg: Channel}>>} */
70
63
  const cache = {};
71
- /** @type {(colorDepth: ColorDepth) => {fg: Channel, bg: Channel}} */
72
64
  const makeColor = (colorDepth = 4) => cache[colorDepth] ?? (cache[colorDepth] = {
73
65
  fg: makeChannel(colorDepth, fgOpen, fgClose),
74
66
  bg: makeChannel(colorDepth, bgOpen, bgClose),
75
67
  });
76
- module.exports = { makeColor };
68
+ exports.makeColor = makeColor;
69
+ //# sourceMappingURL=color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/sgr/color/color.ts"],"names":[],"mappings":";;;AAAA,gCAAqE;AACrE,oCAAuE;AACvE,mCAAsE;AAQtE,MAAM,MAAM,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,CAAC;AAChC,MAAM,MAAM,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,CAAC;AAEhC,SAAS,WAAW,CAAC,UAAsB,EAAE,IAAY,EAAE,KAAa;IACvE,MAAM,OAAO,GAAG,IAAA,aAAO,EAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IACxC,MAAM,KAAK,GAAK,IAAA,iBAAS,EAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAE1C,MAAM,GAAG,GAAG,CAAC,IAAuB,EAAO,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEnE,MAAM,MAAM,GACX,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QACnD,UAAU,KAAK,CAAC,CAAC,CAAC;YACjB,IAAI,KAAK,MAAM,CAAC,CAAC;gBAChB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAA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H,CAAC,GAAG,IAAyC,EAAO,EAAE,CAAC,GAAG,CACzD,IAAI;4BACJ,IAAA,eAAO,EAAC,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,YAAI,EAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,IAAA,YAAI,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACxE,CAAC,CAAC;oBACL,GAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAElB,OAAO,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;KAC/C,CAAC;AACH,CAAC;AAED,MAAM,KAAK,GAAuC,EAAE,CAAC;AAE9C,MAAM,SAAS,GAAG,CAAC,aAAyB,CAAC,EAAS,EAAE,CAC9D,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG;IACzC,EAAE,EAAG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;IAC7C,EAAE,EAAG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;CAC7C,CAAC,CAAC;AAJS,QAAA,SAAS,aAIlB"}
@@ -1,2 +1,2 @@
1
- declare const _exports: typeof import("./color");
2
- export = _exports;
1
+ export * from "./color";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sgr/color/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -1,2 +1,18 @@
1
1
  "use strict";
2
- module.exports = 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);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./color"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sgr/color/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1,30 @@
1
+ import type { SGR } from "../sgr";
2
+ export interface Channel {
3
+ black: SGR;
4
+ red: SGR;
5
+ green: SGR;
6
+ yellow: SGR;
7
+ blue: SGR;
8
+ magenta: SGR;
9
+ cyan: SGR;
10
+ white: SGR;
11
+ brightBlack: SGR;
12
+ brightRed: SGR;
13
+ brightGreen: SGR;
14
+ brightYellow: SGR;
15
+ brightBlue: SGR;
16
+ brightMagenta: SGR;
17
+ brightCyan: SGR;
18
+ brightWhite: SGR;
19
+ rgb: (r: number, g: number, b: number) => SGR;
20
+ x256: {
21
+ (code: number): SGR;
22
+ (r: number, g: number, b: number): SGR;
23
+ };
24
+ default: string;
25
+ }
26
+ export type Color = {
27
+ fg: Channel;
28
+ bg: Channel;
29
+ };
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/sgr/color/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,QAAQ,CAAC;AAEhC,MAAM,WAAW,OAAO;IACvB,KAAK,EAAK,GAAG,CAAC;IACd,GAAG,EAAO,GAAG,CAAC;IACd,KAAK,EAAK,GAAG,CAAC;IACd,MAAM,EAAI,GAAG,CAAC;IACd,IAAI,EAAM,GAAG,CAAC;IACd,OAAO,EAAG,GAAG,CAAC;IACd,IAAI,EAAM,GAAG,CAAC;IACd,KAAK,EAAK,GAAG,CAAC;IAEd,WAAW,EAAK,GAAG,CAAC;IACpB,SAAS,EAAO,GAAG,CAAC;IACpB,WAAW,EAAK,GAAG,CAAC;IACpB,YAAY,EAAI,GAAG,CAAC;IACpB,UAAU,EAAM,GAAG,CAAC;IACpB,aAAa,EAAG,GAAG,CAAC;IACpB,UAAU,EAAM,GAAG,CAAC;IACpB,WAAW,EAAK,GAAG,CAAC;IAEpB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;IAE9C,IAAI,EAAE;QACL,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QACpB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;KACvC,CAAC;IAEF,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,KAAK,GAAG;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/sgr/color/types.ts"],"names":[],"mappings":""}
@@ -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,CAajE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAYhE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAgBhE;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,6 +1,10 @@
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
9
  if (r === g && g === b) {
6
10
  // grayscale
@@ -12,7 +16,6 @@ function rgbToX256(r, g, b) {
12
16
  Math.floor(g * 6 / 256) * 6 +
13
17
  Math.floor(b * 6 / 256));
14
18
  }
15
- /** @type {(code: number) => [number, number, number]} */
16
19
  function x256ToRgb(code) {
17
20
  if (code >= 232) {
18
21
  // grayscale
@@ -25,7 +28,6 @@ function x256ToRgb(code) {
25
28
  const b = (code % 6) * 51;
26
29
  return [r, g, b];
27
30
  }
28
- /** @type {(r: number, g: number, b: number) => number} */
29
31
  function rgbToX16(r, g, b) {
30
32
  // First calculate it as a 4x4x4 cube.
31
33
  r = Math.min(2, Math.floor(r / 85));
@@ -40,28 +42,19 @@ function rgbToX16(r, g, b) {
40
42
  // Return value uses the SGR offset scheme: 0–7 for normal, 60–67 for bright.
41
43
  return index + (bright ? 60 : 0);
42
44
  }
43
- /** @type {(r: number, g: number, b: number) => number} */
44
45
  function rgbToX8(r, g, b) {
45
46
  r = r >= 128 ? 1 : 0;
46
47
  g = g >= 128 ? 1 : 0;
47
48
  b = b >= 128 ? 1 : 0;
48
49
  return (r ? 1 : 0) | (g ? 2 : 0) | (b ? 4 : 0);
49
50
  }
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 };
51
+ function clip(...args) {
52
+ return args.length === 1 ?
53
+ Math.max(0, Math.min(255, Math.floor(args[0]))) :
54
+ [
55
+ Math.max(0, Math.min(255, Math.floor(args[0]))),
56
+ Math.max(0, Math.min(255, Math.floor(args[1]))),
57
+ Math.max(0, Math.min(255, Math.floor(args[2]))),
58
+ ];
59
+ }
60
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/sgr/color/utils.ts"],"names":[],"mappings":";;AAAA,8BAaC;AAED,8BAYC;AAED,4BAgBC;AAED,0BAMC;AAID,oBAUC;AAnED,SAAgB,SAAS,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACxD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,YAAY;QACZ,OAAO,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,mBAAmB;IACnB,OAAO,CACN,EAAE;QACF,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE;QAC5B,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CACvB,CAAC;AACH,CAAC;AAED,SAAgB,SAAS,CAAC,IAAY;IACrC,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;QACjB,YAAY;QACZ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC;QACj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I,CACnB,GAAG,IAAyC;IAE5C,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD;YACC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,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;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