react 16.0.0-alpha.11 → 16.0.0-beta.2

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,13 +1,16 @@
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');
8
13
  var checkPropTypes = require('prop-types/checkPropTypes');
9
- var factory = require('prop-types/factory');
10
- var factory$1 = require('create-react-class/factory');
11
14
 
12
15
  /**
13
16
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -21,6 +24,10 @@ var factory$1 = require('create-react-class/factory');
21
24
  *
22
25
  */
23
26
 
27
+ {
28
+ var warning = require$$0;
29
+ }
30
+
24
31
  function warnNoop(publicInstance, callerName) {
25
32
  {
26
33
  var constructor = publicInstance.constructor;
@@ -99,29 +106,68 @@ var ReactNoopUpdateQueue = {
99
106
  var ReactNoopUpdateQueue_1 = ReactNoopUpdateQueue;
100
107
 
101
108
  /**
102
- * Copyright 2013-present, Facebook, Inc.
109
+ * Copyright 2014-2015, Facebook, Inc.
103
110
  * All rights reserved.
104
111
  *
105
112
  * This source code is licensed under the BSD-style license found in the
106
113
  * LICENSE file in the root directory of this source tree. An additional grant
107
114
  * of patent rights can be found in the PATENTS file in the same directory.
108
115
  *
109
- *
110
- * @providesModule canDefineProperty
116
+ * @providesModule lowPriorityWarning
117
+ */
118
+
119
+ /**
120
+ * Forked from fbjs/warning:
121
+ * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
122
+ *
123
+ * Only change is we use console.warn instead of console.error,
124
+ * and do nothing when 'console' is not supported.
125
+ * This really simplifies the code.
126
+ * ---
127
+ * Similar to invariant but only logs a warning if the condition is not met.
128
+ * This can be used to log issues in development environments in critical
129
+ * paths. Removing the logging code for production environments will keep the
130
+ * same logic and follow the same code paths.
111
131
  */
112
132
 
113
- var canDefineProperty$1 = false;
133
+ var lowPriorityWarning = function () {};
134
+
114
135
  {
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
- }
136
+ var printWarning = function (format) {
137
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
138
+ args[_key - 1] = arguments[_key];
139
+ }
140
+
141
+ var argIndex = 0;
142
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
143
+ return args[argIndex++];
144
+ });
145
+ if (typeof console !== 'undefined') {
146
+ console.warn(message);
147
+ }
148
+ try {
149
+ // --- Welcome to debugging React ---
150
+ // This error was thrown as a convenience so that you can use this stack
151
+ // to find the callsite that caused this warning to fire.
152
+ throw new Error(message);
153
+ } catch (x) {}
154
+ };
155
+
156
+ lowPriorityWarning = function (condition, format) {
157
+ if (format === undefined) {
158
+ throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
159
+ }
160
+ if (!condition) {
161
+ for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
162
+ args[_key2 - 2] = arguments[_key2];
163
+ }
164
+
165
+ printWarning.apply(undefined, [format].concat(args));
166
+ }
167
+ };
122
168
  }
123
169
 
124
- var canDefineProperty_1 = canDefineProperty$1;
170
+ var lowPriorityWarning_1 = lowPriorityWarning;
125
171
 
126
172
  /**
127
173
  * Base class helpers for the updating state of a component.
@@ -196,14 +242,12 @@ ReactComponent.prototype.forceUpdate = function (callback) {
196
242
  replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
197
243
  };
198
244
  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
- }
245
+ Object.defineProperty(ReactComponent.prototype, methodName, {
246
+ get: function () {
247
+ lowPriorityWarning_1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
248
+ return undefined;
249
+ }
250
+ });
207
251
  };
208
252
  for (var fnName in deprecatedAPIs) {
209
253
  if (deprecatedAPIs.hasOwnProperty(fnName)) {
@@ -227,112 +271,37 @@ function ReactPureComponent(props, context, updater) {
227
271
 
228
272
  function ComponentDummy() {}
229
273
  ComponentDummy.prototype = ReactComponent.prototype;
230
- ReactPureComponent.prototype = new ComponentDummy();
231
- ReactPureComponent.prototype.constructor = ReactPureComponent;
274
+ var pureComponentPrototype = ReactPureComponent.prototype = new ComponentDummy();
275
+ pureComponentPrototype.constructor = ReactPureComponent;
232
276
  // Avoid an extra prototype jump for these methods.
233
- objectAssign$1(ReactPureComponent.prototype, ReactComponent.prototype);
234
- ReactPureComponent.prototype.isPureReactComponent = true;
235
-
236
- var ReactBaseClasses = {
237
- Component: ReactComponent,
238
- PureComponent: ReactPureComponent
239
- };
240
-
241
- /**
242
- * Static poolers. Several custom versions for each potential number of
243
- * arguments. A completely generic pooler is easy to implement, but would
244
- * require accessing the `arguments` object. In each of these, `this` refers to
245
- * the Class itself, not an instance. If any others are needed, simply add them
246
- * here, or in their own files.
247
- */
248
- var oneArgumentPooler = function (copyFieldsFrom) {
249
- var Klass = this;
250
- if (Klass.instancePool.length) {
251
- var instance = Klass.instancePool.pop();
252
- Klass.call(instance, copyFieldsFrom);
253
- return instance;
254
- } else {
255
- return new Klass(copyFieldsFrom);
256
- }
257
- };
258
-
259
- var twoArgumentPooler$1 = function (a1, a2) {
260
- var Klass = this;
261
- if (Klass.instancePool.length) {
262
- var instance = Klass.instancePool.pop();
263
- Klass.call(instance, a1, a2);
264
- return instance;
265
- } else {
266
- return new Klass(a1, a2);
267
- }
268
- };
277
+ objectAssign$1(pureComponentPrototype, ReactComponent.prototype);
278
+ pureComponentPrototype.isPureReactComponent = true;
269
279
 
270
- var threeArgumentPooler = function (a1, a2, a3) {
271
- var Klass = this;
272
- if (Klass.instancePool.length) {
273
- var instance = Klass.instancePool.pop();
274
- Klass.call(instance, a1, a2, a3);
275
- return instance;
276
- } else {
277
- return new Klass(a1, a2, a3);
278
- }
279
- };
280
-
281
- var fourArgumentPooler$1 = function (a1, a2, a3, a4) {
282
- var Klass = this;
283
- if (Klass.instancePool.length) {
284
- var instance = Klass.instancePool.pop();
285
- Klass.call(instance, a1, a2, a3, a4);
286
- return instance;
287
- } else {
288
- return new Klass(a1, a2, a3, a4);
289
- }
290
- };
291
-
292
- var standardReleaser = function (instance) {
293
- var Klass = this;
294
- !(instance instanceof Klass) ? invariant(false, 'Trying to release an instance into a pool of a different type.') : void 0;
295
- instance.destructor();
296
- if (Klass.instancePool.length < Klass.poolSize) {
297
- Klass.instancePool.push(instance);
298
- }
299
- };
300
-
301
- var DEFAULT_POOL_SIZE = 10;
302
- 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
+ }
303
289
 
304
- /**
305
- * Augments `CopyConstructor` to be a poolable class, augmenting only the class
306
- * itself (statically) not adding any prototypical fields. Any CopyConstructor
307
- * you give this may have a `poolSize` property, and will look for a
308
- * prototypical `destructor` on instances.
309
- *
310
- * @param {Function} CopyConstructor Constructor that can be used to reset.
311
- * @param {Function} pooler Customizable pooler.
312
- */
313
- var addPoolingTo = function (CopyConstructor, pooler) {
314
- // Casting as any so that flow ignores the actual implementation and trusts
315
- // it to match the type we declared
316
- var NewKlass = CopyConstructor;
317
- NewKlass.instancePool = [];
318
- NewKlass.getPooled = pooler || DEFAULT_POOLER;
319
- if (!NewKlass.poolSize) {
320
- NewKlass.poolSize = DEFAULT_POOL_SIZE;
321
- }
322
- NewKlass.release = standardReleaser;
323
- 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;
324
297
  };
325
298
 
