@galadrim/galadmin 0.1.33 → 0.1.34

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 (179) hide show
  1. package/dist/api.js +1 -0
  2. package/dist/api.js.map +1 -1
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/package.json +1 -1
  5. package/src/api.ts +1 -0
  6. package/src/front/node_modules/.cache/.eslintcache +1 -1
  7. package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/6c/19/fe86ba5d7c4062f185480ad22dd3b9fae9b30149827224339f9a633a9a94 +1 -1
  8. package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/87/08/421190bfe6e50816e059da6c33526c9943732ef856ebd2752d0cbfb4a852 +1 -1
  9. package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/c2/e5/5451dd89bb0fd48f988bf27c7ee614c66eb91f7085c5b5c8cb33048d0c32 +1 -1
  10. package/src/front/node_modules/.package-lock.json +115 -74
  11. package/src/front/node_modules/@babel/code-frame/README.md +1 -1
  12. package/src/front/node_modules/@babel/code-frame/lib/index.js +15 -1
  13. package/src/front/node_modules/@babel/code-frame/lib/index.js.map +1 -1
  14. package/src/front/node_modules/@babel/code-frame/node_modules/ansi-styles/index.js +165 -0
  15. package/src/front/node_modules/@babel/code-frame/node_modules/ansi-styles/license +9 -0
  16. package/src/front/node_modules/@babel/code-frame/node_modules/ansi-styles/package.json +56 -0
  17. package/src/front/node_modules/@babel/code-frame/node_modules/ansi-styles/readme.md +147 -0
  18. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/index.js +228 -0
  19. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/index.js.flow +93 -0
  20. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/license +9 -0
  21. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/package.json +71 -0
  22. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/readme.md +314 -0
  23. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/templates.js +128 -0
  24. package/src/front/node_modules/@babel/code-frame/node_modules/chalk/types/index.d.ts +97 -0
  25. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/browser.js +5 -0
  26. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/index.js +131 -0
  27. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/license +9 -0
  28. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/package.json +53 -0
  29. package/src/front/node_modules/@babel/code-frame/node_modules/supports-color/readme.md +66 -0
  30. package/src/front/node_modules/@babel/code-frame/package.json +3 -2
  31. package/src/front/node_modules/@babel/compat-data/data/plugin-bugfixes.json +2 -0
  32. package/src/front/node_modules/@babel/compat-data/data/plugins.json +8 -0
  33. package/src/front/node_modules/@babel/compat-data/package.json +1 -1
  34. package/src/front/node_modules/@babel/core/cjs-proxy.cjs +3 -1
  35. package/src/front/node_modules/@babel/core/lib/config/config-chain.js +7 -4
  36. package/src/front/node_modules/@babel/core/lib/config/config-chain.js.map +1 -1
  37. package/src/front/node_modules/@babel/core/lib/config/config-descriptors.js +2 -1
  38. package/src/front/node_modules/@babel/core/lib/config/config-descriptors.js.map +1 -1
  39. package/src/front/node_modules/@babel/core/lib/config/files/module-types.js +5 -5
  40. package/src/front/node_modules/@babel/core/lib/config/files/module-types.js.map +1 -1
  41. package/src/front/node_modules/@babel/core/lib/config/full.js.map +1 -1
  42. package/src/front/node_modules/@babel/core/lib/config/helpers/config-api.js +4 -4
  43. package/src/front/node_modules/@babel/core/lib/config/helpers/config-api.js.map +1 -1
  44. package/src/front/node_modules/@babel/core/lib/config/index.js.map +1 -1
  45. package/src/front/node_modules/@babel/core/lib/config/item.js.map +1 -1
  46. package/src/front/node_modules/@babel/core/lib/config/printer.js.map +1 -1
  47. package/src/front/node_modules/@babel/core/lib/config/validation/options.js.map +1 -1
  48. package/src/front/node_modules/@babel/core/lib/config/validation/plugins.js.map +1 -1
  49. package/src/front/node_modules/@babel/core/lib/index.js +2 -1
  50. package/src/front/node_modules/@babel/core/lib/index.js.map +1 -1
  51. package/src/front/node_modules/@babel/core/lib/transformation/file/file.js +5 -5
  52. package/src/front/node_modules/@babel/core/lib/transformation/file/file.js.map +1 -1
  53. package/src/front/node_modules/@babel/core/lib/transformation/file/generate.js.map +1 -1
  54. package/src/front/node_modules/@babel/core/lib/transformation/index.js +3 -1
  55. package/src/front/node_modules/@babel/core/lib/transformation/index.js.map +1 -1
  56. package/src/front/node_modules/@babel/core/lib/transformation/plugin-pass.js.map +1 -1
  57. package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/README.md +2 -13
  58. package/src/front/node_modules/@babel/core/node_modules/semver/package.json +38 -0
  59. package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/semver.js +54 -20
  60. package/src/front/node_modules/@babel/core/package.json +13 -13
  61. package/src/front/node_modules/@babel/generator/lib/buffer.js.map +1 -1
  62. package/src/front/node_modules/@babel/generator/lib/generators/classes.js +6 -6
  63. package/src/front/node_modules/@babel/generator/lib/generators/classes.js.map +1 -1
  64. package/src/front/node_modules/@babel/generator/lib/generators/methods.js.map +1 -1
  65. package/src/front/node_modules/@babel/generator/lib/generators/types.js.map +1 -1
  66. package/src/front/node_modules/@babel/generator/lib/index.js +2 -1
  67. package/src/front/node_modules/@babel/generator/lib/index.js.map +1 -1
  68. package/src/front/node_modules/@babel/generator/lib/printer.js +2 -2
  69. package/src/front/node_modules/@babel/generator/lib/printer.js.map +1 -1
  70. package/src/front/node_modules/@babel/generator/lib/source-map.js.map +1 -1
  71. package/src/front/node_modules/@babel/generator/package.json +4 -4
  72. package/src/front/node_modules/@babel/helper-compilation-targets/lib/debug.js +2 -2
  73. package/src/front/node_modules/@babel/helper-compilation-targets/lib/debug.js.map +1 -1
  74. package/src/front/node_modules/@babel/helper-compilation-targets/lib/filter-items.js +3 -3
  75. package/src/front/node_modules/@babel/helper-compilation-targets/lib/filter-items.js.map +1 -1
  76. package/src/front/node_modules/@babel/helper-compilation-targets/lib/pretty.js +2 -2
  77. package/src/front/node_modules/@babel/helper-compilation-targets/lib/pretty.js.map +1 -1
  78. package/src/front/node_modules/@babel/helper-compilation-targets/lib/utils.js +3 -3
  79. package/src/front/node_modules/@babel/helper-compilation-targets/lib/utils.js.map +1 -1
  80. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/LICENSE +15 -0
  81. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/README.md +443 -0
  82. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/bin/semver.js +174 -0
  83. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/package.json +38 -0
  84. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/range.bnf +16 -0
  85. package/src/front/node_modules/@babel/helper-compilation-targets/node_modules/semver/semver.js +1643 -0
  86. package/src/front/node_modules/@babel/helper-compilation-targets/package.json +4 -8
  87. package/src/front/node_modules/@babel/helper-module-transforms/README.md +1 -1
  88. package/src/front/node_modules/@babel/helper-module-transforms/lib/dynamic-import.js +11 -12
  89. package/src/front/node_modules/@babel/helper-module-transforms/lib/dynamic-import.js.map +1 -1
  90. package/src/front/node_modules/@babel/helper-module-transforms/lib/index.js +15 -16
  91. package/src/front/node_modules/@babel/helper-module-transforms/lib/index.js.map +1 -1
  92. package/src/front/node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js +3 -4
  93. package/src/front/node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js.map +1 -1
  94. package/src/front/node_modules/@babel/helper-module-transforms/lib/rewrite-this.js +4 -5
  95. package/src/front/node_modules/@babel/helper-module-transforms/lib/rewrite-this.js.map +1 -1
  96. package/src/front/node_modules/@babel/helper-module-transforms/package.json +10 -6
  97. package/src/front/node_modules/@babel/helpers/lib/helpers/regeneratorRuntime.js +2 -4
  98. package/src/front/node_modules/@babel/helpers/lib/helpers/regeneratorRuntime.js.map +1 -1
  99. package/src/front/node_modules/@babel/helpers/lib/helpers-generated.js +1 -1
  100. package/src/front/node_modules/@babel/helpers/lib/helpers-generated.js.map +1 -1
  101. package/src/front/node_modules/@babel/helpers/package.json +6 -6
  102. package/src/front/node_modules/@babel/highlight/README.md +1 -1
  103. package/src/front/node_modules/@babel/highlight/lib/index.js +20 -10
  104. package/src/front/node_modules/@babel/highlight/lib/index.js.map +1 -1
  105. package/src/front/node_modules/@babel/highlight/package.json +2 -3
  106. package/src/front/node_modules/@babel/parser/lib/index.js +115 -160
  107. package/src/front/node_modules/@babel/parser/lib/index.js.map +1 -1
  108. package/src/front/node_modules/@babel/parser/lib/options.js +6 -2
  109. package/src/front/node_modules/@babel/parser/lib/options.js.map +1 -1
  110. package/src/front/node_modules/@babel/parser/lib/parser/expression.js +4 -4
  111. package/src/front/node_modules/@babel/parser/lib/parser/expression.js.map +1 -1
  112. package/src/front/node_modules/@babel/parser/lib/parser/lval.js +6 -6
  113. package/src/front/node_modules/@babel/parser/lib/parser/lval.js.map +1 -1
  114. package/src/front/node_modules/@babel/parser/lib/parser/statement.js +20 -19
  115. package/src/front/node_modules/@babel/parser/lib/parser/statement.js.map +1 -1
  116. package/src/front/node_modules/@babel/parser/lib/parser/util.js +1 -1
  117. package/src/front/node_modules/@babel/parser/lib/parser/util.js.map +1 -1
  118. package/src/front/node_modules/@babel/parser/lib/plugins/flow/index.js +7 -7
  119. package/src/front/node_modules/@babel/parser/lib/plugins/flow/index.js.map +1 -1
  120. package/src/front/node_modules/@babel/parser/lib/plugins/flow/scope.js +2 -2
  121. package/src/front/node_modules/@babel/parser/lib/plugins/flow/scope.js.map +1 -1
  122. package/src/front/node_modules/@babel/parser/lib/plugins/placeholders.js +2 -1
  123. package/src/front/node_modules/@babel/parser/lib/plugins/placeholders.js.map +1 -1
  124. package/src/front/node_modules/@babel/parser/lib/plugins/typescript/index.js +16 -16
  125. package/src/front/node_modules/@babel/parser/lib/plugins/typescript/index.js.map +1 -1
  126. package/src/front/node_modules/@babel/parser/lib/plugins/typescript/scope.js +16 -14
  127. package/src/front/node_modules/@babel/parser/lib/plugins/typescript/scope.js.map +1 -1
  128. package/src/front/node_modules/@babel/parser/lib/util/class-scope.js +5 -5
  129. package/src/front/node_modules/@babel/parser/lib/util/class-scope.js.map +1 -1
  130. package/src/front/node_modules/@babel/parser/lib/util/expression-scope.js +7 -12
  131. package/src/front/node_modules/@babel/parser/lib/util/expression-scope.js.map +1 -1
  132. package/src/front/node_modules/@babel/parser/lib/util/scope.js +23 -23
  133. package/src/front/node_modules/@babel/parser/lib/util/scope.js.map +1 -1
  134. package/src/front/node_modules/@babel/parser/lib/util/scopeflags.js +60 -99
  135. package/src/front/node_modules/@babel/parser/lib/util/scopeflags.js.map +1 -1
  136. package/src/front/node_modules/@babel/parser/package.json +3 -3
  137. package/src/front/node_modules/@babel/traverse/lib/cache.js +24 -3
  138. package/src/front/node_modules/@babel/traverse/lib/cache.js.map +1 -1
  139. package/src/front/node_modules/@babel/traverse/lib/index.js +5 -3
  140. package/src/front/node_modules/@babel/traverse/lib/index.js.map +1 -1
  141. package/src/front/node_modules/@babel/traverse/lib/path/context.js.map +1 -1
  142. package/src/front/node_modules/@babel/traverse/lib/path/conversion.js +1 -4
  143. package/src/front/node_modules/@babel/traverse/lib/path/conversion.js.map +1 -1
  144. package/src/front/node_modules/@babel/traverse/lib/path/index.js +2 -6
  145. package/src/front/node_modules/@babel/traverse/lib/path/index.js.map +1 -1
  146. package/src/front/node_modules/@babel/traverse/lib/path/lib/hoister.js.map +1 -1
  147. package/src/front/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js +9 -7
  148. package/src/front/node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js.map +1 -1
  149. package/src/front/node_modules/@babel/traverse/lib/path/modification.js +3 -2
  150. package/src/front/node_modules/@babel/traverse/lib/path/modification.js.map +1 -1
  151. package/src/front/node_modules/@babel/traverse/lib/path/removal.js +3 -1
  152. package/src/front/node_modules/@babel/traverse/lib/path/removal.js.map +1 -1
  153. package/src/front/node_modules/@babel/traverse/lib/path/replacement.js +4 -4
  154. package/src/front/node_modules/@babel/traverse/lib/path/replacement.js.map +1 -1
  155. package/src/front/node_modules/@babel/traverse/lib/scope/index.js +2 -1
  156. package/src/front/node_modules/@babel/traverse/lib/scope/index.js.map +1 -1
  157. package/src/front/node_modules/@babel/traverse/lib/traverse-node.js +6 -2
  158. package/src/front/node_modules/@babel/traverse/lib/traverse-node.js.map +1 -1
  159. package/src/front/node_modules/@babel/traverse/lib/visitors.js.map +1 -1
  160. package/src/front/node_modules/@babel/traverse/package.json +6 -5
  161. package/src/front/node_modules/@babel/types/README.md +1 -1
  162. package/src/front/node_modules/@babel/types/lib/ast-types/generated/index.js.map +1 -1
  163. package/src/front/node_modules/@babel/types/lib/converters/toStatement.js.map +1 -1
  164. package/src/front/node_modules/@babel/types/lib/definitions/core.js +8 -1
  165. package/src/front/node_modules/@babel/types/lib/definitions/core.js.map +1 -1
  166. package/src/front/node_modules/@babel/types/lib/index.d.ts +11 -10
  167. package/src/front/node_modules/@babel/types/lib/validators/generated/index.js.map +1 -1
  168. package/src/front/node_modules/@babel/types/lib/validators/isType.js +1 -0
  169. package/src/front/node_modules/@babel/types/lib/validators/isType.js.map +1 -1
  170. package/src/front/node_modules/@babel/types/package.json +3 -4
  171. package/src/front/node_modules/react-scripts/node_modules/@babel/core/node_modules/semver/package.json +19 -9
  172. package/src/front/node_modules/react-scripts/node_modules/@babel/core/node_modules/semver/semver.js +68 -26
  173. package/src/front/package-lock.json +216 -142
  174. package/src/front/node_modules/@nicolo-ribaudo/semver-v6/CHANGELOG.md +0 -70
  175. package/src/front/node_modules/@nicolo-ribaudo/semver-v6/package.json +0 -28
  176. package/src/front/node_modules/react-scripts/node_modules/@babel/core/node_modules/semver/CHANGELOG.md +0 -39
  177. /package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/LICENSE +0 -0
  178. /package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/bin/semver.js +0 -0
  179. /package/src/front/node_modules/{@nicolo-ribaudo/semver-v6 → @babel/core/node_modules/semver}/range.bnf +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["_highlight","require","deprecationWarningShown","getDefs","chalk","gutter","grey","marker","red","bold","message","NEWLINE","getMarkerLines","loc","source","opts","startLoc","Object","assign","column","line","start","endLoc","end","linesAbove","linesBelow","startLine","startColumn","endLine","endColumn","Math","max","min","length","lineDiff","markerLines","i","lineNumber","sourceLength","codeFrameColumns","rawLines","highlighted","highlightCode","forceColor","shouldHighlight","getChalk","defs","maybeHighlight","chalkFn","string","lines","split","hasColumns","numberMaxWidth","String","highlightedLines","highlight","frame","slice","map","index","number","paddedNumber","hasMarker","lastMarkerLine","markerLine","Array","isArray","markerSpacing","replace","numberOfMarkers","repeat","join","reset","_default","colNumber","process","emitWarning","deprecationError","Error","name","console","warn","location"],"sources":["../src/index.ts"],"sourcesContent":["import highlight, { shouldHighlight, getChalk } from \"@babel/highlight\";\n\ntype Chalk = ReturnType<typeof getChalk>;\n\nlet deprecationWarningShown = false;\n\ntype Location = {\n column: number;\n line: number;\n};\n\ntype NodeLocation = {\n end?: Location;\n start: Location;\n};\n\nexport interface Options {\n /** Syntax highlight the code as JavaScript for terminals. default: false */\n highlightCode?: boolean;\n /** The number of lines to show above the error. default: 2 */\n linesAbove?: number;\n /** The number of lines to show below the error. default: 3 */\n linesBelow?: number;\n /**\n * Forcibly syntax highlight the code as JavaScript (for non-terminals);\n * overrides highlightCode.\n * default: false\n */\n forceColor?: boolean;\n /**\n * Pass in a string to be displayed inline (if possible) next to the\n * highlighted location in the code. If it can't be positioned inline,\n * it will be placed above the code frame.\n * default: nothing\n */\n message?: string;\n}\n\n/**\n * Chalk styles for code frame token types.\n */\nfunction getDefs(chalk: Chalk) {\n return {\n gutter: chalk.grey,\n marker: chalk.red.bold,\n message: chalk.red.bold,\n };\n}\n\n/**\n * RegExp to test for newlines in terminal.\n */\n\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\n\n/**\n * Extract what lines should be marked and highlighted.\n */\n\ntype MarkerLines = Record<number, true | [number, number]>;\n\nfunction getMarkerLines(\n loc: NodeLocation,\n source: Array<string>,\n opts: Options,\n): {\n start: number;\n end: number;\n markerLines: MarkerLines;\n} {\n const startLoc: Location = {\n column: 0,\n line: -1,\n ...loc.start,\n };\n const endLoc: Location = {\n ...startLoc,\n ...loc.end,\n };\n const { linesAbove = 2, linesBelow = 3 } = opts || {};\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: MarkerLines = {};\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine;\n\n if (!startColumn) {\n markerLines[lineNumber] = true;\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1].length;\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - i].length;\n\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else {\n if (startColumn === endColumn) {\n if (startColumn) {\n markerLines[startLine] = [startColumn, 0];\n } else {\n markerLines[startLine] = true;\n }\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn];\n }\n }\n\n return { start, end, markerLines };\n}\n\nexport function codeFrameColumns(\n rawLines: string,\n loc: NodeLocation,\n opts: Options = {},\n): string {\n const highlighted =\n (opts.highlightCode || opts.forceColor) && shouldHighlight(opts);\n const chalk = getChalk(opts);\n const defs = getDefs(chalk);\n const maybeHighlight = (chalkFn: Chalk, string: string) => {\n return highlighted ? chalkFn(string) : string;\n };\n const lines = rawLines.split(NEWLINE);\n const { start, end, markerLines } = getMarkerLines(loc, lines, opts);\n const hasColumns = loc.start && typeof loc.start.column === \"number\";\n\n const numberMaxWidth = String(end).length;\n\n const highlightedLines = highlighted ? highlight(rawLines, opts) : rawLines;\n\n let frame = highlightedLines\n .split(NEWLINE, end)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const gutter = ` ${paddedNumber} |`;\n const hasMarker = markerLines[number];\n const lastMarkerLine = !markerLines[number + 1];\n if (hasMarker) {\n let markerLine = \"\";\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line\n .slice(0, Math.max(hasMarker[0] - 1, 0))\n .replace(/[^\\t]/g, \" \");\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\n \"\\n \",\n maybeHighlight(defs.gutter, gutter.replace(/\\d/g, \" \")),\n \" \",\n markerSpacing,\n maybeHighlight(defs.marker, \"^\").repeat(numberOfMarkers),\n ].join(\"\");\n\n if (lastMarkerLine && opts.message) {\n markerLine += \" \" + maybeHighlight(defs.message, opts.message);\n }\n }\n return [\n maybeHighlight(defs.marker, \">\"),\n maybeHighlight(defs.gutter, gutter),\n line.length > 0 ? ` ${line}` : \"\",\n markerLine,\n ].join(\"\");\n } else {\n return ` ${maybeHighlight(defs.gutter, gutter)}${\n line.length > 0 ? ` ${line}` : \"\"\n }`;\n }\n })\n .join(\"\\n\");\n\n if (opts.message && !hasColumns) {\n frame = `${\" \".repeat(numberMaxWidth + 1)}${opts.message}\\n${frame}`;\n }\n\n if (highlighted) {\n return chalk.reset(frame);\n } else {\n return frame;\n }\n}\n\n/**\n * Create a code frame, adding line numbers, code highlighting, and pointing to a given position.\n */\n\nexport default function (\n rawLines: string,\n lineNumber: number,\n colNumber?: number | null,\n opts: Options = {},\n): string {\n if (!deprecationWarningShown) {\n deprecationWarningShown = true;\n\n const message =\n \"Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.\";\n\n if (process.emitWarning) {\n // A string is directly supplied to emitWarning, because when supplying an\n // Error object node throws in the tests because of different contexts\n process.emitWarning(message, \"DeprecationWarning\");\n } else {\n const deprecationError = new Error(message);\n deprecationError.name = \"DeprecationWarning\";\n console.warn(new Error(message));\n }\n }\n\n colNumber = Math.max(colNumber, 0);\n\n const location: NodeLocation = {\n start: { column: colNumber, line: lineNumber },\n };\n\n return codeFrameColumns(rawLines, location, opts);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAIA,IAAIC,uBAAuB,GAAG,KAAK;AAqCnC,SAASC,OAAOA,CAACC,KAAY,EAAE;EAC7B,OAAO;IACLC,MAAM,EAAED,KAAK,CAACE,IAAI;IAClBC,MAAM,EAAEH,KAAK,CAACI,GAAG,CAACC,IAAI;IACtBC,OAAO,EAAEN,KAAK,CAACI,GAAG,CAACC;EACrB,CAAC;AACH;AAMA,MAAME,OAAO,GAAG,yBAAyB;AAQzC,SAASC,cAAcA,CACrBC,GAAiB,EACjBC,MAAqB,EACrBC,IAAa,EAKb;EACA,MAAMC,QAAkB,GAAAC,MAAA,CAAAC,MAAA;IACtBC,MAAM,EAAE,CAAC;IACTC,IAAI,EAAE,CAAC;EAAC,GACLP,GAAG,CAACQ,KAAK,CACb;EACD,MAAMC,MAAgB,GAAAL,MAAA,CAAAC,MAAA,KACjBF,QAAQ,EACRH,GAAG,CAACU,GAAG,CACX;EACD,MAAM;IAAEC,UAAU,GAAG,CAAC;IAAEC,UAAU,GAAG;EAAE,CAAC,GAAGV,IAAI,IAAI,CAAC,CAAC;EACrD,MAAMW,SAAS,GAAGV,QAAQ,CAACI,IAAI;EAC/B,MAAMO,WAAW,GAAGX,QAAQ,CAACG,MAAM;EACnC,MAAMS,OAAO,GAAGN,MAAM,CAACF,IAAI;EAC3B,MAAMS,SAAS,GAAGP,MAAM,CAACH,MAAM;EAE/B,IAAIE,KAAK,GAAGS,IAAI,CAACC,GAAG,CAACL,SAAS,IAAIF,UAAU,GA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C;MAC3CoE,gBAAgB,CAACE,IAAI,GAAG,oBAAoB;MAC5CC,OAAO,CAACC,IAAI,CAAC,IAAIH,KAAK,CAACrE,OAAO,CAAC,CAAC;IAClC;EACF;EAEAiE,SAAS,GAAG7C,IAAI,CAACC,GAAG,CAAC4C,SAAS,EAAE,CAAC,CAAC;EAElC,MAAMQ,QAAsB,GAAG;IAC7B9D,KAAK,EAAE;MAAEF,MAAM,EAAEwD,SAAS;MAAEvD,IAAI,EAAEiB;IAAW;EAC/C,CAAC;EAED,OAAOE,gBAAgB,CAACC,QAAQ,EAAE2C,QAAQ,EAAEpE,IAAI,CAAC;AACnD"}
