react 16.0.0-alpha.13 → 16.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,13 @@
1
1
  'use strict';
2
2
 
3
+
4
+ if (process.env.NODE_ENV !== "production") {
5
+ (function() {
6
+
7
+ 'use strict';
8
+
3
9
  var objectAssign$1 = require('object-assign');
4
- var warning = require('fbjs/lib/warning');
10
+ var require$$0 = require('fbjs/lib/warning');
5
11
  var emptyObject = require('fbjs/lib/emptyObject');
6
12
  var invariant = require('fbjs/lib/invariant');
7
13
  var emptyFunction = require('fbjs/lib/emptyFunction');
@@ -19,6 +25,10 @@ var checkPropTypes = require('prop-types/checkPropTypes');
19
25
  *
20
26
  */
21
27
 
28
+ {
29
+ var warning = require$$0;
30
+ }
31
+
22
32
  function warnNoop(publicInstance, callerName) {
23
33
  {
24
34
  var constructor = publicInstance.constructor;
@@ -262,112 +272,37 @@ function ReactPureComponent(props, context, updater) {
262
272
 
263
273
  function ComponentDummy() {}
264
274
  ComponentDummy.prototype = ReactComponent.prototype;
265
- ReactPureComponent.prototype = new ComponentDummy();
266
- ReactPureComponent.prototype.constructor = ReactPureComponent;
275
+ var pureComponentPrototype = ReactPureComponent.prototype = new ComponentDummy();
276
+ pureComponentPrototype.constructor = ReactPureComponent;
267
277
  // Avoid an extra prototype jump for these methods.
268
- objectAssign$1(ReactPureComponent.prototype, ReactComponent.prototype);
269
- ReactPureComponent.prototype.isPureReactComponent = true;
270
-
271
- var ReactBaseClasses = {
272
- Component: ReactComponent,
273
- PureComponent: ReactPureComponent
274
- };
275
-
276
- /**
277
- * Static poolers. Several custom versions for each potential number of
278
- * arguments. A completely generic pooler is easy to implement, but would
279
- * require accessing the `arguments` object. In each of these, `this` refers to
280
- * the Class itself, not an instance. If any others are needed, simply add them
281
- * here, or in their own files.
282
- */
283
- var oneArgumentPooler = function (copyFieldsFrom) {
284
- var Klass = this;
285
- if (Klass.instancePool.length) {
286
- var instance = Klass.instancePool.pop();
287
- Klass.call(instance, copyFieldsFrom);
288
- return instance;
289
- } else {
290
- return new Klass(copyFieldsFrom);
291
- }
292
- };
293
-
294
- var twoArgumentPooler$1 = function (a1, a2) {
295
- var Klass = this;
296
- if (Klass.instancePool.length) {
297
- var instance = Klass.instancePool.pop();
298
- Klass.call(instance, a1, a2);
299
- return instance;
300
- } else {
301
- return new Klass(a1, a2);
302
- }
303
- };
304
-
305
- var threeArgumentPooler = function (a1, a2, a3) {
306
- var Klass = this;
307
- if (Klass.instancePool.length) {
308
- var instance = Klass.instancePool.pop();
309
- Klass.call(instance, a1, a2, a3);
310
- return instance;
311
- } else {
312
- return new Klass(a1, a2, a3);
313
- }
314
- };
315
-
316
- var fourArgumentPooler$1 = function (a1, a2, a3, a4) {
317
- var Klass = this;
318
- if (Klass.instancePool.length) {
319
- var instance = Klass.instancePool.pop();
320
- Klass.call(instance, a1, a2, a3, a4);
321
- return instance;
322
- } else {
323
- return new Klass(a1, a2, a3, a4);
324
- }
325
- };
326
-
327
- var standardReleaser = function (instance) {
328
- var Klass = this;
329
- !(instance instanceof Klass) ? invariant(false, 'Trying to release an instance into a pool of a different type.') : void 0;
330
- instance.destructor();
331
- if (Klass.instancePool.length < Klass.poolSize) {
332
- Klass.instancePool.push(instance);
333
- }
334
- };
278
+ objectAssign$1(pureComponentPrototype, ReactComponent.prototype);
279
+ pureComponentPrototype.isPureReactComponent = true;
335
280
 
336
- var DEFAULT_POOL_SIZE = 10;
337
- var DEFAULT_POOLER = oneArgumentPooler;
281
+ function ReactAsyncComponent(props, context, updater) {
282
+ // Duplicated from ReactComponent.
283
+ this.props = props;
284
+ this.context = context;
285
+ this.refs = emptyObject;
286
+ // We initialize the default updater but the real one gets injected by the
287
+ // renderer.
288
+ this.updater = updater || ReactNoopUpdateQueue_1;
289
+ }
338
290
 
339
- /**
340
- * Augments `CopyConstructor` to be a poolable class, augmenting only the class
341
- * itself (statically) not adding any prototypical fields. Any CopyConstructor
342
- * you give this may have a `poolSize` property, and will look for a
343
- * prototypical `destructor` on instances.
344
- *
345
- * @param {Function} CopyConstructor Constructor that can be used to reset.
346
- * @param {Function} pooler Customizable pooler.
347
- */
348
- var addPoolingTo = function (CopyConstructor, pooler) {
349
- // Casting as any so that flow ignores the actual implementation and trusts
350
- // it to match the type we declared
351
- var NewKlass = CopyConstructor;
352
- NewKlass.instancePool = [];
353
- NewKlass.getPooled = pooler || DEFAULT_POOLER;
354
- if (!NewKlass.poolSize) {
355
- NewKlass.poolSize = DEFAULT_POOL_SIZE;
356
- }
357
- NewKlass.release = standardReleaser;
358
- return NewKlass;
291
+ var asyncComponentPrototype = ReactAsyncComponent.prototype = new ComponentDummy();
292
+ asyncComponentPrototype.constructor = ReactAsyncComponent;
293
+ // Avoid an extra prototype jump for these methods.
294
+ objectAssign$1(asyncComponentPrototype, ReactComponent.prototype);
295
+ asyncComponentPrototype.unstable_isAsyncReactComponent = true;
296
+ asyncComponentPrototype.render = function () {
297
+ return this.props.children;
359
298
  };
360
299
 
361
- var PooledClass = {
362
- addPoolingTo: addPoolingTo,
363
- oneArgumentPooler: oneArgumentPooler,
364
- twoArgumentPooler: twoArgumentPooler$1,
365
- threeArgumentPooler: threeArgumentPooler,
366
- fourArgumentPooler: fourArgumentPooler$1
300
+ var ReactBaseClasses = {
301
+ Component: ReactComponent,
302
+ PureComponent: ReactPureComponent,
303
+ AsyncComponent: ReactAsyncComponent
367
304
  };
368
305
 
369
- var PooledClass_1 = PooledClass;
370
-
371
306
  /**
372
307
  * Copyright 2013-present, Facebook, Inc.
373
308
  * All rights reserved.
@@ -398,9 +333,13 @@ var ReactCurrentOwner_1 = ReactCurrentOwner;
398
333
 
399
334
  var hasOwnProperty = Object.prototype.hasOwnProperty;
400
335
 
336
+ {
337
+ var warning$2 = require$$0;
338
+ }
339
+
401
340
  // The Symbol used to tag the ReactElement type. If there is no native Symbol
402
341
  // nor polyfill, then a plain number is used for performance.
403
- var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
342
+ var REACT_ELEMENT_TYPE$1 = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
404
343
 
405
344
  var RESERVED_PROPS = {
406
345
  key: true,
@@ -440,7 +379,7 @@ function defineKeyPropWarningGetter(props, displayName) {
440
379
  var warnAboutAccessingKey = function () {
441
380
  if (!specialPropKeyWarningShown) {
442
381
  specialPropKeyWarningShown = true;
443
- warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
382
+ warning$2(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
444
383
  }
445
384
  };
446
385
  warnAboutAccessingKey.isReactWarning = true;
@@ -454,7 +393,7 @@ function defineRefPropWarningGetter(props, displayName) {
454
393
  var warnAboutAccessingRef = function () {
455
394
  if (!specialPropRefWarningShown) {
456
395
  specialPropRefWarningShown = true;
457
- warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
396
+ warning$2(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
458
397
  }
459
398
  };
460
399
  warnAboutAccessingRef.isReactWarning = true;
@@ -487,7 +426,7 @@ function defineRefPropWarningGetter(props, displayName) {
487
426
  var ReactElement = function (type, key, ref, self, source, owner, props) {
488
427
  var element = {
489
428
  // This tag allow us to uniquely identify this as a React Element
490
- $$typeof: REACT_ELEMENT_TYPE,
429
+ $$typeof: REACT_ELEMENT_TYPE$1,
491
430
 
492
431
  // Built-in properties that belong on the element
493
432
  type: type,
@@ -602,7 +541,7 @@ ReactElement.createElement = function (type, config, children) {
602
541
  }
603
542
  {
604
543
  if (key || ref) {
605
- if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
544
+ if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE$1) {
606
545
  var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
607
546
  if (key) {
608
547
  defineKeyPropWarningGetter(props, displayName);
@@ -711,7 +650,7 @@ ReactElement.cloneElement = function (element, config, children) {
711
650
  * @final
712
651
  */
713
652
  ReactElement.isValidElement = function (object) {
714
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
653
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE$1;
715
654
  };
716
655
 
717
656
  var ReactElement_1 = ReactElement;
@@ -724,694 +663,252 @@ var ReactElement_1 = ReactElement;
724
663
  * LICENSE file in the root directory of this source tree. An additional grant
725
664
  * of patent rights can be found in the PATENTS file in the same directory.
726
665
  *
727
- * @providesModule ReactTypeOfWork
666
+ * @providesModule ReactDebugCurrentFrame
728
667
  *
729
668
  */
730
669
 
731
- var ReactTypeOfWork = {
732
- IndeterminateComponent: 0, // Before we know whether it is functional or class
733
- FunctionalComponent: 1,
734
- ClassComponent: 2,
735
- HostRoot: 3, // Root of a host tree. Could be nested inside another node.
736
- HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
737
- HostComponent: 5,
738
- HostText: 6,
739
- CoroutineComponent: 7,
740
- CoroutineHandlerPhase: 8,
741
- YieldComponent: 9,
742
- Fragment: 10
743
- };
670
+ var ReactDebugCurrentFrame = {};
671
+
672
+ {
673
+ // Component that is being worked on
674
+ ReactDebugCurrentFrame.getCurrentStack = null;
675
+
676
+ ReactDebugCurrentFrame.getStackAddendum = function () {
677
+ var impl = ReactDebugCurrentFrame.getCurrentStack;
678
+ if (impl) {
679
+ return impl();
680
+ }
681
+ return null;
682
+ };
683
+ }
684
+
685
+ var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame;
686
+
687
+ {
688
+ var warning$1 = require$$0;
689
+
690
+ var _require = ReactDebugCurrentFrame_1,
691
+ getStackAddendum = _require.getStackAddendum;
692
+ }
693
+
694
+ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
695
+ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
696
+ // The Symbol used to tag the ReactElement type. If there is no native Symbol
697
+ // nor polyfill, then a plain number is used for performance.
698
+ var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
699
+
700
+ var SEPARATOR = '.';
701
+ var SUBSEPARATOR = ':';
744
702
 
745
703
  /**
746
- * Copyright 2013-present, Facebook, Inc.
747
- * All rights reserved.
748
- *
749
- * This source code is licensed under the BSD-style license found in the
750
- * LICENSE file in the root directory of this source tree. An additional grant
751
- * of patent rights can be found in the PATENTS file in the same directory.
704
+ * Escape and wrap key so it is safe to use as a reactid
752
705
  *
753
- * @providesModule getComponentName
754
- *
706
+ * @param {string} key to be escaped.
707
+ * @return {string} the escaped key.
755
708
  */
709
+ function escape(key) {
710
+ var escapeRegex = /[=:]/g;
711
+ var escaperLookup = {
712
+ '=': '=0',
713
+ ':': '=2'
714
+ };
715
+ var escapedString = ('' + key).replace(escapeRegex, function (match) {
716
+ return escaperLookup[match];
717
+ });
756
718
 
757
- function getComponentName(instanceOrFiber) {
758
- if (typeof instanceOrFiber.getName === 'function') {
759
- // Stack reconciler
760
- var instance = instanceOrFiber;
761
- return instance.getName();
719
+ return '$' + escapedString;
720
+ }
721
+
722
+ /**
723
+ * TODO: Test that a single child and an array with one item have the same key
724
+ * pattern.
725
+ */
726
+
727
+ var didWarnAboutMaps = false;
728
+
729
+ var userProvidedKeyEscapeRegex = /\/+/g;
730
+ function escapeUserProvidedKey(text) {
731
+ return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
732
+ }
733
+
734
+ var POOL_SIZE = 10;
735
+ var traverseContextPool = [];
736
+ function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
737
+ if (traverseContextPool.length) {
738
+ var traverseContext = traverseContextPool.pop();
739
+ traverseContext.result = mapResult;
740
+ traverseContext.keyPrefix = keyPrefix;
741
+ traverseContext.func = mapFunction;
742
+ traverseContext.context = mapContext;
743
+ traverseContext.count = 0;
744
+ return traverseContext;
745
+ } else {
746
+ return {
747
+ result: mapResult,
748
+ keyPrefix: keyPrefix,
749
+ func: mapFunction,
750
+ context: mapContext,
751
+ count: 0
752
+ };
762
753
  }
763
- if (typeof instanceOrFiber.tag === 'number') {
764
- // Fiber reconciler
765
- var fiber = instanceOrFiber;
766
- var type = fiber.type;
754
+ }
767
755
 
768
- if (typeof type === 'string') {
769
- return type;
770
- }
771
- if (typeof type === 'function') {
772
- return type.displayName || type.name;
773
- }
756
+ function releaseTraverseContext(traverseContext) {
757
+ traverseContext.result = null;
758
+ traverseContext.keyPrefix = null;
759
+ traverseContext.func = null;
760
+ traverseContext.context = null;
761
+ traverseContext.count = 0;
762
+ if (traverseContextPool.length < POOL_SIZE) {
763
+ traverseContextPool.push(traverseContext);
774
764
  }
775
- return null;
776
765
  }
777
766
 
778
- var getComponentName_1 = getComponentName;
767
+ /**
768
+ * @param {?*} children Children tree container.
769
+ * @param {!string} nameSoFar Name of the key path so far.
770
+ * @param {!function} callback Callback to invoke with each child found.
771
+ * @param {?*} traverseContext Used to pass information throughout the traversal
772
+ * process.
773
+ * @return {!number} The number of children in this subtree.
774
+ */
775
+ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
776
+ var type = typeof children;
779
777
 
780
- var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent;
781
- var FunctionalComponent = ReactTypeOfWork.FunctionalComponent;
782
- var ClassComponent = ReactTypeOfWork.ClassComponent;
783
- var HostComponent = ReactTypeOfWork.HostComponent;
778
+ if (type === 'undefined' || type === 'boolean') {
779
+ // All of the above are perceived as null.
780
+ children = null;
781
+ }
784
782
 
783
+ if (children === null || type === 'string' || type === 'number' ||
784
+ // The following is inlined from ReactElement. This means we can optimize
785
+ // some checks. React Fiber also inlines this logic for similar purposes.
786
+ type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE) {
787
+ callback(traverseContext, children,
788
+ // If it's the only child, treat the name as if it was wrapped in an array
789
+ // so that it's consistent if the number of children grows.
790
+ nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
791
+ return 1;
792
+ }
785
793
 
794
+ var child;
795
+ var nextName;
796
+ var subtreeCount = 0; // Count of children found in the current subtree.
797
+ var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
786
798
 
787
- function describeComponentFrame$1(name, source, ownerName) {
788
- return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
789
- }
799
+ if (Array.isArray(children)) {
800
+ for (var i = 0; i < children.length; i++) {
801
+ child = children[i];
802
+ nextName = nextNamePrefix + getComponentKey(child, i);
803
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
804
+ }
805
+ } else {
806
+ var iteratorFn = ITERATOR_SYMBOL && children[ITERATOR_SYMBOL] || children[FAUX_ITERATOR_SYMBOL];
807
+ if (typeof iteratorFn === 'function') {
808
+ {
809
+ // Warn about using Maps as children
810
+ if (iteratorFn === children.entries) {
811
+ warning$1(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getStackAddendum());
812
+ didWarnAboutMaps = true;
813
+ }
814
+ }
790
815
 
791
- function describeFiber(fiber) {
792
- switch (fiber.tag) {
793
- case IndeterminateComponent:
794
- case FunctionalComponent:
795
- case ClassComponent:
796
- case HostComponent:
797
- var owner = fiber._debugOwner;
798
- var source = fiber._debugSource;
799
- var name = getComponentName_1(fiber);
800
- var ownerName = null;
801
- if (owner) {
802
- ownerName = getComponentName_1(owner);
816
+ var iterator = iteratorFn.call(children);
817
+ var step;
818
+ var ii = 0;
819
+ while (!(step = iterator.next()).done) {
820
+ child = step.value;
821
+ nextName = nextNamePrefix + getComponentKey(child, ii++);
822
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
823
+ }
824
+ } else if (type === 'object') {
825
+ var addendum = '';
826
+ {
827
+ addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getStackAddendum();
803
828
  }
804
- return describeComponentFrame$1(name, source, ownerName);
805
- default:
806
- return '';
829
+ var childrenString = '' + children;
830
+ invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
831
+ }
807
832
  }
833
+
834
+ return subtreeCount;
808
835
  }
809
836
 
810
- // This function can only be called with a work-in-progress fiber and
811
- // only during begin or complete phase. Do not call it under any other
812
- // circumstances.
813
- function getStackAddendumByWorkInProgressFiber$1(workInProgress) {
814
- var info = '';
815
- var node = workInProgress;
816
- do {
817
- info += describeFiber(node);
818
- // Otherwise this return pointer might point to the wrong tree:
819
- node = node['return'];
820
- } while (node);
821
- return info;
837
+ /**
838
+ * Traverses children that are typically specified as `props.children`, but
839
+ * might also be specified through attributes:
840
+ *
841
+ * - `traverseAllChildren(this.props.children, ...)`
842
+ * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
843
+ *
844
+ * The `traverseContext` is an optional argument that is passed through the
845
+ * entire traversal. It can be used to store accumulations or anything else that
846
+ * the callback might find relevant.
847
+ *
848
+ * @param {?*} children Children tree object.
849
+ * @param {!function} callback To invoke upon traversing each child.
850
+ * @param {?*} traverseContext Context for traversal.
851
+ * @return {!number} The number of children in this subtree.
852
+ */
853
+ function traverseAllChildren(children, callback, traverseContext) {
854
+ if (children == null) {
855
+ return 0;
856
+ }
857
+
858
+ return traverseAllChildrenImpl(children, '', callback, traverseContext);
822
859
  }
823
860
 
824
- var ReactFiberComponentTreeHook = {
825
- getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$1,
826
- describeComponentFrame: describeComponentFrame$1
827
- };
861
+ /**
862
+ * Generate a key string that identifies a component within a set.
863
+ *
864
+ * @param {*} component A component that could contain a manual key.
865
+ * @param {number} index Index that is used if a manual key is not provided.
866
+ * @return {string}
867
+ */
868
+ function getComponentKey(component, index) {
869
+ // Do some typechecking here since we call this blindly. We want to ensure
870
+ // that we don't block potential future ES APIs.
871
+ if (typeof component === 'object' && component !== null && component.key != null) {
872
+ // Explicit key
873
+ return escape(component.key);
874
+ }
875
+ // Implicit key determined by the index in the set
876
+ return index.toString(36);
877
+ }
828
878
 
829
- var getStackAddendumByWorkInProgressFiber = ReactFiberComponentTreeHook.getStackAddendumByWorkInProgressFiber;
830
- var describeComponentFrame = ReactFiberComponentTreeHook.describeComponentFrame;
879
+ function forEachSingleChild(bookKeeping, child, name) {
880
+ var func = bookKeeping.func,
881
+ context = bookKeeping.context;
831
882
 
883
+ func.call(context, child, bookKeeping.count++);
884
+ }
832
885
 
886
+ /**
887
+ * Iterates through children that are typically specified as `props.children`.
888
+ *
889
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.foreach
890
+ *
891
+ * The provided forEachFunc(child, index) will be called for each
892
+ * leaf child.
893
+ *
894
+ * @param {?*} children Children tree container.
895
+ * @param {function(*, int)} forEachFunc
896
+ * @param {*} forEachContext Context for forEachContext.
897
+ */
898
+ function forEachChildren(children, forEachFunc, forEachContext) {
899
+ if (children == null) {
900
+ return children;
901
+ }
902
+ var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
903
+ traverseAllChildren(children, forEachSingleChild, traverseContext);
904
+ releaseTraverseContext(traverseContext);
905
+ }
833
906
 
834
-
835
-
836
- function isNative(fn) {
837
- // Based on isNative() from Lodash
838
- var funcToString = Function.prototype.toString;
839
- var reIsNative = RegExp('^' + funcToString
840
- // Take an example native function source for comparison
841
- .call(Object.prototype.hasOwnProperty)
842
- // Strip regex characters so we can use it for regex
843
- .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
844
- // Remove hasOwnProperty from the template to make it generic
845
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
846
- try {
847
- var source = funcToString.call(fn);
848
- return reIsNative.test(source);
849
- } catch (err) {
850
- return false;
851
- }
852
- }
853
-
854
- var canUseCollections =
855
- // Array.from
856
- typeof Array.from === 'function' &&
857
- // Map
858
- typeof Map === 'function' && isNative(Map) &&
859
- // Map.prototype.keys
860
- Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) &&
861
- // Set
862
- typeof Set === 'function' && isNative(Set) &&
863
- // Set.prototype.keys
864
- Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys);
865
-
866
- var setItem;
867
- var getItem;
868
- var removeItem;
869
- var getItemIDs;
870
- var addRoot;
871
- var removeRoot;
872
- var getRootIDs;
873
-
874
- if (canUseCollections) {
875
- var itemMap = new Map();
876
- var rootIDSet = new Set();
877
-
878
- setItem = function (id, item) {
879
- itemMap.set(id, item);
880
- };
881
- getItem = function (id) {
882
- return itemMap.get(id);
883
- };
884
- removeItem = function (id) {
885
- itemMap['delete'](id);
886
- };
887
- getItemIDs = function () {
888
- return Array.from(itemMap.keys());
889
- };
890
-
891
- addRoot = function (id) {
892
- rootIDSet.add(id);
893
- };
894
- removeRoot = function (id) {
895
- rootIDSet['delete'](id);
896
- };
897
- getRootIDs = function () {
898
- return Array.from(rootIDSet.keys());
899
- };
900
- } else {
901
- var itemByKey = {};
902
- var rootByKey = {};
903
-
904
- // Use non-numeric keys to prevent V8 performance issues:
905
- // https://github.com/facebook/react/pull/7232
906
- var getKeyFromID = function (id) {
907
- return '.' + id;
908
- };
909
- var getIDFromKey = function (key) {
910
- return parseInt(key.substr(1), 10);
911
- };
912
-
913
- setItem = function (id, item) {
914
- var key = getKeyFromID(id);
915
- itemByKey[key] = item;
916
- };
917
- getItem = function (id) {
918
- var key = getKeyFromID(id);
919
- return itemByKey[key];
920
- };
921
- removeItem = function (id) {
922
- var key = getKeyFromID(id);
923
- delete itemByKey[key];
924
- };
925
- getItemIDs = function () {
926
- return Object.keys(itemByKey).map(getIDFromKey);
927
- };
928
-
929
- addRoot = function (id) {
930
- var key = getKeyFromID(id);
931
- rootByKey[key] = true;
932
- };
933
- removeRoot = function (id) {
934
- var key = getKeyFromID(id);
935
- delete rootByKey[key];
936
- };
937
- getRootIDs = function () {
938
- return Object.keys(rootByKey).map(getIDFromKey);
939
- };
940
- }
941
-
942
- var unmountedIDs = [];
943
-
944
- function purgeDeep(id) {
945
- var item = getItem(id);
946
- if (item) {
947
- var childIDs = item.childIDs;
948
-
949
- removeItem(id);
950
- childIDs.forEach(purgeDeep);
951
- }
952
- }
953
-
954
- function getDisplayName(element) {
955
- if (element == null) {
956
- return '#empty';
957
- } else if (typeof element === 'string' || typeof element === 'number') {
958
- return '#text';
959
- } else if (typeof element.type === 'string') {
960
- return element.type;
961
- } else {
962
- return element.type.displayName || element.type.name || 'Unknown';
963
- }
964
- }
965
-
966
- function describeID(id) {
967
- var name = ReactComponentTreeHook.getDisplayName(id);
968
- var element = ReactComponentTreeHook.getElement(id);
969
- var ownerID = ReactComponentTreeHook.getOwnerID(id);
970
- var ownerName = void 0;
971
-
972
- if (ownerID) {
973
- ownerName = ReactComponentTreeHook.getDisplayName(ownerID);
974
- }
975
- warning(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id);
976
- return describeComponentFrame(name || '', element && element._source, ownerName || '');
977
- }
978
-
979
- var ReactComponentTreeHook = {
980
- onSetChildren: function (id, nextChildIDs) {
981
- var item = getItem(id);
982
- invariant(item, 'Item must have been set');
983
- item.childIDs = nextChildIDs;
984
-
985
- for (var i = 0; i < nextChildIDs.length; i++) {
986
- var nextChildID = nextChildIDs[i];
987
- var nextChild = getItem(nextChildID);
988
- !nextChild ? invariant(false, 'Expected hook events to fire for the child before its parent includes it in onSetChildren().') : void 0;
989
- !(nextChild.childIDs != null || typeof nextChild.element !== 'object' || nextChild.element == null) ? invariant(false, 'Expected onSetChildren() to fire for a container child before its parent includes it in onSetChildren().') : void 0;
990
- !nextChild.isMounted ? invariant(false, 'Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().') : void 0;
991
- if (nextChild.parentID == null) {
992
- nextChild.parentID = id;
993
- // TODO: This shouldn't be necessary but mounting a new root during in
994
- // componentWillMount currently causes not-yet-mounted components to
995
- // be purged from our tree data so their parent id is missing.
996
- }
997
- !(nextChild.parentID === id) ? invariant(false, 'Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (%s has parents %s and %s).', nextChildID, nextChild.parentID, id) : void 0;
998
- }
999
- },
1000
- onBeforeMountComponent: function (id, element, parentID) {
1001
- var item = {
1002
- element: element,
1003
- parentID: parentID,
1004
- text: null,
1005
- childIDs: [],
1006
- isMounted: false,
1007
- updateCount: 0
1008
- };
1009
- setItem(id, item);
1010
- },
1011
- onBeforeUpdateComponent: function (id, element) {
1012
- var item = getItem(id);
1013
- if (!item || !item.isMounted) {
1014
- // We may end up here as a result of setState() in componentWillUnmount().
1015
- // In this case, ignore the element.
1016
- return;
1017
- }
1018
- item.element = element;
1019
- },
1020
- onMountComponent: function (id) {
1021
- var item = getItem(id);
1022
- invariant(item, 'Item must have been set');
1023
- item.isMounted = true;
1024
- var isRoot = item.parentID === 0;
1025
- if (isRoot) {
1026
- addRoot(id);
1027
- }
1028
- },
1029
- onUpdateComponent: function (id) {
1030
- var item = getItem(id);
1031
- if (!item || !item.isMounted) {
1032
- // We may end up here as a result of setState() in componentWillUnmount().
1033
- // In this case, ignore the element.
1034
- return;
1035
- }
1036
- item.updateCount++;
1037
- },
1038
- onUnmountComponent: function (id) {
1039
- var item = getItem(id);
1040
- if (item) {
1041
- // We need to check if it exists.
1042
- // `item` might not exist if it is inside an error boundary, and a sibling
1043
- // error boundary child threw while mounting. Then this instance never
1044
- // got a chance to mount, but it still gets an unmounting event during
1045
- // the error boundary cleanup.
1046
- item.isMounted = false;
1047
- var isRoot = item.parentID === 0;
1048
- if (isRoot) {
1049
- removeRoot(id);
1050
- }
1051
- }
1052
- unmountedIDs.push(id);
1053
- },
1054
- purgeUnmountedComponents: function () {
1055
- if (ReactComponentTreeHook._preventPurging) {
1056
- // Should only be used for testing.
1057
- return;
1058
- }
1059
-
1060
- for (var i = 0; i < unmountedIDs.length; i++) {
1061
- var id = unmountedIDs[i];
1062
- purgeDeep(id);
1063
- }
1064
- unmountedIDs.length = 0;
1065
- },
1066
- isMounted: function (id) {
1067
- var item = getItem(id);
1068
- return item ? item.isMounted : false;
1069
- },
1070
- getCurrentStackAddendum: function (topElement) {
1071
- var info = '';
1072
- if (topElement) {
1073
- var name = getDisplayName(topElement);
1074
- var owner = topElement._owner;
1075
- info += describeComponentFrame(name, topElement._source, owner && getComponentName_1(owner));
1076
- }
1077
-
1078
- var currentOwner = ReactCurrentOwner_1.current;
1079
- if (currentOwner) {
1080
- if (typeof currentOwner.tag === 'number') {
1081
- var workInProgress = currentOwner;
1082
- // Safe because if current owner exists, we are reconciling,
1083
- // and it is guaranteed to be the work-in-progress version.
1084
- info += getStackAddendumByWorkInProgressFiber(workInProgress);
1085
- } else if (typeof currentOwner._debugID === 'number') {
1086
- info += ReactComponentTreeHook.getStackAddendumByID(currentOwner._debugID);
1087
- }
1088
- }
1089
- return info;
1090
- },
1091
- getStackAddendumByID: function (id) {
1092
- var info = '';
1093
- while (id) {
1094
- info += describeID(id);
1095
- id = ReactComponentTreeHook.getParentID(id);
1096
- }
1097
- return info;
1098
- },
1099
- getChildIDs: function (id) {
1100
- var item = getItem(id);
1101
- return item ? item.childIDs : [];
1102
- },
1103
- getDisplayName: function (id) {
1104
- var element = ReactComponentTreeHook.getElement(id);
1105
- if (!element) {
1106
- return null;
1107
- }
1108
- return getDisplayName(element);
1109
- },
1110
- getElement: function (id) {
1111
- var item = getItem(id);
1112
- return item ? item.element : null;
1113
- },
1114
- getOwnerID: function (id) {
1115
- var element = ReactComponentTreeHook.getElement(id);
1116
- if (!element || !element._owner) {
1117
- return null;
1118
- }
1119
- return element._owner._debugID;
1120
- },
1121
- getParentID: function (id) {
1122
- var item = getItem(id);
1123
- return item ? item.parentID : null;
1124
- },
1125
- getSource: function (id) {
1126
- var item = getItem(id);
1127
- var element = item ? item.element : null;
1128
- var source = element != null ? element._source : null;
1129
- return source;
1130
- },
1131
- getText: function (id) {
1132
- var element = ReactComponentTreeHook.getElement(id);
1133
- if (typeof element === 'string') {
1134
- return element;
1135
- } else if (typeof element === 'number') {
1136
- return '' + element;
1137
- } else {
1138
- return null;
1139
- }
1140
- },
1141
- getUpdateCount: function (id) {
1142
- var item = getItem(id);
1143
- return item ? item.updateCount : 0;
1144
- },
1145
-
1146
-
1147
- getRootIDs: getRootIDs,
1148
- getRegisteredIDs: getItemIDs
1149
- };
1150
-
1151
- var ReactComponentTreeHook_1 = ReactComponentTreeHook;
1152
-
1153
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
1154
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
1155
- // The Symbol used to tag the ReactElement type. If there is no native Symbol
1156
- // nor polyfill, then a plain number is used for performance.
1157
- var REACT_ELEMENT_TYPE$1 = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
1158
-
1159
- {
1160
- var _require = ReactComponentTreeHook_1,
1161
- getCurrentStackAddendum = _require.getCurrentStackAddendum;
1162
- }
1163
-
1164
- var SEPARATOR = '.';
1165
- var SUBSEPARATOR = ':';
1166
-
1167
- /**
1168
- * Escape and wrap key so it is safe to use as a reactid
1169
- *
1170
- * @param {string} key to be escaped.
1171
- * @return {string} the escaped key.
1172
- */
1173
- function escape(key) {
1174
- var escapeRegex = /[=:]/g;
1175
- var escaperLookup = {
1176
- '=': '=0',
1177
- ':': '=2'
1178
- };
1179
- var escapedString = ('' + key).replace(escapeRegex, function (match) {
1180
- return escaperLookup[match];
1181
- });
1182
-
1183
- return '$' + escapedString;
1184
- }
1185
-
1186
- var unescapeInDev = emptyFunction;
1187
- {
1188
- /**
1189
- * Unescape and unwrap key for human-readable display
1190
- *
1191
- * @param {string} key to unescape.
1192
- * @return {string} the unescaped key.
1193
- */
1194
- unescapeInDev = function (key) {
1195
- var unescapeRegex = /(=0|=2)/g;
1196
- var unescaperLookup = {
1197
- '=0': '=',
1198
- '=2': ':'
1199
- };
1200
- var keySubstring = key[0] === '.' && key[1] === '$' ? key.substring(2) : key.substring(1);
1201
-
1202
- return ('' + keySubstring).replace(unescapeRegex, function (match) {
1203
- return unescaperLookup[match];
1204
- });
1205
- };
1206
- }
1207
-
1208
- /**
1209
- * TODO: Test that a single child and an array with one item have the same key
1210
- * pattern.
1211
- */
1212
-
1213
- var didWarnAboutMaps = false;
1214
-
1215
- /**
1216
- * Generate a key string that identifies a component within a set.
1217
- *
1218
- * @param {*} component A component that could contain a manual key.
1219
- * @param {number} index Index that is used if a manual key is not provided.
1220
- * @return {string}
1221
- */
1222
- function getComponentKey(component, index) {
1223
- // Do some typechecking here since we call this blindly. We want to ensure
1224
- // that we don't block potential future ES APIs.
1225
- if (typeof component === 'object' && component !== null && component.key != null) {
1226
- // Explicit key
1227
- return escape(component.key);
1228
- }
1229
- // Implicit key determined by the index in the set
1230
- return index.toString(36);
1231
- }
1232
-
1233
- /**
1234
- * @param {?*} children Children tree container.
1235
- * @param {!string} nameSoFar Name of the key path so far.
1236
- * @param {!function} callback Callback to invoke with each child found.
1237
- * @param {?*} traverseContext Used to pass information throughout the traversal
1238
- * process.
1239
- * @return {!number} The number of children in this subtree.
1240
- */
1241
- function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
1242
- var type = typeof children;
1243
-
1244
- if (type === 'undefined' || type === 'boolean') {
1245
- // All of the above are perceived as null.
1246
- children = null;
1247
- }
1248
-
1249
- if (children === null || type === 'string' || type === 'number' ||
1250
- // The following is inlined from ReactElement. This means we can optimize
1251
- // some checks. React Fiber also inlines this logic for similar purposes.
1252
- type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE$1) {
1253
- callback(traverseContext, children,
1254
- // If it's the only child, treat the name as if it was wrapped in an array
1255
- // so that it's consistent if the number of children grows.
1256
- nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar, unescapeInDev);
1257
- return 1;
1258
- }
1259
-
1260
- var child;
1261
- var nextName;
1262
- var subtreeCount = 0; // Count of children found in the current subtree.
1263
- var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1264
-
1265
- if (Array.isArray(children)) {
1266
- for (var i = 0; i < children.length; i++) {
1267
- child = children[i];
1268
- nextName = nextNamePrefix + getComponentKey(child, i);
1269
- subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1270
- }
1271
- } else {
1272
- var iteratorFn = ITERATOR_SYMBOL && children[ITERATOR_SYMBOL] || children[FAUX_ITERATOR_SYMBOL];
1273
- if (typeof iteratorFn === 'function') {
1274
- {
1275
- // Warn about using Maps as children
1276
- if (iteratorFn === children.entries) {
1277
- warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentStackAddendum());
1278
- didWarnAboutMaps = true;
1279
- }
1280
- }
1281
-
1282
- var iterator = iteratorFn.call(children);
1283
- var step;
1284
- var ii = 0;
1285
- while (!(step = iterator.next()).done) {
1286
- child = step.value;
1287
- nextName = nextNamePrefix + getComponentKey(child, ii++);
1288
- subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1289
- }
1290
- } else if (type === 'object') {
1291
- var addendum = '';
1292
- {
1293
- addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentStackAddendum();
1294
- }
1295
- var childrenString = '' + children;
1296
- invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
1297
- }
1298
- }
1299
-
1300
- return subtreeCount;
1301
- }
1302
-
1303
- /**
1304
- * Traverses children that are typically specified as `props.children`, but
1305
- * might also be specified through attributes:
1306
- *
1307
- * - `traverseAllChildren(this.props.children, ...)`
1308
- * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
1309
- *
1310
- * The `traverseContext` is an optional argument that is passed through the
1311
- * entire traversal. It can be used to store accumulations or anything else that
1312
- * the callback might find relevant.
1313
- *
1314
- * @param {?*} children Children tree object.
1315
- * @param {!function} callback To invoke upon traversing each child.
1316
- * @param {?*} traverseContext Context for traversal.
1317
- * @return {!number} The number of children in this subtree.
1318
- */
1319
- function traverseAllChildren(children, callback, traverseContext) {
1320
- if (children == null) {
1321
- return 0;
1322
- }
1323
-
1324
- return traverseAllChildrenImpl(children, '', callback, traverseContext);
1325
- }
1326
-
1327
- var traverseAllChildren_1 = traverseAllChildren;
1328
-
1329
- var twoArgumentPooler = PooledClass_1.twoArgumentPooler;
1330
- var fourArgumentPooler = PooledClass_1.fourArgumentPooler;
1331
-
1332
- var userProvidedKeyEscapeRegex = /\/+/g;
1333
- function escapeUserProvidedKey(text) {
1334
- return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
1335
- }
1336
-
1337
- /**
1338
- * PooledClass representing the bookkeeping associated with performing a child
1339
- * traversal. Allows avoiding binding callbacks.
1340
- *
1341
- * @constructor ForEachBookKeeping
1342
- * @param {!function} forEachFunction Function to perform traversal with.
1343
- * @param {?*} forEachContext Context to perform context with.
1344
- */
1345
- function ForEachBookKeeping(forEachFunction, forEachContext) {
1346
- this.func = forEachFunction;
1347
- this.context = forEachContext;
1348
- this.count = 0;
1349
- }
1350
- ForEachBookKeeping.prototype.destructor = function () {
1351
- this.func = null;
1352
- this.context = null;
1353
- this.count = 0;
1354
- };
1355
- PooledClass_1.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
1356
-
1357
- function forEachSingleChild(bookKeeping, child, name) {
1358
- var func = bookKeeping.func,
1359
- context = bookKeeping.context;
1360
-
1361
- func.call(context, child, bookKeeping.count++);
1362
- }
1363
-
1364
- /**
1365
- * Iterates through children that are typically specified as `props.children`.
1366
- *
1367
- * See https://facebook.github.io/react/docs/react-api.html#react.children.foreach
1368
- *
1369
- * The provided forEachFunc(child, index) will be called for each
1370
- * leaf child.
1371
- *
1372
- * @param {?*} children Children tree container.
1373
- * @param {function(*, int)} forEachFunc
1374
- * @param {*} forEachContext Context for forEachContext.
1375
- */
1376
- function forEachChildren(children, forEachFunc, forEachContext) {
1377
- if (children == null) {
1378
- return children;
1379
- }
1380
- var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
1381
- traverseAllChildren_1(children, forEachSingleChild, traverseContext);
1382
- ForEachBookKeeping.release(traverseContext);
1383
- }
1384
-
1385
- /**
1386
- * PooledClass representing the bookkeeping associated with performing a child
1387
- * mapping. Allows avoiding binding callbacks.
1388
- *
1389
- * @constructor MapBookKeeping
1390
- * @param {!*} mapResult Object containing the ordered map of results.
1391
- * @param {!function} mapFunction Function to perform mapping with.
1392
- * @param {?*} mapContext Context to perform mapping with.
1393
- */
1394
- function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
1395
- this.result = mapResult;
1396
- this.keyPrefix = keyPrefix;
1397
- this.func = mapFunction;
1398
- this.context = mapContext;
1399
- this.count = 0;
1400
- }
1401
- MapBookKeeping.prototype.destructor = function () {
1402
- this.result = null;
1403
- this.keyPrefix = null;
1404
- this.func = null;
1405
- this.context = null;
1406
- this.count = 0;
1407
- };
1408
- PooledClass_1.addPoolingTo(MapBookKeeping, fourArgumentPooler);
1409
-
1410
- function mapSingleChildIntoContext(bookKeeping, child, childKey) {
1411
- var result = bookKeeping.result,
1412
- keyPrefix = bookKeeping.keyPrefix,
1413
- func = bookKeeping.func,
1414
- context = bookKeeping.context;
907
+ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
908
+ var result = bookKeeping.result,
909
+ keyPrefix = bookKeeping.keyPrefix,
910
+ func = bookKeeping.func,
911
+ context = bookKeeping.context;
1415
912
 
1416
913
 
1417
914
  var mappedChild = func.call(context, child, bookKeeping.count++);
@@ -1433,9 +930,9 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1433
930
  if (prefix != null) {
1434
931
  escapedPrefix = escapeUserProvidedKey(prefix) + '/';
1435
932
  }
1436
- var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
1437
- traverseAllChildren_1(children, mapSingleChildIntoContext, traverseContext);
1438
- MapBookKeeping.release(traverseContext);
933
+ var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
934
+ traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
935
+ releaseTraverseContext(traverseContext);
1439
936
  }
1440
937
 
1441
938
  /**
@@ -1460,10 +957,6 @@ function mapChildren(children, func, context) {
1460
957
  return result;
1461
958
  }
1462
959
 
1463
- function forEachSingleChildDummy(traverseContext, child, name) {
1464
- return null;
1465
- }
1466
-
1467
960
  /**
1468
961
  * Count the number of children that are typically specified as
1469
962
  * `props.children`.
@@ -1474,7 +967,7 @@ function forEachSingleChildDummy(traverseContext, child, name) {
1474
967
  * @return {number} The number of children.
1475
968
  */
1476
969
  function countChildren(children, context) {
1477
- return traverseAllChildren_1(children, forEachSingleChildDummy, null);
970
+ return traverseAllChildren(children, emptyFunction.thatReturnsNull, null);
1478
971
  }
1479
972
 
1480
973
  /**
@@ -1492,7 +985,6 @@ function toArray(children) {
1492
985
  var ReactChildren = {
1493
986
  forEach: forEachChildren,
1494
987
  map: mapChildren,
1495
- mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
1496
988
  count: countChildren,
1497
989
  toArray: toArray
1498
990
  };
@@ -1510,7 +1002,7 @@ var ReactChildren_1 = ReactChildren;
1510
1002
  * @providesModule ReactVersion
1511
1003
  */
1512
1004
 
1513
- var ReactVersion = '16.0.0-alpha.13';
1005
+ var ReactVersion = '16.0.0-beta.4';
1514
1006
 
1515
1007
  /**
1516
1008
  * Returns the first child in a collection of children and verifies that there
@@ -1533,57 +1025,89 @@ function onlyChild(children) {
1533
1025
 
1534
1026
  var onlyChild_1 = onlyChild;
1535
1027
 
1536
- var ReactDebugCurrentFrame$1 = {};
1537
-
1538
- {
1539
- var _require$2 = ReactComponentTreeHook_1,
1540
- getStackAddendumByID = _require$2.getStackAddendumByID,
1541
- getCurrentStackAddendum$2 = _require$2.getCurrentStackAddendum;
1028
+ /**
1029
+ * Copyright 2016-present, Facebook, Inc.
1030
+ * All rights reserved.
1031
+ *
1032
+ * This source code is licensed under the BSD-style license found in the
1033
+ * LICENSE file in the root directory of this source tree. An additional grant
1034
+ * of patent rights can be found in the PATENTS file in the same directory.
1035
+ *
1036
+ *
1037
+ * @providesModule describeComponentFrame
1038
+ */
1542
1039
 
1543
- var _require2 = ReactFiberComponentTreeHook,
1544
- getStackAddendumByWorkInProgressFiber$2 = _require2.getStackAddendumByWorkInProgressFiber;
1040
+ var describeComponentFrame$1 = function (name, source, ownerName) {
1041
+ return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
1042
+ };
1545
1043
 
1546
- // Component that is being worked on
1044
+ /**
1045
+ * Copyright 2013-present, Facebook, Inc.
1046
+ * All rights reserved.
1047
+ *
1048
+ * This source code is licensed under the BSD-style license found in the
1049
+ * LICENSE file in the root directory of this source tree. An additional grant
1050
+ * of patent rights can be found in the PATENTS file in the same directory.
1051
+ *
1052
+ * @providesModule getComponentName
1053
+ *
1054
+ */
1547
1055
 
1056
+ function getComponentName$1(instanceOrFiber) {
1057
+ if (typeof instanceOrFiber.getName === 'function') {
1058
+ // Stack reconciler
1059
+ var instance = instanceOrFiber;
1060
+ return instance.getName();
1061
+ }
1062
+ if (typeof instanceOrFiber.tag === 'number') {
1063
+ // Fiber reconciler
1064
+ var fiber = instanceOrFiber;
1065
+ var type = fiber.type;
1548
1066
 
1549
- ReactDebugCurrentFrame$1.current = null;
1550
-
1551
- // Element that is being cloned or created
1552
- ReactDebugCurrentFrame$1.element = null;
1553
-
1554
- ReactDebugCurrentFrame$1.getStackAddendum = function () {
1555
- var stack = null;
1556
- var current = ReactDebugCurrentFrame$1.current;
1557
- var element = ReactDebugCurrentFrame$1.element;
1558
- if (current !== null) {
1559
- if (typeof current === 'number') {
1560
- // DebugID from Stack.
1561
- var debugID = current;
1562
- stack = getStackAddendumByID(debugID);
1563
- } else if (typeof current.tag === 'number') {
1564
- // This is a Fiber.
1565
- // The stack will only be correct if this is a work in progress
1566
- // version and we're calling it during reconciliation.
1567
- var workInProgress = current;
1568
- stack = getStackAddendumByWorkInProgressFiber$2(workInProgress);
1569
- }
1570
- } else if (element !== null) {
1571
- stack = getCurrentStackAddendum$2(element);
1067
+ if (typeof type === 'string') {
1068
+ return type;
1572
1069
  }
1573
- return stack;
1574
- };
1070
+ if (typeof type === 'function') {
1071
+ return type.displayName || type.name;
1072
+ }
1073
+ }
1074
+ return null;
1575
1075
  }
1576
1076
 
1577
- var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame$1;
1077
+ var getComponentName_1 = getComponentName$1;
1578
1078
 
1579
1079
  {
1580
1080
  var checkPropTypes$1 = checkPropTypes;
1581
1081
  var lowPriorityWarning$1 = lowPriorityWarning_1;
1582
- var ReactDebugCurrentFrame = ReactDebugCurrentFrame_1;
1583
- var warning$1 = warning;
1082
+ var ReactDebugCurrentFrame$1 = ReactDebugCurrentFrame_1;
1083
+ var warning$3 = require$$0;
1084
+ var describeComponentFrame = describeComponentFrame$1;
1085
+ var getComponentName = getComponentName_1;
1086
+
1087
+ var currentlyValidatingElement = null;
1088
+
1089
+ var getDisplayName = function (element) {
1090
+ if (element == null) {
1091
+ return '#empty';
1092
+ } else if (typeof element === 'string' || typeof element === 'number') {
1093
+ return '#text';
1094
+ } else if (typeof element.type === 'string') {
1095
+ return element.type;
1096
+ } else {
1097
+ return element.type.displayName || element.type.name || 'Unknown';
1098
+ }
1099
+ };
1584
1100
 
1585
- var _require$1 = ReactComponentTreeHook_1,
1586
- getCurrentStackAddendum$1 = _require$1.getCurrentStackAddendum;
1101
+ var getStackAddendum$1 = function () {
1102
+ var stack = '';
1103
+ if (currentlyValidatingElement) {
1104
+ var name = getDisplayName(currentlyValidatingElement);
1105
+ var owner = currentlyValidatingElement._owner;
1106
+ stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
1107
+ }
1108
+ stack += ReactDebugCurrentFrame$1.getStackAddendum() || '';
1109
+ return stack;
1110
+ };
1587
1111
  }
1588
1112
 
1589
1113
  var ITERATOR_SYMBOL$1 = typeof Symbol === 'function' && Symbol.iterator;
@@ -1591,7 +1115,7 @@ var FAUX_ITERATOR_SYMBOL$1 = '@@iterator'; // Before Symbol spec.
1591
1115
 
1592
1116
  function getDeclarationErrorAddendum() {
1593
1117
  if (ReactCurrentOwner_1.current) {
1594
- var name = getComponentName_1(ReactCurrentOwner_1.current);
1118
+ var name = getComponentName(ReactCurrentOwner_1.current);
1595
1119
  if (name) {
1596
1120
  return '\n\nCheck the render method of `' + name + '`.';
1597
1121
  }
@@ -1657,10 +1181,12 @@ function validateExplicitKey(element, parentType) {
1657
1181
  var childOwner = '';
1658
1182
  if (element && element._owner && element._owner !== ReactCurrentOwner_1.current) {
1659
1183
  // Give the component that originally created this child.
1660
- childOwner = ' It was passed a child from ' + getComponentName_1(element._owner) + '.';
1184
+ childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
1661
1185
  }
1662
1186
 
1663
- warning$1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getCurrentStackAddendum$1(element));
1187
+ currentlyValidatingElement = element;
1188
+ warning$3(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getStackAddendum$1());
1189
+ currentlyValidatingElement = null;
1664
1190
  }
1665
1191
 
1666
1192
  /**
@@ -1706,127 +1232,426 @@ function validateChildKeys(node, parentType) {
1706
1232
  }
1707
1233
  }
1708
1234
 
1709
- /**
1710
- * Given an element, validate that its props follow the propTypes definition,
1711
- * provided by the type.
1712
- *
1713
- * @param {ReactElement} element
1714
- */
1715
- function validatePropTypes(element) {
1716
- var componentClass = element.type;
1717
- if (typeof componentClass !== 'function') {
1718
- return;
1235
+ /**
1236
+ * Given an element, validate that its props follow the propTypes definition,
1237
+ * provided by the type.
1238
+ *
1239
+ * @param {ReactElement} element
1240
+ */
1241
+ function validatePropTypes(element) {
1242
+ var componentClass = element.type;
1243
+ if (typeof componentClass !== 'function') {
1244
+ return;
1245
+ }
1246
+ var name = componentClass.displayName || componentClass.name;
1247
+
1248
+ // ReactNative `View.propTypes` have been deprecated in favor of `ViewPropTypes`.
1249
+ // In their place a temporary getter has been added with a deprecated warning message.
1250
+ // Avoid triggering that warning during validation using the temporary workaround,
1251
+ // __propTypesSecretDontUseThesePlease.
1252
+ // TODO (bvaughn) Revert this particular change any time after April 1 ReactNative tag.
1253
+ var propTypes = typeof componentClass.__propTypesSecretDontUseThesePlease === 'object' ? componentClass.__propTypesSecretDontUseThesePlease : componentClass.propTypes;
1254
+
1255
+ if (propTypes) {
1256
+ currentlyValidatingElement = element;
1257
+ checkPropTypes$1(propTypes, element.props, 'prop', name, getStackAddendum$1);
1258
+ currentlyValidatingElement = null;
1259
+ }
1260
+ if (typeof componentClass.getDefaultProps === 'function') {
1261
+ warning$3(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1262
+ }
1263
+ }
1264
+
1265
+ var ReactElementValidator$1 = {
1266
+ createElement: function (type, props, children) {
1267
+ var validType = typeof type === 'string' || typeof type === 'function';
1268
+ // We warn in this case but don't throw. We expect the element creation to
1269
+ // succeed and there will likely be errors in render.
1270
+ if (!validType) {
1271
+ var info = '';
1272
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1273
+ info += ' You likely forgot to export your component from the file ' + "it's defined in.";
1274
+ }
1275
+
1276
+ var sourceInfo = getSourceInfoErrorAddendum(props);
1277
+ if (sourceInfo) {
1278
+ info += sourceInfo;
1279
+ } else {
1280
+ info += getDeclarationErrorAddendum();
1281
+ }
1282
+
1283
+ info += ReactDebugCurrentFrame$1.getStackAddendum() || '';
1284
+
1285
+ warning$3(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info);
1286
+ }
1287
+
1288
+ var element = ReactElement_1.createElement.apply(this, arguments);
1289
+
1290
+ // The result can be nullish if a mock or a custom function is used.
1291
+ // TODO: Drop this when these are no longer allowed as the type argument.
1292
+ if (element == null) {
1293
+ return element;
1294
+ }
1295
+
1296
+ // Skip key warning if the type isn't valid since our key validation logic
1297
+ // doesn't expect a non-string/function type and can throw confusing errors.
1298
+ // We don't want exception behavior to differ between dev and prod.
1299
+ // (Rendering will throw with a helpful message and as soon as the type is
1300
+ // fixed, the key warnings will appear.)
1301
+ if (validType) {
1302
+ for (var i = 2; i < arguments.length; i++) {
1303
+ validateChildKeys(arguments[i], type);
1304
+ }
1305
+ }
1306
+
1307
+ validatePropTypes(element);
1308
+
1309
+ return element;
1310
+ },
1311
+
1312
+ createFactory: function (type) {
1313
+ var validatedFactory = ReactElementValidator$1.createElement.bind(null, type);
1314
+ // Legacy hook TODO: Warn if this is accessed
1315
+ validatedFactory.type = type;
1316
+
1317
+ {
1318
+ Object.defineProperty(validatedFactory, 'type', {
1319
+ enumerable: false,
1320
+ get: function () {
1321
+ lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
1322
+ Object.defineProperty(this, 'type', {
1323
+ value: type
1324
+ });
1325
+ return type;
1326
+ }
1327
+ });
1328
+ }
1329
+
1330
+ return validatedFactory;
1331
+ },
1332
+
1333
+ cloneElement: function (element, props, children) {
1334
+ var newElement = ReactElement_1.cloneElement.apply(this, arguments);
1335
+ for (var i = 2; i < arguments.length; i++) {
1336
+ validateChildKeys(arguments[i], newElement.type);
1337
+ }
1338
+ validatePropTypes(newElement);
1339
+ return newElement;
1340
+ }
1341
+ };
1342
+
1343
+ var ReactElementValidator_1 = ReactElementValidator$1;
1344
+
1345
+ {
1346
+ var warning$4 = require$$0;
1347
+ }
1348
+
1349
+ function isNative(fn) {
1350
+ // Based on isNative() from Lodash
1351
+ var funcToString = Function.prototype.toString;
1352
+ var reIsNative = RegExp('^' + funcToString
1353
+ // Take an example native function source for comparison
1354
+ .call(Object.prototype.hasOwnProperty)
1355
+ // Strip regex characters so we can use it for regex
1356
+ .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
1357
+ // Remove hasOwnProperty from the template to make it generic
1358
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
1359
+ try {
1360
+ var source = funcToString.call(fn);
1361
+ return reIsNative.test(source);
1362
+ } catch (err) {
1363
+ return false;
1364
+ }
1365
+ }
1366
+
1367
+ var canUseCollections =
1368
+ // Array.from
1369
+ typeof Array.from === 'function' &&
1370
+ // Map
1371
+ typeof Map === 'function' && isNative(Map) &&
1372
+ // Map.prototype.keys
1373
+ Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) &&
1374
+ // Set
1375
+ typeof Set === 'function' && isNative(Set) &&
1376
+ // Set.prototype.keys
1377
+ Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys);
1378
+
1379
+ var setItem;
1380
+ var getItem;
1381
+ var removeItem;
1382
+ var getItemIDs;
1383
+ var addRoot;
1384
+ var removeRoot;
1385
+ var getRootIDs;
1386
+
1387
+ if (canUseCollections) {
1388
+ var itemMap = new Map();
1389
+ var rootIDSet = new Set();
1390
+
1391
+ setItem = function (id, item) {
1392
+ itemMap.set(id, item);
1393
+ };
1394
+ getItem = function (id) {
1395
+ return itemMap.get(id);
1396
+ };
1397
+ removeItem = function (id) {
1398
+ itemMap['delete'](id);
1399
+ };
1400
+ getItemIDs = function () {
1401
+ return Array.from(itemMap.keys());
1402
+ };
1403
+
1404
+ addRoot = function (id) {
1405
+ rootIDSet.add(id);
1406
+ };
1407
+ removeRoot = function (id) {
1408
+ rootIDSet['delete'](id);
1409
+ };
1410
+ getRootIDs = function () {
1411
+ return Array.from(rootIDSet.keys());
1412
+ };
1413
+ } else {
1414
+ var itemByKey = {};
1415
+ var rootByKey = {};
1416
+
1417
+ // Use non-numeric keys to prevent V8 performance issues:
1418
+ // https://github.com/facebook/react/pull/7232
1419
+ var getKeyFromID = function (id) {
1420
+ return '.' + id;
1421
+ };
1422
+ var getIDFromKey = function (key) {
1423
+ return parseInt(key.substr(1), 10);
1424
+ };
1425
+
1426
+ setItem = function (id, item) {
1427
+ var key = getKeyFromID(id);
1428
+ itemByKey[key] = item;
1429
+ };
1430
+ getItem = function (id) {
1431
+ var key = getKeyFromID(id);
1432
+ return itemByKey[key];
1433
+ };
1434
+ removeItem = function (id) {
1435
+ var key = getKeyFromID(id);
1436
+ delete itemByKey[key];
1437
+ };
1438
+ getItemIDs = function () {
1439
+ return Object.keys(itemByKey).map(getIDFromKey);
1440
+ };
1441
+
1442
+ addRoot = function (id) {
1443
+ var key = getKeyFromID(id);
1444
+ rootByKey[key] = true;
1445
+ };
1446
+ removeRoot = function (id) {
1447
+ var key = getKeyFromID(id);
1448
+ delete rootByKey[key];
1449
+ };
1450
+ getRootIDs = function () {
1451
+ return Object.keys(rootByKey).map(getIDFromKey);
1452
+ };
1453
+ }
1454
+
1455
+ var unmountedIDs = [];
1456
+
1457
+ function purgeDeep(id) {
1458
+ var item = getItem(id);
1459
+ if (item) {
1460
+ var childIDs = item.childIDs;
1461
+
1462
+ removeItem(id);
1463
+ childIDs.forEach(purgeDeep);
1464
+ }
1465
+ }
1466
+
1467
+ function getDisplayName$1(element) {
1468
+ if (element == null) {
1469
+ return '#empty';
1470
+ } else if (typeof element === 'string' || typeof element === 'number') {
1471
+ return '#text';
1472
+ } else if (typeof element.type === 'string') {
1473
+ return element.type;
1474
+ } else {
1475
+ return element.type.displayName || element.type.name || 'Unknown';
1719
1476
  }
1720
- var name = componentClass.displayName || componentClass.name;
1477
+ }
1721
1478
 
1722
- // ReactNative `View.propTypes` have been deprecated in favor of `ViewPropTypes`.
1723
- // In their place a temporary getter has been added with a deprecated warning message.
1724
- // Avoid triggering that warning during validation using the temporary workaround,
1725
- // __propTypesSecretDontUseThesePlease.
1726
- // TODO (bvaughn) Revert this particular change any time after April 1 ReactNative tag.
1727
- var propTypes = typeof componentClass.__propTypesSecretDontUseThesePlease === 'object' ? componentClass.__propTypesSecretDontUseThesePlease : componentClass.propTypes;
1479
+ function describeID(id) {
1480
+ var name = ReactComponentTreeHook.getDisplayName(id);
1481
+ var element = ReactComponentTreeHook.getElement(id);
1482
+ var ownerID = ReactComponentTreeHook.getOwnerID(id);
1483
+ var ownerName = void 0;
1728
1484
 
1729
- if (propTypes) {
1730
- checkPropTypes$1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
1731
- }
1732
- if (typeof componentClass.getDefaultProps === 'function') {
1733
- warning$1(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1485
+ if (ownerID) {
1486
+ ownerName = ReactComponentTreeHook.getDisplayName(ownerID);
1734
1487
  }
1488
+ warning$4(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id);
1489
+ return describeComponentFrame$1(name || '', element && element._source, ownerName || '');
1735
1490
  }
1736
1491
 
1737
- var ReactElementValidator$1 = {
1738
- createElement: function (type, props, children) {
1739
- var validType = typeof type === 'string' || typeof type === 'function';
1740
- // We warn in this case but don't throw. We expect the element creation to
1741
- // succeed and there will likely be errors in render.
1742
- if (!validType) {
1743
- var info = '';
1744
- if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1745
- info += ' You likely forgot to export your component from the file ' + "it's defined in.";
1746
- }
1492
+ var ReactComponentTreeHook = {
1493
+ onSetChildren: function (id, nextChildIDs) {
1494
+ var item = getItem(id);
1495
+ !item ? invariant(false, 'Item must have been set') : void 0;
1496
+ item.childIDs = nextChildIDs;
1747
1497
 
1748
- var sourceInfo = getSourceInfoErrorAddendum(props);
1749
- if (sourceInfo) {
1750
- info += sourceInfo;
1751
- } else {
1752
- info += getDeclarationErrorAddendum();
1498
+ for (var i = 0; i < nextChildIDs.length; i++) {
1499
+ var nextChildID = nextChildIDs[i];
1500
+ var nextChild = getItem(nextChildID);
1501
+ !nextChild ? invariant(false, 'Expected hook events to fire for the child before its parent includes it in onSetChildren().') : void 0;
1502
+ !(nextChild.childIDs != null || typeof nextChild.element !== 'object' || nextChild.element == null) ? invariant(false, 'Expected onSetChildren() to fire for a container child before its parent includes it in onSetChildren().') : void 0;
1503
+ !nextChild.isMounted ? invariant(false, 'Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().') : void 0;
1504
+ if (nextChild.parentID == null) {
1505
+ nextChild.parentID = id;
1506
+ // TODO: This shouldn't be necessary but mounting a new root during in
1507
+ // componentWillMount currently causes not-yet-mounted components to
1508
+ // be purged from our tree data so their parent id is missing.
1753
1509
  }
1754
-
1755
- info += getCurrentStackAddendum$1();
1756
-
1757
- warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info);
1510
+ !(nextChild.parentID === id) ? invariant(false, 'Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (%s has parents %s and %s).', nextChildID, nextChild.parentID, id) : void 0;
1758
1511
  }
1759
-
1760
- var element = ReactElement_1.createElement.apply(this, arguments);
1761
-
1762
- // The result can be nullish if a mock or a custom function is used.
1763
- // TODO: Drop this when these are no longer allowed as the type argument.
1764
- if (element == null) {
1765
- return element;
1512
+ },
1513
+ onBeforeMountComponent: function (id, element, parentID) {
1514
+ var item = {
1515
+ element: element,
1516
+ parentID: parentID,
1517
+ text: null,
1518
+ childIDs: [],
1519
+ isMounted: false,
1520
+ updateCount: 0
1521
+ };
1522
+ setItem(id, item);
1523
+ },
1524
+ onBeforeUpdateComponent: function (id, element) {
1525
+ var item = getItem(id);
1526
+ if (!item || !item.isMounted) {
1527
+ // We may end up here as a result of setState() in componentWillUnmount().
1528
+ // In this case, ignore the element.
1529
+ return;
1766
1530
  }
1767
-
1768
- {
1769
- ReactDebugCurrentFrame.element = element;
1531
+ item.element = element;
1532
+ },
1533
+ onMountComponent: function (id) {
1534
+ var item = getItem(id);
1535
+ !item ? invariant(false, 'Item must have been set') : void 0;
1536
+ item.isMounted = true;
1537
+ var isRoot = item.parentID === 0;
1538
+ if (isRoot) {
1539
+ addRoot(id);
1770
1540
  }
1771
-
1772
- // Skip key warning if the type isn't valid since our key validation logic
1773
- // doesn't expect a non-string/function type and can throw confusing errors.
1774
- // We don't want exception behavior to differ between dev and prod.
1775
- // (Rendering will throw with a helpful message and as soon as the type is
1776
- // fixed, the key warnings will appear.)
1777
- if (validType) {
1778
- for (var i = 2; i < arguments.length; i++) {
1779
- validateChildKeys(arguments[i], type);
1541
+ },
1542
+ onUpdateComponent: function (id) {
1543
+ var item = getItem(id);
1544
+ if (!item || !item.isMounted) {
1545
+ // We may end up here as a result of setState() in componentWillUnmount().
1546
+ // In this case, ignore the element.
1547
+ return;
1548
+ }
1549
+ item.updateCount++;
1550
+ },
1551
+ onUnmountComponent: function (id) {
1552
+ var item = getItem(id);
1553
+ if (item) {
1554
+ // We need to check if it exists.
1555
+ // `item` might not exist if it is inside an error boundary, and a sibling
1556
+ // error boundary child threw while mounting. Then this instance never
1557
+ // got a chance to mount, but it still gets an unmounting event during
1558
+ // the error boundary cleanup.
1559
+ item.isMounted = false;
1560
+ var isRoot = item.parentID === 0;
1561
+ if (isRoot) {
1562
+ removeRoot(id);
1780
1563
  }
1781
1564
  }
1782
-
1783
- validatePropTypes(element);
1784
-
1785
- {
1786
- ReactDebugCurrentFrame.element = null;
1565
+ unmountedIDs.push(id);
1566
+ },
1567
+ purgeUnmountedComponents: function () {
1568
+ if (ReactComponentTreeHook._preventPurging) {
1569
+ // Should only be used for testing.
1570
+ return;
1787
1571
  }
1788
1572
 
1789
- return element;
1573
+ for (var i = 0; i < unmountedIDs.length; i++) {
1574
+ var id = unmountedIDs[i];
1575
+ purgeDeep(id);
1576
+ }
1577
+ unmountedIDs.length = 0;
1790
1578
  },
1791
-
1792
- createFactory: function (type) {
1793
- var validatedFactory = ReactElementValidator$1.createElement.bind(null, type);
1794
- // Legacy hook TODO: Warn if this is accessed
1795
- validatedFactory.type = type;
1796
-
1797
- {
1798
- Object.defineProperty(validatedFactory, 'type', {
1799
- enumerable: false,
1800
- get: function () {
1801
- lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
1802
- Object.defineProperty(this, 'type', {
1803
- value: type
1804
- });
1805
- return type;
1806
- }
1807
- });
1579
+ isMounted: function (id) {
1580
+ var item = getItem(id);
1581
+ return item ? item.isMounted : false;
1582
+ },
1583
+ getCurrentStackAddendum: function () {
1584
+ var info = '';
1585
+ var currentOwner = ReactCurrentOwner_1.current;
1586
+ if (currentOwner) {
1587
+ !(typeof currentOwner.tag !== 'number') ? invariant(false, 'Fiber owners should not show up in Stack stack traces.') : void 0;
1588
+ if (typeof currentOwner._debugID === 'number') {
1589
+ info += ReactComponentTreeHook.getStackAddendumByID(currentOwner._debugID);
1590
+ }
1808
1591
  }
1809
-
1810
- return validatedFactory;
1592
+ return info;
1811
1593
  },
1812
-
1813
- cloneElement: function (element, props, children) {
1814
- var newElement = ReactElement_1.cloneElement.apply(this, arguments);
1815
- {
1816
- ReactDebugCurrentFrame.element = newElement;
1594
+ getStackAddendumByID: function (id) {
1595
+ var info = '';
1596
+ while (id) {
1597
+ info += describeID(id);
1598
+ id = ReactComponentTreeHook.getParentID(id);
1817
1599
  }
1818
- for (var i = 2; i < arguments.length; i++) {
1819
- validateChildKeys(arguments[i], newElement.type);
1600
+ return info;
1601
+ },
1602
+ getChildIDs: function (id) {
1603
+ var item = getItem(id);
1604
+ return item ? item.childIDs : [];
1605
+ },
1606
+ getDisplayName: function (id) {
1607
+ var element = ReactComponentTreeHook.getElement(id);
1608
+ if (!element) {
1609
+ return null;
1820
1610
  }
1821
- validatePropTypes(newElement);
1822
- {
1823
- ReactDebugCurrentFrame.element = null;
1611
+ return getDisplayName$1(element);
1612
+ },
1613
+ getElement: function (id) {
1614
+ var item = getItem(id);
1615
+ return item ? item.element : null;
1616
+ },
1617
+ getOwnerID: function (id) {
1618
+ var element = ReactComponentTreeHook.getElement(id);
1619
+ if (!element || !element._owner) {
1620
+ return null;
1824
1621
  }
1825
- return newElement;
1826
- }
1622
+ return element._owner._debugID;
1623
+ },
1624
+ getParentID: function (id) {
1625
+ var item = getItem(id);
1626
+ return item ? item.parentID : null;
1627
+ },
1628
+ getSource: function (id) {
1629
+ var item = getItem(id);
1630
+ var element = item ? item.element : null;
1631
+ var source = element != null ? element._source : null;
1632
+ return source;
1633
+ },
1634
+ getText: function (id) {
1635
+ var element = ReactComponentTreeHook.getElement(id);
1636
+ if (typeof element === 'string') {
1637
+ return element;
1638
+ } else if (typeof element === 'number') {
1639
+ return '' + element;
1640
+ } else {
1641
+ return null;
1642
+ }
1643
+ },
1644
+ getUpdateCount: function (id) {
1645
+ var item = getItem(id);
1646
+ return item ? item.updateCount : 0;
1647
+ },
1648
+
1649
+
1650
+ getRootIDs: getRootIDs,
1651
+ getRegisteredIDs: getItemIDs
1827
1652
  };
1828
1653
 
1829
- var ReactElementValidator_1 = ReactElementValidator$1;
1654
+ var ReactComponentTreeHook_1 = ReactComponentTreeHook;
1830
1655
 
1831
1656
  var createElement = ReactElement_1.createElement;
1832
1657
  var createFactory = ReactElement_1.createFactory;
@@ -1850,6 +1675,7 @@ var React = {
1850
1675
 
1851
1676
  Component: ReactBaseClasses.Component,
1852
1677
  PureComponent: ReactBaseClasses.PureComponent,
1678
+ unstable_AsyncComponent: ReactBaseClasses.AsyncComponent,
1853
1679
 
1854
1680
  createElement: createElement,
1855
1681
  cloneElement: cloneElement,
@@ -1872,6 +1698,9 @@ var React = {
1872
1698
  });
1873
1699
  }
1874
1700
 
1875
- var React_1 = React;
1701
+ var ReactEntry = React;
1876
1702
 
1877
- module.exports = React_1;
1703
+ module.exports = ReactEntry;
1704
+
1705
+ })();
1706
+ }