mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-11-25 17:06:52 +01:00
3252 lines
No EOL
101 KiB
JavaScript
3252 lines
No EOL
101 KiB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
module.exports = factory();
|
|
else if(typeof define === 'function' && define.amd)
|
|
define([], factory);
|
|
else if(typeof exports === 'object')
|
|
exports["prettyFormat"] = factory();
|
|
else
|
|
root["prettyFormat"] = factory();
|
|
})(window, function() {
|
|
return /******/ (function(modules) { // webpackBootstrap
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/
|
|
/******/ // Check if module is in cache
|
|
/******/ if(installedModules[moduleId]) {
|
|
/******/ return installedModules[moduleId].exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = installedModules[moduleId] = {
|
|
/******/ i: moduleId,
|
|
/******/ l: false,
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
/******/ __webpack_require__.m = modules;
|
|
/******/
|
|
/******/ // expose the module cache
|
|
/******/ __webpack_require__.c = installedModules;
|
|
/******/
|
|
/******/ // define getter function for harmony exports
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
/******/ }
|
|
/******/ };
|
|
/******/
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/
|
|
/******/ // create a fake namespace object
|
|
/******/ // mode & 1: value is a module id, require it
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
/******/ // mode & 4: return value when already ns object
|
|
/******/ // mode & 8|1: behave like require
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
/******/ if(mode & 8) return value;
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
/******/ var ns = Object.create(null);
|
|
/******/ __webpack_require__.r(ns);
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
/******/ return ns;
|
|
/******/ };
|
|
/******/
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
/******/ __webpack_require__.n = function(module) {
|
|
/******/ var getter = module && module.__esModule ?
|
|
/******/ function getDefault() { return module['default']; } :
|
|
/******/ function getModuleExports() { return module; };
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
/******/ return getter;
|
|
/******/ };
|
|
/******/
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
/******/
|
|
/******/ // __webpack_public_path__
|
|
/******/ __webpack_require__.p = "";
|
|
/******/
|
|
/******/
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __webpack_require__(__webpack_require__.s = "./packages/pretty-format/src/index.ts");
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ({
|
|
|
|
/***/ "./node_modules/ansi-regex/index.js":
|
|
/*!******************************************!*\
|
|
!*** ./node_modules/ansi-regex/index.js ***!
|
|
\******************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = function () {
|
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
_ref$onlyFirst = _ref.onlyFirst,
|
|
onlyFirst = _ref$onlyFirst === void 0 ? false : _ref$onlyFirst;
|
|
|
|
var pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
|
|
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/ansi-styles/index.js":
|
|
/*!*******************************************!*\
|
|
!*** ./node_modules/ansi-styles/index.js ***!
|
|
\*******************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/* WEBPACK VAR INJECTION */(function(module) {
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
|
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
|
|
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
|
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
|
var wrapAnsi16 = function wrapAnsi16(fn, offset) {
|
|
return function () {
|
|
var code = fn.apply(void 0, arguments);
|
|
return "\x1B[".concat(code + offset, "m");
|
|
};
|
|
};
|
|
|
|
var wrapAnsi256 = function wrapAnsi256(fn, offset) {
|
|
return function () {
|
|
var code = fn.apply(void 0, arguments);
|
|
return "\x1B[".concat(38 + offset, ";5;").concat(code, "m");
|
|
};
|
|
};
|
|
|
|
var wrapAnsi16m = function wrapAnsi16m(fn, offset) {
|
|
return function () {
|
|
var rgb = fn.apply(void 0, arguments);
|
|
return "\x1B[".concat(38 + offset, ";2;").concat(rgb[0], ";").concat(rgb[1], ";").concat(rgb[2], "m");
|
|
};
|
|
};
|
|
|
|
var ansi2ansi = function ansi2ansi(n) {
|
|
return n;
|
|
};
|
|
|
|
var rgb2rgb = function rgb2rgb(r, g, b) {
|
|
return [r, g, b];
|
|
};
|
|
|
|
var setLazyProperty = function setLazyProperty(object, property, _get) {
|
|
Object.defineProperty(object, property, {
|
|
get: function get() {
|
|
var value = _get();
|
|
|
|
Object.defineProperty(object, property, {
|
|
value: value,
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
return value;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
};
|
|
/** @type {typeof import('color-convert')} */
|
|
|
|
|
|
var colorConvert;
|
|
|
|
var makeDynamicStyles = function makeDynamicStyles(wrap, targetSpace, identity, isBackground) {
|
|
if (colorConvert === undefined) {
|
|
colorConvert = __webpack_require__(/*! color-convert */ "./node_modules/ansi-styles/node_modules/color-convert/index.js");
|
|
}
|
|
|
|
var offset = isBackground ? 10 : 0;
|
|
var styles = {};
|
|
|
|
for (var _i = 0, _Object$entries = Object.entries(colorConvert); _i < _Object$entries.length; _i++) {
|
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
sourceSpace = _Object$entries$_i[0],
|
|
suite = _Object$entries$_i[1];
|
|
|
|
var name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
|
|
|
if (sourceSpace === targetSpace) {
|
|
styles[name] = wrap(identity, offset);
|
|
} else if (_typeof(suite) === 'object') {
|
|
styles[name] = wrap(suite[targetSpace], offset);
|
|
}
|
|
}
|
|
|
|
return styles;
|
|
};
|
|
|
|
function assembleStyles() {
|
|
var codes = new Map();
|
|
var styles = {
|
|
modifier: {
|
|
reset: [0, 0],
|
|
// 21 isn't widely supported and 22 does the same thing
|
|
bold: [1, 22],
|
|
dim: [2, 22],
|
|
italic: [3, 23],
|
|
underline: [4, 24],
|
|
inverse: [7, 27],
|
|
hidden: [8, 28],
|
|
strikethrough: [9, 29]
|
|
},
|
|
color: {
|
|
black: [30, 39],
|
|
red: [31, 39],
|
|
green: [32, 39],
|
|
yellow: [33, 39],
|
|
blue: [34, 39],
|
|
magenta: [35, 39],
|
|
cyan: [36, 39],
|
|
white: [37, 39],
|
|
// Bright color
|
|
blackBright: [90, 39],
|
|
redBright: [91, 39],
|
|
greenBright: [92, 39],
|
|
yellowBright: [93, 39],
|
|
blueBright: [94, 39],
|
|
magentaBright: [95, 39],
|
|
cyanBright: [96, 39],
|
|
whiteBright: [97, 39]
|
|
},
|
|
bgColor: {
|
|
bgBlack: [40, 49],
|
|
bgRed: [41, 49],
|
|
bgGreen: [42, 49],
|
|
bgYellow: [43, 49],
|
|
bgBlue: [44, 49],
|
|
bgMagenta: [45, 49],
|
|
bgCyan: [46, 49],
|
|
bgWhite: [47, 49],
|
|
// Bright color
|
|
bgBlackBright: [100, 49],
|
|
bgRedBright: [101, 49],
|
|
bgGreenBright: [102, 49],
|
|
bgYellowBright: [103, 49],
|
|
bgBlueBright: [104, 49],
|
|
bgMagentaBright: [105, 49],
|
|
bgCyanBright: [106, 49],
|
|
bgWhiteBright: [107, 49]
|
|
}
|
|
}; // Alias bright black as gray (and grey)
|
|
|
|
styles.color.gray = styles.color.blackBright;
|
|
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
|
styles.color.grey = styles.color.blackBright;
|
|
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
|
|
|
for (var _i2 = 0, _Object$entries2 = Object.entries(styles); _i2 < _Object$entries2.length; _i2++) {
|
|
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
groupName = _Object$entries2$_i[0],
|
|
group = _Object$entries2$_i[1];
|
|
|
|
for (var _i3 = 0, _Object$entries3 = Object.entries(group); _i3 < _Object$entries3.length; _i3++) {
|
|
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
styleName = _Object$entries3$_i[0],
|
|
style = _Object$entries3$_i[1];
|
|
|
|
styles[styleName] = {
|
|
open: "\x1B[".concat(style[0], "m"),
|
|
close: "\x1B[".concat(style[1], "m")
|
|
};
|
|
group[styleName] = styles[styleName];
|
|
codes.set(style[0], style[1]);
|
|
}
|
|
|
|
Object.defineProperty(styles, groupName, {
|
|
value: group,
|
|
enumerable: false
|
|
});
|
|
}
|
|
|
|
Object.defineProperty(styles, 'codes', {
|
|
value: codes,
|
|
enumerable: false
|
|
});
|
|
styles.color.close = "\x1B[39m";
|
|
styles.bgColor.close = "\x1B[49m";
|
|
setLazyProperty(styles.color, 'ansi', function () {
|
|
return makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false);
|
|
});
|
|
setLazyProperty(styles.color, 'ansi256', function () {
|
|
return makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false);
|
|
});
|
|
setLazyProperty(styles.color, 'ansi16m', function () {
|
|
return makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false);
|
|
});
|
|
setLazyProperty(styles.bgColor, 'ansi', function () {
|
|
return makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true);
|
|
});
|
|
setLazyProperty(styles.bgColor, 'ansi256', function () {
|
|
return makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true);
|
|
});
|
|
setLazyProperty(styles.bgColor, 'ansi16m', function () {
|
|
return makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true);
|
|
});
|
|
return styles;
|
|
} // Make the export immutable
|
|
|
|
|
|
Object.defineProperty(module, 'exports', {
|
|
enumerable: true,
|
|
get: assembleStyles
|
|
});
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/ansi-styles/node_modules/color-convert/conversions.js":
|
|
/*!****************************************************************************!*\
|
|
!*** ./node_modules/ansi-styles/node_modules/color-convert/conversions.js ***!
|
|
\****************************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
|
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
|
|
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
|
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
|
/* MIT license */
|
|
|
|
/* eslint-disable no-mixed-operators */
|
|
var cssKeywords = __webpack_require__(/*! color-name */ "./node_modules/color-name/index.js"); // NOTE: conversions should only return primitive values (i.e. arrays, or
|
|
// values that give correct `typeof` results).
|
|
// do not use box values types (i.e. Number(), String(), etc.)
|
|
|
|
|
|
var reverseKeywords = {};
|
|
|
|
for (var _i = 0, _Object$keys = Object.keys(cssKeywords); _i < _Object$keys.length; _i++) {
|
|
var key = _Object$keys[_i];
|
|
reverseKeywords[cssKeywords[key]] = key;
|
|
}
|
|
|
|
var convert = {
|
|
rgb: {
|
|
channels: 3,
|
|
labels: 'rgb'
|
|
},
|
|
hsl: {
|
|
channels: 3,
|
|
labels: 'hsl'
|
|
},
|
|
hsv: {
|
|
channels: 3,
|
|
labels: 'hsv'
|
|
},
|
|
hwb: {
|
|
channels: 3,
|
|
labels: 'hwb'
|
|
},
|
|
cmyk: {
|
|
channels: 4,
|
|
labels: 'cmyk'
|
|
},
|
|
xyz: {
|
|
channels: 3,
|
|
labels: 'xyz'
|
|
},
|
|
lab: {
|
|
channels: 3,
|
|
labels: 'lab'
|
|
},
|
|
lch: {
|
|
channels: 3,
|
|
labels: 'lch'
|
|
},
|
|
hex: {
|
|
channels: 1,
|
|
labels: ['hex']
|
|
},
|
|
keyword: {
|
|
channels: 1,
|
|
labels: ['keyword']
|
|
},
|
|
ansi16: {
|
|
channels: 1,
|
|
labels: ['ansi16']
|
|
},
|
|
ansi256: {
|
|
channels: 1,
|
|
labels: ['ansi256']
|
|
},
|
|
hcg: {
|
|
channels: 3,
|
|
labels: ['h', 'c', 'g']
|
|
},
|
|
apple: {
|
|
channels: 3,
|
|
labels: ['r16', 'g16', 'b16']
|
|
},
|
|
gray: {
|
|
channels: 1,
|
|
labels: ['gray']
|
|
}
|
|
};
|
|
module.exports = convert; // Hide .channels and .labels properties
|
|
|
|
for (var _i2 = 0, _Object$keys2 = Object.keys(convert); _i2 < _Object$keys2.length; _i2++) {
|
|
var model = _Object$keys2[_i2];
|
|
|
|
if (!('channels' in convert[model])) {
|
|
throw new Error('missing channels property: ' + model);
|
|
}
|
|
|
|
if (!('labels' in convert[model])) {
|
|
throw new Error('missing channel labels property: ' + model);
|
|
}
|
|
|
|
if (convert[model].labels.length !== convert[model].channels) {
|
|
throw new Error('channel and label counts mismatch: ' + model);
|
|
}
|
|
|
|
var _convert$model = convert[model],
|
|
channels = _convert$model.channels,
|
|
labels = _convert$model.labels;
|
|
delete convert[model].channels;
|
|
delete convert[model].labels;
|
|
Object.defineProperty(convert[model], 'channels', {
|
|
value: channels
|
|
});
|
|
Object.defineProperty(convert[model], 'labels', {
|
|
value: labels
|
|
});
|
|
}
|
|
|
|
convert.rgb.hsl = function (rgb) {
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255;
|
|
var min = Math.min(r, g, b);
|
|
var max = Math.max(r, g, b);
|
|
var delta = max - min;
|
|
var h;
|
|
var s;
|
|
|
|
if (max === min) {
|
|
h = 0;
|
|
} else if (r === max) {
|
|
h = (g - b) / delta;
|
|
} else if (g === max) {
|
|
h = 2 + (b - r) / delta;
|
|
} else if (b === max) {
|
|
h = 4 + (r - g) / delta;
|
|
}
|
|
|
|
h = Math.min(h * 60, 360);
|
|
|
|
if (h < 0) {
|
|
h += 360;
|
|
}
|
|
|
|
var l = (min + max) / 2;
|
|
|
|
if (max === min) {
|
|
s = 0;
|
|
} else if (l <= 0.5) {
|
|
s = delta / (max + min);
|
|
} else {
|
|
s = delta / (2 - max - min);
|
|
}
|
|
|
|
return [h, s * 100, l * 100];
|
|
};
|
|
|
|
convert.rgb.hsv = function (rgb) {
|
|
var rdif;
|
|
var gdif;
|
|
var bdif;
|
|
var h;
|
|
var s;
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255;
|
|
var v = Math.max(r, g, b);
|
|
var diff = v - Math.min(r, g, b);
|
|
|
|
var diffc = function diffc(c) {
|
|
return (v - c) / 6 / diff + 1 / 2;
|
|
};
|
|
|
|
if (diff === 0) {
|
|
h = 0;
|
|
s = 0;
|
|
} else {
|
|
s = diff / v;
|
|
rdif = diffc(r);
|
|
gdif = diffc(g);
|
|
bdif = diffc(b);
|
|
|
|
if (r === v) {
|
|
h = bdif - gdif;
|
|
} else if (g === v) {
|
|
h = 1 / 3 + rdif - bdif;
|
|
} else if (b === v) {
|
|
h = 2 / 3 + gdif - rdif;
|
|
}
|
|
|
|
if (h < 0) {
|
|
h += 1;
|
|
} else if (h > 1) {
|
|
h -= 1;
|
|
}
|
|
}
|
|
|
|
return [h * 360, s * 100, v * 100];
|
|
};
|
|
|
|
convert.rgb.hwb = function (rgb) {
|
|
var r = rgb[0];
|
|
var g = rgb[1];
|
|
var b = rgb[2];
|
|
var h = convert.rgb.hsl(rgb)[0];
|
|
var w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
return [h, w * 100, b * 100];
|
|
};
|
|
|
|
convert.rgb.cmyk = function (rgb) {
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255;
|
|
var k = Math.min(1 - r, 1 - g, 1 - b);
|
|
var c = (1 - r - k) / (1 - k) || 0;
|
|
var m = (1 - g - k) / (1 - k) || 0;
|
|
var y = (1 - b - k) / (1 - k) || 0;
|
|
return [c * 100, m * 100, y * 100, k * 100];
|
|
};
|
|
|
|
function comparativeDistance(x, y) {
|
|
/*
|
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
|
*/
|
|
return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
|
|
}
|
|
|
|
convert.rgb.keyword = function (rgb) {
|
|
var reversed = reverseKeywords[rgb];
|
|
|
|
if (reversed) {
|
|
return reversed;
|
|
}
|
|
|
|
var currentClosestDistance = Infinity;
|
|
var currentClosestKeyword;
|
|
|
|
for (var _i3 = 0, _Object$keys3 = Object.keys(cssKeywords); _i3 < _Object$keys3.length; _i3++) {
|
|
var keyword = _Object$keys3[_i3];
|
|
var value = cssKeywords[keyword]; // Compute comparative distance
|
|
|
|
var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
|
|
|
|
if (distance < currentClosestDistance) {
|
|
currentClosestDistance = distance;
|
|
currentClosestKeyword = keyword;
|
|
}
|
|
}
|
|
|
|
return currentClosestKeyword;
|
|
};
|
|
|
|
convert.keyword.rgb = function (keyword) {
|
|
return cssKeywords[keyword];
|
|
};
|
|
|
|
convert.rgb.xyz = function (rgb) {
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255; // Assume sRGB
|
|
|
|
r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
|
g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
|
b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
|
var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
return [x * 100, y * 100, z * 100];
|
|
};
|
|
|
|
convert.rgb.lab = function (rgb) {
|
|
var xyz = convert.rgb.xyz(rgb);
|
|
var x = xyz[0];
|
|
var y = xyz[1];
|
|
var z = xyz[2];
|
|
x /= 95.047;
|
|
y /= 100;
|
|
z /= 108.883;
|
|
x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
|
y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
|
z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
|
var l = 116 * y - 16;
|
|
var a = 500 * (x - y);
|
|
var b = 200 * (y - z);
|
|
return [l, a, b];
|
|
};
|
|
|
|
convert.hsl.rgb = function (hsl) {
|
|
var h = hsl[0] / 360;
|
|
var s = hsl[1] / 100;
|
|
var l = hsl[2] / 100;
|
|
var t2;
|
|
var t3;
|
|
var val;
|
|
|
|
if (s === 0) {
|
|
val = l * 255;
|
|
return [val, val, val];
|
|
}
|
|
|
|
if (l < 0.5) {
|
|
t2 = l * (1 + s);
|
|
} else {
|
|
t2 = l + s - l * s;
|
|
}
|
|
|
|
var t1 = 2 * l - t2;
|
|
var rgb = [0, 0, 0];
|
|
|
|
for (var i = 0; i < 3; i++) {
|
|
t3 = h + 1 / 3 * -(i - 1);
|
|
|
|
if (t3 < 0) {
|
|
t3++;
|
|
}
|
|
|
|
if (t3 > 1) {
|
|
t3--;
|
|
}
|
|
|
|
if (6 * t3 < 1) {
|
|
val = t1 + (t2 - t1) * 6 * t3;
|
|
} else if (2 * t3 < 1) {
|
|
val = t2;
|
|
} else if (3 * t3 < 2) {
|
|
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
} else {
|
|
val = t1;
|
|
}
|
|
|
|
rgb[i] = val * 255;
|
|
}
|
|
|
|
return rgb;
|
|
};
|
|
|
|
convert.hsl.hsv = function (hsl) {
|
|
var h = hsl[0];
|
|
var s = hsl[1] / 100;
|
|
var l = hsl[2] / 100;
|
|
var smin = s;
|
|
var lmin = Math.max(l, 0.01);
|
|
l *= 2;
|
|
s *= l <= 1 ? l : 2 - l;
|
|
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
var v = (l + s) / 2;
|
|
var sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
return [h, sv * 100, v * 100];
|
|
};
|
|
|
|
convert.hsv.rgb = function (hsv) {
|
|
var h = hsv[0] / 60;
|
|
var s = hsv[1] / 100;
|
|
var v = hsv[2] / 100;
|
|
var hi = Math.floor(h) % 6;
|
|
var f = h - Math.floor(h);
|
|
var p = 255 * v * (1 - s);
|
|
var q = 255 * v * (1 - s * f);
|
|
var t = 255 * v * (1 - s * (1 - f));
|
|
v *= 255;
|
|
|
|
switch (hi) {
|
|
case 0:
|
|
return [v, t, p];
|
|
|
|
case 1:
|
|
return [q, v, p];
|
|
|
|
case 2:
|
|
return [p, v, t];
|
|
|
|
case 3:
|
|
return [p, q, v];
|
|
|
|
case 4:
|
|
return [t, p, v];
|
|
|
|
case 5:
|
|
return [v, p, q];
|
|
}
|
|
};
|
|
|
|
convert.hsv.hsl = function (hsv) {
|
|
var h = hsv[0];
|
|
var s = hsv[1] / 100;
|
|
var v = hsv[2] / 100;
|
|
var vmin = Math.max(v, 0.01);
|
|
var sl;
|
|
var l;
|
|
l = (2 - s) * v;
|
|
var lmin = (2 - s) * vmin;
|
|
sl = s * vmin;
|
|
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
sl = sl || 0;
|
|
l /= 2;
|
|
return [h, sl * 100, l * 100];
|
|
}; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
|
|
|
|
|
convert.hwb.rgb = function (hwb) {
|
|
var h = hwb[0] / 360;
|
|
var wh = hwb[1] / 100;
|
|
var bl = hwb[2] / 100;
|
|
var ratio = wh + bl;
|
|
var f; // Wh + bl cant be > 1
|
|
|
|
if (ratio > 1) {
|
|
wh /= ratio;
|
|
bl /= ratio;
|
|
}
|
|
|
|
var i = Math.floor(6 * h);
|
|
var v = 1 - bl;
|
|
f = 6 * h - i;
|
|
|
|
if ((i & 0x01) !== 0) {
|
|
f = 1 - f;
|
|
}
|
|
|
|
var n = wh + f * (v - wh); // Linear interpolation
|
|
|
|
var r;
|
|
var g;
|
|
var b;
|
|
/* eslint-disable max-statements-per-line,no-multi-spaces */
|
|
|
|
switch (i) {
|
|
default:
|
|
case 6:
|
|
case 0:
|
|
r = v;
|
|
g = n;
|
|
b = wh;
|
|
break;
|
|
|
|
case 1:
|
|
r = n;
|
|
g = v;
|
|
b = wh;
|
|
break;
|
|
|
|
case 2:
|
|
r = wh;
|
|
g = v;
|
|
b = n;
|
|
break;
|
|
|
|
case 3:
|
|
r = wh;
|
|
g = n;
|
|
b = v;
|
|
break;
|
|
|
|
case 4:
|
|
r = n;
|
|
g = wh;
|
|
b = v;
|
|
break;
|
|
|
|
case 5:
|
|
r = v;
|
|
g = wh;
|
|
b = n;
|
|
break;
|
|
}
|
|
/* eslint-enable max-statements-per-line,no-multi-spaces */
|
|
|
|
|
|
return [r * 255, g * 255, b * 255];
|
|
};
|
|
|
|
convert.cmyk.rgb = function (cmyk) {
|
|
var c = cmyk[0] / 100;
|
|
var m = cmyk[1] / 100;
|
|
var y = cmyk[2] / 100;
|
|
var k = cmyk[3] / 100;
|
|
var r = 1 - Math.min(1, c * (1 - k) + k);
|
|
var g = 1 - Math.min(1, m * (1 - k) + k);
|
|
var b = 1 - Math.min(1, y * (1 - k) + k);
|
|
return [r * 255, g * 255, b * 255];
|
|
};
|
|
|
|
convert.xyz.rgb = function (xyz) {
|
|
var x = xyz[0] / 100;
|
|
var y = xyz[1] / 100;
|
|
var z = xyz[2] / 100;
|
|
var r;
|
|
var g;
|
|
var b;
|
|
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
b = x * 0.0557 + y * -0.2040 + z * 1.0570; // Assume sRGB
|
|
|
|
r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
|
|
g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
|
|
b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
|
|
r = Math.min(Math.max(0, r), 1);
|
|
g = Math.min(Math.max(0, g), 1);
|
|
b = Math.min(Math.max(0, b), 1);
|
|
return [r * 255, g * 255, b * 255];
|
|
};
|
|
|
|
convert.xyz.lab = function (xyz) {
|
|
var x = xyz[0];
|
|
var y = xyz[1];
|
|
var z = xyz[2];
|
|
x /= 95.047;
|
|
y /= 100;
|
|
z /= 108.883;
|
|
x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
|
y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
|
z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
|
var l = 116 * y - 16;
|
|
var a = 500 * (x - y);
|
|
var b = 200 * (y - z);
|
|
return [l, a, b];
|
|
};
|
|
|
|
convert.lab.xyz = function (lab) {
|
|
var l = lab[0];
|
|
var a = lab[1];
|
|
var b = lab[2];
|
|
var x;
|
|
var y;
|
|
var z;
|
|
y = (l + 16) / 116;
|
|
x = a / 500 + y;
|
|
z = y - b / 200;
|
|
var y2 = Math.pow(y, 3);
|
|
var x2 = Math.pow(x, 3);
|
|
var z2 = Math.pow(z, 3);
|
|
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
|
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
|
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
|
x *= 95.047;
|
|
y *= 100;
|
|
z *= 108.883;
|
|
return [x, y, z];
|
|
};
|
|
|
|
convert.lab.lch = function (lab) {
|
|
var l = lab[0];
|
|
var a = lab[1];
|
|
var b = lab[2];
|
|
var h;
|
|
var hr = Math.atan2(b, a);
|
|
h = hr * 360 / 2 / Math.PI;
|
|
|
|
if (h < 0) {
|
|
h += 360;
|
|
}
|
|
|
|
var c = Math.sqrt(a * a + b * b);
|
|
return [l, c, h];
|
|
};
|
|
|
|
convert.lch.lab = function (lch) {
|
|
var l = lch[0];
|
|
var c = lch[1];
|
|
var h = lch[2];
|
|
var hr = h / 360 * 2 * Math.PI;
|
|
var a = c * Math.cos(hr);
|
|
var b = c * Math.sin(hr);
|
|
return [l, a, b];
|
|
};
|
|
|
|
convert.rgb.ansi16 = function (args) {
|
|
var saturation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
|
|
var _args = _slicedToArray(args, 3),
|
|
r = _args[0],
|
|
g = _args[1],
|
|
b = _args[2];
|
|
|
|
var value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
|
|
|
|
value = Math.round(value / 50);
|
|
|
|
if (value === 0) {
|
|
return 30;
|
|
}
|
|
|
|
var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
|
|
if (value === 2) {
|
|
ansi += 60;
|
|
}
|
|
|
|
return ansi;
|
|
};
|
|
|
|
convert.hsv.ansi16 = function (args) {
|
|
// Optimization here; we already know the value and don't need to get
|
|
// it converted for us.
|
|
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
};
|
|
|
|
convert.rgb.ansi256 = function (args) {
|
|
var r = args[0];
|
|
var g = args[1];
|
|
var b = args[2]; // We use the extended greyscale palette here, with the exception of
|
|
// black and white. normal palette only has 4 greyscale shades.
|
|
|
|
if (r === g && g === b) {
|
|
if (r < 8) {
|
|
return 16;
|
|
}
|
|
|
|
if (r > 248) {
|
|
return 231;
|
|
}
|
|
|
|
return Math.round((r - 8) / 247 * 24) + 232;
|
|
}
|
|
|
|
var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
return ansi;
|
|
};
|
|
|
|
convert.ansi16.rgb = function (args) {
|
|
var color = args % 10; // Handle greyscale
|
|
|
|
if (color === 0 || color === 7) {
|
|
if (args > 50) {
|
|
color += 3.5;
|
|
}
|
|
|
|
color = color / 10.5 * 255;
|
|
return [color, color, color];
|
|
}
|
|
|
|
var mult = (~~(args > 50) + 1) * 0.5;
|
|
var r = (color & 1) * mult * 255;
|
|
var g = (color >> 1 & 1) * mult * 255;
|
|
var b = (color >> 2 & 1) * mult * 255;
|
|
return [r, g, b];
|
|
};
|
|
|
|
convert.ansi256.rgb = function (args) {
|
|
// Handle greyscale
|
|
if (args >= 232) {
|
|
var c = (args - 232) * 10 + 8;
|
|
return [c, c, c];
|
|
}
|
|
|
|
args -= 16;
|
|
var rem;
|
|
var r = Math.floor(args / 36) / 5 * 255;
|
|
var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
var b = rem % 6 / 5 * 255;
|
|
return [r, g, b];
|
|
};
|
|
|
|
convert.rgb.hex = function (args) {
|
|
var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
|
|
var string = integer.toString(16).toUpperCase();
|
|
return '000000'.substring(string.length) + string;
|
|
};
|
|
|
|
convert.hex.rgb = function (args) {
|
|
var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
|
|
if (!match) {
|
|
return [0, 0, 0];
|
|
}
|
|
|
|
var colorString = match[0];
|
|
|
|
if (match[0].length === 3) {
|
|
colorString = colorString.split('').map(function (char) {
|
|
return char + char;
|
|
}).join('');
|
|
}
|
|
|
|
var integer = parseInt(colorString, 16);
|
|
var r = integer >> 16 & 0xFF;
|
|
var g = integer >> 8 & 0xFF;
|
|
var b = integer & 0xFF;
|
|
return [r, g, b];
|
|
};
|
|
|
|
convert.rgb.hcg = function (rgb) {
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255;
|
|
var max = Math.max(Math.max(r, g), b);
|
|
var min = Math.min(Math.min(r, g), b);
|
|
var chroma = max - min;
|
|
var grayscale;
|
|
var hue;
|
|
|
|
if (chroma < 1) {
|
|
grayscale = min / (1 - chroma);
|
|
} else {
|
|
grayscale = 0;
|
|
}
|
|
|
|
if (chroma <= 0) {
|
|
hue = 0;
|
|
} else if (max === r) {
|
|
hue = (g - b) / chroma % 6;
|
|
} else if (max === g) {
|
|
hue = 2 + (b - r) / chroma;
|
|
} else {
|
|
hue = 4 + (r - g) / chroma;
|
|
}
|
|
|
|
hue /= 6;
|
|
hue %= 1;
|
|
return [hue * 360, chroma * 100, grayscale * 100];
|
|
};
|
|
|
|
convert.hsl.hcg = function (hsl) {
|
|
var s = hsl[1] / 100;
|
|
var l = hsl[2] / 100;
|
|
var c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l);
|
|
var f = 0;
|
|
|
|
if (c < 1.0) {
|
|
f = (l - 0.5 * c) / (1.0 - c);
|
|
}
|
|
|
|
return [hsl[0], c * 100, f * 100];
|
|
};
|
|
|
|
convert.hsv.hcg = function (hsv) {
|
|
var s = hsv[1] / 100;
|
|
var v = hsv[2] / 100;
|
|
var c = s * v;
|
|
var f = 0;
|
|
|
|
if (c < 1.0) {
|
|
f = (v - c) / (1 - c);
|
|
}
|
|
|
|
return [hsv[0], c * 100, f * 100];
|
|
};
|
|
|
|
convert.hcg.rgb = function (hcg) {
|
|
var h = hcg[0] / 360;
|
|
var c = hcg[1] / 100;
|
|
var g = hcg[2] / 100;
|
|
|
|
if (c === 0.0) {
|
|
return [g * 255, g * 255, g * 255];
|
|
}
|
|
|
|
var pure = [0, 0, 0];
|
|
var hi = h % 1 * 6;
|
|
var v = hi % 1;
|
|
var w = 1 - v;
|
|
var mg = 0;
|
|
/* eslint-disable max-statements-per-line */
|
|
|
|
switch (Math.floor(hi)) {
|
|
case 0:
|
|
pure[0] = 1;
|
|
pure[1] = v;
|
|
pure[2] = 0;
|
|
break;
|
|
|
|
case 1:
|
|
pure[0] = w;
|
|
pure[1] = 1;
|
|
pure[2] = 0;
|
|
break;
|
|
|
|
case 2:
|
|
pure[0] = 0;
|
|
pure[1] = 1;
|
|
pure[2] = v;
|
|
break;
|
|
|
|
case 3:
|
|
pure[0] = 0;
|
|
pure[1] = w;
|
|
pure[2] = 1;
|
|
break;
|
|
|
|
case 4:
|
|
pure[0] = v;
|
|
pure[1] = 0;
|
|
pure[2] = 1;
|
|
break;
|
|
|
|
default:
|
|
pure[0] = 1;
|
|
pure[1] = 0;
|
|
pure[2] = w;
|
|
}
|
|
/* eslint-enable max-statements-per-line */
|
|
|
|
|
|
mg = (1.0 - c) * g;
|
|
return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
|
|
};
|
|
|
|
convert.hcg.hsv = function (hcg) {
|
|
var c = hcg[1] / 100;
|
|
var g = hcg[2] / 100;
|
|
var v = c + g * (1.0 - c);
|
|
var f = 0;
|
|
|
|
if (v > 0.0) {
|
|
f = c / v;
|
|
}
|
|
|
|
return [hcg[0], f * 100, v * 100];
|
|
};
|
|
|
|
convert.hcg.hsl = function (hcg) {
|
|
var c = hcg[1] / 100;
|
|
var g = hcg[2] / 100;
|
|
var l = g * (1.0 - c) + 0.5 * c;
|
|
var s = 0;
|
|
|
|
if (l > 0.0 && l < 0.5) {
|
|
s = c / (2 * l);
|
|
} else if (l >= 0.5 && l < 1.0) {
|
|
s = c / (2 * (1 - l));
|
|
}
|
|
|
|
return [hcg[0], s * 100, l * 100];
|
|
};
|
|
|
|
convert.hcg.hwb = function (hcg) {
|
|
var c = hcg[1] / 100;
|
|
var g = hcg[2] / 100;
|
|
var v = c + g * (1.0 - c);
|
|
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
};
|
|
|
|
convert.hwb.hcg = function (hwb) {
|
|
var w = hwb[1] / 100;
|
|
var b = hwb[2] / 100;
|
|
var v = 1 - b;
|
|
var c = v - w;
|
|
var g = 0;
|
|
|
|
if (c < 1) {
|
|
g = (v - c) / (1 - c);
|
|
}
|
|
|
|
return [hwb[0], c * 100, g * 100];
|
|
};
|
|
|
|
convert.apple.rgb = function (apple) {
|
|
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
};
|
|
|
|
convert.rgb.apple = function (rgb) {
|
|
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
};
|
|
|
|
convert.gray.rgb = function (args) {
|
|
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
};
|
|
|
|
convert.gray.hsl = function (args) {
|
|
return [0, 0, args[0]];
|
|
};
|
|
|
|
convert.gray.hsv = convert.gray.hsl;
|
|
|
|
convert.gray.hwb = function (gray) {
|
|
return [0, 100, gray[0]];
|
|
};
|
|
|
|
convert.gray.cmyk = function (gray) {
|
|
return [0, 0, 0, gray[0]];
|
|
};
|
|
|
|
convert.gray.lab = function (gray) {
|
|
return [gray[0], 0, 0];
|
|
};
|
|
|
|
convert.gray.hex = function (gray) {
|
|
var val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
|
var integer = (val << 16) + (val << 8) + val;
|
|
var string = integer.toString(16).toUpperCase();
|
|
return '000000'.substring(string.length) + string;
|
|
};
|
|
|
|
convert.rgb.gray = function (rgb) {
|
|
var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
return [val / 255 * 100];
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/ansi-styles/node_modules/color-convert/index.js":
|
|
/*!**********************************************************************!*\
|
|
!*** ./node_modules/ansi-styles/node_modules/color-convert/index.js ***!
|
|
\**********************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
var conversions = __webpack_require__(/*! ./conversions */ "./node_modules/ansi-styles/node_modules/color-convert/conversions.js");
|
|
|
|
var route = __webpack_require__(/*! ./route */ "./node_modules/ansi-styles/node_modules/color-convert/route.js");
|
|
|
|
var convert = {};
|
|
var models = Object.keys(conversions);
|
|
|
|
function wrapRaw(fn) {
|
|
var wrappedFn = function wrappedFn() {
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
var arg0 = args[0];
|
|
|
|
if (arg0 === undefined || arg0 === null) {
|
|
return arg0;
|
|
}
|
|
|
|
if (arg0.length > 1) {
|
|
args = arg0;
|
|
}
|
|
|
|
return fn(args);
|
|
}; // Preserve .conversion property if there is one
|
|
|
|
|
|
if ('conversion' in fn) {
|
|
wrappedFn.conversion = fn.conversion;
|
|
}
|
|
|
|
return wrappedFn;
|
|
}
|
|
|
|
function wrapRounded(fn) {
|
|
var wrappedFn = function wrappedFn() {
|
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
args[_key2] = arguments[_key2];
|
|
}
|
|
|
|
var arg0 = args[0];
|
|
|
|
if (arg0 === undefined || arg0 === null) {
|
|
return arg0;
|
|
}
|
|
|
|
if (arg0.length > 1) {
|
|
args = arg0;
|
|
}
|
|
|
|
var result = fn(args); // We're assuming the result is an array here.
|
|
// see notice in conversions.js; don't use box types
|
|
// in conversion functions.
|
|
|
|
if (_typeof(result) === 'object') {
|
|
for (var len = result.length, i = 0; i < len; i++) {
|
|
result[i] = Math.round(result[i]);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}; // Preserve .conversion property if there is one
|
|
|
|
|
|
if ('conversion' in fn) {
|
|
wrappedFn.conversion = fn.conversion;
|
|
}
|
|
|
|
return wrappedFn;
|
|
}
|
|
|
|
models.forEach(function (fromModel) {
|
|
convert[fromModel] = {};
|
|
Object.defineProperty(convert[fromModel], 'channels', {
|
|
value: conversions[fromModel].channels
|
|
});
|
|
Object.defineProperty(convert[fromModel], 'labels', {
|
|
value: conversions[fromModel].labels
|
|
});
|
|
var routes = route(fromModel);
|
|
var routeModels = Object.keys(routes);
|
|
routeModels.forEach(function (toModel) {
|
|
var fn = routes[toModel];
|
|
convert[fromModel][toModel] = wrapRounded(fn);
|
|
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
});
|
|
});
|
|
module.exports = convert;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/ansi-styles/node_modules/color-convert/route.js":
|
|
/*!**********************************************************************!*\
|
|
!*** ./node_modules/ansi-styles/node_modules/color-convert/route.js ***!
|
|
\**********************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var conversions = __webpack_require__(/*! ./conversions */ "./node_modules/ansi-styles/node_modules/color-convert/conversions.js");
|
|
/*
|
|
This function routes a model to all other models.
|
|
|
|
all functions that are routed have a property `.conversion` attached
|
|
to the returned synthetic function. This property is an array
|
|
of strings, each with the steps in between the 'from' and 'to'
|
|
color models (inclusive).
|
|
|
|
conversions that are not possible simply are not included.
|
|
*/
|
|
|
|
|
|
function buildGraph() {
|
|
var graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
|
|
|
var models = Object.keys(conversions);
|
|
|
|
for (var len = models.length, i = 0; i < len; i++) {
|
|
graph[models[i]] = {
|
|
// http://jsperf.com/1-vs-infinity
|
|
// micro-opt, but this is simple.
|
|
distance: -1,
|
|
parent: null
|
|
};
|
|
}
|
|
|
|
return graph;
|
|
} // https://en.wikipedia.org/wiki/Breadth-first_search
|
|
|
|
|
|
function deriveBFS(fromModel) {
|
|
var graph = buildGraph();
|
|
var queue = [fromModel]; // Unshift -> queue -> pop
|
|
|
|
graph[fromModel].distance = 0;
|
|
|
|
while (queue.length) {
|
|
var current = queue.pop();
|
|
var adjacents = Object.keys(conversions[current]);
|
|
|
|
for (var len = adjacents.length, i = 0; i < len; i++) {
|
|
var adjacent = adjacents[i];
|
|
var node = graph[adjacent];
|
|
|
|
if (node.distance === -1) {
|
|
node.distance = graph[current].distance + 1;
|
|
node.parent = current;
|
|
queue.unshift(adjacent);
|
|
}
|
|
}
|
|
}
|
|
|
|
return graph;
|
|
}
|
|
|
|
function link(from, to) {
|
|
return function (args) {
|
|
return to(from(args));
|
|
};
|
|
}
|
|
|
|
function wrapConversion(toModel, graph) {
|
|
var path = [graph[toModel].parent, toModel];
|
|
var fn = conversions[graph[toModel].parent][toModel];
|
|
var cur = graph[toModel].parent;
|
|
|
|
while (graph[cur].parent) {
|
|
path.unshift(graph[cur].parent);
|
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
cur = graph[cur].parent;
|
|
}
|
|
|
|
fn.conversion = path;
|
|
return fn;
|
|
}
|
|
|
|
module.exports = function (fromModel) {
|
|
var graph = deriveBFS(fromModel);
|
|
var conversion = {};
|
|
var models = Object.keys(graph);
|
|
|
|
for (var len = models.length, i = 0; i < len; i++) {
|
|
var toModel = models[i];
|
|
var node = graph[toModel];
|
|
|
|
if (node.parent === null) {
|
|
// No possible conversion, or this node is the source model.
|
|
continue;
|
|
}
|
|
|
|
conversion[toModel] = wrapConversion(toModel, graph);
|
|
}
|
|
|
|
return conversion;
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/color-name/index.js":
|
|
/*!******************************************!*\
|
|
!*** ./node_modules/color-name/index.js ***!
|
|
\******************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = {
|
|
"aliceblue": [240, 248, 255],
|
|
"antiquewhite": [250, 235, 215],
|
|
"aqua": [0, 255, 255],
|
|
"aquamarine": [127, 255, 212],
|
|
"azure": [240, 255, 255],
|
|
"beige": [245, 245, 220],
|
|
"bisque": [255, 228, 196],
|
|
"black": [0, 0, 0],
|
|
"blanchedalmond": [255, 235, 205],
|
|
"blue": [0, 0, 255],
|
|
"blueviolet": [138, 43, 226],
|
|
"brown": [165, 42, 42],
|
|
"burlywood": [222, 184, 135],
|
|
"cadetblue": [95, 158, 160],
|
|
"chartreuse": [127, 255, 0],
|
|
"chocolate": [210, 105, 30],
|
|
"coral": [255, 127, 80],
|
|
"cornflowerblue": [100, 149, 237],
|
|
"cornsilk": [255, 248, 220],
|
|
"crimson": [220, 20, 60],
|
|
"cyan": [0, 255, 255],
|
|
"darkblue": [0, 0, 139],
|
|
"darkcyan": [0, 139, 139],
|
|
"darkgoldenrod": [184, 134, 11],
|
|
"darkgray": [169, 169, 169],
|
|
"darkgreen": [0, 100, 0],
|
|
"darkgrey": [169, 169, 169],
|
|
"darkkhaki": [189, 183, 107],
|
|
"darkmagenta": [139, 0, 139],
|
|
"darkolivegreen": [85, 107, 47],
|
|
"darkorange": [255, 140, 0],
|
|
"darkorchid": [153, 50, 204],
|
|
"darkred": [139, 0, 0],
|
|
"darksalmon": [233, 150, 122],
|
|
"darkseagreen": [143, 188, 143],
|
|
"darkslateblue": [72, 61, 139],
|
|
"darkslategray": [47, 79, 79],
|
|
"darkslategrey": [47, 79, 79],
|
|
"darkturquoise": [0, 206, 209],
|
|
"darkviolet": [148, 0, 211],
|
|
"deeppink": [255, 20, 147],
|
|
"deepskyblue": [0, 191, 255],
|
|
"dimgray": [105, 105, 105],
|
|
"dimgrey": [105, 105, 105],
|
|
"dodgerblue": [30, 144, 255],
|
|
"firebrick": [178, 34, 34],
|
|
"floralwhite": [255, 250, 240],
|
|
"forestgreen": [34, 139, 34],
|
|
"fuchsia": [255, 0, 255],
|
|
"gainsboro": [220, 220, 220],
|
|
"ghostwhite": [248, 248, 255],
|
|
"gold": [255, 215, 0],
|
|
"goldenrod": [218, 165, 32],
|
|
"gray": [128, 128, 128],
|
|
"green": [0, 128, 0],
|
|
"greenyellow": [173, 255, 47],
|
|
"grey": [128, 128, 128],
|
|
"honeydew": [240, 255, 240],
|
|
"hotpink": [255, 105, 180],
|
|
"indianred": [205, 92, 92],
|
|
"indigo": [75, 0, 130],
|
|
"ivory": [255, 255, 240],
|
|
"khaki": [240, 230, 140],
|
|
"lavender": [230, 230, 250],
|
|
"lavenderblush": [255, 240, 245],
|
|
"lawngreen": [124, 252, 0],
|
|
"lemonchiffon": [255, 250, 205],
|
|
"lightblue": [173, 216, 230],
|
|
"lightcoral": [240, 128, 128],
|
|
"lightcyan": [224, 255, 255],
|
|
"lightgoldenrodyellow": [250, 250, 210],
|
|
"lightgray": [211, 211, 211],
|
|
"lightgreen": [144, 238, 144],
|
|
"lightgrey": [211, 211, 211],
|
|
"lightpink": [255, 182, 193],
|
|
"lightsalmon": [255, 160, 122],
|
|
"lightseagreen": [32, 178, 170],
|
|
"lightskyblue": [135, 206, 250],
|
|
"lightslategray": [119, 136, 153],
|
|
"lightslategrey": [119, 136, 153],
|
|
"lightsteelblue": [176, 196, 222],
|
|
"lightyellow": [255, 255, 224],
|
|
"lime": [0, 255, 0],
|
|
"limegreen": [50, 205, 50],
|
|
"linen": [250, 240, 230],
|
|
"magenta": [255, 0, 255],
|
|
"maroon": [128, 0, 0],
|
|
"mediumaquamarine": [102, 205, 170],
|
|
"mediumblue": [0, 0, 205],
|
|
"mediumorchid": [186, 85, 211],
|
|
"mediumpurple": [147, 112, 219],
|
|
"mediumseagreen": [60, 179, 113],
|
|
"mediumslateblue": [123, 104, 238],
|
|
"mediumspringgreen": [0, 250, 154],
|
|
"mediumturquoise": [72, 209, 204],
|
|
"mediumvioletred": [199, 21, 133],
|
|
"midnightblue": [25, 25, 112],
|
|
"mintcream": [245, 255, 250],
|
|
"mistyrose": [255, 228, 225],
|
|
"moccasin": [255, 228, 181],
|
|
"navajowhite": [255, 222, 173],
|
|
"navy": [0, 0, 128],
|
|
"oldlace": [253, 245, 230],
|
|
"olive": [128, 128, 0],
|
|
"olivedrab": [107, 142, 35],
|
|
"orange": [255, 165, 0],
|
|
"orangered": [255, 69, 0],
|
|
"orchid": [218, 112, 214],
|
|
"palegoldenrod": [238, 232, 170],
|
|
"palegreen": [152, 251, 152],
|
|
"paleturquoise": [175, 238, 238],
|
|
"palevioletred": [219, 112, 147],
|
|
"papayawhip": [255, 239, 213],
|
|
"peachpuff": [255, 218, 185],
|
|
"peru": [205, 133, 63],
|
|
"pink": [255, 192, 203],
|
|
"plum": [221, 160, 221],
|
|
"powderblue": [176, 224, 230],
|
|
"purple": [128, 0, 128],
|
|
"rebeccapurple": [102, 51, 153],
|
|
"red": [255, 0, 0],
|
|
"rosybrown": [188, 143, 143],
|
|
"royalblue": [65, 105, 225],
|
|
"saddlebrown": [139, 69, 19],
|
|
"salmon": [250, 128, 114],
|
|
"sandybrown": [244, 164, 96],
|
|
"seagreen": [46, 139, 87],
|
|
"seashell": [255, 245, 238],
|
|
"sienna": [160, 82, 45],
|
|
"silver": [192, 192, 192],
|
|
"skyblue": [135, 206, 235],
|
|
"slateblue": [106, 90, 205],
|
|
"slategray": [112, 128, 144],
|
|
"slategrey": [112, 128, 144],
|
|
"snow": [255, 250, 250],
|
|
"springgreen": [0, 255, 127],
|
|
"steelblue": [70, 130, 180],
|
|
"tan": [210, 180, 140],
|
|
"teal": [0, 128, 128],
|
|
"thistle": [216, 191, 216],
|
|
"tomato": [255, 99, 71],
|
|
"turquoise": [64, 224, 208],
|
|
"violet": [238, 130, 238],
|
|
"wheat": [245, 222, 179],
|
|
"white": [255, 255, 255],
|
|
"whitesmoke": [245, 245, 245],
|
|
"yellow": [255, 255, 0],
|
|
"yellowgreen": [154, 205, 50]
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/react-is/cjs/react-is.development.js":
|
|
/*!***********************************************************!*\
|
|
!*** ./node_modules/react-is/cjs/react-is.development.js ***!
|
|
\***********************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/** @license React v16.13.1
|
|
* react-is.development.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
if (true) {
|
|
(function () {
|
|
'use strict'; // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
// nor polyfill, then a plain number is used for performance.
|
|
|
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
|
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
|
|
function isValidElementType(type) {
|
|
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || _typeof(type) === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
}
|
|
|
|
function typeOf(object) {
|
|
if (_typeof(object) === 'object' && object !== null) {
|
|
var $$typeof = object.$$typeof;
|
|
|
|
switch ($$typeof) {
|
|
case REACT_ELEMENT_TYPE:
|
|
var type = object.type;
|
|
|
|
switch (type) {
|
|
case REACT_ASYNC_MODE_TYPE:
|
|
case REACT_CONCURRENT_MODE_TYPE:
|
|
case REACT_FRAGMENT_TYPE:
|
|
case REACT_PROFILER_TYPE:
|
|
case REACT_STRICT_MODE_TYPE:
|
|
case REACT_SUSPENSE_TYPE:
|
|
return type;
|
|
|
|
default:
|
|
var $$typeofType = type && type.$$typeof;
|
|
|
|
switch ($$typeofType) {
|
|
case REACT_CONTEXT_TYPE:
|
|
case REACT_FORWARD_REF_TYPE:
|
|
case REACT_LAZY_TYPE:
|
|
case REACT_MEMO_TYPE:
|
|
case REACT_PROVIDER_TYPE:
|
|
return $$typeofType;
|
|
|
|
default:
|
|
return $$typeof;
|
|
}
|
|
|
|
}
|
|
|
|
case REACT_PORTAL_TYPE:
|
|
return $$typeof;
|
|
}
|
|
}
|
|
|
|
return undefined;
|
|
} // AsyncMode is deprecated along with isAsyncMode
|
|
|
|
|
|
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
var Element = REACT_ELEMENT_TYPE;
|
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
var Fragment = REACT_FRAGMENT_TYPE;
|
|
var Lazy = REACT_LAZY_TYPE;
|
|
var Memo = REACT_MEMO_TYPE;
|
|
var Portal = REACT_PORTAL_TYPE;
|
|
var Profiler = REACT_PROFILER_TYPE;
|
|
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
var Suspense = REACT_SUSPENSE_TYPE;
|
|
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
|
|
function isAsyncMode(object) {
|
|
{
|
|
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
|
|
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
|
}
|
|
}
|
|
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
}
|
|
|
|
function isConcurrentMode(object) {
|
|
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
}
|
|
|
|
function isContextConsumer(object) {
|
|
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
}
|
|
|
|
function isContextProvider(object) {
|
|
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
}
|
|
|
|
function isElement(object) {
|
|
return _typeof(object) === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
}
|
|
|
|
function isForwardRef(object) {
|
|
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
}
|
|
|
|
function isFragment(object) {
|
|
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
}
|
|
|
|
function isLazy(object) {
|
|
return typeOf(object) === REACT_LAZY_TYPE;
|
|
}
|
|
|
|
function isMemo(object) {
|
|
return typeOf(object) === REACT_MEMO_TYPE;
|
|
}
|
|
|
|
function isPortal(object) {
|
|
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
}
|
|
|
|
function isProfiler(object) {
|
|
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
}
|
|
|
|
function isStrictMode(object) {
|
|
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
}
|
|
|
|
function isSuspense(object) {
|
|
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
}
|
|
|
|
exports.AsyncMode = AsyncMode;
|
|
exports.ConcurrentMode = ConcurrentMode;
|
|
exports.ContextConsumer = ContextConsumer;
|
|
exports.ContextProvider = ContextProvider;
|
|
exports.Element = Element;
|
|
exports.ForwardRef = ForwardRef;
|
|
exports.Fragment = Fragment;
|
|
exports.Lazy = Lazy;
|
|
exports.Memo = Memo;
|
|
exports.Portal = Portal;
|
|
exports.Profiler = Profiler;
|
|
exports.StrictMode = StrictMode;
|
|
exports.Suspense = Suspense;
|
|
exports.isAsyncMode = isAsyncMode;
|
|
exports.isConcurrentMode = isConcurrentMode;
|
|
exports.isContextConsumer = isContextConsumer;
|
|
exports.isContextProvider = isContextProvider;
|
|
exports.isElement = isElement;
|
|
exports.isForwardRef = isForwardRef;
|
|
exports.isFragment = isFragment;
|
|
exports.isLazy = isLazy;
|
|
exports.isMemo = isMemo;
|
|
exports.isPortal = isPortal;
|
|
exports.isProfiler = isProfiler;
|
|
exports.isStrictMode = isStrictMode;
|
|
exports.isSuspense = isSuspense;
|
|
exports.isValidElementType = isValidElementType;
|
|
exports.typeOf = typeOf;
|
|
})();
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/react-is/index.js":
|
|
/*!****************************************!*\
|
|
!*** ./node_modules/react-is/index.js ***!
|
|
\****************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
if (false) {} else {
|
|
module.exports = __webpack_require__(/*! ./cjs/react-is.development.js */ "./node_modules/react-is/cjs/react-is.development.js");
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./node_modules/webpack/buildin/module.js":
|
|
/*!***********************************!*\
|
|
!*** (webpack)/buildin/module.js ***!
|
|
\***********************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = function (module) {
|
|
if (!module.webpackPolyfill) {
|
|
module.deprecate = function () {};
|
|
|
|
module.paths = []; // module.parent = undefined by default
|
|
|
|
if (!module.children) module.children = [];
|
|
Object.defineProperty(module, "loaded", {
|
|
enumerable: true,
|
|
get: function get() {
|
|
return module.l;
|
|
}
|
|
});
|
|
Object.defineProperty(module, "id", {
|
|
enumerable: true,
|
|
get: function get() {
|
|
return module.i;
|
|
}
|
|
});
|
|
module.webpackPolyfill = 1;
|
|
}
|
|
|
|
return module;
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/collections.ts":
|
|
/*!***************************************************!*\
|
|
!*** ./packages/pretty-format/src/collections.ts ***!
|
|
\***************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.printIteratorEntries = printIteratorEntries;
|
|
exports.printIteratorValues = printIteratorValues;
|
|
exports.printListItems = printListItems;
|
|
exports.printObjectProperties = printObjectProperties;
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*/
|
|
var getKeysOfEnumerableProperties = function getKeysOfEnumerableProperties(object) {
|
|
var keys = Object.keys(object).sort();
|
|
|
|
if (Object.getOwnPropertySymbols) {
|
|
Object.getOwnPropertySymbols(object).forEach(function (symbol) {
|
|
if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
|
|
keys.push(symbol);
|
|
}
|
|
});
|
|
}
|
|
|
|
return keys;
|
|
};
|
|
/**
|
|
* Return entries (for example, of a map)
|
|
* with spacing, indentation, and comma
|
|
* without surrounding punctuation (for example, braces)
|
|
*/
|
|
|
|
|
|
function printIteratorEntries(iterator, config, indentation, depth, refs, printer) {
|
|
var separator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ': ';
|
|
var result = '';
|
|
var current = iterator.next();
|
|
|
|
if (!current.done) {
|
|
result += config.spacingOuter;
|
|
var indentationNext = indentation + config.indent;
|
|
|
|
while (!current.done) {
|
|
var name = printer(current.value[0], config, indentationNext, depth, refs);
|
|
var value = printer(current.value[1], config, indentationNext, depth, refs);
|
|
result += indentationNext + name + separator + value;
|
|
current = iterator.next();
|
|
|
|
if (!current.done) {
|
|
result += ',' + config.spacingInner;
|
|
} else if (!config.min) {
|
|
result += ',';
|
|
}
|
|
}
|
|
|
|
result += config.spacingOuter + indentation;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
/**
|
|
* Return values (for example, of a set)
|
|
* with spacing, indentation, and comma
|
|
* without surrounding punctuation (braces or brackets)
|
|
*/
|
|
|
|
|
|
function printIteratorValues(iterator, config, indentation, depth, refs, printer) {
|
|
var result = '';
|
|
var current = iterator.next();
|
|
|
|
if (!current.done) {
|
|
result += config.spacingOuter;
|
|
var indentationNext = indentation + config.indent;
|
|
|
|
while (!current.done) {
|
|
result += indentationNext + printer(current.value, config, indentationNext, depth, refs);
|
|
current = iterator.next();
|
|
|
|
if (!current.done) {
|
|
result += ',' + config.spacingInner;
|
|
} else if (!config.min) {
|
|
result += ',';
|
|
}
|
|
}
|
|
|
|
result += config.spacingOuter + indentation;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
/**
|
|
* Return items (for example, of an array)
|
|
* with spacing, indentation, and comma
|
|
* without surrounding punctuation (for example, brackets)
|
|
**/
|
|
|
|
|
|
function printListItems(list, config, indentation, depth, refs, printer) {
|
|
var result = '';
|
|
|
|
if (list.length) {
|
|
result += config.spacingOuter;
|
|
var indentationNext = indentation + config.indent;
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
result += indentationNext + printer(list[i], config, indentationNext, depth, refs);
|
|
|
|
if (i < list.length - 1) {
|
|
result += ',' + config.spacingInner;
|
|
} else if (!config.min) {
|
|
result += ',';
|
|
}
|
|
}
|
|
|
|
result += config.spacingOuter + indentation;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
/**
|
|
* Return properties of an object
|
|
* with spacing, indentation, and comma
|
|
* without surrounding punctuation (for example, braces)
|
|
*/
|
|
|
|
|
|
function printObjectProperties(val, config, indentation, depth, refs, printer) {
|
|
var result = '';
|
|
var keys = getKeysOfEnumerableProperties(val);
|
|
|
|
if (keys.length) {
|
|
result += config.spacingOuter;
|
|
var indentationNext = indentation + config.indent;
|
|
|
|
for (var i = 0; i < keys.length; i++) {
|
|
var key = keys[i];
|
|
var name = printer(key, config, indentationNext, depth, refs);
|
|
var value = printer(val[key], config, indentationNext, depth, refs);
|
|
result += indentationNext + name + ': ' + value;
|
|
|
|
if (i < keys.length - 1) {
|
|
result += ',' + config.spacingInner;
|
|
} else if (!config.min) {
|
|
result += ',';
|
|
}
|
|
}
|
|
|
|
result += config.spacingOuter + indentation;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/index.ts":
|
|
/*!*********************************************!*\
|
|
!*** ./packages/pretty-format/src/index.ts ***!
|
|
\*********************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var _ansiStyles = _interopRequireDefault(__webpack_require__(/*! ansi-styles */ "./node_modules/ansi-styles/index.js"));
|
|
|
|
var _collections = __webpack_require__(/*! ./collections */ "./packages/pretty-format/src/collections.ts");
|
|
|
|
var _AsymmetricMatcher = _interopRequireDefault(__webpack_require__(/*! ./plugins/AsymmetricMatcher */ "./packages/pretty-format/src/plugins/AsymmetricMatcher.ts"));
|
|
|
|
var _ConvertAnsi = _interopRequireDefault(__webpack_require__(/*! ./plugins/ConvertAnsi */ "./packages/pretty-format/src/plugins/ConvertAnsi.ts"));
|
|
|
|
var _DOMCollection = _interopRequireDefault(__webpack_require__(/*! ./plugins/DOMCollection */ "./packages/pretty-format/src/plugins/DOMCollection.ts"));
|
|
|
|
var _DOMElement = _interopRequireDefault(__webpack_require__(/*! ./plugins/DOMElement */ "./packages/pretty-format/src/plugins/DOMElement.ts"));
|
|
|
|
var _Immutable = _interopRequireDefault(__webpack_require__(/*! ./plugins/Immutable */ "./packages/pretty-format/src/plugins/Immutable.ts"));
|
|
|
|
var _ReactElement = _interopRequireDefault(__webpack_require__(/*! ./plugins/ReactElement */ "./packages/pretty-format/src/plugins/ReactElement.ts"));
|
|
|
|
var _ReactTestComponent = _interopRequireDefault(__webpack_require__(/*! ./plugins/ReactTestComponent */ "./packages/pretty-format/src/plugins/ReactTestComponent.ts"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var toString = Object.prototype.toString;
|
|
var toISOString = Date.prototype.toISOString;
|
|
var errorToString = Error.prototype.toString;
|
|
var regExpToString = RegExp.prototype.toString;
|
|
/**
|
|
* Explicitly comparing typeof constructor to function avoids undefined as name
|
|
* when mock identity-obj-proxy returns the key as the value for any key.
|
|
*/
|
|
|
|
var getConstructorName = function getConstructorName(val) {
|
|
return typeof val.constructor === 'function' && val.constructor.name || 'Object';
|
|
};
|
|
/* global window */
|
|
|
|
/** Is val is equal to global window object? Works even if it does not exist :) */
|
|
|
|
|
|
var isWindow = function isWindow(val) {
|
|
return typeof window !== 'undefined' && val === window;
|
|
};
|
|
|
|
var SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
|
var NEWLINE_REGEXP = /\n/gi;
|
|
|
|
var PrettyFormatPluginError = /*#__PURE__*/function (_Error) {
|
|
_inherits(PrettyFormatPluginError, _Error);
|
|
|
|
var _super = _createSuper(PrettyFormatPluginError);
|
|
|
|
function PrettyFormatPluginError(message, stack) {
|
|
var _this;
|
|
|
|
_classCallCheck(this, PrettyFormatPluginError);
|
|
|
|
_this = _super.call(this, message);
|
|
_this.stack = stack;
|
|
_this.name = _this.constructor.name;
|
|
return _this;
|
|
}
|
|
|
|
return PrettyFormatPluginError;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
|
|
function isToStringedArrayType(toStringed) {
|
|
return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';
|
|
}
|
|
|
|
function printNumber(val) {
|
|
return Object.is(val, -0) ? '-0' : String(val);
|
|
}
|
|
|
|
function printBigInt(val) {
|
|
return String("".concat(val, "n"));
|
|
}
|
|
|
|
function printFunction(val, printFunctionName) {
|
|
if (!printFunctionName) {
|
|
return '[Function]';
|
|
}
|
|
|
|
return '[Function ' + (val.name || 'anonymous') + ']';
|
|
}
|
|
|
|
function printSymbol(val) {
|
|
return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
|
|
}
|
|
|
|
function printError(val) {
|
|
return '[' + errorToString.call(val) + ']';
|
|
}
|
|
/**
|
|
* The first port of call for printing an object, handles most of the
|
|
* data-types in JS.
|
|
*/
|
|
|
|
|
|
function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
if (val === true || val === false) {
|
|
return '' + val;
|
|
}
|
|
|
|
if (val === undefined) {
|
|
return 'undefined';
|
|
}
|
|
|
|
if (val === null) {
|
|
return 'null';
|
|
}
|
|
|
|
var typeOf = _typeof(val);
|
|
|
|
if (typeOf === 'number') {
|
|
return printNumber(val);
|
|
}
|
|
|
|
if (typeOf === 'bigint') {
|
|
return printBigInt(val);
|
|
}
|
|
|
|
if (typeOf === 'string') {
|
|
if (escapeString) {
|
|
return '"' + val.replace(/"|\\/g, '\\$&') + '"';
|
|
}
|
|
|
|
return '"' + val + '"';
|
|
}
|
|
|
|
if (typeOf === 'function') {
|
|
return printFunction(val, printFunctionName);
|
|
}
|
|
|
|
if (typeOf === 'symbol') {
|
|
return printSymbol(val);
|
|
}
|
|
|
|
var toStringed = toString.call(val);
|
|
|
|
if (toStringed === '[object WeakMap]') {
|
|
return 'WeakMap {}';
|
|
}
|
|
|
|
if (toStringed === '[object WeakSet]') {
|
|
return 'WeakSet {}';
|
|
}
|
|
|
|
if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') {
|
|
return printFunction(val, printFunctionName);
|
|
}
|
|
|
|
if (toStringed === '[object Symbol]') {
|
|
return printSymbol(val);
|
|
}
|
|
|
|
if (toStringed === '[object Date]') {
|
|
return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
|
|
}
|
|
|
|
if (toStringed === '[object Error]') {
|
|
return printError(val);
|
|
}
|
|
|
|
if (toStringed === '[object RegExp]') {
|
|
if (escapeRegex) {
|
|
// https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js
|
|
return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
}
|
|
|
|
return regExpToString.call(val);
|
|
}
|
|
|
|
if (val instanceof Error) {
|
|
return printError(val);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
/**
|
|
* Handles more complex objects ( such as objects with circular references.
|
|
* maps and sets etc )
|
|
*/
|
|
|
|
|
|
function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
if (refs.indexOf(val) !== -1) {
|
|
return '[Circular]';
|
|
}
|
|
|
|
refs = refs.slice();
|
|
refs.push(val);
|
|
var hitMaxDepth = ++depth > config.maxDepth;
|
|
var min = config.min;
|
|
|
|
if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function' && !hasCalledToJSON) {
|
|
return printer(val.toJSON(), config, indentation, depth, refs, true);
|
|
}
|
|
|
|
var toStringed = toString.call(val);
|
|
|
|
if (toStringed === '[object Arguments]') {
|
|
return hitMaxDepth ? '[Arguments]' : (min ? '' : 'Arguments ') + '[' + (0, _collections.printListItems)(val, config, indentation, depth, refs, printer) + ']';
|
|
}
|
|
|
|
if (isToStringedArrayType(toStringed)) {
|
|
return hitMaxDepth ? '[' + val.constructor.name + ']' : (min ? '' : val.constructor.name + ' ') + '[' + (0, _collections.printListItems)(val, config, indentation, depth, refs, printer) + ']';
|
|
}
|
|
|
|
if (toStringed === '[object Map]') {
|
|
return hitMaxDepth ? '[Map]' : 'Map {' + (0, _collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer, ' => ') + '}';
|
|
}
|
|
|
|
if (toStringed === '[object Set]') {
|
|
return hitMaxDepth ? '[Set]' : 'Set {' + (0, _collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) + '}';
|
|
} // Avoid failure to serialize global window object in jsdom test environment.
|
|
// For example, not even relevant if window is prop of React element.
|
|
|
|
|
|
return hitMaxDepth || isWindow(val) ? '[' + getConstructorName(val) + ']' : (min ? '' : getConstructorName(val) + ' ') + '{' + (0, _collections.printObjectProperties)(val, config, indentation, depth, refs, printer) + '}';
|
|
}
|
|
|
|
function isNewPlugin(plugin) {
|
|
return plugin.serialize != null;
|
|
}
|
|
|
|
function printPlugin(plugin, val, config, indentation, depth, refs) {
|
|
var printed;
|
|
|
|
try {
|
|
printed = isNewPlugin(plugin) ? plugin.serialize(val, config, indentation, depth, refs, printer) : plugin.print(val, function (valChild) {
|
|
return printer(valChild, config, indentation, depth, refs);
|
|
}, function (str) {
|
|
var indentationNext = indentation + config.indent;
|
|
return indentationNext + str.replace(NEWLINE_REGEXP, '\n' + indentationNext);
|
|
}, {
|
|
edgeSpacing: config.spacingOuter,
|
|
min: config.min,
|
|
spacing: config.spacingInner
|
|
}, config.colors);
|
|
} catch (error) {
|
|
throw new PrettyFormatPluginError(error.message, error.stack);
|
|
}
|
|
|
|
if (typeof printed !== 'string') {
|
|
throw new Error("pretty-format: Plugin must return type \"string\" but instead returned \"".concat(_typeof(printed), "\"."));
|
|
}
|
|
|
|
return printed;
|
|
}
|
|
|
|
function findPlugin(plugins, val) {
|
|
for (var p = 0; p < plugins.length; p++) {
|
|
try {
|
|
if (plugins[p].test(val)) {
|
|
return plugins[p];
|
|
}
|
|
} catch (error) {
|
|
throw new PrettyFormatPluginError(error.message, error.stack);
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
var plugin = findPlugin(config.plugins, val);
|
|
|
|
if (plugin !== null) {
|
|
return printPlugin(plugin, val, config, indentation, depth, refs);
|
|
}
|
|
|
|
var basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
|
|
|
|
if (basicResult !== null) {
|
|
return basicResult;
|
|
}
|
|
|
|
return printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
|
|
}
|
|
|
|
var DEFAULT_THEME = {
|
|
comment: 'gray',
|
|
content: 'reset',
|
|
prop: 'yellow',
|
|
tag: 'cyan',
|
|
value: 'green'
|
|
};
|
|
var DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
|
|
var DEFAULT_OPTIONS = {
|
|
callToJSON: true,
|
|
escapeRegex: false,
|
|
escapeString: true,
|
|
highlight: false,
|
|
indent: 2,
|
|
maxDepth: Infinity,
|
|
min: false,
|
|
plugins: [],
|
|
printFunctionName: true,
|
|
theme: DEFAULT_THEME
|
|
};
|
|
|
|
function validateOptions(options) {
|
|
Object.keys(options).forEach(function (key) {
|
|
if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
|
|
throw new Error("pretty-format: Unknown option \"".concat(key, "\"."));
|
|
}
|
|
});
|
|
|
|
if (options.min && options.indent !== undefined && options.indent !== 0) {
|
|
throw new Error('pretty-format: Options "min" and "indent" cannot be used together.');
|
|
}
|
|
|
|
if (options.theme !== undefined) {
|
|
if (options.theme === null) {
|
|
throw new Error("pretty-format: Option \"theme\" must not be null.");
|
|
}
|
|
|
|
if (_typeof(options.theme) !== 'object') {
|
|
throw new Error("pretty-format: Option \"theme\" must be of type \"object\" but instead received \"".concat(_typeof(options.theme), "\"."));
|
|
}
|
|
}
|
|
}
|
|
|
|
var getColorsHighlight = function getColorsHighlight(options) {
|
|
return DEFAULT_THEME_KEYS.reduce(function (colors, key) {
|
|
var value = options.theme && options.theme[key] !== undefined ? options.theme[key] : DEFAULT_THEME[key];
|
|
var color = value && _ansiStyles.default[value];
|
|
|
|
if (color && typeof color.close === 'string' && typeof color.open === 'string') {
|
|
colors[key] = color;
|
|
} else {
|
|
throw new Error("pretty-format: Option \"theme\" has a key \"".concat(key, "\" whose value \"").concat(value, "\" is undefined in ansi-styles."));
|
|
}
|
|
|
|
return colors;
|
|
}, Object.create(null));
|
|
};
|
|
|
|
var getColorsEmpty = function getColorsEmpty() {
|
|
return DEFAULT_THEME_KEYS.reduce(function (colors, key) {
|
|
colors[key] = {
|
|
close: '',
|
|
open: ''
|
|
};
|
|
return colors;
|
|
}, Object.create(null));
|
|
};
|
|
|
|
var getPrintFunctionName = function getPrintFunctionName(options) {
|
|
return options && options.printFunctionName !== undefined ? options.printFunctionName : DEFAULT_OPTIONS.printFunctionName;
|
|
};
|
|
|
|
var getEscapeRegex = function getEscapeRegex(options) {
|
|
return options && options.escapeRegex !== undefined ? options.escapeRegex : DEFAULT_OPTIONS.escapeRegex;
|
|
};
|
|
|
|
var getEscapeString = function getEscapeString(options) {
|
|
return options && options.escapeString !== undefined ? options.escapeString : DEFAULT_OPTIONS.escapeString;
|
|
};
|
|
|
|
var getConfig = function getConfig(options) {
|
|
return {
|
|
callToJSON: options && options.callToJSON !== undefined ? options.callToJSON : DEFAULT_OPTIONS.callToJSON,
|
|
colors: options && options.highlight ? getColorsHighlight(options) : getColorsEmpty(),
|
|
escapeRegex: getEscapeRegex(options),
|
|
escapeString: getEscapeString(options),
|
|
indent: options && options.min ? '' : createIndent(options && options.indent !== undefined ? options.indent : DEFAULT_OPTIONS.indent),
|
|
maxDepth: options && options.maxDepth !== undefined ? options.maxDepth : DEFAULT_OPTIONS.maxDepth,
|
|
min: options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
|
|
plugins: options && options.plugins !== undefined ? options.plugins : DEFAULT_OPTIONS.plugins,
|
|
printFunctionName: getPrintFunctionName(options),
|
|
spacingInner: options && options.min ? ' ' : '\n',
|
|
spacingOuter: options && options.min ? '' : '\n'
|
|
};
|
|
};
|
|
|
|
function createIndent(indent) {
|
|
return new Array(indent + 1).join(' ');
|
|
}
|
|
/**
|
|
* Returns a presentation string of your `val` object
|
|
* @param val any potential JavaScript object
|
|
* @param options Custom settings
|
|
*/
|
|
|
|
|
|
function prettyFormat(val, options) {
|
|
if (options) {
|
|
validateOptions(options);
|
|
|
|
if (options.plugins) {
|
|
var plugin = findPlugin(options.plugins, val);
|
|
|
|
if (plugin !== null) {
|
|
return printPlugin(plugin, val, getConfig(options), '', 0, []);
|
|
}
|
|
}
|
|
}
|
|
|
|
var basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options), getEscapeString(options));
|
|
|
|
if (basicResult !== null) {
|
|
return basicResult;
|
|
}
|
|
|
|
return printComplexValue(val, getConfig(options), '', 0, []);
|
|
}
|
|
|
|
prettyFormat.plugins = {
|
|
AsymmetricMatcher: _AsymmetricMatcher.default,
|
|
ConvertAnsi: _ConvertAnsi.default,
|
|
DOMCollection: _DOMCollection.default,
|
|
DOMElement: _DOMElement.default,
|
|
Immutable: _Immutable.default,
|
|
ReactElement: _ReactElement.default,
|
|
ReactTestComponent: _ReactTestComponent.default
|
|
}; // eslint-disable-next-line no-redeclare
|
|
|
|
module.exports = prettyFormat;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/AsymmetricMatcher.ts":
|
|
/*!*****************************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/AsymmetricMatcher.ts ***!
|
|
\*****************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.test = exports.serialize = void 0;
|
|
|
|
var _collections = __webpack_require__(/*! ../collections */ "./packages/pretty-format/src/collections.ts");
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
var asymmetricMatcher = typeof Symbol === 'function' && Symbol.for ? Symbol.for('jest.asymmetricMatcher') : 0x1357a5;
|
|
var SPACE = ' ';
|
|
|
|
var serialize = function serialize(val, config, indentation, depth, refs, printer) {
|
|
var stringedValue = val.toString();
|
|
|
|
if (stringedValue === 'ArrayContaining' || stringedValue === 'ArrayNotContaining') {
|
|
if (++depth > config.maxDepth) {
|
|
return '[' + stringedValue + ']';
|
|
}
|
|
|
|
return stringedValue + SPACE + '[' + (0, _collections.printListItems)(val.sample, config, indentation, depth, refs, printer) + ']';
|
|
}
|
|
|
|
if (stringedValue === 'ObjectContaining' || stringedValue === 'ObjectNotContaining') {
|
|
if (++depth > config.maxDepth) {
|
|
return '[' + stringedValue + ']';
|
|
}
|
|
|
|
return stringedValue + SPACE + '{' + (0, _collections.printObjectProperties)(val.sample, config, indentation, depth, refs, printer) + '}';
|
|
}
|
|
|
|
if (stringedValue === 'StringMatching' || stringedValue === 'StringNotMatching') {
|
|
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
|
|
}
|
|
|
|
if (stringedValue === 'StringContaining' || stringedValue === 'StringNotContaining') {
|
|
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
|
|
}
|
|
|
|
return val.toAsymmetricMatcher();
|
|
};
|
|
|
|
exports.serialize = serialize;
|
|
|
|
var test = function test(val) {
|
|
return val && val.$$typeof === asymmetricMatcher;
|
|
};
|
|
|
|
exports.test = test;
|
|
var plugin = {
|
|
serialize: serialize,
|
|
test: test
|
|
};
|
|
var _default = plugin;
|
|
exports.default = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/ConvertAnsi.ts":
|
|
/*!***********************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/ConvertAnsi.ts ***!
|
|
\***********************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.serialize = exports.test = void 0;
|
|
|
|
var _ansiRegex = _interopRequireDefault(__webpack_require__(/*! ansi-regex */ "./node_modules/ansi-regex/index.js"));
|
|
|
|
var _ansiStyles = _interopRequireDefault(__webpack_require__(/*! ansi-styles */ "./node_modules/ansi-styles/index.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
var toHumanReadableAnsi = function toHumanReadableAnsi(text) {
|
|
return text.replace((0, _ansiRegex.default)(), function (match) {
|
|
switch (match) {
|
|
case _ansiStyles.default.red.close:
|
|
case _ansiStyles.default.green.close:
|
|
case _ansiStyles.default.cyan.close:
|
|
case _ansiStyles.default.gray.close:
|
|
case _ansiStyles.default.white.close:
|
|
case _ansiStyles.default.yellow.close:
|
|
case _ansiStyles.default.bgRed.close:
|
|
case _ansiStyles.default.bgGreen.close:
|
|
case _ansiStyles.default.bgYellow.close:
|
|
case _ansiStyles.default.inverse.close:
|
|
case _ansiStyles.default.dim.close:
|
|
case _ansiStyles.default.bold.close:
|
|
case _ansiStyles.default.reset.open:
|
|
case _ansiStyles.default.reset.close:
|
|
return '</>';
|
|
|
|
case _ansiStyles.default.red.open:
|
|
return '<red>';
|
|
|
|
case _ansiStyles.default.green.open:
|
|
return '<green>';
|
|
|
|
case _ansiStyles.default.cyan.open:
|
|
return '<cyan>';
|
|
|
|
case _ansiStyles.default.gray.open:
|
|
return '<gray>';
|
|
|
|
case _ansiStyles.default.white.open:
|
|
return '<white>';
|
|
|
|
case _ansiStyles.default.yellow.open:
|
|
return '<yellow>';
|
|
|
|
case _ansiStyles.default.bgRed.open:
|
|
return '<bgRed>';
|
|
|
|
case _ansiStyles.default.bgGreen.open:
|
|
return '<bgGreen>';
|
|
|
|
case _ansiStyles.default.bgYellow.open:
|
|
return '<bgYellow>';
|
|
|
|
case _ansiStyles.default.inverse.open:
|
|
return '<inverse>';
|
|
|
|
case _ansiStyles.default.dim.open:
|
|
return '<dim>';
|
|
|
|
case _ansiStyles.default.bold.open:
|
|
return '<bold>';
|
|
|
|
default:
|
|
return '';
|
|
}
|
|
});
|
|
};
|
|
|
|
var test = function test(val) {
|
|
return typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
|
|
};
|
|
|
|
exports.test = test;
|
|
|
|
var serialize = function serialize(val, config, indentation, depth, refs, printer) {
|
|
return printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
|
|
};
|
|
|
|
exports.serialize = serialize;
|
|
var plugin = {
|
|
serialize: serialize,
|
|
test: test
|
|
};
|
|
var _default = plugin;
|
|
exports.default = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/DOMCollection.ts":
|
|
/*!*************************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/DOMCollection.ts ***!
|
|
\*************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.serialize = exports.test = void 0;
|
|
|
|
var _collections = __webpack_require__(/*! ../collections */ "./packages/pretty-format/src/collections.ts");
|
|
|
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
var SPACE = ' ';
|
|
var OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
|
|
var ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
|
|
|
|
var testName = function testName(name) {
|
|
return OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
|
|
};
|
|
|
|
var test = function test(val) {
|
|
return val && val.constructor && !!val.constructor.name && testName(val.constructor.name);
|
|
};
|
|
|
|
exports.test = test;
|
|
|
|
var isNamedNodeMap = function isNamedNodeMap(collection) {
|
|
return collection.constructor.name === 'NamedNodeMap';
|
|
};
|
|
|
|
var serialize = function serialize(collection, config, indentation, depth, refs, printer) {
|
|
var name = collection.constructor.name;
|
|
|
|
if (++depth > config.maxDepth) {
|
|
return '[' + name + ']';
|
|
}
|
|
|
|
return (config.min ? '' : name + SPACE) + (OBJECT_NAMES.indexOf(name) !== -1 ? '{' + (0, _collections.printObjectProperties)(isNamedNodeMap(collection) ? Array.from(collection).reduce(function (props, attribute) {
|
|
props[attribute.name] = attribute.value;
|
|
return props;
|
|
}, {}) : _objectSpread({}, collection), config, indentation, depth, refs, printer) + '}' : '[' + (0, _collections.printListItems)(Array.from(collection), config, indentation, depth, refs, printer) + ']');
|
|
};
|
|
|
|
exports.serialize = serialize;
|
|
var plugin = {
|
|
serialize: serialize,
|
|
test: test
|
|
};
|
|
var _default = plugin;
|
|
exports.default = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/DOMElement.ts":
|
|
/*!**********************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/DOMElement.ts ***!
|
|
\**********************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.serialize = exports.test = void 0;
|
|
|
|
var _markup = __webpack_require__(/*! ./lib/markup */ "./packages/pretty-format/src/plugins/lib/markup.ts");
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
var ELEMENT_NODE = 1;
|
|
var TEXT_NODE = 3;
|
|
var COMMENT_NODE = 8;
|
|
var FRAGMENT_NODE = 11;
|
|
var ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
|
|
|
|
var testNode = function testNode(nodeType, name) {
|
|
return nodeType === ELEMENT_NODE && ELEMENT_REGEXP.test(name) || nodeType === TEXT_NODE && name === 'Text' || nodeType === COMMENT_NODE && name === 'Comment' || nodeType === FRAGMENT_NODE && name === 'DocumentFragment';
|
|
};
|
|
|
|
var test = function test(val) {
|
|
return val && val.constructor && val.constructor.name && testNode(val.nodeType, val.constructor.name);
|
|
};
|
|
|
|
exports.test = test;
|
|
|
|
function nodeIsText(node) {
|
|
return node.nodeType === TEXT_NODE;
|
|
}
|
|
|
|
function nodeIsComment(node) {
|
|
return node.nodeType === COMMENT_NODE;
|
|
}
|
|
|
|
function nodeIsFragment(node) {
|
|
return node.nodeType === FRAGMENT_NODE;
|
|
}
|
|
|
|
var serialize = function serialize(node, config, indentation, depth, refs, printer) {
|
|
if (nodeIsText(node)) {
|
|
return (0, _markup.printText)(node.data, config);
|
|
}
|
|
|
|
if (nodeIsComment(node)) {
|
|
return (0, _markup.printComment)(node.data, config);
|
|
}
|
|
|
|
var type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase();
|
|
|
|
if (++depth > config.maxDepth) {
|
|
return (0, _markup.printElementAsLeaf)(type, config);
|
|
}
|
|
|
|
return (0, _markup.printElement)(type, (0, _markup.printProps)(nodeIsFragment(node) ? [] : Array.from(node.attributes).map(function (attr) {
|
|
return attr.name;
|
|
}).sort(), nodeIsFragment(node) ? {} : Array.from(node.attributes).reduce(function (props, attribute) {
|
|
props[attribute.name] = attribute.value;
|
|
return props;
|
|
}, {}), config, indentation + config.indent, depth, refs, printer), (0, _markup.printChildren)(Array.prototype.slice.call(node.childNodes || node.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
|
|
};
|
|
|
|
exports.serialize = serialize;
|
|
var plugin = {
|
|
serialize: serialize,
|
|
test: test
|
|
};
|
|
var _default = plugin;
|
|
exports.default = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/Immutable.ts":
|
|
/*!*********************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/Immutable.ts ***!
|
|
\*********************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.test = exports.serialize = void 0;
|
|
|
|
var _collections = __webpack_require__(/*! ../collections */ "./packages/pretty-format/src/collections.ts");
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
// SENTINEL constants are from https://github.com/facebook/immutable-js
|
|
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
|
|
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
|
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
|
|
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
|
|
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
|
|
var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
|
|
|
|
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
|
|
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
|
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
|
|
|
|
var getImmutableName = function getImmutableName(name) {
|
|
return 'Immutable.' + name;
|
|
};
|
|
|
|
var printAsLeaf = function printAsLeaf(name) {
|
|
return '[' + name + ']';
|
|
};
|
|
|
|
var SPACE = ' ';
|
|
var LAZY = '…'; // Seq is lazy if it calls a method like filter
|
|
|
|
var printImmutableEntries = function printImmutableEntries(val, config, indentation, depth, refs, printer, type) {
|
|
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE + '{' + (0, _collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer) + '}';
|
|
}; // Record has an entries method because it is a collection in immutable v3.
|
|
// Return an iterator for Immutable Record from version v3 or v4.
|
|
|
|
|
|
function getRecordEntries(val) {
|
|
var i = 0;
|
|
return {
|
|
next: function next() {
|
|
if (i < val._keys.length) {
|
|
var key = val._keys[i++];
|
|
return {
|
|
done: false,
|
|
value: [key, val.get(key)]
|
|
};
|
|
}
|
|
|
|
return {
|
|
done: true,
|
|
value: undefined
|
|
};
|
|
}
|
|
};
|
|
}
|
|
|
|
var printImmutableRecord = function printImmutableRecord(val, config, indentation, depth, refs, printer) {
|
|
// _name property is defined only for an Immutable Record instance
|
|
// which was constructed with a second optional descriptive name arg
|
|
var name = getImmutableName(val._name || 'Record');
|
|
return ++depth > config.maxDepth ? printAsLeaf(name) : name + SPACE + '{' + (0, _collections.printIteratorEntries)(getRecordEntries(val), config, indentation, depth, refs, printer) + '}';
|
|
};
|
|
|
|
var printImmutableSeq = function printImmutableSeq(val, config, indentation, depth, refs, printer) {
|
|
var name = getImmutableName('Seq');
|
|
|
|
if (++depth > config.maxDepth) {
|
|
return printAsLeaf(name);
|
|
}
|
|
|
|
if (val[IS_KEYED_SENTINEL]) {
|
|
return name + SPACE + '{' + ( // from Immutable collection of entries or from ECMAScript object
|
|
val._iter || val._object ? (0, _collections.printIteratorEntries)(val.entries(), config, indentation, depth, refs, printer) : LAZY) + '}';
|
|
}
|
|
|
|
return name + SPACE + '[' + (val._iter || // from Immutable collection of values
|
|
val._array || // from ECMAScript array
|
|
val._collection || // from ECMAScript collection in immutable v4
|
|
val._iterable // from ECMAScript collection in immutable v3
|
|
? (0, _collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) : LAZY) + ']';
|
|
};
|
|
|
|
var printImmutableValues = function printImmutableValues(val, config, indentation, depth, refs, printer, type) {
|
|
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE + '[' + (0, _collections.printIteratorValues)(val.values(), config, indentation, depth, refs, printer) + ']';
|
|
};
|
|
|
|
var serialize = function serialize(val, config, indentation, depth, refs, printer) {
|
|
if (val[IS_MAP_SENTINEL]) {
|
|
return printImmutableEntries(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map');
|
|
}
|
|
|
|
if (val[IS_LIST_SENTINEL]) {
|
|
return printImmutableValues(val, config, indentation, depth, refs, printer, 'List');
|
|
}
|
|
|
|
if (val[IS_SET_SENTINEL]) {
|
|
return printImmutableValues(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set');
|
|
}
|
|
|
|
if (val[IS_STACK_SENTINEL]) {
|
|
return printImmutableValues(val, config, indentation, depth, refs, printer, 'Stack');
|
|
}
|
|
|
|
if (val[IS_SEQ_SENTINEL]) {
|
|
return printImmutableSeq(val, config, indentation, depth, refs, printer);
|
|
} // For compatibility with immutable v3 and v4, let record be the default.
|
|
|
|
|
|
return printImmutableRecord(val, config, indentation, depth, refs, printer);
|
|
}; // Explicitly comparing sentinel properties to true avoids false positive
|
|
// when mock identity-obj-proxy returns the key as the value for any key.
|
|
|
|
|
|
exports.serialize = serialize;
|
|
|
|
var test = function test(val) {
|
|
return val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
|
|
};
|
|
|
|
exports.test = test;
|
|
var plugin = {
|
|
serialize: serialize,
|
|
test: test
|
|
};
|
|
var _default = plugin;
|
|
exports.default = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/ReactElement.ts":
|
|
/*!************************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/ReactElement.ts ***!
|
|
\************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.test = exports.serialize = void 0;
|
|
|
|
var ReactIs = _interopRequireWildcard(__webpack_require__(/*! react-is */ "./node_modules/react-is/index.js"));
|
|
|
|
var _markup = __webpack_require__(/*! ./lib/markup */ "./packages/pretty-format/src/plugins/lib/markup.ts");
|
|
|
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
|
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
// Given element.props.children, or subtree during recursive traversal,
|
|
// return flattened array of children.
|
|
var getChildren = function getChildren(arg) {
|
|
var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
|
|
if (Array.isArray(arg)) {
|
|
arg.forEach(function (item) {
|
|
getChildren(item, children);
|
|
});
|
|
} else if (arg != null && arg !== false) {
|
|
children.push(arg);
|
|
}
|
|
|
|
return children;
|
|
};
|
|
|
|
var getType = function getType(element) {
|
|
var type = element.type;
|
|
|
|
if (typeof type === 'string') {
|
|
return type;
|
|
}
|
|
|
|
if (typeof type === 'function') {
|
|
return type.displayName || type.name || 'Unknown';
|
|
}
|
|
|
|
if (ReactIs.isFragment(element)) {
|
|
return 'React.Fragment';
|
|
}
|
|
|
|
if (ReactIs.isSuspense(element)) {
|
|
return 'React.Suspense';
|
|
}
|
|
|
|
if (_typeof(type) === 'object' && type !== null) {
|
|
if (ReactIs.isContextProvider(element)) {
|
|
return 'Context.Provider';
|
|
}
|
|
|
|
if (ReactIs.isContextConsumer(element)) {
|
|
return 'Context.Consumer';
|
|
}
|
|
|
|
if (ReactIs.isForwardRef(element)) {
|
|
if (type.displayName) {
|
|
return type.displayName;
|
|
}
|
|
|
|
var functionName = type.render.displayName || type.render.name || '';
|
|
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
|
}
|
|
|
|
if (ReactIs.isMemo(element)) {
|
|
var _functionName = type.displayName || type.type.displayName || type.type.name || '';
|
|
|
|
return _functionName !== '' ? 'Memo(' + _functionName + ')' : 'Memo';
|
|
}
|
|
}
|
|
|
|
return 'UNDEFINED';
|
|
};
|
|
|
|
var getPropKeys = function getPropKeys(element) {
|
|
var props = element.props;
|
|
return Object.keys(props).filter(function (key) {
|
|
return key !== 'children' && props[key] !== undefined;
|
|
}).sort();
|
|
};
|
|
|
|
var serialize = function serialize(element, config, indentation, depth, refs, printer) {
|
|
return ++depth > config.maxDepth ? (0, _markup.printElementAsLeaf)(getType(element), config) : (0, _markup.printElement)(getType(element), (0, _markup.printProps)(getPropKeys(element), element.props, config, indentation + config.indent, depth, refs, printer), (0, _markup.printChildren)(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
|
|
};
|
|
|
|
exports.serialize = serialize;
|
|
|
|
var test = function test(val) {
|
|
return val && ReactIs.isElement(val);
|
|
};
|
|
|
|
exports.test = test;
|
|
var plugin = {
|
|
serialize: serialize,
|
|
test: test
|
|
};
|
|
var _default = plugin;
|
|
exports.default = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/ReactTestComponent.ts":
|
|
/*!******************************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/ReactTestComponent.ts ***!
|
|
\******************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = exports.test = exports.serialize = void 0;
|
|
|
|
var _markup = __webpack_require__(/*! ./lib/markup */ "./packages/pretty-format/src/plugins/lib/markup.ts");
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
// Child can be `number` in Stack renderer but not in Fiber renderer.
|
|
var testSymbol = typeof Symbol === 'function' && Symbol.for ? Symbol.for('react.test.json') : 0xea71357;
|
|
|
|
var getPropKeys = function getPropKeys(object) {
|
|
var props = object.props;
|
|
return props ? Object.keys(props).filter(function (key) {
|
|
return props[key] !== undefined;
|
|
}).sort() : [];
|
|
};
|
|
|
|
var serialize = function serialize(object, config, indentation, depth, refs, printer) {
|
|
return ++depth > config.maxDepth ? (0, _markup.printElementAsLeaf)(object.type, config) : (0, _markup.printElement)(object.type, object.props ? (0, _markup.printProps)(getPropKeys(object), object.props, config, indentation + config.indent, depth, refs, printer) : '', object.children ? (0, _markup.printChildren)(object.children, config, indentation + config.indent, depth, refs, printer) : '', config, indentation);
|
|
};
|
|
|
|
exports.serialize = serialize;
|
|
|
|
var test = function test(val) {
|
|
return val && val.$$typeof === testSymbol;
|
|
};
|
|
|
|
exports.test = test;
|
|
var plugin = {
|
|
serialize: serialize,
|
|
test: test
|
|
};
|
|
var _default = plugin;
|
|
exports.default = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/lib/escapeHTML.ts":
|
|
/*!**************************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/lib/escapeHTML.ts ***!
|
|
\**************************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = escapeHTML;
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
function escapeHTML(str) {
|
|
return str.replace(/</g, '<').replace(/>/g, '>');
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./packages/pretty-format/src/plugins/lib/markup.ts":
|
|
/*!**********************************************************!*\
|
|
!*** ./packages/pretty-format/src/plugins/lib/markup.ts ***!
|
|
\**********************************************************/
|
|
/*! no static exports found */
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = void 0;
|
|
|
|
var _escapeHTML = _interopRequireDefault(__webpack_require__(/*! ./escapeHTML */ "./packages/pretty-format/src/plugins/lib/escapeHTML.ts"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
// Return empty string if keys is empty.
|
|
var printProps = function printProps(keys, props, config, indentation, depth, refs, printer) {
|
|
var indentationNext = indentation + config.indent;
|
|
var colors = config.colors;
|
|
return keys.map(function (key) {
|
|
var value = props[key];
|
|
var printed = printer(value, config, indentationNext, depth, refs);
|
|
|
|
if (typeof value !== 'string') {
|
|
if (printed.indexOf('\n') !== -1) {
|
|
printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
|
|
}
|
|
|
|
printed = '{' + printed + '}';
|
|
}
|
|
|
|
return config.spacingInner + indentation + colors.prop.open + key + colors.prop.close + '=' + colors.value.open + printed + colors.value.close;
|
|
}).join('');
|
|
}; // Return empty string if children is empty.
|
|
|
|
|
|
exports.printProps = printProps;
|
|
|
|
var printChildren = function printChildren(children, config, indentation, depth, refs, printer) {
|
|
return children.map(function (child) {
|
|
return config.spacingOuter + indentation + (typeof child === 'string' ? printText(child, config) : printer(child, config, indentation, depth, refs));
|
|
}).join('');
|
|
};
|
|
|
|
exports.printChildren = printChildren;
|
|
|
|
var printText = function printText(text, config) {
|
|
var contentColor = config.colors.content;
|
|
return contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close;
|
|
};
|
|
|
|
exports.printText = printText;
|
|
|
|
var printComment = function printComment(comment, config) {
|
|
var commentColor = config.colors.comment;
|
|
return commentColor.open + '<!--' + (0, _escapeHTML.default)(comment) + '-->' + commentColor.close;
|
|
}; // Separate the functions to format props, children, and element,
|
|
// so a plugin could override a particular function, if needed.
|
|
// Too bad, so sad: the traditional (but unnecessary) space
|
|
// in a self-closing tagColor requires a second test of printedProps.
|
|
|
|
|
|
exports.printComment = printComment;
|
|
|
|
var printElement = function printElement(type, printedProps, printedChildren, config, indentation) {
|
|
var tagColor = config.colors.tag;
|
|
return tagColor.open + '<' + type + (printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open) + (printedChildren ? '>' + tagColor.close + printedChildren + config.spacingOuter + indentation + tagColor.open + '</' + type : (printedProps && !config.min ? '' : ' ') + '/') + '>' + tagColor.close;
|
|
};
|
|
|
|
exports.printElement = printElement;
|
|
|
|
var printElementAsLeaf = function printElementAsLeaf(type, config) {
|
|
var tagColor = config.colors.tag;
|
|
return tagColor.open + '<' + type + tagColor.close + ' …' + tagColor.open + ' />' + tagColor.close;
|
|
};
|
|
|
|
exports.printElementAsLeaf = printElementAsLeaf;
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
});
|
|
//# sourceMappingURL=index.js.map
|