Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/@babel/code-frame/lib/index.js

    rd565449 r0c6b92a  
    1 "use strict";
    2 
    3 Object.defineProperty(exports, "__esModule", {
    4   value: true
    5 });
    6 exports.codeFrameColumns = codeFrameColumns;
    7 exports.default = _default;
    8 var _highlight = require("@babel/highlight");
    9 var _picocolors = _interopRequireWildcard(require("picocolors"), true);
    10 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); }
    11 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 && {}.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; }
    12 const colors = typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? (0, _picocolors.createColors)(false) : _picocolors.default;
     1'use strict';
     2
     3Object.defineProperty(exports, '__esModule', { value: true });
     4
     5var picocolors = require('picocolors');
     6var jsTokens = require('js-tokens');
     7var helperValidatorIdentifier = require('@babel/helper-validator-identifier');
     8
     9function isColorSupported() {
     10  return (typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported
     11  );
     12}
    1313const compose = (f, g) => v => f(g(v));
    14 let pcWithForcedColor = undefined;
    15 function getColors(forceColor) {
    16   if (forceColor) {
    17     var _pcWithForcedColor;
    18     (_pcWithForcedColor = pcWithForcedColor) != null ? _pcWithForcedColor : pcWithForcedColor = (0, _picocolors.createColors)(true);
    19     return pcWithForcedColor;
    20   }
    21   return colors;
    22 }
    23 let deprecationWarningShown = false;
    24 function getDefs(colors) {
     14function buildDefs(colors) {
    2515  return {
     16    keyword: colors.cyan,
     17    capitalized: colors.yellow,
     18    jsxIdentifier: colors.yellow,
     19    punctuator: colors.yellow,
     20    number: colors.magenta,
     21    string: colors.green,
     22    regex: colors.magenta,
     23    comment: colors.gray,
     24    invalid: compose(compose(colors.white, colors.bgRed), colors.bold),
    2625    gutter: colors.gray,
    2726    marker: compose(colors.red, colors.bold),
    28     message: compose(colors.red, colors.bold)
    29   };
    30 }
     27    message: compose(colors.red, colors.bold),
     28    reset: colors.reset
     29  };
     30}
     31const defsOn = buildDefs(picocolors.createColors(true));
     32const defsOff = buildDefs(picocolors.createColors(false));
     33function getDefs(enabled) {
     34  return enabled ? defsOn : defsOff;
     35}
     36
     37const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
     38const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
     39const BRACKET = /^[()[\]{}]$/;
     40let tokenize;
     41{
     42  const JSX_TAG = /^[a-z][\w-]*$/i;
     43  const getTokenType = function (token, offset, text) {
     44    if (token.type === "name") {
     45      if (helperValidatorIdentifier.isKeyword(token.value) || helperValidatorIdentifier.isStrictReservedWord(token.value, true) || sometimesKeywords.has(token.value)) {
     46        return "keyword";
     47      }
     48      if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
     49        return "jsxIdentifier";
     50      }
     51      if (token.value[0] !== token.value[0].toLowerCase()) {
     52        return "capitalized";
     53      }
     54    }
     55    if (token.type === "punctuator" && BRACKET.test(token.value)) {
     56      return "bracket";
     57    }
     58    if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
     59      return "punctuator";
     60    }
     61    return token.type;
     62  };
     63  tokenize = function* (text) {
     64    let match;
     65    while (match = jsTokens.default.exec(text)) {
     66      const token = jsTokens.matchToToken(match);
     67      yield {
     68        type: getTokenType(token, match.index, text),
     69        value: token.value
     70      };
     71    }
     72  };
     73}
     74function highlight(text) {
     75  if (text === "") return "";
     76  const defs = getDefs(true);
     77  let highlighted = "";
     78  for (const {
     79    type,
     80    value
     81  } of tokenize(text)) {
     82    if (type in defs) {
     83      highlighted += value.split(NEWLINE$1).map(str => defs[type](str)).join("\n");
     84    } else {
     85      highlighted += value;
     86    }
     87  }
     88  return highlighted;
     89}
     90
     91let deprecationWarningShown = false;
    3192const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
    3293function getMarkerLines(loc, source, opts) {
     
    87148}
    88149function codeFrameColumns(rawLines, loc, opts = {}) {
    89   const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
    90   const colors = getColors(opts.forceColor);
    91   const defs = getDefs(colors);
    92   const maybeHighlight = (fmt, string) => {
    93     return highlighted ? fmt(string) : string;
    94   };
     150  const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
     151  const defs = getDefs(shouldHighlight);
    95152  const lines = rawLines.split(NEWLINE);
    96153  const {
     
    101158  const hasColumns = loc.start && typeof loc.start.column === "number";
    102159  const numberMaxWidth = String(end).length;
    103   const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines;
     160  const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
    104161  let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
    105162    const number = start + 1 + index;
     
    113170        const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
    114171        const numberOfMarkers = hasMarker[1] || 1;
    115         markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), " ", markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
     172        markerLine = ["\n ", defs.gutter(gutter.replace(/\d/g, " ")), " ", markerSpacing, defs.marker("^").repeat(numberOfMarkers)].join("");
    116173        if (lastMarkerLine && opts.message) {
    117           markerLine += " " + maybeHighlight(defs.message, opts.message);
     174          markerLine += " " + defs.message(opts.message);
    118175        }
    119176      }
    120       return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
    121     } else {
    122       return ` ${maybeHighlight(defs.gutter, gutter)}${line.length > 0 ? ` ${line}` : ""}`;
     177      return [defs.marker(">"), defs.gutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
     178    } else {
     179      return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
    123180    }
    124181  }).join("\n");
     
    126183    frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
    127184  }
    128   if (highlighted) {
    129     return colors.reset(frame);
     185  if (shouldHighlight) {
     186    return defs.reset(frame);
    130187  } else {
    131188    return frame;
    132189  }
    133190}
    134 function _default(rawLines, lineNumber, colNumber, opts = {}) {
     191function index (rawLines, lineNumber, colNumber, opts = {}) {
    135192  if (!deprecationWarningShown) {
    136193    deprecationWarningShown = true;
     
    154211}
    155212
     213exports.codeFrameColumns = codeFrameColumns;
     214exports.default = index;
     215exports.highlight = highlight;
    156216//# sourceMappingURL=index.js.map
Note: See TracChangeset for help on using the changeset viewer.