Comparing version 19.0.0-rc-20b6f4c0e8-20240607 to 19.0.0-rc-34d0c5e357-20240607
@@ -28,44 +28,28 @@ /** | ||
printWarning('error', format, args, new Error('react-stack-top-frame')); | ||
printWarning('error', format, args); | ||
} | ||
} | ||
} // eslint-disable-next-line react-internal/no-production-logging | ||
} | ||
function printWarning(level, format, args, currentStack) { | ||
function printWarning(level, format, args) { | ||
// When changing this logic, you might want to also | ||
// update consoleWithStackDev.www.js as well. | ||
{ | ||
var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
var stack = ReactSharedInternals.getStackAddendum(); | ||
if (ReactSharedInternals.getCurrentStack) { | ||
// We only add the current stack to the console when createTask is not supported. | ||
// Since createTask requires DevTools to be open to work, this means that stacks | ||
// can be lost while DevTools isn't open but we can't detect this. | ||
var stack = ReactSharedInternals.getCurrentStack(currentStack); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} // eslint-disable-next-line react-internal/safe-string-coercion | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
} | ||
if (isErrorLogger) { | ||
// Don't prefix our default logging formatting in ReactFiberErrorLoggger. | ||
// Don't toString the arguments. | ||
args.unshift(format); | ||
} else { | ||
// TODO: Remove this prefix and stop toStringing in the wrapper and | ||
// instead do it at each callsite as needed. | ||
// Careful: RN currently depends on this prefix | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
args = args.map(function (item) { | ||
return String(item); | ||
}); | ||
args.unshift('Warning: ' + format); | ||
} // We intentionally don't use spread (or .apply) directly because it | ||
var argsWithFormat = args.map(function (item) { | ||
return String(item); | ||
}); // Careful: RN currently depends on this prefix | ||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | ||
// breaks IE9: https://github.com/facebook/react/issues/13610 | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
Function.prototype.apply.call(console[level], console, args); | ||
Function.prototype.apply.call(console[level], console, argsWithFormat); | ||
} | ||
@@ -72,0 +56,0 @@ } |
@@ -77,44 +77,28 @@ /** | ||
printWarning('error', format, args, new Error('react-stack-top-frame')); | ||
printWarning('error', format, args); | ||
} | ||
} | ||
} // eslint-disable-next-line react-internal/no-production-logging | ||
} | ||
function printWarning(level, format, args, currentStack) { | ||
function printWarning(level, format, args) { | ||
// When changing this logic, you might want to also | ||
// update consoleWithStackDev.www.js as well. | ||
{ | ||
var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
var stack = ReactSharedInternals.getStackAddendum(); | ||
if (ReactSharedInternals.getCurrentStack) { | ||
// We only add the current stack to the console when createTask is not supported. | ||
// Since createTask requires DevTools to be open to work, this means that stacks | ||
// can be lost while DevTools isn't open but we can't detect this. | ||
var stack = ReactSharedInternals.getCurrentStack(currentStack); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} // eslint-disable-next-line react-internal/safe-string-coercion | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
} | ||
if (isErrorLogger) { | ||
// Don't prefix our default logging formatting in ReactFiberErrorLoggger. | ||
// Don't toString the arguments. | ||
args.unshift(format); | ||
} else { | ||
// TODO: Remove this prefix and stop toStringing in the wrapper and | ||
// instead do it at each callsite as needed. | ||
// Careful: RN currently depends on this prefix | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
args = args.map(function (item) { | ||
return String(item); | ||
}); | ||
args.unshift('Warning: ' + format); | ||
} // We intentionally don't use spread (or .apply) directly because it | ||
var argsWithFormat = args.map(function (item) { | ||
return String(item); | ||
}); // Careful: RN currently depends on this prefix | ||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | ||
// breaks IE9: https://github.com/facebook/react/issues/13610 | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
Function.prototype.apply.call(console[level], console, args); | ||
Function.prototype.apply.call(console[level], console, argsWithFormat); | ||
} | ||
@@ -310,5 +294,3 @@ } | ||
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); // This function is deprecated. Don't use. Only the renderer knows what a valid type is. | ||
// TODO: Delete this when enableOwnerStacks ships. | ||
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); | ||
function isValidElementType(type) { | ||
@@ -711,5 +693,4 @@ if (typeof type === 'string' || typeof type === 'function') { | ||
return !!(prototype && prototype.isReactComponent); | ||
} // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship. | ||
} | ||
function describeUnknownElementTypeFrameInDEV(type) { | ||
@@ -944,3 +925,3 @@ | ||
writable: true, | ||
value: 0 | ||
value: false | ||
}); // debugInfo contains Server Component debug information. | ||
@@ -972,6 +953,2 @@ | ||
function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) { | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) { | ||
{ | ||
@@ -1111,5 +1088,27 @@ if (!isValidElementType(type)) { | ||
return ReactElement(type, key, ref, self, source, getOwner(), props); | ||
var element = ReactElement(type, key, ref, self, source, getOwner(), props); | ||
if (type === REACT_FRAGMENT_TYPE) { | ||
validateFragmentProps(element); | ||
} | ||
return element; | ||
} | ||
} | ||
function getDeclarationErrorAddendum() { | ||
{ | ||
var owner = getOwner(); | ||
if (owner) { | ||
var name = getComponentNameFromType(owner.type); | ||
if (name) { | ||
return '\n\nCheck the render method of `' + name + '`.'; | ||
} | ||
} | ||
return ''; | ||
} | ||
} | ||
/** | ||
@@ -1125,2 +1124,3 @@ * Ensure that every element either is passed in a static location, in an | ||
function validateChildKeys(node, parentType) { | ||
@@ -1143,3 +1143,3 @@ { | ||
if (node._store) { | ||
node._store.validated = 1; | ||
node._store.validated = true; | ||
} | ||
@@ -1195,3 +1195,2 @@ } else { | ||
function validateExplicitKey(element, parentType) { | ||
{ | ||
@@ -1202,3 +1201,3 @@ if (!element._store || element._store.validated || element.key != null) { | ||
element._store.validated = 1; | ||
element._store.validated = true; | ||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); | ||
@@ -1229,34 +1228,25 @@ | ||
var prevGetCurrentStack = ReactSharedInternals.getCurrentStack; | ||
setCurrentlyValidatingElement(element); | ||
ReactSharedInternals.getCurrentStack = function () { | ||
var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation | ||
if (prevGetCurrentStack) { | ||
stack += prevGetCurrentStack() || ''; | ||
} | ||
return stack; | ||
}; | ||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); | ||
ReactSharedInternals.getCurrentStack = prevGetCurrentStack; | ||
setCurrentlyValidatingElement(null); | ||
} | ||
} | ||
function setCurrentlyValidatingElement(element) { | ||
{ | ||
if (element) { | ||
var stack = describeUnknownElementTypeFrameInDEV(element.type); | ||
ReactSharedInternals.setExtraStackFrame(stack); | ||
} else { | ||
ReactSharedInternals.setExtraStackFrame(null); | ||
} | ||
} | ||
} | ||
function getCurrentComponentErrorInfo(parentType) { | ||
{ | ||
var info = ''; | ||
var owner = getOwner(); | ||
var info = getDeclarationErrorAddendum(); | ||
if (owner) { | ||
var name = getComponentNameFromType(owner.type); | ||
if (name) { | ||
info = '\n\nCheck the render method of `' + name + '`.'; | ||
} | ||
} | ||
if (!info) { | ||
@@ -1273,3 +1263,28 @@ var parentName = getComponentNameFromType(parentType); | ||
} | ||
/** | ||
* Given a fragment, validate that it can only be provided with fragment props | ||
* @param {ReactElement} fragment | ||
*/ | ||
function validateFragmentProps(fragment) { | ||
// TODO: Move this to render phase instead of at element creation. | ||
{ | ||
var keys = Object.keys(fragment.props); | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
if (key !== 'children' && key !== 'key') { | ||
setCurrentlyValidatingElement(fragment); | ||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); | ||
setCurrentlyValidatingElement(null); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
var jsxDEV = jsxDEV$1 ; | ||
@@ -1276,0 +1291,0 @@ |
@@ -82,44 +82,28 @@ /** | ||
printWarning('error', format, args, new Error('react-stack-top-frame')); | ||
printWarning('error', format, args); | ||
} | ||
} | ||
} // eslint-disable-next-line react-internal/no-production-logging | ||
} | ||
function printWarning(level, format, args, currentStack) { | ||
function printWarning(level, format, args) { | ||
// When changing this logic, you might want to also | ||
// update consoleWithStackDev.www.js as well. | ||
{ | ||
var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
var stack = ReactSharedInternalsServer.getStackAddendum(); | ||
if (ReactSharedInternalsServer.getCurrentStack) { | ||
// We only add the current stack to the console when createTask is not supported. | ||
// Since createTask requires DevTools to be open to work, this means that stacks | ||
// can be lost while DevTools isn't open but we can't detect this. | ||
var stack = ReactSharedInternalsServer.getCurrentStack(currentStack); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} // eslint-disable-next-line react-internal/safe-string-coercion | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
} | ||
if (isErrorLogger) { | ||
// Don't prefix our default logging formatting in ReactFiberErrorLoggger. | ||
// Don't toString the arguments. | ||
args.unshift(format); | ||
} else { | ||
// TODO: Remove this prefix and stop toStringing in the wrapper and | ||
// instead do it at each callsite as needed. | ||
// Careful: RN currently depends on this prefix | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
args = args.map(function (item) { | ||
return String(item); | ||
}); | ||
args.unshift('Warning: ' + format); | ||
} // We intentionally don't use spread (or .apply) directly because it | ||
var argsWithFormat = args.map(function (item) { | ||
return String(item); | ||
}); // Careful: RN currently depends on this prefix | ||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | ||
// breaks IE9: https://github.com/facebook/react/issues/13610 | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
Function.prototype.apply.call(console[level], console, args); | ||
Function.prototype.apply.call(console[level], console, argsWithFormat); | ||
} | ||
@@ -315,5 +299,3 @@ } | ||
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); // This function is deprecated. Don't use. Only the renderer knows what a valid type is. | ||
// TODO: Delete this when enableOwnerStacks ships. | ||
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); | ||
function isValidElementType(type) { | ||
@@ -716,5 +698,4 @@ if (typeof type === 'string' || typeof type === 'function') { | ||
return !!(prototype && prototype.isReactComponent); | ||
} // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship. | ||
} | ||
function describeUnknownElementTypeFrameInDEV(type) { | ||
@@ -949,3 +930,3 @@ | ||
writable: true, | ||
value: 0 | ||
value: false | ||
}); // debugInfo contains Server Component debug information. | ||
@@ -983,3 +964,3 @@ | ||
var isStaticChildren = false; | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
@@ -990,3 +971,3 @@ } | ||
var isStaticChildren = true; | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
@@ -1003,6 +984,2 @@ } | ||
function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) { | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) { | ||
{ | ||
@@ -1142,5 +1119,27 @@ if (!isValidElementType(type)) { | ||
return ReactElement(type, key, ref, self, source, getOwner(), props); | ||
var element = ReactElement(type, key, ref, self, source, getOwner(), props); | ||
if (type === REACT_FRAGMENT_TYPE) { | ||
validateFragmentProps(element); | ||
} | ||
return element; | ||
} | ||
} | ||
function getDeclarationErrorAddendum() { | ||
{ | ||
var owner = getOwner(); | ||
if (owner) { | ||
var name = getComponentNameFromType(owner.type); | ||
if (name) { | ||
return '\n\nCheck the render method of `' + name + '`.'; | ||
} | ||
} | ||
return ''; | ||
} | ||
} | ||
/** | ||
@@ -1156,2 +1155,3 @@ * Ensure that every element either is passed in a static location, in an | ||
function validateChildKeys(node, parentType) { | ||
@@ -1174,3 +1174,3 @@ { | ||
if (node._store) { | ||
node._store.validated = 1; | ||
node._store.validated = true; | ||
} | ||
@@ -1226,3 +1226,2 @@ } else { | ||
function validateExplicitKey(element, parentType) { | ||
{ | ||
@@ -1233,3 +1232,3 @@ if (!element._store || element._store.validated || element.key != null) { | ||
element._store.validated = 1; | ||
element._store.validated = true; | ||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); | ||
@@ -1260,34 +1259,25 @@ | ||
var prevGetCurrentStack = ReactSharedInternalsServer.getCurrentStack; | ||
setCurrentlyValidatingElement(element); | ||
ReactSharedInternalsServer.getCurrentStack = function () { | ||
var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation | ||
if (prevGetCurrentStack) { | ||
stack += prevGetCurrentStack() || ''; | ||
} | ||
return stack; | ||
}; | ||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); | ||
ReactSharedInternalsServer.getCurrentStack = prevGetCurrentStack; | ||
setCurrentlyValidatingElement(null); | ||
} | ||
} | ||
function setCurrentlyValidatingElement(element) { | ||
{ | ||
if (element) { | ||
var stack = describeUnknownElementTypeFrameInDEV(element.type); | ||
ReactSharedInternalsServer.setExtraStackFrame(stack); | ||
} else { | ||
ReactSharedInternalsServer.setExtraStackFrame(null); | ||
} | ||
} | ||
} | ||
function getCurrentComponentErrorInfo(parentType) { | ||
{ | ||
var info = ''; | ||
var owner = getOwner(); | ||
var info = getDeclarationErrorAddendum(); | ||
if (owner) { | ||
var name = getComponentNameFromType(owner.type); | ||
if (name) { | ||
info = '\n\nCheck the render method of `' + name + '`.'; | ||
} | ||
} | ||
if (!info) { | ||
@@ -1304,3 +1294,28 @@ var parentName = getComponentNameFromType(parentType); | ||
} | ||
/** | ||
* Given a fragment, validate that it can only be provided with fragment props | ||
* @param {ReactElement} fragment | ||
*/ | ||
function validateFragmentProps(fragment) { | ||
// TODO: Move this to render phase instead of at element creation. | ||
{ | ||
var keys = Object.keys(fragment.props); | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
if (key !== 'children' && key !== 'key') { | ||
setCurrentlyValidatingElement(fragment); | ||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); | ||
setCurrentlyValidatingElement(null); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
var jsx = jsxProdSignatureRunningInDevWithDynamicChildren ; // we may want to special case jsxs internally to take advantage of static children. | ||
@@ -1307,0 +1322,0 @@ // for now we can ship identical prod functions |
@@ -77,44 +77,28 @@ /** | ||
printWarning('error', format, args, new Error('react-stack-top-frame')); | ||
printWarning('error', format, args); | ||
} | ||
} | ||
} // eslint-disable-next-line react-internal/no-production-logging | ||
} | ||
function printWarning(level, format, args, currentStack) { | ||
function printWarning(level, format, args) { | ||
// When changing this logic, you might want to also | ||
// update consoleWithStackDev.www.js as well. | ||
{ | ||
var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
var stack = ReactSharedInternals.getStackAddendum(); | ||
if (ReactSharedInternals.getCurrentStack) { | ||
// We only add the current stack to the console when createTask is not supported. | ||
// Since createTask requires DevTools to be open to work, this means that stacks | ||
// can be lost while DevTools isn't open but we can't detect this. | ||
var stack = ReactSharedInternals.getCurrentStack(currentStack); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} // eslint-disable-next-line react-internal/safe-string-coercion | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
} | ||
if (isErrorLogger) { | ||
// Don't prefix our default logging formatting in ReactFiberErrorLoggger. | ||
// Don't toString the arguments. | ||
args.unshift(format); | ||
} else { | ||
// TODO: Remove this prefix and stop toStringing in the wrapper and | ||
// instead do it at each callsite as needed. | ||
// Careful: RN currently depends on this prefix | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
args = args.map(function (item) { | ||
return String(item); | ||
}); | ||
args.unshift('Warning: ' + format); | ||
} // We intentionally don't use spread (or .apply) directly because it | ||
var argsWithFormat = args.map(function (item) { | ||
return String(item); | ||
}); // Careful: RN currently depends on this prefix | ||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | ||
// breaks IE9: https://github.com/facebook/react/issues/13610 | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
Function.prototype.apply.call(console[level], console, args); | ||
Function.prototype.apply.call(console[level], console, argsWithFormat); | ||
} | ||
@@ -310,5 +294,3 @@ } | ||
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); // This function is deprecated. Don't use. Only the renderer knows what a valid type is. | ||
// TODO: Delete this when enableOwnerStacks ships. | ||
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); | ||
function isValidElementType(type) { | ||
@@ -711,5 +693,4 @@ if (typeof type === 'string' || typeof type === 'function') { | ||
return !!(prototype && prototype.isReactComponent); | ||
} // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship. | ||
} | ||
function describeUnknownElementTypeFrameInDEV(type) { | ||
@@ -944,3 +925,3 @@ | ||
writable: true, | ||
value: 0 | ||
value: false | ||
}); // debugInfo contains Server Component debug information. | ||
@@ -978,3 +959,3 @@ | ||
var isStaticChildren = false; | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
return jsxDEV(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
@@ -985,8 +966,14 @@ } | ||
var isStaticChildren = true; | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
return jsxDEV(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
} | ||
var didWarnAboutKeySpread = {}; | ||
/** | ||
* https://github.com/reactjs/rfcs/pull/107 | ||
* @param {*} type | ||
* @param {object} props | ||
* @param {string} key | ||
*/ | ||
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) { | ||
function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) { | ||
{ | ||
@@ -1126,5 +1113,27 @@ if (!isValidElementType(type)) { | ||
return ReactElement(type, key, ref, self, source, getOwner(), props); | ||
var element = ReactElement(type, key, ref, self, source, getOwner(), props); | ||
if (type === REACT_FRAGMENT_TYPE) { | ||
validateFragmentProps(element); | ||
} | ||
return element; | ||
} | ||
} | ||
function getDeclarationErrorAddendum() { | ||
{ | ||
var owner = getOwner(); | ||
if (owner) { | ||
var name = getComponentNameFromType(owner.type); | ||
if (name) { | ||
return '\n\nCheck the render method of `' + name + '`.'; | ||
} | ||
} | ||
return ''; | ||
} | ||
} | ||
/** | ||
@@ -1140,2 +1149,3 @@ * Ensure that every element either is passed in a static location, in an | ||
function validateChildKeys(node, parentType) { | ||
@@ -1158,3 +1168,3 @@ { | ||
if (node._store) { | ||
node._store.validated = 1; | ||
node._store.validated = true; | ||
} | ||
@@ -1210,3 +1220,2 @@ } else { | ||
function validateExplicitKey(element, parentType) { | ||
{ | ||
@@ -1217,3 +1226,3 @@ if (!element._store || element._store.validated || element.key != null) { | ||
element._store.validated = 1; | ||
element._store.validated = true; | ||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); | ||
@@ -1244,34 +1253,25 @@ | ||
var prevGetCurrentStack = ReactSharedInternals.getCurrentStack; | ||
setCurrentlyValidatingElement(element); | ||
ReactSharedInternals.getCurrentStack = function () { | ||
var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation | ||
if (prevGetCurrentStack) { | ||
stack += prevGetCurrentStack() || ''; | ||
} | ||
return stack; | ||
}; | ||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); | ||
ReactSharedInternals.getCurrentStack = prevGetCurrentStack; | ||
setCurrentlyValidatingElement(null); | ||
} | ||
} | ||
function setCurrentlyValidatingElement(element) { | ||
{ | ||
if (element) { | ||
var stack = describeUnknownElementTypeFrameInDEV(element.type); | ||
ReactSharedInternals.setExtraStackFrame(stack); | ||
} else { | ||
ReactSharedInternals.setExtraStackFrame(null); | ||
} | ||
} | ||
} | ||
function getCurrentComponentErrorInfo(parentType) { | ||
{ | ||
var info = ''; | ||
var owner = getOwner(); | ||
var info = getDeclarationErrorAddendum(); | ||
if (owner) { | ||
var name = getComponentNameFromType(owner.type); | ||
if (name) { | ||
info = '\n\nCheck the render method of `' + name + '`.'; | ||
} | ||
} | ||
if (!info) { | ||
@@ -1288,3 +1288,28 @@ var parentName = getComponentNameFromType(parentType); | ||
} | ||
/** | ||
* Given a fragment, validate that it can only be provided with fragment props | ||
* @param {ReactElement} fragment | ||
*/ | ||
function validateFragmentProps(fragment) { | ||
// TODO: Move this to render phase instead of at element creation. | ||
{ | ||
var keys = Object.keys(fragment.props); | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
if (key !== 'children' && key !== 'key') { | ||
setCurrentlyValidatingElement(fragment); | ||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); | ||
setCurrentlyValidatingElement(null); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
var jsx = jsxProdSignatureRunningInDevWithDynamicChildren ; // we may want to special case jsxs internally to take advantage of static children. | ||
@@ -1291,0 +1316,0 @@ // for now we can ship identical prod functions |
@@ -82,44 +82,28 @@ /** | ||
printWarning('error', format, args, new Error('react-stack-top-frame')); | ||
printWarning('error', format, args); | ||
} | ||
} | ||
} // eslint-disable-next-line react-internal/no-production-logging | ||
} | ||
function printWarning(level, format, args, currentStack) { | ||
function printWarning(level, format, args) { | ||
// When changing this logic, you might want to also | ||
// update consoleWithStackDev.www.js as well. | ||
{ | ||
var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
var stack = ReactSharedInternalsServer.getStackAddendum(); | ||
if (ReactSharedInternalsServer.getCurrentStack) { | ||
// We only add the current stack to the console when createTask is not supported. | ||
// Since createTask requires DevTools to be open to work, this means that stacks | ||
// can be lost while DevTools isn't open but we can't detect this. | ||
var stack = ReactSharedInternalsServer.getCurrentStack(currentStack); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} // eslint-disable-next-line react-internal/safe-string-coercion | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
} | ||
if (isErrorLogger) { | ||
// Don't prefix our default logging formatting in ReactFiberErrorLoggger. | ||
// Don't toString the arguments. | ||
args.unshift(format); | ||
} else { | ||
// TODO: Remove this prefix and stop toStringing in the wrapper and | ||
// instead do it at each callsite as needed. | ||
// Careful: RN currently depends on this prefix | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
args = args.map(function (item) { | ||
return String(item); | ||
}); | ||
args.unshift('Warning: ' + format); | ||
} // We intentionally don't use spread (or .apply) directly because it | ||
var argsWithFormat = args.map(function (item) { | ||
return String(item); | ||
}); // Careful: RN currently depends on this prefix | ||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | ||
// breaks IE9: https://github.com/facebook/react/issues/13610 | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
Function.prototype.apply.call(console[level], console, args); | ||
Function.prototype.apply.call(console[level], console, argsWithFormat); | ||
} | ||
@@ -315,5 +299,3 @@ } | ||
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); // This function is deprecated. Don't use. Only the renderer knows what a valid type is. | ||
// TODO: Delete this when enableOwnerStacks ships. | ||
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference'); | ||
function isValidElementType(type) { | ||
@@ -716,5 +698,4 @@ if (typeof type === 'string' || typeof type === 'function') { | ||
return !!(prototype && prototype.isReactComponent); | ||
} // TODO: Delete this once the key warning no longer uses it. I.e. when enableOwnerStacks ship. | ||
} | ||
function describeUnknownElementTypeFrameInDEV(type) { | ||
@@ -949,3 +930,3 @@ | ||
writable: true, | ||
value: 0 | ||
value: false | ||
}); // debugInfo contains Server Component debug information. | ||
@@ -983,3 +964,3 @@ | ||
var isStaticChildren = false; | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
@@ -990,3 +971,3 @@ } | ||
var isStaticChildren = true; | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
return jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
@@ -1003,6 +984,2 @@ } | ||
function jsxDEV$1(type, config, maybeKey, isStaticChildren, source, self) { | ||
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self); | ||
} | ||
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self, debugStack, debugTask) { | ||
{ | ||
@@ -1142,5 +1119,27 @@ if (!isValidElementType(type)) { | ||
return ReactElement(type, key, ref, self, source, getOwner(), props); | ||
var element = ReactElement(type, key, ref, self, source, getOwner(), props); | ||
if (type === REACT_FRAGMENT_TYPE) { | ||
validateFragmentProps(element); | ||
} | ||
return element; | ||
} | ||
} | ||
function getDeclarationErrorAddendum() { | ||
{ | ||
var owner = getOwner(); | ||
if (owner) { | ||
var name = getComponentNameFromType(owner.type); | ||
if (name) { | ||
return '\n\nCheck the render method of `' + name + '`.'; | ||
} | ||
} | ||
return ''; | ||
} | ||
} | ||
/** | ||
@@ -1156,2 +1155,3 @@ * Ensure that every element either is passed in a static location, in an | ||
function validateChildKeys(node, parentType) { | ||
@@ -1174,3 +1174,3 @@ { | ||
if (node._store) { | ||
node._store.validated = 1; | ||
node._store.validated = true; | ||
} | ||
@@ -1226,3 +1226,2 @@ } else { | ||
function validateExplicitKey(element, parentType) { | ||
{ | ||
@@ -1233,3 +1232,3 @@ if (!element._store || element._store.validated || element.key != null) { | ||
element._store.validated = 1; | ||
element._store.validated = true; | ||
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); | ||
@@ -1260,34 +1259,25 @@ | ||
var prevGetCurrentStack = ReactSharedInternalsServer.getCurrentStack; | ||
setCurrentlyValidatingElement(element); | ||
ReactSharedInternalsServer.getCurrentStack = function () { | ||
var stack = describeUnknownElementTypeFrameInDEV(element.type); // Delegate to the injected renderer-specific implementation | ||
if (prevGetCurrentStack) { | ||
stack += prevGetCurrentStack() || ''; | ||
} | ||
return stack; | ||
}; | ||
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); | ||
ReactSharedInternalsServer.getCurrentStack = prevGetCurrentStack; | ||
setCurrentlyValidatingElement(null); | ||
} | ||
} | ||
function setCurrentlyValidatingElement(element) { | ||
{ | ||
if (element) { | ||
var stack = describeUnknownElementTypeFrameInDEV(element.type); | ||
ReactSharedInternalsServer.setExtraStackFrame(stack); | ||
} else { | ||
ReactSharedInternalsServer.setExtraStackFrame(null); | ||
} | ||
} | ||
} | ||
function getCurrentComponentErrorInfo(parentType) { | ||
{ | ||
var info = ''; | ||
var owner = getOwner(); | ||
var info = getDeclarationErrorAddendum(); | ||
if (owner) { | ||
var name = getComponentNameFromType(owner.type); | ||
if (name) { | ||
info = '\n\nCheck the render method of `' + name + '`.'; | ||
} | ||
} | ||
if (!info) { | ||
@@ -1304,3 +1294,28 @@ var parentName = getComponentNameFromType(parentType); | ||
} | ||
/** | ||
* Given a fragment, validate that it can only be provided with fragment props | ||
* @param {ReactElement} fragment | ||
*/ | ||
function validateFragmentProps(fragment) { | ||
// TODO: Move this to render phase instead of at element creation. | ||
{ | ||
var keys = Object.keys(fragment.props); | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
if (key !== 'children' && key !== 'key') { | ||
setCurrentlyValidatingElement(fragment); | ||
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); | ||
setCurrentlyValidatingElement(null); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
var jsx = jsxProdSignatureRunningInDevWithDynamicChildren ; // we may want to special case jsxs internally to take advantage of static children. | ||
@@ -1307,0 +1322,0 @@ // for now we can ship identical prod functions |
@@ -75,3 +75,3 @@ /** | ||
var isArrayImpl = Array.isArray, | ||
ReactSharedInternals = { H: null, A: null, T: null, S: null }, | ||
ReactSharedInternals = { H: null, A: null, T: null }, | ||
hasOwnProperty = Object.prototype.hasOwnProperty; | ||
@@ -203,4 +203,3 @@ function ReactElement(type, key, _ref, self, source, owner, props) { | ||
escapedPrefix + | ||
(null == callback.key || | ||
(children && children.key === callback.key) | ||
(!callback.key || (children && children.key === callback.key) | ||
? "" | ||
@@ -461,13 +460,14 @@ : ("" + callback.key).replace( | ||
var prevTransition = ReactSharedInternals.T, | ||
transition = {}; | ||
ReactSharedInternals.T = transition; | ||
callbacks = new Set(); | ||
ReactSharedInternals.T = { _callbacks: callbacks }; | ||
var currentTransition = ReactSharedInternals.T; | ||
try { | ||
var returnValue = scope(), | ||
onStartTransitionFinish = ReactSharedInternals.S; | ||
null !== onStartTransitionFinish && | ||
onStartTransitionFinish(transition, returnValue); | ||
var returnValue = scope(); | ||
"object" === typeof returnValue && | ||
null !== returnValue && | ||
"function" === typeof returnValue.then && | ||
returnValue.then(noop, reportGlobalError); | ||
(callbacks.forEach(function (callback) { | ||
return callback(currentTransition, returnValue); | ||
}), | ||
returnValue.then(noop, reportGlobalError)); | ||
} catch (error) { | ||
@@ -542,2 +542,2 @@ reportGlobalError(error); | ||
}; | ||
exports.version = "19.0.0-rc-20b6f4c0e8-20240607"; | ||
exports.version = "19.0.0-rc-34d0c5e357-20240607"; |
@@ -91,3 +91,3 @@ /** | ||
} | ||
function noop() {} | ||
function noop$1() {} | ||
function resolveThenable(thenable) { | ||
@@ -102,3 +102,3 @@ switch (thenable.status) { | ||
("string" === typeof thenable.status | ||
? thenable.then(noop, noop) | ||
? thenable.then(noop$1, noop$1) | ||
: ((thenable.status = "pending"), | ||
@@ -175,4 +175,3 @@ thenable.then( | ||
escapedPrefix + | ||
(null == callback.key || | ||
(children && children.key === callback.key) | ||
(!callback.key || (children && children.key === callback.key) | ||
? "" | ||
@@ -271,2 +270,32 @@ : ("" + callback.key).replace( | ||
} | ||
var reportGlobalError = | ||
"function" === typeof reportError | ||
? reportError | ||
: function (error) { | ||
if ( | ||
"object" === typeof window && | ||
"function" === typeof window.ErrorEvent | ||
) { | ||
var event = new window.ErrorEvent("error", { | ||
bubbles: !0, | ||
cancelable: !0, | ||
message: | ||
"object" === typeof error && | ||
null !== error && | ||
"string" === typeof error.message | ||
? String(error.message) | ||
: String(error), | ||
error: error | ||
}); | ||
if (!window.dispatchEvent(event)) return; | ||
} else if ( | ||
"object" === typeof process && | ||
"function" === typeof process.emit | ||
) { | ||
process.emit("uncaughtException", error); | ||
return; | ||
} | ||
console.error(error); | ||
}; | ||
function noop() {} | ||
exports.Children = { | ||
@@ -418,5 +447,28 @@ map: mapChildren, | ||
}; | ||
exports.startTransition = function (scope) { | ||
var prevTransition = ReactSharedInternals.T, | ||
callbacks = new Set(); | ||
ReactSharedInternals.T = { _callbacks: callbacks }; | ||
var currentTransition = ReactSharedInternals.T; | ||
try { | ||
var returnValue = scope(); | ||
"object" === typeof returnValue && | ||
null !== returnValue && | ||
"function" === typeof returnValue.then && | ||
(callbacks.forEach(function (callback) { | ||
return callback(currentTransition, returnValue); | ||
}), | ||
returnValue.then(noop, reportGlobalError)); | ||
} catch (error) { | ||
reportGlobalError(error); | ||
} finally { | ||
ReactSharedInternals.T = prevTransition; | ||
} | ||
}; | ||
exports.use = function (usable) { | ||
return ReactSharedInternals.H.use(usable); | ||
}; | ||
exports.useActionState = function (action, initialState, permalink) { | ||
return ReactSharedInternals.H.useActionState(action, initialState, permalink); | ||
}; | ||
exports.useCallback = function (callback, deps) { | ||
@@ -432,2 +484,2 @@ return ReactSharedInternals.H.useCallback(callback, deps); | ||
}; | ||
exports.version = "19.0.0-rc-20b6f4c0e8-20240607"; | ||
exports.version = "19.0.0-rc-34d0c5e357-20240607"; |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "19.0.0-rc-20b6f4c0e8-20240607", | ||
"version": "19.0.0-rc-34d0c5e357-20240607", | ||
"homepage": "https://react.dev/", | ||
@@ -10,0 +10,0 @@ "bugs": "https://github.com/facebook/react/issues", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9804
378694