UNPKG

rmwc

Version:

A thin React wrapper for Material Design (Web) Components

1,595 lines (1,402 loc) 297 kB
/** @license React v16.0.0 * react-test-renderer.development.js * * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; if (process.env.NODE_ENV !== "production") { (function() { 'use strict'; var _assign = require('object-assign'); var invariant = require('fbjs/lib/invariant'); var require$$0 = require('fbjs/lib/warning'); var emptyObject = require('fbjs/lib/emptyObject'); var react = require('react'); var checkPropTypes = require('prop-types/checkPropTypes'); var shallowEqual = require('fbjs/lib/shallowEqual'); /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule reactProdInvariant * */ /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule ReactFeatureFlags * */ var ReactFeatureFlags = { enableAsyncSubtreeAPI: true }; var ReactFeatureFlags_1 = ReactFeatureFlags; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule ReactTypeOfSideEffect * */ var ReactTypeOfSideEffect = { // Don't change these two values: NoEffect: 0, // 0b00000000 PerformedWork: 1, // 0b00000001 // You can change the rest (and add more). Placement: 2, // 0b00000010 Update: 4, // 0b00000100 PlacementAndUpdate: 6, // 0b00000110 Deletion: 8, // 0b00001000 ContentReset: 16, // 0b00010000 Callback: 32, // 0b00100000 Err: 64, // 0b01000000 Ref: 128 }; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule ReactPriorityLevel * */ var ReactPriorityLevel = { NoWork: 0, // No work is pending. SynchronousPriority: 1, // For controlled text inputs. Synchronous side-effects. TaskPriority: 2, // Completes at the end of the current tick. HighPriority: 3, // Interaction that needs to complete pretty soon to feel responsive. LowPriority: 4, // Data fetching, or result from updating stores. OffscreenPriority: 5 }; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule ReactTypeOfWork * */ var ReactTypeOfWork = { IndeterminateComponent: 0, // Before we know whether it is functional or class FunctionalComponent: 1, ClassComponent: 2, HostRoot: 3, // Root of a host tree. Could be nested inside another node. HostPortal: 4, // A subtree. Could be an entry point to a different renderer. HostComponent: 5, HostText: 6, CoroutineComponent: 7, CoroutineHandlerPhase: 8, YieldComponent: 9, Fragment: 10 }; var CallbackEffect = ReactTypeOfSideEffect.Callback; var NoWork = ReactPriorityLevel.NoWork; var SynchronousPriority = ReactPriorityLevel.SynchronousPriority; var TaskPriority = ReactPriorityLevel.TaskPriority; var ClassComponent$1 = ReactTypeOfWork.ClassComponent; var HostRoot$1 = ReactTypeOfWork.HostRoot; { var warning$1 = require$$0; } // Callbacks are not validated until invocation // Singly linked-list of updates. When an update is scheduled, it is added to // the queue of the current fiber and the work-in-progress fiber. The two queues // are separate but they share a persistent structure. // // During reconciliation, updates are removed from the work-in-progress fiber, // but they remain on the current fiber. That ensures that if a work-in-progress // is aborted, the aborted updates are recovered by cloning from current. // // The work-in-progress queue is always a subset of the current queue. // // When the tree is committed, the work-in-progress becomes the current. var _queue1 = void 0; var _queue2 = void 0; function comparePriority(a, b) { // When comparing update priorities, treat sync and Task work as equal. // TODO: Could we avoid the need for this by always coercing sync priority // to Task when scheduling an update? if ((a === TaskPriority || a === SynchronousPriority) && (b === TaskPriority || b === SynchronousPriority)) { return 0; } if (a === NoWork && b !== NoWork) { return -255; } if (a !== NoWork && b === NoWork) { return 255; } return a - b; } function createUpdateQueue() { var queue = { first: null, last: null, hasForceUpdate: false, callbackList: null }; { queue.isProcessing = false; } return queue; } function cloneUpdate(update) { return { priorityLevel: update.priorityLevel, partialState: update.partialState, callback: update.callback, isReplace: update.isReplace, isForced: update.isForced, isTopLevelUnmount: update.isTopLevelUnmount, next: null }; } function insertUpdateIntoQueue(queue, update, insertAfter, insertBefore) { if (insertAfter !== null) { insertAfter.next = update; } else { // This is the first item in the queue. update.next = queue.first; queue.first = update; } if (insertBefore !== null) { update.next = insertBefore; } else { // This is the last item in the queue. queue.last = update; } } // Returns the update after which the incoming update should be inserted into // the queue, or null if it should be inserted at beginning. function findInsertionPosition(queue, update) { var priorityLevel = update.priorityLevel; var insertAfter = null; var insertBefore = null; if (queue.last !== null && comparePriority(queue.last.priorityLevel, priorityLevel) <= 0) { // Fast path for the common case where the update should be inserted at // the end of the queue. insertAfter = queue.last; } else { insertBefore = queue.first; while (insertBefore !== null && comparePriority(insertBefore.priorityLevel, priorityLevel) <= 0) { insertAfter = insertBefore; insertBefore = insertBefore.next; } } return insertAfter; } function ensureUpdateQueues(fiber) { var alternateFiber = fiber.alternate; var queue1 = fiber.updateQueue; if (queue1 === null) { queue1 = fiber.updateQueue = createUpdateQueue(); } var queue2 = void 0; if (alternateFiber !== null) { queue2 = alternateFiber.updateQueue; if (queue2 === null) { queue2 = alternateFiber.updateQueue = createUpdateQueue(); } } else { queue2 = null; } _queue1 = queue1; // Return null if there is no alternate queue, or if its queue is the same. _queue2 = queue2 !== queue1 ? queue2 : null; } // The work-in-progress queue is a subset of the current queue (if it exists). // We need to insert the incoming update into both lists. However, it's possible // that the correct position in one list will be different from the position in // the other. Consider the following case: // // Current: 3-5-6 // Work-in-progress: 6 // // Then we receive an update with priority 4 and insert it into each list: // // Current: 3-4-5-6 // Work-in-progress: 4-6 // // In the current queue, the new update's `next` pointer points to the update // with priority 5. But in the work-in-progress queue, the pointer points to the // update with priority 6. Because these two queues share the same persistent // data structure, this won't do. (This can only happen when the incoming update // has higher priority than all the updates in the work-in-progress queue.) // // To solve this, in the case where the incoming update needs to be inserted // into two different positions, we'll make a clone of the update and insert // each copy into a separate queue. This forks the list while maintaining a // persistent structure, because the update that is added to the work-in-progress // is always added to the front of the list. // // However, if incoming update is inserted into the same position of both lists, // we shouldn't make a copy. // // If the update is cloned, it returns the cloned update. function insertUpdate(fiber, update) { // We'll have at least one and at most two distinct update queues. ensureUpdateQueues(fiber); var queue1 = _queue1; var queue2 = _queue2; // Warn if an update is scheduled from inside an updater function. { if (queue1.isProcessing || queue2 !== null && queue2.isProcessing) { warning$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.'); } } // Find the insertion position in the first queue. var insertAfter1 = findInsertionPosition(queue1, update); var insertBefore1 = insertAfter1 !== null ? insertAfter1.next : queue1.first; if (queue2 === null) { // If there's no alternate queue, there's nothing else to do but insert. insertUpdateIntoQueue(queue1, update, insertAfter1, insertBefore1); return null; } // If there is an alternate queue, find the insertion position. var insertAfter2 = findInsertionPosition(queue2, update); var insertBefore2 = insertAfter2 !== null ? insertAfter2.next : queue2.first; // Now we can insert into the first queue. This must come after finding both // insertion positions because it mutates the list. insertUpdateIntoQueue(queue1, update, insertAfter1, insertBefore1); // See if the insertion positions are equal. Be careful to only compare // non-null values. if (insertBefore1 === insertBefore2 && insertBefore1 !== null || insertAfter1 === insertAfter2 && insertAfter1 !== null) { // The insertion positions are the same, so when we inserted into the first // queue, it also inserted into the alternate. All we need to do is update // the alternate queue's `first` and `last` pointers, in case they // have changed. if (insertAfter2 === null) { queue2.first = update; } if (insertBefore2 === null) { queue2.last = null; } return null; } else { // The insertion positions are different, so we need to clone the update and // insert the clone into the alternate queue. var update2 = cloneUpdate(update); insertUpdateIntoQueue(queue2, update2, insertAfter2, insertBefore2); return update2; } } function addUpdate(fiber, partialState, callback, priorityLevel) { var update = { priorityLevel: priorityLevel, partialState: partialState, callback: callback, isReplace: false, isForced: false, isTopLevelUnmount: false, next: null }; insertUpdate(fiber, update); } var addUpdate_1 = addUpdate; function addReplaceUpdate(fiber, state, callback, priorityLevel) { var update = { priorityLevel: priorityLevel, partialState: state, callback: callback, isReplace: true, isForced: false, isTopLevelUnmount: false, next: null }; insertUpdate(fiber, update); } var addReplaceUpdate_1 = addReplaceUpdate; function addForceUpdate(fiber, callback, priorityLevel) { var update = { priorityLevel: priorityLevel, partialState: null, callback: callback, isReplace: false, isForced: true, isTopLevelUnmount: false, next: null }; insertUpdate(fiber, update); } var addForceUpdate_1 = addForceUpdate; function getUpdatePriority(fiber) { var updateQueue = fiber.updateQueue; if (updateQueue === null) { return NoWork; } if (fiber.tag !== ClassComponent$1 && fiber.tag !== HostRoot$1) { return NoWork; } return updateQueue.first !== null ? updateQueue.first.priorityLevel : NoWork; } var getUpdatePriority_1 = getUpdatePriority; function addTopLevelUpdate$1(fiber, partialState, callback, priorityLevel) { var isTopLevelUnmount = partialState.element === null; var update = { priorityLevel: priorityLevel, partialState: partialState, callback: callback, isReplace: false, isForced: false, isTopLevelUnmount: isTopLevelUnmount, next: null }; var update2 = insertUpdate(fiber, update); if (isTopLevelUnmount) { // TODO: Redesign the top-level mount/update/unmount API to avoid this // special case. var queue1 = _queue1; var queue2 = _queue2; // Drop all updates that are lower-priority, so that the tree is not // remounted. We need to do this for both queues. if (queue1 !== null && update.next !== null) { update.next = null; queue1.last = update; } if (queue2 !== null && update2 !== null && update2.next !== null) { update2.next = null; queue2.last = update; } } } var addTopLevelUpdate_1 = addTopLevelUpdate$1; function getStateFromUpdate(update, instance, prevState, props) { var partialState = update.partialState; if (typeof partialState === 'function') { var updateFn = partialState; return updateFn.call(instance, prevState, props); } else { return partialState; } } function beginUpdateQueue(current, workInProgress, queue, instance, prevState, props, priorityLevel) { if (current !== null && current.updateQueue === queue) { // We need to create a work-in-progress queue, by cloning the current queue. var currentQueue = queue; queue = workInProgress.updateQueue = { first: currentQueue.first, last: currentQueue.last, // These fields are no longer valid because they were already committed. // Reset them. callbackList: null, hasForceUpdate: false }; } { // Set this flag so we can warn if setState is called inside the update // function of another setState. queue.isProcessing = true; } // Calculate these using the the existing values as a base. var callbackList = queue.callbackList; var hasForceUpdate = queue.hasForceUpdate; // Applies updates with matching priority to the previous state to create // a new state object. var state = prevState; var dontMutatePrevState = true; var update = queue.first; while (update !== null && comparePriority(update.priorityLevel, priorityLevel) <= 0) { // Remove each update from the queue right before it is processed. That way // if setState is called from inside an updater function, the new update // will be inserted in the correct position. queue.first = update.next; if (queue.first === null) { queue.last = null; } var _partialState = void 0; if (update.isReplace) { state = getStateFromUpdate(update, instance, state, props); dontMutatePrevState = true; } else { _partialState = getStateFromUpdate(update, instance, state, props); if (_partialState) { if (dontMutatePrevState) { state = _assign({}, state, _partialState); } else { state = _assign(state, _partialState); } dontMutatePrevState = false; } } if (update.isForced) { hasForceUpdate = true; } // Second condition ignores top-level unmount callbacks if they are not the // last update in the queue, since a subsequent update will cause a remount. if (update.callback !== null && !(update.isTopLevelUnmount && update.next !== null)) { callbackList = callbackList !== null ? callbackList : []; callbackList.push(update.callback); workInProgress.effectTag |= CallbackEffect; } update = update.next; } queue.callbackList = callbackList; queue.hasForceUpdate = hasForceUpdate; if (queue.first === null && callbackList === null && !hasForceUpdate) { // The queue is empty and there are no callbacks. We can reset it. workInProgress.updateQueue = null; } { // No longer processing. queue.isProcessing = false; } return state; } var beginUpdateQueue_1 = beginUpdateQueue; function commitCallbacks(finishedWork, queue, context) { var callbackList = queue.callbackList; if (callbackList === null) { return; } // Set the list to null to make sure they don't get called more than once. queue.callbackList = null; for (var i = 0; i < callbackList.length; i++) { var _callback = callbackList[i]; !(typeof _callback === 'function') ? invariant(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', _callback) : void 0; _callback.call(context); } } var commitCallbacks_1 = commitCallbacks; var ReactFiberUpdateQueue = { addUpdate: addUpdate_1, addReplaceUpdate: addReplaceUpdate_1, addForceUpdate: addForceUpdate_1, getUpdatePriority: getUpdatePriority_1, addTopLevelUpdate: addTopLevelUpdate_1, beginUpdateQueue: beginUpdateQueue_1, commitCallbacks: commitCallbacks_1 }; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule getComponentName * */ function getComponentName$1(instanceOrFiber) { if (typeof instanceOrFiber.getName === 'function') { // Stack reconciler var instance = instanceOrFiber; return instance.getName(); } if (typeof instanceOrFiber.tag === 'number') { // Fiber reconciler var fiber = instanceOrFiber; var type = fiber.type; if (typeof type === 'string') { return type; } if (typeof type === 'function') { return type.displayName || type.name; } } return null; } var getComponentName_1 = getComponentName$1; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule ReactInstanceMap */ /** * `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. */ // TODO: Replace this with ES6: var ReactInstanceMap = new Map(); var ReactInstanceMap = { /** * This API should be called `delete` but we'd have to make sure to always * transform these to strings for IE support. When this transform is fully * supported we can rename it. */ remove: function (key) { key._reactInternalFiber = undefined; }, get: function (key) { return key._reactInternalFiber; }, has: function (key) { return key._reactInternalFiber !== undefined; }, set: function (key, value) { key._reactInternalFiber = value; } }; var ReactInstanceMap_1 = ReactInstanceMap; var ReactInternals = react.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; var ReactGlobalSharedState = { ReactCurrentOwner: ReactInternals.ReactCurrentOwner }; { _assign(ReactGlobalSharedState, { ReactComponentTreeHook: ReactInternals.ReactComponentTreeHook, ReactDebugCurrentFrame: ReactInternals.ReactDebugCurrentFrame }); } var ReactGlobalSharedState_1 = ReactGlobalSharedState; var ReactCurrentOwner = ReactGlobalSharedState_1.ReactCurrentOwner; { var warning$3 = require$$0; } var ClassComponent$3 = ReactTypeOfWork.ClassComponent; var HostComponent$2 = ReactTypeOfWork.HostComponent; var HostRoot$3 = ReactTypeOfWork.HostRoot; var HostPortal = ReactTypeOfWork.HostPortal; var HostText$1 = ReactTypeOfWork.HostText; var NoEffect = ReactTypeOfSideEffect.NoEffect; var Placement = ReactTypeOfSideEffect.Placement; var MOUNTING = 1; var MOUNTED = 2; var UNMOUNTED = 3; function isFiberMountedImpl(fiber) { var node = 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. if ((node.effectTag & Placement) !== NoEffect) { return MOUNTING; } while (node['return']) { node = node['return']; if ((node.effectTag & Placement) !== NoEffect) { return MOUNTING; } } } else { while (node['return']) { node = node['return']; } } if (node.tag === HostRoot$3) { // TODO: Check if this was a nested HostRoot when used with // renderContainerIntoSubtree. return MOUNTED; } // If we didn't hit the root, that means that we're in an disconnected tree // that has been unmounted. return UNMOUNTED; } var isFiberMounted$1 = function (fiber) { return isFiberMountedImpl(fiber) === MOUNTED; }; var isMounted = function (component) { { var owner = ReactCurrentOwner.current; if (owner !== null && owner.tag === ClassComponent$3) { var ownerFiber = owner; var instance = ownerFiber.stateNode; warning$3(instance._warnedAboutRefsInRender, '%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.', getComponentName_1(ownerFiber) || 'A component'); instance._warnedAboutRefsInRender = true; } } var fiber = ReactInstanceMap_1.get(component); if (!fiber) { return false; } return isFiberMountedImpl(fiber) === MOUNTED; }; function assertIsMounted(fiber) { !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; } 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 state = isFiberMountedImpl(fiber); !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; if (state === MOUNTING) { 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']; var parentB = parentA ? parentA.alternate : null; if (!parentA || !parentB) { // 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. invariant(false, '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; break; } if (_child === b) { didFindChild = true; b = parentA; a = parentB; break; } _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 (_child === b) { didFindChild = true; b = parentB; a = parentA; break; } _child = _child.sibling; } !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0; } } !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0; } // If the root is not a host container, we're in a disconnected tree. I.e. // unmounted. !(a.tag === HostRoot$3) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0; 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; } var findCurrentFiberUsingSlowPath_1 = findCurrentFiberUsingSlowPath; var findCurrentHostFiber$1 = function (parent) { var currentParent = findCurrentFiberUsingSlowPath(parent); if (!currentParent) { return null; } // Next we'll drill down this component to find the first HostComponent/Text. var node = currentParent; while (true) { if (node.tag === HostComponent$2 || node.tag === HostText$1) { return node; } else if (node.child) { node.child['return'] = node; node = node.child; continue; } if (node === currentParent) { return null; } while (!node.sibling) { if (!node['return'] || node['return'] === currentParent) { return null; } node = node['return']; } node.sibling['return'] = node['return']; node = node.sibling; } // Flow needs the return null here, but ESLint complains about it. // eslint-disable-next-line no-unreachable return null; }; var findCurrentHostFiberWithNoPortals$1 = function (parent) { var currentParent = findCurrentFiberUsingSlowPath(parent); if (!currentParent) { return null; } // Next we'll drill down this component to find the first HostComponent/Text. var node = currentParent; while (true) { if (node.tag === HostComponent$2 || node.tag === HostText$1) { return node; } else if (node.child && node.tag !== HostPortal) { node.child['return'] = node; node = node.child; continue; } if (node === currentParent) { return null; } while (!node.sibling) { if (!node['return'] || node['return'] === currentParent) { return null; } node = node['return']; } node.sibling['return'] = node['return']; node = node.sibling; } // Flow needs the return null here, but ESLint complains about it. // eslint-disable-next-line no-unreachable return null; }; var ReactFiberTreeReflection = { isFiberMounted: isFiberMounted$1, isMounted: isMounted, findCurrentFiberUsingSlowPath: findCurrentFiberUsingSlowPath_1, findCurrentHostFiber: findCurrentHostFiber$1, findCurrentHostFiberWithNoPortals: findCurrentHostFiberWithNoPortals$1 }; { var warning$4 = require$$0; } var valueStack = []; { var fiberStack = []; } var index = -1; var createCursor$1 = function (defaultValue) { return { current: defaultValue }; }; var isEmpty = function () { return index === -1; }; var pop$1 = function (cursor, fiber) { if (index < 0) { { warning$4(false, 'Unexpected pop.'); } return; } { if (fiber !== fiberStack[index]) { warning$4(false, 'Unexpected Fiber popped.'); } } cursor.current = valueStack[index]; valueStack[index] = null; { fiberStack[index] = null; } index--; }; var push$1 = function (cursor, value, fiber) { index++; valueStack[index] = cursor.current; { fiberStack[index] = fiber; } cursor.current = value; }; var reset = function () { while (index > -1) { valueStack[index] = null; { fiberStack[index] = null; } index--; } }; var ReactFiberStack = { createCursor: createCursor$1, isEmpty: isEmpty, pop: pop$1, push: push$1, reset: reset }; /** * Copyright (c) 2016-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * * @providesModule describeComponentFrame */ var describeComponentFrame = function (name, source, ownerName) { return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); }; var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent; var FunctionalComponent$1 = ReactTypeOfWork.FunctionalComponent; var ClassComponent$4 = ReactTypeOfWork.ClassComponent; var HostComponent$3 = ReactTypeOfWork.HostComponent; function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: case FunctionalComponent$1: case ClassComponent$4: case HostComponent$3: var owner = fiber._debugOwner; var source = fiber._debugSource; var name = getComponentName_1(fiber); var ownerName = null; if (owner) { ownerName = getComponentName_1(owner); } return describeComponentFrame(name, source, ownerName); default: return ''; } } // This function can only be called with a work-in-progress fiber and // only during begin or complete phase. Do not call it under any other // circumstances. function getStackAddendumByWorkInProgressFiber$1(workInProgress) { var info = ''; var node = workInProgress; do { info += describeFiber(node); // Otherwise this return pointer might point to the wrong tree: node = node['return']; } while (node); return info; } var ReactFiberComponentTreeHook = { getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$1 }; var ReactDebugCurrentFrame = ReactGlobalSharedState_1.ReactDebugCurrentFrame; { var getComponentName$3 = getComponentName_1; var _require2$1 = ReactFiberComponentTreeHook, getStackAddendumByWorkInProgressFiber = _require2$1.getStackAddendumByWorkInProgressFiber; } function getCurrentFiberOwnerName() { { var fiber = ReactDebugCurrentFiber$2.current; if (fiber === null) { return null; } if (fiber._debugOwner != null) { return getComponentName$3(fiber._debugOwner); } } return null; } function getCurrentFiberStackAddendum() { { var fiber = ReactDebugCurrentFiber$2.current; if (fiber === null) { return null; } // Safe because if current fiber exists, we are reconciling, // and it is guaranteed to be the work-in-progress version. return getStackAddendumByWorkInProgressFiber(fiber); } return null; } function resetCurrentFiber() { ReactDebugCurrentFrame.getCurrentStack = null; ReactDebugCurrentFiber$2.current = null; ReactDebugCurrentFiber$2.phase = null; } function setCurrentFiber(fiber, phase) { ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackAddendum; ReactDebugCurrentFiber$2.current = fiber; ReactDebugCurrentFiber$2.phase = phase; } var ReactDebugCurrentFiber$2 = { current: null, phase: null, resetCurrentFiber: resetCurrentFiber, setCurrentFiber: setCurrentFiber, getCurrentFiberOwnerName: getCurrentFiberOwnerName, getCurrentFiberStackAddendum: getCurrentFiberStackAddendum }; var ReactDebugCurrentFiber_1 = ReactDebugCurrentFiber$2; // Trust the developer to only use this with a true check /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @providesModule ReactDebugFiberPerf * */ var ReactDebugFiberPerf = null; { var _require$1 = ReactTypeOfWork, HostRoot$4 = _require$1.HostRoot, HostComponent$4 = _require$1.HostComponent, HostText$2 = _require$1.HostText, HostPortal$1 = _require$1.HostPortal, YieldComponent = _require$1.YieldComponent, Fragment$1 = _require$1.Fragment; var getComponentName$4 = getComponentName_1; // Prefix measurements so that it's possible to filter them. // Longer prefixes are hard to read in DevTools. var reactEmoji = '\u269B'; var warningEmoji = '\u26D4'; var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; // Keep track of current fiber so that we know the path to unwind on pause. // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? var currentFiber = null; // If we're in the middle of user code, which fiber and method is it? // Reusing `currentFiber` would be confusing for this because user code fiber // can change during commit phase too, but we don't need to unwind it (since // lifecycles in the commit phase don't resemble a tree). var currentPhase = null; var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem, // so we will keep track of it, and include it in the report. // Track commits caused by cascading updates. var isCommitting = false; var hasScheduledUpdateInCurrentCommit = false; var hasScheduledUpdateInCurrentPhase = false; var commitCountInCurrentWorkLoop = 0; var effectCountInCurrentCommit = 0; // During commits, we only show a measurement once per method name // to avoid stretch the commit phase with measurement overhead. var labelsInCurrentCommit = new Set(); var formatMarkName = function (markName) { return reactEmoji + ' ' + markName; }; var formatLabel = function (label, warning) { var prefix = warning ? warningEmoji + ' ' : reactEmoji + ' '; var suffix = warning ? ' Warning: ' + warning : ''; return '' + prefix + label + suffix; }; var beginMark = function (markName) { performance.mark(formatMarkName(markName)); }; var clearMark = function (markName) { performance.clearMarks(formatMarkName(markName)); }; var endMark = function (label, markName, warning) { var formattedMarkName = formatMarkName(markName); var formattedLabel = formatLabel(label, warning); try { performance.measure(formattedLabel, formattedMarkName); } catch (err) {} // If previous mark was missing for some reason, this will throw. // This could only happen if React crashed in an unexpected place earlier. // Don't pile on with more errors. // Clear marks immediately to avoid growing buffer. performance.clearMarks(formattedMarkName); performance.clearMeasures(formattedLabel); }; var getFiberMarkName = function (label, debugID) { return label + ' (#' + debugID + ')'; }; var getFiberLabel = function (componentName, isMounted, phase) { if (phase === null) { // These are composite component total time measurements. return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']'; } else { // Composite component methods. return componentName + '.' + phase; } }; var beginFiberMark = function (fiber, phase) { var componentName = getComponentName$4(fiber) || 'Unknown'; var debugID = fiber._debugID; var isMounted = fiber.alternate !== null; var label = getFiberLabel(componentName, isMounted, phase); if (isCommitting && labelsInCurrentCommit.has(label)) { // During the commit phase, we don't show duplicate labels because // there is a fixed overhead for every measurement, and we don't // want to stretch the commit phase beyond necessary. return false; } labelsInCurrentCommit.add(label); var markName = getFiberMarkName(label, debugID); beginMark(markName); return true; }; var clearFiberMark = function (fiber, phase) { var componentName = getComponentName$4(fiber) || 'Unknown'; var debugID = fiber._debugID; var isMounted = fiber.alternate !== null; var label = getFiberLabel(componentName, isMounted, phase); var markName = getFiberMarkName(label, debugID); clearMark(markName); }; var endFiberMark = function (fiber, phase, warning) { var componentName = getComponentName$4(fiber) || 'Unknown'; var debugID = fiber._debugID; var isMounted = fiber.alternate !== null; var label = getFiberLabel(componentName, isMounted, phase); var markName = getFiberMarkName(label, debugID); endMark(label, markName, warning); }; var shouldIgnoreFiber = function (fiber) { // Host components should be skipped in the timeline. // We could check typeof fiber.type, but does this work with RN? switch (fiber.tag) { case HostRoot$4: case HostComponent$4: case HostText$2: case HostPortal$1: case YieldComponent: case Fragment$1: return true; default: return false; } }; var clearPendingPhaseMeasurement = function () { if (currentPhase !== null && currentPhaseFiber !== null) { clearFiberMark(currentPhaseFiber, currentPhase); } currentPhaseFiber = null; currentPhase = null; hasScheduledUpdateInCurrentPhase = false; }; var pauseTimers = function () { // Stops all currently active measurements so that they can be resumed // if we continue in a later deferred loop from the same unit of work. var fiber = currentFiber; while (fiber) { if (fiber._debugIsCurrentlyTiming) { endFiberMark(fiber, null, null); } fiber = fiber['return']; } }; var resumeTimersRecursively = function (fiber) { if (fiber['return'] !== null) { resumeTimersRecursively(fiber['return']); } if (fiber._debugIsCurrentlyTiming) { beginFiberMark(fiber, null); } }; var resumeTimers = function () { // Resumes all measurements that were active during the last deferred loop. if (currentFiber !== null) { resumeTimersRecursively(currentFiber); } }; ReactDebugFiberPerf = { recordEffect: function () { effectCountInCurrentCommit++; }, recordScheduleUpdate: function () { if (isCommitting) { hasScheduledUpdateInCurrentCommit = true; } if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') { hasScheduledUpdateInCurrentPhase = true; } }, startWorkTimer: function (fiber) { if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { return; } // If we pause, this is the fiber to unwind from. currentFiber = fiber; if (!beginFiberMark(fiber, null)) { return; } fiber._debugIsCurrentlyTiming = true; }, cancelWorkTimer: function (fiber) { if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { return; } // Remember we shouldn't complete measurement for this fiber. // Otherwise flamechart will be deep even for small updates. fiber._debugIsCurrentlyTiming = false; clearFiberMark(fiber, null); }, stopWorkTimer: function (fiber) { if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { return; } // If we pause, its parent is the fiber to unwind from. currentFiber = fiber['return']; if (!fiber._debugIsCurrentlyTiming) { return; } fiber._debugIsCurrentlyTiming = false; endFiberMark(fiber, null, null); }, stopFailedWorkTimer: function (fiber) { if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { return; } // If we pause, its parent is the fiber to unwind from. currentFiber = fiber['return']; if (!fiber._debugIsCurrentlyTiming) { return; } fiber._debugIsCurrentlyTiming = false; var warning = 'An error was thrown inside this error boundary'; endFiberMark(fiber, null, warning); }, startPhaseTimer: function (fiber, phase) { if (!supportsUserTiming) { return; } clearPendingPhaseMeasurement(); if (!beginFiberMark(fiber, phase)) { return; } currentPhaseFiber = fiber; currentPhase = phase; }, stopPhaseTimer: function () { if (!supportsUserTiming) { return; } if (currentPhase !== null && currentPhaseFiber !== null) { var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null; endFiberMark(currentPhaseFiber, currentPhase, warning); } currentPhase = null; currentPhaseFiber = null; }, startWorkLoopTimer: function () { if (!supportsUserTiming) { return; } commitCountInCurrentWorkLoop = 0; // This is top level call. // Any other measurements are performed within. beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop. resumeTimers(); }, stopWorkLoopTimer: function () { if (!supportsUserTiming) { return; } var warning = commitCountInCurrentWorkLoop > 1 ? 'There were cascading updates' : null; commitCountInCurrentWorkLoop = 0; // Pause any measurements until the next loop. pauseTimers(); endMark('(React Tree Reconciliation)', '(React Tree Reconciliation)', warning); }, startCommitTimer: function () { if (!supportsUserTiming) { return; } isCommitting = true; hasScheduledUpdateInCurrentCommit = false; labelsInCurrentCommit.clear(); beginMark('(Committing Changes)'); }, stopCommitTimer: function () { if (!supportsUserTiming) { return; } var warning = null; if (hasScheduledUpdateInCurrentCommit) { warning = 'Lifecycle hook scheduled a cascading update'; } else if (commitCountInCurrentWorkLoop > 0) { warning = 'Caused by a cascading update in earlier commit'; } hasScheduledUpdateInCurrentCommit = false; commitCountInCurrentWorkLoop++; isCommitting = false; labelsInCurrentCommit.clear(); endMark('(Committing Changes)', '(Committing Changes)', warning); }, startCommitHostEffectsTimer: function () { if (!supportsUserTiming) { return; } effectCountInCurrentCommit = 0; beginMark('(Committing Host Effects)'); }, stopCommitHostEffectsTimer: function () { if (!supportsUserTiming) { return; } var count = effectCountInCurrentCommit; effectCountInCurrentCommit = 0; endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null); }, startCommitLifeCyclesTimer: function () { if (!supportsUserTiming) { return; } effectCountInCurrentCommit = 0; beginMark('(Calling Lifecycle Methods)'); }, stopCommitLifeCyclesTimer: function () { if (!supportsUserTiming) { return; } var count = effectCountInCurrentCommit; effectCountInCurrentCommit = 0; endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null); } }; } var ReactDebugFiberPerf_1 = ReactDebugFiberPerf; var isFiberMounted = ReactFiberTreeReflection.isFiberMounted; var ClassComponent$2 = ReactTypeOfWork.ClassComponent; var HostRoot$2 = ReactTypeOfWork.HostRoot; var createCursor = ReactFiberStack.createCursor; var pop = ReactFiberStack.pop; var push = ReactFiberStack.push; { var warning$2 = require$$0; var checkPropTypes$1 = checkPropTypes; var ReactDebugCurrentFiber$1 = ReactDebugCurrentFiber_1; var _require4 = ReactDebugFiberPerf_1, startPhaseTimer = _require4.startPhaseTimer, stopPhaseTimer = _require4.stopPhaseTimer; var warnedAboutMissingGetChildContext = {}; } // A cursor to the current merged context object on the stack. var contextStackCursor = createCursor(emptyObject); // A cursor to a boolean indicating whether the context has changed. var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. // We use this to get access to the parent context after we have already // pushed the next context provider, and now need to merge their contexts. var previousContext = emptyObject; function getUnmaskedContext(workInProgress) { var hasOwnContext = isContextProvider$1(workInProgress); if (hasOwnContext) { // If the fiber is a context provider itself, when we read its context // we have already pushed its own child context on the stack. A context // provider should not "see" its own child context. Therefore we read the // previous (parent) context instead for a context provider. return previousContext; } return contextStackCursor.current; } var getUnmaskedContext_1 = getUnmaskedContext; function cacheContext(workInProgress, unmaskedContext, maskedContext) { var instance = workInProgress.stateNode; instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; instance.__reactInternalMemoizedMaskedChildContext = maskedContext; } var cacheContext_1 = cacheContext; var getMaskedContext = function (workInProgress, unmaskedContext) { var type = workInProgress.type; var contextTypes = type.contextTypes; if (!contextTypes) { return emptyObject; } // Avoid recreating masked context unless unmasked context has changed. // Failing to do this will result in unnecessary calls to componentWillReceiveProps. // This may trigger infinite loops if componentWillReceiveProps calls setState. var instance = workInProgress.stateNode; if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { return instance.__reactInternalMemoizedMaskedChildContext; } var context = {}; for (var key in contextTypes) { context[key] = unmaskedContext[key]; } { var name = getComponentName_1(workInProgress) || 'Unknown'; ReactDebugCurrentFiber$1.setCurrentFiber(workInProgress, null); checkPropTypes$1(contextTypes, context, 'context', name, ReactDebugCurrentFiber$1.getCurrentFiberStackAddendum); ReactDebugCurrentFiber$1.resetCurrentFiber(); } // Cache unmasked context so we can avoid recreating masked context unless necessary. // Context is created before the class component is instantiated so check for instance. if (instance) { cacheContext(workInProgress, unmaskedContext, context); } return context; }; var hasContextChanged = function () { return didPerformWorkStackCursor.current; }; function isContextConsumer(fiber) { return fiber.tag === ClassComponent$2 && fiber.type.contextTypes != null; } var isContextConsumer_1 = isContextConsumer; function isContextProvider$1(fiber) { return fiber.tag === ClassComponent$2 && fiber.type.childContextTypes != null; } var isContextProvider_1 = isContextProvider$1; function popContextProvider(fiber) { if (!isContextProvider$1(fiber)) { return; } pop(didPerformWorkStackCursor, fiber); pop(contextStackCursor, fiber); } var popContextProvider_1 = popContextProvider; var popTopLevelContextObject = function (fiber) { pop(didPerformWorkStackCursor, fiber); pop(contextStackCursor, fiber); }; var pushTopLevelContextObject = function (fiber, context, didChange) { !(contextStackCursor.cursor == null) ? invariant(false, 'Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.') : void 0; push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); }; function processChildContext$1(fiber, parentContext, isReconciling) { var instance = fiber.stateNode; var childContextTypes = fiber.type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. // It has only been added in Fiber to match the (unintentional) behavior in Stack. if (typeof instance.getChildContext !== 'function') { { var componentName = getComponentName_1(fiber) || 'Unknown'; if (!warnedAboutMissingGetChildContext[componentName]) { warnedAboutMissingGetChildContext[componentName] = true; warning$2(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); } } return parentContext; } var childContext = void 0; { ReactDebugCurrentFiber$1.setCurrentFiber(fiber, 'getChildContext'); startPhaseTimer(fiber, 'getChildContext'); childContext = instance.getChildContext(); stopPhaseTimer(); ReactDebugCurrentFiber$1.resetCurrentFiber(); } for (var contextKey in childContext) { !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName_1(fiber) || 'Unknown', contextKey) : void 0; } { var name = getComponentName_1(fiber) || 'Unknown'; // We can only provide accurat