UNPKG

react-inspector

Version:

Power of Browser DevTools inspectors right inside your React app

1,343 lines (1,312 loc) 83.6 kB
import React, { createContext, useMemo, useContext, memo, Children, useCallback, useState, useLayoutEffect } from 'react'; import PropTypes from 'prop-types'; import isDOM from 'is-dom'; function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var _extends_1 = createCommonjsModule(function (module) { function _extends() { module.exports = _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; module.exports["default"] = module.exports, module.exports.__esModule = true; return _extends.apply(this, arguments); } module.exports = _extends; module.exports["default"] = module.exports, module.exports.__esModule = true; }); var _extends = unwrapExports(_extends_1); var objectWithoutPropertiesLoose = createCommonjsModule(function (module) { function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } module.exports = _objectWithoutPropertiesLoose; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(objectWithoutPropertiesLoose); var objectWithoutProperties = createCommonjsModule(function (module) { function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } module.exports = _objectWithoutProperties; module.exports["default"] = module.exports, module.exports.__esModule = true; }); var _objectWithoutProperties = unwrapExports(objectWithoutProperties); var theme$1 = { BASE_FONT_FAMILY: 'Menlo, monospace', BASE_FONT_SIZE: '11px', BASE_LINE_HEIGHT: 1.2, BASE_BACKGROUND_COLOR: 'rgb(36, 36, 36)', BASE_COLOR: 'rgb(213, 213, 213)', OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES: 10, OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES: 5, OBJECT_NAME_COLOR: 'rgb(227, 110, 236)', OBJECT_VALUE_NULL_COLOR: 'rgb(127, 127, 127)', OBJECT_VALUE_UNDEFINED_COLOR: 'rgb(127, 127, 127)', OBJECT_VALUE_REGEXP_COLOR: 'rgb(233, 63, 59)', OBJECT_VALUE_STRING_COLOR: 'rgb(233, 63, 59)', OBJECT_VALUE_SYMBOL_COLOR: 'rgb(233, 63, 59)', OBJECT_VALUE_NUMBER_COLOR: 'hsl(252, 100%, 75%)', OBJECT_VALUE_BOOLEAN_COLOR: 'hsl(252, 100%, 75%)', OBJECT_VALUE_FUNCTION_PREFIX_COLOR: 'rgb(85, 106, 242)', HTML_TAG_COLOR: 'rgb(93, 176, 215)', HTML_TAGNAME_COLOR: 'rgb(93, 176, 215)', HTML_TAGNAME_TEXT_TRANSFORM: 'lowercase', HTML_ATTRIBUTE_NAME_COLOR: 'rgb(155, 187, 220)', HTML_ATTRIBUTE_VALUE_COLOR: 'rgb(242, 151, 102)', HTML_COMMENT_COLOR: 'rgb(137, 137, 137)', HTML_DOCTYPE_COLOR: 'rgb(192, 192, 192)', ARROW_COLOR: 'rgb(145, 145, 145)', ARROW_MARGIN_RIGHT: 3, ARROW_FONT_SIZE: 12, ARROW_ANIMATION_DURATION: '0', TREENODE_FONT_FAMILY: 'Menlo, monospace', TREENODE_FONT_SIZE: '11px', TREENODE_LINE_HEIGHT: 1.2, TREENODE_PADDING_LEFT: 12, TABLE_BORDER_COLOR: 'rgb(85, 85, 85)', TABLE_TH_BACKGROUND_COLOR: 'rgb(44, 44, 44)', TABLE_TH_HOVER_COLOR: 'rgb(48, 48, 48)', TABLE_SORT_ICON_COLOR: 'black', TABLE_DATA_BACKGROUND_IMAGE: 'linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(51, 139, 255, 0.0980392) 50%, rgba(51, 139, 255, 0.0980392))', TABLE_DATA_BACKGROUND_SIZE: '128px 32px' }; var theme = { BASE_FONT_FAMILY: 'Menlo, monospace', BASE_FONT_SIZE: '11px', BASE_LINE_HEIGHT: 1.2, BASE_BACKGROUND_COLOR: 'white', BASE_COLOR: 'black', OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES: 10, OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES: 5, OBJECT_NAME_COLOR: 'rgb(136, 19, 145)', OBJECT_VALUE_NULL_COLOR: 'rgb(128, 128, 128)', OBJECT_VALUE_UNDEFINED_COLOR: 'rgb(128, 128, 128)', OBJECT_VALUE_REGEXP_COLOR: 'rgb(196, 26, 22)', OBJECT_VALUE_STRING_COLOR: 'rgb(196, 26, 22)', OBJECT_VALUE_SYMBOL_COLOR: 'rgb(196, 26, 22)', OBJECT_VALUE_NUMBER_COLOR: 'rgb(28, 0, 207)', OBJECT_VALUE_BOOLEAN_COLOR: 'rgb(28, 0, 207)', OBJECT_VALUE_FUNCTION_PREFIX_COLOR: 'rgb(13, 34, 170)', HTML_TAG_COLOR: 'rgb(168, 148, 166)', HTML_TAGNAME_COLOR: 'rgb(136, 18, 128)', HTML_TAGNAME_TEXT_TRANSFORM: 'lowercase', HTML_ATTRIBUTE_NAME_COLOR: 'rgb(153, 69, 0)', HTML_ATTRIBUTE_VALUE_COLOR: 'rgb(26, 26, 166)', HTML_COMMENT_COLOR: 'rgb(35, 110, 37)', HTML_DOCTYPE_COLOR: 'rgb(192, 192, 192)', ARROW_COLOR: '#6e6e6e', ARROW_MARGIN_RIGHT: 3, ARROW_FONT_SIZE: 12, ARROW_ANIMATION_DURATION: '0', TREENODE_FONT_FAMILY: 'Menlo, monospace', TREENODE_FONT_SIZE: '11px', TREENODE_LINE_HEIGHT: 1.2, TREENODE_PADDING_LEFT: 12, TABLE_BORDER_COLOR: '#aaa', TABLE_TH_BACKGROUND_COLOR: '#eee', TABLE_TH_HOVER_COLOR: 'hsla(0, 0%, 90%, 1)', TABLE_SORT_ICON_COLOR: '#6e6e6e', TABLE_DATA_BACKGROUND_IMAGE: 'linear-gradient(to bottom, white, white 50%, rgb(234, 243, 255) 50%, rgb(234, 243, 255))', TABLE_DATA_BACKGROUND_SIZE: '128px 32px' }; var themes = /*#__PURE__*/Object.freeze({ __proto__: null, chromeDark: theme$1, chromeLight: theme }); var arrayWithHoles = createCommonjsModule(function (module) { function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } module.exports = _arrayWithHoles; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(arrayWithHoles); var iterableToArrayLimit = createCommonjsModule(function (module) { 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; } module.exports = _iterableToArrayLimit; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(iterableToArrayLimit); var arrayLikeToArray = createCommonjsModule(function (module) { 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; } module.exports = _arrayLikeToArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(arrayLikeToArray); var unsupportedIterableToArray = createCommonjsModule(function (module) { 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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); } module.exports = _unsupportedIterableToArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(unsupportedIterableToArray); var nonIterableRest = createCommonjsModule(function (module) { 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."); } module.exports = _nonIterableRest; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(nonIterableRest); var slicedToArray = createCommonjsModule(function (module) { function _slicedToArray(arr, i) { return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest(); } module.exports = _slicedToArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); var _slicedToArray = unwrapExports(slicedToArray); var _typeof_1 = createCommonjsModule(function (module) { function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { module.exports = _typeof = function _typeof(obj) { return typeof obj; }; module.exports["default"] = module.exports, module.exports.__esModule = true; } else { module.exports = _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; module.exports["default"] = module.exports, module.exports.__esModule = true; } return _typeof(obj); } module.exports = _typeof; module.exports["default"] = module.exports, module.exports.__esModule = true; }); var _typeof = unwrapExports(_typeof_1); var runtime_1 = createCommonjsModule(function (module) { var runtime = function (exports) { var Op = Object.prototype; var hasOwn = Op.hasOwnProperty; var undefined$1; var $Symbol = typeof Symbol === "function" ? Symbol : {}; var iteratorSymbol = $Symbol.iterator || "@@iterator"; var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); return obj[key]; } try { define({}, ""); } catch (err) { define = function (obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; var generator = Object.create(protoGenerator.prototype); var context = new Context(tryLocsList || []); generator._invoke = makeInvokeMethod(innerFn, self, context); return generator; } exports.wrap = wrap; function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } var GenStateSuspendedStart = "suspendedStart"; var GenStateSuspendedYield = "suspendedYield"; var GenStateExecuting = "executing"; var GenStateCompleted = "completed"; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; IteratorPrototype[iteratorSymbol] = function () { return this; }; var getProto = Object.getPrototypeOf; var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { IteratorPrototype = NativeIteratorPrototype; } var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; GeneratorFunctionPrototype.constructor = GeneratorFunction; GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } exports.isGeneratorFunction = function (genFun) { var ctor = typeof genFun === "function" && genFun.constructor; return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false; }; exports.mark = function (genFun) { if (Object.setPrototypeOf) { Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); } else { genFun.__proto__ = GeneratorFunctionPrototype; define(genFun, toStringTagSymbol, "GeneratorFunction"); } genFun.prototype = Object.create(Gp); return genFun; }; exports.awrap = function (arg) { return { __await: arg }; }; function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (record.type === "throw") { reject(record.arg); } else { var result = record.arg; var value = result.value; if (value && typeof value === "object" && hasOwn.call(value, "__await")) { return PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }); } return PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped; resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } } var previousPromise; function enqueue(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } this._invoke = enqueue; } defineIteratorMethods(AsyncIterator.prototype); AsyncIterator.prototype[asyncIteratorSymbol] = function () { return this; }; exports.AsyncIterator = AsyncIterator; exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { if (PromiseImpl === void 0) PromiseImpl = Promise; var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }; function makeInvokeMethod(innerFn, self, context) { var state = GenStateSuspendedStart; return function invoke(method, arg) { if (state === GenStateExecuting) { throw new Error("Generator is already running"); } if (state === GenStateCompleted) { if (method === "throw") { throw arg; } return doneResult(); } context.method = method; context.arg = arg; while (true) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (context.method === "next") { context.sent = context._sent = context.arg; } else if (context.method === "throw") { if (state === GenStateSuspendedStart) { state = GenStateCompleted; throw context.arg; } context.dispatchException(context.arg); } else if (context.method === "return") { context.abrupt("return", context.arg); } state = GenStateExecuting; var record = tryCatch(innerFn, self, context); if (record.type === "normal") { state = context.done ? GenStateCompleted : GenStateSuspendedYield; if (record.arg === ContinueSentinel) { continue; } return { value: record.arg, done: context.done }; } else if (record.type === "throw") { state = GenStateCompleted; context.method = "throw"; context.arg = record.arg; } } }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (method === undefined$1) { context.delegate = null; if (context.method === "throw") { if (delegate.iterator["return"]) { context.method = "return"; context.arg = undefined$1; maybeInvokeDelegate(delegate, context); if (context.method === "throw") { return ContinueSentinel; } } context.method = "throw"; context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if (record.type === "throw") { context.method = "throw"; context.arg = record.arg; context.delegate = null; return ContinueSentinel; } var info = record.arg; if (!info) { context.method = "throw"; context.arg = new TypeError("iterator result is not an object"); context.delegate = null; return ContinueSentinel; } if (info.done) { context[delegate.resultName] = info.value; context.next = delegate.nextLoc; if (context.method !== "return") { context.method = "next"; context.arg = undefined$1; } } else { return info; } context.delegate = null; return ContinueSentinel; } defineIteratorMethods(Gp); define(Gp, toStringTagSymbol, "Generator"); Gp[iteratorSymbol] = function () { return this; }; Gp.toString = function () { return "[object Generator]"; }; function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; if (1 in locs) { entry.catchLoc = locs[1]; } if (2 in locs) { entry.finallyLoc = locs[2]; entry.afterLoc = locs[3]; } this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal"; delete record.arg; entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }]; tryLocsList.forEach(pushTryEntry, this); this.reset(true); } exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } keys.reverse(); return function next() { while (keys.length) { var key = keys.pop(); if (key in object) { next.value = key; next.done = false; return next; } } next.done = true; return next; }; }; function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) { return iteratorMethod.call(iterable); } if (typeof iterable.next === "function") { return iterable; } if (!isNaN(iterable.length)) { var i = -1, next = function next() { while (++i < iterable.length) { if (hasOwn.call(iterable, i)) { next.value = iterable[i]; next.done = false; return next; } } next.value = undefined$1; next.done = true; return next; }; return next.next = next; } } return { next: doneResult }; } exports.values = values; function doneResult() { return { value: undefined$1, done: true }; } Context.prototype = { constructor: Context, reset: function (skipTempReset) { this.prev = 0; this.next = 0; this.sent = this._sent = undefined$1; this.done = false; this.delegate = null; this.method = "next"; this.arg = undefined$1; this.tryEntries.forEach(resetTryEntry); if (!skipTempReset) { for (var name in this) { if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { this[name] = undefined$1; } } } }, stop: function () { this.done = true; var rootEntry = this.tryEntries[0]; var rootRecord = rootEntry.completion; if (rootRecord.type === "throw") { throw rootRecord.arg; } return this.rval; }, dispatchException: function (exception) { if (this.done) { throw exception; } var context = this; function handle(loc, caught) { record.type = "throw"; record.arg = exception; context.next = loc; if (caught) { context.method = "next"; context.arg = undefined$1; } return !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; var record = entry.completion; if (entry.tryLoc === "root") { return handle("end"); } if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"); var hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) { return handle(entry.catchLoc, true); } else if (this.prev < entry.finallyLoc) { return handle(entry.finallyLoc); } } else if (hasCatch) { if (this.prev < entry.catchLoc) { return handle(entry.catchLoc, true); } } else if (hasFinally) { if (this.prev < entry.finallyLoc) { return handle(entry.finallyLoc); } } else { throw new Error("try statement without catch or finally"); } } } }, abrupt: function (type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { finallyEntry = null; } var record = finallyEntry ? finallyEntry.completion : {}; record.type = type; record.arg = arg; if (finallyEntry) { this.method = "next"; this.next = finallyEntry.finallyLoc; return ContinueSentinel; } return this.complete(record); }, complete: function (record, afterLoc) { if (record.type === "throw") { throw record.arg; } if (record.type === "break" || record.type === "continue") { this.next = record.arg; } else if (record.type === "return") { this.rval = this.arg = record.arg; this.method = "return"; this.next = "end"; } else if (record.type === "normal" && afterLoc) { this.next = afterLoc; } return ContinueSentinel; }, finish: function (finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) { this.complete(entry.completion, entry.afterLoc); resetTryEntry(entry); return ContinueSentinel; } } }, "catch": function (tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (record.type === "throw") { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function (iterable, resultName, nextLoc) { this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }; if (this.method === "next") { this.arg = undefined$1; } return ContinueSentinel; } }; return exports; }( module.exports ); try { regeneratorRuntime = runtime; } catch (accidentalStrictMode) { Function("r", "regeneratorRuntime = r")(runtime); } }); var regenerator = runtime_1; var arrayWithoutHoles = createCommonjsModule(function (module) { function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return arrayLikeToArray(arr); } module.exports = _arrayWithoutHoles; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(arrayWithoutHoles); var iterableToArray = createCommonjsModule(function (module) { function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } module.exports = _iterableToArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(iterableToArray); var nonIterableSpread = createCommonjsModule(function (module) { function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } module.exports = _nonIterableSpread; module.exports["default"] = module.exports, module.exports.__esModule = true; }); unwrapExports(nonIterableSpread); var toConsumableArray = createCommonjsModule(function (module) { function _toConsumableArray(arr) { return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread(); } module.exports = _toConsumableArray; module.exports["default"] = module.exports, module.exports.__esModule = true; }); var _toConsumableArray = unwrapExports(toConsumableArray); var defineProperty = createCommonjsModule(function (module) { 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; } module.exports = _defineProperty; module.exports["default"] = module.exports, module.exports.__esModule = true; }); var _defineProperty = unwrapExports(defineProperty); var ExpandedPathsContext = createContext([{}, function () {}]); var unselectable = { WebkitTouchCallout: 'none', WebkitUserSelect: 'none', KhtmlUserSelect: 'none', MozUserSelect: 'none', msUserSelect: 'none', OUserSelect: 'none', userSelect: 'none' }; function ownKeys$7(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$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } var base = (function (theme) { return { DOMNodePreview: { htmlOpenTag: { base: { color: theme.HTML_TAG_COLOR }, tagName: { color: theme.HTML_TAGNAME_COLOR, textTransform: theme.HTML_TAGNAME_TEXT_TRANSFORM }, htmlAttributeName: { color: theme.HTML_ATTRIBUTE_NAME_COLOR }, htmlAttributeValue: { color: theme.HTML_ATTRIBUTE_VALUE_COLOR } }, htmlCloseTag: { base: { color: theme.HTML_TAG_COLOR }, offsetLeft: { marginLeft: -theme.TREENODE_PADDING_LEFT }, tagName: { color: theme.HTML_TAGNAME_COLOR, textTransform: theme.HTML_TAGNAME_TEXT_TRANSFORM } }, htmlComment: { color: theme.HTML_COMMENT_COLOR }, htmlDoctype: { color: theme.HTML_DOCTYPE_COLOR } }, ObjectPreview: { objectDescription: { fontStyle: 'italic' }, preview: { fontStyle: 'italic' }, arrayMaxProperties: theme.OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES, objectMaxProperties: theme.OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES }, ObjectName: { base: { color: theme.OBJECT_NAME_COLOR }, dimmed: { opacity: 0.6 } }, ObjectValue: { objectValueNull: { color: theme.OBJECT_VALUE_NULL_COLOR }, objectValueUndefined: { color: theme.OBJECT_VALUE_UNDEFINED_COLOR }, objectValueRegExp: { color: theme.OBJECT_VALUE_REGEXP_COLOR }, objectValueString: { color: theme.OBJECT_VALUE_STRING_COLOR }, objectValueSymbol: { color: theme.OBJECT_VALUE_SYMBOL_COLOR }, objectValueNumber: { color: theme.OBJECT_VALUE_NUMBER_COLOR }, objectValueBoolean: { color: theme.OBJECT_VALUE_BOOLEAN_COLOR }, objectValueFunctionPrefix: { color: theme.OBJECT_VALUE_FUNCTION_PREFIX_COLOR, fontStyle: 'italic' }, objectValueFunctionName: { fontStyle: 'italic' } }, TreeView: { treeViewOutline: { padding: 0, margin: 0, listStyleType: 'none' } }, TreeNode: { treeNodeBase: { color: theme.BASE_COLOR, backgroundColor: theme.BASE_BACKGROUND_COLOR, lineHeight: theme.TREENODE_LINE_HEIGHT, cursor: 'default', boxSizing: 'border-box', listStyle: 'none', fontFamily: theme.TREENODE_FONT_FAMILY, fontSize: theme.TREENODE_FONT_SIZE }, treeNodePreviewContainer: {}, treeNodePlaceholder: _objectSpread$7({ whiteSpace: 'pre', fontSize: theme.ARROW_FONT_SIZE, marginRight: theme.ARROW_MARGIN_RIGHT }, unselectable), treeNodeArrow: { base: _objectSpread$7(_objectSpread$7({ color: theme.ARROW_COLOR, display: 'inline-block', fontSize: theme.ARROW_FONT_SIZE, marginRight: theme.ARROW_MARGIN_RIGHT }, parseFloat(theme.ARROW_ANIMATION_DURATION) > 0 ? { transition: "transform ".concat(theme.ARROW_ANIMATION_DURATION, " ease 0s") } : {}), unselectable), expanded: { WebkitTransform: 'rotateZ(90deg)', MozTransform: 'rotateZ(90deg)', transform: 'rotateZ(90deg)' }, collapsed: { WebkitTransform: 'rotateZ(0deg)', MozTransform: 'rotateZ(0deg)', transform: 'rotateZ(0deg)' } }, treeNodeChildNodesContainer: { margin: 0, paddingLeft: theme.TREENODE_PADDING_LEFT } }, TableInspector: { base: { color: theme.BASE_COLOR, position: 'relative', border: "1px solid ".concat(theme.TABLE_BORDER_COLOR), fontFamily: theme.BASE_FONT_FAMILY, fontSize: theme.BASE_FONT_SIZE, lineHeight: '120%', boxSizing: 'border-box', cursor: 'default' } }, TableInspectorHeaderContainer: { base: { top: 0, height: '17px', left: 0, right: 0, overflowX: 'hidden' }, table: { tableLayout: 'fixed', borderSpacing: 0, borderCollapse: 'separate', height: '100%', width: '100%', margin: 0 } }, TableInspectorDataContainer: { tr: { display: 'table-row' }, td: { boxSizing: 'border-box', border: 'none', height: '16px', verticalAlign: 'top', padding: '1px 4px', WebkitUserSelect: 'text', whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden', lineHeight: '14px' }, div: { position: 'static', top: '17px', bottom: 0, overflowY: 'overlay', transform: 'translateZ(0)', left: 0, right: 0, overflowX: 'hidden' }, table: { positon: 'static', left: 0, top: 0, right: 0, bottom: 0, borderTop: '0 none transparent', margin: 0, backgroundImage: theme.TABLE_DATA_BACKGROUND_IMAGE, backgroundSize: theme.TABLE_DATA_BACKGROUND_SIZE, tableLayout: 'fixed', borderSpacing: 0, borderCollapse: 'separate', width: '100%', fontSize: theme.BASE_FONT_SIZE, lineHeight: '120%' } }, TableInspectorTH: { base: { position: 'relative', height: 'auto', textAlign: 'left', backgroundColor: theme.TABLE_TH_BACKGROUND_COLOR, borderBottom: "1px solid ".concat(theme.TABLE_BORDER_COLOR), fontWeight: 'normal', verticalAlign: 'middle', padding: '0 4px', whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden', lineHeight: '14px', ':hover': { backgroundColor: theme.TABLE_TH_HOVER_COLOR } }, div: { whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden', fontSize: theme.BASE_FONT_SIZE, lineHeight: '120%' } }, TableInspectorLeftBorder: { none: { borderLeft: 'none' }, solid: { borderLeft: "1px solid ".concat(theme.TABLE_BORDER_COLOR) } }, TableInspectorSortIcon: _objectSpread$7({ display: 'block', marginRight: 3, width: 8, height: 7, marginTop: -7, color: theme.TABLE_SORT_ICON_COLOR, fontSize: 12 }, unselectable) }; }); var DEFAULT_THEME_NAME = 'chromeLight'; var ThemeContext = createContext(base(themes[DEFAULT_THEME_NAME])); var useStyles = function useStyles(baseStylesKey) { var themeStyles = useContext(ThemeContext); return themeStyles[baseStylesKey]; }; var themeAcceptor = function themeAcceptor(WrappedComponent) { var ThemeAcceptor = function ThemeAcceptor(_ref) { var _ref$theme = _ref.theme, theme = _ref$theme === void 0 ? DEFAULT_THEME_NAME : _ref$theme, restProps = _objectWithoutProperties(_ref, ["theme"]); var themeStyles = useMemo(function () { switch (Object.prototype.toString.call(theme)) { case '[object String]': return base(themes[theme]); case '[object Object]': return base(theme); default: return base(themes[DEFAULT_THEME_NAME]); } }, [theme]); return React.createElement(ThemeContext.Provider, { value: themeStyles }, React.createElement(WrappedComponent, restProps)); }; ThemeAcceptor.propTypes = { theme: PropTypes.oneOfType([PropTypes.string, PropTypes.object]) }; return ThemeAcceptor; }; function ownKeys$6(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$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } var Arrow = function Arrow(_ref) { var expanded = _ref.expanded, styles = _ref.styles; return React.createElement("span", { style: _objectSpread$6(_objectSpread$6({}, styles.base), expanded ? styles.expanded : styles.collapsed) }, "\u25B6"); }; var TreeNode = memo(function (props) { props = _objectSpread$6({ expanded: true, nodeRenderer: function nodeRenderer(_ref2) { var name = _ref2.name; return React.createElement("span", null, name); }, onClick: function onClick() {}, shouldShowArrow: false, shouldShowPlaceholder: true }, props); var _props = props, expanded = _props.expanded, onClick = _props.onClick, children = _props.children, nodeRenderer = _props.nodeRenderer, title = _props.title, shouldShowArrow = _props.shouldShowArrow, shouldShowPlaceholder = _props.shouldShowPlaceholder; var styles = useStyles('TreeNode'); var NodeRenderer = nodeRenderer; return React.createElement("li", { "aria-expanded": expanded, role: "treeitem", style: styles.treeNodeBase, title: title }, React.createElement("div", { style: styles.treeNodePreviewContainer, onClick: onClick }, shouldShowArrow || Children.count(children) > 0 ? React.createElement(Arrow, { expanded: expanded, styles: styles.treeNodeArrow }) : shouldShowPlaceholder && React.createElement("span", { style: styles.treeNodePlaceholder }, "\xA0"), React.createElement(NodeRenderer, props)), React.createElement("ol", { role: "group", style: styles.treeNodeChildNodesContainer }, expanded ? children : undefined)); }); TreeNode.propTypes = { name: PropTypes.string, data: PropTypes.any, expanded: PropTypes.bool, shouldShowArrow: PropTypes.bool, shouldShowPlaceholder: PropTypes.bool, nodeRenderer: PropTypes.func, onClick: PropTypes.func }; function ownKeys$5(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$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _createForOfIteratorHelper$1(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(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(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); } function _arrayLikeToArray$1(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; } var DEFAULT_ROOT_PATH = '$'; var WILDCARD = '*'; function hasChildNodes(data, dataIterator) { return !dataIterator(data).next().done; } var wildcardPathsFromLevel = function wildcardPathsFromLevel(level) { return Array.from({ length: level }, function (_, i) { return [DEFAULT_ROOT_PATH].concat(Array.from({ length: i }, function () { return '*'; })).join('.'); }); }; var getExpandedPaths = function getExpandedPaths(data, dataIterator, expandPaths, expandLevel, prevExpandedPaths) { var wildcardPaths = [].concat(wildcardPathsFromLevel(expandLevel)).concat(expandPaths).filter(function (path) { return typeof path === 'string'; }); var expandedPaths = []; wildcardPaths.forEach(function (wildcardPath) { var keyPaths = wildcardPath.split('.'); var populatePaths = function populatePaths(curData, curPath, depth) { if (depth === keyPaths.length) { expandedPaths.push(curPath); return; } var key = keyPaths[depth]; if (depth === 0) { if (hasChildNodes(curData, dataIterator) && (key === DEFAULT_ROOT_PATH || key === WILDCARD)) { populatePaths(curData, DEFAULT_ROOT_PATH, depth + 1); } } else { if (key === WILDCARD) { var _iterator = _createForOfIteratorHelper$1(dataIterator(curData)), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var _step$value = _step.value, name = _step$value.name, _data = _step$value.data; if (hasChildNodes(_data, dataIterator)) { populatePaths(_data, "".concat(curPath, ".").concat(name), depth + 1); } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } else { var value = curData[key]; if (hasChildNodes(value, dataIterator)) { populatePaths(value, "".concat(curPath, ".").concat(key), depth + 1); } } } }; populatePaths(data, '', 0); }); return expandedPaths.reduce(function (obj, path) { obj[path] = true; return obj; }, _objectSpread$5({}, prevExpandedPaths)); }; function ownKeys$4(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$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } var ConnectedTreeNode = memo(function (props) { var data = props.data, dataIterator = props.dataIterator, path = props.path, depth = props.depth, nodeRenderer = props.nodeRenderer; var _useContext = useContext(ExpandedPathsContext), _useContext2 = _slicedToArray(_useContext, 2), expandedPaths = _useContext2[0], setExpandedPaths = _useContext2[1]; var nodeHasChildNodes = hasChildNodes(data, dataIterator); var expanded = !!expandedPaths[path]; var handleClick = useCallback(function () { return nodeHasChildNodes && setExpandedPaths(function (prevExpandedPaths) { return _objectSpread$4(_objectSpread$4({}, prevExpandedPaths), {}, _defineProperty({}, path, !expanded)); }); }, [nodeHasChildNodes, setExpandedPaths, path, expanded]); return React.createElement(TreeNode, _extends({ expanded: expanded, onClick: handleClick , shouldShowArrow: nodeHasChildNodes , shouldShowPlaceholder: depth > 0 , nodeRenderer: nodeRenderer }, props), expanded ? _toConsumableArray(dataIterator(data)).map(function (_ref) { var name = _ref.name, data = _ref.data, renderNodeProps = _objectWithoutProperties(_ref, ["name", "data"]); return React.createElement(ConnectedTreeNode, _extends({ name: name, data: data, depth: depth + 1, path: "".concat(path, ".").concat(name), key: name, dataIterator: dataIterator, nodeRenderer: nodeRenderer }, renderNodeProps)); }) : null); }); ConnectedTreeNode.propTypes = { name: PropTypes.string, data: PropTypes.any, dataIterator: PropTypes.func, depth: PropTypes.number, expanded: PropTypes.bool, nodeRenderer: PropTypes.func }; var TreeView = memo(function (_ref2) { var name = _ref2.name, data = _ref2.data, dataIterator = _ref2.dataIterator, nodeRenderer = _ref2.nodeRenderer, expandPaths = _ref2.expandPaths, expandLevel = _ref2.expandLevel; var styles = useStyles('TreeView'); var stateAndSetter = useState({}); var _stateAndSetter = _slicedToArray(stateAndSetter, 2), setExpandedPaths = _stateAndSetter[1]; useLayoutEffect(function () { return setExpandedPaths(function (prevExpandedPaths) { return getExpandedPaths(data, dataIterator, expandPaths, expandLevel, prevExpandedPaths); }); }, [data, dataIterator, expandPaths, expandLevel]); return React.createElement(ExpandedPathsContext.Provider, { value: stateAndSetter }, React.createElement("ol", { role: "tree", style: styles.treeViewOutline }, React.createElement(ConnectedTreeNode, { name: name, data: data, dataIterator: dataIterator, depth: 0, path: DEFAULT_ROOT_PATH, nodeRenderer: nodeRenderer }))); }); TreeView.propTypes = { name: PropTypes.string, data: PropTypes.any, dataIterator: PropTypes.func, nodeRenderer: PropTypes.func, expandPaths: PropTypes.oneOfType([PropTypes.string, PropTypes.array]), expandLevel: PropTypes.number }; function ownKeys$3(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$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } var ObjectName = function ObjectName(_ref) { var name = _ref.name, _ref$dimmed = _ref.dimmed, dimmed = _ref$dimmed === void 0 ? false : _ref$dimmed, _ref$styles = _ref.styles, styles = _ref$styles === void 0 ? {} : _ref$styles; var themeStyles = useStyles('ObjectName'); var appliedStyles = _objectSpread$3(_objectSpread$3(_objectSpread$3({}, themeStyles.base), dimmed ? themeStyles['dimmed'] : {}), styles); return React.createElement("span", { style: appliedStyles }, name); }; ObjectName.propTypes = { name: PropTypes.string, dimmed: PropTypes.bool }; function ownKeys$2(object,