react 16.0.0-alpha.9 → 16.0.0-alpha.13

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.
@@ -6,8 +6,6 @@ var emptyObject = require('fbjs/lib/emptyObject');
6
6
  var invariant = require('fbjs/lib/invariant');
7
7
  var emptyFunction = require('fbjs/lib/emptyFunction');
8
8
  var checkPropTypes = require('prop-types/checkPropTypes');
9
- var factory = require('prop-types/factory');
10
- var factory$1 = require('create-react-class/factory');
11
9
 
12
10
  /**
13
11
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -99,29 +97,68 @@ var ReactNoopUpdateQueue = {
99
97
  var ReactNoopUpdateQueue_1 = ReactNoopUpdateQueue;
100
98
 
101
99
  /**
102
- * Copyright 2013-present, Facebook, Inc.
100
+ * Copyright 2014-2015, Facebook, Inc.
103
101
  * All rights reserved.
104
102
  *
105
103
  * This source code is licensed under the BSD-style license found in the
106
104
  * LICENSE file in the root directory of this source tree. An additional grant
107
105
  * of patent rights can be found in the PATENTS file in the same directory.
108
106
  *
109
- *
110
- * @providesModule canDefineProperty
107
+ * @providesModule lowPriorityWarning
108
+ */
109
+
110
+ /**
111
+ * Forked from fbjs/warning:
112
+ * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
113
+ *
114
+ * Only change is we use console.warn instead of console.error,
115
+ * and do nothing when 'console' is not supported.
116
+ * This really simplifies the code.
117
+ * ---
118
+ * Similar to invariant but only logs a warning if the condition is not met.
119
+ * This can be used to log issues in development environments in critical
120
+ * paths. Removing the logging code for production environments will keep the
121
+ * same logic and follow the same code paths.
111
122
  */
112
123
 
113
- var canDefineProperty$1 = false;
124
+ var lowPriorityWarning = function () {};
125
+
114
126
  {
115
- try {
116
- // $FlowFixMe https://github.com/facebook/flow/issues/285
117
- Object.defineProperty({}, 'x', { get: function () {} });
118
- canDefineProperty$1 = true;
119
- } catch (x) {
120
- // IE will fail on defineProperty
121
- }
127
+ var printWarning = function (format) {
128
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
129
+ args[_key - 1] = arguments[_key];
130
+ }
131
+
132
+ var argIndex = 0;
133
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
134
+ return args[argIndex++];
135
+ });
136
+ if (typeof console !== 'undefined') {
137
+ console.warn(message);
138
+ }
139
+ try {
140
+ // --- Welcome to debugging React ---
141
+ // This error was thrown as a convenience so that you can use this stack
142
+ // to find the callsite that caused this warning to fire.
143
+ throw new Error(message);
144
+ } catch (x) {}
145
+ };
146
+
147
+ lowPriorityWarning = function (condition, format) {
148
+ if (format === undefined) {
149
+ throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
150
+ }
151
+ if (!condition) {
152
+ for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
153
+ args[_key2 - 2] = arguments[_key2];
154
+ }
155
+
156
+ printWarning.apply(undefined, [format].concat(args));
157
+ }
158
+ };
122
159
  }
123
160
 
124
- var canDefineProperty_1 = canDefineProperty$1;
161
+ var lowPriorityWarning_1 = lowPriorityWarning;
125
162
 
126
163
  /**
127
164
  * Base class helpers for the updating state of a component.
@@ -196,14 +233,12 @@ ReactComponent.prototype.forceUpdate = function (callback) {
196
233
  replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
197
234
  };
198
235
  var defineDeprecationWarning = function (methodName, info) {
199
- if (canDefineProperty_1) {
200
- Object.defineProperty(ReactComponent.prototype, methodName, {
201
- get: function () {
202
- warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
203
- return undefined;
204
- }
205
- });
206
- }
236
+ Object.defineProperty(ReactComponent.prototype, methodName, {
237
+ get: function () {
238
+ lowPriorityWarning_1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
239
+ return undefined;
240
+ }
241
+ });
207
242
  };
208
243
  for (var fnName in deprecatedAPIs) {
209
244
  if (deprecatedAPIs.hasOwnProperty(fnName)) {
@@ -361,29 +396,12 @@ var ReactCurrentOwner = {
361
396
 
362
397
  var ReactCurrentOwner_1 = ReactCurrentOwner;
363
398
 
364
- /**
365
- * Copyright 2014-present, Facebook, Inc.
366
- * All rights reserved.
367
- *
368
- * This source code is licensed under the BSD-style license found in the
369
- * LICENSE file in the root directory of this source tree. An additional grant
370
- * of patent rights can be found in the PATENTS file in the same directory.
371
- *
372
- * @providesModule ReactElementSymbol
373
- *
374
- */
399
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
375
400
 
376
401
  // The Symbol used to tag the ReactElement type. If there is no native Symbol
377
402
  // nor polyfill, then a plain number is used for performance.
378
-
379
403
  var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
380
404
 
