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

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,12 @@
1
1
  'use strict';
2
2
 
3
+
4
+ if (process.env.NODE_ENV !== "production") {
5
+
6
+ 'use strict';
7
+
3
8
  var objectAssign$1 = require('object-assign');
4
- var warning = require('fbjs/lib/warning');
9
+ var require$$0 = require('fbjs/lib/warning');
5
10
  var emptyObject = require('fbjs/lib/emptyObject');
6
11
  var invariant = require('fbjs/lib/invariant');
7
12
  var emptyFunction = require('fbjs/lib/emptyFunction');
@@ -19,6 +24,10 @@ var checkPropTypes = require('prop-types/checkPropTypes');
19
24
  *
20
25
  */
21
26
 
27
+ {
28
+ var warning = require$$0;
29
+ }
30
+
22
31
  function warnNoop(publicInstance, callerName) {
23
32
  {
24
33
  var constructor = publicInstance.constructor;
@@ -262,112 +271,37 @@ function ReactPureComponent(props, context, updater) {
262
271
 
263
272
  function ComponentDummy() {}
264
273
  ComponentDummy.prototype = ReactComponent.prototype;
265
- ReactPureComponent.prototype = new ComponentDummy();
266
- ReactPureComponent.prototype.constructor = ReactPureComponent;
274
+ var pureComponentPrototype = ReactPureComponent.prototype = new ComponentDummy();
275
+ pureComponentPrototype.constructor = ReactPureComponent;
267
276
  // 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
- };
277
+ objectAssign$1(pureComponentPrototype, ReactComponent.prototype);
278
+ pureComponentPrototype.isPureReactComponent = true;
335
279
 
336
- var DEFAULT_POOL_SIZE = 10;
337
- var DEFAULT_POOLER = oneArgumentPooler;
280
+ function ReactAsyncComponent(props, context, updater) {
281
+ // Duplicated from ReactComponent.
282
+ this.props = props;
283
+ this.context = context;
284
+ this.refs = emptyObject;
285
+ // We initialize the default updater but the real one gets injected by the
286
+ // renderer.
287
+ this.updater = updater || ReactNoopUpdateQueue_1;
288
+ }
338
289
 
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;
290
+ var asyncComponentPrototype = ReactAsyncComponent.prototype = new ComponentDummy();
291
+ asyncComponentPrototype.constructor = ReactAsyncComponent;
292
+ // Avoid an extra prototype jump for these methods.
293
+ objectAssign$1(asyncComponentPrototype, ReactComponent.prototype);
294
+ asyncComponentPrototype.unstable_isAsyncReactComponent = true;
295
+ asyncComponentPrototype.render = function () {
296
+ return this.props.children;
359
297
  };
360
298
 
361
- var PooledClass = {
362
- addPoolingTo: addPoolingTo,
363
- oneArgumentPooler: oneArgumentPooler,
364
- twoArgumentPooler: twoArgumentPooler$1,
365
- threeArgumentPooler: threeArgumentPooler,
366
- fourArgumentPooler: fourArgumentPooler$1
299
+ var ReactBaseClasses = {
300
+ Component: ReactComponent,
301
+ PureComponent: ReactPureComponent,
302
+ AsyncComponent: ReactAsyncComponent
367
303
  };
368
304
 
369
- var PooledClass_1 = PooledClass;
370
-
371
305
  /**
372
306
  * Copyright 2013-present, Facebook, Inc.
373
307
  * All rights reserved.
@@ -398,9 +332,13 @@ var ReactCurrentOwner_1 = ReactCurrentOwner;
398
332
 
399
333
  var hasOwnProperty = Object.prototype.hasOwnProperty;
400
334
 
335
+ {
336
+ var warning$2 = require$$0;
337
+ }
338
+
401
339
  // The Symbol used to tag the ReactElement type. If there is no native Symbol
402
340
  // 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;
341
+ var REACT_ELEMENT_TYPE$1 = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
404
342
 
405
343
  var RESERVED_PROPS = {
406
344
  key: true,
@@ -440,7 +378,7 @@ function defineKeyPropWarningGetter(props, displayName) {
440
378
  var warnAboutAccessingKey = function () {
441
379
  if (!specialPropKeyWarningShown) {
442
380
  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);
381
+ 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
382
  }
445
383
  };
446
384
  warnAboutAccessingKey.isReactWarning = true;
@@ -454,7 +392,7 @@ function defineRefPropWarningGetter(props, displayName) {
454
392
  var warnAboutAccessingRef = function () {
455
393
  if (!specialPropRefWarningShown) {
456
394
  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);
395
+ 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
396
  }
459
397
  };
460
398
  warnAboutAccessingRef.isReactWarning = true;
@@ -487,7 +425,7 @@ function defineRefPropWarningGetter(props, displayName) {
487
425
  var ReactElement = function (type, key, ref, self, source, owner, props) {
488
426
  var element = {
489
427
  // This tag allow us to uniquely identify this as a React Element
490
- $$typeof: REACT_ELEMENT_TYPE,
428
+ $$typeof: REACT_ELEMENT_TYPE$1,
491
429
 
492
430
  // Built-in properties that belong on the element
493
431
  type: type,
@@ -602,7 +540,7 @@ ReactElement.createElement = function (type, config, children) {
602
540
  }
603
541
  {
604
542
  if (key || ref) {
605
- if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
543
+ if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE$1) {
606
544
  var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
607
545
  if (key) {
608
546
  defineKeyPropWarningGetter(props, displayName);
@@ -711,7 +649,7 @@ ReactElement.cloneElement = function (element, config, children) {
711
649
  * @final
712
650
  */
713
651
  ReactElement.isValidElement = function (object) {
714
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
652
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE$1;
715
653
  };
716
654
 
717
655
  var ReactElement_1 = ReactElement;
@@ -724,694 +662,252 @@ var ReactElement_1 = ReactElement;
724
662
  * LICENSE file in the root directory of this source tree. An additional grant
725
663
  * of patent rights can be found in the PATENTS file in the same directory.
726
664
  *
727
- * @providesModule ReactTypeOfWork
665
+ * @providesModule ReactDebugCurrentFrame
728
666
  *
729
667
  */
730
668
 
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
- };
669
+ var ReactDebugCurrentFrame = {};
670
+
671
+ {
672
+ // Component that is being worked on
673
+ ReactDebugCurrentFrame.getCurrentStack = null;
674
+
675
+ ReactDebugCurrentFrame.getStackAddendum = function () {
676
+ var impl = ReactDebugCurrentFrame.getCurrentStack;
677
+ if (impl) {
678
+ return impl();
679
+ }
680
+ return null;
681
+ };
682
+ }
683
+
684
+ var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame;
685
+
686
+ {
687
+ var warning$1 = require$$0;
688
+
689
+ var _require = ReactDebugCurrentFrame_1,
690
+ getStackAddendum = _require.getStackAddendum;
691
+ }
692
+
693
+ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
694
+ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
695
+ // The Symbol used to tag the ReactElement type. If there is no native Symbol
696
+ // nor polyfill, then a plain number is used for performance.
697
+ var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
698
+
699
+ var SEPARATOR = '.';
700
+ var SUBSEPARATOR = ':';
744
701
 
745
702
  /**
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.
703
+ * Escape and wrap key so it is safe to use as a reactid
752
704
  *
753
- * @providesModule getComponentName
754
- *
705
+ * @param {string} key to be escaped.
706
+ * @return {string} the escaped key.
755
707
  */
708
+ function escape(key) {
709
+ var escapeRegex = /[=:]/g;
710
+ var escaperLookup = {
711
+ '=': '=0',
712
+ ':': '=2'
713
+ };
714
+ var escapedString = ('' + key).replace(escapeRegex, function (match) {
715
+ return escaperLookup[match];
716
+ });
756
717
 
757
- function getComponentName(instanceOrFiber) {
758
- if (typeof instanceOrFiber.getName === 'function') {
759
- // Stack reconciler
760
- var instance = instanceOrFiber;
761
- return instance.getName();
718
+ return '$' + escapedString;
719
+ }
720
+
721
+ /**
722
+ * TODO: Test that a single child and an array with one item have the same key
723
+ * pattern.
724
+ */
725
+
726
+ var didWarnAboutMaps = false;
727
+
728
+ var userProvidedKeyEscapeRegex = /\/+/g;
729
+ function escapeUserProvidedKey(text) {
730
+ return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
731
+ }
732
+
733
+ var POOL_SIZE = 10;
734
+ var traverseContextPool = [];
735
+ function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
736
+ if (traverseContextPool.length) {
737
+ var traverseContext = traverseContextPool.pop();
738
+ traverseContext.result = mapResult;
739
+ traverseContext.keyPrefix = keyPrefix;
740
+ traverseContext.func = mapFunction;
741
+ traverseContext.context = mapContext;
742
+ traverseContext.count = 0;
743
+ return traverseContext;
744
+ } else {
745
+ return {
746
+ result: mapResult,
747
+ keyPrefix: keyPrefix,
748
+ func: mapFunction,
749
+ context: mapContext,
750
+ count: 0
751
+ };
762
752
  }
763
- if (typeof instanceOrFiber.tag === 'number') {
764
- // Fiber reconciler
765
- var fiber = instanceOrFiber;
766
- var type = fiber.type;
753
+ }
767
754
 
768
- if (typeof type === 'string') {
769
- return type;
770
- }
771
- if (typeof type === 'function') {
772
- return type.displayName || type.name;
773
- }
755
+ function releaseTraverseContext(traverseContext) {
756
+ traverseContext.result = null;
757
+ traverseContext.keyPrefix = null;
758
+ traverseContext.func = null;
759
+ traverseContext.context = null;
760
+ traverseContext.count = 0;
761
+ if (traverseContextPool.length < POOL_SIZE) {
762
+ traverseContextPool.push(traverseContext);
774
763
  }
775
- return null;
776
764
  }
777
765
 
778
- var getComponentName_1 = getComponentName;
766
+ /**
767
+ * @param {?*} children Children tree container.
768
+ * @param {!string} nameSoFar Name of the key path so far.
769
+ * @param {!function} callback Callback to invoke with each child found.
770
+ * @param {?*} traverseContext Used to pass information throughout the traversal
771
+ * process.
772
+ * @return {!number} The number of children in this subtree.
773
+ */
774
+ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
775
+ var type = typeof children;
779
776
 
780
- var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent;
781
- var FunctionalComponent = ReactTypeOfWork.FunctionalComponent;
782
- var ClassComponent = ReactTypeOfWork.ClassComponent;
783
- var HostComponent = ReactTypeOfWork.HostComponent;
777
+ if (type === 'undefined' || type === 'boolean') {
778
+ // All of the above are perceived as null.
779
+ children = null;
780
+ }
784
781
 
782
+ if (children === null || type === 'string' || type === 'number' ||
783
+ // The following is inlined from ReactElement. This means we can optimize
784
+ // some checks. React Fiber also inlines this logic for similar purposes.
785
+ type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE) {
786
+ callback(traverseContext, children,
787
+ // If it's the only child, treat the name as if it was wrapped in an array
788
+ // so that it's consistent if the number of children grows.
789
+ nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
790
+ return 1;
791
+ }
785
792
 
793
+ var child;
794
+ var nextName;
795
+ var subtreeCount = 0; // Count of children found in the current subtree.
796
+ var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
786
797
 
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
- }
798
+ if (Array.isArray(children)) {
799
+ for (var i = 0; i < children.length; i++) {
800
+ child = children[i];
801
+ nextName = nextNamePrefix + getComponentKey(child, i);
802
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
803
+ }
804
+ } else {
805
+ var iteratorFn = ITERATOR_SYMBOL && children[ITERATOR_SYMBOL] || children[FAUX_ITERATOR_SYMBOL];
806
+ if (typeof iteratorFn === 'function') {
807
+ {
808
+ // Warn about using Maps as children
809
+ if (iteratorFn === children.entries) {
810
+ 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());
811
+ didWarnAboutMaps = true;
812
+ }
813
+ }
790
814
 
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);
815
+ var iterator = iteratorFn.call(children);
816
+ var step;
817
+ var ii = 0;
818
+ while (!(step = iterator.next()).done) {
819
+ child = step.value;
820
+ nextName = nextNamePrefix + getComponentKey(child, ii++);
821
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
822
+ }
823
+ } else if (type === 'object') {
824
+ var addendum = '';
825
+ {
826
+ addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getStackAddendum();
803
827
  }
804
- return describeComponentFrame$1(name, source, ownerName);
805
- default:
806
- return '';
828
+ var childrenString = '' + children;
829
+ 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);
830
+ }
807
831
  }
832
+
833
+ return subtreeCount;
808
834
  }
809
835
 
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;
836
+ /**
837
+ * Traverses children that are typically specified as `props.children`, but
838
+ * might also be specified through attributes:
839
+ *
840
+ * - `traverseAllChildren(this.props.children, ...)`
841
+ * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
842
+ *
843
+ * The `traverseContext` is an optional argument that is passed through the
844
+ * entire traversal. It can be used to store accumulations or anything else that
845
+ * the callback might find relevant.
846
+ *
847
+ * @param {?*} children Children tree object.
848
+ * @param {!function} callback To invoke upon traversing each child.
849
+ * @param {?*} traverseContext Context for traversal.
850
+ * @return {!number} The number of children in this subtree.
851
+ */
852
+ function traverseAllChildren(children, callback, traverseContext) {
853
+ if (children == null) {
854
+ return 0;
855
+ }
856
+
857
+ return traverseAllChildrenImpl(children, '', callback, traverseContext);
822
858
  }
823
859
 
824
- var ReactFiberComponentTreeHook = {
825
- getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$1,
826
- describeComponentFrame: describeComponentFrame$1
827
- };
860
+ /**
861
+ * Generate a key string that identifies a component within a set.
862
+ *
863
+ * @param {*} component A component that could contain a manual key.
864
+ * @param {number} index Index that is used if a manual key is not provided.
865
+ * @return {string}
866
+ */
867
+ function getComponentKey(component, index) {
868
+ // Do some typechecking here since we call this blindly. We want to ensure
869
+ // that we don't block potential future ES APIs.
870
+ if (typeof component === 'object' && component !== null && component.key != null) {
871
+ // Explicit key
872
+ return escape(component.key);
873
+ }
874
+ // Implicit key determined by the index in the set
875
+ return index.toString(36);
876
+ }
828
877
 
829
- var getStackAddendumByWorkInProgressFiber = ReactFiberComponentTreeHook.getStackAddendumByWorkInProgressFiber;
830
- var describeComponentFrame = ReactFiberComponentTreeHook.describeComponentFrame;
878
+ function forEachSingleChild(bookKeeping, child, name) {
879
+ var func = bookKeeping.func,
880
+ context = bookKeeping.context;
831
881
 
882
+ func.call(context, child, bookKeeping.count++);
883
+ }
832
884
 
885
+ /**
886
+ * Iterates through children that are typically specified as `props.children`.
887
+ *
888
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.foreach
889
+ *
890
+ * The provided forEachFunc(child, index) will be called for each
891
+ * leaf child.
892
+ *
893
+ * @param {?*} children Children tree container.
894
+ * @param {function(*, int)} forEachFunc
895
+ * @param {*} forEachContext Context for forEachContext.
896
+ */
897
+ function forEachChildren(children, forEachFunc, forEachContext) {
898
+ if (children == null) {
899
+ return children;
900
+ }
901
+ var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
902
+ traverseAllChildren(children, forEachSingleChild, traverseContext);
903
+ releaseTraverseContext(traverseContext);
904
+ }
833
905
 
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;
906
+ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
907
+ var result = bookKeeping.result,
908
+ keyPrefix = bookKeeping.keyPrefix,
909
+ func = bookKeeping.func,
910
+ context = bookKeeping.context;
1415
911
 
1416
912
 
1417
913
  var mappedChild = func.call(context, child, bookKeeping.count++);
@@ -1433,9 +929,9 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1433
929
  if (prefix != null) {
1434
930
  escapedPrefix = escapeUserProvidedKey(prefix) + '/';
1435
931
  }
1436
- var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
1437
- traverseAllChildren_1(children, mapSingleChildIntoContext, traverseContext);
1438
- MapBookKeeping.release(traverseContext);
932
+ var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
933
+ traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
934
+ releaseTraverseContext(traverseContext);
1439
935
  }
