UNPKG

74 kBJavaScriptView Raw
1/** @license React v16.9.0
2 * react.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12
13
14if (process.env.NODE_ENV !== "production") {
15 (function() {
16'use strict';
17
18var _assign = require('object-assign');
19var checkPropTypes = require('prop-types/checkPropTypes');
20
21// TODO: this is special because it gets imported during build.
22
23var ReactVersion = '16.9.0';
24
25// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
26// nor polyfill, then a plain number is used for performance.
27var hasSymbol = typeof Symbol === 'function' && Symbol.for;
28
29var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
30var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
31var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
32var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
33var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
34var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
35var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
36// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
37// (unstable) APIs that have been removed. Can we remove the symbols?
38
39var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
40var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
41var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
42var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
43var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
44var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
45var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
46var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
47
48var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
49var FAUX_ITERATOR_SYMBOL = '@@iterator';
50
51function getIteratorFn(maybeIterable) {
52 if (maybeIterable === null || typeof maybeIterable !== 'object') {
53 return null;
54 }
55 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
56 if (typeof maybeIterator === 'function') {
57 return maybeIterator;
58 }
59 return null;
60}
61
62// Do not require this module directly! Use normal `invariant` calls with
63// template literal strings. The messages will be converted to ReactError during
64// build, and in production they will be minified.
65
66// Do not require this module directly! Use normal `invariant` calls with
67// template literal strings. The messages will be converted to ReactError during
68// build, and in production they will be minified.
69
70function ReactError(error) {
71 error.name = 'Invariant Violation';
72 return error;
73}
74
75/**
76 * Use invariant() to assert state which your program assumes to be true.
77 *
78 * Provide sprintf-style format (only %s is supported) and arguments
79 * to provide information about what broke and what you were
80 * expecting.
81 *
82 * The invariant message will be stripped in production, but the invariant
83 * will remain to ensure logic does not differ in production.
84 */
85
86/**
87 * Forked from fbjs/warning:
88 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
89 *
90 * Only change is we use console.warn instead of console.error,
91 * and do nothing when 'console' is not supported.
92 * This really simplifies the code.
93 * ---
94 * Similar to invariant but only logs a warning if the condition is not met.
95 * This can be used to log issues in development environments in critical
96 * paths. Removing the logging code for production environments will keep the
97 * same logic and follow the same code paths.
98 */
99
100var lowPriorityWarning = function () {};
101
102{
103 var printWarning = function (format) {
104 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
105 args[_key - 1] = arguments[_key];
106 }
107
108 var argIndex = 0;
109 var message = 'Warning: ' + format.replace(/%s/g, function () {
110 return args[argIndex++];
111 });
112 if (typeof console !== 'undefined') {
113 console.warn(message);
114 }
115 try {
116 // --- Welcome to debugging React ---
117 // This error was thrown as a convenience so that you can use this stack
118 // to find the callsite that caused this warning to fire.
119 throw new Error(message);
120 } catch (x) {}
121 };
122
123 lowPriorityWarning = function (condition, format) {
124 if (format === undefined) {
125 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
126 }
127 if (!condition) {
128 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
129 args[_key2 - 2] = arguments[_key2];
130 }
131
132 printWarning.apply(undefined, [format].concat(args));
133 }
134 };
135}
136
137var lowPriorityWarning$1 = lowPriorityWarning;
138
139/**
140 * Similar to invariant but only logs a warning if the condition is not met.
141 * This can be used to log issues in development environments in critical
142 * paths. Removing the logging code for production environments will keep the
143 * same logic and follow the same code paths.
144 */
145
146var warningWithoutStack = function () {};
147
148{
149 warningWithoutStack = function (condition, format) {
150 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
151 args[_key - 2] = arguments[_key];
152 }
153
154 if (format === undefined) {
155 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
156 }
157 if (args.length > 8) {
158 // Check before the condition to catch violations early.
159 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
160 }
161 if (condition) {
162 return;
163 }
164 if (typeof console !== 'undefined') {
165 var argsWithFormat = args.map(function (item) {
166 return '' + item;
167 });
168 argsWithFormat.unshift('Warning: ' + format);
169
170 // We intentionally don't use spread (or .apply) directly because it
171 // breaks IE9: https://github.com/facebook/react/issues/13610
172 Function.prototype.apply.call(console.error, console, argsWithFormat);
173 }
174 try {
175 // --- Welcome to debugging React ---
176 // This error was thrown as a convenience so that you can use this stack
177 // to find the callsite that caused this warning to fire.
178 var argIndex = 0;
179 var message = 'Warning: ' + format.replace(/%s/g, function () {
180 return args[argIndex++];
181 });
182 throw new Error(message);
183 } catch (x) {}
184 };
185}
186
187var warningWithoutStack$1 = warningWithoutStack;
188
189var didWarnStateUpdateForUnmountedComponent = {};
190
191function warnNoop(publicInstance, callerName) {
192 {
193 var _constructor = publicInstance.constructor;
194 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
195 var warningKey = componentName + '.' + callerName;
196 if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
197 return;
198 }
199 warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
200 didWarnStateUpdateForUnmountedComponent[warningKey] = true;
201 }
202}
203
204/**
205 * This is the abstract API for an update queue.
206 */
207var ReactNoopUpdateQueue = {
208 /**
209 * Checks whether or not this composite component is mounted.
210 * @param {ReactClass} publicInstance The instance we want to test.
211 * @return {boolean} True if mounted, false otherwise.
212 * @protected
213 * @final
214 */
215 isMounted: function (publicInstance) {
216 return false;
217 },
218
219 /**
220 * Forces an update. This should only be invoked when it is known with
221 * certainty that we are **not** in a DOM transaction.
222 *
223 * You may want to call this when you know that some deeper aspect of the
224 * component's state has changed but `setState` was not called.
225 *
226 * This will not invoke `shouldComponentUpdate`, but it will invoke
227 * `componentWillUpdate` and `componentDidUpdate`.
228 *
229 * @param {ReactClass} publicInstance The instance that should rerender.
230 * @param {?function} callback Called after component is updated.
231 * @param {?string} callerName name of the calling function in the public API.
232 * @internal
233 */
234 enqueueForceUpdate: function (publicInstance, callback, callerName) {
235 warnNoop(publicInstance, 'forceUpdate');
236 },
237
238 /**
239 * Replaces all of the state. Always use this or `setState` to mutate state.
240 * You should treat `this.state` as immutable.
241 *
242 * There is no guarantee that `this.state` will be immediately updated, so
243 * accessing `this.state` after calling this method may return the old value.
244 *
245 * @param {ReactClass} publicInstance The instance that should rerender.
246 * @param {object} completeState Next state.
247 * @param {?function} callback Called after component is updated.
248 * @param {?string} callerName name of the calling function in the public API.
249 * @internal
250 */
251 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
252 warnNoop(publicInstance, 'replaceState');
253 },
254
255 /**
256 * Sets a subset of the state. This only exists because _pendingState is
257 * internal. This provides a merging strategy that is not available to deep
258 * properties which is confusing. TODO: Expose pendingState or don't use it
259 * during the merge.
260 *
261 * @param {ReactClass} publicInstance The instance that should rerender.
262 * @param {object} partialState Next partial state to be merged with state.
263 * @param {?function} callback Called after component is updated.
264 * @param {?string} Name of the calling function in the public API.
265 * @internal
266 */
267 enqueueSetState: function (publicInstance, partialState, callback, callerName) {
268 warnNoop(publicInstance, 'setState');
269 }
270};
271
272var emptyObject = {};
273{
274 Object.freeze(emptyObject);
275}
276
277/**
278 * Base class helpers for the updating state of a component.
279 */
280function Component(props, context, updater) {
281 this.props = props;
282 this.context = context;
283 // If a component has string refs, we will assign a different object later.
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;
288}
289
290Component.prototype.isReactComponent = {};
291
292/**
293 * Sets a subset of the state. Always use this to mutate
294 * state. You should treat `this.state` as immutable.
295 *
296 * There is no guarantee that `this.state` will be immediately updated, so
297 * accessing `this.state` after calling this method may return the old value.
298 *
299 * There is no guarantee that calls to `setState` will run synchronously,
300 * as they may eventually be batched together. You can provide an optional
301 * callback that will be executed when the call to setState is actually
302 * completed.
303 *
304 * When a function is provided to setState, it will be called at some point in
305 * the future (not synchronously). It will be called with the up to date
306 * component arguments (state, props, context). These values can be different
307 * from this.* because your function may be called after receiveProps but before
308 * shouldComponentUpdate, and this new state, props, and context will not yet be
309 * assigned to this.
310 *
311 * @param {object|function} partialState Next partial state or function to
312 * produce next partial state to be merged with current state.
313 * @param {?function} callback Called after state is updated.
314 * @final
315 * @protected
316 */
317Component.prototype.setState = function (partialState, callback) {
318 (function () {
319 if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
320 {
321 throw ReactError(Error('setState(...): takes an object of state variables to update or a function which returns an object of state variables.'));
322 }
323 }
324 })();
325 this.updater.enqueueSetState(this, partialState, callback, 'setState');
326};
327
328/**
329 * Forces an update. This should only be invoked when it is known with
330 * certainty that we are **not** in a DOM transaction.
331 *
332 * You may want to call this when you know that some deeper aspect of the
333 * component's state has changed but `setState` was not called.
334 *
335 * This will not invoke `shouldComponentUpdate`, but it will invoke
336 * `componentWillUpdate` and `componentDidUpdate`.
337 *
338 * @param {?function} callback Called after update is complete.
339 * @final
340 * @protected
341 */
342Component.prototype.forceUpdate = function (callback) {
343 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
344};
345
346/**
347 * Deprecated APIs. These APIs used to exist on classic React classes but since
348 * we would like to deprecate them, we're not going to move them over to this
349 * modern base class. Instead, we define a getter that warns if it's accessed.
350 */
351{
352 var deprecatedAPIs = {
353 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
354 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
355 };
356 var defineDeprecationWarning = function (methodName, info) {
357 Object.defineProperty(Component.prototype, methodName, {
358 get: function () {
359 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
360 return undefined;
361 }
362 });
363 };
364 for (var fnName in deprecatedAPIs) {
365 if (deprecatedAPIs.hasOwnProperty(fnName)) {
366 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
367 }
368 }
369}
370
371function ComponentDummy() {}
372ComponentDummy.prototype = Component.prototype;
373
374/**
375 * Convenience component with default shallow equality check for sCU.
376 */
377function PureComponent(props, context, updater) {
378 this.props = props;
379 this.context = context;
380 // If a component has string refs, we will assign a different object later.
381 this.refs = emptyObject;
382 this.updater = updater || ReactNoopUpdateQueue;
383}
384
385var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
386pureComponentPrototype.constructor = PureComponent;
387// Avoid an extra prototype jump for these methods.
388_assign(pureComponentPrototype, Component.prototype);
389pureComponentPrototype.isPureReactComponent = true;
390
391// an immutable object with a single mutable value
392function createRef() {
393 var refObject = {
394 current: null
395 };
396 {
397 Object.seal(refObject);
398 }
399 return refObject;
400}
401
402/**
403 * Keeps track of the current dispatcher.
404 */
405var ReactCurrentDispatcher = {
406 /**
407 * @internal
408 * @type {ReactComponent}
409 */
410 current: null
411};
412
413/**
414 * Keeps track of the current batch's configuration such as how long an update
415 * should suspend for if it needs to.
416 */
417var ReactCurrentBatchConfig = {
418 suspense: null
419};
420
421/**
422 * Keeps track of the current owner.
423 *
424 * The current owner is the component who should own any components that are
425 * currently being constructed.
426 */
427var ReactCurrentOwner = {
428 /**
429 * @internal
430 * @type {ReactComponent}
431 */
432 current: null
433};
434
435var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
436
437var describeComponentFrame = function (name, source, ownerName) {
438 var sourceInfo = '';
439 if (source) {
440 var path = source.fileName;
441 var fileName = path.replace(BEFORE_SLASH_RE, '');
442 {
443 // In DEV, include code for a common special case:
444 // prefer "folder/index.js" instead of just "index.js".
445 if (/^index\./.test(fileName)) {
446 var match = path.match(BEFORE_SLASH_RE);
447 if (match) {
448 var pathBeforeSlash = match[1];
449 if (pathBeforeSlash) {
450 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
451 fileName = folderName + '/' + fileName;
452 }
453 }
454 }
455 }
456 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
457 } else if (ownerName) {
458 sourceInfo = ' (created by ' + ownerName + ')';
459 }
460 return '\n in ' + (name || 'Unknown') + sourceInfo;
461};
462
463var Resolved = 1;
464
465
466function refineResolvedLazyComponent(lazyComponent) {
467 return lazyComponent._status === Resolved ? lazyComponent._result : null;
468}
469
470function getWrappedName(outerType, innerType, wrapperName) {
471 var functionName = innerType.displayName || innerType.name || '';
472 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
473}
474
475function getComponentName(type) {
476 if (type == null) {
477 // Host root, text node or just invalid type.
478 return null;
479 }
480 {
481 if (typeof type.tag === 'number') {
482 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
483 }
484 }
485 if (typeof type === 'function') {
486 return type.displayName || type.name || null;
487 }
488 if (typeof type === 'string') {
489 return type;
490 }
491 switch (type) {
492 case REACT_FRAGMENT_TYPE:
493 return 'Fragment';
494 case REACT_PORTAL_TYPE:
495 return 'Portal';
496 case REACT_PROFILER_TYPE:
497 return 'Profiler';
498 case REACT_STRICT_MODE_TYPE:
499 return 'StrictMode';
500 case REACT_SUSPENSE_TYPE:
501 return 'Suspense';
502 case REACT_SUSPENSE_LIST_TYPE:
503 return 'SuspenseList';
504 }
505 if (typeof type === 'object') {
506 switch (type.$$typeof) {
507 case REACT_CONTEXT_TYPE:
508 return 'Context.Consumer';
509 case REACT_PROVIDER_TYPE:
510 return 'Context.Provider';
511 case REACT_FORWARD_REF_TYPE:
512 return getWrappedName(type, type.render, 'ForwardRef');
513 case REACT_MEMO_TYPE:
514 return getComponentName(type.type);
515 case REACT_LAZY_TYPE:
516 {
517 var thenable = type;
518 var resolvedThenable = refineResolvedLazyComponent(thenable);
519 if (resolvedThenable) {
520 return getComponentName(resolvedThenable);
521 }
522 break;
523 }
524 }
525 }
526 return null;
527}
528
529var ReactDebugCurrentFrame = {};
530
531var currentlyValidatingElement = null;
532
533function setCurrentlyValidatingElement(element) {
534 {
535 currentlyValidatingElement = element;
536 }
537}
538
539{
540 // Stack implementation injected by the current renderer.
541 ReactDebugCurrentFrame.getCurrentStack = null;
542
543 ReactDebugCurrentFrame.getStackAddendum = function () {
544 var stack = '';
545
546 // Add an extra top frame while an element is being validated
547 if (currentlyValidatingElement) {
548 var name = getComponentName(currentlyValidatingElement.type);
549 var owner = currentlyValidatingElement._owner;
550 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
551 }
552
553 // Delegate to the injected renderer-specific implementation
554 var impl = ReactDebugCurrentFrame.getCurrentStack;
555 if (impl) {
556 stack += impl() || '';
557 }
558
559 return stack;
560 };
561}
562
563/**
564 * Used by act() to track whether you're inside an act() scope.
565 */
566
567var IsSomeRendererActing = {
568 current: false
569};
570
571var ReactSharedInternals = {
572 ReactCurrentDispatcher: ReactCurrentDispatcher,
573 ReactCurrentBatchConfig: ReactCurrentBatchConfig,
574 ReactCurrentOwner: ReactCurrentOwner,
575 IsSomeRendererActing: IsSomeRendererActing,
576 // Used by renderers to avoid bundling object-assign twice in UMD bundles:
577 assign: _assign
578};
579
580{
581 _assign(ReactSharedInternals, {
582 // These should not be included in production.
583 ReactDebugCurrentFrame: ReactDebugCurrentFrame,
584 // Shim for React DOM 16.0.0 which still destructured (but not used) this.
585 // TODO: remove in React 17.0.
586 ReactComponentTreeHook: {}
587 });
588}
589
590/**
591 * Similar to invariant but only logs a warning if the condition is not met.
592 * This can be used to log issues in development environments in critical
593 * paths. Removing the logging code for production environments will keep the
594 * same logic and follow the same code paths.
595 */
596
597var warning = warningWithoutStack$1;
598
599{
600 warning = function (condition, format) {
601 if (condition) {
602 return;
603 }
604 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
605 var stack = ReactDebugCurrentFrame.getStackAddendum();
606 // eslint-disable-next-line react-internal/warning-and-invariant-args
607
608 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
609 args[_key - 2] = arguments[_key];
610 }
611
612 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
613 };
614}
615
616var warning$1 = warning;
617
618var hasOwnProperty = Object.prototype.hasOwnProperty;
619
620var RESERVED_PROPS = {
621 key: true,
622 ref: true,
623 __self: true,
624 __source: true
625};
626
627var specialPropKeyWarningShown = void 0;
628var specialPropRefWarningShown = void 0;
629
630function hasValidRef(config) {
631 {
632 if (hasOwnProperty.call(config, 'ref')) {
633 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
634 if (getter && getter.isReactWarning) {
635 return false;
636 }
637 }
638 }
639 return config.ref !== undefined;
640}
641
642function hasValidKey(config) {
643 {
644 if (hasOwnProperty.call(config, 'key')) {
645 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
646 if (getter && getter.isReactWarning) {
647 return false;
648 }
649 }
650 }
651 return config.key !== undefined;
652}
653
654function defineKeyPropWarningGetter(props, displayName) {
655 var warnAboutAccessingKey = function () {
656 if (!specialPropKeyWarningShown) {
657 specialPropKeyWarningShown = true;
658 warningWithoutStack$1(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);
659 }
660 };
661 warnAboutAccessingKey.isReactWarning = true;
662 Object.defineProperty(props, 'key', {
663 get: warnAboutAccessingKey,
664 configurable: true
665 });
666}
667
668function defineRefPropWarningGetter(props, displayName) {
669 var warnAboutAccessingRef = function () {
670 if (!specialPropRefWarningShown) {
671 specialPropRefWarningShown = true;
672 warningWithoutStack$1(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);
673 }
674 };
675 warnAboutAccessingRef.isReactWarning = true;
676 Object.defineProperty(props, 'ref', {
677 get: warnAboutAccessingRef,
678 configurable: true
679 });
680}
681
682/**
683 * Factory method to create a new React element. This no longer adheres to
684 * the class pattern, so do not use new to call it. Also, no instanceof check
685 * will work. Instead test $$typeof field against Symbol.for('react.element') to check
686 * if something is a React Element.
687 *
688 * @param {*} type
689 * @param {*} props
690 * @param {*} key
691 * @param {string|object} ref
692 * @param {*} owner
693 * @param {*} self A *temporary* helper to detect places where `this` is
694 * different from the `owner` when React.createElement is called, so that we
695 * can warn. We want to get rid of owner and replace string `ref`s with arrow
696 * functions, and as long as `this` and owner are the same, there will be no
697 * change in behavior.
698 * @param {*} source An annotation object (added by a transpiler or otherwise)
699 * indicating filename, line number, and/or other information.
700 * @internal
701 */
702var ReactElement = function (type, key, ref, self, source, owner, props) {
703 var element = {
704 // This tag allows us to uniquely identify this as a React Element
705 $$typeof: REACT_ELEMENT_TYPE,
706
707 // Built-in properties that belong on the element
708 type: type,
709 key: key,
710 ref: ref,
711 props: props,
712
713 // Record the component responsible for creating this element.
714 _owner: owner
715 };
716
717 {
718 // The validation flag is currently mutative. We put it on
719 // an external backing store so that we can freeze the whole object.
720 // This can be replaced with a WeakMap once they are implemented in
721 // commonly used development environments.
722 element._store = {};
723
724 // To make comparing ReactElements easier for testing purposes, we make
725 // the validation flag non-enumerable (where possible, which should
726 // include every environment we run tests in), so the test framework
727 // ignores it.
728 Object.defineProperty(element._store, 'validated', {
729 configurable: false,
730 enumerable: false,
731 writable: true,
732 value: false
733 });
734 // self and source are DEV only properties.
735 Object.defineProperty(element, '_self', {
736 configurable: false,
737 enumerable: false,
738 writable: false,
739 value: self
740 });
741 // Two elements created in two different places should be considered
742 // equal for testing purposes and therefore we hide it from enumeration.
743 Object.defineProperty(element, '_source', {
744 configurable: false,
745 enumerable: false,
746 writable: false,
747 value: source
748 });
749 if (Object.freeze) {
750 Object.freeze(element.props);
751 Object.freeze(element);
752 }
753 }
754
755 return element;
756};
757
758/**
759 * https://github.com/reactjs/rfcs/pull/107
760 * @param {*} type
761 * @param {object} props
762 * @param {string} key
763 */
764
765
766/**
767 * https://github.com/reactjs/rfcs/pull/107
768 * @param {*} type
769 * @param {object} props
770 * @param {string} key
771 */
772function jsxDEV(type, config, maybeKey, source, self) {
773 var propName = void 0;
774
775 // Reserved names are extracted
776 var props = {};
777
778 var key = null;
779 var ref = null;
780
781 if (hasValidRef(config)) {
782 ref = config.ref;
783 }
784
785 if (hasValidKey(config)) {
786 key = '' + config.key;
787 }
788
789 // Remaining properties are added to a new props object
790 for (propName in config) {
791 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
792 props[propName] = config[propName];
793 }
794 }
795
796 // intentionally not checking if key was set above
797 // this key is higher priority as it's static
798 if (maybeKey !== undefined) {
799 key = '' + maybeKey;
800 }
801
802 // Resolve default props
803 if (type && type.defaultProps) {
804 var defaultProps = type.defaultProps;
805 for (propName in defaultProps) {
806 if (props[propName] === undefined) {
807 props[propName] = defaultProps[propName];
808 }
809 }
810 }
811
812 if (key || ref) {
813 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
814 if (key) {
815 defineKeyPropWarningGetter(props, displayName);
816 }
817 if (ref) {
818 defineRefPropWarningGetter(props, displayName);
819 }
820 }
821
822 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
823}
824
825/**
826 * Create and return a new ReactElement of the given type.
827 * See https://reactjs.org/docs/react-api.html#createelement
828 */
829function createElement(type, config, children) {
830 var propName = void 0;
831
832 // Reserved names are extracted
833 var props = {};
834
835 var key = null;
836 var ref = null;
837 var self = null;
838 var source = null;
839
840 if (config != null) {
841 if (hasValidRef(config)) {
842 ref = config.ref;
843 }
844 if (hasValidKey(config)) {
845 key = '' + config.key;
846 }
847
848 self = config.__self === undefined ? null : config.__self;
849 source = config.__source === undefined ? null : config.__source;
850 // Remaining properties are added to a new props object
851 for (propName in config) {
852 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
853 props[propName] = config[propName];
854 }
855 }
856 }
857
858 // Children can be more than one argument, and those are transferred onto
859 // the newly allocated props object.
860 var childrenLength = arguments.length - 2;
861 if (childrenLength === 1) {
862 props.children = children;
863 } else if (childrenLength > 1) {
864 var childArray = Array(childrenLength);
865 for (var i = 0; i < childrenLength; i++) {
866 childArray[i] = arguments[i + 2];
867 }
868 {
869 if (Object.freeze) {
870 Object.freeze(childArray);
871 }
872 }
873 props.children = childArray;
874 }
875
876 // Resolve default props
877 if (type && type.defaultProps) {
878 var defaultProps = type.defaultProps;
879 for (propName in defaultProps) {
880 if (props[propName] === undefined) {
881 props[propName] = defaultProps[propName];
882 }
883 }
884 }
885 {
886 if (key || ref) {
887 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
888 if (key) {
889 defineKeyPropWarningGetter(props, displayName);
890 }
891 if (ref) {
892 defineRefPropWarningGetter(props, displayName);
893 }
894 }
895 }
896 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
897}
898
899/**
900 * Return a function that produces ReactElements of a given type.
901 * See https://reactjs.org/docs/react-api.html#createfactory
902 */
903
904
905function cloneAndReplaceKey(oldElement, newKey) {
906 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
907
908 return newElement;
909}
910
911/**
912 * Clone and return a new ReactElement using element as the starting point.
913 * See https://reactjs.org/docs/react-api.html#cloneelement
914 */
915function cloneElement(element, config, children) {
916 (function () {
917 if (!!(element === null || element === undefined)) {
918 {
919 throw ReactError(Error('React.cloneElement(...): The argument must be a React element, but you passed ' + element + '.'));
920 }
921 }
922 })();
923
924 var propName = void 0;
925
926 // Original props are copied
927 var props = _assign({}, element.props);
928
929 // Reserved names are extracted
930 var key = element.key;
931 var ref = element.ref;
932 // Self is preserved since the owner is preserved.
933 var self = element._self;
934 // Source is preserved since cloneElement is unlikely to be targeted by a
935 // transpiler, and the original source is probably a better indicator of the
936 // true owner.
937 var source = element._source;
938
939 // Owner will be preserved, unless ref is overridden
940 var owner = element._owner;
941
942 if (config != null) {
943 if (hasValidRef(config)) {
944 // Silently steal the ref from the parent.
945 ref = config.ref;
946 owner = ReactCurrentOwner.current;
947 }
948 if (hasValidKey(config)) {
949 key = '' + config.key;
950 }
951
952 // Remaining properties override existing props
953 var defaultProps = void 0;
954 if (element.type && element.type.defaultProps) {
955 defaultProps = element.type.defaultProps;
956 }
957 for (propName in config) {
958 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
959 if (config[propName] === undefined && defaultProps !== undefined) {
960 // Resolve default props
961 props[propName] = defaultProps[propName];
962 } else {
963 props[propName] = config[propName];
964 }
965 }
966 }
967 }
968
969 // Children can be more than one argument, and those are transferred onto
970 // the newly allocated props object.
971 var childrenLength = arguments.length - 2;
972 if (childrenLength === 1) {
973 props.children = children;
974 } else if (childrenLength > 1) {
975 var childArray = Array(childrenLength);
976 for (var i = 0; i < childrenLength; i++) {
977 childArray[i] = arguments[i + 2];
978 }
979 props.children = childArray;
980 }
981
982 return ReactElement(element.type, key, ref, self, source, owner, props);
983}
984
985/**
986 * Verifies the object is a ReactElement.
987 * See https://reactjs.org/docs/react-api.html#isvalidelement
988 * @param {?object} object
989 * @return {boolean} True if `object` is a ReactElement.
990 * @final
991 */
992function isValidElement(object) {
993 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
994}
995
996var SEPARATOR = '.';
997var SUBSEPARATOR = ':';
998
999/**
1000 * Escape and wrap key so it is safe to use as a reactid
1001 *
1002 * @param {string} key to be escaped.
1003 * @return {string} the escaped key.
1004 */
1005function escape(key) {
1006 var escapeRegex = /[=:]/g;
1007 var escaperLookup = {
1008 '=': '=0',
1009 ':': '=2'
1010 };
1011 var escapedString = ('' + key).replace(escapeRegex, function (match) {
1012 return escaperLookup[match];
1013 });
1014
1015 return '$' + escapedString;
1016}
1017
1018/**
1019 * TODO: Test that a single child and an array with one item have the same key
1020 * pattern.
1021 */
1022
1023var didWarnAboutMaps = false;
1024
1025var userProvidedKeyEscapeRegex = /\/+/g;
1026function escapeUserProvidedKey(text) {
1027 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
1028}
1029
1030var POOL_SIZE = 10;
1031var traverseContextPool = [];
1032function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
1033 if (traverseContextPool.length) {
1034 var traverseContext = traverseContextPool.pop();
1035 traverseContext.result = mapResult;
1036 traverseContext.keyPrefix = keyPrefix;
1037 traverseContext.func = mapFunction;
1038 traverseContext.context = mapContext;
1039 traverseContext.count = 0;
1040 return traverseContext;
1041 } else {
1042 return {
1043 result: mapResult,
1044 keyPrefix: keyPrefix,
1045 func: mapFunction,
1046 context: mapContext,
1047 count: 0
1048 };
1049 }
1050}
1051
1052function releaseTraverseContext(traverseContext) {
1053 traverseContext.result = null;
1054 traverseContext.keyPrefix = null;
1055 traverseContext.func = null;
1056 traverseContext.context = null;
1057 traverseContext.count = 0;
1058 if (traverseContextPool.length < POOL_SIZE) {
1059 traverseContextPool.push(traverseContext);
1060 }
1061}
1062
1063/**
1064 * @param {?*} children Children tree container.
1065 * @param {!string} nameSoFar Name of the key path so far.
1066 * @param {!function} callback Callback to invoke with each child found.
1067 * @param {?*} traverseContext Used to pass information throughout the traversal
1068 * process.
1069 * @return {!number} The number of children in this subtree.
1070 */
1071function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
1072 var type = typeof children;
1073
1074 if (type === 'undefined' || type === 'boolean') {
1075 // All of the above are perceived as null.
1076 children = null;
1077 }
1078
1079 var invokeCallback = false;
1080
1081 if (children === null) {
1082 invokeCallback = true;
1083 } else {
1084 switch (type) {
1085 case 'string':
1086 case 'number':
1087 invokeCallback = true;
1088 break;
1089 case 'object':
1090 switch (children.$$typeof) {
1091 case REACT_ELEMENT_TYPE:
1092 case REACT_PORTAL_TYPE:
1093 invokeCallback = true;
1094 }
1095 }
1096 }
1097
1098 if (invokeCallback) {
1099 callback(traverseContext, children,
1100 // If it's the only child, treat the name as if it was wrapped in an array
1101 // so that it's consistent if the number of children grows.
1102 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
1103 return 1;
1104 }
1105
1106 var child = void 0;
1107 var nextName = void 0;
1108 var subtreeCount = 0; // Count of children found in the current subtree.
1109 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1110
1111 if (Array.isArray(children)) {
1112 for (var i = 0; i < children.length; i++) {
1113 child = children[i];
1114 nextName = nextNamePrefix + getComponentKey(child, i);
1115 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1116 }
1117 } else {
1118 var iteratorFn = getIteratorFn(children);
1119 if (typeof iteratorFn === 'function') {
1120 {
1121 // Warn about using Maps as children
1122 if (iteratorFn === children.entries) {
1123 !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
1124 didWarnAboutMaps = true;
1125 }
1126 }
1127
1128 var iterator = iteratorFn.call(children);
1129 var step = void 0;
1130 var ii = 0;
1131 while (!(step = iterator.next()).done) {
1132 child = step.value;
1133 nextName = nextNamePrefix + getComponentKey(child, ii++);
1134 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1135 }
1136 } else if (type === 'object') {
1137 var addendum = '';
1138 {
1139 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
1140 }
1141 var childrenString = '' + children;
1142 (function () {
1143 {
1144 {
1145 throw ReactError(Error('Objects are not valid as a React child (found: ' + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ').' + addendum));
1146 }
1147 }
1148 })();
1149 }
1150 }
1151
1152 return subtreeCount;
1153}
1154
1155/**
1156 * Traverses children that are typically specified as `props.children`, but
1157 * might also be specified through attributes:
1158 *
1159 * - `traverseAllChildren(this.props.children, ...)`
1160 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
1161 *
1162 * The `traverseContext` is an optional argument that is passed through the
1163 * entire traversal. It can be used to store accumulations or anything else that
1164 * the callback might find relevant.
1165 *
1166 * @param {?*} children Children tree object.
1167 * @param {!function} callback To invoke upon traversing each child.
1168 * @param {?*} traverseContext Context for traversal.
1169 * @return {!number} The number of children in this subtree.
1170 */
1171function traverseAllChildren(children, callback, traverseContext) {
1172 if (children == null) {
1173 return 0;
1174 }
1175
1176 return traverseAllChildrenImpl(children, '', callback, traverseContext);
1177}
1178
1179/**
1180 * Generate a key string that identifies a component within a set.
1181 *
1182 * @param {*} component A component that could contain a manual key.
1183 * @param {number} index Index that is used if a manual key is not provided.
1184 * @return {string}
1185 */
1186function getComponentKey(component, index) {
1187 // Do some typechecking here since we call this blindly. We want to ensure
1188 // that we don't block potential future ES APIs.
1189 if (typeof component === 'object' && component !== null && component.key != null) {
1190 // Explicit key
1191 return escape(component.key);
1192 }
1193 // Implicit key determined by the index in the set
1194 return index.toString(36);
1195}
1196
1197function forEachSingleChild(bookKeeping, child, name) {
1198 var func = bookKeeping.func,
1199 context = bookKeeping.context;
1200
1201 func.call(context, child, bookKeeping.count++);
1202}
1203
1204/**
1205 * Iterates through children that are typically specified as `props.children`.
1206 *
1207 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
1208 *
1209 * The provided forEachFunc(child, index) will be called for each
1210 * leaf child.
1211 *
1212 * @param {?*} children Children tree container.
1213 * @param {function(*, int)} forEachFunc
1214 * @param {*} forEachContext Context for forEachContext.
1215 */
1216function forEachChildren(children, forEachFunc, forEachContext) {
1217 if (children == null) {
1218 return children;
1219 }
1220 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
1221 traverseAllChildren(children, forEachSingleChild, traverseContext);
1222 releaseTraverseContext(traverseContext);
1223}
1224
1225function mapSingleChildIntoContext(bookKeeping, child, childKey) {
1226 var result = bookKeeping.result,
1227 keyPrefix = bookKeeping.keyPrefix,
1228 func = bookKeeping.func,
1229 context = bookKeeping.context;
1230
1231
1232 var mappedChild = func.call(context, child, bookKeeping.count++);
1233 if (Array.isArray(mappedChild)) {
1234 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
1235 return c;
1236 });
1237 } else if (mappedChild != null) {
1238 if (isValidElement(mappedChild)) {
1239 mappedChild = cloneAndReplaceKey(mappedChild,
1240 // Keep both the (mapped) and old keys if they differ, just as
1241 // traverseAllChildren used to do for objects as children
1242 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
1243 }
1244 result.push(mappedChild);
1245 }
1246}
1247
1248function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1249 var escapedPrefix = '';
1250 if (prefix != null) {
1251 escapedPrefix = escapeUserProvidedKey(prefix) + '/';
1252 }
1253 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
1254 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
1255 releaseTraverseContext(traverseContext);
1256}
1257
1258/**
1259 * Maps children that are typically specified as `props.children`.
1260 *
1261 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
1262 *
1263 * The provided mapFunction(child, key, index) will be called for each
1264 * leaf child.
1265 *
1266 * @param {?*} children Children tree container.
1267 * @param {function(*, int)} func The map function.
1268 * @param {*} context Context for mapFunction.
1269 * @return {object} Object containing the ordered map of results.
1270 */
1271function mapChildren(children, func, context) {
1272 if (children == null) {
1273 return children;
1274 }
1275 var result = [];
1276 mapIntoWithKeyPrefixInternal(children, result, null, func, context);
1277 return result;
1278}
1279
1280/**
1281 * Count the number of children that are typically specified as
1282 * `props.children`.
1283 *
1284 * See https://reactjs.org/docs/react-api.html#reactchildrencount
1285 *
1286 * @param {?*} children Children tree container.
1287 * @return {number} The number of children.
1288 */
1289function countChildren(children) {
1290 return traverseAllChildren(children, function () {
1291 return null;
1292 }, null);
1293}
1294
1295/**
1296 * Flatten a children object (typically specified as `props.children`) and
1297 * return an array with appropriately re-keyed children.
1298 *
1299 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
1300 */
1301function toArray(children) {
1302 var result = [];
1303 mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
1304 return child;
1305 });
1306 return result;
1307}
1308
1309/**
1310 * Returns the first child in a collection of children and verifies that there
1311 * is only one child in the collection.
1312 *
1313 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
1314 *
1315 * The current implementation of this function assumes that a single child gets
1316 * passed without a wrapper, but the purpose of this helper function is to
1317 * abstract away the particular structure of children.
1318 *
1319 * @param {?object} children Child collection structure.
1320 * @return {ReactElement} The first and only `ReactElement` contained in the
1321 * structure.
1322 */
1323function onlyChild(children) {
1324 (function () {
1325 if (!isValidElement(children)) {
1326 {
1327 throw ReactError(Error('React.Children.only expected to receive a single React element child.'));
1328 }
1329 }
1330 })();
1331 return children;
1332}
1333
1334function createContext(defaultValue, calculateChangedBits) {
1335 if (calculateChangedBits === undefined) {
1336 calculateChangedBits = null;
1337 } else {
1338 {
1339 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
1340 }
1341 }
1342
1343 var context = {
1344 $$typeof: REACT_CONTEXT_TYPE,
1345 _calculateChangedBits: calculateChangedBits,
1346 // As a workaround to support multiple concurrent renderers, we categorize
1347 // some renderers as primary and others as secondary. We only expect
1348 // there to be two concurrent renderers at most: React Native (primary) and
1349 // Fabric (secondary); React DOM (primary) and React ART (secondary).
1350 // Secondary renderers store their context values on separate fields.
1351 _currentValue: defaultValue,
1352 _currentValue2: defaultValue,
1353 // Used to track how many concurrent renderers this context currently
1354 // supports within in a single renderer. Such as parallel server rendering.
1355 _threadCount: 0,
1356 // These are circular
1357 Provider: null,
1358 Consumer: null
1359 };
1360
1361 context.Provider = {
1362 $$typeof: REACT_PROVIDER_TYPE,
1363 _context: context
1364 };
1365
1366 var hasWarnedAboutUsingNestedContextConsumers = false;
1367 var hasWarnedAboutUsingConsumerProvider = false;
1368
1369 {
1370 // A separate object, but proxies back to the original context object for
1371 // backwards compatibility. It has a different $$typeof, so we can properly
1372 // warn for the incorrect usage of Context as a Consumer.
1373 var Consumer = {
1374 $$typeof: REACT_CONTEXT_TYPE,
1375 _context: context,
1376 _calculateChangedBits: context._calculateChangedBits
1377 };
1378 // $FlowFixMe: Flow complains about not setting a value, which is intentional here
1379 Object.defineProperties(Consumer, {
1380 Provider: {
1381 get: function () {
1382 if (!hasWarnedAboutUsingConsumerProvider) {
1383 hasWarnedAboutUsingConsumerProvider = true;
1384 warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
1385 }
1386 return context.Provider;
1387 },
1388 set: function (_Provider) {
1389 context.Provider = _Provider;
1390 }
1391 },
1392 _currentValue: {
1393 get: function () {
1394 return context._currentValue;
1395 },
1396 set: function (_currentValue) {
1397 context._currentValue = _currentValue;
1398 }
1399 },
1400 _currentValue2: {
1401 get: function () {
1402 return context._currentValue2;
1403 },
1404 set: function (_currentValue2) {
1405 context._currentValue2 = _currentValue2;
1406 }
1407 },
1408 _threadCount: {
1409 get: function () {
1410 return context._threadCount;
1411 },
1412 set: function (_threadCount) {
1413 context._threadCount = _threadCount;
1414 }
1415 },
1416 Consumer: {
1417 get: function () {
1418 if (!hasWarnedAboutUsingNestedContextConsumers) {
1419 hasWarnedAboutUsingNestedContextConsumers = true;
1420 warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
1421 }
1422 return context.Consumer;
1423 }
1424 }
1425 });
1426 // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
1427 context.Consumer = Consumer;
1428 }
1429
1430 {
1431 context._currentRenderer = null;
1432 context._currentRenderer2 = null;
1433 }
1434
1435 return context;
1436}
1437
1438function lazy(ctor) {
1439 var lazyType = {
1440 $$typeof: REACT_LAZY_TYPE,
1441 _ctor: ctor,
1442 // React uses these fields to store the result.
1443 _status: -1,
1444 _result: null
1445 };
1446
1447 {
1448 // In production, this would just set it on the object.
1449 var defaultProps = void 0;
1450 var propTypes = void 0;
1451 Object.defineProperties(lazyType, {
1452 defaultProps: {
1453 configurable: true,
1454 get: function () {
1455 return defaultProps;
1456 },
1457 set: function (newDefaultProps) {
1458 warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
1459 defaultProps = newDefaultProps;
1460 // Match production behavior more closely:
1461 Object.defineProperty(lazyType, 'defaultProps', {
1462 enumerable: true
1463 });
1464 }
1465 },
1466 propTypes: {
1467 configurable: true,
1468 get: function () {
1469 return propTypes;
1470 },
1471 set: function (newPropTypes) {
1472 warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
1473 propTypes = newPropTypes;
1474 // Match production behavior more closely:
1475 Object.defineProperty(lazyType, 'propTypes', {
1476 enumerable: true
1477 });
1478 }
1479 }
1480 });
1481 }
1482
1483 return lazyType;
1484}
1485
1486function forwardRef(render) {
1487 {
1488 if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
1489 warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
1490 } else if (typeof render !== 'function') {
1491 warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
1492 } else {
1493 !(
1494 // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
1495 render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0;
1496 }
1497
1498 if (render != null) {
1499 !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
1500 }
1501 }
1502
1503 return {
1504 $$typeof: REACT_FORWARD_REF_TYPE,
1505 render: render
1506 };
1507}
1508
1509function isValidElementType(type) {
1510 return typeof type === 'string' || typeof type === 'function' ||
1511 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1512 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE);
1513}
1514
1515function memo(type, compare) {
1516 {
1517 if (!isValidElementType(type)) {
1518 warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
1519 }
1520 }
1521 return {
1522 $$typeof: REACT_MEMO_TYPE,
1523 type: type,
1524 compare: compare === undefined ? null : compare
1525 };
1526}
1527
1528function resolveDispatcher() {
1529 var dispatcher = ReactCurrentDispatcher.current;
1530 (function () {
1531 if (!(dispatcher !== null)) {
1532 {
1533 throw ReactError(Error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.'));
1534 }
1535 }
1536 })();
1537 return dispatcher;
1538}
1539
1540function useContext(Context, unstable_observedBits) {
1541 var dispatcher = resolveDispatcher();
1542 {
1543 !(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0;
1544
1545 // TODO: add a more generic warning for invalid values.
1546 if (Context._context !== undefined) {
1547 var realContext = Context._context;
1548 // Don't deduplicate because this legitimately causes bugs
1549 // and nobody should be using this in existing code.
1550 if (realContext.Consumer === Context) {
1551 warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
1552 } else if (realContext.Provider === Context) {
1553 warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
1554 }
1555 }
1556 }
1557 return dispatcher.useContext(Context, unstable_observedBits);
1558}
1559
1560function useState(initialState) {
1561 var dispatcher = resolveDispatcher();
1562 return dispatcher.useState(initialState);
1563}
1564
1565function useReducer(reducer, initialArg, init) {
1566 var dispatcher = resolveDispatcher();
1567 return dispatcher.useReducer(reducer, initialArg, init);
1568}
1569
1570function useRef(initialValue) {
1571 var dispatcher = resolveDispatcher();
1572 return dispatcher.useRef(initialValue);
1573}
1574
1575function useEffect(create, inputs) {
1576 var dispatcher = resolveDispatcher();
1577 return dispatcher.useEffect(create, inputs);
1578}
1579
1580function useLayoutEffect(create, inputs) {
1581 var dispatcher = resolveDispatcher();
1582 return dispatcher.useLayoutEffect(create, inputs);
1583}
1584
1585function useCallback(callback, inputs) {
1586 var dispatcher = resolveDispatcher();
1587 return dispatcher.useCallback(callback, inputs);
1588}
1589
1590function useMemo(create, inputs) {
1591 var dispatcher = resolveDispatcher();
1592 return dispatcher.useMemo(create, inputs);
1593}
1594
1595function useImperativeHandle(ref, create, inputs) {
1596 var dispatcher = resolveDispatcher();
1597 return dispatcher.useImperativeHandle(ref, create, inputs);
1598}
1599
1600function useDebugValue(value, formatterFn) {
1601 {
1602 var dispatcher = resolveDispatcher();
1603 return dispatcher.useDebugValue(value, formatterFn);
1604 }
1605}
1606
1607var emptyObject$1 = {};
1608
1609function useResponder(responder, listenerProps) {
1610 var dispatcher = resolveDispatcher();
1611 {
1612 if (responder == null || responder.$$typeof !== REACT_RESPONDER_TYPE) {
1613 warning$1(false, 'useResponder: invalid first argument. Expected an event responder, but instead got %s', responder);
1614 return;
1615 }
1616 }
1617 return dispatcher.useResponder(responder, listenerProps || emptyObject$1);
1618}
1619
1620// Within the scope of the callback, mark all updates as being allowed to suspend.
1621function withSuspenseConfig(scope, config) {
1622 var previousConfig = ReactCurrentBatchConfig.suspense;
1623 ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
1624 try {
1625 scope();
1626 } finally {
1627 ReactCurrentBatchConfig.suspense = previousConfig;
1628 }
1629}
1630
1631/**
1632 * ReactElementValidator provides a wrapper around a element factory
1633 * which validates the props passed to the element. This is intended to be
1634 * used only in DEV and could be replaced by a static type checker for languages
1635 * that support it.
1636 */
1637
1638var propTypesMisspellWarningShown = void 0;
1639
1640{
1641 propTypesMisspellWarningShown = false;
1642}
1643
1644function getDeclarationErrorAddendum() {
1645 if (ReactCurrentOwner.current) {
1646 var name = getComponentName(ReactCurrentOwner.current.type);
1647 if (name) {
1648 return '\n\nCheck the render method of `' + name + '`.';
1649 }
1650 }
1651 return '';
1652}
1653
1654function getSourceInfoErrorAddendum(source) {
1655 if (source !== undefined) {
1656 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
1657 var lineNumber = source.lineNumber;
1658 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
1659 }
1660 return '';
1661}
1662
1663function getSourceInfoErrorAddendumForProps(elementProps) {
1664 if (elementProps !== null && elementProps !== undefined) {
1665 return getSourceInfoErrorAddendum(elementProps.__source);
1666 }
1667 return '';
1668}
1669
1670/**
1671 * Warn if there's no key explicitly set on dynamic arrays of children or
1672 * object keys are not valid. This allows us to keep track of children between
1673 * updates.
1674 */
1675var ownerHasKeyUseWarning = {};
1676
1677function getCurrentComponentErrorInfo(parentType) {
1678 var info = getDeclarationErrorAddendum();
1679
1680 if (!info) {
1681 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1682 if (parentName) {
1683 info = '\n\nCheck the top-level render call using <' + parentName + '>.';
1684 }
1685 }
1686 return info;
1687}
1688
1689/**
1690 * Warn if the element doesn't have an explicit key assigned to it.
1691 * This element is in an array. The array could grow and shrink or be
1692 * reordered. All children that haven't already been validated are required to
1693 * have a "key" property assigned to it. Error statuses are cached so a warning
1694 * will only be shown once.
1695 *
1696 * @internal
1697 * @param {ReactElement} element Element that requires a key.
1698 * @param {*} parentType element's parent's type.
1699 */
1700function validateExplicitKey(element, parentType) {
1701 if (!element._store || element._store.validated || element.key != null) {
1702 return;
1703 }
1704 element._store.validated = true;
1705
1706 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1707 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1708 return;
1709 }
1710 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
1711
1712 // Usually the current owner is the offender, but if it accepts children as a
1713 // property, it may be the creator of the child that's responsible for
1714 // assigning it a key.
1715 var childOwner = '';
1716 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
1717 // Give the component that originally created this child.
1718 childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
1719 }
1720
1721 setCurrentlyValidatingElement(element);
1722 {
1723 warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
1724 }
1725 setCurrentlyValidatingElement(null);
1726}
1727
1728/**
1729 * Ensure that every element either is passed in a static location, in an
1730 * array with an explicit keys property defined, or in an object literal
1731 * with valid key property.
1732 *
1733 * @internal
1734 * @param {ReactNode} node Statically passed child of any type.
1735 * @param {*} parentType node's parent's type.
1736 */
1737function validateChildKeys(node, parentType) {
1738 if (typeof node !== 'object') {
1739 return;
1740 }
1741 if (Array.isArray(node)) {
1742 for (var i = 0; i < node.length; i++) {
1743 var child = node[i];
1744 if (isValidElement(child)) {
1745 validateExplicitKey(child, parentType);
1746 }
1747 }
1748 } else if (isValidElement(node)) {
1749 // This element was passed in a valid location.
1750 if (node._store) {
1751 node._store.validated = true;
1752 }
1753 } else if (node) {
1754 var iteratorFn = getIteratorFn(node);
1755 if (typeof iteratorFn === 'function') {
1756 // Entry iterators used to provide implicit keys,
1757 // but now we print a separate warning for them later.
1758 if (iteratorFn !== node.entries) {
1759 var iterator = iteratorFn.call(node);
1760 var step = void 0;
1761 while (!(step = iterator.next()).done) {
1762 if (isValidElement(step.value)) {
1763 validateExplicitKey(step.value, parentType);
1764 }
1765 }
1766 }
1767 }
1768 }
1769}
1770
1771/**
1772 * Given an element, validate that its props follow the propTypes definition,
1773 * provided by the type.
1774 *
1775 * @param {ReactElement} element
1776 */
1777function validatePropTypes(element) {
1778 var type = element.type;
1779 if (type === null || type === undefined || typeof type === 'string') {
1780 return;
1781 }
1782 var name = getComponentName(type);
1783 var propTypes = void 0;
1784 if (typeof type === 'function') {
1785 propTypes = type.propTypes;
1786 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
1787 // Note: Memo only checks outer props here.
1788 // Inner props are checked in the reconciler.
1789 type.$$typeof === REACT_MEMO_TYPE)) {
1790 propTypes = type.propTypes;
1791 } else {
1792 return;
1793 }
1794 if (propTypes) {
1795 setCurrentlyValidatingElement(element);
1796 checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
1797 setCurrentlyValidatingElement(null);
1798 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1799 propTypesMisspellWarningShown = true;
1800 warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
1801 }
1802 if (typeof type.getDefaultProps === 'function') {
1803 !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
1804 }
1805}
1806
1807/**
1808 * Given a fragment, validate that it can only be provided with fragment props
1809 * @param {ReactElement} fragment
1810 */
1811function validateFragmentProps(fragment) {
1812 setCurrentlyValidatingElement(fragment);
1813
1814 var keys = Object.keys(fragment.props);
1815 for (var i = 0; i < keys.length; i++) {
1816 var key = keys[i];
1817 if (key !== 'children' && key !== 'key') {
1818 warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1819 break;
1820 }
1821 }
1822
1823 if (fragment.ref !== null) {
1824 warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
1825 }
1826
1827 setCurrentlyValidatingElement(null);
1828}
1829
1830function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1831 var validType = isValidElementType(type);
1832
1833 // We warn in this case but don't throw. We expect the element creation to
1834 // succeed and there will likely be errors in render.
1835 if (!validType) {
1836 var info = '';
1837 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1838 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
1839 }
1840
1841 var sourceInfo = getSourceInfoErrorAddendum(source);
1842 if (sourceInfo) {
1843 info += sourceInfo;
1844 } else {
1845 info += getDeclarationErrorAddendum();
1846 }
1847
1848 var typeString = void 0;
1849 if (type === null) {
1850 typeString = 'null';
1851 } else if (Array.isArray(type)) {
1852 typeString = 'array';
1853 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1854 typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
1855 info = ' Did you accidentally export a JSX literal instead of a component?';
1856 } else {
1857 typeString = typeof type;
1858 }
1859
1860 warning$1(false, 'React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
1861 }
1862
1863 var element = jsxDEV(type, props, key, source, self);
1864
1865 // The result can be nullish if a mock or a custom function is used.
1866 // TODO: Drop this when these are no longer allowed as the type argument.
1867 if (element == null) {
1868 return element;
1869 }
1870
1871 // Skip key warning if the type isn't valid since our key validation logic
1872 // doesn't expect a non-string/function type and can throw confusing errors.
1873 // We don't want exception behavior to differ between dev and prod.
1874 // (Rendering will throw with a helpful message and as soon as the type is
1875 // fixed, the key warnings will appear.)
1876 if (validType) {
1877 var children = props.children;
1878 if (children !== undefined) {
1879 if (isStaticChildren) {
1880 for (var i = 0; i < children.length; i++) {
1881 validateChildKeys(children[i], type);
1882 }
1883 } else {
1884 validateChildKeys(children, type);
1885 }
1886 }
1887 }
1888
1889 if (props.key !== undefined) {
1890 warning$1(false, 'React.jsx: Spreading a key to JSX is a deprecated pattern. ' + 'Explicitly pass a key after spreading props in your JSX call. ' + 'E.g. <ComponentName {...props} key={key} />');
1891 }
1892
1893 if (type === REACT_FRAGMENT_TYPE) {
1894 validateFragmentProps(element);
1895 } else {
1896 validatePropTypes(element);
1897 }
1898
1899 return element;
1900}
1901
1902// These two functions exist to still get child warnings in dev
1903// even with the prod transform. This means that jsxDEV is purely
1904// opt-in behavior for better messages but that we won't stop
1905// giving you warnings if you use production apis.
1906function jsxWithValidationStatic(type, props, key) {
1907 return jsxWithValidation(type, props, key, true);
1908}
1909
1910function jsxWithValidationDynamic(type, props, key) {
1911 return jsxWithValidation(type, props, key, false);
1912}
1913
1914function createElementWithValidation(type, props, children) {
1915 var validType = isValidElementType(type);
1916
1917 // We warn in this case but don't throw. We expect the element creation to
1918 // succeed and there will likely be errors in render.
1919 if (!validType) {
1920 var info = '';
1921 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1922 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
1923 }
1924
1925 var sourceInfo = getSourceInfoErrorAddendumForProps(props);
1926 if (sourceInfo) {
1927 info += sourceInfo;
1928 } else {
1929 info += getDeclarationErrorAddendum();
1930 }
1931
1932 var typeString = void 0;
1933 if (type === null) {
1934 typeString = 'null';
1935 } else if (Array.isArray(type)) {
1936 typeString = 'array';
1937 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1938 typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
1939 info = ' Did you accidentally export a JSX literal instead of a component?';
1940 } else {
1941 typeString = typeof type;
1942 }
1943
1944 warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
1945 }
1946
1947 var element = createElement.apply(this, arguments);
1948
1949 // The result can be nullish if a mock or a custom function is used.
1950 // TODO: Drop this when these are no longer allowed as the type argument.
1951 if (element == null) {
1952 return element;
1953 }
1954
1955 // Skip key warning if the type isn't valid since our key validation logic
1956 // doesn't expect a non-string/function type and can throw confusing errors.
1957 // We don't want exception behavior to differ between dev and prod.
1958 // (Rendering will throw with a helpful message and as soon as the type is
1959 // fixed, the key warnings will appear.)
1960 if (validType) {
1961 for (var i = 2; i < arguments.length; i++) {
1962 validateChildKeys(arguments[i], type);
1963 }
1964 }
1965
1966 if (type === REACT_FRAGMENT_TYPE) {
1967 validateFragmentProps(element);
1968 } else {
1969 validatePropTypes(element);
1970 }
1971
1972 return element;
1973}
1974
1975function createFactoryWithValidation(type) {
1976 var validatedFactory = createElementWithValidation.bind(null, type);
1977 validatedFactory.type = type;
1978 // Legacy hook: remove it
1979 {
1980 Object.defineProperty(validatedFactory, 'type', {
1981 enumerable: false,
1982 get: function () {
1983 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
1984 Object.defineProperty(this, 'type', {
1985 value: type
1986 });
1987 return type;
1988 }
1989 });
1990 }
1991
1992 return validatedFactory;
1993}
1994
1995function cloneElementWithValidation(element, props, children) {
1996 var newElement = cloneElement.apply(this, arguments);
1997 for (var i = 2; i < arguments.length; i++) {
1998 validateChildKeys(arguments[i], newElement.type);
1999 }
2000 validatePropTypes(newElement);
2001 return newElement;
2002}
2003
2004var hasBadMapPolyfill = void 0;
2005
2006{
2007 hasBadMapPolyfill = false;
2008 try {
2009 var frozenObject = Object.freeze({});
2010 var testMap = new Map([[frozenObject, null]]);
2011 var testSet = new Set([frozenObject]);
2012 // This is necessary for Rollup to not consider these unused.
2013 // https://github.com/rollup/rollup/issues/1771
2014 // TODO: we can remove these if Rollup fixes the bug.
2015 testMap.set(0, 0);
2016 testSet.add(0);
2017 } catch (e) {
2018 // TODO: Consider warning about bad polyfills
2019 hasBadMapPolyfill = true;
2020 }
2021}
2022
2023function createFundamentalComponent(impl) {
2024 // We use responder as a Map key later on. When we have a bad
2025 // polyfill, then we can't use it as a key as the polyfill tries
2026 // to add a property to the object.
2027 if (true && !hasBadMapPolyfill) {
2028 Object.freeze(impl);
2029 }
2030 var fundamantalComponent = {
2031 $$typeof: REACT_FUNDAMENTAL_TYPE,
2032 impl: impl
2033 };
2034 {
2035 Object.freeze(fundamantalComponent);
2036 }
2037 return fundamantalComponent;
2038}
2039
2040function createEventResponder(displayName, responderConfig) {
2041 var getInitialState = responderConfig.getInitialState,
2042 onEvent = responderConfig.onEvent,
2043 onMount = responderConfig.onMount,
2044 onUnmount = responderConfig.onUnmount,
2045 onOwnershipChange = responderConfig.onOwnershipChange,
2046 onRootEvent = responderConfig.onRootEvent,
2047 rootEventTypes = responderConfig.rootEventTypes,
2048 targetEventTypes = responderConfig.targetEventTypes;
2049
2050 var eventResponder = {
2051 $$typeof: REACT_RESPONDER_TYPE,
2052 displayName: displayName,
2053 getInitialState: getInitialState || null,
2054 onEvent: onEvent || null,
2055 onMount: onMount || null,
2056 onOwnershipChange: onOwnershipChange || null,
2057 onRootEvent: onRootEvent || null,
2058 onUnmount: onUnmount || null,
2059 rootEventTypes: rootEventTypes || null,
2060 targetEventTypes: targetEventTypes || null
2061 };
2062 // We use responder as a Map key later on. When we have a bad
2063 // polyfill, then we can't use it as a key as the polyfill tries
2064 // to add a property to the object.
2065 if (true && !hasBadMapPolyfill) {
2066 Object.freeze(eventResponder);
2067 }
2068 return eventResponder;
2069}
2070
2071// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
2072
2073
2074// In some cases, StrictMode should also double-render lifecycles.
2075// This can be confusing for tests though,
2076// And it can be bad for performance in production.
2077// This feature flag can be used to control the behavior:
2078
2079
2080// To preserve the "Pause on caught exceptions" behavior of the debugger, we
2081// replay the begin phase of a failed component inside invokeGuardedCallback.
2082
2083
2084// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
2085
2086
2087// Gather advanced timing metrics for Profiler subtrees.
2088
2089
2090// Trace which interactions trigger each commit.
2091
2092
2093// Only used in www builds.
2094 // TODO: true? Here it might just be false.
2095
2096// Only used in www builds.
2097
2098
2099// Only used in www builds.
2100
2101
2102// Disable javascript: URL strings in href for XSS protection.
2103
2104
2105// React Fire: prevent the value and checked attributes from syncing
2106// with their related DOM properties
2107
2108
2109// These APIs will no longer be "unstable" in the upcoming 16.7 release,
2110// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
2111
2112
2113
2114
2115// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
2116// This is a flag so we can fix warnings in RN core before turning it on
2117
2118
2119// Experimental React Flare event system and event components support.
2120var enableFlareAPI = false;
2121
2122// Experimental Host Component support.
2123var enableFundamentalAPI = false;
2124
2125// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
2126var enableJSXTransformAPI = false;
2127
2128// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
2129// Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
2130
2131// Temporary flag to revert the fix in #15650
2132
2133
2134// For tests, we flush suspense fallbacks in an act scope;
2135// *except* in some of our own tests, where we test incremental loading states.
2136
2137
2138// Changes priority of some events like mousemove to user-blocking priority,
2139// but without making them discrete. The flag exists in case it causes
2140// starvation problems.
2141
2142
2143// Add a callback property to suspense to notify which promises are currently
2144// in the update queue. This allows reporting and tracing of what is causing
2145// the user to see a loading state.
2146
2147
2148// Part of the simplification of React.createElement so we can eventually move
2149// from React.createElement to React.jsx
2150// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
2151
2152var React = {
2153 Children: {
2154 map: mapChildren,
2155 forEach: forEachChildren,
2156 count: countChildren,
2157 toArray: toArray,
2158 only: onlyChild
2159 },
2160
2161 createRef: createRef,
2162 Component: Component,
2163 PureComponent: PureComponent,
2164
2165 createContext: createContext,
2166 forwardRef: forwardRef,
2167 lazy: lazy,
2168 memo: memo,
2169
2170 useCallback: useCallback,
2171 useContext: useContext,
2172 useEffect: useEffect,
2173 useImperativeHandle: useImperativeHandle,
2174 useDebugValue: useDebugValue,
2175 useLayoutEffect: useLayoutEffect,
2176 useMemo: useMemo,
2177 useReducer: useReducer,
2178 useRef: useRef,
2179 useState: useState,
2180
2181 Fragment: REACT_FRAGMENT_TYPE,
2182 Profiler: REACT_PROFILER_TYPE,
2183 StrictMode: REACT_STRICT_MODE_TYPE,
2184 Suspense: REACT_SUSPENSE_TYPE,
2185 unstable_SuspenseList: REACT_SUSPENSE_LIST_TYPE,
2186
2187 createElement: createElementWithValidation,
2188 cloneElement: cloneElementWithValidation,
2189 createFactory: createFactoryWithValidation,
2190 isValidElement: isValidElement,
2191
2192 version: ReactVersion,
2193
2194 unstable_withSuspenseConfig: withSuspenseConfig,
2195
2196 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
2197};
2198
2199if (enableFlareAPI) {
2200 React.unstable_useResponder = useResponder;
2201 React.unstable_createResponder = createEventResponder;
2202}
2203
2204if (enableFundamentalAPI) {
2205 React.unstable_createFundamental = createFundamentalComponent;
2206}
2207
2208// Note: some APIs are added with feature flags.
2209// Make sure that stable builds for open source
2210// don't modify the React object to avoid deopts.
2211// Also let's not expose their names in stable builds.
2212
2213if (enableJSXTransformAPI) {
2214 {
2215 React.jsxDEV = jsxWithValidation;
2216 React.jsx = jsxWithValidationDynamic;
2217 React.jsxs = jsxWithValidationStatic;
2218 }
2219}
2220
2221
2222
2223var React$2 = Object.freeze({
2224 default: React
2225});
2226
2227var React$3 = ( React$2 && React ) || React$2;
2228
2229// TODO: decide on the top-level export form.
2230// This is hacky but makes it work with both Rollup and Jest.
2231var react = React$3.default || React$3;
2232
2233module.exports = react;
2234 })();
2235}