381
- var ReactElementSymbol = REACT_ELEMENT_TYPE;
382
-
383
- var hasOwnProperty = Object.prototype.hasOwnProperty;
384
-
385
-
386
-
387
405
  var RESERVED_PROPS = {
388
406
  key: true,
389
407
  ref: true,
@@ -469,7 +487,7 @@ function defineRefPropWarningGetter(props, displayName) {
469
487
  var ReactElement = function (type, key, ref, self, source, owner, props) {
470
488
  var element = {
471
489
  // This tag allow us to uniquely identify this as a React Element
472
- $$typeof: ReactElementSymbol,
490
+ $$typeof: REACT_ELEMENT_TYPE,
473
491
 
474
492
  // Built-in properties that belong on the element
475
493
  type: type,
@@ -492,33 +510,27 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
492
510
  // the validation flag non-enumerable (where possible, which should
493
511
  // include every environment we run tests in), so the test framework
494
512
  // ignores it.
495
- if (canDefineProperty_1) {
496
- Object.defineProperty(element._store, 'validated', {
497
- configurable: false,
498
- enumerable: false,
499
- writable: true,
500
- value: false
501
- });
502
- // self and source are DEV only properties.
503
- Object.defineProperty(element, '_self', {
504
- configurable: false,
505
- enumerable: false,
506
- writable: false,
507
- value: self
508
- });
509
- // Two elements created in two different places should be considered
510
- // equal for testing purposes and therefore we hide it from enumeration.
511
- Object.defineProperty(element, '_source', {
512
- configurable: false,
513
- enumerable: false,
514
- writable: false,
515
- value: source
516
- });
517
- } else {
518
- element._store.validated = false;
519
- element._self = self;
520
- element._source = source;
521
- }
513
+ Object.defineProperty(element._store, 'validated', {
514
+ configurable: false,
515
+ enumerable: false,
516
+ writable: true,
517
+ value: false
518
+ });
519
+ // self and source are DEV only properties.
520
+ Object.defineProperty(element, '_self', {
521
+ configurable: false,
522
+ enumerable: false,
523
+ writable: false,
524
+ value: self
525
+ });
526
+ // Two elements created in two different places should be considered
527
+ // equal for testing purposes and therefore we hide it from enumeration.
528
+ Object.defineProperty(element, '_source', {
529
+ configurable: false,
530
+ enumerable: false,
531
+ writable: false,
532
+ value: source
533
+ });
522
534
  if (Object.freeze) {
523
535
  Object.freeze(element.props);
524
536
  Object.freeze(element);
@@ -590,7 +602,7 @@ ReactElement.createElement = function (type, config, children) {
590
602
  }
591
603
  {
592
604
  if (key || ref) {
593
- if (typeof props.$$typeof === 'undefined' || props.$$typeof !== ReactElementSymbol) {
605
+ if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
594
606
  var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
595
607
  if (key) {
596
608
  defineKeyPropWarningGetter(props, displayName);
@@ -609,14 +621,14 @@ ReactElement.createElement = function (type, config, children) {
609
621
  * See https://facebook.github.io/react/docs/react-api.html#createfactory
610
622
  */
611
623
  ReactElement.createFactory = function (type) {
612
- var factory$$1 = ReactElement.createElement.bind(null, type);
624
+ var factory = ReactElement.createElement.bind(null, type);
613
625
  // Expose the type on the factory and the prototype so that it can be
614
626
  // easily accessed on elements. E.g. `<Foo />.type === Foo`.
615
627
  // This should not be named `constructor` since this may not be the function
616
628
  // that created the element, and it may not even be a constructor.
617
629
  // Legacy hook TODO: Warn if this is accessed
618
- factory$$1.type = type;
619
- return factory$$1;
630
+ factory.type = type;
631
+ return factory;
620
632
  };
621
633
 
622
634
  ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
@@ -699,7 +711,7 @@ ReactElement.cloneElement = function (element, config, children) {
699
711
  * @final
700
712
  */
701
713
  ReactElement.isValidElement = function (object) {
702
- return typeof object === 'object' && object !== null && object.$$typeof === ReactElementSymbol;
714
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
703
715
  };
704
716
 
705
717
  var ReactElement_1 = ReactElement;
@@ -712,37 +724,23 @@ var ReactElement_1 = ReactElement;
712
724
  * LICENSE file in the root directory of this source tree. An additional grant
713
725
  * of patent rights can be found in the PATENTS file in the same directory.
714
726
  *
715
- * @providesModule getIteratorFn
727
+ * @providesModule ReactTypeOfWork
716
728
  *
717
729
  */
718
730
 
719
- /* global Symbol */
720
-
721
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
722
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
723
-
724
- /**
725
- * Returns the iterator method function contained on the iterable object.
726
- *
727
- * Be sure to invoke the function with the iterable as context:
728
- *
729
- * var iteratorFn = getIteratorFn(myIterable);
730
- * if (iteratorFn) {
731
- * var iterator = iteratorFn.call(myIterable);
732
- * ...
733
- * }
734
- *
735
- * @param {?object} maybeIterable
736
- * @return {?function}
737
- */
738
- function getIteratorFn(maybeIterable) {
739
- var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
740
- if (typeof iteratorFn === 'function') {
741
- return iteratorFn;
742
- }
743
- }
744
-
745
- var getIteratorFn_1 = getIteratorFn;
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
+ };
746
744
 
747
745
  /**
748
746
  * Copyright 2013-present, Facebook, Inc.
@@ -752,818 +750,798 @@ var getIteratorFn_1 = getIteratorFn;
752
750
  * LICENSE file in the root directory of this source tree. An additional grant
753
751
  * of patent rights can be found in the PATENTS file in the same directory.
754
752
  *
755
- * @providesModule KeyEscapeUtils
753
+ * @providesModule getComponentName
756
754
  *
757
755
  */
758
756
 
759
- /**
760
- * Escape and wrap key so it is safe to use as a reactid
761
- *
762
- * @param {string} key to be escaped.
763
- * @return {string} the escaped key.
764
- */
757
+ function getComponentName(instanceOrFiber) {
758
+ if (typeof instanceOrFiber.getName === 'function') {
759
+ // Stack reconciler
760
+ var instance = instanceOrFiber;
761
+ return instance.getName();
762
+ }
763
+ if (typeof instanceOrFiber.tag === 'number') {
764
+ // Fiber reconciler
765
+ var fiber = instanceOrFiber;
766
+ var type = fiber.type;
765
767
 
766
- function escape(key) {
767
- var escapeRegex = /[=:]/g;
768
- var escaperLookup = {
769
- '=': '=0',
770
- ':': '=2'
771
- };
772
- var escapedString = ('' + key).replace(escapeRegex, function (match) {
773
- return escaperLookup[match];
774
- });
768
+ if (typeof type === 'string') {
769
+ return type;
770
+ }
771
+ if (typeof type === 'function') {
772
+ return type.displayName || type.name;
773
+ }
774
+ }
775
+ return null;
776
+ }
775
777
 
776
- return '$' + escapedString;
778
+ var getComponentName_1 = getComponentName;
779
+
780
+ var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent;
781
+ var FunctionalComponent = ReactTypeOfWork.FunctionalComponent;
782
+ var ClassComponent = ReactTypeOfWork.ClassComponent;
783
+ var HostComponent = ReactTypeOfWork.HostComponent;
784
+
785
+
786
+
787
+ function describeComponentFrame$1(name, source, ownerName) {
788
+ return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
777
789
  }
778
790
 
779
- /**
780
- * Unescape and unwrap key for human-readable display
781
- *
782
- * @param {string} key to unescape.
783
- * @return {string} the unescaped key.
784
- */
785
- function unescape(key) {
786
- var unescapeRegex = /(=0|=2)/g;
787
- var unescaperLookup = {
788
- '=0': '=',
789
- '=2': ':'
790
- };
791
- var keySubstring = key[0] === '.' && key[1] === '$' ? key.substring(2) : key.substring(1);
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);
803
+ }
804
+ return describeComponentFrame$1(name, source, ownerName);
805
+ default:
806
+ return '';
807
+ }
808
+ }
792
809
 
793
- return ('' + keySubstring).replace(unescapeRegex, function (match) {
794
- return unescaperLookup[match];
795
- });
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;
796
822
  }
797
823
 
798
- var KeyEscapeUtils = {
799
- escape: escape,
800
- unescape: unescape
824
+ var ReactFiberComponentTreeHook = {
825
+ getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$1,
826
+ describeComponentFrame: describeComponentFrame$1
801
827
  };
802
828
 
803
- var KeyEscapeUtils_1 = KeyEscapeUtils;
829
+ var getStackAddendumByWorkInProgressFiber = ReactFiberComponentTreeHook.getStackAddendumByWorkInProgressFiber;
830
+ var describeComponentFrame = ReactFiberComponentTreeHook.describeComponentFrame;
804
831
 
805
- var SEPARATOR = '.';
806
- var SUBSEPARATOR = ':';
807
832
 
808
- /**
809
- * This is inlined from ReactElement since this file is shared between
810
- * isomorphic and renderers. We could extract this to a
811
- *
812
- */
813
833
 
814
- /**
815
- * TODO: Test that a single child and an array with one item have the same key
816
- * pattern.
817
- */
818
834
 
819
- var didWarnAboutMaps = false;
820
835
 
821
- /**
822
- * Generate a key string that identifies a component within a set.
823
- *
824
- * @param {*} component A component that could contain a manual key.
825
- * @param {number} index Index that is used if a manual key is not provided.
826
- * @return {string}
827
- */
828
- function getComponentKey(component, index) {
829
- // Do some typechecking here since we call this blindly. We want to ensure
830
- // that we don't block potential future ES APIs.
831
- if (component && typeof component === 'object' && component.key != null) {
832
- // Explicit key
833
- return KeyEscapeUtils_1.escape(component.key);
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;
834
851
  }
835
- // Implicit key determined by the index in the set
836
- return index.toString(36);
837
852
  }
838
853
 
839
- /**
840
- * @param {?*} children Children tree container.
841
- * @param {!string} nameSoFar Name of the key path so far.
842
- * @param {!function} callback Callback to invoke with each child found.
843
- * @param {?*} traverseContext Used to pass information throughout the traversal
844
- * process.
845
- * @return {!number} The number of children in this subtree.
846
- */
847
- function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
848
- var type = typeof children;
849
-
850
- if (type === 'undefined' || type === 'boolean') {
851
- // All of the above are perceived as null.
852
- children = null;
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);
854
865
 
855
- if (children === null || type === 'string' || type === 'number' ||
856
- // The following is inlined from ReactElement. This means we can optimize
857
- // some checks. React Fiber also inlines this logic for similar purposes.
858
- type === 'object' && children.$$typeof === ReactElementSymbol) {
859
- callback(traverseContext, children,
860
- // If it's the only child, treat the name as if it was wrapped in an array
861
- // so that it's consistent if the number of children grows.
862
- nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
863
- return 1;
864
- }
866
+ var setItem;
867
+ var getItem;
868
+ var removeItem;
869
+ var getItemIDs;
870
+ var addRoot;
871
+ var removeRoot;
872
+ var getRootIDs;
865
873
 
866
- var child;
867
- var nextName;
868
- var subtreeCount = 0; // Count of children found in the current subtree.
869
- var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
874
+ if (canUseCollections) {
875
+ var itemMap = new Map();
876
+ var rootIDSet = new Set();
870
877
 
871
- if (Array.isArray(children)) {
872
- for (var i = 0; i < children.length; i++) {
873
- child = children[i];
874
- nextName = nextNamePrefix + getComponentKey(child, i);
875
- subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
876
- }
877
- } else {
878
- var iteratorFn = getIteratorFn_1(children);
879
- if (iteratorFn) {
880
- {
881
- // Warn about using Maps as children
882
- if (iteratorFn === children.entries) {
883
- var mapsAsChildrenAddendum = '';
884
- if (ReactCurrentOwner_1.current) {
885
- var mapsAsChildrenOwnerName = ReactCurrentOwner_1.current.getName();
886
- if (mapsAsChildrenOwnerName) {
887
- mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';
888
- }
889
- }
890
- 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', mapsAsChildrenAddendum);
891
- didWarnAboutMaps = true;
892
- }
893
- }
894
-
895
- var iterator = iteratorFn.call(children);
896
- var step;
897
- var ii = 0;
898
- while (!(step = iterator.next()).done) {
899
- child = step.value;
900
- nextName = nextNamePrefix + getComponentKey(child, ii++);
901
- subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
902
- }
903
- } else if (type === 'object') {
904
- var addendum = '';
905
- {
906
- addendum = ' If you meant to render a collection of children, use an array ' + 'instead.';
907
- if (ReactCurrentOwner_1.current) {
908
- var name = ReactCurrentOwner_1.current.getName();
909
- if (name) {
910
- addendum += '\n\nCheck the render method of `' + name + '`.';
911
- }
912
- }
913
- }
914
- var childrenString = '' + children;
915
- 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);
916
- }
917
- }
918
-
919
- return subtreeCount;
920
- }
921
-
922
- /**
923
- * Traverses children that are typically specified as `props.children`, but
924
- * might also be specified through attributes:
925
- *
926
- * - `traverseAllChildren(this.props.children, ...)`
927
- * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
928
- *
929
- * The `traverseContext` is an optional argument that is passed through the
930
- * entire traversal. It can be used to store accumulations or anything else that
931
- * the callback might find relevant.
932
- *
933
- * @param {?*} children Children tree object.
934
- * @param {!function} callback To invoke upon traversing each child.
935
- * @param {?*} traverseContext Context for traversal.
936
- * @return {!number} The number of children in this subtree.
937
- */
938
- function traverseAllChildren(children, callback, traverseContext) {
939
- if (children == null) {
940
- return 0;
941
- }
942
-
943
- return traverseAllChildrenImpl(children, '', callback, traverseContext);
944
- }
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
+ };
945
890
 
946
- var traverseAllChildren_1 = traverseAllChildren;
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 = {};
947
903
 
948
- var twoArgumentPooler = PooledClass_1.twoArgumentPooler;
949
- var fourArgumentPooler = PooledClass_1.fourArgumentPooler;
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
+ };
950
912
 
951
- var userProvidedKeyEscapeRegex = /\/+/g;
952
- function escapeUserProvidedKey(text) {
953
- return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
954
- }
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
+ };
955
928
 
956
- /**
957
- * PooledClass representing the bookkeeping associated with performing a child
958
- * traversal. Allows avoiding binding callbacks.
959
- *
960
- * @constructor ForEachBookKeeping
961
- * @param {!function} forEachFunction Function to perform traversal with.
962
- * @param {?*} forEachContext Context to perform context with.
963
- */
964
- function ForEachBookKeeping(forEachFunction, forEachContext) {
965
- this.func = forEachFunction;
966
- this.context = forEachContext;
967
- this.count = 0;
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
+ };
968
940
  }
969
- ForEachBookKeeping.prototype.destructor = function () {
970
- this.func = null;
971
- this.context = null;
972
- this.count = 0;
973
- };
974
- PooledClass_1.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
975
941
 
976
- function forEachSingleChild(bookKeeping, child, name) {
977
- var func = bookKeeping.func,
978
- context = bookKeeping.context;
942
+ var unmountedIDs = [];
979
943
 
980
- func.call(context, child, bookKeeping.count++);
981
- }
944
+ function purgeDeep(id) {
945
+ var item = getItem(id);
946
+ if (item) {
947
+ var childIDs = item.childIDs;
982
948
 
983
- /**
984
- * Iterates through children that are typically specified as `props.children`.
985
- *
986
- * See https://facebook.github.io/react/docs/react-api.html#react.children.foreach
987
- *
988
- * The provided forEachFunc(child, index) will be called for each
989
- * leaf child.
990
- *
991
- * @param {?*} children Children tree container.
992
- * @param {function(*, int)} forEachFunc
993
- * @param {*} forEachContext Context for forEachContext.
994
- */
995
- function forEachChildren(children, forEachFunc, forEachContext) {
996
- if (children == null) {
997
- return children;
949
+ removeItem(id);
950
+ childIDs.forEach(purgeDeep);
998
951
  }
999
- var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
1000
- traverseAllChildren_1(children, forEachSingleChild, traverseContext);
1001
- ForEachBookKeeping.release(traverseContext);
1002
- }
1003
-
1004
- /**
1005
- * PooledClass representing the bookkeeping associated with performing a child
1006
- * mapping. Allows avoiding binding callbacks.
1007
- *
1008
- * @constructor MapBookKeeping
1009
- * @param {!*} mapResult Object containing the ordered map of results.
1010
- * @param {!function} mapFunction Function to perform mapping with.
1011
- * @param {?*} mapContext Context to perform mapping with.
1012
- */
1013
- function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
1014
- this.result = mapResult;
1015
- this.keyPrefix = keyPrefix;
1016
- this.func = mapFunction;
1017
- this.context = mapContext;
1018
- this.count = 0;
1019
952
  }
1020
- MapBookKeeping.prototype.destructor = function () {
1021
- this.result = null;
1022
- this.keyPrefix = null;
1023
- this.func = null;
1024
- this.context = null;
1025
- this.count = 0;
1026
- };
1027
- PooledClass_1.addPoolingTo(MapBookKeeping, fourArgumentPooler);
1028
-
1029
- function mapSingleChildIntoContext(bookKeeping, child, childKey) {
1030
- var result = bookKeeping.result,
1031
- keyPrefix = bookKeeping.keyPrefix,
1032
- func = bookKeeping.func,
1033
- context = bookKeeping.context;
1034
-
1035
953
 
1036
- var mappedChild = func.call(context, child, bookKeeping.count++);
1037
- if (Array.isArray(mappedChild)) {
1038
- mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
1039
- } else if (mappedChild != null) {
1040
- if (ReactElement_1.isValidElement(mappedChild)) {
1041
- mappedChild = ReactElement_1.cloneAndReplaceKey(mappedChild,
1042
- // Keep both the (mapped) and old keys if they differ, just as
1043
- // traverseAllChildren used to do for objects as children
1044
- keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
1045
- }
1046
- result.push(mappedChild);
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';
1047
963
  }
1048
964
  }
1049
965
 
1050
- function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1051
- var escapedPrefix = '';
1052
- if (prefix != null) {
1053
- escapedPrefix = escapeUserProvidedKey(prefix) + '/';
1054
- }
1055
- var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
1056
- traverseAllChildren_1(children, mapSingleChildIntoContext, traverseContext);
1057
- MapBookKeeping.release(traverseContext);
1058
- }
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;
1059
971
 
1060
- /**
1061
- * Maps children that are typically specified as `props.children`.
1062
- *
1063
- * See https://facebook.github.io/react/docs/react-api.html#react.children.map
1064
- *
1065
- * The provided mapFunction(child, key, index) will be called for each
1066
- * leaf child.
1067
- *
1068
- * @param {?*} children Children tree container.
1069
- * @param {function(*, int)} func The map function.
1070
- * @param {*} context Context for mapFunction.
1071
- * @return {object} Object containing the ordered map of results.
1072
- */
1073
- function mapChildren(children, func, context) {
1074
- if (children == null) {
1075
- return children;
972
+ if (ownerID) {
973
+ ownerName = ReactComponentTreeHook.getDisplayName(ownerID);
1076
974
  }
1077
- var result = [];
1078
- mapIntoWithKeyPrefixInternal(children, result, null, func, context);
1079
- return result;
975
+ warning(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id);
976
+ return describeComponentFrame(name || '', element && element._source, ownerName || '');
1080
977
  }
1081
978
 
1082
- function forEachSingleChildDummy(traverseContext, child, name) {
1083
- return null;
1084
- }
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;
1085
984
 
1086
- /**
1087
- * Count the number of children that are typically specified as
1088
- * `props.children`.
1089
- *
1090
- * See https://facebook.github.io/react/docs/react-api.html#react.children.count
1091
- *
1092
- * @param {?*} children Children tree container.
1093
- * @return {number} The number of children.
1094
- */
1095
- function countChildren(children, context) {
1096
- return traverseAllChildren_1(children, forEachSingleChildDummy, null);
1097
- }
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
+ }
1098
1059
 
1099
- /**
1100
- * Flatten a children object (typically specified as `props.children`) and
1101
- * return an array with appropriately re-keyed children.
1102
- *
1103
- * See https://facebook.github.io/react/docs/react-api.html#react.children.toarray
1104
- */
1105
- function toArray(children) {
1106
- var result = [];
1107
- mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
1108
- return result;
1109
- }
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
+ }
1110
1077
 
1111
- var ReactChildren = {
1112
- forEach: forEachChildren,
1113
- map: mapChildren,
1114
- mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
1115
- count: countChildren,
1116
- toArray: toArray
1117
- };
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
+ },
1118
1145
 
1119
- var ReactChildren_1 = ReactChildren;
1120
1146
 
1121
- /**
1122
- * Copyright 2013-present, Facebook, Inc.
1123
- * All rights reserved.
1124
- *
1125
- * This source code is licensed under the BSD-style license found in the
1126
- * LICENSE file in the root directory of this source tree. An additional grant
1127
- * of patent rights can be found in the PATENTS file in the same directory.
1128
- *
1129
- * @providesModule getComponentName
1130
- *
1131
- */
1147
+ getRootIDs: getRootIDs,
1148
+ getRegisteredIDs: getItemIDs
1149
+ };
1132
1150
 
1133
- function getComponentName(instanceOrFiber) {
1134
- if (typeof instanceOrFiber.getName === 'function') {
1135
- // Stack reconciler
1136
- var instance = instanceOrFiber;
1137
- return instance.getName();
1138
- }
1139
- if (typeof instanceOrFiber.tag === 'number') {
1140
- // Fiber reconciler
1141
- var fiber = instanceOrFiber;
1142
- var type = fiber.type;
1151
+ var ReactComponentTreeHook_1 = ReactComponentTreeHook;
1143
1152
 
1144
- if (typeof type === 'string') {
1145
- return type;
1146
- }
1147
- if (typeof type === 'function') {
1148
- return type.displayName || type.name;
1149
- }
1150
- }
1151
- return null;
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;
1153
1158
 
1154
- var getComponentName_1 = getComponentName;
1159
+ {
1160
+ var _require = ReactComponentTreeHook_1,
1161
+ getCurrentStackAddendum = _require.getCurrentStackAddendum;
1162
+ }
1155
1163
 
1156
- var checkPropTypes$2 = checkPropTypes;
1164
+ var SEPARATOR = '.';
1165
+ var SUBSEPARATOR = ':';
1157
1166
 
1158
1167
  /**
1159
- * Copyright 2013-present, Facebook, Inc.
1160
- * All rights reserved.
1161
- *
1162
- * This source code is licensed under the BSD-style license found in the
1163
- * LICENSE file in the root directory of this source tree. An additional grant
1164
- * of patent rights can be found in the PATENTS file in the same directory.
1168
+ * Escape and wrap key so it is safe to use as a reactid
1165
1169
  *
1166
- * @providesModule ReactTypeOfWork
1167
- *
1170
+ * @param {string} key to be escaped.
1171
+ * @return {string} the escaped key.
1168
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
+ });
1169
1182
 
1170
- var ReactTypeOfWork = {
1171
- IndeterminateComponent: 0, // Before we know whether it is functional or class
1172
- FunctionalComponent: 1,
1173
- ClassComponent: 2,
1174
- HostRoot: 3, // Root of a host tree. Could be nested inside another node.
1175
- HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
1176
- HostComponent: 5,
1177
- HostText: 6,
1178
- CoroutineComponent: 7,
1179
- CoroutineHandlerPhase: 8,
1180
- YieldComponent: 9,
1181
- Fragment: 10
1182
- };
1183
-
1184
- var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent;
1185
- var FunctionalComponent = ReactTypeOfWork.FunctionalComponent;
1186
- var ClassComponent = ReactTypeOfWork.ClassComponent;
1187
- var HostComponent = ReactTypeOfWork.HostComponent;
1188
-
1189
-
1190
-
1191
- function describeComponentFrame$1(name, source, ownerName) {
1192
- return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
1183
+ return '$' + escapedString;
1193
1184
  }
1194
1185
 
1195
- function describeFiber(fiber) {
1196
- switch (fiber.tag) {
1197
- case IndeterminateComponent:
1198
- case FunctionalComponent:
1199
- case ClassComponent:
1200
- case HostComponent:
1201
- var owner = fiber._debugOwner;
1202
- var source = fiber._debugSource;
1203
- var name = getComponentName_1(fiber);
1204
- var ownerName = null;
1205
- if (owner) {
1206
- ownerName = getComponentName_1(owner);
1207
- }
1208
- return describeComponentFrame$1(name, source, ownerName);
1209
- default:
1210
- return '';
1211
- }
1212
- }
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);
1213
1201
 
1214
- // This function can only be called with a work-in-progress fiber and
1215
- // only during begin or complete phase. Do not call it under any other
1216
- // circumstances.
1217
- function getStackAddendumByWorkInProgressFiber$2(workInProgress) {
1218
- var info = '';
1219
- var node = workInProgress;
1220
- do {
1221
- info += describeFiber(node);
1222
- // Otherwise this return pointer might point to the wrong tree:
1223
- node = node['return'];
1224
- } while (node);
1225
- return info;
1202
+ return ('' + keySubstring).replace(unescapeRegex, function (match) {
1203
+ return unescaperLookup[match];
1204
+ });
1205
+ };
1226
1206
  }
1227
1207
 
1228
- var ReactFiberComponentTreeHook = {
1229
- getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$2,
1230
- describeComponentFrame: describeComponentFrame$1
1231
- };
1232
-
1233
- var getStackAddendumByWorkInProgressFiber$1 = ReactFiberComponentTreeHook.getStackAddendumByWorkInProgressFiber;
1234
- var describeComponentFrame = ReactFiberComponentTreeHook.describeComponentFrame;
1208
+ /**
1209
+ * TODO: Test that a single child and an array with one item have the same key
1210
+ * pattern.
1211
+ */
1235
1212
 
1213
+ var didWarnAboutMaps = false;
1236
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
+ }
1237
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;
1238
1243
 
1244
+ if (type === 'undefined' || type === 'boolean') {
1245
+ // All of the above are perceived as null.
1246
+ children = null;
1247
+ }
1239
1248
 
1240
- function isNative(fn) {
1241
- // Based on isNative() from Lodash
1242
- var funcToString = Function.prototype.toString;
1243
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1244
- var reIsNative = RegExp('^' + funcToString
1245
- // Take an example native function source for comparison
1246
- .call(hasOwnProperty)
1247
- // Strip regex characters so we can use it for regex
1248
- .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
1249
- // Remove hasOwnProperty from the template to make it generic
1250
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
1251
- try {
1252
- var source = funcToString.call(fn);
1253
- return reIsNative.test(source);
1254
- } catch (err) {
1255
- return false;
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;
1256
1258
  }
1257
- }
1258
1259
 
1259
- var canUseCollections =
1260
- // Array.from
1261
- typeof Array.from === 'function' &&
1262
- // Map
1263
- typeof Map === 'function' && isNative(Map) &&
1264
- // Map.prototype.keys
1265
- Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) &&
1266
- // Set
1267
- typeof Set === 'function' && isNative(Set) &&
1268
- // Set.prototype.keys
1269
- Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys);
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;
1270
1264
 
1271
- var setItem;
1272
- var getItem;
1273
- var removeItem;
1274
- var getItemIDs;
1275
- var addRoot;
1276
- var removeRoot;
1277
- var getRootIDs;
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
+ }
1278
1281
 
