react-reconciler
Advanced tools
Comparing version 0.0.0-experimental-d5de45820-20210714 to 0.0.0-experimental-d6cb4e77-20240911
@@ -1,5 +0,6 @@ | ||
/** @license React vundefined | ||
/** | ||
* @license React | ||
* react-reconciler-constants.development.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -10,36 +11,10 @@ * This source code is licensed under the MIT license found in the | ||
'use strict'; | ||
if (process.env.NODE_ENV !== "production") { | ||
(function() { | ||
'use strict'; | ||
var SyncLane = | ||
/* */ | ||
1; | ||
var InputContinuousLane = | ||
/* */ | ||
4; | ||
var DefaultLane = | ||
/* */ | ||
16; | ||
var IdleLane = | ||
/* */ | ||
536870912; | ||
var DiscreteEventPriority = SyncLane; | ||
var ContinuousEventPriority = InputContinuousLane; | ||
var DefaultEventPriority = DefaultLane; | ||
var IdleEventPriority = IdleLane; | ||
var LegacyRoot = 0; | ||
var ConcurrentRoot = 1; | ||
exports.ConcurrentRoot = ConcurrentRoot; | ||
exports.ContinuousEventPriority = ContinuousEventPriority; | ||
exports.DefaultEventPriority = DefaultEventPriority; | ||
exports.DiscreteEventPriority = DiscreteEventPriority; | ||
exports.IdleEventPriority = IdleEventPriority; | ||
exports.LegacyRoot = LegacyRoot; | ||
})(); | ||
} | ||
"use strict"; | ||
"production" !== process.env.NODE_ENV && | ||
((exports.ConcurrentRoot = 1), | ||
(exports.ContinuousEventPriority = 8), | ||
(exports.DefaultEventPriority = 32), | ||
(exports.DiscreteEventPriority = 2), | ||
(exports.IdleEventPriority = 268435456), | ||
(exports.LegacyRoot = 0), | ||
(exports.NoEventPriority = 0)); |
@@ -1,5 +0,6 @@ | ||
/** @license React vundefined | ||
/** | ||
* @license React | ||
* react-reconciler-reflection.development.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -10,694 +11,189 @@ * This source code is licensed under the MIT license found in the | ||
'use strict'; | ||
if (process.env.NODE_ENV !== "production") { | ||
(function() { | ||
'use strict'; | ||
var React = require('react'); | ||
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
function error(format) { | ||
{ | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
printWarning('error', format, args); | ||
} | ||
} | ||
function printWarning(level, format, args) { | ||
// When changing this logic, you might want to also | ||
// update consoleWithStackDev.www.js as well. | ||
{ | ||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | ||
var stack = ReactDebugCurrentFrame.getStackAddendum(); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
var argsWithFormat = args.map(function (item) { | ||
return '' + 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, argsWithFormat); | ||
} | ||
} | ||
/** | ||
* `ReactInstanceMap` maintains a mapping from a public facing stateful | ||
* instance (key) and the internal representation (value). This allows public | ||
* methods to accept the user facing instance as an argument and map them back | ||
* to internal methods. | ||
* | ||
* Note that this module is currently shared and assumed to be stateless. | ||
* If this becomes an actual Map, that will break. | ||
*/ | ||
function get(key) { | ||
return key._reactInternals; | ||
} | ||
var FunctionComponent = 0; | ||
var ClassComponent = 1; | ||
var IndeterminateComponent = 2; // Before we know whether it is function or class | ||
var HostRoot = 3; // Root of a host tree. Could be nested inside another node. | ||
var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. | ||
var HostComponent = 5; | ||
var HostText = 6; | ||
var Fragment = 7; | ||
var Mode = 8; | ||
var ContextConsumer = 9; | ||
var ContextProvider = 10; | ||
var ForwardRef = 11; | ||
var Profiler = 12; | ||
var SuspenseComponent = 13; | ||
var MemoComponent = 14; | ||
var SimpleMemoComponent = 15; | ||
var LazyComponent = 16; | ||
var IncompleteClassComponent = 17; | ||
var DehydratedFragment = 18; | ||
var SuspenseListComponent = 19; | ||
var ScopeComponent = 21; | ||
var OffscreenComponent = 22; | ||
var LegacyHiddenComponent = 23; | ||
var CacheComponent = 24; | ||
// ATTENTION | ||
// When adding new symbols to this file, | ||
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' | ||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol | ||
// nor polyfill, then a plain number is used for performance. | ||
var REACT_ELEMENT_TYPE = 0xeac7; | ||
var REACT_PORTAL_TYPE = 0xeaca; | ||
var REACT_FRAGMENT_TYPE = 0xeacb; | ||
var REACT_STRICT_MODE_TYPE = 0xeacc; | ||
var REACT_PROFILER_TYPE = 0xead2; | ||
var REACT_PROVIDER_TYPE = 0xeacd; | ||
var REACT_CONTEXT_TYPE = 0xeace; | ||
var REACT_FORWARD_REF_TYPE = 0xead0; | ||
var REACT_SUSPENSE_TYPE = 0xead1; | ||
var REACT_SUSPENSE_LIST_TYPE = 0xead8; | ||
var REACT_MEMO_TYPE = 0xead3; | ||
var REACT_LAZY_TYPE = 0xead4; | ||
var REACT_SCOPE_TYPE = 0xead7; | ||
var REACT_OPAQUE_ID_TYPE = 0xeae0; | ||
var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; | ||
var REACT_OFFSCREEN_TYPE = 0xeae2; | ||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; | ||
var REACT_CACHE_TYPE = 0xeae4; | ||
if (typeof Symbol === 'function' && Symbol.for) { | ||
var symbolFor = Symbol.for; | ||
REACT_ELEMENT_TYPE = symbolFor('react.element'); | ||
REACT_PORTAL_TYPE = symbolFor('react.portal'); | ||
REACT_FRAGMENT_TYPE = symbolFor('react.fragment'); | ||
REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'); | ||
REACT_PROFILER_TYPE = symbolFor('react.profiler'); | ||
REACT_PROVIDER_TYPE = symbolFor('react.provider'); | ||
REACT_CONTEXT_TYPE = symbolFor('react.context'); | ||
REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'); | ||
REACT_SUSPENSE_TYPE = symbolFor('react.suspense'); | ||
REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'); | ||
REACT_MEMO_TYPE = symbolFor('react.memo'); | ||
REACT_LAZY_TYPE = symbolFor('react.lazy'); | ||
REACT_SCOPE_TYPE = symbolFor('react.scope'); | ||
REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); | ||
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'); | ||
REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'); | ||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); | ||
REACT_CACHE_TYPE = symbolFor('react.cache'); | ||
} | ||
function getWrappedName(outerType, innerType, wrapperName) { | ||
var displayName = outerType.displayName; | ||
if (displayName) { | ||
return displayName; | ||
} | ||
var functionName = innerType.displayName || innerType.name || ''; | ||
return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName; | ||
} // Keep in sync with react-reconciler/getComponentNameFromFiber | ||
function getContextName(type) { | ||
return type.displayName || 'Context'; | ||
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead. | ||
function getComponentNameFromType(type) { | ||
if (type == null) { | ||
// Host root, text node or just invalid type. | ||
return null; | ||
} | ||
{ | ||
if (typeof type.tag === 'number') { | ||
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.'); | ||
} | ||
} | ||
if (typeof type === 'function') { | ||
return type.displayName || type.name || null; | ||
} | ||
if (typeof type === 'string') { | ||
return type; | ||
} | ||
switch (type) { | ||
case REACT_FRAGMENT_TYPE: | ||
return 'Fragment'; | ||
case REACT_PORTAL_TYPE: | ||
return 'Portal'; | ||
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_CACHE_TYPE: | ||
return 'Cache'; | ||
} | ||
if (typeof type === 'object') { | ||
switch (type.$$typeof) { | ||
case REACT_CONTEXT_TYPE: | ||
var context = type; | ||
return getContextName(context) + '.Consumer'; | ||
case REACT_PROVIDER_TYPE: | ||
var provider = type; | ||
return getContextName(provider._context) + '.Provider'; | ||
case REACT_FORWARD_REF_TYPE: | ||
return getWrappedName(type, type.render, 'ForwardRef'); | ||
case REACT_MEMO_TYPE: | ||
var outerName = type.displayName || null; | ||
if (outerName !== null) { | ||
return outerName; | ||
} | ||
return getComponentNameFromType(type.type) || 'Memo'; | ||
case REACT_LAZY_TYPE: | ||
{ | ||
var lazyComponent = type; | ||
var payload = lazyComponent._payload; | ||
var init = lazyComponent._init; | ||
try { | ||
return getComponentNameFromType(init(payload)); | ||
} catch (x) { | ||
return null; | ||
} | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
function getWrappedName$1(outerType, innerType, wrapperName) { | ||
var functionName = innerType.displayName || innerType.name || ''; | ||
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); | ||
} // Keep in sync with shared/getComponentNameFromType | ||
function getContextName$1(type) { | ||
return type.displayName || 'Context'; | ||
} | ||
function getComponentNameFromFiber(fiber) { | ||
var tag = fiber.tag, | ||
type = fiber.type; | ||
switch (tag) { | ||
case CacheComponent: | ||
return 'Cache'; | ||
case ContextConsumer: | ||
var context = type; | ||
return getContextName$1(context) + '.Consumer'; | ||
case ContextProvider: | ||
var provider = type; | ||
return getContextName$1(provider._context) + '.Provider'; | ||
case DehydratedFragment: | ||
return 'DehydratedFragment'; | ||
case ForwardRef: | ||
return getWrappedName$1(type, type.render, 'ForwardRef'); | ||
case Fragment: | ||
return 'Fragment'; | ||
case HostComponent: | ||
// Host component type is the display name (e.g. "div", "View") | ||
return type; | ||
case HostPortal: | ||
return 'Portal'; | ||
case HostRoot: | ||
return 'Root'; | ||
case HostText: | ||
return 'Text'; | ||
case LazyComponent: | ||
// Name comes from the type in this case; we don't have a tag. | ||
return getComponentNameFromType(type); | ||
case LegacyHiddenComponent: | ||
return 'LegacyHidden'; | ||
case Mode: | ||
if (type === REACT_STRICT_MODE_TYPE) { | ||
// Don't be less specific than shared/getComponentNameFromType | ||
return 'StrictMode'; | ||
"use strict"; | ||
"production" !== process.env.NODE_ENV && | ||
(function () { | ||
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 'Mode'; | ||
case OffscreenComponent: | ||
return 'Offscreen'; | ||
case Profiler: | ||
return 'Profiler'; | ||
case ScopeComponent: | ||
return 'Scope'; | ||
case SuspenseComponent: | ||
return 'Suspense'; | ||
case SuspenseListComponent: | ||
return 'SuspenseList'; | ||
// The display name for this tags come from the user-provided type: | ||
case ClassComponent: | ||
case FunctionComponent: | ||
case IncompleteClassComponent: | ||
case IndeterminateComponent: | ||
case MemoComponent: | ||
case SimpleMemoComponent: | ||
if (typeof type === 'function') { | ||
return type.displayName || type.name || null; | ||
} | ||
if (typeof type === 'string') { | ||
return type; | ||
} | ||
break; | ||
} | ||
return null; | ||
} | ||
// Don't change these two values. They're used by React Dev Tools. | ||
var NoFlags = | ||
/* */ | ||
0; | ||
var Placement = | ||
/* */ | ||
2; | ||
var Hydrating = | ||
/* */ | ||
2048; | ||
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; | ||
function getNearestMountedFiber(fiber) { | ||
var node = fiber; | ||
var nearestMounted = fiber; | ||
if (!fiber.alternate) { | ||
// If there is no alternate, this might be a new tree that isn't inserted | ||
// yet. If it is, then it will have a pending insertion effect on it. | ||
var nextNode = node; | ||
do { | ||
node = nextNode; | ||
if ((node.flags & (Placement | Hydrating)) !== NoFlags) { | ||
// This is an insertion or in-progress hydration. The nearest possible | ||
// mounted fiber is the parent but we need to continue to figure out | ||
// if that one is still mounted. | ||
nearestMounted = node.return; | ||
} | ||
nextNode = node.return; | ||
} while (nextNode); | ||
} else { | ||
while (node.return) { | ||
node = node.return; | ||
return 3 === node.tag ? nearestMounted : null; | ||
} | ||
} | ||
if (node.tag === HostRoot) { | ||
// TODO: Check if this was a nested HostRoot when used with | ||
// renderContainerIntoSubtree. | ||
return nearestMounted; | ||
} // If we didn't hit the root, that means that we're in an disconnected tree | ||
// that has been unmounted. | ||
return null; | ||
} | ||
function getSuspenseInstanceFromFiber(fiber) { | ||
if (fiber.tag === SuspenseComponent) { | ||
var suspenseState = fiber.memoizedState; | ||
if (suspenseState === null) { | ||
var current = fiber.alternate; | ||
if (current !== null) { | ||
suspenseState = current.memoizedState; | ||
} | ||
function assertIsMounted(fiber) { | ||
if (getNearestMountedFiber(fiber) !== fiber) | ||
throw Error("Unable to find node on an unmounted component."); | ||
} | ||
if (suspenseState !== null) { | ||
return suspenseState.dehydrated; | ||
} | ||
} | ||
return null; | ||
} | ||
function getContainerFromFiber(fiber) { | ||
return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null; | ||
} | ||
function isFiberMounted(fiber) { | ||
return getNearestMountedFiber(fiber) === fiber; | ||
} | ||
function isMounted(component) { | ||
{ | ||
var owner = ReactCurrentOwner.current; | ||
if (owner !== null && owner.tag === ClassComponent) { | ||
var ownerFiber = owner; | ||
var instance = ownerFiber.stateNode; | ||
if (!instance._warnedAboutRefsInRender) { | ||
error('%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentNameFromFiber(ownerFiber) || 'A 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; | ||
} | ||
instance._warnedAboutRefsInRender = true; | ||
} | ||
} | ||
var fiber = get(component); | ||
if (!fiber) { | ||
return false; | ||
} | ||
return getNearestMountedFiber(fiber) === fiber; | ||
} | ||
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) { | ||
// If there is no alternate, then we only need to check if it is mounted. | ||
var nearestMounted = getNearestMountedFiber(fiber); | ||
if (!(nearestMounted !== null)) { | ||
{ | ||
throw Error( "Unable to find node on an unmounted component." ); | ||
} | ||
} | ||
if (nearestMounted !== fiber) { | ||
return null; | ||
} | ||
return fiber; | ||
} // If we have two possible branches, we'll walk backwards up to the root | ||
// to see what path the root points to. On the way we may hit one of the | ||
// special cases and we'll deal with them. | ||
var a = fiber; | ||
var b = alternate; | ||
while (true) { | ||
var parentA = a.return; | ||
if (parentA === null) { | ||
// We're at the root. | ||
break; | ||
} | ||
var parentB = parentA.alternate; | ||
if (parentB === null) { | ||
// There is no alternate. This is an unusual case. Currently, it only | ||
// happens when a Suspense component is hidden. An extra fragment fiber | ||
// is inserted in between the Suspense fiber and its children. Skip | ||
// over this extra fragment fiber and proceed to the next parent. | ||
var nextParent = parentA.return; | ||
if (nextParent !== null) { | ||
a = b = nextParent; | ||
continue; | ||
} // If there's no parent, we're at the root. | ||
break; | ||
} // If both copies of the parent fiber point to the same child, we can | ||
// assume that the child is current. This happens when we bailout on low | ||
// priority: the bailed out fiber's child reuses the current child. | ||
if (parentA.child === parentB.child) { | ||
var child = parentA.child; | ||
while (child) { | ||
if (child === a) { | ||
// We've determined that A is the current branch. | ||
assertIsMounted(parentA); | ||
return fiber; | ||
} | ||
if (child === b) { | ||
// We've determined that B is the current branch. | ||
assertIsMounted(parentA); | ||
return alternate; | ||
} | ||
child = child.sibling; | ||
} // We should never have an alternate for any mounting node. So the only | ||
// way this could possibly happen is if this was unmounted, if at all. | ||
{ | ||
{ | ||
throw Error( "Unable to find node on an unmounted component." ); | ||
} | ||
} | ||
} | ||
if (a.return !== b.return) { | ||
// The return pointer of A and the return pointer of B point to different | ||
// fibers. We assume that return pointers never criss-cross, so A must | ||
// belong to the child set of A.return, and B must belong to the child | ||
// set of B.return. | ||
a = parentA; | ||
b = parentB; | ||
} else { | ||
// The return pointers point to the same fiber. We'll have to use the | ||
// default, slow path: scan the child sets of each parent alternate to see | ||
// which child belongs to which set. | ||
// | ||
// Search parent A's child set | ||
var didFindChild = false; | ||
var _child = parentA.child; | ||
while (_child) { | ||
if (_child === a) { | ||
didFindChild = true; | ||
a = parentA; | ||
b = parentB; | ||
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 (_child === b) { | ||
didFindChild = true; | ||
b = parentA; | ||
a = parentB; | ||
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."); | ||
} | ||
_child = _child.sibling; | ||
} | ||
if (!didFindChild) { | ||
// Search parent B's child set | ||
_child = parentB.child; | ||
while (_child) { | ||
if (_child === a) { | ||
didFindChild = true; | ||
a = parentB; | ||
b = parentA; | ||
break; | ||
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 (_child === b) { | ||
didFindChild = true; | ||
b = parentB; | ||
a = parentA; | ||
break; | ||
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." | ||
); | ||
} | ||
_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; | ||
} | ||
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." ); | ||
function findCurrentHostFiberImpl(node) { | ||
var tag = node.tag; | ||
if (5 === tag || 26 === tag || 27 === tag || 6 === tag) return node; | ||
for (node = node.child; null !== node; ) { | ||
tag = findCurrentHostFiberImpl(node); | ||
if (null !== tag) return tag; | ||
node = node.sibling; | ||
} | ||
return null; | ||
} | ||
} // If the root is not a host container, we're in a disconnected tree. I.e. | ||
// unmounted. | ||
if (!(a.tag === HostRoot)) { | ||
{ | ||
throw Error( "Unable to find node on an unmounted component." ); | ||
function findCurrentHostFiberWithNoPortalsImpl(node) { | ||
var tag = node.tag; | ||
if (5 === tag || 26 === tag || 27 === tag || 6 === tag) return node; | ||
for (node = node.child; null !== node; ) { | ||
if ( | ||
4 !== node.tag && | ||
((tag = findCurrentHostFiberWithNoPortalsImpl(node)), null !== tag) | ||
) | ||
return tag; | ||
node = node.sibling; | ||
} | ||
return null; | ||
} | ||
} | ||
Symbol.for("react.portal"); | ||
Symbol.for("react.fragment"); | ||
Symbol.for("react.strict_mode"); | ||
Symbol.for("react.profiler"); | ||
Symbol.for("react.provider"); | ||
Symbol.for("react.consumer"); | ||
Symbol.for("react.context"); | ||
Symbol.for("react.forward_ref"); | ||
Symbol.for("react.suspense"); | ||
Symbol.for("react.suspense_list"); | ||
Symbol.for("react.memo"); | ||
Symbol.for("react.lazy"); | ||
Symbol.for("react.client.reference"); | ||
new ("function" === typeof WeakMap ? WeakMap : Map)(); | ||
exports.doesFiberContain = function (parentFiber, childFiber) { | ||
for ( | ||
var parentFiberAlternate = parentFiber.alternate; | ||
null !== childFiber; | ||
if (a.stateNode.current === a) { | ||
// We've determined that A is the current branch. | ||
return fiber; | ||
} // Otherwise B has to be current branch. | ||
return alternate; | ||
} | ||
function findCurrentHostFiber(parent) { | ||
var currentParent = findCurrentFiberUsingSlowPath(parent); | ||
return currentParent !== null ? findCurrentHostFiberImpl(currentParent) : null; | ||
} | ||
function findCurrentHostFiberImpl(node) { | ||
// Next we'll drill down this component to find the first HostComponent/Text. | ||
if (node.tag === HostComponent || node.tag === HostText) { | ||
return node; | ||
} | ||
var child = node.child; | ||
while (child !== null) { | ||
var match = findCurrentHostFiberImpl(child); | ||
if (match !== null) { | ||
return match; | ||
} | ||
child = child.sibling; | ||
} | ||
return null; | ||
} | ||
function findCurrentHostFiberWithNoPortals(parent) { | ||
var currentParent = findCurrentFiberUsingSlowPath(parent); | ||
return currentParent !== null ? findCurrentHostFiberWithNoPortalsImpl(currentParent) : null; | ||
} | ||
function findCurrentHostFiberWithNoPortalsImpl(node) { | ||
// Next we'll drill down this component to find the first HostComponent/Text. | ||
if (node.tag === HostComponent || node.tag === HostText) { | ||
return node; | ||
} | ||
var child = node.child; | ||
while (child !== null) { | ||
if (child.tag !== HostPortal) { | ||
var match = findCurrentHostFiberWithNoPortalsImpl(child); | ||
if (match !== null) { | ||
return match; | ||
) { | ||
if (childFiber === parentFiber || childFiber === parentFiberAlternate) | ||
return !0; | ||
childFiber = childFiber.return; | ||
} | ||
} | ||
child = child.sibling; | ||
} | ||
return null; | ||
} | ||
function isFiberSuspenseAndTimedOut(fiber) { | ||
var memoizedState = fiber.memoizedState; | ||
return fiber.tag === SuspenseComponent && memoizedState !== null && memoizedState.dehydrated === null; | ||
} | ||
function doesFiberContain(parentFiber, childFiber) { | ||
var node = childFiber; | ||
var parentFiberAlternate = parentFiber.alternate; | ||
while (node !== null) { | ||
if (node === parentFiber || node === parentFiberAlternate) { | ||
return true; | ||
} | ||
node = node.return; | ||
} | ||
return false; | ||
} | ||
exports.doesFiberContain = doesFiberContain; | ||
exports.findCurrentFiberUsingSlowPath = findCurrentFiberUsingSlowPath; | ||
exports.findCurrentHostFiber = findCurrentHostFiber; | ||
exports.findCurrentHostFiberWithNoPortals = findCurrentHostFiberWithNoPortals; | ||
exports.getContainerFromFiber = getContainerFromFiber; | ||
exports.getNearestMountedFiber = getNearestMountedFiber; | ||
exports.getSuspenseInstanceFromFiber = getSuspenseInstanceFromFiber; | ||
exports.isFiberMounted = isFiberMounted; | ||
exports.isFiberSuspenseAndTimedOut = isFiberSuspenseAndTimedOut; | ||
exports.isMounted = isMounted; | ||
return !1; | ||
}; | ||
exports.findCurrentFiberUsingSlowPath = findCurrentFiberUsingSlowPath; | ||
exports.findCurrentHostFiber = function (parent) { | ||
parent = findCurrentFiberUsingSlowPath(parent); | ||
return null !== parent ? findCurrentHostFiberImpl(parent) : null; | ||
}; | ||
exports.findCurrentHostFiberWithNoPortals = function (parent) { | ||
parent = findCurrentFiberUsingSlowPath(parent); | ||
return null !== parent | ||
? findCurrentHostFiberWithNoPortalsImpl(parent) | ||
: null; | ||
}; | ||
exports.getContainerFromFiber = function (fiber) { | ||
return 3 === fiber.tag ? fiber.stateNode.containerInfo : null; | ||
}; | ||
exports.getNearestMountedFiber = getNearestMountedFiber; | ||
exports.getSuspenseInstanceFromFiber = function (fiber) { | ||
if (13 === fiber.tag) { | ||
var suspenseState = fiber.memoizedState; | ||
null === suspenseState && | ||
((fiber = fiber.alternate), | ||
null !== fiber && (suspenseState = fiber.memoizedState)); | ||
if (null !== suspenseState) return suspenseState.dehydrated; | ||
} | ||
return null; | ||
}; | ||
exports.isFiberMounted = function (fiber) { | ||
return getNearestMountedFiber(fiber) === fiber; | ||
}; | ||
exports.isFiberSuspenseAndTimedOut = function (fiber) { | ||
var memoizedState = fiber.memoizedState; | ||
return ( | ||
13 === fiber.tag && | ||
null !== memoizedState && | ||
null === memoizedState.dehydrated | ||
); | ||
}; | ||
exports.isMounted = function (component) { | ||
return (component = component._reactInternals) | ||
? getNearestMountedFiber(component) === component | ||
: !1; | ||
}; | ||
})(); | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-reconciler-constants.production.min.js'); | ||
module.exports = require('./cjs/react-reconciler-constants.production.js'); | ||
} else { | ||
module.exports = require('./cjs/react-reconciler-constants.development.js'); | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-reconciler.production.min.js'); | ||
module.exports = require('./cjs/react-reconciler.production.js'); | ||
} else { | ||
module.exports = require('./cjs/react-reconciler.development.js'); | ||
} |
{ | ||
"name": "react-reconciler", | ||
"description": "React package for creating custom renderers.", | ||
"version": "0.0.0-experimental-d5de45820-20210714", | ||
"version": "0.0.0-experimental-d6cb4e77-20240911", | ||
"keywords": [ | ||
"react" | ||
], | ||
"homepage": "https://reactjs.org/", | ||
"homepage": "https://react.dev/", | ||
"bugs": "https://github.com/facebook/react/issues", | ||
@@ -14,3 +14,2 @@ "license": "MIT", | ||
"README.md", | ||
"build-info.json", | ||
"constants.js", | ||
@@ -31,14 +30,7 @@ "index.js", | ||
"peerDependencies": { | ||
"react": "0.0.0-experimental-d5de45820-20210714" | ||
"react": "0.0.0-experimental-d6cb4e77-20240911" | ||
}, | ||
"dependencies": { | ||
"loose-envify": "^1.1.0", | ||
"object-assign": "^4.1.1", | ||
"scheduler": "0.0.0-experimental-d5de45820-20210714" | ||
}, | ||
"browserify": { | ||
"transform": [ | ||
"loose-envify" | ||
] | ||
"scheduler": "0.0.0-experimental-d6cb4e77-20240911" | ||
} | ||
} |
@@ -54,3 +54,3 @@ # react-reconciler | ||
The full list of supported methods [can be found here](https://github.com/facebook/react/blob/main/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js). For their signatures, we recommend looking at specific examples below. | ||
The full list of supported methods [can be found here](https://github.com/facebook/react/blob/main/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js). For their signatures, we recommend looking at specific examples below. | ||
@@ -61,5 +61,5 @@ The React repository includes several renderers. Each of them has its own host config. | ||
* [React ART](https://github.com/facebook/react/blob/main/packages/react-art/src/ReactART.js) and its [host config](https://github.com/facebook/react/blob/main/packages/react-art/src/ReactARTHostConfig.js) | ||
* [React DOM](https://github.com/facebook/react/blob/main/packages/react-dom/src/client/ReactDOM.js) and its [host config](https://github.com/facebook/react/blob/main/packages/react-dom/src/client/ReactDOMHostConfig.js) | ||
* [React Native](https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactNativeRenderer.js) and its [host config](https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactNativeHostConfig.js) | ||
* [React ART](https://github.com/facebook/react/blob/main/packages/react-art/src/ReactART.js) and its [host config](https://github.com/facebook/react/blob/main/packages/react-art/src/ReactFiberConfigART.js) | ||
* [React DOM](https://github.com/facebook/react/blob/main/packages/react-dom/src/client/ReactDOM.js) and its [host config](https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js) | ||
* [React Native](https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactNativeRenderer.js) and its [host config](https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactFiberConfigNative.js) | ||
@@ -86,3 +86,3 @@ If these links break please file an issue and we’ll fix them. They intentionally link to the latest versions since the API is still evolving. If you have more questions please file an issue and we’ll try to help! | ||
If your target platform has immutable trees, you'll want the **persistent mode** instead. In that mode, existing nodes are never mutated, and instead every change clones the parent tree and then replaces the whole parent tree at the root. This is the node used by the new React Native renderer, codenamed "Fabric". | ||
If your target platform has immutable trees, you'll want the **persistent mode** instead. In that mode, existing nodes are never mutated, and instead every change clones the parent tree and then replaces the whole parent tree at the root. This is the mode used by the new React Native renderer, codenamed "Fabric". | ||
@@ -135,10 +135,2 @@ ```js | ||
#### `prepareUpdate(instance, type, oldProps, newProps, rootContainer, hostContext)` | ||
React calls this method so that you can compare the previous and the next props, and decide whether you need to update the underlying instance or not. If you don't need to update it, return `null`. If you need to update it, you can return an arbitrary object representing the changes that need to happen. Then in `commitUpdate` you would need to apply those changes to the instance. | ||
This method happens **in the render phase**. It should only *calculate* the update — but not apply it! For example, the DOM renderer returns an array that looks like `[prop1, value1, prop2, value2, ...]` for all props that have actually changed. And only in `commitUpdate` it applies those changes. You should calculate as much as you can in `prepareUpdate` so that `commitUpdate` can be very fast and straightforward. | ||
See the meaning of `rootContainer` and `hostContext` in the `createInstance` documentation. | ||
#### `shouldSetTextContent(type, props)` | ||
@@ -194,6 +186,2 @@ | ||
#### `now()` | ||
You can proxy this to `performance.now()` or its equivalent in your environment. | ||
#### `scheduleTimeout(fn, delay)` | ||
@@ -211,3 +199,3 @@ | ||
#### `supportsMicrotask` | ||
#### `supportsMicrotasks` | ||
@@ -253,3 +241,3 @@ Set this to true to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part of our discrete event implementation in React DOM. If you're not sure if your renderer should support this, you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control over user events, like React Native, can choose to use a different mechanism. | ||
You can consult the `getCurrentEventPriority()` implementation in `ReactDOMHostConfig.js` for a reference implementation. | ||
You can consult the `getCurrentEventPriority()` implementation in `ReactFiberConfigDOM.js` for a reference implementation. | ||
@@ -314,5 +302,5 @@ ### Mutation Methods | ||
#### `commitUpdate(instance, updatePayload, type, prevProps, nextProps, internalHandle)` | ||
#### `commitUpdate(instance, type, prevProps, nextProps, internalHandle)` | ||
This method should mutate the `instance` according to the set of changes in `updatePayload`. Here, `updatePayload` is the object that you've returned from `prepareUpdate` and has an arbitrary structure that makes sense for your renderer. For example, the DOM renderer returns an update payload like `[prop1, value1, prop2, value2, ...]` from `prepareUpdate`, and that structure gets passed into `commitUpdate`. Ideally, all the diffing and calculation should happen inside `prepareUpdate` so that `commitUpdate` can be fast and straightforward. | ||
This method should mutate the `instance` to match `nextProps`. | ||
@@ -341,5 +329,29 @@ The `internalHandle` data structure is meant to be opaque. If you bend the rules and rely on its internal fields, be aware that it may change significantly between versions. You're taking on additional maintenance risk by reading from it, and giving up all guarantees if you write something to it. | ||
#### `maySuspendCommit(type, props)` | ||
This method is called during render to determine if the Host Component type and props require some kind of loading process to complete before committing an update. | ||
#### `preloadInstance(type, props)` | ||
This method may be called during render if the Host Component type and props might suspend a commit. It can be used to initiate any work that might shorten the duration of a suspended commit. | ||
#### `startSuspendingCommit()` | ||
This method is called just before the commit phase. Use it to set up any necessary state while any Host Components that might suspend this commit are evaluated to determine if the commit must be suspended. | ||
#### `suspendInstance(type, props)` | ||
This method is called after `startSuspendingCommit` for each Host Component that indicated it might suspend a commit. | ||
#### `waitForCommitToBeReady()` | ||
This method is called after all `suspendInstance` calls are complete. | ||
Return `null` if the commit can happen immediately. | ||
Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this callback will initiate the commit when called. The return value is a cancellation function that the Reconciler can use to abort the commit. | ||
### Persistence Methods | ||
If you use the persistent mode instead of the mutation mode, you would still need the "Core Methods". However, instead of the Mutation Methods above you will implement a different set of methods that performs cloning nodes and replacing them at the root level. You can find a list of them in the "Persistence" section [listed in this file](https://github.com/facebook/react/blob/main/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js). File an issue if you need help. | ||
If you use the persistent mode instead of the mutation mode, you would still need the "Core Methods". However, instead of the Mutation Methods above you will implement a different set of methods that performs cloning nodes and replacing them at the root level. You can find a list of them in the "Persistence" section [listed in this file](https://github.com/facebook/react/blob/main/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js). File an issue if you need help. | ||
@@ -350,2 +362,2 @@ ### Hydration Methods | ||
To support hydration, you need to declare `supportsHydration: true` and then implement the methods in the "Hydration" section [listed in this file](https://github.com/facebook/react/blob/main/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js). File an issue if you need help. | ||
To support hydration, you need to declare `supportsHydration: true` and then implement the methods in the "Hydration" section [listed in this file](https://github.com/facebook/react/blob/main/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js). File an issue if you need help. |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/react-reconciler-reflection.production.min.js'); | ||
module.exports = require('./cjs/react-reconciler-reflection.production.js'); | ||
} else { | ||
module.exports = require('./cjs/react-reconciler-reflection.development.js'); | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances 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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1496933
2
40255
354
4
+ Addedreact@0.0.0-experimental-d6cb4e77-20240911(transitive)
+ Addedscheduler@0.0.0-experimental-d6cb4e77-20240911(transitive)
- Removedloose-envify@^1.1.0
- Removedobject-assign@^4.1.1
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedreact@0.0.0-experimental-d5de45820-20210714(transitive)
- Removedscheduler@0.0.0-experimental-d5de45820-20210714(transitive)