1440
936
 
1441
937
  /**
@@ -1460,10 +956,6 @@ function mapChildren(children, func, context) {
1460
956
  return result;
1461
957
  }
1462
958
 
1463
- function forEachSingleChildDummy(traverseContext, child, name) {
1464
- return null;
1465
- }
1466
-
1467
959
  /**
1468
960
  * Count the number of children that are typically specified as
1469
961
  * `props.children`.
@@ -1474,7 +966,7 @@ function forEachSingleChildDummy(traverseContext, child, name) {
1474
966
  * @return {number} The number of children.
1475
967
  */
1476
968
  function countChildren(children, context) {
1477
- return traverseAllChildren_1(children, forEachSingleChildDummy, null);
969
+ return traverseAllChildren(children, emptyFunction.thatReturnsNull, null);
1478
970
  }
1479
971
 
1480
972
  /**
@@ -1492,7 +984,6 @@ function toArray(children) {
1492
984
  var ReactChildren = {
1493
985
  forEach: forEachChildren,
1494
986
  map: mapChildren,
1495
- mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
1496
987
  count: countChildren,
1497
988
  toArray: toArray
1498
989
  };
@@ -1510,7 +1001,7 @@ var ReactChildren_1 = ReactChildren;
1510
1001
  * @providesModule ReactVersion
1511
1002
  */