326
- var PooledClass = {
327
- addPoolingTo: addPoolingTo,
328
- oneArgumentPooler: oneArgumentPooler,
329
- twoArgumentPooler: twoArgumentPooler$1,
330
- threeArgumentPooler: threeArgumentPooler,
331
- fourArgumentPooler: fourArgumentPooler$1
299
+ var ReactBaseClasses = {
300
+ Component: ReactComponent,
301
+ PureComponent: ReactPureComponent,
302
+ AsyncComponent: ReactAsyncComponent
332
303
  };
333
304
 
334
- var PooledClass_1 = PooledClass;
335
-
336
305
  /**
337
306
  * Copyright 2013-present, Facebook, Inc.
338
307
  * All rights reserved.
@@ -361,28 +330,15 @@ var ReactCurrentOwner = {
361
330
 
362
331
  var ReactCurrentOwner_1 = ReactCurrentOwner;
363
332
 
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
- */
375
-
376
- // The Symbol used to tag the ReactElement type. If there is no native Symbol
377
- // nor polyfill, then a plain number is used for performance.
378
-
379
- var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
380
-
381
- var ReactElementSymbol = REACT_ELEMENT_TYPE;
382
-
383
333
  var hasOwnProperty = Object.prototype.hasOwnProperty;
384
334
 
335
+ {
336
+ var warning$2 = require$$0;
337
+ }
385
338
 
339
+ // The Symbol used to tag the ReactElement type. If there is no native Symbol
340
+ // nor polyfill, then a plain number is used for performance.
341
+ var REACT_ELEMENT_TYPE$1 = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
386
342
 
387
343
  var RESERVED_PROPS = {
388
344
  key: true,
@@ -422,7 +378,7 @@ function defineKeyPropWarningGetter(props, displayName) {
422
378
  var warnAboutAccessingKey = function () {
423
379
  if (!specialPropKeyWarningShown) {
424
380
  specialPropKeyWarningShown = true;
425
- 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);
426
382
  }
427
383
  };
428
384
  warnAboutAccessingKey.isReactWarning = true;
@@ -436,7 +392,7 @@ function defineRefPropWarningGetter(props, displayName) {
436
392
  var warnAboutAccessingRef = function () {
437
393
  if (!specialPropRefWarningShown) {
438
394
  specialPropRefWarningShown = true;
439
- 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);
440
396
  }
441
397
  };
442
398
  warnAboutAccessingRef.isReactWarning = true;
@@ -469,7 +425,7 @@ function defineRefPropWarningGetter(props, displayName) {
469
425
  var ReactElement = function (type, key, ref, self, source, owner, props) {
470
426
  var element = {
471
427
  // This tag allow us to uniquely identify this as a React Element
472
- $$typeof: ReactElementSymbol,
428
+ $$typeof: REACT_ELEMENT_TYPE$1,
473
429
 
474
430
  // Built-in properties that belong on the element
475
431
  type: type,
@@ -492,33 +448,27 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
492
448
  // the validation flag non-enumerable (where possible, which should
493
449
  // include every environment we run tests in), so the test framework
494
450
  // 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
- }
451
+ Object.defineProperty(element._store, 'validated', {
452
+ configurable: false,
453
+ enumerable: false,
454
+ writable: true,
455
+ value: false
456
+ });
457
+ // self and source are DEV only properties.
458
+ Object.defineProperty(element, '_self', {
459
+ configurable: false,
460
+ enumerable: false,
461
+ writable: false,
462
+ value: self
463
+ });
464
+ // Two elements created in two different places should be considered
465
+ // equal for testing purposes and therefore we hide it from enumeration.
466
+ Object.defineProperty(element, '_source', {
467
+ configurable: false,
468
+ enumerable: false,
469
+ writable: false,
470
+ value: source
471
+ });
522
472
  if (Object.freeze) {
523
473
  Object.freeze(element.props);
524
474
  Object.freeze(element);
@@ -590,7 +540,7 @@ ReactElement.createElement = function (type, config, children) {
590
540
  }
591
541
  {
592
542
  if (key || ref) {
593
- if (typeof props.$$typeof === 'undefined' || props.$$typeof !== ReactElementSymbol) {
543
+ if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE$1) {
594
544
  var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
595
545
  if (key) {
596
546
  defineKeyPropWarningGetter(props, displayName);
@@ -609,14 +559,14 @@ ReactElement.createElement = function (type, config, children) {
609
559
  * See https://facebook.github.io/react/docs/react-api.html#createfactory
610
560
  */
611
561
  ReactElement.createFactory = function (type) {
612
- var factory$$1 = ReactElement.createElement.bind(null, type);
562
+ var factory = ReactElement.createElement.bind(null, type);
613
563
  // Expose the type on the factory and the prototype so that it can be
614
564
  // easily accessed on elements. E.g. `<Foo />.type === Foo`.
615
565
  // This should not be named `constructor` since this may not be the function
616
566
  // that created the element, and it may not even be a constructor.
617
567
  // Legacy hook TODO: Warn if this is accessed
618
- factory$$1.type = type;
619
- return factory$$1;
568
+ factory.type = type;
569
+ return factory;
620
570
  };
621
571
 
622
572
  ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
@@ -699,7 +649,7 @@ ReactElement.cloneElement = function (element, config, children) {
699
649
  * @final
700
650
  */
701
651
  ReactElement.isValidElement = function (object) {
702
- return typeof object === 'object' && object !== null && object.$$typeof === ReactElementSymbol;
652
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE$1;
703
653
  };
704
654
 
705
655
  var ReactElement_1 = ReactElement;
@@ -712,49 +662,42 @@ var ReactElement_1 = ReactElement;
712
662
  * LICENSE file in the root directory of this source tree. An additional grant
713
663
  * of patent rights can be found in the PATENTS file in the same directory.
714
664
  *
715
- * @providesModule getIteratorFn
665
+ * @providesModule ReactDebugCurrentFrame
716
666
  *
717
667
  */
718
668
 
719
- /* global Symbol */
669
+ var ReactDebugCurrentFrame = {};
720
670
 
721
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
722
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
671
+ {
672
+ // Component that is being worked on
673
+ ReactDebugCurrentFrame.getCurrentStack = null;
723
674
 
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
- }
675
+ ReactDebugCurrentFrame.getStackAddendum = function () {
676
+ var impl = ReactDebugCurrentFrame.getCurrentStack;
677
+ if (impl) {
678
+ return impl();
679
+ }
680
+ return null;
681
+ };
743
682
  }
744
683
 
745
- var getIteratorFn_1 = getIteratorFn;
684
+ var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame;
746
685
 
747
- /**
748
- * Copyright 2013-present, Facebook, Inc.
749
- * All rights reserved.
750
- *
751
- * This source code is licensed under the BSD-style license found in the
752
- * LICENSE file in the root directory of this source tree. An additional grant
753
- * of patent rights can be found in the PATENTS file in the same directory.
754
- *
755
- * @providesModule KeyEscapeUtils
756
- *
757
- */
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 = ':';
758
701
 
759
702
  /**
760
703
  * Escape and wrap key so it is safe to use as a reactid
@@ -762,7 +705,6 @@ var getIteratorFn_1 = getIteratorFn;
762
705
  * @param {string} key to be escaped.
763
706
  * @return {string} the escaped key.
764
707
  */
765
-
766
708
  function escape(key) {
767
709
  var escapeRegex = /[=:]/g;
768
710
  var escaperLookup = {
@@ -777,573 +719,118 @@ function escape(key) {
777
719
  }
778
720
 
779
721
  /**
780
- * Unescape and unwrap key for human-readable display
781
- *
782
- * @param {string} key to unescape.
783
- * @return {string} the unescaped key.
722
+ * TODO: Test that a single child and an array with one item have the same key
723
+ * pattern.
784
724
  */
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);
792
-
793
- return ('' + keySubstring).replace(unescapeRegex, function (match) {
794
- return unescaperLookup[match];
795
- });
796
- }
797
725
 
798
- var KeyEscapeUtils = {
799
- escape: escape,
800
- unescape: unescape
801
- };
726
+ var didWarnAboutMaps = false;
802
727
 
803
- var KeyEscapeUtils_1 = KeyEscapeUtils;
728
+ var userProvidedKeyEscapeRegex = /\/+/g;
729
+ function escapeUserProvidedKey(text) {
730
+ return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
731
+ }
804
732
 
805
- /**
806
- * Copyright 2013-present, Facebook, Inc.
807
- * All rights reserved.
808
- *
809
- * This source code is licensed under the BSD-style license found in the
810
- * LICENSE file in the root directory of this source tree. An additional grant
811
- * of patent rights can be found in the PATENTS file in the same directory.
812
- *
813
- * @providesModule ReactTypeOfWork
814
- *
815
- */
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
+ };
752
+ }
753
+ }
816
754
 
817
- var ReactTypeOfWork = {
818
- IndeterminateComponent: 0, // Before we know whether it is functional or class
819
- FunctionalComponent: 1,
820
- ClassComponent: 2,
821
- HostRoot: 3, // Root of a host tree. Could be nested inside another node.
822
- HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
823
- HostComponent: 5,
824
- HostText: 6,
825
- CoroutineComponent: 7,
826
- CoroutineHandlerPhase: 8,
827
- YieldComponent: 9,
828
- Fragment: 10
829
- };
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);
763
+ }
764
+ }
830
765
 
831
766
  /**
832
- * Copyright 2013-present, Facebook, Inc.
833
- * All rights reserved.
834
- *
835
- * This source code is licensed under the BSD-style license found in the
836
- * LICENSE file in the root directory of this source tree. An additional grant
837
- * of patent rights can be found in the PATENTS file in the same directory.
838
- *
839
- * @providesModule getComponentName
840
- *
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.
841
773
  */
774
+ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
775
+ var type = typeof children;
842
776
 
843
- function getComponentName(instanceOrFiber) {
844
- if (typeof instanceOrFiber.getName === 'function') {
845
- // Stack reconciler
846
- var instance = instanceOrFiber;
847
- return instance.getName();
777
+ if (type === 'undefined' || type === 'boolean') {
778
+ // All of the above are perceived as null.
779
+ children = null;
848
780
  }
849
- if (typeof instanceOrFiber.tag === 'number') {
850
- // Fiber reconciler
851
- var fiber = instanceOrFiber;
852
- var type = fiber.type;
853
781
 
854
- if (typeof type === 'string') {
855
- return type;
856
- }
857
- if (typeof type === 'function') {
858
- return type.displayName || type.name;
859
- }
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;
860
791
  }
861
- return null;
862
- }
863
-
864
- var getComponentName_1 = getComponentName;
865
-
866
- var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent;
867
- var FunctionalComponent = ReactTypeOfWork.FunctionalComponent;
868
- var ClassComponent = ReactTypeOfWork.ClassComponent;
869
- var HostComponent = ReactTypeOfWork.HostComponent;
870
-
871
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;
872
797
 
873
- function describeComponentFrame$1(name, source, ownerName) {
874
- return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
875
- }
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
+ }
876
814
 
877
- function describeFiber(fiber) {
878
- switch (fiber.tag) {
879
- case IndeterminateComponent:
880
- case FunctionalComponent:
881
- case ClassComponent:
882
- case HostComponent:
883
- var owner = fiber._debugOwner;
884
- var source = fiber._debugSource;
885
- var name = getComponentName_1(fiber);
886
- var ownerName = null;
887
- if (owner) {
888
- 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();
889
827
  }
890
- return describeComponentFrame$1(name, source, ownerName);
891
- default:
892
- 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
+ }
893
831
  }
894
- }
895
832
 
896
- // This function can only be called with a work-in-progress fiber and
897
- // only during begin or complete phase. Do not call it under any other
898
- // circumstances.
899
- function getStackAddendumByWorkInProgressFiber$1(workInProgress) {
900
- var info = '';
901
- var node = workInProgress;
902
- do {
903
- info += describeFiber(node);
904
- // Otherwise this return pointer might point to the wrong tree:
905
- node = node['return'];
906
- } while (node);
907
- return info;
908
- }
909
-
910
- var ReactFiberComponentTreeHook = {
911
- getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$1,
912
- describeComponentFrame: describeComponentFrame$1
913
- };
914
-
915
- var getStackAddendumByWorkInProgressFiber = ReactFiberComponentTreeHook.getStackAddendumByWorkInProgressFiber;
916
- var describeComponentFrame = ReactFiberComponentTreeHook.describeComponentFrame;
917
-
918
-
919
-
920
-
921
-
922
- function isNative(fn) {
923
- // Based on isNative() from Lodash
924
- var funcToString = Function.prototype.toString;
925
- var hasOwnProperty = Object.prototype.hasOwnProperty;
926
- var reIsNative = RegExp('^' + funcToString
927
- // Take an example native function source for comparison
928
- .call(hasOwnProperty)
929
- // Strip regex characters so we can use it for regex
930
- .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
931
- // Remove hasOwnProperty from the template to make it generic
932
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
933
- try {
934
- var source = funcToString.call(fn);
935
- return reIsNative.test(source);
936
- } catch (err) {
937
- return false;
938
- }
939
- }
940
-
941
- var canUseCollections =
942
- // Array.from
943
- typeof Array.from === 'function' &&
944
- // Map
945
- typeof Map === 'function' && isNative(Map) &&
946
- // Map.prototype.keys
947
- Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) &&
948
- // Set
949
- typeof Set === 'function' && isNative(Set) &&
950
- // Set.prototype.keys
951
- Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys);
952
-
953
- var setItem;
954
- var getItem;
955
- var removeItem;
956
- var getItemIDs;
957
- var addRoot;
958
- var removeRoot;
959
- var getRootIDs;
960
-
961
- if (canUseCollections) {
962
- var itemMap = new Map();
963
- var rootIDSet = new Set();
964
-
965
- setItem = function (id, item) {
966
- itemMap.set(id, item);
967
- };
968
- getItem = function (id) {
969
- return itemMap.get(id);
970
- };
971
- removeItem = function (id) {
972
- itemMap['delete'](id);
973
- };
974
- getItemIDs = function () {
975
- return Array.from(itemMap.keys());
976
- };
977
-
978
- addRoot = function (id) {
979
- rootIDSet.add(id);
980
- };
981
- removeRoot = function (id) {
982
- rootIDSet['delete'](id);
983
- };
984
- getRootIDs = function () {
985
- return Array.from(rootIDSet.keys());
986
- };
987
- } else {
988
- var itemByKey = {};
989
- var rootByKey = {};
990
-
991
- // Use non-numeric keys to prevent V8 performance issues:
992
- // https://github.com/facebook/react/pull/7232
993
- var getKeyFromID = function (id) {
994
- return '.' + id;
995
- };
996
- var getIDFromKey = function (key) {
997
- return parseInt(key.substr(1), 10);
998
- };
999
-
1000
- setItem = function (id, item) {
1001
- var key = getKeyFromID(id);
1002
- itemByKey[key] = item;
1003
- };
1004
- getItem = function (id) {
1005
- var key = getKeyFromID(id);
1006
- return itemByKey[key];
1007
- };
1008
- removeItem = function (id) {
1009
- var key = getKeyFromID(id);
1010
- delete itemByKey[key];
1011
- };
1012
- getItemIDs = function () {
1013
- return Object.keys(itemByKey).map(getIDFromKey);
1014
- };
1015
-
1016
- addRoot = function (id) {
1017
- var key = getKeyFromID(id);
1018
- rootByKey[key] = true;
1019
- };
1020
- removeRoot = function (id) {
1021
- var key = getKeyFromID(id);
1022
- delete rootByKey[key];
1023
- };
1024
- getRootIDs = function () {
1025
- return Object.keys(rootByKey).map(getIDFromKey);
1026
- };
1027
- }
1028
-
1029
- var unmountedIDs = [];
1030
-
1031
- function purgeDeep(id) {
1032
- var item = getItem(id);
1033
- if (item) {
1034
- var childIDs = item.childIDs;
1035
-
1036
- removeItem(id);
1037
- childIDs.forEach(purgeDeep);
1038
- }
1039
- }
1040
-
1041
- function getDisplayName(element) {
1042
- if (element == null) {
1043
- return '#empty';
1044
- } else if (typeof element === 'string' || typeof element === 'number') {
1045
- return '#text';
1046
- } else if (typeof element.type === 'string') {
1047
- return element.type;
1048
- } else {
1049
- return element.type.displayName || element.type.name || 'Unknown';
1050
- }
1051
- }
1052
-
1053
- function describeID(id) {
1054
- var name = ReactComponentTreeHook.getDisplayName(id);
1055
- var element = ReactComponentTreeHook.getElement(id);
1056
- var ownerID = ReactComponentTreeHook.getOwnerID(id);
1057
- var ownerName = void 0;
1058
-
1059
- if (ownerID) {
1060
- ownerName = ReactComponentTreeHook.getDisplayName(ownerID);
1061
- }
1062
- warning(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id);
1063
- return describeComponentFrame(name || '', element && element._source, ownerName || '');
1064
- }
1065
-
1066
- var ReactComponentTreeHook = {
1067
- onSetChildren: function (id, nextChildIDs) {
1068
- var item = getItem(id);
1069
- invariant(item, 'Item must have been set');
1070
- item.childIDs = nextChildIDs;
1071
-
1072
- for (var i = 0; i < nextChildIDs.length; i++) {
1073
- var nextChildID = nextChildIDs[i];
1074
- var nextChild = getItem(nextChildID);
1075
- !nextChild ? invariant(false, 'Expected hook events to fire for the child before its parent includes it in onSetChildren().') : void 0;
1076
- !(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;
1077
- !nextChild.isMounted ? invariant(false, 'Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().') : void 0;
1078
- if (nextChild.parentID == null) {
1079
- nextChild.parentID = id;
1080
- // TODO: This shouldn't be necessary but mounting a new root during in
1081
- // componentWillMount currently causes not-yet-mounted components to
1082
- // be purged from our tree data so their parent id is missing.
1083
- }
1084
- !(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;
1085
- }
1086
- },
1087
- onBeforeMountComponent: function (id, element, parentID) {
1088
- var item = {
1089
- element: element,
1090
- parentID: parentID,
1091
- text: null,
1092
- childIDs: [],
1093
- isMounted: false,
1094
- updateCount: 0
1095
- };
1096
- setItem(id, item);
1097
- },
1098
- onBeforeUpdateComponent: function (id, element) {
1099
- var item = getItem(id);
1100
- if (!item || !item.isMounted) {
1101
- // We may end up here as a result of setState() in componentWillUnmount().
1102
- // In this case, ignore the element.
1103
- return;
1104
- }
1105
- item.element = element;
1106
- },
1107
- onMountComponent: function (id) {
1108
- var item = getItem(id);
1109
- invariant(item, 'Item must have been set');
1110
- item.isMounted = true;
1111
- var isRoot = item.parentID === 0;
1112
- if (isRoot) {
1113
- addRoot(id);
1114
- }
1115
- },
1116
- onUpdateComponent: function (id) {
1117
- var item = getItem(id);
1118
- if (!item || !item.isMounted) {
1119
- // We may end up here as a result of setState() in componentWillUnmount().
1120
- // In this case, ignore the element.
1121
- return;
1122
- }
1123
- item.updateCount++;
1124
- },
1125
- onUnmountComponent: function (id) {
1126
- var item = getItem(id);
1127
- if (item) {
1128
- // We need to check if it exists.
1129
- // `item` might not exist if it is inside an error boundary, and a sibling
1130
- // error boundary child threw while mounting. Then this instance never
1131
- // got a chance to mount, but it still gets an unmounting event during
1132
- // the error boundary cleanup.
1133
- item.isMounted = false;
1134
- var isRoot = item.parentID === 0;
1135
- if (isRoot) {
1136
- removeRoot(id);
1137
- }
1138
- }
1139
- unmountedIDs.push(id);
1140
- },
1141
- purgeUnmountedComponents: function () {
1142
- if (ReactComponentTreeHook._preventPurging) {
1143
- // Should only be used for testing.
1144
- return;
1145
- }
1146
-
1147
- for (var i = 0; i < unmountedIDs.length; i++) {
1148
- var id = unmountedIDs[i];
1149
- purgeDeep(id);
1150
- }
1151
- unmountedIDs.length = 0;
1152
- },
1153
- isMounted: function (id) {
1154
- var item = getItem(id);
1155
- return item ? item.isMounted : false;
1156
- },
1157
- getCurrentStackAddendum: function (topElement) {
1158
- var info = '';
1159
- if (topElement) {
1160
- var name = getDisplayName(topElement);
1161
- var owner = topElement._owner;
1162
- info += describeComponentFrame(name, topElement._source, owner && getComponentName_1(owner));
1163
- }
1164
-
1165
- var currentOwner = ReactCurrentOwner_1.current;
1166
- if (currentOwner) {
1167
- if (typeof currentOwner.tag === 'number') {
1168
- var workInProgress = currentOwner;
1169
- // Safe because if current owner exists, we are reconciling,
1170
- // and it is guaranteed to be the work-in-progress version.
1171
- info += getStackAddendumByWorkInProgressFiber(workInProgress);
1172
- } else if (typeof currentOwner._debugID === 'number') {
1173
- info += ReactComponentTreeHook.getStackAddendumByID(currentOwner._debugID);
1174
- }
1175
- }
1176
- return info;
1177
- },
1178
- getStackAddendumByID: function (id) {
1179
- var info = '';
1180
- while (id) {
1181
- info += describeID(id);
1182
- id = ReactComponentTreeHook.getParentID(id);
1183
- }
1184
- return info;
1185
- },
1186
- getChildIDs: function (id) {
1187
- var item = getItem(id);
1188
- return item ? item.childIDs : [];
1189
- },
1190
- getDisplayName: function (id) {
1191
- var element = ReactComponentTreeHook.getElement(id);
1192
- if (!element) {
1193
- return null;
1194
- }
1195
- return getDisplayName(element);
1196
- },
1197
- getElement: function (id) {
1198
- var item = getItem(id);
1199
- return item ? item.element : null;
1200
- },
1201
- getOwnerID: function (id) {
1202
- var element = ReactComponentTreeHook.getElement(id);
1203
- if (!element || !element._owner) {
1204
- return null;
1205
- }
1206
- return element._owner._debugID;
1207
- },
1208
- getParentID: function (id) {
1209
- var item = getItem(id);
1210
- return item ? item.parentID : null;
1211
- },
1212
- getSource: function (id) {
1213
- var item = getItem(id);
1214
- var element = item ? item.element : null;
1215
- var source = element != null ? element._source : null;
1216
- return source;
1217
- },
1218
- getText: function (id) {
1219
- var element = ReactComponentTreeHook.getElement(id);
1220
- if (typeof element === 'string') {
1221
- return element;
1222
- } else if (typeof element === 'number') {
1223
- return '' + element;
1224
- } else {
1225
- return null;
1226
- }
1227
- },
1228
- getUpdateCount: function (id) {
1229
- var item = getItem(id);
1230
- return item ? item.updateCount : 0;
1231
- },
1232
-
1233
-
1234
- getRootIDs: getRootIDs,
1235
- getRegisteredIDs: getItemIDs
1236
- };
1237
-
1238
- var ReactComponentTreeHook_1 = ReactComponentTreeHook;
1239
-
1240
- {
1241
- var _require = ReactComponentTreeHook_1,
1242
- getCurrentStackAddendum = _require.getCurrentStackAddendum;
1243
- }
1244
-
1245
- var SEPARATOR = '.';
1246
- var SUBSEPARATOR = ':';
1247
-
1248
- /**
1249
- * This is inlined from ReactElement since this file is shared between
1250
- * isomorphic and renderers. We could extract this to a
1251
- *
1252
- */
1253
-
1254
- /**
1255
- * TODO: Test that a single child and an array with one item have the same key
1256
- * pattern.
1257
- */
1258
-
1259
- var didWarnAboutMaps = false;
1260
-
1261
- /**
1262
- * Generate a key string that identifies a component within a set.
1263
- *
1264
- * @param {*} component A component that could contain a manual key.
1265
- * @param {number} index Index that is used if a manual key is not provided.
1266
- * @return {string}
1267
- */
1268
- function getComponentKey(component, index) {
1269
- // Do some typechecking here since we call this blindly. We want to ensure
1270
- // that we don't block potential future ES APIs.
1271
- if (component && typeof component === 'object' && component.key != null) {
1272
- // Explicit key
1273
- return KeyEscapeUtils_1.escape(component.key);
1274
- }
1275
- // Implicit key determined by the index in the set
1276
- return index.toString(36);
1277
- }
1278
-
1279
- /**
1280
- * @param {?*} children Children tree container.
1281
- * @param {!string} nameSoFar Name of the key path so far.
1282
- * @param {!function} callback Callback to invoke with each child found.
1283
- * @param {?*} traverseContext Used to pass information throughout the traversal
1284
- * process.
1285
- * @return {!number} The number of children in this subtree.
1286
- */
1287
- function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
1288
- var type = typeof children;
1289
-
1290
- if (type === 'undefined' || type === 'boolean') {
1291
- // All of the above are perceived as null.
1292
- children = null;
1293
- }
1294
-
1295
- if (children === null || type === 'string' || type === 'number' ||
1296
- // The following is inlined from ReactElement. This means we can optimize
1297
- // some checks. React Fiber also inlines this logic for similar purposes.
1298
- type === 'object' && children.$$typeof === ReactElementSymbol) {
1299
- callback(traverseContext, children,
1300
- // If it's the only child, treat the name as if it was wrapped in an array
1301
- // so that it's consistent if the number of children grows.
1302
- nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
1303
- return 1;
1304
- }
1305
-
1306
- var child;
1307
- var nextName;
1308
- var subtreeCount = 0; // Count of children found in the current subtree.
1309
- var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1310
-
1311
- if (Array.isArray(children)) {
1312
- for (var i = 0; i < children.length; i++) {
1313
- child = children[i];
1314
- nextName = nextNamePrefix + getComponentKey(child, i);
1315
- subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1316
- }
1317
- } else {
1318
- var iteratorFn = getIteratorFn_1(children);
1319
- if (iteratorFn) {
1320
- {
1321
- // Warn about using Maps as children
1322
- if (iteratorFn === children.entries) {
1323
- 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());
1324
- didWarnAboutMaps = true;
1325
- }
1326
- }
1327
-
1328
- var iterator = iteratorFn.call(children);
1329
- var step;
1330
- var ii = 0;
1331
- while (!(step = iterator.next()).done) {
1332
- child = step.value;
1333
- nextName = nextNamePrefix + getComponentKey(child, ii++);
1334
- subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1335
- }
1336
- } else if (type === 'object') {
1337
- var addendum = '';
1338
- {
1339
- addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentStackAddendum();
1340
- }
1341
- var childrenString = '' + children;
1342
- 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);
1343
- }
1344
- }
1345
-
1346
- return subtreeCount;
833
+ return subtreeCount;
1347
834
  }
1348
835
 
1349
836
  /**
@@ -1370,35 +857,23 @@ function traverseAllChildren(children, callback, traverseContext) {
1370
857
  return traverseAllChildrenImpl(children, '', callback, traverseContext);
1371
858
  }
1372
859
 
1373
- var traverseAllChildren_1 = traverseAllChildren;
1374
-
1375
- var twoArgumentPooler = PooledClass_1.twoArgumentPooler;
1376
- var fourArgumentPooler = PooledClass_1.fourArgumentPooler;
1377
-
1378
- var userProvidedKeyEscapeRegex = /\/+/g;
1379
- function escapeUserProvidedKey(text) {
1380
- return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
1381
- }
1382
-
1383
860
  /**
1384
- * PooledClass representing the bookkeeping associated with performing a child
1385
- * traversal. Allows avoiding binding callbacks.
861
+ * Generate a key string that identifies a component within a set.
1386
862
  *
1387
- * @constructor ForEachBookKeeping
1388
- * @param {!function} forEachFunction Function to perform traversal with.
1389
- * @param {?*} forEachContext Context to perform context with.
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}
1390
866
  */
1391
- function ForEachBookKeeping(forEachFunction, forEachContext) {
1392
- this.func = forEachFunction;
1393
- this.context = forEachContext;
1394
- this.count = 0;
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);
1395
876
  }
1396
- ForEachBookKeeping.prototype.destructor = function () {
1397
- this.func = null;
1398
- this.context = null;
1399
- this.count = 0;
1400
- };
1401
- PooledClass_1.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
1402
877
 
1403
878
  function forEachSingleChild(bookKeeping, child, name) {
1404
879
  var func = bookKeeping.func,
@@ -1423,35 +898,10 @@ function forEachChildren(children, forEachFunc, forEachContext) {
1423
898
  if (children == null) {
1424
899
  return children;
1425
900
  }
1426
- var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
1427
- traverseAllChildren_1(children, forEachSingleChild, traverseContext);
1428
- ForEachBookKeeping.release(traverseContext);
1429
- }
1430
-
1431
- /**
1432
- * PooledClass representing the bookkeeping associated with performing a child
1433
- * mapping. Allows avoiding binding callbacks.
1434
- *
1435
- * @constructor MapBookKeeping
1436
- * @param {!*} mapResult Object containing the ordered map of results.
1437
- * @param {!function} mapFunction Function to perform mapping with.
1438
- * @param {?*} mapContext Context to perform mapping with.
1439
- */
1440
- function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
1441
- this.result = mapResult;
1442
- this.keyPrefix = keyPrefix;
1443
- this.func = mapFunction;
1444
- this.context = mapContext;
1445
- this.count = 0;
901
+ var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
902
+ traverseAllChildren(children, forEachSingleChild, traverseContext);
903
+ releaseTraverseContext(traverseContext);
1446
904
  }
1447
- MapBookKeeping.prototype.destructor = function () {
1448
- this.result = null;
1449
- this.keyPrefix = null;
1450
- this.func = null;
1451
- this.context = null;
1452
- this.count = 0;
1453
- };
1454
- PooledClass_1.addPoolingTo(MapBookKeeping, fourArgumentPooler);
1455
905
 
1456
906
  function mapSingleChildIntoContext(bookKeeping, child, childKey) {
1457
907
  var result = bookKeeping.result,
@@ -1479,9 +929,9 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1479
929
  if (prefix != null) {
1480
930
  escapedPrefix = escapeUserProvidedKey(prefix) + '/';
1481
931
  }
1482
- var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
1483
- traverseAllChildren_1(children, mapSingleChildIntoContext, traverseContext);
1484
- MapBookKeeping.release(traverseContext);
932
+ var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
933
+ traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
934
+ releaseTraverseContext(traverseContext);
1485
935
  }
1486
936
 
1487
937
  /**
@@ -1506,10 +956,6 @@ function mapChildren(children, func, context) {
1506
956
  return result;
1507
957
  }
1508
958
 
1509
- function forEachSingleChildDummy(traverseContext, child, name) {
1510
- return null;
1511
- }
1512
-
1513
959
  /**
1514
960
  * Count the number of children that are typically specified as
1515
961
  * `props.children`.
@@ -1519,87 +965,156 @@ function forEachSingleChildDummy(traverseContext, child, name) {
1519
965
  * @param {?*} children Children tree container.
1520
966
  * @return {number} The number of children.
1521
967
  */
1522
- function countChildren(children, context) {
1523
- return traverseAllChildren_1(children, forEachSingleChildDummy, null);
1524
- }
968
+ function countChildren(children, context) {
969
+ return traverseAllChildren(children, emptyFunction.thatReturnsNull, null);
970
+ }
971
+
972
+ /**
973
+ * Flatten a children object (typically specified as `props.children`) and
974
+ * return an array with appropriately re-keyed children.
975
+ *
976
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.toarray
977
+ */
978
+ function toArray(children) {
979
+ var result = [];
980
+ mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
981
+ return result;
982
+ }
983
+
984
+ var ReactChildren = {
985
+ forEach: forEachChildren,
986
+ map: mapChildren,
987
+ count: countChildren,
988
+ toArray: toArray
989
+ };
990
+
991
+ var ReactChildren_1 = ReactChildren;
992
+
993
+ /**
994
+ * Copyright 2013-present, Facebook, Inc.
995
+ * All rights reserved.
996
+ *
997
+ * This source code is licensed under the BSD-style license found in the
998
+ * LICENSE file in the root directory of this source tree. An additional grant
999
+ * of patent rights can be found in the PATENTS file in the same directory.
1000
+ *
1001
+ * @providesModule ReactVersion
1002
+ */
1003
+
1004
+ var ReactVersion = '16.0.0-beta.2';
1005
+
1006
+ /**
1007
+ * Returns the first child in a collection of children and verifies that there
1008
+ * is only one child in the collection.
1009
+ *
1010
+ * See https://facebook.github.io/react/docs/react-api.html#react.children.only
1011
+ *
1012
+ * The current implementation of this function assumes that a single child gets
1013
+ * passed without a wrapper, but the purpose of this helper function is to
1014
+ * abstract away the particular structure of children.
1015
+ *
1016
+ * @param {?object} children Child collection structure.
1017
+ * @return {ReactElement} The first and only `ReactElement` contained in the
1018
+ * structure.
1019
+ */
1020
+ function onlyChild(children) {
1021
+ !ReactElement_1.isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
1022
+ return children;
1023
+ }
1024
+
1025
+ var onlyChild_1 = onlyChild;
1026
+
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
+ */
1038
+
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
+ };
1525
1042
 
