react-test-renderer
Version:
React package for snapshot testing.
1,470 lines (1,469 loc) • 661 kB
JavaScript
/**
* @license React
* react-test-renderer.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
"use strict";
"production" !== process.env.NODE_ENV &&
(function () {
function JSCompiler_object_inline_createNodeMock_1380() {
return null;
}
function findHook(fiber, id) {
for (fiber = fiber.memoizedState; null !== fiber && 0 < id; )
(fiber = fiber.next), id--;
return fiber;
}
function copyWithSetImpl(obj, path, index, value) {
if (index >= path.length) return value;
var key = path[index],
updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
return updated;
}
function copyWithRename(obj, oldPath, newPath) {
if (oldPath.length !== newPath.length)
console.warn("copyWithRename() expects paths of the same length");
else {
for (var i = 0; i < newPath.length - 1; i++)
if (oldPath[i] !== newPath[i]) {
console.warn(
"copyWithRename() expects paths to be the same except for the deepest key"
);
return;
}
return copyWithRenameImpl(obj, oldPath, newPath, 0);
}
}
function copyWithRenameImpl(obj, oldPath, newPath, index) {
var oldKey = oldPath[index],
updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
index + 1 === oldPath.length
? ((updated[newPath[index]] = updated[oldKey]),
isArrayImpl(updated)
? updated.splice(oldKey, 1)
: delete updated[oldKey])
: (updated[oldKey] = copyWithRenameImpl(
obj[oldKey],
oldPath,
newPath,
index + 1
));
return updated;
}
function copyWithDeleteImpl(obj, path, index) {
var key = path[index],
updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
if (index + 1 === path.length)
return (
isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key],
updated
);
updated[key] = copyWithDeleteImpl(obj[key], path, index + 1);
return updated;
}
function shouldSuspendImpl() {
return !1;
}
function shouldErrorImpl() {
return null;
}
function createFiber(tag, pendingProps, key, mode) {
return new FiberNode(tag, pendingProps, key, mode);
}
function scheduleRoot(root, element) {
root.context === emptyContextObject &&
(updateContainerImpl(root.current, 2, element, root, null, null),
flushSyncWork());
}
function scheduleRefresh(root, update) {
if (null !== resolveFamily) {
var staleFamilies = update.staleFamilies;
update = update.updatedFamilies;
flushPendingEffects();
scheduleFibersWithFamiliesRecursively(
root.current,
update,
staleFamilies
);
flushSyncWork();
}
}
function setRefreshHandler(handler) {
resolveFamily = handler;
}
function warnInvalidHookAccess() {
console.error(
"Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks"
);
}
function warnInvalidContextAccess() {
console.error(
"Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
);
}
function warnForMissingKey() {}
function setToSortedString(set) {
var array = [];
set.forEach(function (value) {
array.push(value);
});
return array.sort().join(", ");
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || !1;
descriptor.configurable = !0;
"value" in descriptor && (descriptor.writable = !0);
var JSCompiler_temp_const = Object,
JSCompiler_temp_const$jscomp$0 = JSCompiler_temp_const.defineProperty;
a: {
var i$jscomp$0 = descriptor.key;
if ("object" == typeof i$jscomp$0 && i$jscomp$0) {
var e = i$jscomp$0[Symbol.toPrimitive];
if (void 0 !== e) {
i$jscomp$0 = e.call(i$jscomp$0, "string");
if ("object" != typeof i$jscomp$0) break a;
throw new TypeError(
"@@toPrimitive must return a primitive value."
);
}
i$jscomp$0 = String(i$jscomp$0);
}
}
JSCompiler_temp_const$jscomp$0.call(
JSCompiler_temp_const,
target,
"symbol" == typeof i$jscomp$0 ? i$jscomp$0 : i$jscomp$0 + "",
descriptor
);
}
}
function _createClass(Constructor, protoProps, staticProps) {
protoProps && _defineProperties(Constructor.prototype, protoProps);
staticProps && _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", { writable: !1 });
return Constructor;
}
function getNearestMountedFiber(fiber) {
var node = fiber,
nearestMounted = fiber;
if (fiber.alternate) for (; node.return; ) node = node.return;
else {
fiber = node;
do
(node = fiber),
0 !== (node.flags & 4098) && (nearestMounted = node.return),
(fiber = node.return);
while (fiber);
}
return 3 === node.tag ? nearestMounted : null;
}
function assertIsMounted(fiber) {
if (getNearestMountedFiber(fiber) !== fiber)
throw Error("Unable to find node on an unmounted component.");
}
function findCurrentFiberUsingSlowPath(fiber) {
var alternate = fiber.alternate;
if (!alternate) {
alternate = getNearestMountedFiber(fiber);
if (null === alternate)
throw Error("Unable to find node on an unmounted component.");
return alternate !== fiber ? null : fiber;
}
for (var a = fiber, b = alternate; ; ) {
var parentA = a.return;
if (null === parentA) break;
var parentB = parentA.alternate;
if (null === parentB) {
b = parentA.return;
if (null !== b) {
a = b;
continue;
}
break;
}
if (parentA.child === parentB.child) {
for (parentB = parentA.child; parentB; ) {
if (parentB === a) return assertIsMounted(parentA), fiber;
if (parentB === b) return assertIsMounted(parentA), alternate;
parentB = parentB.sibling;
}
throw Error("Unable to find node on an unmounted component.");
}
if (a.return !== b.return) (a = parentA), (b = parentB);
else {
for (var didFindChild = !1, _child = parentA.child; _child; ) {
if (_child === a) {
didFindChild = !0;
a = parentA;
b = parentB;
break;
}
if (_child === b) {
didFindChild = !0;
b = parentA;
a = parentB;
break;
}
_child = _child.sibling;
}
if (!didFindChild) {
for (_child = parentB.child; _child; ) {
if (_child === a) {
didFindChild = !0;
a = parentB;
b = parentA;
break;
}
if (_child === b) {
didFindChild = !0;
b = parentB;
a = parentA;
break;
}
_child = _child.sibling;
}
if (!didFindChild)
throw Error(
"Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue."
);
}
}
if (a.alternate !== b)
throw Error(
"Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."
);
}
if (3 !== a.tag)
throw Error("Unable to find node on an unmounted component.");
return a.stateNode.current === a ? fiber : alternate;
}
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "object" !== typeof maybeIterable)
return null;
maybeIterable =
(MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
maybeIterable["@@iterator"];
return "function" === typeof maybeIterable ? maybeIterable : null;
}
function getComponentNameFromType(type) {
if (null == type) return null;
if ("function" === typeof type)
return type.$$typeof === REACT_CLIENT_REFERENCE
? null
: type.displayName || type.name || null;
if ("string" === typeof type) return type;
switch (type) {
case REACT_FRAGMENT_TYPE:
return "Fragment";
case REACT_PROFILER_TYPE:
return "Profiler";
case REACT_STRICT_MODE_TYPE:
return "StrictMode";
case REACT_SUSPENSE_TYPE:
return "Suspense";
case REACT_SUSPENSE_LIST_TYPE:
return "SuspenseList";
case REACT_ACTIVITY_TYPE:
return "Activity";
}
if ("object" === typeof type)
switch (
("number" === typeof type.tag &&
console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
),
type.$$typeof)
) {
case REACT_PORTAL_TYPE:
return "Portal";
case REACT_CONTEXT_TYPE:
return type.displayName || "Context";
case REACT_CONSUMER_TYPE:
return (type._context.displayName || "Context") + ".Consumer";
case REACT_FORWARD_REF_TYPE:
var innerType = type.render;
type = type.displayName;
type ||
((type = innerType.displayName || innerType.name || ""),
(type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
return type;
case REACT_MEMO_TYPE:
return (
(innerType = type.displayName || null),
null !== innerType
? innerType
: getComponentNameFromType(type.type) || "Memo"
);
case REACT_LAZY_TYPE:
innerType = type._payload;
type = type._init;
try {
return getComponentNameFromType(type(innerType));
} catch (x) {}
}
return null;
}
function getComponentNameFromFiber(fiber) {
var type = fiber.type;
switch (fiber.tag) {
case 31:
return "Activity";
case 24:
return "Cache";
case 9:
return (type._context.displayName || "Context") + ".Consumer";
case 10:
return type.displayName || "Context";
case 18:
return "DehydratedFragment";
case 11:
return (
(fiber = type.render),
(fiber = fiber.displayName || fiber.name || ""),
type.displayName ||
("" !== fiber ? "ForwardRef(" + fiber + ")" : "ForwardRef")
);
case 7:
return "Fragment";
case 26:
case 27:
case 5:
return type;
case 4:
return "Portal";
case 3:
return "Root";
case 6:
return "Text";
case 16:
return getComponentNameFromType(type);
case 8:
return type === REACT_STRICT_MODE_TYPE ? "StrictMode" : "Mode";
case 22:
return "Offscreen";
case 12:
return "Profiler";
case 21:
return "Scope";
case 13:
return "Suspense";
case 19:
return "SuspenseList";
case 25:
return "TracingMarker";
case 1:
case 0:
case 14:
case 15:
if ("function" === typeof type)
return type.displayName || type.name || null;
if ("string" === typeof type) return type;
break;
case 29:
type = fiber._debugInfo;
if (null != type)
for (var i = type.length - 1; 0 <= i; i--)
if ("string" === typeof type[i].name) return type[i].name;
if (null !== fiber.return)
return getComponentNameFromFiber(fiber.return);
}
return null;
}
function injectInternals(internals) {
if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1;
var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (hook.isDisabled) return !0;
if (!hook.supportsFiber)
return (
console.error(
"The installed version of React DevTools is too old and will not work with the current version of React. Please update React DevTools. https://react.dev/link/react-devtools"
),
!0
);
try {
(rendererID = hook.inject(internals)), (injectedHook = hook);
} catch (err) {
console.error("React instrumentation encountered an error: %o.", err);
}
return hook.checkDCE ? !0 : !1;
}
function setIsStrictModeForDevtools(newIsStrictMode) {
"function" === typeof log$1 &&
unstable_setDisableYieldValue(newIsStrictMode);
if (injectedHook && "function" === typeof injectedHook.setStrictMode)
try {
injectedHook.setStrictMode(rendererID, newIsStrictMode);
} catch (err) {
hasLoggedError ||
((hasLoggedError = !0),
console.error(
"React instrumentation encountered an error: %o",
err
));
}
}
function clz32Fallback(x) {
x >>>= 0;
return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0;
}
function getHighestPriorityLanes(lanes) {
var pendingSyncLanes = lanes & 42;
if (0 !== pendingSyncLanes) return pendingSyncLanes;
switch (lanes & -lanes) {
case 1:
return 1;
case 2:
return 2;
case 4:
return 4;
case 8:
return 8;
case 16:
return 16;
case 32:
return 32;
case 64:
return 64;
case 128:
return 128;
case 256:
case 512:
case 1024:
case 2048:
case 4096:
case 8192:
case 16384:
case 32768:
case 65536:
case 131072:
return lanes & 261888;
case 262144:
case 524288:
case 1048576:
case 2097152:
return lanes & 3932160;
case 4194304:
case 8388608:
case 16777216:
case 33554432:
return lanes & 62914560;
case 67108864:
return 67108864;
case 134217728:
return 134217728;
case 268435456:
return 268435456;
case 536870912:
return 536870912;
case 1073741824:
return 0;
default:
return (
console.error(
"Should have found matching lanes. This is a bug in React."
),
lanes
);
}
}
function getNextLanes(root, wipLanes, rootHasPendingCommit) {
var pendingLanes = root.pendingLanes;
if (0 === pendingLanes) return 0;
var nextLanes = 0,
suspendedLanes = root.suspendedLanes,
pingedLanes = root.pingedLanes;
root = root.warmLanes;
var nonIdlePendingLanes = pendingLanes & 134217727;
0 !== nonIdlePendingLanes
? ((pendingLanes = nonIdlePendingLanes & ~suspendedLanes),
0 !== pendingLanes
? (nextLanes = getHighestPriorityLanes(pendingLanes))
: ((pingedLanes &= nonIdlePendingLanes),
0 !== pingedLanes
? (nextLanes = getHighestPriorityLanes(pingedLanes))
: rootHasPendingCommit ||
((rootHasPendingCommit = nonIdlePendingLanes & ~root),
0 !== rootHasPendingCommit &&
(nextLanes =
getHighestPriorityLanes(rootHasPendingCommit)))))
: ((nonIdlePendingLanes = pendingLanes & ~suspendedLanes),
0 !== nonIdlePendingLanes
? (nextLanes = getHighestPriorityLanes(nonIdlePendingLanes))
: 0 !== pingedLanes
? (nextLanes = getHighestPriorityLanes(pingedLanes))
: rootHasPendingCommit ||
((rootHasPendingCommit = pendingLanes & ~root),
0 !== rootHasPendingCommit &&
(nextLanes = getHighestPriorityLanes(rootHasPendingCommit))));
return 0 === nextLanes
? 0
: 0 !== wipLanes &&
wipLanes !== nextLanes &&
0 === (wipLanes & suspendedLanes) &&
((suspendedLanes = nextLanes & -nextLanes),
(rootHasPendingCommit = wipLanes & -wipLanes),
suspendedLanes >= rootHasPendingCommit ||
(32 === suspendedLanes && 0 !== (rootHasPendingCommit & 4194048)))
? wipLanes
: nextLanes;
}
function checkIfRootIsPrerendering(root, renderLanes) {
return (
0 ===
(root.pendingLanes &
~(root.suspendedLanes & ~root.pingedLanes) &
renderLanes)
);
}
function computeExpirationTime(lane, currentTime) {
switch (lane) {
case 1:
case 2:
case 4:
case 8:
case 64:
return currentTime + 250;
case 16:
case 32:
case 128:
case 256:
case 512:
case 1024:
case 2048:
case 4096:
case 8192:
case 16384:
case 32768:
case 65536:
case 131072:
case 262144:
case 524288:
case 1048576:
case 2097152:
return currentTime + 5e3;
case 4194304:
case 8388608:
case 16777216:
case 33554432:
return -1;
case 67108864:
case 134217728:
case 268435456:
case 536870912:
case 1073741824:
return -1;
default:
return (
console.error(
"Should have found matching lanes. This is a bug in React."
),
-1
);
}
}
function claimNextRetryLane() {
var lane = nextRetryLane;
nextRetryLane <<= 1;
0 === (nextRetryLane & 62914560) && (nextRetryLane = 4194304);
return lane;
}
function createLaneMap(initial) {
for (var laneMap = [], i = 0; 31 > i; i++) laneMap.push(initial);
return laneMap;
}
function markRootUpdated$1(root, updateLane) {
root.pendingLanes |= updateLane;
268435456 !== updateLane &&
((root.suspendedLanes = 0),
(root.pingedLanes = 0),
(root.warmLanes = 0));
}
function markSpawnedDeferredLane(root, spawnedLane, entangledLanes) {
root.pendingLanes |= spawnedLane;
root.suspendedLanes &= ~spawnedLane;
var spawnedLaneIndex = 31 - clz32(spawnedLane);
root.entangledLanes |= spawnedLane;
root.entanglements[spawnedLaneIndex] =
root.entanglements[spawnedLaneIndex] |
1073741824 |
(entangledLanes & 261930);
}
function markRootEntangled(root, entangledLanes) {
var rootEntangledLanes = (root.entangledLanes |= entangledLanes);
for (root = root.entanglements; rootEntangledLanes; ) {
var index = 31 - clz32(rootEntangledLanes),
lane = 1 << index;
(lane & entangledLanes) | (root[index] & entangledLanes) &&
(root[index] |= entangledLanes);
rootEntangledLanes &= ~lane;
}
}
function getBumpedLaneForHydration(root, renderLanes) {
var renderLane = renderLanes & -renderLanes;
if (0 !== (renderLane & 42)) renderLane = 1;
else
switch (renderLane) {
case 2:
renderLane = 1;
break;
case 8:
renderLane = 4;
break;
case 32:
renderLane = 16;
break;
case 256:
case 512:
case 1024:
case 2048:
case 4096:
case 8192:
case 16384:
case 32768:
case 65536:
case 131072:
case 262144:
case 524288:
case 1048576:
case 2097152:
case 4194304:
case 8388608:
case 16777216:
case 33554432:
renderLane = 128;
break;
case 268435456:
renderLane = 134217728;
break;
default:
renderLane = 0;
}
return 0 !== (renderLane & (root.suspendedLanes | renderLanes))
? 0
: renderLane;
}
function lanesToEventPriority(lanes) {
lanes &= -lanes;
return 0 !== DiscreteEventPriority && DiscreteEventPriority < lanes
? 0 !== ContinuousEventPriority && ContinuousEventPriority < lanes
? 0 !== (lanes & 134217727)
? DefaultEventPriority
: IdleEventPriority
: ContinuousEventPriority
: DiscreteEventPriority;
}
function shim$1() {
throw Error(
"The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue."
);
}
function shim() {
throw Error(
"The current renderer does not support Resources. This error is likely caused by a bug in React. Please file an issue."
);
}
function getPublicInstance(inst) {
switch (inst.tag) {
case "INSTANCE":
var createNodeMock = inst.rootContainerInstance.createNodeMock;
createNodeMock = createNodeMock({
type: inst.type,
props: inst.props
});
"object" === typeof createNodeMock &&
null !== createNodeMock &&
nodeToInstanceMap.set(createNodeMock, inst);
return createNodeMock;
default:
return inst;
}
}
function appendChild(parentInstance, child) {
isArrayImpl(parentInstance.children) ||
console.error(
"An invalid container has been provided. This may indicate that another renderer is being used in addition to the test renderer. (For example, ReactDOM.createPortal inside of a ReactTestRenderer tree.) This is not supported."
);
var index = parentInstance.children.indexOf(child);
-1 !== index && parentInstance.children.splice(index, 1);
parentInstance.children.push(child);
}
function insertBefore(parentInstance, child, beforeChild) {
var index = parentInstance.children.indexOf(child);
-1 !== index && parentInstance.children.splice(index, 1);
beforeChild = parentInstance.children.indexOf(beforeChild);
parentInstance.children.splice(beforeChild, 0, child);
}
function removeChild(parentInstance, child) {
child = parentInstance.children.indexOf(child);
parentInstance.children.splice(child, 1);
}
function commitUpdate(instance, type, oldProps, newProps) {
instance.type = type;
instance.props = newProps;
}
function commitMount() {}
function commitTextUpdate(textInstance, oldText, newText) {
textInstance.text = newText;
}
function resetTextContent() {}
function hideInstance(instance) {
instance.isHidden = !0;
}
function hideTextInstance(textInstance) {
textInstance.isHidden = !0;
}
function unhideInstance(instance) {
instance.isHidden = !1;
}
function unhideTextInstance(textInstance) {
textInstance.isHidden = !1;
}
function createCursor(defaultValue) {
return { current: defaultValue };
}
function pop(cursor, fiber) {
0 > index$jscomp$0
? console.error("Unexpected pop.")
: (fiber !== fiberStack[index$jscomp$0] &&
console.error("Unexpected Fiber popped."),
(cursor.current = valueStack[index$jscomp$0]),
(valueStack[index$jscomp$0] = null),
(fiberStack[index$jscomp$0] = null),
index$jscomp$0--);
}
function push(cursor, value, fiber) {
index$jscomp$0++;
valueStack[index$jscomp$0] = cursor.current;
fiberStack[index$jscomp$0] = fiber;
cursor.current = value;
}
function is(x, y) {
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
}
function getArrayKind(array) {
for (var kind = 0, i = 0; i < array.length; i++) {
var value = array[i];
if ("object" === typeof value && null !== value)
if (
isArrayImpl(value) &&
2 === value.length &&
"string" === typeof value[0]
) {
if (0 !== kind && 3 !== kind) return 1;
kind = 3;
} else return 1;
else {
if (
"function" === typeof value ||
("string" === typeof value && 50 < value.length) ||
(0 !== kind && 2 !== kind)
)
return 1;
kind = 2;
}
}
return kind;
}
function addObjectToProperties(object, properties, indent, prefix) {
for (var key in object)
hasOwnProperty.call(object, key) &&
"_" !== key[0] &&
addValueToProperties(key, object[key], properties, indent, prefix);
}
function addValueToProperties(
propertyName,
value,
properties,
indent,
prefix
) {
switch (typeof value) {
case "object":
if (null === value) {
value = "null";
break;
} else {
if (value.$$typeof === REACT_ELEMENT_TYPE) {
var typeName = getComponentNameFromType(value.type) || "\u2026",
key = value.key;
value = value.props;
var propsKeys = Object.keys(value),
propsLength = propsKeys.length;
if (null == key && 0 === propsLength) {
value = "<" + typeName + " />";
break;
}
if (
3 > indent ||
(1 === propsLength &&
"children" === propsKeys[0] &&
null == key)
) {
value = "<" + typeName + " \u2026 />";
break;
}
properties.push([
prefix + "\u00a0\u00a0".repeat(indent) + propertyName,
"<" + typeName
]);
null !== key &&
addValueToProperties(
"key",
key,
properties,
indent + 1,
prefix
);
propertyName = !1;
for (var propKey in value)
"children" === propKey
? null != value.children &&
(!isArrayImpl(value.children) ||
0 < value.children.length) &&
(propertyName = !0)
: hasOwnProperty.call(value, propKey) &&
"_" !== propKey[0] &&
addValueToProperties(
propKey,
value[propKey],
properties,
indent + 1,
prefix
);
properties.push([
"",
propertyName ? ">\u2026</" + typeName + ">" : "/>"
]);
return;
}
typeName = Object.prototype.toString.call(value);
typeName = typeName.slice(8, typeName.length - 1);
if ("Array" === typeName)
if (
((propKey = getArrayKind(value)),
2 === propKey || 0 === propKey)
) {
value = JSON.stringify(value);
break;
} else if (3 === propKey) {
properties.push([
prefix + "\u00a0\u00a0".repeat(indent) + propertyName,
""
]);
for (
propertyName = 0;
propertyName < value.length;
propertyName++
)
(typeName = value[propertyName]),
addValueToProperties(
typeName[0],
typeName[1],
properties,
indent + 1,
prefix
);
return;
}
if ("Promise" === typeName) {
if ("fulfilled" === value.status) {
if (
((typeName = properties.length),
addValueToProperties(
propertyName,
value.value,
properties,
indent,
prefix
),
properties.length > typeName)
) {
properties = properties[typeName];
properties[1] =
"Promise<" + (properties[1] || "Object") + ">";
return;
}
} else if (
"rejected" === value.status &&
((typeName = properties.length),
addValueToProperties(
propertyName,
value.reason,
properties,
indent,
prefix
),
properties.length > typeName)
) {
properties = properties[typeName];
properties[1] = "Rejected Promise<" + properties[1] + ">";
return;
}
properties.push([
"\u00a0\u00a0".repeat(indent) + propertyName,
"Promise"
]);
return;
}
"Object" === typeName &&
(propKey = Object.getPrototypeOf(value)) &&
"function" === typeof propKey.constructor &&
(typeName = propKey.constructor.name);
properties.push([
prefix + "\u00a0\u00a0".repeat(indent) + propertyName,
"Object" === typeName ? (3 > indent ? "" : "\u2026") : typeName
]);
3 > indent &&
addObjectToProperties(value, properties, indent + 1, prefix);
return;
}
case "function":
value = "" === value.name ? "() => {}" : value.name + "() {}";
break;
case "string":
value =
"This object has been omitted by React in the console log to avoid sending too much data from the server. Try logging smaller or more specific objects." ===
value
? "\u2026"
: JSON.stringify(value);
break;
case "undefined":
value = "undefined";
break;
case "boolean":
value = value ? "true" : "false";
break;
default:
value = String(value);
}
properties.push([
prefix + "\u00a0\u00a0".repeat(indent) + propertyName,
value
]);
}
function addObjectDiffToProperties(prev, next, properties, indent) {
var isDeeplyEqual = !0;
for (key in prev)
key in next ||
(properties.push([
"\u2013\u00a0" + "\u00a0\u00a0".repeat(indent) + key,
"\u2026"
]),
(isDeeplyEqual = !1));
for (var _key in next)
if (_key in prev) {
var key = prev[_key];
var nextValue = next[_key];
if (key !== nextValue) {
if (0 === indent && "children" === _key)
(isDeeplyEqual = "\u00a0\u00a0".repeat(indent) + _key),
properties.push(
["\u2013\u00a0" + isDeeplyEqual, "\u2026"],
["+\u00a0" + isDeeplyEqual, "\u2026"]
);
else {
if (!(3 <= indent))
if (
"object" === typeof key &&
"object" === typeof nextValue &&
null !== key &&
null !== nextValue &&
key.$$typeof === nextValue.$$typeof
)
if (nextValue.$$typeof === REACT_ELEMENT_TYPE) {
if (
key.type === nextValue.type &&
key.key === nextValue.key
) {
key =
getComponentNameFromType(nextValue.type) || "\u2026";
isDeeplyEqual = "\u00a0\u00a0".repeat(indent) + _key;
key = "<" + key + " \u2026 />";
properties.push(
["\u2013\u00a0" + isDeeplyEqual, key],
["+\u00a0" + isDeeplyEqual, key]
);
isDeeplyEqual = !1;
continue;
}
} else {
var prevKind = Object.prototype.toString.call(key),
nextKind = Object.prototype.toString.call(nextValue);
if (
prevKind === nextKind &&
("[object Object]" === nextKind ||
"[object Array]" === nextKind)
) {
prevKind = [
"\u2007\u00a0" + "\u00a0\u00a0".repeat(indent) + _key,
"[object Array]" === nextKind ? "Array" : ""
];
properties.push(prevKind);
nextKind = properties.length;
addObjectDiffToProperties(
key,
nextValue,
properties,
indent + 1
)
? nextKind === properties.length &&
(prevKind[1] =
"Referentially unequal but deeply equal objects. Consider memoization.")
: (isDeeplyEqual = !1);
continue;
}
}
else if (
"function" === typeof key &&
"function" === typeof nextValue &&
key.name === nextValue.name &&
key.length === nextValue.length &&
((prevKind = Function.prototype.toString.call(key)),
(nextKind = Function.prototype.toString.call(nextValue)),
prevKind === nextKind)
) {
key =
"" === nextValue.name
? "() => {}"
: nextValue.name + "() {}";
properties.push([
"\u2007\u00a0" + "\u00a0\u00a0".repeat(indent) + _key,
key +
" Referentially unequal function closure. Consider memoization."
]);
continue;
}
addValueToProperties(
_key,
key,
properties,
indent,
"\u2013\u00a0"
);
addValueToProperties(
_key,
nextValue,
properties,
indent,
"+\u00a0"
);
}
isDeeplyEqual = !1;
}
} else
properties.push([
"+\u00a0" + "\u00a0\u00a0".repeat(indent) + _key,
"\u2026"
]),
(isDeeplyEqual = !1);
return isDeeplyEqual;
}
function setCurrentTrackFromLanes(lanes) {
currentTrack =
lanes & 63
? "Blocking"
: lanes & 64
? "Gesture"
: lanes & 4194176
? "Transition"
: lanes & 62914560
? "Suspense"
: lanes & 2080374784
? "Idle"
: "Other";
}
function logComponentTrigger(fiber, startTime, endTime, trigger) {
supportsUserTiming &&
((reusableComponentOptions.start = startTime),
(reusableComponentOptions.end = endTime),
(reusableComponentDevToolDetails.color = "warning"),
(reusableComponentDevToolDetails.tooltipText = trigger),
(reusableComponentDevToolDetails.properties = null),
(fiber = fiber._debugTask)
? fiber.run(
performance.measure.bind(
performance,
trigger,
reusableComponentOptions
)
)
: performance.measure(trigger, reusableComponentOptions));
}
function logComponentReappeared(fiber, startTime, endTime) {
logComponentTrigger(fiber, startTime, endTime, "Reconnect");
}
function logComponentRender(
fiber,
startTime,
endTime,
wasHydrated,
committedLanes
) {
var name = getComponentNameFromFiber(fiber);
if (null !== name && supportsUserTiming) {
var alternate = fiber.alternate,
selfTime = fiber.actualDuration;
if (null === alternate || alternate.child !== fiber.child)
for (var child = fiber.child; null !== child; child = child.sibling)
selfTime -= child.actualDuration;
wasHydrated =
0.5 > selfTime
? wasHydrated
? "tertiary-light"
: "primary-light"
: 10 > selfTime
? wasHydrated
? "tertiary"
: "primary"
: 100 > selfTime
? wasHydrated
? "tertiary-dark"
: "primary-dark"
: "error";
var props = fiber.memoizedProps;
selfTime = fiber._debugTask;
null !== props &&
null !== alternate &&
alternate.memoizedProps !== props
? ((child = [resuableChangedPropsEntry]),
(props = addObjectDiffToProperties(
alternate.memoizedProps,
props,
child,
0
)),
1 < child.length &&
(props &&
!alreadyWarnedForDeepEquality &&
0 === (alternate.lanes & committedLanes) &&
100 < fiber.actualDuration
? ((alreadyWarnedForDeepEquality = !0),
(child[0] = reusableDeeplyEqualPropsEntry),
(reusableComponentDevToolDetails.color = "warning"),
(reusableComponentDevToolDetails.tooltipText =
"This component received deeply equal props. It might benefit from useMemo or the React Compiler in its owner."))
: ((reusableComponentDevToolDetails.color = wasHydrated),
(reusableComponentDevToolDetails.tooltipText = name)),
(reusableComponentDevToolDetails.properties = child),
(reusableComponentOptions.start = startTime),
(reusableComponentOptions.end = endTime),
null != selfTime
? selfTime.run(
performance.measure.bind(
performance,
"\u200b" + name,
reusableComponentOptions
)
)
: performance.measure(
"\u200b" + name,
reusableComponentOptions
)))
: null != selfTime
? selfTime.run(
console.timeStamp.bind(
console,
name,
startTime,
endTime,
"Components \u269b",
void 0,
wasHydrated
)
)
: console.timeStamp(
name,
startTime,
endTime,
"Components \u269b",
void 0,
wasHydrated
);
}
}
function logComponentErrored(fiber, startTime, endTime, errors) {
if (supportsUserTiming) {
var name = getComponentNameFromFiber(fiber);
if (null !== name) {
for (
var debugTask = null, properties = [], i = 0;
i < errors.length;
i++
) {
var capturedValue = errors[i];
null == debugTask &&
null !== capturedValue.source &&
(debugTask = capturedValue.source._debugTask);
capturedValue = capturedValue.value;
properties.push([
"Error",
"object" === typeof capturedValue &&
null !== capturedValue &&
"string" === typeof capturedValue.message
? String(capturedValue.message)
: String(capturedValue)
]);
}
null !== fiber.key &&
addValueToProperties("key", fiber.key, properties, 0, "");
null !== fiber.memoizedProps &&
addObjectToProperties(fiber.memoizedProps, properties, 0, "");
null == debugTask && (debugTask = fiber._debugTask);
fiber = {
start: startTime,
end: endTime,
detail: {
devtools: {
color: "error",
track: "Components \u269b",
tooltipText:
13 === fiber.tag
? "Hydration failed"
: "Error boundary caught an error",
properties: properties
}
}
};
debugTask
? debugTask.run(
performance.measure.bind(performance, "\u200b" + name, fiber)
)
: performance.measure("\u200b" + name, fiber);
}
}
}
function logComponentEffect(fiber, startTime, endTime, selfTime, errors) {
if (null !== errors) {
if (supportsUserTiming) {
var name = getComponentNameFromFiber(fiber);
if (null !== name) {
selfTime = [];
for (var i = 0; i < errors.length; i++) {
var error = errors[i].value;
selfTime.push([
"Error",
"object" === typeof error &&
null !== error &&
"string" === typeof error.message
? String(error.message)
: String(error)
]);
}
null !== fiber.key &&
addValueToProperties("key", fiber.key, selfTime, 0, "");
null !== fiber.memoizedProps &&
addObjectToProperties(fiber.memoizedProps, selfTime, 0, "");
startTime = {
start: startTime,
end: endTime,
detail: {
devtools: {
color: "error",
track: "Components \u269b",
tooltipText: "A lifecycle or effect errored",
properties: selfTime
}
}
};
(fiber = fiber._debugTask)
? fiber.run(
performance.measure.bind(
performance,
"\u200b" + name,
startTime
)
)
: performance.measure("\u200b" + name, startTime);
}
}
} else
(name = getComponentNameFromFiber(fiber)),
null !== name &&
supportsUserTiming &&
((errors =
1 > selfTime
? "secondary-light"
: 100 > selfTime
? "secondary"
: 500 > selfTime
? "secondary-dark"
: "error"),
(fiber = fiber._debugTask)
? fiber.run(
console.timeStamp.bind(
console,
name,
startTime,
endTime,
"Components \u269b",
void 0,
errors
)
)
: console.timeStamp(
name,
startTime,
endTime,
"Components \u269b",
void 0,
errors
));
}
function logSuspendedRenderPhase(startTime, endTime, lanes, debugTask) {
!supportsUserTiming ||
endTime <= startTime ||
((lanes =
(lanes & 738197653) === lanes ? "tertiary-dark" : "primary-dark"),
debugTask
? debugTask.run(
console.timeStamp.bind(
console,
"Prewarm",
startTime,
endTime,
currentTrack,
"Scheduler \u269b",
lanes
)
)
: console.timeStamp(
"Prewarm",
startTime,
endTime,
currentTrack,
"Scheduler \u269b",
lanes
));
}
function logSuspendedWithDelayPhase(startTime, endTime, lanes, debugTask) {
!supportsUserTiming ||
endTime <= startTime ||
((lanes =
(lanes & 738197653) === lanes ? "tertiary-dark" : "primary-dark"),
debugTask
? debugTask.run(
console.timeStamp.bind(
console,
"Suspended",
startTime,
endTime,
currentTrack,
"Scheduler \u269b",
lanes
)
)
: console.timeStamp(
"Suspended",
startTime,
endTime,
currentTrack,
"Scheduler \u269b",
lanes
));
}
function logErroredRenderPhase(startTime, endTime, lanes, debugTask) {
!supportsUserTiming ||
endTime <= startTime ||
(debugTask
? debugTask.run(
console.timeStamp.bind(
console,
"Errored",
startTime,
endTime,
currentTrack,
"Scheduler \u269b",
"error"
)
)
: console.timeStamp(
"Errored",
startTime,
endTime,
currentTrack,
"Scheduler \u269b",
"error"
));
}
function logCommitErrored(startTime, endTime, errors, passive, debugTask) {
if (supportsUserTiming && !(endTime <= startTime)) {
for (var properties = [], i = 0; i < errors.length; i++) {
var error = errors[i].value;
properties.push([
"Error",
"object" === typeof error &&
null !== error &&
"string" === typeof error.message
? String(error.message)
: String(error)
]);
}
startTime = {
start: startTime,
end: endTime,
detail: {
devtools: {
color: "error",
track: currentTrack,
trackGroup: "Scheduler \u269b",
tooltipText: passive
? "Remaining Effects Errored"
: "Commit Errored",
properties: properties
}
}
};
debugTask
? debugTask.run(
performance.measure.bind(performance, "Errored", startTime)
)
: performance.measure("Errored", startTime);
}
}
function disabledLog() {}
function disableLogs() {
if (0 === disabledDepth) {
prevLog = console.log;
prevInfo = console.info;
prevWarn = console.warn;
prevError = console.error;
prevGroup = console.group;
prevGroupCollapsed = console.groupCollapsed;
prevGroupEnd = console.groupEnd;
var props = {
configurable: !0,
enumerable: !0,
value: disabledLog,
writable: !0
};
Object.defineProperties(console, {
info: props,
log: props,
warn: props,
error: props,
group: props,
groupCollapsed: props,
groupEnd: props
});
}
disabledDepth++;
}
function reenableLogs() {
disabledDepth--;
if (0 === disabledDepth) {
var props = { configurable: !0, enumerable: !0, writable: !0 };
Object.defineProperties(console, {
log: assign({}, props, { value: prevLog }),
info: assign({}, props, { value: prevInfo }),
warn: assign({}, props, { value: prevWarn }),
error: assign({}, props, { value: prevError }),
group: assign({}, props, { value: prevGroup }),
groupCollapsed: assign({}, props, { value: prevGroupCollapsed }),
groupEnd: assign({}