1512
1003
 
1513
- var ReactVersion = '16.0.0-alpha.13';
1004
+ var ReactVersion = '16.0.0-beta.1';
1514
1005
 
1515
1006
  /**
1516
1007
  * Returns the first child in a collection of children and verifies that there
@@ -1533,57 +1024,89 @@ function onlyChild(children) {
1533
1024
 
1534
1025
  var onlyChild_1 = onlyChild;
1535
1026
 
1536
- var ReactDebugCurrentFrame$1 = {};
1537
-
1538
- {
1539
- var _require$2 = ReactComponentTreeHook_1,
1540
- getStackAddendumByID = _require$2.getStackAddendumByID,
1541
- getCurrentStackAddendum$2 = _require$2.getCurrentStackAddendum;
1027
+ /**
1028
+ * Copyright 2016-present, Facebook, Inc.
1029
+ * All rights reserved.
1030
+ *
1031
+ * This source code is licensed under the BSD-style license found in the
1032
+ * LICENSE file in the root directory of this source tree. An additional grant
1033
+ * of patent rights can be found in the PATENTS file in the same directory.
1034
+ *
1035
+ *
1036
+ * @providesModule describeComponentFrame
1037
+ */
1542
1038
 
1543
- var _require2 = ReactFiberComponentTreeHook,
1544
- getStackAddendumByWorkInProgressFiber$2 = _require2.getStackAddendumByWorkInProgressFiber;
1039
+ var describeComponentFrame$1 = function (name, source, ownerName) {
1040
+ return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
1041
+ };
1545
1042
 
