react 16.0.0-alpha.12 → 16.0.0-beta.3

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