aboutsummaryrefslogtreecommitdiff
path: root/node_modules/pretty-format/build/plugins/lib
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
committerJoel Kronqvist <work.joelkronqvist@pm.me>2022-03-11 20:46:06 +0200
commit080c5819d87b933816d724a83f3bf4f1686770a7 (patch)
tree4a2ccc68b27edf7d4cbc586c932cc7542b655e19 /node_modules/pretty-format/build/plugins/lib
parent5ac7049a9d30733165cc212dee308163c2a14644 (diff)
parentd003b82235a9329f912522a2f70aa950dfce4998 (diff)
downloadLYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.tar.gz
LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.zip
Merge branch 'master' of https://github.com/JoelHMikael/FoodJS
Updating remote changes
Diffstat (limited to 'node_modules/pretty-format/build/plugins/lib')
-rw-r--r--node_modules/pretty-format/build/plugins/lib/escapeHTML.d.ts7
-rw-r--r--node_modules/pretty-format/build/plugins/lib/escapeHTML.js16
-rw-r--r--node_modules/pretty-format/build/plugins/lib/markup.d.ts13
-rw-r--r--node_modules/pretty-format/build/plugins/lib/markup.js153
4 files changed, 189 insertions, 0 deletions
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, '&lt;').replace(/>/g, '&gt;');
+}
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;