1546
- // Component that is being worked on
1043
+ /**
1044
+ * Copyright 2013-present, Facebook, Inc.
1045
+ * All rights reserved.
1046
+ *
1047
+ * This source code is licensed under the BSD-style license found in the
1048
+ * LICENSE file in the root directory of this source tree. An additional grant
1049
+ * of patent rights can be found in the PATENTS file in the same directory.
1050
+ *
1051
+ * @providesModule getComponentName
1052
+ *
1053
+ */
1547
1054
 
1055
+ function getComponentName$1(instanceOrFiber) {
1056
+ if (typeof instanceOrFiber.getName === 'function') {
1057
+ // Stack reconciler
1058
+ var instance = instanceOrFiber;
1059
+ return instance.getName();
1060
+ }
1061
+ if (typeof instanceOrFiber.tag === 'number') {
1062
+ // Fiber reconciler
1063
+ var fiber = instanceOrFiber;
1064
+ var type = fiber.type;
1548
1065
 
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);
1066
+ if (typeof type === 'string') {
1067
+ return type;
1572
1068
  }
1573
- return stack;
1574
- };
1069
+ if (typeof type === 'function') {
1070
+ return type.displayName || type.name;
1071
+ }
1072
+ }
1073
+ return null;
1575
1074
  }
1576
1075
 
1577
- var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame$1;
1076
+ var getComponentName_1 = getComponentName$1;
1578
1077
 
