message_bus 3.3.8 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/assets/react.js DELETED
@@ -1,3029 +0,0 @@
1
- /** @license React v16.6.1
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
- (function (global, factory) {
13
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
14
- typeof define === 'function' && define.amd ? define(factory) :
15
- (global.React = factory());
16
- }(this, (function () { 'use strict';
17
-
18
- // TODO: this is special because it gets imported during build.
19
-
20
- var ReactVersion = '16.6.3';
21
-
22
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
23
- // nor polyfill, then a plain number is used for performance.
24
- var hasSymbol = typeof Symbol === 'function' && Symbol.for;
25
-
26
- var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
27
- var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
28
- var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
29
- var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
30
- var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
31
- var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
32
- var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
33
-
34
- var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
35
- var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
36
- var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
37
- var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
38
- var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
39
-
40
- var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
41
- var FAUX_ITERATOR_SYMBOL = '@@iterator';
42
-
43
- function getIteratorFn(maybeIterable) {
44
- if (maybeIterable === null || typeof maybeIterable !== 'object') {
45
- return null;
46
- }
47
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
48
- if (typeof maybeIterator === 'function') {
49
- return maybeIterator;
50
- }
51
- return null;
52
- }
53
-
54
- var enableHooks = false;
55
- // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
56
-
57
-
58
- // In some cases, StrictMode should also double-render lifecycles.
59
- // This can be confusing for tests though,
60
- // And it can be bad for performance in production.
61
- // This feature flag can be used to control the behavior:
62
-
63
-
64
- // To preserve the "Pause on caught exceptions" behavior of the debugger, we
65
- // replay the begin phase of a failed component inside invokeGuardedCallback.
66
-
67
-
68
- // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
69
-
70
-
71
- // Gather advanced timing metrics for Profiler subtrees.
72
-
73
-
74
- // Trace which interactions trigger each commit.
75
- var enableSchedulerTracing = true;
76
-
77
- // Only used in www builds.
78
-
79
-
80
- // Only used in www builds.
81
-
82
-
83
- // React Fire: prevent the value and checked attributes from syncing
84
- // with their related DOM properties
85
-
86
-
87
- // These APIs will no longer be "unstable" in the upcoming 16.7 release,
88
- // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
89
- var enableStableConcurrentModeAPIs = false;
90
-
91
- /*
92
- object-assign
93
- (c) Sindre Sorhus
94
- @license MIT
95
- */
96
-
97
-
98
- /* eslint-disable no-unused-vars */
99
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
100
- var hasOwnProperty = Object.prototype.hasOwnProperty;
101
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
102
-
103
- function toObject(val) {
104
- if (val === null || val === undefined) {
105
- throw new TypeError('Object.assign cannot be called with null or undefined');
106
- }
107
-
108
- return Object(val);
109
- }
110
-
111
- function shouldUseNative() {
112
- try {
113
- if (!Object.assign) {
114
- return false;
115
- }
116
-
117
- // Detect buggy property enumeration order in older V8 versions.
118
-
119
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
120
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
121
- test1[5] = 'de';
122
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
123
- return false;
124
- }
125
-
126
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
127
- var test2 = {};
128
- for (var i = 0; i < 10; i++) {
129
- test2['_' + String.fromCharCode(i)] = i;
130
- }
131
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
132
- return test2[n];
133
- });
134
- if (order2.join('') !== '0123456789') {
135
- return false;
136
- }
137
-
138
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
139
- var test3 = {};
140
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
141
- test3[letter] = letter;
142
- });
143
- if (Object.keys(Object.assign({}, test3)).join('') !==
144
- 'abcdefghijklmnopqrst') {
145
- return false;
146
- }
147
-
148
- return true;
149
- } catch (err) {
150
- // We don't expect any of the above to throw, but better to be safe.
151
- return false;
152
- }
153
- }
154
-
155
- var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
156
- var from;
157
- var to = toObject(target);
158
- var symbols;
159
-
160
- for (var s = 1; s < arguments.length; s++) {
161
- from = Object(arguments[s]);
162
-
163
- for (var key in from) {
164
- if (hasOwnProperty.call(from, key)) {
165
- to[key] = from[key];
166
- }
167
- }
168
-
169
- if (getOwnPropertySymbols) {
170
- symbols = getOwnPropertySymbols(from);
171
- for (var i = 0; i < symbols.length; i++) {
172
- if (propIsEnumerable.call(from, symbols[i])) {
173
- to[symbols[i]] = from[symbols[i]];
174
- }
175
- }
176
- }
177
- }
178
-
179
- return to;
180
- };
181
-
182
- /**
183
- * Use invariant() to assert state which your program assumes to be true.
184
- *
185
- * Provide sprintf-style format (only %s is supported) and arguments
186
- * to provide information about what broke and what you were
187
- * expecting.
188
- *
189
- * The invariant message will be stripped in production, but the invariant
190
- * will remain to ensure logic does not differ in production.
191
- */
192
-
193
- var validateFormat = function () {};
194
-
195
- {
196
- validateFormat = function (format) {
197
- if (format === undefined) {
198
- throw new Error('invariant requires an error message argument');
199
- }
200
- };
201
- }
202
-
203
- function invariant(condition, format, a, b, c, d, e, f) {
204
- validateFormat(format);
205
-
206
- if (!condition) {
207
- var error = void 0;
208
- if (format === undefined) {
209
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
210
- } else {
211
- var args = [a, b, c, d, e, f];
212
- var argIndex = 0;
213
- error = new Error(format.replace(/%s/g, function () {
214
- return args[argIndex++];
215
- }));
216
- error.name = 'Invariant Violation';
217
- }
218
-
219
- error.framesToPop = 1; // we don't care about invariant's own frame
220
- throw error;
221
- }
222
- }
223
-
224
- // Relying on the `invariant()` implementation lets us
225
- // preserve the format and params in the www builds.
226
-
227
- /**
228
- * Forked from fbjs/warning:
229
- * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
230
- *
231
- * Only change is we use console.warn instead of console.error,
232
- * and do nothing when 'console' is not supported.
233
- * This really simplifies the code.
234
- * ---
235
- * Similar to invariant but only logs a warning if the condition is not met.
236
- * This can be used to log issues in development environments in critical
237
- * paths. Removing the logging code for production environments will keep the
238
- * same logic and follow the same code paths.
239
- */
240
-
241
- var lowPriorityWarning = function () {};
242
-
243
- {
244
- var printWarning = function (format) {
245
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
246
- args[_key - 1] = arguments[_key];
247
- }
248
-
249
- var argIndex = 0;
250
- var message = 'Warning: ' + format.replace(/%s/g, function () {
251
- return args[argIndex++];
252
- });
253
- if (typeof console !== 'undefined') {
254
- console.warn(message);
255
- }
256
- try {
257
- // --- Welcome to debugging React ---
258
- // This error was thrown as a convenience so that you can use this stack
259
- // to find the callsite that caused this warning to fire.
260
- throw new Error(message);
261
- } catch (x) {}
262
- };
263
-
264
- lowPriorityWarning = function (condition, format) {
265
- if (format === undefined) {
266
- throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
267
- }
268
- if (!condition) {
269
- for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
270
- args[_key2 - 2] = arguments[_key2];
271
- }
272
-
273
- printWarning.apply(undefined, [format].concat(args));
274
- }
275
- };
276
- }
277
-
278
- var lowPriorityWarning$1 = lowPriorityWarning;
279
-
280
- /**
281
- * Similar to invariant but only logs a warning if the condition is not met.
282
- * This can be used to log issues in development environments in critical
283
- * paths. Removing the logging code for production environments will keep the
284
- * same logic and follow the same code paths.
285
- */
286
-
287
- var warningWithoutStack = function () {};
288
-
289
- {
290
- warningWithoutStack = function (condition, format) {
291
- for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
292
- args[_key - 2] = arguments[_key];
293
- }
294
-
295
- if (format === undefined) {
296
- throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
297
- }
298
- if (args.length > 8) {
299
- // Check before the condition to catch violations early.
300
- throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
301
- }
302
- if (condition) {
303
- return;
304
- }
305
- if (typeof console !== 'undefined') {
306
- var argsWithFormat = args.map(function (item) {
307
- return '' + item;
308
- });
309
- argsWithFormat.unshift('Warning: ' + format);
310
-
311
- // We intentionally don't use spread (or .apply) directly because it
312
- // breaks IE9: https://github.com/facebook/react/issues/13610
313
- Function.prototype.apply.call(console.error, console, argsWithFormat);
314
- }
315
- try {
316
- // --- Welcome to debugging React ---
317
- // This error was thrown as a convenience so that you can use this stack
318
- // to find the callsite that caused this warning to fire.
319
- var argIndex = 0;
320
- var message = 'Warning: ' + format.replace(/%s/g, function () {
321
- return args[argIndex++];
322
- });
323
- throw new Error(message);
324
- } catch (x) {}
325
- };
326
- }
327
-
328
- var warningWithoutStack$1 = warningWithoutStack;
329
-
330
- var didWarnStateUpdateForUnmountedComponent = {};
331
-
332
- function warnNoop(publicInstance, callerName) {
333
- {
334
- var _constructor = publicInstance.constructor;
335
- var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
336
- var warningKey = componentName + '.' + callerName;
337
- if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
338
- return;
339
- }
340
- 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);
341
- didWarnStateUpdateForUnmountedComponent[warningKey] = true;
342
- }
343
- }
344
-
345
- /**
346
- * This is the abstract API for an update queue.
347
- */
348
- var ReactNoopUpdateQueue = {
349
- /**
350
- * Checks whether or not this composite component is mounted.
351
- * @param {ReactClass} publicInstance The instance we want to test.
352
- * @return {boolean} True if mounted, false otherwise.
353
- * @protected
354
- * @final
355
- */
356
- isMounted: function (publicInstance) {
357
- return false;
358
- },
359
-
360
- /**
361
- * Forces an update. This should only be invoked when it is known with
362
- * certainty that we are **not** in a DOM transaction.
363
- *
364
- * You may want to call this when you know that some deeper aspect of the
365
- * component's state has changed but `setState` was not called.
366
- *
367
- * This will not invoke `shouldComponentUpdate`, but it will invoke
368
- * `componentWillUpdate` and `componentDidUpdate`.
369
- *
370
- * @param {ReactClass} publicInstance The instance that should rerender.
371
- * @param {?function} callback Called after component is updated.
372
- * @param {?string} callerName name of the calling function in the public API.
373
- * @internal
374
- */
375
- enqueueForceUpdate: function (publicInstance, callback, callerName) {
376
- warnNoop(publicInstance, 'forceUpdate');
377
- },
378
-
379
- /**
380
- * Replaces all of the state. Always use this or `setState` to mutate state.
381
- * You should treat `this.state` as immutable.
382
- *
383
- * There is no guarantee that `this.state` will be immediately updated, so
384
- * accessing `this.state` after calling this method may return the old value.
385
- *
386
- * @param {ReactClass} publicInstance The instance that should rerender.
387
- * @param {object} completeState Next state.
388
- * @param {?function} callback Called after component is updated.
389
- * @param {?string} callerName name of the calling function in the public API.
390
- * @internal
391
- */
392
- enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
393
- warnNoop(publicInstance, 'replaceState');
394
- },
395
-
396
- /**
397
- * Sets a subset of the state. This only exists because _pendingState is
398
- * internal. This provides a merging strategy that is not available to deep
399
- * properties which is confusing. TODO: Expose pendingState or don't use it
400
- * during the merge.
401
- *
402
- * @param {ReactClass} publicInstance The instance that should rerender.
403
- * @param {object} partialState Next partial state to be merged with state.
404
- * @param {?function} callback Called after component is updated.
405
- * @param {?string} Name of the calling function in the public API.
406
- * @internal
407
- */
408
- enqueueSetState: function (publicInstance, partialState, callback, callerName) {
409
- warnNoop(publicInstance, 'setState');
410
- }
411
- };
412
-
413
- var emptyObject = {};
414
- {
415
- Object.freeze(emptyObject);
416
- }
417
-
418
- /**
419
- * Base class helpers for the updating state of a component.
420
- */
421
- function Component(props, context, updater) {
422
- this.props = props;
423
- this.context = context;
424
- // If a component has string refs, we will assign a different object later.
425
- this.refs = emptyObject;
426
- // We initialize the default updater but the real one gets injected by the
427
- // renderer.
428
- this.updater = updater || ReactNoopUpdateQueue;
429
- }
430
-
431
- Component.prototype.isReactComponent = {};
432
-
433
- /**
434
- * Sets a subset of the state. Always use this to mutate
435
- * state. You should treat `this.state` as immutable.
436
- *
437
- * There is no guarantee that `this.state` will be immediately updated, so
438
- * accessing `this.state` after calling this method may return the old value.
439
- *
440
- * There is no guarantee that calls to `setState` will run synchronously,
441
- * as they may eventually be batched together. You can provide an optional
442
- * callback that will be executed when the call to setState is actually
443
- * completed.
444
- *
445
- * When a function is provided to setState, it will be called at some point in
446
- * the future (not synchronously). It will be called with the up to date
447
- * component arguments (state, props, context). These values can be different
448
- * from this.* because your function may be called after receiveProps but before
449
- * shouldComponentUpdate, and this new state, props, and context will not yet be
450
- * assigned to this.
451
- *
452
- * @param {object|function} partialState Next partial state or function to
453
- * produce next partial state to be merged with current state.
454
- * @param {?function} callback Called after state is updated.
455
- * @final
456
- * @protected
457
- */
458
- Component.prototype.setState = function (partialState, callback) {
459
- !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
460
- this.updater.enqueueSetState(this, partialState, callback, 'setState');
461
- };
462
-
463
- /**
464
- * Forces an update. This should only be invoked when it is known with
465
- * certainty that we are **not** in a DOM transaction.
466
- *
467
- * You may want to call this when you know that some deeper aspect of the
468
- * component's state has changed but `setState` was not called.
469
- *
470
- * This will not invoke `shouldComponentUpdate`, but it will invoke
471
- * `componentWillUpdate` and `componentDidUpdate`.
472
- *
473
- * @param {?function} callback Called after update is complete.
474
- * @final
475
- * @protected
476
- */
477
- Component.prototype.forceUpdate = function (callback) {
478
- this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
479
- };
480
-
481
- /**
482
- * Deprecated APIs. These APIs used to exist on classic React classes but since
483
- * we would like to deprecate them, we're not going to move them over to this
484
- * modern base class. Instead, we define a getter that warns if it's accessed.
485
- */
486
- {
487
- var deprecatedAPIs = {
488
- isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
489
- replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
490
- };
491
- var defineDeprecationWarning = function (methodName, info) {
492
- Object.defineProperty(Component.prototype, methodName, {
493
- get: function () {
494
- lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
495
- return undefined;
496
- }
497
- });
498
- };
499
- for (var fnName in deprecatedAPIs) {
500
- if (deprecatedAPIs.hasOwnProperty(fnName)) {
501
- defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
502
- }
503
- }
504
- }
505
-
506
- function ComponentDummy() {}
507
- ComponentDummy.prototype = Component.prototype;
508
-
509
- /**
510
- * Convenience component with default shallow equality check for sCU.
511
- */
512
- function PureComponent(props, context, updater) {
513
- this.props = props;
514
- this.context = context;
515
- // If a component has string refs, we will assign a different object later.
516
- this.refs = emptyObject;
517
- this.updater = updater || ReactNoopUpdateQueue;
518
- }
519
-
520
- var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
521
- pureComponentPrototype.constructor = PureComponent;
522
- // Avoid an extra prototype jump for these methods.
523
- objectAssign(pureComponentPrototype, Component.prototype);
524
- pureComponentPrototype.isPureReactComponent = true;
525
-
526
- // an immutable object with a single mutable value
527
- function createRef() {
528
- var refObject = {
529
- current: null
530
- };
531
- {
532
- Object.seal(refObject);
533
- }
534
- return refObject;
535
- }
536
-
537
- /* eslint-disable no-var */
538
-
539
- // TODO: Use symbols?
540
- var ImmediatePriority = 1;
541
- var UserBlockingPriority = 2;
542
- var NormalPriority = 3;
543
- var LowPriority = 4;
544
- var IdlePriority = 5;
545
-
546
- // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
547
- // Math.pow(2, 30) - 1
548
- // 0b111111111111111111111111111111
549
- var maxSigned31BitInt = 1073741823;
550
-
551
- // Times out immediately
552
- var IMMEDIATE_PRIORITY_TIMEOUT = -1;
553
- // Eventually times out
554
- var USER_BLOCKING_PRIORITY = 250;
555
- var NORMAL_PRIORITY_TIMEOUT = 5000;
556
- var LOW_PRIORITY_TIMEOUT = 10000;
557
- // Never times out
558
- var IDLE_PRIORITY = maxSigned31BitInt;
559
-
560
- // Callbacks are stored as a circular, doubly linked list.
561
- var firstCallbackNode = null;
562
-
563
- var currentDidTimeout = false;
564
- var currentPriorityLevel = NormalPriority;
565
- var currentEventStartTime = -1;
566
- var currentExpirationTime = -1;
567
-
568
- // This is set when a callback is being executed, to prevent re-entrancy.
569
- var isExecutingCallback = false;
570
-
571
- var isHostCallbackScheduled = false;
572
-
573
- var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
574
-
575
- function ensureHostCallbackIsScheduled() {
576
- if (isExecutingCallback) {
577
- // Don't schedule work yet; wait until the next time we yield.
578
- return;
579
- }
580
- // Schedule the host callback using the earliest expiration in the list.
581
- var expirationTime = firstCallbackNode.expirationTime;
582
- if (!isHostCallbackScheduled) {
583
- isHostCallbackScheduled = true;
584
- } else {
585
- // Cancel the existing host callback.
586
- cancelHostCallback();
587
- }
588
- requestHostCallback(flushWork, expirationTime);
589
- }
590
-
591
- function flushFirstCallback() {
592
- var flushedNode = firstCallbackNode;
593
-
594
- // Remove the node from the list before calling the callback. That way the
595
- // list is in a consistent state even if the callback throws.
596
- var next = firstCallbackNode.next;
597
- if (firstCallbackNode === next) {
598
- // This is the last callback in the list.
599
- firstCallbackNode = null;
600
- next = null;
601
- } else {
602
- var lastCallbackNode = firstCallbackNode.previous;
603
- firstCallbackNode = lastCallbackNode.next = next;
604
- next.previous = lastCallbackNode;
605
- }
606
-
607
- flushedNode.next = flushedNode.previous = null;
608
-
609
- // Now it's safe to call the callback.
610
- var callback = flushedNode.callback;
611
- var expirationTime = flushedNode.expirationTime;
612
- var priorityLevel = flushedNode.priorityLevel;
613
- var previousPriorityLevel = currentPriorityLevel;
614
- var previousExpirationTime = currentExpirationTime;
615
- currentPriorityLevel = priorityLevel;
616
- currentExpirationTime = expirationTime;
617
- var continuationCallback;
618
- try {
619
- continuationCallback = callback();
620
- } finally {
621
- currentPriorityLevel = previousPriorityLevel;
622
- currentExpirationTime = previousExpirationTime;
623
- }
624
-
625
- // A callback may return a continuation. The continuation should be scheduled
626
- // with the same priority and expiration as the just-finished callback.
627
- if (typeof continuationCallback === 'function') {
628
- var continuationNode = {
629
- callback: continuationCallback,
630
- priorityLevel: priorityLevel,
631
- expirationTime: expirationTime,
632
- next: null,
633
- previous: null
634
- };
635
-
636
- // Insert the new callback into the list, sorted by its expiration. This is
637
- // almost the same as the code in `scheduleCallback`, except the callback
638
- // is inserted into the list *before* callbacks of equal expiration instead
639
- // of after.
640
- if (firstCallbackNode === null) {
641
- // This is the first callback in the list.
642
- firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode;
643
- } else {
644
- var nextAfterContinuation = null;
645
- var node = firstCallbackNode;
646
- do {
647
- if (node.expirationTime >= expirationTime) {
648
- // This callback expires at or after the continuation. We will insert
649
- // the continuation *before* this callback.
650
- nextAfterContinuation = node;
651
- break;
652
- }
653
- node = node.next;
654
- } while (node !== firstCallbackNode);
655
-
656
- if (nextAfterContinuation === null) {
657
- // No equal or lower priority callback was found, which means the new
658
- // callback is the lowest priority callback in the list.
659
- nextAfterContinuation = firstCallbackNode;
660
- } else if (nextAfterContinuation === firstCallbackNode) {
661
- // The new callback is the highest priority callback in the list.
662
- firstCallbackNode = continuationNode;
663
- ensureHostCallbackIsScheduled();
664
- }
665
-
666
- var previous = nextAfterContinuation.previous;
667
- previous.next = nextAfterContinuation.previous = continuationNode;
668
- continuationNode.next = nextAfterContinuation;
669
- continuationNode.previous = previous;
670
- }
671
- }
672
- }
673
-
674
- function flushImmediateWork() {
675
- if (
676
- // Confirm we've exited the outer most event handler
677
- currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) {
678
- isExecutingCallback = true;
679
- try {
680
- do {
681
- flushFirstCallback();
682
- } while (
683
- // Keep flushing until there are no more immediate callbacks
684
- firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority);
685
- } finally {
686
- isExecutingCallback = false;
687
- if (firstCallbackNode !== null) {
688
- // There's still work remaining. Request another callback.
689
- ensureHostCallbackIsScheduled();
690
- } else {
691
- isHostCallbackScheduled = false;
692
- }
693
- }
694
- }
695
- }
696
-
697
- function flushWork(didTimeout) {
698
- isExecutingCallback = true;
699
- var previousDidTimeout = currentDidTimeout;
700
- currentDidTimeout = didTimeout;
701
- try {
702
- if (didTimeout) {
703
- // Flush all the expired callbacks without yielding.
704
- while (firstCallbackNode !== null) {
705
- // Read the current time. Flush all the callbacks that expire at or
706
- // earlier than that time. Then read the current time again and repeat.
707
- // This optimizes for as few performance.now calls as possible.
708
- var currentTime = getCurrentTime();
709
- if (firstCallbackNode.expirationTime <= currentTime) {
710
- do {
711
- flushFirstCallback();
712
- } while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime);
713
- continue;
714
- }
715
- break;
716
- }
717
- } else {
718
- // Keep flushing callbacks until we run out of time in the frame.
719
- if (firstCallbackNode !== null) {
720
- do {
721
- flushFirstCallback();
722
- } while (firstCallbackNode !== null && !shouldYieldToHost());
723
- }
724
- }
725
- } finally {
726
- isExecutingCallback = false;
727
- currentDidTimeout = previousDidTimeout;
728
- if (firstCallbackNode !== null) {
729
- // There's still work remaining. Request another callback.
730
- ensureHostCallbackIsScheduled();
731
- } else {
732
- isHostCallbackScheduled = false;
733
- }
734
- // Before exiting, flush all the immediate work that was scheduled.
735
- flushImmediateWork();
736
- }
737
- }
738
-
739
- function unstable_runWithPriority(priorityLevel, eventHandler) {
740
- switch (priorityLevel) {
741
- case ImmediatePriority:
742
- case UserBlockingPriority:
743
- case NormalPriority:
744
- case LowPriority:
745
- case IdlePriority:
746
- break;
747
- default:
748
- priorityLevel = NormalPriority;
749
- }
750
-
751
- var previousPriorityLevel = currentPriorityLevel;
752
- var previousEventStartTime = currentEventStartTime;
753
- currentPriorityLevel = priorityLevel;
754
- currentEventStartTime = getCurrentTime();
755
-
756
- try {
757
- return eventHandler();
758
- } finally {
759
- currentPriorityLevel = previousPriorityLevel;
760
- currentEventStartTime = previousEventStartTime;
761
-
762
- // Before exiting, flush all the immediate work that was scheduled.
763
- flushImmediateWork();
764
- }
765
- }
766
-
767
- function unstable_wrapCallback(callback) {
768
- var parentPriorityLevel = currentPriorityLevel;
769
- return function () {
770
- // This is a fork of runWithPriority, inlined for performance.
771
- var previousPriorityLevel = currentPriorityLevel;
772
- var previousEventStartTime = currentEventStartTime;
773
- currentPriorityLevel = parentPriorityLevel;
774
- currentEventStartTime = getCurrentTime();
775
-
776
- try {
777
- return callback.apply(this, arguments);
778
- } finally {
779
- currentPriorityLevel = previousPriorityLevel;
780
- currentEventStartTime = previousEventStartTime;
781
- flushImmediateWork();
782
- }
783
- };
784
- }
785
-
786
- function unstable_scheduleCallback(callback, deprecated_options) {
787
- var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
788
-
789
- var expirationTime;
790
- if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
791
- // FIXME: Remove this branch once we lift expiration times out of React.
792
- expirationTime = startTime + deprecated_options.timeout;
793
- } else {
794
- switch (currentPriorityLevel) {
795
- case ImmediatePriority:
796
- expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
797
- break;
798
- case UserBlockingPriority:
799
- expirationTime = startTime + USER_BLOCKING_PRIORITY;
800
- break;
801
- case IdlePriority:
802
- expirationTime = startTime + IDLE_PRIORITY;
803
- break;
804
- case LowPriority:
805
- expirationTime = startTime + LOW_PRIORITY_TIMEOUT;
806
- break;
807
- case NormalPriority:
808
- default:
809
- expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
810
- }
811
- }
812
-
813
- var newNode = {
814
- callback: callback,
815
- priorityLevel: currentPriorityLevel,
816
- expirationTime: expirationTime,
817
- next: null,
818
- previous: null
819
- };
820
-
821
- // Insert the new callback into the list, ordered first by expiration, then
822
- // by insertion. So the new callback is inserted any other callback with
823
- // equal expiration.
824
- if (firstCallbackNode === null) {
825
- // This is the first callback in the list.
826
- firstCallbackNode = newNode.next = newNode.previous = newNode;
827
- ensureHostCallbackIsScheduled();
828
- } else {
829
- var next = null;
830
- var node = firstCallbackNode;
831
- do {
832
- if (node.expirationTime > expirationTime) {
833
- // The new callback expires before this one.
834
- next = node;
835
- break;
836
- }
837
- node = node.next;
838
- } while (node !== firstCallbackNode);
839
-
840
- if (next === null) {
841
- // No callback with a later expiration was found, which means the new
842
- // callback has the latest expiration in the list.
843
- next = firstCallbackNode;
844
- } else if (next === firstCallbackNode) {
845
- // The new callback has the earliest expiration in the entire list.
846
- firstCallbackNode = newNode;
847
- ensureHostCallbackIsScheduled();
848
- }
849
-
850
- var previous = next.previous;
851
- previous.next = next.previous = newNode;
852
- newNode.next = next;
853
- newNode.previous = previous;
854
- }
855
-
856
- return newNode;
857
- }
858
-
859
- function unstable_cancelCallback(callbackNode) {
860
- var next = callbackNode.next;
861
- if (next === null) {
862
- // Already cancelled.
863
- return;
864
- }
865
-
866
- if (next === callbackNode) {
867
- // This is the only scheduled callback. Clear the list.
868
- firstCallbackNode = null;
869
- } else {
870
- // Remove the callback from its position in the list.
871
- if (callbackNode === firstCallbackNode) {
872
- firstCallbackNode = next;
873
- }
874
- var previous = callbackNode.previous;
875
- previous.next = next;
876
- next.previous = previous;
877
- }
878
-
879
- callbackNode.next = callbackNode.previous = null;
880
- }
881
-
882
- function unstable_getCurrentPriorityLevel() {
883
- return currentPriorityLevel;
884
- }
885
-
886
- function unstable_shouldYield() {
887
- return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
888
- }
889
-
890
- // The remaining code is essentially a polyfill for requestIdleCallback. It
891
- // works by scheduling a requestAnimationFrame, storing the time for the start
892
- // of the frame, then scheduling a postMessage which gets scheduled after paint.
893
- // Within the postMessage handler do as much work as possible until time + frame
894
- // rate. By separating the idle call into a separate event tick we ensure that
895
- // layout, paint and other browser work is counted against the available time.
896
- // The frame rate is dynamically adjusted.
897
-
898
- // We capture a local reference to any global, in case it gets polyfilled after
899
- // this module is initially evaluated. We want to be using a
900
- // consistent implementation.
901
- var localDate = Date;
902
-
903
- // This initialization code may run even on server environments if a component
904
- // just imports ReactDOM (e.g. for findDOMNode). Some environments might not
905
- // have setTimeout or clearTimeout. However, we always expect them to be defined
906
- // on the client. https://github.com/facebook/react/pull/13088
907
- var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
908
- var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
909
-
910
- // We don't expect either of these to necessarily be defined, but we will error
911
- // later if they are missing on the client.
912
- var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
913
- var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
914
-
915
- var getCurrentTime;
916
-
917
- // requestAnimationFrame does not run when the tab is in the background. If
918
- // we're backgrounded we prefer for that work to happen so that the page
919
- // continues to load in the background. So we also schedule a 'setTimeout' as
920
- // a fallback.
921
- // TODO: Need a better heuristic for backgrounded work.
922
- var ANIMATION_FRAME_TIMEOUT = 100;
923
- var rAFID;
924
- var rAFTimeoutID;
925
- var requestAnimationFrameWithTimeout = function (callback) {
926
- // schedule rAF and also a setTimeout
927
- rAFID = localRequestAnimationFrame(function (timestamp) {
928
- // cancel the setTimeout
929
- localClearTimeout(rAFTimeoutID);
930
- callback(timestamp);
931
- });
932
- rAFTimeoutID = localSetTimeout(function () {
933
- // cancel the requestAnimationFrame
934
- localCancelAnimationFrame(rAFID);
935
- callback(getCurrentTime());
936
- }, ANIMATION_FRAME_TIMEOUT);
937
- };
938
-
939
- if (hasNativePerformanceNow) {
940
- var Performance = performance;
941
- getCurrentTime = function () {
942
- return Performance.now();
943
- };
944
- } else {
945
- getCurrentTime = function () {
946
- return localDate.now();
947
- };
948
- }
949
-
950
- var requestHostCallback;
951
- var cancelHostCallback;
952
- var shouldYieldToHost;
953
-
954
- if (typeof window !== 'undefined' && window._schedMock) {
955
- // Dynamic injection, only for testing purposes.
956
- var impl = window._schedMock;
957
- requestHostCallback = impl[0];
958
- cancelHostCallback = impl[1];
959
- shouldYieldToHost = impl[2];
960
- } else if (
961
- // If Scheduler runs in a non-DOM environment, it falls back to a naive
962
- // implementation using setTimeout.
963
- typeof window === 'undefined' ||
964
- // "addEventListener" might not be available on the window object
965
- // if this is a mocked "window" object. So we need to validate that too.
966
- typeof window.addEventListener !== 'function') {
967
- var _callback = null;
968
- var _currentTime = -1;
969
- var _flushCallback = function (didTimeout, ms) {
970
- if (_callback !== null) {
971
- var cb = _callback;
972
- _callback = null;
973
- try {
974
- _currentTime = ms;
975
- cb(didTimeout);
976
- } finally {
977
- _currentTime = -1;
978
- }
979
- }
980
- };
981
- requestHostCallback = function (cb, ms) {
982
- if (_currentTime !== -1) {
983
- // Protect against re-entrancy.
984
- setTimeout(requestHostCallback, 0, cb, ms);
985
- } else {
986
- _callback = cb;
987
- setTimeout(_flushCallback, ms, true, ms);
988
- setTimeout(_flushCallback, maxSigned31BitInt, false, maxSigned31BitInt);
989
- }
990
- };
991
- cancelHostCallback = function () {
992
- _callback = null;
993
- };
994
- shouldYieldToHost = function () {
995
- return false;
996
- };
997
- getCurrentTime = function () {
998
- return _currentTime === -1 ? 0 : _currentTime;
999
- };
1000
- } else {
1001
- if (typeof console !== 'undefined') {
1002
- // TODO: Remove fb.me link
1003
- if (typeof localRequestAnimationFrame !== 'function') {
1004
- console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1005
- }
1006
- if (typeof localCancelAnimationFrame !== 'function') {
1007
- console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1008
- }
1009
- }
1010
-
1011
- var scheduledHostCallback = null;
1012
- var isMessageEventScheduled = false;
1013
- var timeoutTime = -1;
1014
-
1015
- var isAnimationFrameScheduled = false;
1016
-
1017
- var isFlushingHostCallback = false;
1018
-
1019
- var frameDeadline = 0;
1020
- // We start out assuming that we run at 30fps but then the heuristic tracking
1021
- // will adjust this value to a faster fps if we get more frequent animation
1022
- // frames.
1023
- var previousFrameTime = 33;
1024
- var activeFrameTime = 33;
1025
-
1026
- shouldYieldToHost = function () {
1027
- return frameDeadline <= getCurrentTime();
1028
- };
1029
-
1030
- // We use the postMessage trick to defer idle work until after the repaint.
1031
- var messageKey = '__reactIdleCallback$' + Math.random().toString(36).slice(2);
1032
- var idleTick = function (event) {
1033
- if (event.source !== window || event.data !== messageKey) {
1034
- return;
1035
- }
1036
-
1037
- isMessageEventScheduled = false;
1038
-
1039
- var prevScheduledCallback = scheduledHostCallback;
1040
- var prevTimeoutTime = timeoutTime;
1041
- scheduledHostCallback = null;
1042
- timeoutTime = -1;
1043
-
1044
- var currentTime = getCurrentTime();
1045
-
1046
- var didTimeout = false;
1047
- if (frameDeadline - currentTime <= 0) {
1048
- // There's no time left in this idle period. Check if the callback has
1049
- // a timeout and whether it's been exceeded.
1050
- if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
1051
- // Exceeded the timeout. Invoke the callback even though there's no
1052
- // time left.
1053
- didTimeout = true;
1054
- } else {
1055
- // No timeout.
1056
- if (!isAnimationFrameScheduled) {
1057
- // Schedule another animation callback so we retry later.
1058
- isAnimationFrameScheduled = true;
1059
- requestAnimationFrameWithTimeout(animationTick);
1060
- }
1061
- // Exit without invoking the callback.
1062
- scheduledHostCallback = prevScheduledCallback;
1063
- timeoutTime = prevTimeoutTime;
1064
- return;
1065
- }
1066
- }
1067
-
1068
- if (prevScheduledCallback !== null) {
1069
- isFlushingHostCallback = true;
1070
- try {
1071
- prevScheduledCallback(didTimeout);
1072
- } finally {
1073
- isFlushingHostCallback = false;
1074
- }
1075
- }
1076
- };
1077
- // Assumes that we have addEventListener in this environment. Might need
1078
- // something better for old IE.
1079
- window.addEventListener('message', idleTick, false);
1080
-
1081
- var animationTick = function (rafTime) {
1082
- if (scheduledHostCallback !== null) {
1083
- // Eagerly schedule the next animation callback at the beginning of the
1084
- // frame. If the scheduler queue is not empty at the end of the frame, it
1085
- // will continue flushing inside that callback. If the queue *is* empty,
1086
- // then it will exit immediately. Posting the callback at the start of the
1087
- // frame ensures it's fired within the earliest possible frame. If we
1088
- // waited until the end of the frame to post the callback, we risk the
1089
- // browser skipping a frame and not firing the callback until the frame
1090
- // after that.
1091
- requestAnimationFrameWithTimeout(animationTick);
1092
- } else {
1093
- // No pending work. Exit.
1094
- isAnimationFrameScheduled = false;
1095
- return;
1096
- }
1097
-
1098
- var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
1099
- if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
1100
- if (nextFrameTime < 8) {
1101
- // Defensive coding. We don't support higher frame rates than 120hz.
1102
- // If the calculated frame time gets lower than 8, it is probably a bug.
1103
- nextFrameTime = 8;
1104
- }
1105
- // If one frame goes long, then the next one can be short to catch up.
1106
- // If two frames are short in a row, then that's an indication that we
1107
- // actually have a higher frame rate than what we're currently optimizing.
1108
- // We adjust our heuristic dynamically accordingly. For example, if we're
1109
- // running on 120hz display or 90hz VR display.
1110
- // Take the max of the two in case one of them was an anomaly due to
1111
- // missed frame deadlines.
1112
- activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
1113
- } else {
1114
- previousFrameTime = nextFrameTime;
1115
- }
1116
- frameDeadline = rafTime + activeFrameTime;
1117
- if (!isMessageEventScheduled) {
1118
- isMessageEventScheduled = true;
1119
- window.postMessage(messageKey, '*');
1120
- }
1121
- };
1122
-
1123
- requestHostCallback = function (callback, absoluteTimeout) {
1124
- scheduledHostCallback = callback;
1125
- timeoutTime = absoluteTimeout;
1126
- if (isFlushingHostCallback || absoluteTimeout < 0) {
1127
- // Don't wait for the next frame. Continue working ASAP, in a new event.
1128
- window.postMessage(messageKey, '*');
1129
- } else if (!isAnimationFrameScheduled) {
1130
- // If rAF didn't already schedule one, we need to schedule a frame.
1131
- // TODO: If this rAF doesn't materialize because the browser throttles, we
1132
- // might want to still have setTimeout trigger rIC as a backup to ensure
1133
- // that we keep performing work.
1134
- isAnimationFrameScheduled = true;
1135
- requestAnimationFrameWithTimeout(animationTick);
1136
- }
1137
- };
1138
-
1139
- cancelHostCallback = function () {
1140
- scheduledHostCallback = null;
1141
- isMessageEventScheduled = false;
1142
- timeoutTime = -1;
1143
- };
1144
- }
1145
-
1146
- var DEFAULT_THREAD_ID = 0;
1147
-
1148
- // Counters used to generate unique IDs.
1149
- var interactionIDCounter = 0;
1150
- var threadIDCounter = 0;
1151
-
1152
- // Set of currently traced interactions.
1153
- // Interactions "stack"–
1154
- // Meaning that newly traced interactions are appended to the previously active set.
1155
- // When an interaction goes out of scope, the previous set (if any) is restored.
1156
- var interactionsRef = null;
1157
-
1158
- // Listener(s) to notify when interactions begin and end.
1159
- var subscriberRef = null;
1160
-
1161
- if (enableSchedulerTracing) {
1162
- interactionsRef = {
1163
- current: new Set()
1164
- };
1165
- subscriberRef = {
1166
- current: null
1167
- };
1168
- }
1169
-
1170
- function unstable_clear(callback) {
1171
- if (!enableSchedulerTracing) {
1172
- return callback();
1173
- }
1174
-
1175
- var prevInteractions = interactionsRef.current;
1176
- interactionsRef.current = new Set();
1177
-
1178
- try {
1179
- return callback();
1180
- } finally {
1181
- interactionsRef.current = prevInteractions;
1182
- }
1183
- }
1184
-
1185
- function unstable_getCurrent() {
1186
- if (!enableSchedulerTracing) {
1187
- return null;
1188
- } else {
1189
- return interactionsRef.current;
1190
- }
1191
- }
1192
-
1193
- function unstable_getThreadID() {
1194
- return ++threadIDCounter;
1195
- }
1196
-
1197
- function unstable_trace(name, timestamp, callback) {
1198
- var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
1199
-
1200
- if (!enableSchedulerTracing) {
1201
- return callback();
1202
- }
1203
-
1204
- var interaction = {
1205
- __count: 1,
1206
- id: interactionIDCounter++,
1207
- name: name,
1208
- timestamp: timestamp
1209
- };
1210
-
1211
- var prevInteractions = interactionsRef.current;
1212
-
1213
- // Traced interactions should stack/accumulate.
1214
- // To do that, clone the current interactions.
1215
- // The previous set will be restored upon completion.
1216
- var interactions = new Set(prevInteractions);
1217
- interactions.add(interaction);
1218
- interactionsRef.current = interactions;
1219
-
1220
- var subscriber = subscriberRef.current;
1221
- var returnValue = void 0;
1222
-
1223
- try {
1224
- if (subscriber !== null) {
1225
- subscriber.onInteractionTraced(interaction);
1226
- }
1227
- } finally {
1228
- try {
1229
- if (subscriber !== null) {
1230
- subscriber.onWorkStarted(interactions, threadID);
1231
- }
1232
- } finally {
1233
- try {
1234
- returnValue = callback();
1235
- } finally {
1236
- interactionsRef.current = prevInteractions;
1237
-
1238
- try {
1239
- if (subscriber !== null) {
1240
- subscriber.onWorkStopped(interactions, threadID);
1241
- }
1242
- } finally {
1243
- interaction.__count--;
1244
-
1245
- // If no async work was scheduled for this interaction,
1246
- // Notify subscribers that it's completed.
1247
- if (subscriber !== null && interaction.__count === 0) {
1248
- subscriber.onInteractionScheduledWorkCompleted(interaction);
1249
- }
1250
- }
1251
- }
1252
- }
1253
- }
1254
-
1255
- return returnValue;
1256
- }
1257
-
1258
- function unstable_wrap(callback) {
1259
- var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
1260
-
1261
- if (!enableSchedulerTracing) {
1262
- return callback;
1263
- }
1264
-
1265
- var wrappedInteractions = interactionsRef.current;
1266
-
1267
- var subscriber = subscriberRef.current;
1268
- if (subscriber !== null) {
1269
- subscriber.onWorkScheduled(wrappedInteractions, threadID);
1270
- }
1271
-
1272
- // Update the pending async work count for the current interactions.
1273
- // Update after calling subscribers in case of error.
1274
- wrappedInteractions.forEach(function (interaction) {
1275
- interaction.__count++;
1276
- });
1277
-
1278
- var hasRun = false;
1279
-
1280
- function wrapped() {
1281
- var prevInteractions = interactionsRef.current;
1282
- interactionsRef.current = wrappedInteractions;
1283
-
1284
- subscriber = subscriberRef.current;
1285
-
1286
- try {
1287
- var returnValue = void 0;
1288
-
1289
- try {
1290
- if (subscriber !== null) {
1291
- subscriber.onWorkStarted(wrappedInteractions, threadID);
1292
- }
1293
- } finally {
1294
- try {
1295
- returnValue = callback.apply(undefined, arguments);
1296
- } finally {
1297
- interactionsRef.current = prevInteractions;
1298
-
1299
- if (subscriber !== null) {
1300
- subscriber.onWorkStopped(wrappedInteractions, threadID);
1301
- }
1302
- }
1303
- }
1304
-
1305
- return returnValue;
1306
- } finally {
1307
- if (!hasRun) {
1308
- // We only expect a wrapped function to be executed once,
1309
- // But in the event that it's executed more than once–
1310
- // Only decrement the outstanding interaction counts once.
1311
- hasRun = true;
1312
-
1313
- // Update pending async counts for all wrapped interactions.
1314
- // If this was the last scheduled async work for any of them,
1315
- // Mark them as completed.
1316
- wrappedInteractions.forEach(function (interaction) {
1317
- interaction.__count--;
1318
-
1319
- if (subscriber !== null && interaction.__count === 0) {
1320
- subscriber.onInteractionScheduledWorkCompleted(interaction);
1321
- }
1322
- });
1323
- }
1324
- }
1325
- }
1326
-
1327
- wrapped.cancel = function cancel() {
1328
- subscriber = subscriberRef.current;
1329
-
1330
- try {
1331
- if (subscriber !== null) {
1332
- subscriber.onWorkCanceled(wrappedInteractions, threadID);
1333
- }
1334
- } finally {
1335
- // Update pending async counts for all wrapped interactions.
1336
- // If this was the last scheduled async work for any of them,
1337
- // Mark them as completed.
1338
- wrappedInteractions.forEach(function (interaction) {
1339
- interaction.__count--;
1340
-
1341
- if (subscriber && interaction.__count === 0) {
1342
- subscriber.onInteractionScheduledWorkCompleted(interaction);
1343
- }
1344
- });
1345
- }
1346
- };
1347
-
1348
- return wrapped;
1349
- }
1350
-
1351
- var subscribers = null;
1352
- if (enableSchedulerTracing) {
1353
- subscribers = new Set();
1354
- }
1355
-
1356
- function unstable_subscribe(subscriber) {
1357
- if (enableSchedulerTracing) {
1358
- subscribers.add(subscriber);
1359
-
1360
- if (subscribers.size === 1) {
1361
- subscriberRef.current = {
1362
- onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
1363
- onInteractionTraced: onInteractionTraced,
1364
- onWorkCanceled: onWorkCanceled,
1365
- onWorkScheduled: onWorkScheduled,
1366
- onWorkStarted: onWorkStarted,
1367
- onWorkStopped: onWorkStopped
1368
- };
1369
- }
1370
- }
1371
- }
1372
-
1373
- function unstable_unsubscribe(subscriber) {
1374
- if (enableSchedulerTracing) {
1375
- subscribers.delete(subscriber);
1376
-
1377
- if (subscribers.size === 0) {
1378
- subscriberRef.current = null;
1379
- }
1380
- }
1381
- }
1382
-
1383
- function onInteractionTraced(interaction) {
1384
- var didCatchError = false;
1385
- var caughtError = null;
1386
-
1387
- subscribers.forEach(function (subscriber) {
1388
- try {
1389
- subscriber.onInteractionTraced(interaction);
1390
- } catch (error) {
1391
- if (!didCatchError) {
1392
- didCatchError = true;
1393
- caughtError = error;
1394
- }
1395
- }
1396
- });
1397
-
1398
- if (didCatchError) {
1399
- throw caughtError;
1400
- }
1401
- }
1402
-
1403
- function onInteractionScheduledWorkCompleted(interaction) {
1404
- var didCatchError = false;
1405
- var caughtError = null;
1406
-
1407
- subscribers.forEach(function (subscriber) {
1408
- try {
1409
- subscriber.onInteractionScheduledWorkCompleted(interaction);
1410
- } catch (error) {
1411
- if (!didCatchError) {
1412
- didCatchError = true;
1413
- caughtError = error;
1414
- }
1415
- }
1416
- });
1417
-
1418
- if (didCatchError) {
1419
- throw caughtError;
1420
- }
1421
- }
1422
-
1423
- function onWorkScheduled(interactions, threadID) {
1424
- var didCatchError = false;
1425
- var caughtError = null;
1426
-
1427
- subscribers.forEach(function (subscriber) {
1428
- try {
1429
- subscriber.onWorkScheduled(interactions, threadID);
1430
- } catch (error) {
1431
- if (!didCatchError) {
1432
- didCatchError = true;
1433
- caughtError = error;
1434
- }
1435
- }
1436
- });
1437
-
1438
- if (didCatchError) {
1439
- throw caughtError;
1440
- }
1441
- }
1442
-
1443
- function onWorkStarted(interactions, threadID) {
1444
- var didCatchError = false;
1445
- var caughtError = null;
1446
-
1447
- subscribers.forEach(function (subscriber) {
1448
- try {
1449
- subscriber.onWorkStarted(interactions, threadID);
1450
- } catch (error) {
1451
- if (!didCatchError) {
1452
- didCatchError = true;
1453
- caughtError = error;
1454
- }
1455
- }
1456
- });
1457
-
1458
- if (didCatchError) {
1459
- throw caughtError;
1460
- }
1461
- }
1462
-
1463
- function onWorkStopped(interactions, threadID) {
1464
- var didCatchError = false;
1465
- var caughtError = null;
1466
-
1467
- subscribers.forEach(function (subscriber) {
1468
- try {
1469
- subscriber.onWorkStopped(interactions, threadID);
1470
- } catch (error) {
1471
- if (!didCatchError) {
1472
- didCatchError = true;
1473
- caughtError = error;
1474
- }
1475
- }
1476
- });
1477
-
1478
- if (didCatchError) {
1479
- throw caughtError;
1480
- }
1481
- }
1482
-
1483
- function onWorkCanceled(interactions, threadID) {
1484
- var didCatchError = false;
1485
- var caughtError = null;
1486
-
1487
- subscribers.forEach(function (subscriber) {
1488
- try {
1489
- subscriber.onWorkCanceled(interactions, threadID);
1490
- } catch (error) {
1491
- if (!didCatchError) {
1492
- didCatchError = true;
1493
- caughtError = error;
1494
- }
1495
- }
1496
- });
1497
-
1498
- if (didCatchError) {
1499
- throw caughtError;
1500
- }
1501
- }
1502
-
1503
- /**
1504
- * Keeps track of the current owner.
1505
- *
1506
- * The current owner is the component who should own any components that are
1507
- * currently being constructed.
1508
- */
1509
- var ReactCurrentOwner = {
1510
- /**
1511
- * @internal
1512
- * @type {ReactComponent}
1513
- */
1514
- current: null,
1515
- currentDispatcher: null
1516
- };
1517
-
1518
- var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
1519
-
1520
- var describeComponentFrame = function (name, source, ownerName) {
1521
- var sourceInfo = '';
1522
- if (source) {
1523
- var path = source.fileName;
1524
- var fileName = path.replace(BEFORE_SLASH_RE, '');
1525
- {
1526
- // In DEV, include code for a common special case:
1527
- // prefer "folder/index.js" instead of just "index.js".
1528
- if (/^index\./.test(fileName)) {
1529
- var match = path.match(BEFORE_SLASH_RE);
1530
- if (match) {
1531
- var pathBeforeSlash = match[1];
1532
- if (pathBeforeSlash) {
1533
- var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
1534
- fileName = folderName + '/' + fileName;
1535
- }
1536
- }
1537
- }
1538
- }
1539
- sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
1540
- } else if (ownerName) {
1541
- sourceInfo = ' (created by ' + ownerName + ')';
1542
- }
1543
- return '\n in ' + (name || 'Unknown') + sourceInfo;
1544
- };
1545
-
1546
- var Resolved = 1;
1547
-
1548
-
1549
- function refineResolvedLazyComponent(lazyComponent) {
1550
- return lazyComponent._status === Resolved ? lazyComponent._result : null;
1551
- }
1552
-
1553
- function getWrappedName(outerType, innerType, wrapperName) {
1554
- var functionName = innerType.displayName || innerType.name || '';
1555
- return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
1556
- }
1557
-
1558
- function getComponentName(type) {
1559
- if (type == null) {
1560
- // Host root, text node or just invalid type.
1561
- return null;
1562
- }
1563
- {
1564
- if (typeof type.tag === 'number') {
1565
- warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
1566
- }
1567
- }
1568
- if (typeof type === 'function') {
1569
- return type.displayName || type.name || null;
1570
- }
1571
- if (typeof type === 'string') {
1572
- return type;
1573
- }
1574
- switch (type) {
1575
- case REACT_CONCURRENT_MODE_TYPE:
1576
- return 'ConcurrentMode';
1577
- case REACT_FRAGMENT_TYPE:
1578
- return 'Fragment';
1579
- case REACT_PORTAL_TYPE:
1580
- return 'Portal';
1581
- case REACT_PROFILER_TYPE:
1582
- return 'Profiler';
1583
- case REACT_STRICT_MODE_TYPE:
1584
- return 'StrictMode';
1585
- case REACT_SUSPENSE_TYPE:
1586
- return 'Suspense';
1587
- }
1588
- if (typeof type === 'object') {
1589
- switch (type.$$typeof) {
1590
- case REACT_CONTEXT_TYPE:
1591
- return 'Context.Consumer';
1592
- case REACT_PROVIDER_TYPE:
1593
- return 'Context.Provider';
1594
- case REACT_FORWARD_REF_TYPE:
1595
- return getWrappedName(type, type.render, 'ForwardRef');
1596
- case REACT_MEMO_TYPE:
1597
- return getComponentName(type.type);
1598
- case REACT_LAZY_TYPE:
1599
- {
1600
- var thenable = type;
1601
- var resolvedThenable = refineResolvedLazyComponent(thenable);
1602
- if (resolvedThenable) {
1603
- return getComponentName(resolvedThenable);
1604
- }
1605
- }
1606
- }
1607
- }
1608
- return null;
1609
- }
1610
-
1611
- var ReactDebugCurrentFrame = {};
1612
-
1613
- var currentlyValidatingElement = null;
1614
-
1615
- function setCurrentlyValidatingElement(element) {
1616
- {
1617
- currentlyValidatingElement = element;
1618
- }
1619
- }
1620
-
1621
- {
1622
- // Stack implementation injected by the current renderer.
1623
- ReactDebugCurrentFrame.getCurrentStack = null;
1624
-
1625
- ReactDebugCurrentFrame.getStackAddendum = function () {
1626
- var stack = '';
1627
-
1628
- // Add an extra top frame while an element is being validated
1629
- if (currentlyValidatingElement) {
1630
- var name = getComponentName(currentlyValidatingElement.type);
1631
- var owner = currentlyValidatingElement._owner;
1632
- stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
1633
- }
1634
-
1635
- // Delegate to the injected renderer-specific implementation
1636
- var impl = ReactDebugCurrentFrame.getCurrentStack;
1637
- if (impl) {
1638
- stack += impl() || '';
1639
- }
1640
-
1641
- return stack;
1642
- };
1643
- }
1644
-
1645
- var ReactSharedInternals = {
1646
- ReactCurrentOwner: ReactCurrentOwner,
1647
- // Used by renderers to avoid bundling object-assign twice in UMD bundles:
1648
- assign: objectAssign
1649
- };
1650
-
1651
- {
1652
- // Re-export the schedule API(s) for UMD bundles.
1653
- // This avoids introducing a dependency on a new UMD global in a minor update,
1654
- // Since that would be a breaking change (e.g. for all existing CodeSandboxes).
1655
- // This re-export is only required for UMD bundles;
1656
- // CJS bundles use the shared NPM package.
1657
- objectAssign(ReactSharedInternals, {
1658
- Scheduler: {
1659
- unstable_cancelCallback: unstable_cancelCallback,
1660
- unstable_shouldYield: unstable_shouldYield,
1661
- unstable_now: getCurrentTime,
1662
- unstable_scheduleCallback: unstable_scheduleCallback,
1663
- unstable_runWithPriority: unstable_runWithPriority,
1664
- unstable_wrapCallback: unstable_wrapCallback,
1665
- unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel
1666
- },
1667
- SchedulerTracing: {
1668
- __interactionsRef: interactionsRef,
1669
- __subscriberRef: subscriberRef,
1670
- unstable_clear: unstable_clear,
1671
- unstable_getCurrent: unstable_getCurrent,
1672
- unstable_getThreadID: unstable_getThreadID,
1673
- unstable_subscribe: unstable_subscribe,
1674
- unstable_trace: unstable_trace,
1675
- unstable_unsubscribe: unstable_unsubscribe,
1676
- unstable_wrap: unstable_wrap
1677
- }
1678
- });
1679
- }
1680
-
1681
- {
1682
- objectAssign(ReactSharedInternals, {
1683
- // These should not be included in production.
1684
- ReactDebugCurrentFrame: ReactDebugCurrentFrame,
1685
- // Shim for React DOM 16.0.0 which still destructured (but not used) this.
1686
- // TODO: remove in React 17.0.
1687
- ReactComponentTreeHook: {}
1688
- });
1689
- }
1690
-
1691
- /**
1692
- * Similar to invariant but only logs a warning if the condition is not met.
1693
- * This can be used to log issues in development environments in critical
1694
- * paths. Removing the logging code for production environments will keep the
1695
- * same logic and follow the same code paths.
1696
- */
1697
-
1698
- var warning = warningWithoutStack$1;
1699
-
1700
- {
1701
- warning = function (condition, format) {
1702
- if (condition) {
1703
- return;
1704
- }
1705
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1706
- var stack = ReactDebugCurrentFrame.getStackAddendum();
1707
- // eslint-disable-next-line react-internal/warning-and-invariant-args
1708
-
1709
- for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1710
- args[_key - 2] = arguments[_key];
1711
- }
1712
-
1713
- warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
1714
- };
1715
- }
1716
-
1717
- var warning$1 = warning;
1718
-
1719
- var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1720
-
1721
- var RESERVED_PROPS = {
1722
- key: true,
1723
- ref: true,
1724
- __self: true,
1725
- __source: true
1726
- };
1727
-
1728
- var specialPropKeyWarningShown = void 0;
1729
- var specialPropRefWarningShown = void 0;
1730
-
1731
- function hasValidRef(config) {
1732
- {
1733
- if (hasOwnProperty$1.call(config, 'ref')) {
1734
- var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
1735
- if (getter && getter.isReactWarning) {
1736
- return false;
1737
- }
1738
- }
1739
- }
1740
- return config.ref !== undefined;
1741
- }
1742
-
1743
- function hasValidKey(config) {
1744
- {
1745
- if (hasOwnProperty$1.call(config, 'key')) {
1746
- var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
1747
- if (getter && getter.isReactWarning) {
1748
- return false;
1749
- }
1750
- }
1751
- }
1752
- return config.key !== undefined;
1753
- }
1754
-
1755
- function defineKeyPropWarningGetter(props, displayName) {
1756
- var warnAboutAccessingKey = function () {
1757
- if (!specialPropKeyWarningShown) {
1758
- specialPropKeyWarningShown = true;
1759
- 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);
1760
- }
1761
- };
1762
- warnAboutAccessingKey.isReactWarning = true;
1763
- Object.defineProperty(props, 'key', {
1764
- get: warnAboutAccessingKey,
1765
- configurable: true
1766
- });
1767
- }
1768
-
1769
- function defineRefPropWarningGetter(props, displayName) {
1770
- var warnAboutAccessingRef = function () {
1771
- if (!specialPropRefWarningShown) {
1772
- specialPropRefWarningShown = true;
1773
- 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);
1774
- }
1775
- };
1776
- warnAboutAccessingRef.isReactWarning = true;
1777
- Object.defineProperty(props, 'ref', {
1778
- get: warnAboutAccessingRef,
1779
- configurable: true
1780
- });
1781
- }
1782
-
1783
- /**
1784
- * Factory method to create a new React element. This no longer adheres to
1785
- * the class pattern, so do not use new to call it. Also, no instanceof check
1786
- * will work. Instead test $$typeof field against Symbol.for('react.element') to check
1787
- * if something is a React Element.
1788
- *
1789
- * @param {*} type
1790
- * @param {*} key
1791
- * @param {string|object} ref
1792
- * @param {*} self A *temporary* helper to detect places where `this` is
1793
- * different from the `owner` when React.createElement is called, so that we
1794
- * can warn. We want to get rid of owner and replace string `ref`s with arrow
1795
- * functions, and as long as `this` and owner are the same, there will be no
1796
- * change in behavior.
1797
- * @param {*} source An annotation object (added by a transpiler or otherwise)
1798
- * indicating filename, line number, and/or other information.
1799
- * @param {*} owner
1800
- * @param {*} props
1801
- * @internal
1802
- */
1803
- var ReactElement = function (type, key, ref, self, source, owner, props) {
1804
- var element = {
1805
- // This tag allows us to uniquely identify this as a React Element
1806
- $$typeof: REACT_ELEMENT_TYPE,
1807
-
1808
- // Built-in properties that belong on the element
1809
- type: type,
1810
- key: key,
1811
- ref: ref,
1812
- props: props,
1813
-
1814
- // Record the component responsible for creating this element.
1815
- _owner: owner
1816
- };
1817
-
1818
- {
1819
- // The validation flag is currently mutative. We put it on
1820
- // an external backing store so that we can freeze the whole object.
1821
- // This can be replaced with a WeakMap once they are implemented in
1822
- // commonly used development environments.
1823
- element._store = {};
1824
-
1825
- // To make comparing ReactElements easier for testing purposes, we make
1826
- // the validation flag non-enumerable (where possible, which should
1827
- // include every environment we run tests in), so the test framework
1828
- // ignores it.
1829
- Object.defineProperty(element._store, 'validated', {
1830
- configurable: false,
1831
- enumerable: false,
1832
- writable: true,
1833
- value: false
1834
- });
1835
- // self and source are DEV only properties.
1836
- Object.defineProperty(element, '_self', {
1837
- configurable: false,
1838
- enumerable: false,
1839
- writable: false,
1840
- value: self
1841
- });
1842
- // Two elements created in two different places should be considered
1843
- // equal for testing purposes and therefore we hide it from enumeration.
1844
- Object.defineProperty(element, '_source', {
1845
- configurable: false,
1846
- enumerable: false,
1847
- writable: false,
1848
- value: source
1849
- });
1850
- if (Object.freeze) {
1851
- Object.freeze(element.props);
1852
- Object.freeze(element);
1853
- }
1854
- }
1855
-
1856
- return element;
1857
- };
1858
-
1859
- /**
1860
- * Create and return a new ReactElement of the given type.
1861
- * See https://reactjs.org/docs/react-api.html#createelement
1862
- */
1863
- function createElement(type, config, children) {
1864
- var propName = void 0;
1865
-
1866
- // Reserved names are extracted
1867
- var props = {};
1868
-
1869
- var key = null;
1870
- var ref = null;
1871
- var self = null;
1872
- var source = null;
1873
-
1874
- if (config != null) {
1875
- if (hasValidRef(config)) {
1876
- ref = config.ref;
1877
- }
1878
- if (hasValidKey(config)) {
1879
- key = '' + config.key;
1880
- }
1881
-
1882
- self = config.__self === undefined ? null : config.__self;
1883
- source = config.__source === undefined ? null : config.__source;
1884
- // Remaining properties are added to a new props object
1885
- for (propName in config) {
1886
- if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1887
- props[propName] = config[propName];
1888
- }
1889
- }
1890
- }
1891
-
1892
- // Children can be more than one argument, and those are transferred onto
1893
- // the newly allocated props object.
1894
- var childrenLength = arguments.length - 2;
1895
- if (childrenLength === 1) {
1896
- props.children = children;
1897
- } else if (childrenLength > 1) {
1898
- var childArray = Array(childrenLength);
1899
- for (var i = 0; i < childrenLength; i++) {
1900
- childArray[i] = arguments[i + 2];
1901
- }
1902
- {
1903
- if (Object.freeze) {
1904
- Object.freeze(childArray);
1905
- }
1906
- }
1907
- props.children = childArray;
1908
- }
1909
-
1910
- // Resolve default props
1911
- if (type && type.defaultProps) {
1912
- var defaultProps = type.defaultProps;
1913
- for (propName in defaultProps) {
1914
- if (props[propName] === undefined) {
1915
- props[propName] = defaultProps[propName];
1916
- }
1917
- }
1918
- }
1919
- {
1920
- if (key || ref) {
1921
- var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
1922
- if (key) {
1923
- defineKeyPropWarningGetter(props, displayName);
1924
- }
1925
- if (ref) {
1926
- defineRefPropWarningGetter(props, displayName);
1927
- }
1928
- }
1929
- }
1930
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1931
- }
1932
-
1933
- /**
1934
- * Return a function that produces ReactElements of a given type.
1935
- * See https://reactjs.org/docs/react-api.html#createfactory
1936
- */
1937
-
1938
-
1939
- function cloneAndReplaceKey(oldElement, newKey) {
1940
- var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
1941
-
1942
- return newElement;
1943
- }
1944
-
1945
- /**
1946
- * Clone and return a new ReactElement using element as the starting point.
1947
- * See https://reactjs.org/docs/react-api.html#cloneelement
1948
- */
1949
- function cloneElement(element, config, children) {
1950
- !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
1951
-
1952
- var propName = void 0;
1953
-
1954
- // Original props are copied
1955
- var props = objectAssign({}, element.props);
1956
-
1957
- // Reserved names are extracted
1958
- var key = element.key;
1959
- var ref = element.ref;
1960
- // Self is preserved since the owner is preserved.
1961
- var self = element._self;
1962
- // Source is preserved since cloneElement is unlikely to be targeted by a
1963
- // transpiler, and the original source is probably a better indicator of the
1964
- // true owner.
1965
- var source = element._source;
1966
-
1967
- // Owner will be preserved, unless ref is overridden
1968
- var owner = element._owner;
1969
-
1970
- if (config != null) {
1971
- if (hasValidRef(config)) {
1972
- // Silently steal the ref from the parent.
1973
- ref = config.ref;
1974
- owner = ReactCurrentOwner.current;
1975
- }
1976
- if (hasValidKey(config)) {
1977
- key = '' + config.key;
1978
- }
1979
-
1980
- // Remaining properties override existing props
1981
- var defaultProps = void 0;
1982
- if (element.type && element.type.defaultProps) {
1983
- defaultProps = element.type.defaultProps;
1984
- }
1985
- for (propName in config) {
1986
- if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1987
- if (config[propName] === undefined && defaultProps !== undefined) {
1988
- // Resolve default props
1989
- props[propName] = defaultProps[propName];
1990
- } else {
1991
- props[propName] = config[propName];
1992
- }
1993
- }
1994
- }
1995
- }
1996
-
1997
- // Children can be more than one argument, and those are transferred onto
1998
- // the newly allocated props object.
1999
- var childrenLength = arguments.length - 2;
2000
- if (childrenLength === 1) {
2001
- props.children = children;
2002
- } else if (childrenLength > 1) {
2003
- var childArray = Array(childrenLength);
2004
- for (var i = 0; i < childrenLength; i++) {
2005
- childArray[i] = arguments[i + 2];
2006
- }
2007
- props.children = childArray;
2008
- }
2009
-
2010
- return ReactElement(element.type, key, ref, self, source, owner, props);
2011
- }
2012
-
2013
- /**
2014
- * Verifies the object is a ReactElement.
2015
- * See https://reactjs.org/docs/react-api.html#isvalidelement
2016
- * @param {?object} object
2017
- * @return {boolean} True if `object` is a ReactElement.
2018
- * @final
2019
- */
2020
- function isValidElement(object) {
2021
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2022
- }
2023
-
2024
- var SEPARATOR = '.';
2025
- var SUBSEPARATOR = ':';
2026
-
2027
- /**
2028
- * Escape and wrap key so it is safe to use as a reactid
2029
- *
2030
- * @param {string} key to be escaped.
2031
- * @return {string} the escaped key.
2032
- */
2033
- function escape(key) {
2034
- var escapeRegex = /[=:]/g;
2035
- var escaperLookup = {
2036
- '=': '=0',
2037
- ':': '=2'
2038
- };
2039
- var escapedString = ('' + key).replace(escapeRegex, function (match) {
2040
- return escaperLookup[match];
2041
- });
2042
-
2043
- return '$' + escapedString;
2044
- }
2045
-
2046
- /**
2047
- * TODO: Test that a single child and an array with one item have the same key
2048
- * pattern.
2049
- */
2050
-
2051
- var didWarnAboutMaps = false;
2052
-
2053
- var userProvidedKeyEscapeRegex = /\/+/g;
2054
- function escapeUserProvidedKey(text) {
2055
- return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
2056
- }
2057
-
2058
- var POOL_SIZE = 10;
2059
- var traverseContextPool = [];
2060
- function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
2061
- if (traverseContextPool.length) {
2062
- var traverseContext = traverseContextPool.pop();
2063
- traverseContext.result = mapResult;
2064
- traverseContext.keyPrefix = keyPrefix;
2065
- traverseContext.func = mapFunction;
2066
- traverseContext.context = mapContext;
2067
- traverseContext.count = 0;
2068
- return traverseContext;
2069
- } else {
2070
- return {
2071
- result: mapResult,
2072
- keyPrefix: keyPrefix,
2073
- func: mapFunction,
2074
- context: mapContext,
2075
- count: 0
2076
- };
2077
- }
2078
- }
2079
-
2080
- function releaseTraverseContext(traverseContext) {
2081
- traverseContext.result = null;
2082
- traverseContext.keyPrefix = null;
2083
- traverseContext.func = null;
2084
- traverseContext.context = null;
2085
- traverseContext.count = 0;
2086
- if (traverseContextPool.length < POOL_SIZE) {
2087
- traverseContextPool.push(traverseContext);
2088
- }
2089
- }
2090
-
2091
- /**
2092
- * @param {?*} children Children tree container.
2093
- * @param {!string} nameSoFar Name of the key path so far.
2094
- * @param {!function} callback Callback to invoke with each child found.
2095
- * @param {?*} traverseContext Used to pass information throughout the traversal
2096
- * process.
2097
- * @return {!number} The number of children in this subtree.
2098
- */
2099
- function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
2100
- var type = typeof children;
2101
-
2102
- if (type === 'undefined' || type === 'boolean') {
2103
- // All of the above are perceived as null.
2104
- children = null;
2105
- }
2106
-
2107
- var invokeCallback = false;
2108
-
2109
- if (children === null) {
2110
- invokeCallback = true;
2111
- } else {
2112
- switch (type) {
2113
- case 'string':
2114
- case 'number':
2115
- invokeCallback = true;
2116
- break;
2117
- case 'object':
2118
- switch (children.$$typeof) {
2119
- case REACT_ELEMENT_TYPE:
2120
- case REACT_PORTAL_TYPE:
2121
- invokeCallback = true;
2122
- }
2123
- }
2124
- }
2125
-
2126
- if (invokeCallback) {
2127
- callback(traverseContext, children,
2128
- // If it's the only child, treat the name as if it was wrapped in an array
2129
- // so that it's consistent if the number of children grows.
2130
- nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
2131
- return 1;
2132
- }
2133
-
2134
- var child = void 0;
2135
- var nextName = void 0;
2136
- var subtreeCount = 0; // Count of children found in the current subtree.
2137
- var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
2138
-
2139
- if (Array.isArray(children)) {
2140
- for (var i = 0; i < children.length; i++) {
2141
- child = children[i];
2142
- nextName = nextNamePrefix + getComponentKey(child, i);
2143
- subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2144
- }
2145
- } else {
2146
- var iteratorFn = getIteratorFn(children);
2147
- if (typeof iteratorFn === 'function') {
2148
- {
2149
- // Warn about using Maps as children
2150
- if (iteratorFn === children.entries) {
2151
- !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;
2152
- didWarnAboutMaps = true;
2153
- }
2154
- }
2155
-
2156
- var iterator = iteratorFn.call(children);
2157
- var step = void 0;
2158
- var ii = 0;
2159
- while (!(step = iterator.next()).done) {
2160
- child = step.value;
2161
- nextName = nextNamePrefix + getComponentKey(child, ii++);
2162
- subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2163
- }
2164
- } else if (type === 'object') {
2165
- var addendum = '';
2166
- {
2167
- addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
2168
- }
2169
- var childrenString = '' + children;
2170
- 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);
2171
- }
2172
- }
2173
-
2174
- return subtreeCount;
2175
- }
2176
-
2177
- /**
2178
- * Traverses children that are typically specified as `props.children`, but
2179
- * might also be specified through attributes:
2180
- *
2181
- * - `traverseAllChildren(this.props.children, ...)`
2182
- * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
2183
- *
2184
- * The `traverseContext` is an optional argument that is passed through the
2185
- * entire traversal. It can be used to store accumulations or anything else that
2186
- * the callback might find relevant.
2187
- *
2188
- * @param {?*} children Children tree object.
2189
- * @param {!function} callback To invoke upon traversing each child.
2190
- * @param {?*} traverseContext Context for traversal.
2191
- * @return {!number} The number of children in this subtree.
2192
- */
2193
- function traverseAllChildren(children, callback, traverseContext) {
2194
- if (children == null) {
2195
- return 0;
2196
- }
2197
-
2198
- return traverseAllChildrenImpl(children, '', callback, traverseContext);
2199
- }
2200
-
2201
- /**
2202
- * Generate a key string that identifies a component within a set.
2203
- *
2204
- * @param {*} component A component that could contain a manual key.
2205
- * @param {number} index Index that is used if a manual key is not provided.
2206
- * @return {string}
2207
- */
2208
- function getComponentKey(component, index) {
2209
- // Do some typechecking here since we call this blindly. We want to ensure
2210
- // that we don't block potential future ES APIs.
2211
- if (typeof component === 'object' && component !== null && component.key != null) {
2212
- // Explicit key
2213
- return escape(component.key);
2214
- }
2215
- // Implicit key determined by the index in the set
2216
- return index.toString(36);
2217
- }
2218
-
2219
- function forEachSingleChild(bookKeeping, child, name) {
2220
- var func = bookKeeping.func,
2221
- context = bookKeeping.context;
2222
-
2223
- func.call(context, child, bookKeeping.count++);
2224
- }
2225
-
2226
- /**
2227
- * Iterates through children that are typically specified as `props.children`.
2228
- *
2229
- * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
2230
- *
2231
- * The provided forEachFunc(child, index) will be called for each
2232
- * leaf child.
2233
- *
2234
- * @param {?*} children Children tree container.
2235
- * @param {function(*, int)} forEachFunc
2236
- * @param {*} forEachContext Context for forEachContext.
2237
- */
2238
- function forEachChildren(children, forEachFunc, forEachContext) {
2239
- if (children == null) {
2240
- return children;
2241
- }
2242
- var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
2243
- traverseAllChildren(children, forEachSingleChild, traverseContext);
2244
- releaseTraverseContext(traverseContext);
2245
- }
2246
-
2247
- function mapSingleChildIntoContext(bookKeeping, child, childKey) {
2248
- var result = bookKeeping.result,
2249
- keyPrefix = bookKeeping.keyPrefix,
2250
- func = bookKeeping.func,
2251
- context = bookKeeping.context;
2252
-
2253
-
2254
- var mappedChild = func.call(context, child, bookKeeping.count++);
2255
- if (Array.isArray(mappedChild)) {
2256
- mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
2257
- return c;
2258
- });
2259
- } else if (mappedChild != null) {
2260
- if (isValidElement(mappedChild)) {
2261
- mappedChild = cloneAndReplaceKey(mappedChild,
2262
- // Keep both the (mapped) and old keys if they differ, just as
2263
- // traverseAllChildren used to do for objects as children
2264
- keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
2265
- }
2266
- result.push(mappedChild);
2267
- }
2268
- }
2269
-
2270
- function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
2271
- var escapedPrefix = '';
2272
- if (prefix != null) {
2273
- escapedPrefix = escapeUserProvidedKey(prefix) + '/';
2274
- }
2275
- var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
2276
- traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
2277
- releaseTraverseContext(traverseContext);
2278
- }
2279
-
2280
- /**
2281
- * Maps children that are typically specified as `props.children`.
2282
- *
2283
- * See https://reactjs.org/docs/react-api.html#reactchildrenmap
2284
- *
2285
- * The provided mapFunction(child, key, index) will be called for each
2286
- * leaf child.
2287
- *
2288
- * @param {?*} children Children tree container.
2289
- * @param {function(*, int)} func The map function.
2290
- * @param {*} context Context for mapFunction.
2291
- * @return {object} Object containing the ordered map of results.
2292
- */
2293
- function mapChildren(children, func, context) {
2294
- if (children == null) {
2295
- return children;
2296
- }
2297
- var result = [];
2298
- mapIntoWithKeyPrefixInternal(children, result, null, func, context);
2299
- return result;
2300
- }
2301
-
2302
- /**
2303
- * Count the number of children that are typically specified as
2304
- * `props.children`.
2305
- *
2306
- * See https://reactjs.org/docs/react-api.html#reactchildrencount
2307
- *
2308
- * @param {?*} children Children tree container.
2309
- * @return {number} The number of children.
2310
- */
2311
- function countChildren(children) {
2312
- return traverseAllChildren(children, function () {
2313
- return null;
2314
- }, null);
2315
- }
2316
-
2317
- /**
2318
- * Flatten a children object (typically specified as `props.children`) and
2319
- * return an array with appropriately re-keyed children.
2320
- *
2321
- * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
2322
- */
2323
- function toArray(children) {
2324
- var result = [];
2325
- mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
2326
- return child;
2327
- });
2328
- return result;
2329
- }
2330
-
2331
- /**
2332
- * Returns the first child in a collection of children and verifies that there
2333
- * is only one child in the collection.
2334
- *
2335
- * See https://reactjs.org/docs/react-api.html#reactchildrenonly
2336
- *
2337
- * The current implementation of this function assumes that a single child gets
2338
- * passed without a wrapper, but the purpose of this helper function is to
2339
- * abstract away the particular structure of children.
2340
- *
2341
- * @param {?object} children Child collection structure.
2342
- * @return {ReactElement} The first and only `ReactElement` contained in the
2343
- * structure.
2344
- */
2345
- function onlyChild(children) {
2346
- !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
2347
- return children;
2348
- }
2349
-
2350
- function createContext(defaultValue, calculateChangedBits) {
2351
- if (calculateChangedBits === undefined) {
2352
- calculateChangedBits = null;
2353
- } else {
2354
- {
2355
- !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
2356
- }
2357
- }
2358
-
2359
- var context = {
2360
- $$typeof: REACT_CONTEXT_TYPE,
2361
- _calculateChangedBits: calculateChangedBits,
2362
- // As a workaround to support multiple concurrent renderers, we categorize
2363
- // some renderers as primary and others as secondary. We only expect
2364
- // there to be two concurrent renderers at most: React Native (primary) and
2365
- // Fabric (secondary); React DOM (primary) and React ART (secondary).
2366
- // Secondary renderers store their context values on separate fields.
2367
- _currentValue: defaultValue,
2368
- _currentValue2: defaultValue,
2369
- // Used to track how many concurrent renderers this context currently
2370
- // supports within in a single renderer. Such as parallel server rendering.
2371
- _threadCount: 0,
2372
- // These are circular
2373
- Provider: null,
2374
- Consumer: null
2375
- };
2376
-
2377
- context.Provider = {
2378
- $$typeof: REACT_PROVIDER_TYPE,
2379
- _context: context
2380
- };
2381
-
2382
- var hasWarnedAboutUsingNestedContextConsumers = false;
2383
- var hasWarnedAboutUsingConsumerProvider = false;
2384
-
2385
- {
2386
- // A separate object, but proxies back to the original context object for
2387
- // backwards compatibility. It has a different $$typeof, so we can properly
2388
- // warn for the incorrect usage of Context as a Consumer.
2389
- var Consumer = {
2390
- $$typeof: REACT_CONTEXT_TYPE,
2391
- _context: context,
2392
- _calculateChangedBits: context._calculateChangedBits
2393
- };
2394
- // $FlowFixMe: Flow complains about not setting a value, which is intentional here
2395
- Object.defineProperties(Consumer, {
2396
- Provider: {
2397
- get: function () {
2398
- if (!hasWarnedAboutUsingConsumerProvider) {
2399
- hasWarnedAboutUsingConsumerProvider = true;
2400
- 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?');
2401
- }
2402
- return context.Provider;
2403
- },
2404
- set: function (_Provider) {
2405
- context.Provider = _Provider;
2406
- }
2407
- },
2408
- _currentValue: {
2409
- get: function () {
2410
- return context._currentValue;
2411
- },
2412
- set: function (_currentValue) {
2413
- context._currentValue = _currentValue;
2414
- }
2415
- },
2416
- _currentValue2: {
2417
- get: function () {
2418
- return context._currentValue2;
2419
- },
2420
- set: function (_currentValue2) {
2421
- context._currentValue2 = _currentValue2;
2422
- }
2423
- },
2424
- _threadCount: {
2425
- get: function () {
2426
- return context._threadCount;
2427
- },
2428
- set: function (_threadCount) {
2429
- context._threadCount = _threadCount;
2430
- }
2431
- },
2432
- Consumer: {
2433
- get: function () {
2434
- if (!hasWarnedAboutUsingNestedContextConsumers) {
2435
- hasWarnedAboutUsingNestedContextConsumers = true;
2436
- 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?');
2437
- }
2438
- return context.Consumer;
2439
- }
2440
- }
2441
- });
2442
- // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
2443
- context.Consumer = Consumer;
2444
- }
2445
-
2446
- {
2447
- context._currentRenderer = null;
2448
- context._currentRenderer2 = null;
2449
- }
2450
-
2451
- return context;
2452
- }
2453
-
2454
- function lazy(ctor) {
2455
- return {
2456
- $$typeof: REACT_LAZY_TYPE,
2457
- _ctor: ctor,
2458
- // React uses these fields to store the result.
2459
- _status: -1,
2460
- _result: null
2461
- };
2462
- }
2463
-
2464
- function forwardRef(render) {
2465
- {
2466
- if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
2467
- warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
2468
- } else if (typeof render !== 'function') {
2469
- warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
2470
- } else {
2471
- !(
2472
- // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
2473
- 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;
2474
- }
2475
-
2476
- if (render != null) {
2477
- !(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;
2478
- }
2479
- }
2480
-
2481
- return {
2482
- $$typeof: REACT_FORWARD_REF_TYPE,
2483
- render: render
2484
- };
2485
- }
2486
-
2487
- function isValidElementType(type) {
2488
- return typeof type === 'string' || typeof type === 'function' ||
2489
- // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2490
- type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_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);
2491
- }
2492
-
2493
- function memo(type, compare) {
2494
- {
2495
- if (!isValidElementType(type)) {
2496
- warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
2497
- }
2498
- }
2499
- return {
2500
- $$typeof: REACT_MEMO_TYPE,
2501
- type: type,
2502
- compare: compare === undefined ? null : compare
2503
- };
2504
- }
2505
-
2506
- function resolveDispatcher() {
2507
- var dispatcher = ReactCurrentOwner.currentDispatcher;
2508
- !(dispatcher !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component.') : void 0;
2509
- return dispatcher;
2510
- }
2511
-
2512
- function useContext(Context, observedBits) {
2513
- var dispatcher = resolveDispatcher();
2514
- {
2515
- // TODO: add a more generic warning for invalid values.
2516
- if (Context._context !== undefined) {
2517
- var realContext = Context._context;
2518
- // Don't deduplicate because this legitimately causes bugs
2519
- // and nobody should be using this in existing code.
2520
- if (realContext.Consumer === Context) {
2521
- 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?');
2522
- } else if (realContext.Provider === Context) {
2523
- warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
2524
- }
2525
- }
2526
- }
2527
- return dispatcher.useContext(Context, observedBits);
2528
- }
2529
-
2530
- function useState(initialState) {
2531
- var dispatcher = resolveDispatcher();
2532
- return dispatcher.useState(initialState);
2533
- }
2534
-
2535
- function useReducer(reducer, initialState, initialAction) {
2536
- var dispatcher = resolveDispatcher();
2537
- return dispatcher.useReducer(reducer, initialState, initialAction);
2538
- }
2539
-
2540
- function useRef(initialValue) {
2541
- var dispatcher = resolveDispatcher();
2542
- return dispatcher.useRef(initialValue);
2543
- }
2544
-
2545
- function useEffect(create, inputs) {
2546
- var dispatcher = resolveDispatcher();
2547
- return dispatcher.useEffect(create, inputs);
2548
- }
2549
-
2550
- function useMutationEffect(create, inputs) {
2551
- var dispatcher = resolveDispatcher();
2552
- return dispatcher.useMutationEffect(create, inputs);
2553
- }
2554
-
2555
- function useLayoutEffect(create, inputs) {
2556
- var dispatcher = resolveDispatcher();
2557
- return dispatcher.useLayoutEffect(create, inputs);
2558
- }
2559
-
2560
- function useCallback(callback, inputs) {
2561
- var dispatcher = resolveDispatcher();
2562
- return dispatcher.useCallback(callback, inputs);
2563
- }
2564
-
2565
- function useMemo(create, inputs) {
2566
- var dispatcher = resolveDispatcher();
2567
- return dispatcher.useMemo(create, inputs);
2568
- }
2569
-
2570
- function useImperativeMethods(ref, create, inputs) {
2571
- var dispatcher = resolveDispatcher();
2572
- return dispatcher.useImperativeMethods(ref, create, inputs);
2573
- }
2574
-
2575
- /**
2576
- * Copyright (c) 2013-present, Facebook, Inc.
2577
- *
2578
- * This source code is licensed under the MIT license found in the
2579
- * LICENSE file in the root directory of this source tree.
2580
- */
2581
-
2582
-
2583
-
2584
- var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
2585
-
2586
- var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
2587
-
2588
- /**
2589
- * Copyright (c) 2013-present, Facebook, Inc.
2590
- *
2591
- * This source code is licensed under the MIT license found in the
2592
- * LICENSE file in the root directory of this source tree.
2593
- */
2594
-
2595
-
2596
-
2597
- var printWarning$1 = function() {};
2598
-
2599
- {
2600
- var ReactPropTypesSecret = ReactPropTypesSecret_1;
2601
- var loggedTypeFailures = {};
2602
-
2603
- printWarning$1 = function(text) {
2604
- var message = 'Warning: ' + text;
2605
- if (typeof console !== 'undefined') {
2606
- console.error(message);
2607
- }
2608
- try {
2609
- // --- Welcome to debugging React ---
2610
- // This error was thrown as a convenience so that you can use this stack
2611
- // to find the callsite that caused this warning to fire.
2612
- throw new Error(message);
2613
- } catch (x) {}
2614
- };
2615
- }
2616
-
2617
- /**
2618
- * Assert that the values match with the type specs.
2619
- * Error messages are memorized and will only be shown once.
2620
- *
2621
- * @param {object} typeSpecs Map of name to a ReactPropType
2622
- * @param {object} values Runtime values that need to be type-checked
2623
- * @param {string} location e.g. "prop", "context", "child context"
2624
- * @param {string} componentName Name of the component for error messages.
2625
- * @param {?Function} getStack Returns the component stack.
2626
- * @private
2627
- */
2628
- function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
2629
- {
2630
- for (var typeSpecName in typeSpecs) {
2631
- if (typeSpecs.hasOwnProperty(typeSpecName)) {
2632
- var error;
2633
- // Prop type validation may throw. In case they do, we don't want to
2634
- // fail the render phase where it didn't fail before. So we log it.
2635
- // After these have been cleaned up, we'll let them throw.
2636
- try {
2637
- // This is intentionally an invariant that gets caught. It's the same
2638
- // behavior as without this statement except with a better message.
2639
- if (typeof typeSpecs[typeSpecName] !== 'function') {
2640
- var err = Error(
2641
- (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
2642
- 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
2643
- );
2644
- err.name = 'Invariant Violation';
2645
- throw err;
2646
- }
2647
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
2648
- } catch (ex) {
2649
- error = ex;
2650
- }
2651
- if (error && !(error instanceof Error)) {
2652
- printWarning$1(
2653
- (componentName || 'React class') + ': type specification of ' +
2654
- location + ' `' + typeSpecName + '` is invalid; the type checker ' +
2655
- 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
2656
- 'You may have forgotten to pass an argument to the type checker ' +
2657
- 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
2658
- 'shape all require an argument).'
2659
- );
2660
-
2661
- }
2662
- if (error instanceof Error && !(error.message in loggedTypeFailures)) {
2663
- // Only monitor this failure once because there tends to be a lot of the
2664
- // same error.
2665
- loggedTypeFailures[error.message] = true;
2666
-
2667
- var stack = getStack ? getStack() : '';
2668
-
2669
- printWarning$1(
2670
- 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
2671
- );
2672
- }
2673
- }
2674
- }
2675
- }
2676
- }
2677
-
2678
- var checkPropTypes_1 = checkPropTypes;
2679
-
2680
- /**
2681
- * ReactElementValidator provides a wrapper around a element factory
2682
- * which validates the props passed to the element. This is intended to be
2683
- * used only in DEV and could be replaced by a static type checker for languages
2684
- * that support it.
2685
- */
2686
-
2687
- var propTypesMisspellWarningShown = void 0;
2688
-
2689
- {
2690
- propTypesMisspellWarningShown = false;
2691
- }
2692
-
2693
- function getDeclarationErrorAddendum() {
2694
- if (ReactCurrentOwner.current) {
2695
- var name = getComponentName(ReactCurrentOwner.current.type);
2696
- if (name) {
2697
- return '\n\nCheck the render method of `' + name + '`.';
2698
- }
2699
- }
2700
- return '';
2701
- }
2702
-
2703
- function getSourceInfoErrorAddendum(elementProps) {
2704
- if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
2705
- var source = elementProps.__source;
2706
- var fileName = source.fileName.replace(/^.*[\\\/]/, '');
2707
- var lineNumber = source.lineNumber;
2708
- return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
2709
- }
2710
- return '';
2711
- }
2712
-
2713
- /**
2714
- * Warn if there's no key explicitly set on dynamic arrays of children or
2715
- * object keys are not valid. This allows us to keep track of children between
2716
- * updates.
2717
- */
2718
- var ownerHasKeyUseWarning = {};
2719
-
2720
- function getCurrentComponentErrorInfo(parentType) {
2721
- var info = getDeclarationErrorAddendum();
2722
-
2723
- if (!info) {
2724
- var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
2725
- if (parentName) {
2726
- info = '\n\nCheck the top-level render call using <' + parentName + '>.';
2727
- }
2728
- }
2729
- return info;
2730
- }
2731
-
2732
- /**
2733
- * Warn if the element doesn't have an explicit key assigned to it.
2734
- * This element is in an array. The array could grow and shrink or be
2735
- * reordered. All children that haven't already been validated are required to
2736
- * have a "key" property assigned to it. Error statuses are cached so a warning
2737
- * will only be shown once.
2738
- *
2739
- * @internal
2740
- * @param {ReactElement} element Element that requires a key.
2741
- * @param {*} parentType element's parent's type.
2742
- */
2743
- function validateExplicitKey(element, parentType) {
2744
- if (!element._store || element._store.validated || element.key != null) {
2745
- return;
2746
- }
2747
- element._store.validated = true;
2748
-
2749
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
2750
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
2751
- return;
2752
- }
2753
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
2754
-
2755
- // Usually the current owner is the offender, but if it accepts children as a
2756
- // property, it may be the creator of the child that's responsible for
2757
- // assigning it a key.
2758
- var childOwner = '';
2759
- if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2760
- // Give the component that originally created this child.
2761
- childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
2762
- }
2763
-
2764
- setCurrentlyValidatingElement(element);
2765
- {
2766
- warning$1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
2767
- }
2768
- setCurrentlyValidatingElement(null);
2769
- }
2770
-
2771
- /**
2772
- * Ensure that every element either is passed in a static location, in an
2773
- * array with an explicit keys property defined, or in an object literal
2774
- * with valid key property.
2775
- *
2776
- * @internal
2777
- * @param {ReactNode} node Statically passed child of any type.
2778
- * @param {*} parentType node's parent's type.
2779
- */
2780
- function validateChildKeys(node, parentType) {
2781
- if (typeof node !== 'object') {
2782
- return;
2783
- }
2784
- if (Array.isArray(node)) {
2785
- for (var i = 0; i < node.length; i++) {
2786
- var child = node[i];
2787
- if (isValidElement(child)) {
2788
- validateExplicitKey(child, parentType);
2789
- }
2790
- }
2791
- } else if (isValidElement(node)) {
2792
- // This element was passed in a valid location.
2793
- if (node._store) {
2794
- node._store.validated = true;
2795
- }
2796
- } else if (node) {
2797
- var iteratorFn = getIteratorFn(node);
2798
- if (typeof iteratorFn === 'function') {
2799
- // Entry iterators used to provide implicit keys,
2800
- // but now we print a separate warning for them later.
2801
- if (iteratorFn !== node.entries) {
2802
- var iterator = iteratorFn.call(node);
2803
- var step = void 0;
2804
- while (!(step = iterator.next()).done) {
2805
- if (isValidElement(step.value)) {
2806
- validateExplicitKey(step.value, parentType);
2807
- }
2808
- }
2809
- }
2810
- }
2811
- }
2812
- }
2813
-
2814
- /**
2815
- * Given an element, validate that its props follow the propTypes definition,
2816
- * provided by the type.
2817
- *
2818
- * @param {ReactElement} element
2819
- */
2820
- function validatePropTypes(element) {
2821
- var type = element.type;
2822
- var name = void 0,
2823
- propTypes = void 0;
2824
- if (typeof type === 'function') {
2825
- // Class or function component
2826
- name = type.displayName || type.name;
2827
- propTypes = type.propTypes;
2828
- } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
2829
- // ForwardRef
2830
- var functionName = type.render.displayName || type.render.name || '';
2831
- name = type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
2832
- propTypes = type.propTypes;
2833
- } else {
2834
- return;
2835
- }
2836
- if (propTypes) {
2837
- setCurrentlyValidatingElement(element);
2838
- checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
2839
- setCurrentlyValidatingElement(null);
2840
- } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2841
- propTypesMisspellWarningShown = true;
2842
- warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
2843
- }
2844
- if (typeof type.getDefaultProps === 'function') {
2845
- !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
2846
- }
2847
- }
2848
-
2849
- /**
2850
- * Given a fragment, validate that it can only be provided with fragment props
2851
- * @param {ReactElement} fragment
2852
- */
2853
- function validateFragmentProps(fragment) {
2854
- setCurrentlyValidatingElement(fragment);
2855
-
2856
- var keys = Object.keys(fragment.props);
2857
- for (var i = 0; i < keys.length; i++) {
2858
- var key = keys[i];
2859
- if (key !== 'children' && key !== 'key') {
2860
- warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
2861
- break;
2862
- }
2863
- }
2864
-
2865
- if (fragment.ref !== null) {
2866
- warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
2867
- }
2868
-
2869
- setCurrentlyValidatingElement(null);
2870
- }
2871
-
2872
- function createElementWithValidation(type, props, children) {
2873
- var validType = isValidElementType(type);
2874
-
2875
- // We warn in this case but don't throw. We expect the element creation to
2876
- // succeed and there will likely be errors in render.
2877
- if (!validType) {
2878
- var info = '';
2879
- if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
2880
- 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.";
2881
- }
2882
-
2883
- var sourceInfo = getSourceInfoErrorAddendum(props);
2884
- if (sourceInfo) {
2885
- info += sourceInfo;
2886
- } else {
2887
- info += getDeclarationErrorAddendum();
2888
- }
2889
-
2890
- var typeString = void 0;
2891
- if (type === null) {
2892
- typeString = 'null';
2893
- } else if (Array.isArray(type)) {
2894
- typeString = 'array';
2895
- } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
2896
- typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
2897
- info = ' Did you accidentally export a JSX literal instead of a component?';
2898
- } else {
2899
- typeString = typeof type;
2900
- }
2901
-
2902
- 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);
2903
- }
2904
-
2905
- var element = createElement.apply(this, arguments);
2906
-
2907
- // The result can be nullish if a mock or a custom function is used.
2908
- // TODO: Drop this when these are no longer allowed as the type argument.
2909
- if (element == null) {
2910
- return element;
2911
- }
2912
-
2913
- // Skip key warning if the type isn't valid since our key validation logic
2914
- // doesn't expect a non-string/function type and can throw confusing errors.
2915
- // We don't want exception behavior to differ between dev and prod.
2916
- // (Rendering will throw with a helpful message and as soon as the type is
2917
- // fixed, the key warnings will appear.)
2918
- if (validType) {
2919
- for (var i = 2; i < arguments.length; i++) {
2920
- validateChildKeys(arguments[i], type);
2921
- }
2922
- }
2923
-
2924
- if (type === REACT_FRAGMENT_TYPE) {
2925
- validateFragmentProps(element);
2926
- } else {
2927
- validatePropTypes(element);
2928
- }
2929
-
2930
- return element;
2931
- }
2932
-
2933
- function createFactoryWithValidation(type) {
2934
- var validatedFactory = createElementWithValidation.bind(null, type);
2935
- validatedFactory.type = type;
2936
- // Legacy hook: remove it
2937
- {
2938
- Object.defineProperty(validatedFactory, 'type', {
2939
- enumerable: false,
2940
- get: function () {
2941
- lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
2942
- Object.defineProperty(this, 'type', {
2943
- value: type
2944
- });
2945
- return type;
2946
- }
2947
- });
2948
- }
2949
-
2950
- return validatedFactory;
2951
- }
2952
-
2953
- function cloneElementWithValidation(element, props, children) {
2954
- var newElement = cloneElement.apply(this, arguments);
2955
- for (var i = 2; i < arguments.length; i++) {
2956
- validateChildKeys(arguments[i], newElement.type);
2957
- }
2958
- validatePropTypes(newElement);
2959
- return newElement;
2960
- }
2961
-
2962
- var React = {
2963
- Children: {
2964
- map: mapChildren,
2965
- forEach: forEachChildren,
2966
- count: countChildren,
2967
- toArray: toArray,
2968
- only: onlyChild
2969
- },
2970
-
2971
- createRef: createRef,
2972
- Component: Component,
2973
- PureComponent: PureComponent,
2974
-
2975
- createContext: createContext,
2976
- forwardRef: forwardRef,
2977
- lazy: lazy,
2978
- memo: memo,
2979
-
2980
- Fragment: REACT_FRAGMENT_TYPE,
2981
- StrictMode: REACT_STRICT_MODE_TYPE,
2982
- Suspense: REACT_SUSPENSE_TYPE,
2983
-
2984
- createElement: createElementWithValidation,
2985
- cloneElement: cloneElementWithValidation,
2986
- createFactory: createFactoryWithValidation,
2987
- isValidElement: isValidElement,
2988
-
2989
- version: ReactVersion,
2990
-
2991
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
2992
- };
2993
-
2994
- if (enableStableConcurrentModeAPIs) {
2995
- React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
2996
- React.Profiler = REACT_PROFILER_TYPE;
2997
- } else {
2998
- React.unstable_ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
2999
- React.unstable_Profiler = REACT_PROFILER_TYPE;
3000
- }
3001
-
3002
- if (enableHooks) {
3003
- React.useCallback = useCallback;
3004
- React.useContext = useContext;
3005
- React.useEffect = useEffect;
3006
- React.useImperativeMethods = useImperativeMethods;
3007
- React.useLayoutEffect = useLayoutEffect;
3008
- React.useMemo = useMemo;
3009
- React.useMutationEffect = useMutationEffect;
3010
- React.useReducer = useReducer;
3011
- React.useRef = useRef;
3012
- React.useState = useState;
3013
- }
3014
-
3015
-
3016
-
3017
- var React$2 = Object.freeze({
3018
- default: React
3019
- });
3020
-
3021
- var React$3 = ( React$2 && React ) || React$2;
3022
-
3023
- // TODO: decide on the top-level export form.
3024
- // This is hacky but makes it work with both Rollup and Jest.
3025
- var react = React$3.default || React$3;
3026
-
3027
- return react;
3028
-
3029
- })));