diff options
Diffstat (limited to 'node_modules/pretty-format/build')
24 files changed, 2136 insertions, 0 deletions
diff --git a/node_modules/pretty-format/build/collections.d.ts b/node_modules/pretty-format/build/collections.d.ts new file mode 100644 index 0000000..eaf7e61 --- /dev/null +++ b/node_modules/pretty-format/build/collections.d.ts @@ -0,0 +1,32 @@ +/** + * 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. + * + */ +import type { Config, Printer, Refs } from './types'; +/** + * Return entries (for example, of a map) + * with spacing, indentation, and comma + * without surrounding punctuation (for example, braces) + */ +export declare function printIteratorEntries(iterator: Iterator<[unknown, unknown]>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer, separator?: string): string; +/** + * Return values (for example, of a set) + * with spacing, indentation, and comma + * without surrounding punctuation (braces or brackets) + */ +export declare function printIteratorValues(iterator: Iterator<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string; +/** + * Return items (for example, of an array) + * with spacing, indentation, and comma + * without surrounding punctuation (for example, brackets) + **/ +export declare function printListItems(list: ArrayLike<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string; +/** + * Return properties of an object + * with spacing, indentation, and comma + * without surrounding punctuation (for example, braces) + */ +export declare function printObjectProperties(val: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string; diff --git a/node_modules/pretty-format/build/collections.js b/node_modules/pretty-format/build/collections.js new file mode 100644 index 0000000..004e349 --- /dev/null +++ b/node_modules/pretty-format/build/collections.js @@ -0,0 +1,187 @@ +'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. + * + */ +const getKeysOfEnumerableProperties = (object, compareKeys) => { + const keys = Object.keys(object).sort(compareKeys); + + if (Object.getOwnPropertySymbols) { + Object.getOwnPropertySymbols(object).forEach(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, // Too bad, so sad that separator for ECMAScript Map has been ' => ' + // What a distracting diff if you change a data structure to/from + // ECMAScript Object or Immutable.Map/OrderedMap which use the default. + separator = ': ' +) { + let result = ''; + let current = iterator.next(); + + if (!current.done) { + result += config.spacingOuter; + const indentationNext = indentation + config.indent; + + while (!current.done) { + const name = printer( + current.value[0], + config, + indentationNext, + depth, + refs + ); + const 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 +) { + let result = ''; + let current = iterator.next(); + + if (!current.done) { + result += config.spacingOuter; + const 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) { + let result = ''; + + if (list.length) { + result += config.spacingOuter; + const indentationNext = indentation + config.indent; + + for (let i = 0; i < list.length; i++) { + result += indentationNext; + + if (i in list) { + result += 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) { + let result = ''; + const keys = getKeysOfEnumerableProperties(val, config.compareKeys); + + if (keys.length) { + result += config.spacingOuter; + const indentationNext = indentation + config.indent; + + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const name = printer(key, config, indentationNext, depth, refs); + const 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; +} diff --git a/node_modules/pretty-format/build/index.d.ts b/node_modules/pretty-format/build/index.d.ts new file mode 100644 index 0000000..f62f82f --- /dev/null +++ b/node_modules/pretty-format/build/index.d.ts @@ -0,0 +1,25 @@ +/** + * 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. + */ +import type { NewPlugin, Options, OptionsReceived } from './types'; +export type { Colors, CompareKeys, Config, Options, OptionsReceived, OldPlugin, NewPlugin, Plugin, Plugins, PrettyFormatOptions, Printer, Refs, Theme, } from './types'; +export declare const DEFAULT_OPTIONS: Options; +/** + * Returns a presentation string of your `val` object + * @param val any potential JavaScript object + * @param options Custom settings + */ +export declare function format(val: unknown, options?: OptionsReceived): string; +export declare const plugins: { + AsymmetricMatcher: NewPlugin; + ConvertAnsi: NewPlugin; + DOMCollection: NewPlugin; + DOMElement: NewPlugin; + Immutable: NewPlugin; + ReactElement: NewPlugin; + ReactTestComponent: NewPlugin; +}; +export default format; diff --git a/node_modules/pretty-format/build/index.js b/node_modules/pretty-format/build/index.js new file mode 100644 index 0000000..9ebfa6f --- /dev/null +++ b/node_modules/pretty-format/build/index.js @@ -0,0 +1,597 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = exports.DEFAULT_OPTIONS = void 0; +exports.format = format; +exports.plugins = void 0; + +var _ansiStyles = _interopRequireDefault(require('ansi-styles')); + +var _collections = require('./collections'); + +var _AsymmetricMatcher = _interopRequireDefault( + require('./plugins/AsymmetricMatcher') +); + +var _ConvertAnsi = _interopRequireDefault(require('./plugins/ConvertAnsi')); + +var _DOMCollection = _interopRequireDefault(require('./plugins/DOMCollection')); + +var _DOMElement = _interopRequireDefault(require('./plugins/DOMElement')); + +var _Immutable = _interopRequireDefault(require('./plugins/Immutable')); + +var _ReactElement = _interopRequireDefault(require('./plugins/ReactElement')); + +var _ReactTestComponent = _interopRequireDefault( + require('./plugins/ReactTestComponent') +); + +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. + */ + +/* eslint-disable local/ban-types-eventually */ +const toString = Object.prototype.toString; +const toISOString = Date.prototype.toISOString; +const errorToString = Error.prototype.toString; +const 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. + */ + +const getConstructorName = val => + (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 :) */ + +const isWindow = val => typeof window !== 'undefined' && val === window; + +const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/; +const NEWLINE_REGEXP = /\n/gi; + +class PrettyFormatPluginError extends Error { + constructor(message, stack) { + super(message); + this.stack = stack; + this.name = this.constructor.name; + } +} + +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(`${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'; + } + + const 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); + } + + const 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/main/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); + const hitMaxDepth = ++depth > config.maxDepth; + const min = config.min; + + if ( + config.callToJSON && + !hitMaxDepth && + val.toJSON && + typeof val.toJSON === 'function' && + !hasCalledToJSON + ) { + return printer(val.toJSON(), config, indentation, depth, refs, true); + } + + const 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 + ? '' + : !config.printBasicPrototype && val.constructor.name === 'Array' + ? '' + : 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 + ? '' + : !config.printBasicPrototype && getConstructorName(val) === 'Object' + ? '' + : 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) { + let printed; + + try { + printed = isNewPlugin(plugin) + ? plugin.serialize(val, config, indentation, depth, refs, printer) + : plugin.print( + val, + valChild => printer(valChild, config, indentation, depth, refs), + str => { + const 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 "${typeof printed}".` + ); + } + + return printed; +} + +function findPlugin(plugins, val) { + for (let 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) { + const plugin = findPlugin(config.plugins, val); + + if (plugin !== null) { + return printPlugin(plugin, val, config, indentation, depth, refs); + } + + const basicResult = printBasicValue( + val, + config.printFunctionName, + config.escapeRegex, + config.escapeString + ); + + if (basicResult !== null) { + return basicResult; + } + + return printComplexValue( + val, + config, + indentation, + depth, + refs, + hasCalledToJSON + ); +} + +const DEFAULT_THEME = { + comment: 'gray', + content: 'reset', + prop: 'yellow', + tag: 'cyan', + value: 'green' +}; +const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME); +const DEFAULT_OPTIONS = { + callToJSON: true, + compareKeys: undefined, + escapeRegex: false, + escapeString: true, + highlight: false, + indent: 2, + maxDepth: Infinity, + min: false, + plugins: [], + printBasicPrototype: true, + printFunctionName: true, + theme: DEFAULT_THEME +}; +exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS; + +function validateOptions(options) { + Object.keys(options).forEach(key => { + if (!DEFAULT_OPTIONS.hasOwnProperty(key)) { + throw new Error(`pretty-format: Unknown option "${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 "${typeof options.theme}".` + ); + } + } +} + +const getColorsHighlight = options => + DEFAULT_THEME_KEYS.reduce((colors, key) => { + const value = + options.theme && options.theme[key] !== undefined + ? options.theme[key] + : DEFAULT_THEME[key]; + const 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 "${key}" whose value "${value}" is undefined in ansi-styles.` + ); + } + + return colors; + }, Object.create(null)); + +const getColorsEmpty = () => + DEFAULT_THEME_KEYS.reduce((colors, key) => { + colors[key] = { + close: '', + open: '' + }; + return colors; + }, Object.create(null)); + +const getPrintFunctionName = options => + options && options.printFunctionName !== undefined + ? options.printFunctionName + : DEFAULT_OPTIONS.printFunctionName; + +const getEscapeRegex = options => + options && options.escapeRegex !== undefined + ? options.escapeRegex + : DEFAULT_OPTIONS.escapeRegex; + +const getEscapeString = options => + options && options.escapeString !== undefined + ? options.escapeString + : DEFAULT_OPTIONS.escapeString; + +const getConfig = options => { + var _options$printBasicPr; + + return { + callToJSON: + options && options.callToJSON !== undefined + ? options.callToJSON + : DEFAULT_OPTIONS.callToJSON, + colors: + options && options.highlight + ? getColorsHighlight(options) + : getColorsEmpty(), + compareKeys: + options && typeof options.compareKeys === 'function' + ? options.compareKeys + : DEFAULT_OPTIONS.compareKeys, + 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, + printBasicPrototype: + (_options$printBasicPr = + options === null || options === void 0 + ? void 0 + : options.printBasicPrototype) !== null && + _options$printBasicPr !== void 0 + ? _options$printBasicPr + : true, + 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 format(val, options) { + if (options) { + validateOptions(options); + + if (options.plugins) { + const plugin = findPlugin(options.plugins, val); + + if (plugin !== null) { + return printPlugin(plugin, val, getConfig(options), '', 0, []); + } + } + } + + const basicResult = printBasicValue( + val, + getPrintFunctionName(options), + getEscapeRegex(options), + getEscapeString(options) + ); + + if (basicResult !== null) { + return basicResult; + } + + return printComplexValue(val, getConfig(options), '', 0, []); +} + +const plugins = { + AsymmetricMatcher: _AsymmetricMatcher.default, + ConvertAnsi: _ConvertAnsi.default, + DOMCollection: _DOMCollection.default, + DOMElement: _DOMElement.default, + Immutable: _Immutable.default, + ReactElement: _ReactElement.default, + ReactTestComponent: _ReactTestComponent.default +}; +exports.plugins = plugins; +var _default = format; +exports.default = _default; diff --git a/node_modules/pretty-format/build/plugins/AsymmetricMatcher.d.ts b/node_modules/pretty-format/build/plugins/AsymmetricMatcher.d.ts new file mode 100644 index 0000000..fd2531b --- /dev/null +++ b/node_modules/pretty-format/build/plugins/AsymmetricMatcher.d.ts @@ -0,0 +1,11 @@ +/** + * 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. + */ +import type { NewPlugin } from '../types'; +export declare const serialize: NewPlugin['serialize']; +export declare const test: NewPlugin['test']; +declare const plugin: NewPlugin; +export default plugin; diff --git a/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js b/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js new file mode 100644 index 0000000..4003451 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js @@ -0,0 +1,117 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.test = exports.serialize = exports.default = void 0; + +var _collections = require('../collections'); + +var global = (function () { + if (typeof globalThis !== 'undefined') { + return globalThis; + } else if (typeof global !== 'undefined') { + return global; + } else if (typeof self !== 'undefined') { + return self; + } else if (typeof window !== 'undefined') { + return window; + } else { + return Function('return this')(); + } +})(); + +var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol; +const asymmetricMatcher = + typeof Symbol === 'function' && Symbol.for + ? Symbol.for('jest.asymmetricMatcher') + : 0x1357a5; +const SPACE = ' '; + +const serialize = (val, config, indentation, depth, refs, printer) => { + const 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; + +const test = val => val && val.$$typeof === asymmetricMatcher; + +exports.test = test; +const plugin = { + serialize, + test +}; +var _default = plugin; +exports.default = _default; diff --git a/node_modules/pretty-format/build/plugins/ConvertAnsi.d.ts b/node_modules/pretty-format/build/plugins/ConvertAnsi.d.ts new file mode 100644 index 0000000..bb0f507 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/ConvertAnsi.d.ts @@ -0,0 +1,11 @@ +/** + * 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. + */ +import type { NewPlugin } from '../types'; +export declare const test: NewPlugin['test']; +export declare const serialize: NewPlugin['serialize']; +declare const plugin: NewPlugin; +export default plugin; diff --git a/node_modules/pretty-format/build/plugins/ConvertAnsi.js b/node_modules/pretty-format/build/plugins/ConvertAnsi.js new file mode 100644 index 0000000..c5edf00 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/ConvertAnsi.js @@ -0,0 +1,96 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.test = exports.serialize = exports.default = void 0; + +var _ansiRegex = _interopRequireDefault(require('ansi-regex')); + +var _ansiStyles = _interopRequireDefault(require('ansi-styles')); + +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. + */ +const toHumanReadableAnsi = text => + text.replace((0, _ansiRegex.default)(), 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 ''; + } + }); + +const test = val => + typeof val === 'string' && !!val.match((0, _ansiRegex.default)()); + +exports.test = test; + +const serialize = (val, config, indentation, depth, refs, printer) => + printer(toHumanReadableAnsi(val), config, indentation, depth, refs); + +exports.serialize = serialize; +const plugin = { + serialize, + test +}; +var _default = plugin; +exports.default = _default; diff --git a/node_modules/pretty-format/build/plugins/DOMCollection.d.ts b/node_modules/pretty-format/build/plugins/DOMCollection.d.ts new file mode 100644 index 0000000..bb0f507 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/DOMCollection.d.ts @@ -0,0 +1,11 @@ +/** + * 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. + */ +import type { NewPlugin } from '../types'; +export declare const test: NewPlugin['test']; +export declare const serialize: NewPlugin['serialize']; +declare const plugin: NewPlugin; +export default plugin; diff --git a/node_modules/pretty-format/build/plugins/DOMCollection.js b/node_modules/pretty-format/build/plugins/DOMCollection.js new file mode 100644 index 0000000..f3dba3d --- /dev/null +++ b/node_modules/pretty-format/build/plugins/DOMCollection.js @@ -0,0 +1,80 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.test = exports.serialize = exports.default = void 0; + +var _collections = require('../collections'); + +/** + * 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. + */ + +/* eslint-disable local/ban-types-eventually */ +const SPACE = ' '; +const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap']; +const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/; + +const testName = name => + OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name); + +const test = val => + val && + val.constructor && + !!val.constructor.name && + testName(val.constructor.name); + +exports.test = test; + +const isNamedNodeMap = collection => + collection.constructor.name === 'NamedNodeMap'; + +const serialize = (collection, config, indentation, depth, refs, printer) => { + const 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((props, attribute) => { + props[attribute.name] = attribute.value; + return props; + }, {}) + : {...collection}, + config, + indentation, + depth, + refs, + printer + ) + + '}' + : '[' + + (0, _collections.printListItems)( + Array.from(collection), + config, + indentation, + depth, + refs, + printer + ) + + ']') + ); +}; + +exports.serialize = serialize; +const plugin = { + serialize, + test +}; +var _default = plugin; +exports.default = _default; diff --git a/node_modules/pretty-format/build/plugins/DOMElement.d.ts b/node_modules/pretty-format/build/plugins/DOMElement.d.ts new file mode 100644 index 0000000..bb0f507 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/DOMElement.d.ts @@ -0,0 +1,11 @@ +/** + * 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. + */ +import type { NewPlugin } from '../types'; +export declare const test: NewPlugin['test']; +export declare const serialize: NewPlugin['serialize']; +declare const plugin: NewPlugin; +export default plugin; diff --git a/node_modules/pretty-format/build/plugins/DOMElement.js b/node_modules/pretty-format/build/plugins/DOMElement.js new file mode 100644 index 0000000..b9d30ce --- /dev/null +++ b/node_modules/pretty-format/build/plugins/DOMElement.js @@ -0,0 +1,128 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.test = exports.serialize = exports.default = void 0; + +var _markup = require('./lib/markup'); + +/** + * 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. + */ +const ELEMENT_NODE = 1; +const TEXT_NODE = 3; +const COMMENT_NODE = 8; +const FRAGMENT_NODE = 11; +const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/; + +const testHasAttribute = val => { + try { + return typeof val.hasAttribute === 'function' && val.hasAttribute('is'); + } catch { + return false; + } +}; + +const testNode = val => { + const constructorName = val.constructor.name; + const {nodeType, tagName} = val; + const isCustomElement = + (typeof tagName === 'string' && tagName.includes('-')) || + testHasAttribute(val); + return ( + (nodeType === ELEMENT_NODE && + (ELEMENT_REGEXP.test(constructorName) || isCustomElement)) || + (nodeType === TEXT_NODE && constructorName === 'Text') || + (nodeType === COMMENT_NODE && constructorName === 'Comment') || + (nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment') + ); +}; + +const test = val => { + var _val$constructor; + + return ( + (val === null || val === void 0 + ? void 0 + : (_val$constructor = val.constructor) === null || + _val$constructor === void 0 + ? void 0 + : _val$constructor.name) && testNode(val) + ); +}; + +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; +} + +const 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); + } + + const 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(attr => attr.name) + .sort(), + nodeIsFragment(node) + ? {} + : Array.from(node.attributes).reduce((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; +const plugin = { + serialize, + test +}; +var _default = plugin; +exports.default = _default; diff --git a/node_modules/pretty-format/build/plugins/Immutable.d.ts b/node_modules/pretty-format/build/plugins/Immutable.d.ts new file mode 100644 index 0000000..fd2531b --- /dev/null +++ b/node_modules/pretty-format/build/plugins/Immutable.d.ts @@ -0,0 +1,11 @@ +/** + * 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. + */ +import type { NewPlugin } from '../types'; +export declare const serialize: NewPlugin['serialize']; +export declare const test: NewPlugin['test']; +declare const plugin: NewPlugin; +export default plugin; diff --git a/node_modules/pretty-format/build/plugins/Immutable.js b/node_modules/pretty-format/build/plugins/Immutable.js new file mode 100644 index 0000000..9915966 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/Immutable.js @@ -0,0 +1,247 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.test = exports.serialize = exports.default = void 0; + +var _collections = require('../collections'); + +/** + * 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 +const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; +const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; +const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; +const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; +const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; +const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4 + +const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@'; +const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; +const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; + +const getImmutableName = name => 'Immutable.' + name; + +const printAsLeaf = name => '[' + name + ']'; + +const SPACE = ' '; +const LAZY = '…'; // Seq is lazy if it calls a method like filter + +const printImmutableEntries = ( + val, + config, + indentation, + depth, + refs, + printer, + type +) => + ++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) { + let i = 0; + return { + next() { + if (i < val._keys.length) { + const key = val._keys[i++]; + return { + done: false, + value: [key, val.get(key)] + }; + } + + return { + done: true, + value: undefined + }; + } + }; +} + +const 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 + const name = getImmutableName(val._name || 'Record'); + return ++depth > config.maxDepth + ? printAsLeaf(name) + : name + + SPACE + + '{' + + (0, _collections.printIteratorEntries)( + getRecordEntries(val), + config, + indentation, + depth, + refs, + printer + ) + + '}'; +}; + +const printImmutableSeq = (val, config, indentation, depth, refs, printer) => { + const 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) + + ']' + ); +}; + +const printImmutableValues = ( + val, + config, + indentation, + depth, + refs, + printer, + type +) => + ++depth > config.maxDepth + ? printAsLeaf(getImmutableName(type)) + : getImmutableName(type) + + SPACE + + '[' + + (0, _collections.printIteratorValues)( + val.values(), + config, + indentation, + depth, + refs, + printer + ) + + ']'; + +const 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; + +const test = val => + val && + (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true); + +exports.test = test; +const plugin = { + serialize, + test +}; +var _default = plugin; +exports.default = _default; diff --git a/node_modules/pretty-format/build/plugins/ReactElement.d.ts b/node_modules/pretty-format/build/plugins/ReactElement.d.ts new file mode 100644 index 0000000..fd2531b --- /dev/null +++ b/node_modules/pretty-format/build/plugins/ReactElement.d.ts @@ -0,0 +1,11 @@ +/** + * 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. + */ +import type { NewPlugin } from '../types'; +export declare const serialize: NewPlugin['serialize']; +export declare const test: NewPlugin['test']; +declare const plugin: NewPlugin; +export default plugin; diff --git a/node_modules/pretty-format/build/plugins/ReactElement.js b/node_modules/pretty-format/build/plugins/ReactElement.js new file mode 100644 index 0000000..f45a6e0 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/ReactElement.js @@ -0,0 +1,166 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.test = exports.serialize = exports.default = void 0; + +var ReactIs = _interopRequireWildcard(require('react-is')); + +var _markup = require('./lib/markup'); + +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return {default: obj}; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (key !== 'default' && 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; +} + +/** + * 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. + */ +// Given element.props.children, or subtree during recursive traversal, +// return flattened array of children. +const getChildren = (arg, children = []) => { + if (Array.isArray(arg)) { + arg.forEach(item => { + getChildren(item, children); + }); + } else if (arg != null && arg !== false) { + children.push(arg); + } + + return children; +}; + +const getType = element => { + const 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; + } + + const functionName = type.render.displayName || type.render.name || ''; + return functionName !== '' + ? 'ForwardRef(' + functionName + ')' + : 'ForwardRef'; + } + + if (ReactIs.isMemo(element)) { + const functionName = + type.displayName || type.type.displayName || type.type.name || ''; + return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo'; + } + } + + return 'UNDEFINED'; +}; + +const getPropKeys = element => { + const {props} = element; + return Object.keys(props) + .filter(key => key !== 'children' && props[key] !== undefined) + .sort(); +}; + +const serialize = (element, config, indentation, depth, refs, printer) => + ++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; + +const test = val => val != null && ReactIs.isElement(val); + +exports.test = test; +const plugin = { + serialize, + test +}; +var _default = plugin; +exports.default = _default; diff --git a/node_modules/pretty-format/build/plugins/ReactTestComponent.d.ts b/node_modules/pretty-format/build/plugins/ReactTestComponent.d.ts new file mode 100644 index 0000000..91542d9 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/ReactTestComponent.d.ts @@ -0,0 +1,18 @@ +/** + * 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. + */ +import type { NewPlugin } from '../types'; +export declare type ReactTestObject = { + $$typeof: symbol; + type: string; + props?: Record<string, unknown>; + children?: null | Array<ReactTestChild>; +}; +declare type ReactTestChild = ReactTestObject | string | number; +export declare const serialize: NewPlugin['serialize']; +export declare const test: NewPlugin['test']; +declare const plugin: NewPlugin; +export default plugin; diff --git a/node_modules/pretty-format/build/plugins/ReactTestComponent.js b/node_modules/pretty-format/build/plugins/ReactTestComponent.js new file mode 100644 index 0000000..6e09edc --- /dev/null +++ b/node_modules/pretty-format/build/plugins/ReactTestComponent.js @@ -0,0 +1,79 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.test = exports.serialize = exports.default = void 0; + +var _markup = require('./lib/markup'); + +var global = (function () { + if (typeof globalThis !== 'undefined') { + return globalThis; + } else if (typeof global !== 'undefined') { + return global; + } else if (typeof self !== 'undefined') { + return self; + } else if (typeof window !== 'undefined') { + return window; + } else { + return Function('return this')(); + } +})(); + +var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol; +const testSymbol = + typeof Symbol === 'function' && Symbol.for + ? Symbol.for('react.test.json') + : 0xea71357; + +const getPropKeys = object => { + const {props} = object; + return props + ? Object.keys(props) + .filter(key => props[key] !== undefined) + .sort() + : []; +}; + +const serialize = (object, config, indentation, depth, refs, printer) => + ++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; + +const test = val => val && val.$$typeof === testSymbol; + +exports.test = test; +const plugin = { + serialize, + test +}; +var _default = plugin; +exports.default = _default; diff --git a/node_modules/pretty-format/build/plugins/lib/escapeHTML.d.ts b/node_modules/pretty-format/build/plugins/lib/escapeHTML.d.ts new file mode 100644 index 0000000..aee0d3d --- /dev/null +++ b/node_modules/pretty-format/build/plugins/lib/escapeHTML.d.ts @@ -0,0 +1,7 @@ +/** + * 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. + */ +export default function escapeHTML(str: string): string; diff --git a/node_modules/pretty-format/build/plugins/lib/escapeHTML.js b/node_modules/pretty-format/build/plugins/lib/escapeHTML.js new file mode 100644 index 0000000..50dda25 --- /dev/null +++ b/node_modules/pretty-format/build/plugins/lib/escapeHTML.js @@ -0,0 +1,16 @@ +'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, '>'); +} diff --git a/node_modules/pretty-format/build/plugins/lib/markup.d.ts b/node_modules/pretty-format/build/plugins/lib/markup.d.ts new file mode 100644 index 0000000..60d99ab --- /dev/null +++ b/node_modules/pretty-format/build/plugins/lib/markup.d.ts @@ -0,0 +1,13 @@ +/** + * 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. + */ +import type { Config, Printer, Refs } from '../../types'; +export declare const printProps: (keys: Array<string>, props: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string; +export declare const printChildren: (children: Array<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string; +export declare const printText: (text: string, config: Config) => string; +export declare const printComment: (comment: string, config: Config) => string; +export declare const printElement: (type: string, printedProps: string, printedChildren: string, config: Config, indentation: string) => string; +export declare const printElementAsLeaf: (type: string, config: Config) => string; diff --git a/node_modules/pretty-format/build/plugins/lib/markup.js b/node_modules/pretty-format/build/plugins/lib/markup.js new file mode 100644 index 0000000..4f677ac --- /dev/null +++ b/node_modules/pretty-format/build/plugins/lib/markup.js @@ -0,0 +1,153 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.printText = + exports.printProps = + exports.printElementAsLeaf = + exports.printElement = + exports.printComment = + exports.printChildren = + void 0; + +var _escapeHTML = _interopRequireDefault(require('./escapeHTML')); + +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. +const printProps = (keys, props, config, indentation, depth, refs, printer) => { + const indentationNext = indentation + config.indent; + const colors = config.colors; + return keys + .map(key => { + const value = props[key]; + let 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; + +const printChildren = (children, config, indentation, depth, refs, printer) => + children + .map( + child => + config.spacingOuter + + indentation + + (typeof child === 'string' + ? printText(child, config) + : printer(child, config, indentation, depth, refs)) + ) + .join(''); + +exports.printChildren = printChildren; + +const printText = (text, config) => { + const contentColor = config.colors.content; + return ( + contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close + ); +}; + +exports.printText = printText; + +const printComment = (comment, config) => { + const 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; + +const printElement = ( + type, + printedProps, + printedChildren, + config, + indentation +) => { + const 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; + +const printElementAsLeaf = (type, config) => { + const tagColor = config.colors.tag; + return ( + tagColor.open + + '<' + + type + + tagColor.close + + ' …' + + tagColor.open + + ' />' + + tagColor.close + ); +}; + +exports.printElementAsLeaf = printElementAsLeaf; diff --git a/node_modules/pretty-format/build/types.d.ts b/node_modules/pretty-format/build/types.d.ts new file mode 100644 index 0000000..f070ad8 --- /dev/null +++ b/node_modules/pretty-format/build/types.d.ts @@ -0,0 +1,108 @@ +/** + * 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. + */ +export declare type Colors = { + comment: { + close: string; + open: string; + }; + content: { + close: string; + open: string; + }; + prop: { + close: string; + open: string; + }; + tag: { + close: string; + open: string; + }; + value: { + close: string; + open: string; + }; +}; +declare type Indent = (arg0: string) => string; +export declare type Refs = Array<unknown>; +declare type Print = (arg0: unknown) => string; +export declare type Theme = { + comment: string; + content: string; + prop: string; + tag: string; + value: string; +}; +declare type ThemeReceived = { + comment?: string; + content?: string; + prop?: string; + tag?: string; + value?: string; +}; +export declare type CompareKeys = ((a: string, b: string) => number) | undefined; +export declare type Options = { + callToJSON: boolean; + compareKeys: CompareKeys; + escapeRegex: boolean; + escapeString: boolean; + highlight: boolean; + indent: number; + maxDepth: number; + min: boolean; + plugins: Plugins; + printBasicPrototype: boolean; + printFunctionName: boolean; + theme: Theme; +}; +export interface PrettyFormatOptions { + callToJSON?: boolean; + compareKeys?: CompareKeys; + escapeRegex?: boolean; + escapeString?: boolean; + highlight?: boolean; + indent?: number; + maxDepth?: number; + min?: boolean; + plugins?: Plugins; + printBasicPrototype?: boolean; + printFunctionName?: boolean; + theme?: ThemeReceived; +} +export declare type OptionsReceived = PrettyFormatOptions; +export declare type Config = { + callToJSON: boolean; + compareKeys: CompareKeys; + colors: Colors; + escapeRegex: boolean; + escapeString: boolean; + indent: string; + maxDepth: number; + min: boolean; + plugins: Plugins; + printBasicPrototype: boolean; + printFunctionName: boolean; + spacingInner: string; + spacingOuter: string; +}; +export declare type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string; +declare type Test = (arg0: any) => boolean; +export declare type NewPlugin = { + serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string; + test: Test; +}; +declare type PluginOptions = { + edgeSpacing: string; + min: boolean; + spacing: string; +}; +export declare type OldPlugin = { + print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string; + test: Test; +}; +export declare type Plugin = NewPlugin | OldPlugin; +export declare type Plugins = Array<Plugin>; +export {}; diff --git a/node_modules/pretty-format/build/types.js b/node_modules/pretty-format/build/types.js new file mode 100644 index 0000000..ad9a93a --- /dev/null +++ b/node_modules/pretty-format/build/types.js @@ -0,0 +1 @@ +'use strict'; |