1579
1078
  {
1580
1079
  var checkPropTypes$1 = checkPropTypes;
1581
1080
  var lowPriorityWarning$1 = lowPriorityWarning_1;
1582
- var ReactDebugCurrentFrame = ReactDebugCurrentFrame_1;
1583
- var warning$1 = warning;
1081
+ var ReactDebugCurrentFrame$1 = ReactDebugCurrentFrame_1;
1082
+ var warning$3 = require$$0;
1083
+ var describeComponentFrame = describeComponentFrame$1;
1084
+ var getComponentName = getComponentName_1;
1085
+
1086
+ var currentlyValidatingElement = null;
1087
+
1088
+ var getDisplayName = function (element) {
1089
+ if (element == null) {
1090
+ return '#empty';
1091
+ } else if (typeof element === 'string' || typeof element === 'number') {
1092
+ return '#text';
1093
+ } else if (typeof element.type === 'string') {
1094
+ return element.type;
1095
+ } else {
1096
+ return element.type.displayName || element.type.name || 'Unknown';
1097
+ }
1098
+ };
1584
1099
 
1585
- var _require$1 = ReactComponentTreeHook_1,
1586
- getCurrentStackAddendum$1 = _require$1.getCurrentStackAddendum;
1100
+ var getStackAddendum$1 = function () {
1101
+ var stack = '';
1102
+ if (currentlyValidatingElement) {
1103
+ var name = getDisplayName(currentlyValidatingElement);
1104
+ var owner = currentlyValidatingElement._owner;
1105
+ stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
1106
+ }
1107
+ stack += ReactDebugCurrentFrame$1.getStackAddendum() || '';
1108
+ return stack;
1109
+ };
1587
1110
  }
1588
1111
 
1589
1112
  var ITERATOR_SYMBOL$1 = typeof Symbol === 'function' && Symbol.iterator;
@@ -1591,7 +1114,7 @@ var FAUX_ITERATOR_SYMBOL$1 = '@@iterator'; // Before Symbol spec.
1591
1114
 
1592
1115
  function getDeclarationErrorAddendum() {
1593
1116
  if (ReactCurrentOwner_1.current) {
1594
- var name = getComponentName_1(ReactCurrentOwner_1.current);
1117
+ var name = getComponentName(ReactCurrentOwner_1.current);
1595
1118
  if (name) {
1596
1119
  return '\n\nCheck the render method of `' + name + '`.';
1597
1120
  }
@@ -1657,10 +1180,12 @@ function validateExplicitKey(element, parentType) {
1657
1180
  var childOwner = '';
1658
1181
  if (element && element._owner && element._owner !== ReactCurrentOwner_1.current) {
1659
1182
  // Give the component that originally created this child.
1660
- childOwner = ' It was passed a child from ' + getComponentName_1(element._owner) + '.';
1183
+ childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
1661
1184
  }
1662
1185
 
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));
1186
+ currentlyValidatingElement = element;
1187
+ 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());
1188
+ currentlyValidatingElement = null;
1664
1189
  }
1665
1190
 
