summaryrefslogtreecommitdiff
path: root/node_modules/@babel/code-frame/lib/index.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-05-14 14:05:49 +0800
commit06823fbf1c2e763a5bf76c3990ca98fbbcd98691 (patch)
tree4280bece3888d12a022093bf1a9cd1b049393602 /node_modules/@babel/code-frame/lib/index.js
parent1368909b3cd552dbb0d12d5863c597f5be46177d (diff)
updated node_modules
Diffstat (limited to 'node_modules/@babel/code-frame/lib/index.js')
-rw-r--r--node_modules/@babel/code-frame/lib/index.js37
1 files changed, 18 insertions, 19 deletions
diff --git a/node_modules/@babel/code-frame/lib/index.js b/node_modules/@babel/code-frame/lib/index.js
index 2f900eba..85ef5d6c 100644
--- a/node_modules/@babel/code-frame/lib/index.js
+++ b/node_modules/@babel/code-frame/lib/index.js
@@ -6,27 +6,26 @@ Object.defineProperty(exports, "__esModule", {
exports.codeFrameColumns = codeFrameColumns;
exports.default = _default;
var _highlight = require("@babel/highlight");
-var _chalk = _interopRequireWildcard(require("chalk"), true);
+var _picocolors = _interopRequireWildcard(require("picocolors"), true);
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
-let chalkWithForcedColor = undefined;
-function getChalk(forceColor) {
+const colors = typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? (0, _picocolors.createColors)(false) : _picocolors.default;
+const compose = (f, g) => v => f(g(v));
+let pcWithForcedColor = undefined;
+function getColors(forceColor) {
if (forceColor) {
- var _chalkWithForcedColor;
- (_chalkWithForcedColor = chalkWithForcedColor) != null ? _chalkWithForcedColor : chalkWithForcedColor = new _chalk.default.constructor({
- enabled: true,
- level: 1
- });
- return chalkWithForcedColor;
+ var _pcWithForcedColor;
+ (_pcWithForcedColor = pcWithForcedColor) != null ? _pcWithForcedColor : pcWithForcedColor = (0, _picocolors.createColors)(true);
+ return pcWithForcedColor;
}
- return _chalk.default;
+ return colors;
}
let deprecationWarningShown = false;
-function getDefs(chalk) {
+function getDefs(colors) {
return {
- gutter: chalk.grey,
- marker: chalk.red.bold,
- message: chalk.red.bold
+ gutter: colors.gray,
+ marker: compose(colors.red, colors.bold),
+ message: compose(colors.red, colors.bold)
};
}
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
@@ -88,10 +87,10 @@ function getMarkerLines(loc, source, opts) {
}
function codeFrameColumns(rawLines, loc, opts = {}) {
const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
- const chalk = getChalk(opts.forceColor);
- const defs = getDefs(chalk);
- const maybeHighlight = (chalkFn, string) => {
- return highlighted ? chalkFn(string) : string;
+ const colors = getColors(opts.forceColor);
+ const defs = getDefs(colors);
+ const maybeHighlight = (fmt, string) => {
+ return highlighted ? fmt(string) : string;
};
const lines = rawLines.split(NEWLINE);
const {
@@ -127,7 +126,7 @@ function codeFrameColumns(rawLines, loc, opts = {}) {
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
}
if (highlighted) {
- return chalk.reset(frame);
+ return colors.reset(frame);
} else {
return frame;
}