1279
- if (canUseCollections) {
1280
- var itemMap = new Map();
1281
- var rootIDSet = new Set();
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
+ }
1282
1299
 
1283
- setItem = function (id, item) {
1284
- itemMap.set(id, item);
1285
- };
1286
- getItem = function (id) {
1287
- return itemMap.get(id);
1288
- };
1289
- removeItem = function (id) {
1290
- itemMap['delete'](id);
1291
- };
1292
- getItemIDs = function () {
1293
- return Array.from(itemMap.keys());
1294
- };
1300
+ return subtreeCount;
1301
+ }
1295
1302
 
1296
- addRoot = function (id) {
1297
- rootIDSet.add(id);
1298
- };
1299
- removeRoot = function (id) {
1300
- rootIDSet['delete'](id);
1301
- };
1302
- getRootIDs = function () {
1303
- return Array.from(rootIDSet.keys());
1304
- };
1305
- } else {
1306
- var itemByKey = {};
1307
- var rootByKey = {};
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
+ }
1308
1323
 
1309
- // Use non-numeric keys to prevent V8 performance issues:
1310
- // https://github.com/facebook/react/pull/7232
1311
- var getKeyFromID = function (id) {
1312
- return '.' + id;
1313
- };
1314
- var getIDFromKey = function (key) {
1315
- return parseInt(key.substr(1), 10);
1316
- };
1324
+ return traverseAllChildrenImpl(children, '', callback, traverseContext);
1325
+ }
1317
1326
 