1526
1043
  /**
1527
- * Flatten a children object (typically specified as `props.children`) and
1528
- * return an array with appropriately re-keyed children.
1044
+ * Copyright 2013-present, Facebook, Inc.
1045
+ * All rights reserved.
1529
1046
  *
1530
- * See https://facebook.github.io/react/docs/react-api.html#react.children.toarray
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
+ *
1531
1053
  */
1532
- function toArray(children) {
1533
- var result = [];
1534
- mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
1535
- return result;
1536
- }
1537
1054
 
1538
- var ReactChildren = {
1539
- forEach: forEachChildren,
1540
- map: mapChildren,
1541
- mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
1542
- count: countChildren,
1543
- toArray: toArray
1544
- };
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;
1545
1065
 
1546
- var ReactChildren_1 = ReactChildren;
1066
+ if (typeof type === 'string') {
1067
+ return type;
1068
+ }
1069
+ if (typeof type === 'function') {
1070
+ return type.displayName || type.name;
1071
+ }
1072
+ }
1073
+ return null;
1074
+ }
1547
1075
 
1548
- var ReactDebugCurrentFrame$1 = {};
1076
+ var getComponentName_1 = getComponentName$1;
1549
1077
 
1550
1078
  {
1551
- var _require$2 = ReactComponentTreeHook_1,
1552
- getStackAddendumByID = _require$2.getStackAddendumByID,
1553
- getCurrentStackAddendum$2 = _require$2.getCurrentStackAddendum;
1554
-
1555
- var _require2$1 = ReactFiberComponentTreeHook,
1556
- getStackAddendumByWorkInProgressFiber$2 = _require2$1.getStackAddendumByWorkInProgressFiber;
1079
+ var checkPropTypes$1 = checkPropTypes;
1080
+ var lowPriorityWarning$1 = lowPriorityWarning_1;
1081
+ var ReactDebugCurrentFrame$1 = ReactDebugCurrentFrame_1;
1082
+ var warning$3 = require$$0;
1083
+ var describeComponentFrame = describeComponentFrame$1;
1084
+ var getComponentName = getComponentName_1;
1557
1085
 
1558
- // Component that is being worked on
1086
+ var currentlyValidatingElement = null;
1559
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
+ };
1560
1099
 