1666
1191
  /**
@@ -1706,127 +1231,426 @@ function validateChildKeys(node, parentType) {
1706
1231
  }
1707
1232
  }
1708
1233
 
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;
1234
+ /**
1235
+ * Given an element, validate that its props follow the propTypes definition,
1236
+ * provided by the type.
1237
+ *
1238
+ * @param {ReactElement} element
1239
+ */
1240
+ function validatePropTypes(element) {
1241
+ var componentClass = element.type;
1242
+ if (typeof componentClass !== 'function') {
1243
+ return;
1244
+ }
1245
+ var name = componentClass.displayName || componentClass.name;
1246
+
1247
+ // ReactNative `View.propTypes` have been deprecated in favor of `ViewPropTypes`.
1248
+ // In their place a temporary getter has been added with a deprecated warning message.
1249
+ // Avoid triggering that warning during validation using the temporary workaround,
1250
+ // __propTypesSecretDontUseThesePlease.
1251
+ // TODO (bvaughn) Revert this particular change any time after April 1 ReactNative tag.
1252
+ var propTypes = typeof componentClass.__propTypesSecretDontUseThesePlease === 'object' ? componentClass.__propTypesSecretDontUseThesePlease : componentClass.propTypes;
1253
+
1254
+ if (propTypes) {
1255
+ currentlyValidatingElement = element;
1256
+ checkPropTypes$1(propTypes, element.props, 'prop', name, getStackAddendum$1);
1257
+ currentlyValidatingElement = null;
1258
+ }
1259
+ if (typeof componentClass.getDefaultProps === 'function') {
1260
+ warning$3(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1261
+ }
1262
+ }
1263
+
1264
+ var ReactElementValidator$1 = {
1265
+ createElement: function (type, props, children) {
1266
+ var validType = typeof type === 'string' || typeof type === 'function';
1267
+ // We warn in this case but don't throw. We expect the element creation to
1268
+ // succeed and there will likely be errors in render.
1269
+ if (!validType) {
1270
+ var info = '';
1271
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1272
+ info += ' You likely forgot to export your component from the file ' + "it's defined in.";
1273
+ }
1274
+
1275
+ var sourceInfo = getSourceInfoErrorAddendum(props);
1276
+ if (sourceInfo) {
1277
+ info += sourceInfo;
1278
+ } else {
1279
+ info += getDeclarationErrorAddendum();
1280
+ }
1281
+
1282
+ info += ReactDebugCurrentFrame$1.getStackAddendum() || '';
1283
+
1284
+ 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);
1285
+ }
1286
+
1287
+ var element = ReactElement_1.createElement.apply(this, arguments);
1288
+
1289
+ // The result can be nullish if a mock or a custom function is used.
1290
+ // TODO: Drop this when these are no longer allowed as the type argument.
1291
+ if (element == null) {
1292
+ return element;
1293
+ }
1294
+
1295
+ // Skip key warning if the type isn't valid since our key validation logic
1296
+ // doesn't expect a non-string/function type and can throw confusing errors.
1297
+ // We don't want exception behavior to differ between dev and prod.
1298
+ // (Rendering will throw with a helpful message and as soon as the type is
1299
+ // fixed, the key warnings will appear.)
1300
+ if (validType) {
1301
+ for (var i = 2; i < arguments.length; i++) {
1302
+ validateChildKeys(arguments[i], type);
1303
+ }
1304
+ }
1305
+
1306
+ validatePropTypes(element);
1307
+
1308
+ return element;
1309
+ },
1310
+
1311
+ createFactory: function (type) {
1312
+ var validatedFactory = ReactElementValidator$1.createElement.bind(null, type);
1313
+ // Legacy hook TODO: Warn if this is accessed
1314
+ validatedFactory.type = type;
1315
+
1316
+ {
1317
+ Object.defineProperty(validatedFactory, 'type', {
1318
+ enumerable: false,
1319
+ get: function () {
1320
+ lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
1321
+ Object.defineProperty(this, 'type', {
1322
+ value: type
1323
+ });
1324
+ return type;
1325
+ }
1326
+ });
1327
+ }
1328
+
1329
+ return validatedFactory;
1330
+ },
1331
+
1332
+ cloneElement: function (element, props, children) {
1333
+ var newElement = ReactElement_1.cloneElement.apply(this, arguments);
1334
+ for (var i = 2; i < arguments.length; i++) {
1335
+ validateChildKeys(arguments[i], newElement.type);
1336
+ }
1337
+ validatePropTypes(newElement);
1338
+ return newElement;
1339
+ }
1340
+ };
1341
+
1342
+ var ReactElementValidator_1 = ReactElementValidator$1;
1343
+
1344
+ {
1345
+ var warning$4 = require$$0;
1346
+ }
1347
+
1348
+ function isNative(fn) {
1349
+ // Based on isNative() from Lodash
1350
+ var funcToString = Function.prototype.toString;
1351
+ var reIsNative = RegExp('^' + funcToString
1352
+ // Take an example native function source for comparison
1353
+ .call(Object.prototype.hasOwnProperty)
1354
+ // Strip regex characters so we can use it for regex
1355
+ .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
1356
+ // Remove hasOwnProperty from the template to make it generic
1357
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
1358
+ try {
1359
+ var source = funcToString.call(fn);
1360
+ return reIsNative.test(source);
1361
+ } catch (err) {
1362
+ return false;
1363
+ }
1364
+ }
1365
+
1366
+ var canUseCollections =
1367
+ // Array.from
1368
+ typeof Array.from === 'function' &&
1369
+ // Map
1370
+ typeof Map === 'function' && isNative(Map) &&
1371
+ // Map.prototype.keys
1372
+ Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) &&
1373
+ // Set
1374
+ typeof Set === 'function' && isNative(Set) &&
1375
+ // Set.prototype.keys
1376
+ Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys);
1377
+
1378
+ var setItem;
1379
+ var getItem;
1380
+ var removeItem;
1381
+ var getItemIDs;
1382
+ var addRoot;
1383
+ var removeRoot;
1384
+ var getRootIDs;
1385
+
1386
+ if (canUseCollections) {
1387
+ var itemMap = new Map();
1388
+ var rootIDSet = new Set();
1389
+
1390
+ setItem = function (id, item) {
1391
+ itemMap.set(id, item);
1392
+ };
1393
+ getItem = function (id) {
1394
+ return itemMap.get(id);
1395
+ };
1396
+ removeItem = function (id) {
1397
+ itemMap['delete'](id);
1398
+ };
1399
+ getItemIDs = function () {
1400
+ return Array.from(itemMap.keys());
1401
+ };
1402
+
1403
+ addRoot = function (id) {
1404
+ rootIDSet.add(id);
1405
+ };
1406
+ removeRoot = function (id) {
1407
+ rootIDSet['delete'](id);
1408
+ };
1409
+ getRootIDs = function () {
1410
+ return Array.from(rootIDSet.keys());
1411
+ };
1412
+ } else {
1413
+ var itemByKey = {};
1414
+ var rootByKey = {};
1415
+
1416
+ // Use non-numeric keys to prevent V8 performance issues:
1417
+ // https://github.com/facebook/react/pull/7232
1418
+ var getKeyFromID = function (id) {
1419
+ return '.' + id;
1420
+ };
1421
+ var getIDFromKey = function (key) {
1422
+ return parseInt(key.substr(1), 10);
1423
+ };
1424
+
1425
+ setItem = function (id, item) {
1426
+ var key = getKeyFromID(id);
1427
+ itemByKey[key] = item;
1428
+ };
1429
+ getItem = function (id) {
1430
+ var key = getKeyFromID(id);
1431
+ return itemByKey[key];
1432
+ };
1433
+ removeItem = function (id) {
1434
+ var key = getKeyFromID(id);
1435
+ delete itemByKey[key];
1436
+ };
1437
+ getItemIDs = function () {
1438
+ return Object.keys(itemByKey).map(getIDFromKey);
1439
+ };
1440
+
1441
+ addRoot = function (id) {
1442
+ var key = getKeyFromID(id);
1443
+ rootByKey[key] = true;
1444
+ };
1445
+ removeRoot = function (id) {
1446
+ var key = getKeyFromID(id);
1447
+ delete rootByKey[key];
1448
+ };
1449
+ getRootIDs = function () {
1450
+ return Object.keys(rootByKey).map(getIDFromKey);
1451
+ };
1452
+ }
1453
+
1454
+ var unmountedIDs = [];
1455
+
1456
+ function purgeDeep(id) {
1457
+ var item = getItem(id);
1458
+ if (item) {
1459
+ var childIDs = item.childIDs;
1460
+
1461
+ removeItem(id);
1462
+ childIDs.forEach(purgeDeep);
1463
+ }
1464
+ }
1465
+
1466
+ function getDisplayName$1(element) {
1467
+ if (element == null) {
1468
+ return '#empty';
1469
+ } else if (typeof element === 'string' || typeof element === 'number') {
1470
+ return '#text';
1471
+ } else if (typeof element.type === 'string') {
1472
+ return element.type;
1473
+ } else {
1474
+ return element.type.displayName || element.type.name || 'Unknown';
1719
1475
  }
1720
- var name = componentClass.displayName || componentClass.name;
1476
+ }
1721
1477
 
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;
1478
+ function describeID(id) {
1479
+ var name = ReactComponentTreeHook.getDisplayName(id);
1480
+ var element = ReactComponentTreeHook.getElement(id);
1481
+ var ownerID = ReactComponentTreeHook.getOwnerID(id);
1482
+ var ownerName = void 0;
1728
1483
 
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.');
1484
+ if (ownerID) {
1485
+ ownerName = ReactComponentTreeHook.getDisplayName(ownerID);
1734
1486
  }
1487
+ warning$4(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id);
1488
+ return describeComponentFrame$1(name || '', element && element._source, ownerName || '');
1735
1489
  }