1318
- setItem = function (id, item) {
1319
- var key = getKeyFromID(id);
1320
- itemByKey[key] = item;
1321
- };
1322
- getItem = function (id) {
1323
- var key = getKeyFromID(id);
1324
- return itemByKey[key];
1325
- };
1326
- removeItem = function (id) {
1327
- var key = getKeyFromID(id);
1328
- delete itemByKey[key];
1329
- };
1330
- getItemIDs = function () {
1331
- return Object.keys(itemByKey).map(getIDFromKey);
1332
- };
1327
+ var traverseAllChildren_1 = traverseAllChildren;
1333
1328
 
1334
- addRoot = function (id) {
1335
- var key = getKeyFromID(id);
1336
- rootByKey[key] = true;
1337
- };
1338
- removeRoot = function (id) {
1339
- var key = getKeyFromID(id);
1340
- delete rootByKey[key];
1341
- };
1342
- getRootIDs = function () {
1343
- return Object.keys(rootByKey).map(getIDFromKey);
1344
- };
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, '$&/');
1345
1335
  }
1346
1336
 
1347
- var unmountedIDs = [];
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);
1348
1356
 
1349
- function purgeDeep(id) {
1350
- var item = getItem(id);
1351
- if (item) {
1352
- var childIDs = item.childIDs;
1357
+ function forEachSingleChild(bookKeeping, child, name) {
1358
+ var func = bookKeeping.func,
1359
+ context = bookKeeping.context;
1353
1360
 
1354
- removeItem(id);
1355
- childIDs.forEach(purgeDeep);
1356
- }
1361
+ func.call(context, child, bookKeeping.count++);
1357
1362
  }
1358
1363
 
1359
- function getDisplayName(element) {
1360
- if (element == null) {
1361
- return '#empty';
1362
- } else if (typeof element === 'string' || typeof element === 'number') {
1363
- return '#text';
1364
- } else if (typeof element.type === 'string') {
1365
- return element.type;
1366
- } else {
1367
- return element.type.displayName || element.type.name || 'Unknown';
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;
1368
1379
  }
1380
+ var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
1381
+ traverseAllChildren_1(children, forEachSingleChild, traverseContext);
1382
+ ForEachBookKeeping.release(traverseContext);
1369
1383
  }
1370
1384
 
1371
- function describeID(id) {
1372
- var name = ReactComponentTreeHook.getDisplayName(id);
1373
- var element = ReactComponentTreeHook.getElement(id);
1374
- var ownerID = ReactComponentTreeHook.getOwnerID(id);
1375
- var ownerName = void 0;
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);
1376
1409
 
1377
- if (ownerID) {
1378
- ownerName = ReactComponentTreeHook.getDisplayName(ownerID);
1410
+ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
1411
+ var result = bookKeeping.result,
1412
+ keyPrefix = bookKeeping.keyPrefix,
1413
+ func = bookKeeping.func,
1414
+ context = bookKeeping.context;
1415
+
1416
+
1417
+ var mappedChild = func.call(context, child, bookKeeping.count++);
1418
+ if (Array.isArray(mappedChild)) {
1419
+ mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
1420
+ } else if (mappedChild != null) {
1421
+ if (ReactElement_1.isValidElement(mappedChild)) {
1422
+ mappedChild = ReactElement_1.cloneAndReplaceKey(mappedChild,
1423
+ // Keep both the (mapped) and old keys if they differ, just as
1424
+ // traverseAllChildren used to do for objects as children
1425
+ keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
1426
+ }
1427
+ result.push(mappedChild);
1379
1428
  }
1380
- warning(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id);
1381
- return describeComponentFrame(name || '', element && element._source, ownerName || '');
1382
1429
  }
1383
1430
 
1384
- var ReactComponentTreeHook = {
1385
- onSetChildren: function (id, nextChildIDs) {
1386
- var item = getItem(id);
1387
- invariant(item, 'Item must have been set');
1388
- item.childIDs = nextChildIDs;
1431
+ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1432
+ var escapedPrefix = '';
1433
+ if (prefix != null) {
1434
+ escapedPrefix = escapeUserProvidedKey(prefix) + '/';
1435
+ }
1436
+ var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
1437
+ traverseAllChildren_1(children, mapSingleChildIntoContext, traverseContext);
1438
+ MapBookKeeping.release(traverseContext);
1439
+ }
1389
1440
 
1390
- for (var i = 0; i < nextChildIDs.length; i++) {
1391
- var nextChildID = nextChildIDs[i];
1392
- var nextChild = getItem(nextChildID);
1393
- !nextChild ? invariant(false, 'Expected hook events to fire for the child before its parent includes it in onSetChildren().') : void 0;
1394
- !(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;
1395
- !nextChild.isMounted ? invariant(false, 'Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().') : void 0;
1396
- if (nextChild.parentID == null) {
1397
- nextChild.parentID = id;
1398
- // TODO: This shouldn't be necessary but mounting a new root during in
1399
- // componentWillMount currently causes not-yet-mounted components to
1400
- // be purged from our tree data so their parent id is missing.
1401
- }
1402
- !(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;
1403
- }
1404
- },
1405
- onBeforeMountComponent: function (id, element, parentID) {
1406
- var item = {
1407
- element: element,
1408
- parentID: parentID,
1409
- text: null,
1410
- childIDs: [],
1411
- isMounted: false,
1412
- updateCount: 0
1413
- };
1414
- setItem(id, item);
1415
- },
1416
- onBeforeUpdateComponent: function (id, element) {
1417
- var item = getItem(id);
1418
- if (!item || !item.isMounted) {
1419
- // We may end up here as a result of setState() in componentWillUnmount().
1420
- // In this case, ignore the element.
1421
- return;
1422
- }
1423
- item.element = element;
1424
- },
1425
- onMountComponent: function (id) {
1426
- var item = getItem(id);
1427
- invariant(item, 'Item must have been set');
1428
- item.isMounted = true;
1429
- var isRoot = item.parentID === 0;
1430
- if (isRoot) {
1431
- addRoot(id);
1432
- }
1433
- },
1434
- onUpdateComponent: function (id) {
1435
- var item = getItem(id);
1436
- if (!item || !item.isMounted) {
1437
- // We may end up here as a result of setState() in componentWillUnmount().
1438
- // In this case, ignore the element.
1439
- return;
1440
- }
1441
- item.updateCount++;
1442
- },
1443
- onUnmountComponent: function (id) {
1444
- var item = getItem(id);
1445
- if (item) {
1446
- // We need to check if it exists.
1447
- // `item` might not exist if it is inside an error boundary, and a sibling
1448
- // error boundary child threw while mounting. Then this instance never
1449
- // got a chance to mount, but it still gets an unmounting event during
1450
- // the error boundary cleanup.
1451
- item.isMounted = false;
1452
- var isRoot = item.parentID === 0;
1453
- if (isRoot) {
1454
- removeRoot(id);
1455
- }
1456
- }
1457
- unmountedIDs.push(id);
1458
- },
1459
- purgeUnmountedComponents: function () {
1460
- if (ReactComponentTreeHook._preventPurging) {
1461
- // Should only be used for testing.
1462
- return;
1463
- }
1441
+ /**
1442
+ * Maps children that are typically specified as `props.children`.
1443
+ *
1444
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.map
1445
+ *
1446
+ * The provided mapFunction(child, key, index) will be called for each
1447
+ * leaf child.
1448
+ *
1449
+ * @param {?*} children Children tree container.
1450
+ * @param {function(*, int)} func The map function.
1451
+ * @param {*} context Context for mapFunction.
1452
+ * @return {object} Object containing the ordered map of results.
1453
+ */
1454
+ function mapChildren(children, func, context) {
1455
+ if (children == null) {
1456
+ return children;
1457
+ }
1458
+ var result = [];
1459
+ mapIntoWithKeyPrefixInternal(children, result, null, func, context);
1460
+ return result;
1461
+ }
1464
1462
 
1465
- for (var i = 0; i < unmountedIDs.length; i++) {
1466
- var id = unmountedIDs[i];
1467
- purgeDeep(id);
1468
- }
1469
- unmountedIDs.length = 0;
1470
- },
1471
- isMounted: function (id) {
1472
- var item = getItem(id);
1473
- return item ? item.isMounted : false;
1474
- },
1475
- getCurrentStackAddendum: function (topElement) {
1476
- var info = '';
1477
- if (topElement) {
1478
- var name = getDisplayName(topElement);
1479
- var owner = topElement._owner;
1480
- info += describeComponentFrame(name, topElement._source, owner && getComponentName_1(owner));
1481
- }
1463
+ function forEachSingleChildDummy(traverseContext, child, name) {
1464
+ return null;
1465
+ }
1482
1466
 
1483
- var currentOwner = ReactCurrentOwner_1.current;
1484
- if (currentOwner) {
1485
- if (typeof currentOwner.tag === 'number') {
1486
- var workInProgress = currentOwner;
1487
- // Safe because if current owner exists, we are reconciling,
1488
- // and it is guaranteed to be the work-in-progress version.
1489
- info += getStackAddendumByWorkInProgressFiber$1(workInProgress);
1490
- } else if (typeof currentOwner._debugID === 'number') {
1491
- info += ReactComponentTreeHook.getStackAddendumByID(currentOwner._debugID);
1492
- }
1493
- }
1494
- return info;
1495
- },
1496
- getStackAddendumByID: function (id) {
1497
- var info = '';
1498
- while (id) {
1499
- info += describeID(id);
1500
- id = ReactComponentTreeHook.getParentID(id);
1501
- }
1502
- return info;
1503
- },
1504
- getChildIDs: function (id) {
1505
- var item = getItem(id);
1506
- return item ? item.childIDs : [];
1507
- },
1508
- getDisplayName: function (id) {
1509
- var element = ReactComponentTreeHook.getElement(id);
1510
- if (!element) {
1511
- return null;
1512
- }
1513
- return getDisplayName(element);
1514
- },
1515
- getElement: function (id) {
1516
- var item = getItem(id);
1517
- return item ? item.element : null;
1518
- },
1519
- getOwnerID: function (id) {
1520
- var element = ReactComponentTreeHook.getElement(id);
1521
- if (!element || !element._owner) {
1522
- return null;
1523
- }
1524
- return element._owner._debugID;
1525
- },
1526
- getParentID: function (id) {
1527
- var item = getItem(id);
1528
- return item ? item.parentID : null;
1529
- },
1530
- getSource: function (id) {
1531
- var item = getItem(id);
1532
- var element = item ? item.element : null;
1533
- var source = element != null ? element._source : null;
1534
- return source;
1535
- },
1536
- getText: function (id) {
1537
- var element = ReactComponentTreeHook.getElement(id);
1538
- if (typeof element === 'string') {
1539
- return element;
1540
- } else if (typeof element === 'number') {
1541
- return '' + element;
1542
- } else {
1543
- return null;
1544
- }
1545
- },
1546
- getUpdateCount: function (id) {
1547
- var item = getItem(id);
1548
- return item ? item.updateCount : 0;
1549
- },
1467
+ /**
1468
+ * Count the number of children that are typically specified as
1469
+ * `props.children`.
1470
+ *
1471
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.count
1472
+ *
1473
+ * @param {?*} children Children tree container.
1474
+ * @return {number} The number of children.
1475
+ */
1476
+ function countChildren(children, context) {
1477
+ return traverseAllChildren_1(children, forEachSingleChildDummy, null);
1478
+ }
1550
1479
 
1480
+ /**
1481
+ * Flatten a children object (typically specified as `props.children`) and
1482
+ * return an array with appropriately re-keyed children.
1483
+ *
1484
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.toarray
1485
+ */
1486
+ function toArray(children) {
1487
+ var result = [];
1488
+ mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
1489
+ return result;
1490
+ }
1551
1491
 
1552
- getRootIDs: getRootIDs,
1553
- getRegisteredIDs: getItemIDs
1492
+ var ReactChildren = {
1493
+ forEach: forEachChildren,
1494
+ map: mapChildren,
1495
+ mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
1496
+ count: countChildren,
1497
+ toArray: toArray
1554
1498
  };
1555
1499
 
1556
- var ReactComponentTreeHook_1 = ReactComponentTreeHook;
1500
+ var ReactChildren_1 = ReactChildren;
1501
+
1502
+ /**
1503
+ * Copyright 2013-present, Facebook, Inc.
1504
+ * All rights reserved.
1505
+ *
1506
+ * This source code is licensed under the BSD-style license found in the
1507
+ * LICENSE file in the root directory of this source tree. An additional grant
1508
+ * of patent rights can be found in the PATENTS file in the same directory.
1509
+ *
1510
+ * @providesModule ReactVersion
1511
+ */
1512
+
1513
+ var ReactVersion = '16.0.0-alpha.13';
1514
+
1515
+ /**
1516
+ * Returns the first child in a collection of children and verifies that there
1517
+ * is only one child in the collection.
1518
+ *
1519
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.only
1520
+ *
1521
+ * The current implementation of this function assumes that a single child gets
1522
+ * passed without a wrapper, but the purpose of this helper function is to
1523
+ * abstract away the particular structure of children.
1524
+ *
1525
+ * @param {?object} children Child collection structure.
1526
+ * @return {ReactElement} The first and only `ReactElement` contained in the
1527
+ * structure.
1528
+ */
1529
+ function onlyChild(children) {
1530
+ !ReactElement_1.isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
1531
+ return children;
1532
+ }
1533
+
1534
+ var onlyChild_1 = onlyChild;
1557
1535
 
1558
1536
  var ReactDebugCurrentFrame$1 = {};
1559
1537
 
1560
1538
  {
1561
- var _require$1 = ReactComponentTreeHook_1,
1562
- getStackAddendumByID = _require$1.getStackAddendumByID,
1563
- getCurrentStackAddendum$1 = _require$1.getCurrentStackAddendum;
1539
+ var _require$2 = ReactComponentTreeHook_1,
1540
+ getStackAddendumByID = _require$2.getStackAddendumByID,
1541
+ getCurrentStackAddendum$2 = _require$2.getCurrentStackAddendum;
1564
1542
 
1565
- var _require2$1 = ReactFiberComponentTreeHook,
1566
- getStackAddendumByWorkInProgressFiber = _require2$1.getStackAddendumByWorkInProgressFiber;
1543
+ var _require2 = ReactFiberComponentTreeHook,
1544
+ getStackAddendumByWorkInProgressFiber$2 = _require2.getStackAddendumByWorkInProgressFiber;
1567
1545
 
1568
1546
  // Component that is being worked on
1569
1547
 
@@ -1587,10 +1565,10 @@ var ReactDebugCurrentFrame$1 = {};
1587
1565
  // The stack will only be correct if this is a work in progress
1588
1566
  // version and we're calling it during reconciliation.
1589
1567
  var workInProgress = current;
1590
- stack = getStackAddendumByWorkInProgressFiber(workInProgress);
1568
+ stack = getStackAddendumByWorkInProgressFiber$2(workInProgress);
1591
1569
  }
1592
1570
  } else if (element !== null) {
1593
- stack = getCurrentStackAddendum$1(element);
1571
+ stack = getCurrentStackAddendum$2(element);
1594
1572
  }
1595
1573
  return stack;
1596
1574
  };
@@ -1599,14 +1577,18 @@ var ReactDebugCurrentFrame$1 = {};
1599
1577
  var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame$1;
1600
1578
 
1601
1579
  {
1602
- var checkPropTypes$1 = checkPropTypes$2;
1603
- var warning$3 = warning;
1580
+ var checkPropTypes$1 = checkPropTypes;
1581
+ var lowPriorityWarning$1 = lowPriorityWarning_1;
1604
1582
  var ReactDebugCurrentFrame = ReactDebugCurrentFrame_1;
1583
+ var warning$1 = warning;
1605
1584
 
1606
- var _require = ReactComponentTreeHook_1,
1607
- getCurrentStackAddendum = _require.getCurrentStackAddendum;
1585
+ var _require$1 = ReactComponentTreeHook_1,
1586
+ getCurrentStackAddendum$1 = _require$1.getCurrentStackAddendum;
1608
1587
  }
1609
1588
 
1589
+ var ITERATOR_SYMBOL$1 = typeof Symbol === 'function' && Symbol.iterator;
1590
+ var FAUX_ITERATOR_SYMBOL$1 = '@@iterator'; // Before Symbol spec.
1591
+
1610
1592
  function getDeclarationErrorAddendum() {
1611
1593
  if (ReactCurrentOwner_1.current) {
1612
1594
  var name = getComponentName_1(ReactCurrentOwner_1.current);
@@ -1663,13 +1645,11 @@ function validateExplicitKey(element, parentType) {
1663
1645
  }
1664
1646
  element._store.validated = true;
1665
1647
 
1666
- var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {});
1667
-
1668
1648
  var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1669
- if (memoizer[currentComponentErrorInfo]) {
1649
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1670
1650
  return;
1671
1651
  }
1672
- memoizer[currentComponentErrorInfo] = true;
1652
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
1673
1653
 
1674
1654
  // Usually the current owner is the offender, but if it accepts children as a
1675
1655
  // property, it may be the creator of the child that's responsible for
@@ -1680,7 +1660,7 @@ function validateExplicitKey(element, parentType) {
1680
1660
  childOwner = ' It was passed a child from ' + getComponentName_1(element._owner) + '.';
1681
1661
  }
1682
1662
 
1683
- 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, getCurrentStackAddendum(element));
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));
1684
1664
  }
