You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
898 B
JavaScript
21 lines
898 B
JavaScript
"use strict";
|
|
|
|
const React = require("react");
|
|
const util = require("util");
|
|
const ansiHTML = require("ansi-html-community");
|
|
// const entities = require("entities");
|
|
|
|
function escape(input) {
|
|
// NOTE: This is not necessarily secure! This is just a stopgap solution (used in development-mode code only) to not break display of < and > characters until we can figure out why `entities` doesn't combine with `ansi-html-community`.
|
|
return input.replace(/</g, "<").replace(/>/g, ">");
|
|
}
|
|
|
|
module.exports = function DebugView({ value }) {
|
|
if (process.env.NODE_ENV !== "development") {
|
|
return "[Debug view is disabled outside of development mode. If you see this, please contact the administrator.]";
|
|
} else {
|
|
let inspected = util.inspect(value, { colors: true, depth: null });
|
|
return <pre className="debugPrint" dangerouslySetInnerHTML={{ __html: ansiHTML(escape(inspected)) }} />;
|
|
}
|
|
};
|