1
+ {"version":3,"names":["_highlight","require","_chalk2","chalk","_chalk","chalkWithForcedColor","undefined","getChalk","forceColor","_chalkWithForcedColor","constructor","enabled","level","deprecationWarningShown","getDefs","gutter","grey","marker","red","bold","message","NEWLINE","getMarkerLines","loc","source","opts","startLoc","Object","assign","column","line","start","endLoc","end","linesAbove","linesBelow","startLine","startColumn","endLine","endColumn","Math","max","min","length","lineDiff","markerLines","i","lineNumber","sourceLength","codeFrameColumns","rawLines","highlighted","highlightCode","shouldHighlight","defs","maybeHighlight","chalkFn","string","lines","split","hasColumns","numberMaxWidth","String","highlightedLines","highlight","frame","slice","map","index","number","paddedNumber","hasMarker","lastMarkerLine","markerLine","Array","isArray","markerSpacing","replace","numberOfMarkers","repeat","join","reset","_default","colNumber","process","emitWarning","deprecationError","Error","name","console","warn","location"],"sources":["../src/index.ts"],"sourcesContent":["import highlight, { shouldHighlight } from \"@babel/highlight\";\n\nimport _chalk from \"chalk\";\nconst chalk = _chalk as unknown as typeof import(\"chalk-BABEL_8_BREAKING-true\");\ntype Chalk =\n typeof import(\"chalk-BABEL_8_BREAKING-true\").Instance extends new () => infer R\n ? R\n : never;\n\nlet chalkWithForcedColor: Chalk = undefined;\nfunction getChalk(forceColor: boolean) {\n if (forceColor) {\n chalkWithForcedColor ??= process.env.BABEL_8_BREAKING\n ? new chalk.Instance({ level: 1 })\n : // @ts-expect-error .Instance was .constructor in chalk 2\n new chalk.constructor({ enabled: true, level: 1 });\n return chalkWithForcedColor;\n }\n return chalk;\n}\n\nlet deprecationWarningShown = false;\n\ntype Location = {\n column: number;\n line: number;\n};\n\ntype NodeLocation = {\n end?: Location;\n start: Location;\n};\n\nexport interface Options {\n /** Syntax highlight the code as JavaScript for terminals. default: false */\n highlightCode?: boolean;\n /** The number of lines to show above the error. default: 2 */\n linesAbove?: number;\n /** The number of lines to show below the error. default: 3 */\n linesBelow?: number;\n /**\n * Forcibly syntax highlight the code as JavaScript (for non-terminals);\n * overrides highlightCode.\n * default: false\n */\n forceColor?: boolean;\n /**\n * Pass in a string to be displayed inline (if possible) next to the\n * highlighted location in the code. If it can't be positioned inline,\n * it will be placed above the code frame.\n * default: nothing\n */\n message?: string;\n}\n\n/**\n * Chalk styles for code frame token types.\n */\nfunction getDefs(chalk: Chalk) {\n return {\n gutter: chalk.grey,\n marker: chalk.red.bold,\n message: chalk.red.bold,\n };\n}\n\n/**\n * RegExp to test for newlines in terminal.\n */\n\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\n\n/**\n * Extract what lines should be marked and highlighted.\n */\n\ntype MarkerLines = Record<number, true | [number, number]>;\n\nfunction getMarkerLines(\n loc: NodeLocation,\n source: Array<string>,\n opts: Options,\n): {\n start: number;\n end: number;\n markerLines: MarkerLines;\n} {\n const startLoc: Location = {\n column: 0,\n line: -1,\n ...loc.start,\n };\n const endLoc: Location = {\n ...startLoc,\n ...loc.end,\n };\n const { linesAbove = 2, linesBelow = 3 } = opts || {};\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines: MarkerLines = {};\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine;\n\n if (!startColumn) {\n markerLines[lineNumber] = true;\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1].length;\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - i].length;\n\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else {\n if (startColumn === endColumn) {\n if (startColumn) {\n markerLines[startLine] = [startColumn, 0];\n } else {\n markerLines[startLine] = true;\n }\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn];\n }\n }\n\n return { start, end, markerLines };\n}\n\nexport function codeFrameColumns(\n rawLines: string,\n loc: NodeLocation,\n opts: Options = {},\n): string {\n const highlighted =\n (opts.highlightCode || opts.forceColor) && shouldHighlight(opts);\n const chalk = getChalk(opts.forceColor);\n const defs = getDefs(chalk);\n const maybeHighlight = (chalkFn: Chalk, string: string) => {\n return highlighted ? chalkFn(string) : string;\n };\n const lines = rawLines.split(NEWLINE);\n const { start, end, markerLines } = getMarkerLines(loc, lines, opts);\n const hasColumns = loc.start && typeof loc.start.column === \"number\";\n\n const numberMaxWidth = String(end).length;\n\n const highlightedLines = highlighted ? highlight(rawLines, opts) : rawLines;\n\n let frame = highlightedLines\n .split(NEWLINE, end)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const gutter = ` ${paddedNumber} |`;\n const hasMarker = markerLines[number];\n const lastMarkerLine = !markerLines[number + 1];\n if (hasMarker) {\n let markerLine = \"\";\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line\n .slice(0, Math.max(hasMarker[0] - 1, 0))\n .replace(/[^\\t]/g, \" \");\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\n \"\\n \",\n maybeHighlight(defs.gutter, gutter.replace(/\\d/g, \" \")),\n \" \",\n markerSpacing,\n maybeHighlight(defs.marker, \"^\").repeat(numberOfMarkers),\n ].join(\"\");\n\n if (lastMarkerLine && opts.message) {\n markerLine += \" \" + maybeHighlight(defs.message, opts.message);\n }\n }\n return [\n maybeHighlight(defs.marker, \">\"),\n maybeHighlight(defs.gutter, gutter),\n line.length > 0 ? ` ${line}` : \"\",\n markerLine,\n ].join(\"\");\n } else {\n return ` ${maybeHighlight(defs.gutter, gutter)}${\n line.length > 0 ? ` ${line}` : \"\"\n }`;\n }\n })\n .join(\"\\n\");\n\n if (opts.message && !hasColumns) {\n frame = `${\" \".repeat(numberMaxWidth + 1)}${opts.message}\\n${frame}`;\n }\n\n if (highlighted) {\n return chalk.reset(frame);\n } else {\n return frame;\n }\n}\n\n/**\n * Create a code frame, adding line numbers, code highlighting, and pointing to a given position.\n */\n\nexport default function (\n rawLines: string,\n lineNumber: number,\n colNumber?: number | null,\n opts: Options = {},\n): string {\n if (!deprecationWarningShown) {\n deprecationWarningShown = true;\n\n const message =\n \"Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.\";\n\n if (process.emitWarning) {\n // A string is directly supplied to emitWarning, because when supplying an\n // Error object node throws in the tests because of different contexts\n process.emitWarning(message, \"DeprecationWarning\");\n } else {\n const deprecationError = new Error(message);\n deprecationError.name = \"DeprecationWarning\";\n console.warn(new Error(message));\n }\n }\n\n colNumber = Math.max(colNumber, 0);\n\n const location: NodeLocation = {\n start: { column: colNumber, line: lineNumber },\n };\n\n return codeFrameColumns(rawLines, location, opts);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,MAAME,KAAK,GAAGC,OAAiE;AAM/E,IAAIC,oBAA2B,GAAGC,SAAS;AAC3C,SAASC,QAAQA,CAACC,UAAmB,EAAE;EACrC,IAAIA,UAAU,EAAE;IAAA,IAAAC,qBAAA;IACd,CAAAA,qBAAA,GAAAJ,oBAAoB,YAAA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SAAS,GAAG3C,IAAI,CAACC,GAAG,CAAC0C,SAAS,EAAE,CAAC,CAAC;EAElC,MAAMQ,QAAsB,GAAG;IAC7B5D,KAAK,EAAE;MAAEF,MAAM,EAAEsD,SAAS;MAAErD,IAAI,EAAEiB;IAAW;EAC/C,CAAC;EAED,OAAOE,gBAAgB,CAACC,QAAQ,EAAEyC,QAAQ,EAAElE,IAAI,CAAC;AACnD"}
@@ -0,0 +1,165 @@
1
+ 'use strict';
2
+ const colorConvert = require('color-convert');
3
+
4
+ const wrapAnsi16 = (fn, offset) => function () {
5
+ const code = fn.apply(colorConvert, arguments);
6
+ return `\u001B[${code + offset}m`;
7
+ };
8
+
9
+ const wrapAnsi256 = (fn, offset) => function () {
10
+ const code = fn.apply(colorConvert, arguments);
11
+ return `\u001B[${38 + offset};5;${code}m`;
12
+ };
13
+
14
+ const wrapAnsi16m = (fn, offset) => function () {
15
+ const rgb = fn.apply(colorConvert, arguments);
16
+ return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
17
+ };
18
+
19
+ function assembleStyles() {
20
+ const codes = new Map();
21
+ const styles = {
22
+ modifier: {
23
+ reset: [0, 0],
24
+ // 21 isn't widely supported and 22 does the same thing
25
+ bold: [1, 22],
26
+ dim: [2, 22],
27
+ italic: [3, 23],
28
+ underline: [4, 24],
29
+ inverse: [7, 27],
30
+ hidden: [8, 28],
31
+ strikethrough: [9, 29]
32
+ },
33
+ color: {
34
+ black: [30, 39],
35
+ red: [31, 39],
36
+ green: [32, 39],
37
+ yellow: [33, 39],
38
+ blue: [34, 39],
39
+ magenta: [35, 39],
40
+ cyan: [36, 39],
41
+ white: [37, 39],
42
+ gray: [90, 39],
43
+
44
+ // Bright color
45
+ redBright: [91, 39],
46
+ greenBright: [92, 39],
47
+ yellowBright: [93, 39],
48
+ blueBright: [94, 39],
49
+ magentaBright: [95, 39],
50
+ cyanBright: [96, 39],
51
+ whiteBright: [97, 39]
52
+ },
53
+ bgColor: {
54
+ bgBlack: [40, 49],
55
+ bgRed: [41, 49],
56
+ bgGreen: [42, 49],
57
+ bgYellow: [43, 49],
58
+ bgBlue: [44, 49],
59
+ bgMagenta: [45, 49],
60
+ bgCyan: [46, 49],
61
+ bgWhite: [47, 49],
62
+
63
+ // Bright color
64
+ bgBlackBright: [100, 49],
65
+ bgRedBright: [101, 49],
66
+ bgGreenBright: [102, 49],
67
+ bgYellowBright: [103, 49],
68
+ bgBlueBright: [104, 49],
69
+ bgMagentaBright: [105, 49],
70
+ bgCyanBright: [106, 49],
71
+ bgWhiteBright: [107, 49]
72
+ }
73
+ };
74
+
75
+ // Fix humans
76
+ styles.color.grey = styles.color.gray;
77
+
78
+ for (const groupName of Object.keys(styles)) {
79
+ const group = styles[groupName];
80
+
81
+ for (const styleName of Object.keys(group)) {
82
+ const style = group[styleName];
83
+
84
+ styles[styleName] = {
85
+ open: `\u001B[${style[0]}m`,
86
+ close: `\u001B[${style[1]}m`
87
+ };
88
+
89
+ group[styleName] = styles[styleName];
90
+
91
+ codes.set(style[0], style[1]);
92
+ }
93
+
94
+ Object.defineProperty(styles, groupName, {
95
+ value: group,
96
+ enumerable: false
97
+ });
98
+
99
+ Object.defineProperty(styles, 'codes', {
100
+ value: codes,
101
+ enumerable: false
102
+ });
103
+ }
104
+
105
+ const ansi2ansi = n => n;
106
+ const rgb2rgb = (r, g, b) => [r, g, b];
107
+
108
+ styles.color.close = '\u001B[39m';
109
+ styles.bgColor.close = '\u001B[49m';
110
+
111
+ styles.color.ansi = {
112
+ ansi: wrapAnsi16(ansi2ansi, 0)
113
+ };
114
+ styles.color.ansi256 = {
115
+ ansi256: wrapAnsi256(ansi2ansi, 0)
116
+ };
117
+ styles.color.ansi16m = {
118
+ rgb: wrapAnsi16m(rgb2rgb, 0)
119
+ };
120
+
121
+ styles.bgColor.ansi = {
122
+ ansi: wrapAnsi16(ansi2ansi, 10)
123
+ };
124
+ styles.bgColor.ansi256 = {
125
+ ansi256: wrapAnsi256(ansi2ansi, 10)
126
+ };
127
+ styles.bgColor.ansi16m = {
128
+ rgb: wrapAnsi16m(rgb2rgb, 10)
129
+ };
130
+
131
+ for (let key of Object.keys(colorConvert)) {
132
+ if (typeof colorConvert[key] !== 'object') {
133
+ continue;
134
+ }
135
+
136
+ const suite = colorConvert[key];
137
+
138
+ if (key === 'ansi16') {
139
+ key = 'ansi';
140
+ }
141
+
142
+ if ('ansi16' in suite) {
143
+ styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
144
+ styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
145
+ }
146
+
147
+ if ('ansi256' in suite) {
148
+ styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
149
+ styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
150
+ }
151
+
152
+ if ('rgb' in suite) {
153
+ styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
154
+ styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
155
+ }
156
+ }
157
+
158
+ return styles;
159
+ }
160
+
161
+ // Make the export immutable
162
+ Object.defineProperty(module, 'exports', {
163
+ enumerable: true,
164
+ get: assembleStyles
165
+ });
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "ansi-styles",
3
+ "version": "3.2.1",
4
+ "description": "ANSI escape codes for styling strings in the terminal",
5
+ "license": "MIT",
6
+ "repository": "chalk/ansi-styles",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=4"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && ava",
17
+ "screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
18
+ },
19
+ "files": [
20
+ "index.js"
21
+ ],
22
+ "keywords": [
23
+ "ansi",
24
+ "styles",
25
+ "color",
26
+ "colour",
27
+ "colors",
28
+ "terminal",
29
+ "console",
30
+ "cli",
31
+ "string",
32
+ "tty",
33
+ "escape",
34
+ "formatting",
35
+ "rgb",
36
+ "256",
37
+ "shell",
38
+ "xterm",
39
+ "log",
40
+ "logging",
41
+ "command-line",
42
+ "text"
43
+ ],
44
+ "dependencies": {
45
+ "color-convert": "^1.9.0"
46
+ },
47
+ "devDependencies": {
48
+ "ava": "*",
49
+ "babel-polyfill": "^6.23.0",
50
+ "svg-term-cli": "^2.1.1",
51
+ "xo": "*"
52
+ },
53
+ "ava": {
54
+ "require": "babel-polyfill"
55
+ }
56
+ }
@@ -0,0 +1,147 @@
1
+ # ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
2
+
3
+ > [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
4
+
5
+ You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
6
+
7
+ <img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
8
+
9
+
10
+ ## Install
11
+
12
+ ```
13
+ $ npm install ansi-styles
14
+ ```
15
+
16
+
17
+ ## Usage
18
+
19
+ ```js
20
+ const style = require('ansi-styles');
21
+
22
+ console.log(`${style.green.open}Hello world!${style.green.close}`);
23
+
24
+
25
+ // Color conversion between 16/256/truecolor
26
+ // NOTE: If conversion goes to 16 colors or 256 colors, the original color
27
+ // may be degraded to fit that color palette. This means terminals
28
+ // that do not support 16 million colors will best-match the
29
+ // original color.
30
+ console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
31
+ console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
32
+ console.log(style.color.ansi16m.hex('#ABCDEF') + 'Hello world!' + style.color.close);
33
+ ```
34
+
35
+ ## API
36
+
37
+ Each style has an `open` and `close` property.
38
+
39
+
40
+ ## Styles
41
+
42
+ ### Modifiers
43
+
44
+ - `reset`
45
+ - `bold`
46
+ - `dim`
47
+ - `italic` *(Not widely supported)*
48
+ - `underline`
49
+ - `inverse`
50
+ - `hidden`
51
+ - `strikethrough` *(Not widely supported)*
52
+
53
+ ### Colors
54
+
55
+ - `black`
56
+ - `red`
57
+ - `green`
58
+ - `yellow`
59
+ - `blue`
60
+ - `magenta`
61
+ - `cyan`
62
+ - `white`
63
+ - `gray` ("bright black")
64
+ - `redBright`
65
+ - `greenBright`
66
+ - `yellowBright`
67
+ - `blueBright`
68
+ - `magentaBright`
69
+ - `cyanBright`
70
+ - `whiteBright`
71
+
72
+ ### Background colors
73
+
74
+ - `bgBlack`
75
+ - `bgRed`
76
+ - `bgGreen`
77
+ - `bgYellow`
78
+ - `bgBlue`
79
+ - `bgMagenta`
80
+ - `bgCyan`
81
+ - `bgWhite`
82
+ - `bgBlackBright`
83
+ - `bgRedBright`
84
+ - `bgGreenBright`
85
+ - `bgYellowBright`
86
+ - `bgBlueBright`
87
+ - `bgMagentaBright`
88
+ - `bgCyanBright`
89
+ - `bgWhiteBright`
90
+
91
+
92
+ ## Advanced usage
93
+
94
+ By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
95
+
96
+ - `style.modifier`
97
+ - `style.color`
98
+ - `style.bgColor`
99
+
100
+ ###### Example
101
+
102
+ ```js
103
+ console.log(style.color.green.open);
104
+ ```
105
+
106
+ Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
107
+
108
+ ###### Example
109
+
110
+ ```js
111
+ console.log(style.codes.get(36));
112
+ //=> 39
113
+ ```
114
+
115
+
116
+ ## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
117
+
118
+ `ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
119
+
120
+ To use these, call the associated conversion function with the intended output, for example:
121
+
122
+ ```js
123
+ style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
124
+ style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
125
+
126
+ style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
127
+ style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
128
+
129
+ style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
130
+ style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
131
+ ```
132
+
133
+
134
+ ## Related
135
+
136
+ - [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
137
+
138
+
139
+ ## Maintainers
140
+
141
+ - [Sindre Sorhus](https://github.com/sindresorhus)
142
+ - [Josh Junon](https://github.com/qix-)
143
+
144
+
145
+ ## License
146
+
147
+ MIT
@@ -0,0 +1,228 @@
1
+ 'use strict';
2
+ const escapeStringRegexp = require('escape-string-regexp');
3
+ const ansiStyles = require('ansi-styles');
4
+ const stdoutColor = require('supports-color').stdout;
5
+
6
+ const template = require('./templates.js');
7
+
8
+ const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
9
+
10
+ // `supportsColor.level` → `ansiStyles.color[name]` mapping
11
+ const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
12
+
13
+ // `color-convert` models to exclude from the Chalk API due to conflicts and such
14
+ const skipModels = new Set(['gray']);
15
+
16
+ const styles = Object.create(null);
17
+
18
+ function applyOptions(obj, options) {
19
+ options = options || {};
20
+
21
+ // Detect level if not set manually
22
+ const scLevel = stdoutColor ? stdoutColor.level : 0;
23
+ obj.level = options.level === undefined ? scLevel : options.level;
24
+ obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
25
+ }
26
+
27
+ function Chalk(options) {
28
+ // We check for this.template here since calling `chalk.constructor()`
29
+ // by itself will have a `this` of a previously constructed chalk object
30
+ if (!this || !(this instanceof Chalk) || this.template) {
31
+ const chalk = {};
32
+ applyOptions(chalk, options);
33
+
34
+ chalk.template = function () {
35
+ const args = [].slice.call(arguments);
36
+ return chalkTag.apply(null, [chalk.template].concat(args));
37
+ };
38
+
39
+ Object.setPrototypeOf(chalk, Chalk.prototype);
40
+ Object.setPrototypeOf(chalk.template, chalk);
41
+
42
+ chalk.template.constructor = Chalk;
43
+
44
+ return chalk.template;
45
+ }
46
+
47
+ applyOptions(this, options);
48
+ }
49
+
50
+ // Use bright blue on Windows as the normal blue color is illegible
51
+ if (isSimpleWindowsTerm) {
52
+ ansiStyles.blue.open = '\u001B[94m';
53
+ }
54
+
55
+ for (const key of Object.keys(ansiStyles)) {
56
+ ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
57
+
58
+ styles[key] = {
59
+ get() {
60
+ const codes = ansiStyles[key];
61
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
62
+ }
63
+ };
64
+ }
65
+
66
+ styles.visible = {
67
+ get() {
68
+ return build.call(this, this._styles || [], true, 'visible');
69
+ }
70
+ };
71
+
72
+ ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
73
+ for (const model of Object.keys(ansiStyles.color.ansi)) {
74
+ if (skipModels.has(model)) {
75
+ continue;
76
+ }
77
+
78
+ styles[model] = {
79
+ get() {
80
+ const level = this.level;
81
+ return function () {
82
+ const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
83
+ const codes = {
84
+ open,
85
+ close: ansiStyles.color.close,
86
+ closeRe: ansiStyles.color.closeRe
87
+ };
88
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
89
+ };
90
+ }
91
+ };
92
+ }
93
+
94
+ ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
95
+ for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
96
+ if (skipModels.has(model)) {
97
+ continue;
98
+ }
99
+
100
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
101
+ styles[bgModel] = {
102
+ get() {
103
+ const level = this.level;
104
+ return function () {
105
+ const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
106
+ const codes = {
107
+ open,
108
+ close: ansiStyles.bgColor.close,
109
+ closeRe: ansiStyles.bgColor.closeRe
110
+ };
111
+ return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
112
+ };
113
+ }
114
+ };
115
+ }
116
+
117
+ const proto = Object.defineProperties(() => {}, styles);
118
+
119
+ function build(_styles, _empty, key) {
120
+ const builder = function () {
121
+ return applyStyle.apply(builder, arguments);
122
+ };
123
+
124
+ builder._styles = _styles;
125
+ builder._empty = _empty;
126
+
127
+ const self = this;
128
+
129
+ Object.defineProperty(builder, 'level', {
130
+ enumerable: true,
131
+ get() {
132
+ return self.level;
133
+ },
134
+ set(level) {
135
+ self.level = level;
136
+ }
137
+ });
138
+
139
+ Object.defineProperty(builder, 'enabled', {
140
+ enumerable: true,
141
+ get() {
142
+ return self.enabled;
143
+ },
144
+ set(enabled) {
145
+ self.enabled = enabled;
146
+ }
147
+ });
148
+
149
+ // See below for fix regarding invisible grey/dim combination on Windows
150
+ builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
151
+
152
+ // `__proto__` is used because we must return a function, but there is
153
+ // no way to create a function with a different prototype
154
+ builder.__proto__ = proto; // eslint-disable-line no-proto
155
+
156
+ return builder;
157
+ }
158
+
159
+ function applyStyle() {
160
+ // Support varags, but simply cast to string in case there's only one arg
161
+ const args = arguments;
162
+ const argsLen = args.length;
163
+ let str = String(arguments[0]);
164
+
165
+ if (argsLen === 0) {
166
+ return '';
167
+ }
168
+
169
+ if (argsLen > 1) {
170
+ // Don't slice `arguments`, it prevents V8 optimizations
171
+ for (let a = 1; a < argsLen; a++) {
172
+ str += ' ' + args[a];
173
+ }
174
+ }
175
+
176
+ if (!this.enabled || this.level <= 0 || !str) {
177
+ return this._empty ? '' : str;
178
+ }
179
+
180
+ // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
181
+ // see https://github.com/chalk/chalk/issues/58
182
+ // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
183
+ const originalDim = ansiStyles.dim.open;
184
+ if (isSimpleWindowsTerm && this.hasGrey) {
185
+ ansiStyles.dim.open = '';
186
+ }
187
+
188
+ for (const code of this._styles.slice().reverse()) {
189
+ // Replace any instances already present with a re-opening code
190
+ // otherwise only the part of the string until said closing code
191
+ // will be colored, and the rest will simply be 'plain'.
192
+ str = code.open + str.replace(code.closeRe, code.open) + code.close;
193
+
194
+ // Close the styling before a linebreak and reopen
195
+ // after next line to fix a bleed issue on macOS
196
+ // https://github.com/chalk/chalk/pull/92
197
+ str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
198
+ }
199
+
200
+ // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
201
+ ansiStyles.dim.open = originalDim;
202
+
203
+ return str;
204
+ }
205
+
206
+ function chalkTag(chalk, strings) {
207
+ if (!Array.isArray(strings)) {
208
+ // If chalk() was called by itself or with a string,
209
+ // return the string itself as a string.
210
+ return [].slice.call(arguments, 1).join(' ');
211
+ }
212
+
213
+ const args = [].slice.call(arguments, 2);
214
+ const parts = [strings.raw[0]];
215
+
216
+ for (let i = 1; i < strings.length; i++) {
217
+ parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
218
+ parts.push(String(strings.raw[i]));
219
+ }
220
+
221
+ return template(chalk, parts.join(''));
222
+ }
223
+
224
+ Object.defineProperties(Chalk.prototype, styles);
225
+
226
+ module.exports = Chalk(); // eslint-disable-line new-cap
227
+ module.exports.supportsColor = stdoutColor;
228
+ module.exports.default = module.exports; // For TypeScript