1685
1665
 
1686
1666
  /**
@@ -1709,9 +1689,10 @@ function validateChildKeys(node, parentType) {
1709
1689
  node._store.validated = true;
1710
1690
  }
1711
1691
  } else if (node) {
1712
- var iteratorFn = getIteratorFn_1(node);
1713
- // Entry iterators provide implicit keys.
1714
- if (iteratorFn) {
1692
+ var iteratorFn = ITERATOR_SYMBOL$1 && node[ITERATOR_SYMBOL$1] || node[FAUX_ITERATOR_SYMBOL$1];
1693
+ if (typeof iteratorFn === 'function') {
1694
+ // Entry iterators used to provide implicit keys,
1695
+ // but now we print a separate warning for them later.
1715
1696
  if (iteratorFn !== node.entries) {
1716
1697
  var iterator = iteratorFn.call(node);
1717
1698
  var step;
@@ -1749,11 +1730,11 @@ function validatePropTypes(element) {
1749
1730
  checkPropTypes$1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
1750
1731
  }
1751
1732
  if (typeof componentClass.getDefaultProps === 'function') {
1752
- warning$3(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1733
+ warning$1(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1753
1734
  }
1754
1735
  }
1755
1736
 
1756
- var ReactElementValidator$2 = {
1737
+ var ReactElementValidator$1 = {
1757
1738
  createElement: function (type, props, children) {
1758
1739
  var validType = typeof type === 'string' || typeof type === 'function';
1759
1740
  // We warn in this case but don't throw. We expect the element creation to
@@ -1771,9 +1752,9 @@ var ReactElementValidator$2 = {
1771
1752
  info += getDeclarationErrorAddendum();
1772
1753
  }
1773
1754
 
1774
- info += getCurrentStackAddendum();
1755
+ info += getCurrentStackAddendum$1();
1775
1756
 
1776
- 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);
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);
1777
1758
  }
1778
1759
 
1779
1760
  var element = ReactElement_1.createElement.apply(this, arguments);
@@ -1809,23 +1790,21 @@ var ReactElementValidator$2 = {
1809
1790
  },
1810
1791
 
1811
1792
  createFactory: function (type) {
1812
- var validatedFactory = ReactElementValidator$2.createElement.bind(null, type);
1793
+ var validatedFactory = ReactElementValidator$1.createElement.bind(null, type);
1813
1794
  // Legacy hook TODO: Warn if this is accessed
1814
1795
  validatedFactory.type = type;
1815
1796
 
1816
1797
  {
1817
- if (canDefineProperty_1) {
1818
- Object.defineProperty(validatedFactory, 'type', {
1819
- enumerable: false,
1820
- get: function () {
1821
- warning$3(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
1822
- Object.defineProperty(this, 'type', {
1823
- value: type
1824
- });
1825
- return type;
1826
- }
1827
- });
1828
- }
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
+ });
1829
1808
  }
1830
1809
 
1831
1810
  return validatedFactory;
@@ -1847,233 +1826,20 @@ var ReactElementValidator$2 = {
1847
1826
  }
1848
1827
  };
1849
1828
 
1850
- var ReactElementValidator_1 = ReactElementValidator$2;
1851
-
1852
- /**
1853
- * Create a factory that creates HTML tag elements.
1854
- *
1855
- * @private
1856
- */
1857
- var createDOMFactory = ReactElement_1.createFactory;
1858
- {
1859
- var ReactElementValidator$1 = ReactElementValidator_1;
1860
- createDOMFactory = ReactElementValidator$1.createFactory;
1861
- }
1862
-
1863
- /**
1864
- * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
1865
- * This is also accessible via `React.DOM`.
1866
- *
1867
- * @public
1868
- */
1869
- var ReactDOMFactories = {
1870
- a: createDOMFactory('a'),
1871
- abbr: createDOMFactory('abbr'),
1872
- address: createDOMFactory('address'),
1873
- area: createDOMFactory('area'),
1874
- article: createDOMFactory('article'),
1875
- aside: createDOMFactory('aside'),
1876
- audio: createDOMFactory('audio'),
1877
- b: createDOMFactory('b'),
1878
- base: createDOMFactory('base'),
1879
- bdi: createDOMFactory('bdi'),
1880
- bdo: createDOMFactory('bdo'),
1881
- big: createDOMFactory('big'),
1882
- blockquote: createDOMFactory('blockquote'),
1883
- body: createDOMFactory('body'),
1884
- br: createDOMFactory('br'),
1885
- button: createDOMFactory('button'),
1886
- canvas: createDOMFactory('canvas'),
1887
- caption: createDOMFactory('caption'),
1888
- cite: createDOMFactory('cite'),
1889
- code: createDOMFactory('code'),
1890
- col: createDOMFactory('col'),
1891
- colgroup: createDOMFactory('colgroup'),
1892
- data: createDOMFactory('data'),
1893
- datalist: createDOMFactory('datalist'),
1894
- dd: createDOMFactory('dd'),
1895
- del: createDOMFactory('del'),
1896
- details: createDOMFactory('details'),
1897
- dfn: createDOMFactory('dfn'),
1898
- dialog: createDOMFactory('dialog'),
1899
- div: createDOMFactory('div'),
1900
- dl: createDOMFactory('dl'),
1901
- dt: createDOMFactory('dt'),
1902
- em: createDOMFactory('em'),
1903
- embed: createDOMFactory('embed'),
1904
- fieldset: createDOMFactory('fieldset'),
1905
- figcaption: createDOMFactory('figcaption'),
1906
- figure: createDOMFactory('figure'),
1907
- footer: createDOMFactory('footer'),
1908
- form: createDOMFactory('form'),
1909
- h1: createDOMFactory('h1'),
1910
- h2: createDOMFactory('h2'),
1911
- h3: createDOMFactory('h3'),
1912
- h4: createDOMFactory('h4'),
1913
- h5: createDOMFactory('h5'),
1914
- h6: createDOMFactory('h6'),
1915
- head: createDOMFactory('head'),
1916
- header: createDOMFactory('header'),
1917
- hgroup: createDOMFactory('hgroup'),
1918
- hr: createDOMFactory('hr'),
1919
- html: createDOMFactory('html'),
1920
- i: createDOMFactory('i'),
1921
- iframe: createDOMFactory('iframe'),
1922
- img: createDOMFactory('img'),
1923
- input: createDOMFactory('input'),
1924
- ins: createDOMFactory('ins'),
1925
- kbd: createDOMFactory('kbd'),
1926
- keygen: createDOMFactory('keygen'),
1927
- label: createDOMFactory('label'),
1928
- legend: createDOMFactory('legend'),
1929
- li: createDOMFactory('li'),
1930
- link: createDOMFactory('link'),
1931
- main: createDOMFactory('main'),
1932
- map: createDOMFactory('map'),
1933
- mark: createDOMFactory('mark'),
1934
- menu: createDOMFactory('menu'),
1935
- menuitem: createDOMFactory('menuitem'),
1936
- meta: createDOMFactory('meta'),
1937
- meter: createDOMFactory('meter'),
1938
- nav: createDOMFactory('nav'),
1939
- noscript: createDOMFactory('noscript'),
1940
- object: createDOMFactory('object'),
1941
- ol: createDOMFactory('ol'),
1942
- optgroup: createDOMFactory('optgroup'),
1943
- option: createDOMFactory('option'),
1944
- output: createDOMFactory('output'),
1945
- p: createDOMFactory('p'),
1946
- param: createDOMFactory('param'),
1947
- picture: createDOMFactory('picture'),
1948
- pre: createDOMFactory('pre'),
1949
- progress: createDOMFactory('progress'),
1950
- q: createDOMFactory('q'),
1951
- rp: createDOMFactory('rp'),
1952
- rt: createDOMFactory('rt'),
1953
- ruby: createDOMFactory('ruby'),
1954
- s: createDOMFactory('s'),
1955
- samp: createDOMFactory('samp'),
1956
- script: createDOMFactory('script'),
1957
- section: createDOMFactory('section'),
1958
- select: createDOMFactory('select'),
1959
- small: createDOMFactory('small'),
1960
- source: createDOMFactory('source'),
1961
- span: createDOMFactory('span'),
1962
- strong: createDOMFactory('strong'),
1963
- style: createDOMFactory('style'),
1964
- sub: createDOMFactory('sub'),
1965
- summary: createDOMFactory('summary'),
1966
- sup: createDOMFactory('sup'),
1967
- table: createDOMFactory('table'),
1968
- tbody: createDOMFactory('tbody'),
1969
- td: createDOMFactory('td'),
1970
- textarea: createDOMFactory('textarea'),
1971
- tfoot: createDOMFactory('tfoot'),
1972
- th: createDOMFactory('th'),
1973
- thead: createDOMFactory('thead'),
1974
- time: createDOMFactory('time'),
1975
- title: createDOMFactory('title'),
1976
- tr: createDOMFactory('tr'),
1977
- track: createDOMFactory('track'),
1978
- u: createDOMFactory('u'),
1979
- ul: createDOMFactory('ul'),
1980
- 'var': createDOMFactory('var'),
1981
- video: createDOMFactory('video'),
1982
- wbr: createDOMFactory('wbr'),
1983
-
1984
- // SVG
1985
- circle: createDOMFactory('circle'),
1986
- clipPath: createDOMFactory('clipPath'),
1987
- defs: createDOMFactory('defs'),
1988
- ellipse: createDOMFactory('ellipse'),
1989
- g: createDOMFactory('g'),
1990
- image: createDOMFactory('image'),
1991
- line: createDOMFactory('line'),
1992
- linearGradient: createDOMFactory('linearGradient'),
1993
- mask: createDOMFactory('mask'),
1994
- path: createDOMFactory('path'),
1995
- pattern: createDOMFactory('pattern'),
1996
- polygon: createDOMFactory('polygon'),
1997
- polyline: createDOMFactory('polyline'),
1998
- radialGradient: createDOMFactory('radialGradient'),
1999
- rect: createDOMFactory('rect'),
2000
- stop: createDOMFactory('stop'),
2001
- svg: createDOMFactory('svg'),
2002
- text: createDOMFactory('text'),
2003
- tspan: createDOMFactory('tspan')
2004
- };
2005
-
2006
- var ReactDOMFactories_1 = ReactDOMFactories;
2007
-
2008
- var isValidElement = ReactElement_1.isValidElement;
2009
-
2010
-
2011
-
2012
- var ReactPropTypes = factory(isValidElement);
2013
-
2014
- /**
2015
- * Copyright 2013-present, Facebook, Inc.
2016
- * All rights reserved.
2017
- *
2018
- * This source code is licensed under the BSD-style license found in the
2019
- * LICENSE file in the root directory of this source tree. An additional grant
2020
- * of patent rights can be found in the PATENTS file in the same directory.
2021
- *
2022
- * @providesModule ReactVersion
2023
- */
2024
-
2025
- var ReactVersion = '16.0.0-alpha.9';
2026
-
2027
- /**
2028
- * Returns the first child in a collection of children and verifies that there
2029
- * is only one child in the collection.
2030
- *
2031
- * See https://facebook.github.io/react/docs/react-api.html#react.children.only
2032
- *
2033
- * The current implementation of this function assumes that a single child gets
2034
- * passed without a wrapper, but the purpose of this helper function is to
2035
- * abstract away the particular structure of children.
2036
- *
2037
- * @param {?object} children Child collection structure.
2038
- * @return {ReactElement} The first and only `ReactElement` contained in the
2039
- * structure.
2040
- */
2041
- function onlyChild(children) {
2042
- !ReactElement_1.isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
2043
- return children;
2044
- }
2045
-
2046
- var onlyChild_1 = onlyChild;
2047
-
2048
- var Component = ReactBaseClasses.Component;
2049
-
2050
- var isValidElement$1 = ReactElement_1.isValidElement;
2051
-
2052
-
2053
-
2054
-
2055
- var createClass = factory$1(Component, isValidElement$1, ReactNoopUpdateQueue_1);
1829
+ var ReactElementValidator_1 = ReactElementValidator$1;
2056
1830
 