1561
- ReactDebugCurrentFrame$1.current = null;
1562
-
1563
- // Element that is being cloned or created
1564
- ReactDebugCurrentFrame$1.element = null;
1565
-
1566
- ReactDebugCurrentFrame$1.getStackAddendum = function () {
1567
- var stack = null;
1568
- var current = ReactDebugCurrentFrame$1.current;
1569
- var element = ReactDebugCurrentFrame$1.element;
1570
- if (current !== null) {
1571
- if (typeof current === 'number') {
1572
- // DebugID from Stack.
1573
- var debugID = current;
1574
- stack = getStackAddendumByID(debugID);
1575
- } else if (typeof current.tag === 'number') {
1576
- // This is a Fiber.
1577
- // The stack will only be correct if this is a work in progress
1578
- // version and we're calling it during reconciliation.
1579
- var workInProgress = current;
1580
- stack = getStackAddendumByWorkInProgressFiber$2(workInProgress);
1581
- }
1582
- } else if (element !== null) {
1583
- stack = getCurrentStackAddendum$2(element);
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));
1584
1106
  }
1107
+ stack += ReactDebugCurrentFrame$1.getStackAddendum() || '';
1585
1108
  return stack;
1586
1109
  };
1587
1110
  }
1588
1111
 
1589
- var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame$1;
1590
-
1591
- {
1592
- var checkPropTypes$1 = checkPropTypes;
1593
- var warning$2 = warning;
1594
- var ReactDebugCurrentFrame = ReactDebugCurrentFrame_1;
1595
-
1596
- var _require$1 = ReactComponentTreeHook_1,
1597
- getCurrentStackAddendum$1 = _require$1.getCurrentStackAddendum;
1598
- }
1112
+ var ITERATOR_SYMBOL$1 = typeof Symbol === 'function' && Symbol.iterator;
1113
+ var FAUX_ITERATOR_SYMBOL$1 = '@@iterator'; // Before Symbol spec.
1599
1114
 