1736
1490
 
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
- }
1491
+ var ReactComponentTreeHook = {
1492
+ onSetChildren: function (id, nextChildIDs) {
1493
+ var item = getItem(id);
1494
+ !item ? invariant(false, 'Item must have been set') : void 0;
1495
+ item.childIDs = nextChildIDs;
1747
1496
 
1748
- var sourceInfo = getSourceInfoErrorAddendum(props);
1749
- if (sourceInfo) {
1750
- info += sourceInfo;
1751
- } else {
1752
- info += getDeclarationErrorAddendum();
1497
+ for (var i = 0; i < nextChildIDs.length; i++) {
1498
+ var nextChildID = nextChildIDs[i];
1499
+ var nextChild = getItem(nextChildID);
1500
+ !nextChild ? invariant(false, 'Expected hook events to fire for the child before its parent includes it in onSetChildren().') : void 0;
1501
+ !(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;
1502
+ !nextChild.isMounted ? invariant(false, 'Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().') : void 0;
1503
+ if (nextChild.parentID == null) {
1504
+ nextChild.parentID = id;
1505
+ // TODO: This shouldn't be necessary but mounting a new root during in
1506
+ // componentWillMount currently causes not-yet-mounted components to
1507
+ // be purged from our tree data so their parent id is missing.
1753
1508
  }
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);
1509
+ !(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
1510
  }
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;
1511
+ },
1512
+ onBeforeMountComponent: function (id, element, parentID) {
1513
+ var item = {
1514
+ element: element,
1515
+ parentID: parentID,
1516
+ text: null,
1517
+ childIDs: [],
1518
+ isMounted: false,
1519
+ updateCount: 0
1520
+ };
1521
+ setItem(id, item);
1522
+ },
1523
+ onBeforeUpdateComponent: function (id, element) {
1524
+ var item = getItem(id);
1525
+ if (!item || !item.isMounted) {
1526
+ // We may end up here as a result of setState() in componentWillUnmount().
1527
+ // In this case, ignore the element.
1528
+ return;
1766
1529
  }
1767
-
1768
- {
1769
- ReactDebugCurrentFrame.element = element;
1530
+ item.element = element;
1531
+ },
1532
+ onMountComponent: function (id) {
1533
+ var item = getItem(id);
1534
+ !item ? invariant(false, 'Item must have been set') : void 0;
1535
+ item.isMounted = true;
1536
+ var isRoot = item.parentID === 0;
1537
+ if (isRoot) {
1538
+ addRoot(id);
1770
1539
  }
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);
1540
+ },
1541
+ onUpdateComponent: function (id) {
1542
+ var item = getItem(id);
1543
+ if (!item || !item.isMounted) {
1544
+ // We may end up here as a result of setState() in componentWillUnmount().
1545
+ // In this case, ignore the element.
1546
+ return;
1547
+ }
1548
+ item.updateCount++;
1549
+ },
1550
+ onUnmountComponent: function (id) {
1551
+ var item = getItem(id);
1552
+ if (item) {
1553
+ // We need to check if it exists.
1554
+ // `item` might not exist if it is inside an error boundary, and a sibling
1555
+ // error boundary child threw while mounting. Then this instance never
1556
+ // got a chance to mount, but it still gets an unmounting event during
1557
+ // the error boundary cleanup.
1558
+ item.isMounted = false;
1559
+ var isRoot = item.parentID === 0;
1560
+ if (isRoot) {
1561
+ removeRoot(id);
1780
1562
  }
1781
1563
  }
1782
-
1783
- validatePropTypes(element);
1784
-
1785
- {
1786
- ReactDebugCurrentFrame.element = null;
1564
+ unmountedIDs.push(id);
1565
+ },
1566
+ purgeUnmountedComponents: function () {
1567
+ if (ReactComponentTreeHook._preventPurging) {
1568
+ // Should only be used for testing.
1569
+ return;
1787
1570
  }
1788
1571
 
1789
- return element;
1572
+ for (var i = 0; i < unmountedIDs.length; i++) {
1573
+ var id = unmountedIDs[i];
1574
+ purgeDeep(id);
1575
+ }
1576
+ unmountedIDs.length = 0;
1790
1577
  },
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
- });
1578
+ isMounted: function (id) {
1579
+ var item = getItem(id);
1580
+ return item ? item.isMounted : false;
1581
+ },
1582
+ getCurrentStackAddendum: function () {
1583
+ var info = '';
1584
+ var currentOwner = ReactCurrentOwner_1.current;
1585
+ if (currentOwner) {
1586
+ invariant(typeof currentOwner.tag !== 'number', 'Fiber owners should not show up in Stack stack traces.');
1587
+ if (typeof currentOwner._debugID === 'number') {
1588
+ info += ReactComponentTreeHook.getStackAddendumByID(currentOwner._debugID);
1589
+ }
1808
1590
  }
1809
-
1810
- return validatedFactory;
1591
+ return info;
1811
1592
  },
1812
-
1813
- cloneElement: function (element, props, children) {
1814
- var newElement = ReactElement_1.cloneElement.apply(this, arguments);
1815
- {
1816
- ReactDebugCurrentFrame.element = newElement;
1593
+ getStackAddendumByID: function (id) {
1594
+ var info = '';
1595
+ while (id) {
1596
+ info += describeID(id);
1597
+ id = ReactComponentTreeHook.getParentID(id);
1817
1598
  }
1818
- for (var i = 2; i < arguments.length; i++) {
1819
- validateChildKeys(arguments[i], newElement.type);
1599
+ return info;
1600
+ },
1601
+ getChildIDs: function (id) {
1602
+ var item = getItem(id);
1603
+ return item ? item.childIDs : [];
1604
+ },
1605
+ getDisplayName: function (id) {
1606
+ var element = ReactComponentTreeHook.getElement(id);
1607
+ if (!element) {
1608
+ return null;
1820
1609
  }
1821
- validatePropTypes(newElement);
1822
- {
1823
- ReactDebugCurrentFrame.element = null;
1610
+ return getDisplayName$1(element);
1611
+ },
1612
+ getElement: function (id) {
1613
+ var item = getItem(id);
1614
+ return item ? item.element : null;
1615
+ },
1616
+ getOwnerID: function (id) {
1617
+ var element = ReactComponentTreeHook.getElement(id);
1618
+ if (!element || !element._owner) {
1619
+ return null;
1824
1620
  }
1825
- return newElement;
1826
- }
1621
+ return element._owner._debugID;
1622
+ },
1623
+ getParentID: function (id) {
1624
+ var item = getItem(id);
1625
+ return item ? item.parentID : null;
1626
+ },
1627
+ getSource: function (id) {
1628
+ var item = getItem(id);
1629
+ var element = item ? item.element : null;
1630
+ var source = element != null ? element._source : null;
1631
+ return source;
1632
+ },
1633
+ getText: function (id) {
1634
+ var element = ReactComponentTreeHook.getElement(id);
1635
+ if (typeof element === 'string') {
1636
+ return element;
1637
+ } else if (typeof element === 'number') {
1638
+ return '' + element;
1639
+ } else {
1640
+ return null;
1641
+ }
1642
+ },
1643
+ getUpdateCount: function (id) {
1644
+ var item = getItem(id);
1645
+ return item ? item.updateCount : 0;
1646
+ },
1647
+
1648
+
1649
+ getRootIDs: getRootIDs,
1650
+ getRegisteredIDs: getItemIDs
1827
1651
  };
1828
1652
 
1829
- var ReactElementValidator_1 = ReactElementValidator$1;
1653
+ var ReactComponentTreeHook_1 = ReactComponentTreeHook;
1830
1654
 
1831
1655
  var createElement = ReactElement_1.createElement;
1832
1656
  var createFactory = ReactElement_1.createFactory;
@@ -1850,6 +1674,7 @@ var React = {
1850
1674
 
1851
1675
  Component: ReactBaseClasses.Component,
1852
1676
  PureComponent: ReactBaseClasses.PureComponent,
1677
+ unstable_AsyncComponent: ReactBaseClasses.AsyncComponent,
1853
1678
 
1854
1679
  createElement: createElement,
1855
1680
  cloneElement: cloneElement,
@@ -1872,6 +1697,8 @@ var React = {
1872
1697
  });
1873
1698
  }
1874
1699
 
1875
- var React_1 = React;
1700
+ var ReactEntry = React;
1876
1701
 
1877
- module.exports = React_1;
1702
+ module.exports = ReactEntry;
1703
+
1704
+ }