2057
1831
  var createElement = ReactElement_1.createElement;
2058
1832
  var createFactory = ReactElement_1.createFactory;
2059
1833
  var cloneElement = ReactElement_1.cloneElement;
2060
1834
 
2061
1835
  {
2062
- var warning$1 = warning;
2063
- var canDefineProperty = canDefineProperty_1;
2064
1836
  var ReactElementValidator = ReactElementValidator_1;
2065
1837
  createElement = ReactElementValidator.createElement;
2066
1838
  createFactory = ReactElementValidator.createFactory;
2067
1839
  cloneElement = ReactElementValidator.cloneElement;
2068
1840
  }
2069
1841
 
2070
- var createMixin = function (mixin) {
2071
- return mixin;
2072
- };
2073
-
2074
1842
  var React = {
2075
- // Modern
2076
-
2077
1843
  Children: {
2078
1844
  map: ReactChildren_1.map,
2079
1845
  forEach: ReactChildren_1.forEach,
@@ -2089,19 +1855,7 @@ var React = {
2089
1855
  cloneElement: cloneElement,
2090
1856
  isValidElement: ReactElement_1.isValidElement,
2091
1857
 
2092
- // TODO (bvaughn) Remove these getters in 16.0.0-alpha.10
2093
- PropTypes: ReactPropTypes,
2094
- checkPropTypes: checkPropTypes$2,
2095
- createClass: createClass,
2096
-
2097
- // Classic
2098
-
2099
1858
  createFactory: createFactory,
2100
- createMixin: createMixin,
2101
-
2102
- // This looks DOM specific but these are actually isomorphic helpers
2103
- // since they are just generating DOM strings.
2104
- DOM: ReactDOMFactories_1,
2105
1859
 
2106
1860
  version: ReactVersion,
2107
1861
 
@@ -2116,44 +1870,6 @@ var React = {
2116
1870
  ReactComponentTreeHook: ReactComponentTreeHook_1,
2117
1871
  ReactDebugCurrentFrame: ReactDebugCurrentFrame_1
2118
1872
  });
2119
-
2120
- var warnedForCheckPropTypes = false;
2121
- var warnedForCreateMixin = false;
2122
- var warnedForCreateClass = false;
2123
- var warnedForPropTypes = false;
2124
-
2125
- React.createMixin = function (mixin) {
2126
- warning$1(warnedForCreateMixin, 'React.createMixin is deprecated and should not be used. You ' + 'can use this mixin directly instead.');
2127
- warnedForCreateMixin = true;
2128
- return mixin;
2129
- };
2130
-
2131
- // TODO (bvaughn) Remove both of these deprecation warnings in 16.0.0-alpha.10
2132
- if (canDefineProperty) {
2133
- Object.defineProperty(React, 'checkPropTypes', {
2134
- get: function () {
2135
- warning$1(warnedForCheckPropTypes, 'checkPropTypes has been moved to a separate package. ' + 'Accessing React.checkPropTypes is no longer supported ' + 'and will be removed completely in React 16. ' + 'Use the prop-types package on npm instead. ' + '(https://fb.me/migrating-from-react-proptypes)');
2136
- warnedForCheckPropTypes = true;
2137
- return ReactPropTypes;
2138
- }
2139
- });
2140
-
2141
- Object.defineProperty(React, 'createClass', {
2142
- get: function () {
2143
- warning$1(warnedForCreateClass, 'React.createClass is no longer supported. Use a plain JavaScript ' + "class instead. If you're not yet ready to migrate, " + 'create-react-class is available on npm as a drop-in replacement. ' + '(https://fb.me/migrating-from-react-create-class)');
2144
- warnedForCreateClass = true;
2145
- return createClass;
2146
- }
2147
- });
2148
-
2149
- Object.defineProperty(React, 'PropTypes', {
2150
- get: function () {
2151
- warning$1(warnedForPropTypes, 'PropTypes has been moved to a separate package. ' + 'Accessing React.PropTypes is no longer supported ' + 'and will be removed completely in React 16. ' + 'Use the prop-types package on npm instead. ' + '(https://fb.me/migrating-from-react-proptypes)');
2152
- warnedForPropTypes = true;
2153
- return ReactPropTypes;
2154
- }
2155
- });
2156
- }
2157
1873
  }
2158
1874
 
2159
1875
  var React_1 = React;