index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1677462587409, function(require, module, exports) {
  8. const wrapAnsi16 = (fn, offset) => (...args) => {
  9. const code = fn(...args);
  10. return `\u001B[${code + offset}m`;
  11. };
  12. const wrapAnsi256 = (fn, offset) => (...args) => {
  13. const code = fn(...args);
  14. return `\u001B[${38 + offset};5;${code}m`;
  15. };
  16. const wrapAnsi16m = (fn, offset) => (...args) => {
  17. const rgb = fn(...args);
  18. return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
  19. };
  20. const ansi2ansi = n => n;
  21. const rgb2rgb = (r, g, b) => [r, g, b];
  22. const setLazyProperty = (object, property, get) => {
  23. Object.defineProperty(object, property, {
  24. get: () => {
  25. const value = get();
  26. Object.defineProperty(object, property, {
  27. value,
  28. enumerable: true,
  29. configurable: true
  30. });
  31. return value;
  32. },
  33. enumerable: true,
  34. configurable: true
  35. });
  36. };
  37. /** @type {typeof import('color-convert')} */
  38. let colorConvert;
  39. const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
  40. if (colorConvert === undefined) {
  41. colorConvert = require('color-convert');
  42. }
  43. const offset = isBackground ? 10 : 0;
  44. const styles = {};
  45. for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
  46. const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
  47. if (sourceSpace === targetSpace) {
  48. styles[name] = wrap(identity, offset);
  49. } else if (typeof suite === 'object') {
  50. styles[name] = wrap(suite[targetSpace], offset);
  51. }
  52. }
  53. return styles;
  54. };
  55. function assembleStyles() {
  56. const codes = new Map();
  57. const styles = {
  58. modifier: {
  59. reset: [0, 0],
  60. // 21 isn't widely supported and 22 does the same thing
  61. bold: [1, 22],
  62. dim: [2, 22],
  63. italic: [3, 23],
  64. underline: [4, 24],
  65. inverse: [7, 27],
  66. hidden: [8, 28],
  67. strikethrough: [9, 29]
  68. },
  69. color: {
  70. black: [30, 39],
  71. red: [31, 39],
  72. green: [32, 39],
  73. yellow: [33, 39],
  74. blue: [34, 39],
  75. magenta: [35, 39],
  76. cyan: [36, 39],
  77. white: [37, 39],
  78. // Bright color
  79. blackBright: [90, 39],
  80. redBright: [91, 39],
  81. greenBright: [92, 39],
  82. yellowBright: [93, 39],
  83. blueBright: [94, 39],
  84. magentaBright: [95, 39],
  85. cyanBright: [96, 39],
  86. whiteBright: [97, 39]
  87. },
  88. bgColor: {
  89. bgBlack: [40, 49],
  90. bgRed: [41, 49],
  91. bgGreen: [42, 49],
  92. bgYellow: [43, 49],
  93. bgBlue: [44, 49],
  94. bgMagenta: [45, 49],
  95. bgCyan: [46, 49],
  96. bgWhite: [47, 49],
  97. // Bright color
  98. bgBlackBright: [100, 49],
  99. bgRedBright: [101, 49],
  100. bgGreenBright: [102, 49],
  101. bgYellowBright: [103, 49],
  102. bgBlueBright: [104, 49],
  103. bgMagentaBright: [105, 49],
  104. bgCyanBright: [106, 49],
  105. bgWhiteBright: [107, 49]
  106. }
  107. };
  108. // Alias bright black as gray (and grey)
  109. styles.color.gray = styles.color.blackBright;
  110. styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
  111. styles.color.grey = styles.color.blackBright;
  112. styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
  113. for (const [groupName, group] of Object.entries(styles)) {
  114. for (const [styleName, style] of Object.entries(group)) {
  115. styles[styleName] = {
  116. open: `\u001B[${style[0]}m`,
  117. close: `\u001B[${style[1]}m`
  118. };
  119. group[styleName] = styles[styleName];
  120. codes.set(style[0], style[1]);
  121. }
  122. Object.defineProperty(styles, groupName, {
  123. value: group,
  124. enumerable: false
  125. });
  126. }
  127. Object.defineProperty(styles, 'codes', {
  128. value: codes,
  129. enumerable: false
  130. });
  131. styles.color.close = '\u001B[39m';
  132. styles.bgColor.close = '\u001B[49m';
  133. setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
  134. setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
  135. setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
  136. setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
  137. setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
  138. setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
  139. return styles;
  140. }
  141. // Make the export immutable
  142. Object.defineProperty(module, 'exports', {
  143. enumerable: true,
  144. get: assembleStyles
  145. });
  146. }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
  147. return __REQUIRE__(1677462587409);
  148. })()
  149. //miniprogram-npm-outsideDeps=["color-convert"]
  150. //# sourceMappingURL=index.js.map