1600
1115
  function getDeclarationErrorAddendum() {
1601
1116
  if (ReactCurrentOwner_1.current) {
1602
- var name = getComponentName_1(ReactCurrentOwner_1.current);
1117
+ var name = getComponentName(ReactCurrentOwner_1.current);
1603
1118
  if (name) {
1604
1119
  return '\n\nCheck the render method of `' + name + '`.';
1605
1120
  }
@@ -1665,10 +1180,12 @@ function validateExplicitKey(element, parentType) {
1665
1180
  var childOwner = '';
1666
1181
  if (element && element._owner && element._owner !== ReactCurrentOwner_1.current) {
1667
1182
  // Give the component that originally created this child.
1668
- childOwner = ' It was passed a child from ' + getComponentName_1(element._owner) + '.';
1183
+ childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
1669
1184
  }
1670
1185
 
1671
- warning$2(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;
1672
1189
  }
1673
1190
 
1674
1191
  /**
@@ -1697,9 +1214,10 @@ function validateChildKeys(node, parentType) {
1697
1214
  node._store.validated = true;
1698
1215
  }
1699
1216
  } else if (node) {
1700
- var iteratorFn = getIteratorFn_1(node);
1701
- // Entry iterators provide implicit keys.
1702
- if (iteratorFn) {
1217
+ var iteratorFn = ITERATOR_SYMBOL$1 && node[ITERATOR_SYMBOL$1] || node[FAUX_ITERATOR_SYMBOL$1];
1218
+ if (typeof iteratorFn === 'function') {
1219
+ // Entry iterators used to provide implicit keys,
1220
+ // but now we print a separate warning for them later.
1703
1221
  if (iteratorFn !== node.entries) {
1704
1222
  var iterator = iteratorFn.call(node);
1705
1223
  var step;
@@ -1734,14 +1252,16 @@ function validatePropTypes(element) {
1734
1252
  var propTypes = typeof componentClass.__propTypesSecretDontUseThesePlease === 'object' ? componentClass.__propTypesSecretDontUseThesePlease : componentClass.propTypes;
1735
1253
 
1736
1254
  if (propTypes) {
1737
- checkPropTypes$1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
1255
+ currentlyValidatingElement = element;
1256
+ checkPropTypes$1(propTypes, element.props, 'prop', name, getStackAddendum$1);
1257
+ currentlyValidatingElement = null;
1738
1258
  }
1739
1259
  if (typeof componentClass.getDefaultProps === 'function') {
1740
- warning$2(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1260
+ warning$3(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1741
1261
  }
1742
1262
  }
1743
1263
 
1744
- var ReactElementValidator$2 = {
1264
+ var ReactElementValidator$1 = {
1745
1265
  createElement: function (type, props, children) {
1746
1266
  var validType = typeof type === 'string' || typeof type === 'function';
1747
1267
  // We warn in this case but don't throw. We expect the element creation to
@@ -1759,308 +1279,391 @@ var ReactElementValidator$2 = {
1759
1279
  info += getDeclarationErrorAddendum();
1760
1280
  }
1761
1281
 
1762
- info += getCurrentStackAddendum$1();
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';
1475
+ }
1476
+ }
1477
+
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;
1483
+
1484
+ if (ownerID) {
1485
+ ownerName = ReactComponentTreeHook.getDisplayName(ownerID);
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 || '');
1489
+ }
1490
+
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;
1763
1496
 
1764
- warning$2(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);
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.
1508
+ }
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;
1765
1510
  }
1766
-
1767
- var element = ReactElement_1.createElement.apply(this, arguments);
1768
-
1769
- // The result can be nullish if a mock or a custom function is used.
1770
- // TODO: Drop this when these are no longer allowed as the type argument.
1771
- if (element == null) {
1772
- 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;
1773
1529
  }
1774
-
1775
- {
1776
- 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);
1777
1539
  }
1778
-
1779
- // Skip key warning if the type isn't valid since our key validation logic
1780
- // doesn't expect a non-string/function type and can throw confusing errors.
1781
- // We don't want exception behavior to differ between dev and prod.
1782
- // (Rendering will throw with a helpful message and as soon as the type is
1783
- // fixed, the key warnings will appear.)
1784
- if (validType) {
1785
- for (var i = 2; i < arguments.length; i++) {
1786
- 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);
1787
1562
  }
1788
1563
  }
1789
-
1790
- validatePropTypes(element);
1791
-
1792
- {
1793
- ReactDebugCurrentFrame.element = null;
1564
+ unmountedIDs.push(id);
1565
+ },
1566
+ purgeUnmountedComponents: function () {
1567
+ if (ReactComponentTreeHook._preventPurging) {
1568
+ // Should only be used for testing.
1569
+ return;
1794
1570
  }
1795
1571
 
1796
- return element;
1572
+ for (var i = 0; i < unmountedIDs.length; i++) {
1573
+ var id = unmountedIDs[i];
1574
+ purgeDeep(id);
1575
+ }
1576
+ unmountedIDs.length = 0;
1797
1577
  },
1798
-
1799
- createFactory: function (type) {
1800
- var validatedFactory = ReactElementValidator$2.createElement.bind(null, type);
1801
- // Legacy hook TODO: Warn if this is accessed
1802
- validatedFactory.type = type;
1803
-
1804
- {
1805
- if (canDefineProperty_1) {
1806
- Object.defineProperty(validatedFactory, 'type', {
1807
- enumerable: false,
1808
- get: function () {
1809
- warning$2(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
1810
- Object.defineProperty(this, 'type', {
1811
- value: type
1812
- });
1813
- return type;
1814
- }
1815
- });
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);
1816
1589
  }
1817
1590
  }
1818
-
1819
- return validatedFactory;
1591
+ return info;
1820
1592
  },
1821
-
1822
- cloneElement: function (element, props, children) {
1823
- var newElement = ReactElement_1.cloneElement.apply(this, arguments);
1824
- {
1825
- ReactDebugCurrentFrame.element = newElement;
1593
+ getStackAddendumByID: function (id) {
1594
+ var info = '';
1595
+ while (id) {
1596
+ info += describeID(id);
1597
+ id = ReactComponentTreeHook.getParentID(id);
1826
1598
  }
1827
- for (var i = 2; i < arguments.length; i++) {
1828
- 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;
1829
1609
  }
1830
- validatePropTypes(newElement);
1831
- {
1832
- 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;
1833
1620
  }
1834
- return newElement;
1835
- }
1836
- };
1837
-
1838
- var ReactElementValidator_1 = ReactElementValidator$2;
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
+ },
1839
1647
 
1840
- /**
1841
- * Create a factory that creates HTML tag elements.
1842
- *
1843
- * @private
1844
- */
1845
- var createDOMFactory = ReactElement_1.createFactory;
1846
- {
1847
- var ReactElementValidator$1 = ReactElementValidator_1;
1848
- createDOMFactory = ReactElementValidator$1.createFactory;
1849
- }
1850
1648
 
1851
- /**
1852
- * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
1853
- *
1854
- * @public
1855
- */
1856
- var ReactDOMFactories = {
1857
- a: createDOMFactory('a'),
1858
- abbr: createDOMFactory('abbr'),
1859
- address: createDOMFactory('address'),
1860
- area: createDOMFactory('area'),
1861
- article: createDOMFactory('article'),
1862
- aside: createDOMFactory('aside'),
1863
- audio: createDOMFactory('audio'),
1864
- b: createDOMFactory('b'),
1865
- base: createDOMFactory('base'),
1866
- bdi: createDOMFactory('bdi'),
1867
- bdo: createDOMFactory('bdo'),
1868
- big: createDOMFactory('big'),
1869
- blockquote: createDOMFactory('blockquote'),
1870
- body: createDOMFactory('body'),
1871
- br: createDOMFactory('br'),
1872
- button: createDOMFactory('button'),
1873
- canvas: createDOMFactory('canvas'),
1874
- caption: createDOMFactory('caption'),
1875
- cite: createDOMFactory('cite'),
1876
- code: createDOMFactory('code'),
1877
- col: createDOMFactory('col'),
1878
- colgroup: createDOMFactory('colgroup'),
1879
- data: createDOMFactory('data'),
1880
- datalist: createDOMFactory('datalist'),
1881
- dd: createDOMFactory('dd'),
1882
- del: createDOMFactory('del'),
1883
- details: createDOMFactory('details'),
1884
- dfn: createDOMFactory('dfn'),
1885
- dialog: createDOMFactory('dialog'),
1886
- div: createDOMFactory('div'),
1887
- dl: createDOMFactory('dl'),
1888
- dt: createDOMFactory('dt'),
1889
- em: createDOMFactory('em'),
1890
- embed: createDOMFactory('embed'),
1891
- fieldset: createDOMFactory('fieldset'),
1892
- figcaption: createDOMFactory('figcaption'),
1893
- figure: createDOMFactory('figure'),
1894
- footer: createDOMFactory('footer'),
1895
- form: createDOMFactory('form'),
1896
- h1: createDOMFactory('h1'),
1897
- h2: createDOMFactory('h2'),
1898
- h3: createDOMFactory('h3'),
1899
- h4: createDOMFactory('h4'),
1900
- h5: createDOMFactory('h5'),
1901
- h6: createDOMFactory('h6'),
1902
- head: createDOMFactory('head'),
1903
- header: createDOMFactory('header'),
1904
- hgroup: createDOMFactory('hgroup'),
1905
- hr: createDOMFactory('hr'),
1906
- html: createDOMFactory('html'),
1907
- i: createDOMFactory('i'),
1908
- iframe: createDOMFactory('iframe'),
1909
- img: createDOMFactory('img'),
1910
- input: createDOMFactory('input'),
1911
- ins: createDOMFactory('ins'),
1912
- kbd: createDOMFactory('kbd'),
1913
- keygen: createDOMFactory('keygen'),
1914
- label: createDOMFactory('label'),
1915
- legend: createDOMFactory('legend'),
1916
- li: createDOMFactory('li'),
1917
- link: createDOMFactory('link'),
1918
- main: createDOMFactory('main'),
1919
- map: createDOMFactory('map'),
1920
- mark: createDOMFactory('mark'),
1921
- menu: createDOMFactory('menu'),
1922
- menuitem: createDOMFactory('menuitem'),
1923
- meta: createDOMFactory('meta'),
1924
- meter: createDOMFactory('meter'),
1925
- nav: createDOMFactory('nav'),
1926
- noscript: createDOMFactory('noscript'),
1927
- object: createDOMFactory('object'),
1928
- ol: createDOMFactory('ol'),
1929
- optgroup: createDOMFactory('optgroup'),
1930
- option: createDOMFactory('option'),
1931
- output: createDOMFactory('output'),
1932
- p: createDOMFactory('p'),
1933
- param: createDOMFactory('param'),
1934
- picture: createDOMFactory('picture'),
1935
- pre: createDOMFactory('pre'),
1936
- progress: createDOMFactory('progress'),
1937
- q: createDOMFactory('q'),
1938
- rp: createDOMFactory('rp'),
1939
- rt: createDOMFactory('rt'),
1940
- ruby: createDOMFactory('ruby'),
1941
- s: createDOMFactory('s'),
1942
- samp: createDOMFactory('samp'),
1943
- script: createDOMFactory('script'),
1944
- section: createDOMFactory('section'),
1945
- select: createDOMFactory('select'),
1946
- small: createDOMFactory('small'),
1947
- source: createDOMFactory('source'),
1948
- span: createDOMFactory('span'),
1949
- strong: createDOMFactory('strong'),
1950
- style: createDOMFactory('style'),
1951
- sub: createDOMFactory('sub'),
1952
- summary: createDOMFactory('summary'),
1953
- sup: createDOMFactory('sup'),
1954
- table: createDOMFactory('table'),
1955
- tbody: createDOMFactory('tbody'),
1956
- td: createDOMFactory('td'),
1957
- textarea: createDOMFactory('textarea'),
1958
- tfoot: createDOMFactory('tfoot'),
1959
- th: createDOMFactory('th'),
1960
- thead: createDOMFactory('thead'),
1961
- time: createDOMFactory('time'),
1962
- title: createDOMFactory('title'),
1963
- tr: createDOMFactory('tr'),
1964
- track: createDOMFactory('track'),
1965
- u: createDOMFactory('u'),
1966
- ul: createDOMFactory('ul'),
1967
- 'var': createDOMFactory('var'),
1968
- video: createDOMFactory('video'),
1969
- wbr: createDOMFactory('wbr'),
1970
-
1971
- // SVG
1972
- circle: createDOMFactory('circle'),
1973
- clipPath: createDOMFactory('clipPath'),
1974
- defs: createDOMFactory('defs'),
1975
- ellipse: createDOMFactory('ellipse'),
1976
- g: createDOMFactory('g'),
1977
- image: createDOMFactory('image'),
1978
- line: createDOMFactory('line'),
1979
- linearGradient: createDOMFactory('linearGradient'),
1980
- mask: createDOMFactory('mask'),
1981
- path: createDOMFactory('path'),
1982
- pattern: createDOMFactory('pattern'),
1983
- polygon: createDOMFactory('polygon'),
1984
- polyline: createDOMFactory('polyline'),
1985
- radialGradient: createDOMFactory('radialGradient'),
1986
- rect: createDOMFactory('rect'),
1987
- stop: createDOMFactory('stop'),
1988
- svg: createDOMFactory('svg'),
1989
- text: createDOMFactory('text'),
1990
- tspan: createDOMFactory('tspan')
1649
+ getRootIDs: getRootIDs,
1650
+ getRegisteredIDs: getItemIDs
1991
1651
  };
1992
1652
 
1993
- var ReactDOMFactories_1 = ReactDOMFactories;
1994
-
1995
- var isValidElement = ReactElement_1.isValidElement;
1996
-
1997
-
1998
-
1999
- var ReactPropTypes = factory(isValidElement);
2000
-
2001
- /**
2002
- * Copyright 2013-present, Facebook, Inc.
2003
- * All rights reserved.
2004
- *
2005
- * This source code is licensed under the BSD-style license found in the
2006
- * LICENSE file in the root directory of this source tree. An additional grant
2007
- * of patent rights can be found in the PATENTS file in the same directory.
2008
- *
2009
- * @providesModule ReactVersion
2010
- */
2011
-
2012
- var ReactVersion = '16.0.0-alpha.11';
2013
-
2014
- /**
2015
- * Returns the first child in a collection of children and verifies that there
2016
- * is only one child in the collection.
2017
- *
2018
- * See https://facebook.github.io/react/docs/react-api.html#react.children.only
2019
- *
2020
- * The current implementation of this function assumes that a single child gets
2021
- * passed without a wrapper, but the purpose of this helper function is to
2022
- * abstract away the particular structure of children.
2023
- *
2024
- * @param {?object} children Child collection structure.
2025
- * @return {ReactElement} The first and only `ReactElement` contained in the
2026
- * structure.
2027
- */
2028
- function onlyChild(children) {
2029
- !ReactElement_1.isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
2030
- return children;
2031
- }
2032
-
2033
- var onlyChild_1 = onlyChild;
2034
-
2035
- var Component = ReactBaseClasses.Component;
2036
-
2037
- var isValidElement$1 = ReactElement_1.isValidElement;
2038
-
2039
-
2040
-
2041
-
2042
- var createClass = factory$1(Component, isValidElement$1, ReactNoopUpdateQueue_1);
1653
+ var ReactComponentTreeHook_1 = ReactComponentTreeHook;
2043
1654
 
2044
1655
  var createElement = ReactElement_1.createElement;
2045
1656
  var createFactory = ReactElement_1.createFactory;
2046
1657
  var cloneElement = ReactElement_1.cloneElement;
2047
1658
 
2048
1659
  {
2049
- var warning$1 = warning;
2050
- var canDefineProperty = canDefineProperty_1;
2051
1660
  var ReactElementValidator = ReactElementValidator_1;
2052
1661
  createElement = ReactElementValidator.createElement;
2053
1662
  createFactory = ReactElementValidator.createFactory;
2054
1663
  cloneElement = ReactElementValidator.cloneElement;
2055
1664
  }
2056
1665
 
2057
- var createMixin = function (mixin) {
2058
- return mixin;
2059
- };
2060
-
2061
1666
  var React = {
2062
- // Modern
2063
-
2064
1667
  Children: {
2065
1668
  map: ReactChildren_1.map,
2066
1669
  forEach: ReactChildren_1.forEach,
@@ -2071,24 +1674,13 @@ var React = {
2071
1674
 
2072
1675
  Component: ReactBaseClasses.Component,
2073
1676
  PureComponent: ReactBaseClasses.PureComponent,
1677
+ unstable_AsyncComponent: ReactBaseClasses.AsyncComponent,
2074
1678
 
2075
1679
  createElement: createElement,
2076
1680
  cloneElement: cloneElement,
2077
1681
  isValidElement: ReactElement_1.isValidElement,
2078
1682
 
2079
- // TODO (bvaughn) Remove these getters before 16.0.0
2080
- PropTypes: ReactPropTypes,
2081
- checkPropTypes: checkPropTypes,
2082
- createClass: createClass,
2083
-
2084
- // Classic
2085
-
2086
1683
  createFactory: createFactory,
2087
- createMixin: createMixin,
2088
-
2089
- // This looks DOM specific but these are actually isomorphic helpers
2090
- // since they are just generating DOM strings.
2091
- DOM: ReactDOMFactories_1,
2092
1684
 
2093
1685
  version: ReactVersion,
2094
1686
 
@@ -2103,61 +1695,10 @@ var React = {
2103
1695
  ReactComponentTreeHook: ReactComponentTreeHook_1,
2104
1696
  ReactDebugCurrentFrame: ReactDebugCurrentFrame_1
2105
1697
  });
1698
+ }
2106
1699
 
2107
- var warnedForCheckPropTypes = false;
2108
- var warnedForCreateMixin = false;
2109
- var warnedForCreateClass = false;
2110
- var warnedForPropTypes = false;
2111
-
2112
- React.createMixin = function (mixin) {
2113
- warning$1(warnedForCreateMixin, 'React.createMixin is deprecated and should not be used. You ' + 'can use this mixin directly instead.');
2114
- warnedForCreateMixin = true;
2115
- return mixin;
2116
- };
2117
-
2118
- // TODO (bvaughn) Remove all of these accessors before 16.0.0
2119
- if (canDefineProperty) {
2120
- Object.defineProperty(React, 'checkPropTypes', {
2121
- get: function () {
2122
- 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)');
2123
- warnedForCheckPropTypes = true;
2124
- return checkPropTypes;
2125
- }
2126
- });
2127
-
2128
- Object.defineProperty(React, 'createClass', {
2129
- get: function () {
2130
- 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)');
2131
- warnedForCreateClass = true;
2132
- return createClass;
2133
- }
2134
- });
1700
+ var ReactEntry = React;
2135
1701
 
2136
- Object.defineProperty(React, 'PropTypes', {
2137
- get: function () {
2138
- 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)');
2139
- warnedForPropTypes = true;
2140
- return ReactPropTypes;
2141
- }
2142
- });
2143
- }
1702
+ module.exports = ReactEntry;
2144
1703
 
2145
- // React.DOM factories are deprecated. Wrap these methods so that
2146
- // invocations of the React.DOM namespace and alert users to switch
2147
- // to the `react-addons-dom-factories` package.
2148
- React.DOM = {};
2149
- var warnedForFactories = false;
2150
- Object.keys(ReactDOMFactories_1).forEach(function (factory$$1) {
2151
- React.DOM[factory$$1] = function () {
2152
- if (!warnedForFactories) {
2153
- warning$1(false, 'Accessing factories like React.DOM.%s has been deprecated ' + 'and will be removed in the future. Use the ' + 'react-addons-dom-factories package instead.', factory$$1);
2154
- warnedForFactories = true;
2155
- }
2156
- return ReactDOMFactories_1[factory$$1].apply(ReactDOMFactories_1, arguments);
2157
- };
2158
- });
2159
1704
  }
2160
-
2161
- var React_1 = React;
2162
-
2163
- module.exports = React_1;