react 19.0.0-canary-657428a9e-20240416 → 19.0.0-canary-33a32441e9-20240418
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/react.development.js +4 -11
- package/cjs/react.production.js +4 -7
- package/cjs/react.production.min.js +17 -17
- package/cjs/react.production.min.js.map +1 -1
- package/cjs/react.react-server.development.js +1 -1
- package/cjs/react.react-server.production.js +1 -1
- package/cjs/react.react-server.production.min.js +1 -1
- package/package.json +1 -2
- package/umd/react.development.js +0 -3433
- package/umd/react.production.min.js +0 -33
- package/umd/react.profiling.min.js +0 -33
package/umd/react.development.js
DELETED
@@ -1,3433 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license React
|
3
|
-
* react.development.js
|
4
|
-
*
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
6
|
-
*
|
7
|
-
* This source code is licensed under the MIT license found in the
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/
|
10
|
-
|
11
|
-
(function (global, factory) {
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
13
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}));
|
15
|
-
})(this, (function (exports) { 'use strict';
|
16
|
-
|
17
|
-
var ReactVersion = '19.0.0-canary-657428a9e-20240416';
|
18
|
-
|
19
|
-
// ATTENTION
|
20
|
-
// When adding new symbols to this file,
|
21
|
-
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
22
|
-
// The Symbol used to tag the ReactElement-like types.
|
23
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
24
|
-
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
25
|
-
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
26
|
-
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
27
|
-
var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
28
|
-
var REACT_PROVIDER_TYPE = Symbol.for('react.provider'); // TODO: Delete with enableRenderableContext
|
29
|
-
|
30
|
-
var REACT_CONSUMER_TYPE = Symbol.for('react.consumer');
|
31
|
-
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
32
|
-
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
33
|
-
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
34
|
-
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
35
|
-
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
36
|
-
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
37
|
-
var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
|
38
|
-
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
39
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
40
|
-
function getIteratorFn(maybeIterable) {
|
41
|
-
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
42
|
-
return null;
|
43
|
-
}
|
44
|
-
|
45
|
-
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
46
|
-
|
47
|
-
if (typeof maybeIterator === 'function') {
|
48
|
-
return maybeIterator;
|
49
|
-
}
|
50
|
-
|
51
|
-
return null;
|
52
|
-
}
|
53
|
-
|
54
|
-
// -----------------------------------------------------------------------------
|
55
|
-
|
56
|
-
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
57
|
-
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
58
|
-
|
59
|
-
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
|
60
|
-
// as a normal prop instead of stripping it from the props object.
|
61
|
-
// Passes `ref` as a normal prop instead of stripping it from the props object
|
62
|
-
// during element creation.
|
63
|
-
|
64
|
-
var enableRefAsProp = true;
|
65
|
-
// This allows us to land breaking changes to remove legacy mode APIs in experimental builds
|
66
|
-
// before removing them in stable in the next Major
|
67
|
-
|
68
|
-
var disableLegacyMode = true;
|
69
|
-
|
70
|
-
var enableRenderableContext = true; // Enables the `initialValue` option for `useDeferredValue`
|
71
|
-
// stuff. Intended to enable React core members to more easily debug scheduling
|
72
|
-
// issues in DEV builds.
|
73
|
-
|
74
|
-
var enableDebugTracing = false;
|
75
|
-
|
76
|
-
var ReactSharedInternals$1 = {
|
77
|
-
H: null,
|
78
|
-
C: null,
|
79
|
-
T: null
|
80
|
-
};
|
81
|
-
|
82
|
-
{
|
83
|
-
ReactSharedInternals$1.owner = null;
|
84
|
-
}
|
85
|
-
|
86
|
-
{
|
87
|
-
ReactSharedInternals$1.actQueue = null;
|
88
|
-
ReactSharedInternals$1.isBatchingLegacy = false;
|
89
|
-
ReactSharedInternals$1.didScheduleLegacyUpdate = false;
|
90
|
-
ReactSharedInternals$1.didUsePromise = false;
|
91
|
-
ReactSharedInternals$1.thrownErrors = [];
|
92
|
-
var currentExtraStackFrame$1 = null;
|
93
|
-
|
94
|
-
ReactSharedInternals$1.setExtraStackFrame = function (stack) {
|
95
|
-
currentExtraStackFrame$1 = stack;
|
96
|
-
}; // Stack implementation injected by the current renderer.
|
97
|
-
|
98
|
-
|
99
|
-
ReactSharedInternals$1.getCurrentStack = null;
|
100
|
-
|
101
|
-
ReactSharedInternals$1.getStackAddendum = function () {
|
102
|
-
var stack = ''; // Add an extra top frame while an element is being validated
|
103
|
-
|
104
|
-
if (currentExtraStackFrame$1) {
|
105
|
-
stack += currentExtraStackFrame$1;
|
106
|
-
} // Delegate to the injected renderer-specific implementation
|
107
|
-
|
108
|
-
|
109
|
-
var impl = ReactSharedInternals$1.getCurrentStack;
|
110
|
-
|
111
|
-
if (impl) {
|
112
|
-
stack += impl() || '';
|
113
|
-
}
|
114
|
-
|
115
|
-
return stack;
|
116
|
-
};
|
117
|
-
}
|
118
|
-
|
119
|
-
// by calls to these methods by a Babel plugin.
|
120
|
-
//
|
121
|
-
// In PROD (or in packages without access to React internals),
|
122
|
-
// they are left as they are instead.
|
123
|
-
|
124
|
-
function warn(format) {
|
125
|
-
{
|
126
|
-
{
|
127
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
128
|
-
args[_key - 1] = arguments[_key];
|
129
|
-
}
|
130
|
-
|
131
|
-
printWarning('warn', format, args);
|
132
|
-
}
|
133
|
-
}
|
134
|
-
}
|
135
|
-
function error(format) {
|
136
|
-
{
|
137
|
-
{
|
138
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
139
|
-
args[_key2 - 1] = arguments[_key2];
|
140
|
-
}
|
141
|
-
|
142
|
-
printWarning('error', format, args);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
function printWarning(level, format, args) {
|
148
|
-
// When changing this logic, you might want to also
|
149
|
-
// update consoleWithStackDev.www.js as well.
|
150
|
-
{
|
151
|
-
var stack = ReactSharedInternals$1.getStackAddendum();
|
152
|
-
|
153
|
-
if (stack !== '') {
|
154
|
-
format += '%s';
|
155
|
-
args = args.concat([stack]);
|
156
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
157
|
-
|
158
|
-
|
159
|
-
var argsWithFormat = args.map(function (item) {
|
160
|
-
return String(item);
|
161
|
-
}); // Careful: RN currently depends on this prefix
|
162
|
-
|
163
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
164
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
165
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
166
|
-
|
167
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
var didWarnStateUpdateForUnmountedComponent = {};
|
172
|
-
|
173
|
-
function warnNoop(publicInstance, callerName) {
|
174
|
-
{
|
175
|
-
var _constructor = publicInstance.constructor;
|
176
|
-
var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
|
177
|
-
var warningKey = componentName + "." + callerName;
|
178
|
-
|
179
|
-
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
180
|
-
return;
|
181
|
-
}
|
182
|
-
|
183
|
-
error("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);
|
184
|
-
|
185
|
-
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
186
|
-
}
|
187
|
-
}
|
188
|
-
/**
|
189
|
-
* This is the abstract API for an update queue.
|
190
|
-
*/
|
191
|
-
|
192
|
-
|
193
|
-
var ReactNoopUpdateQueue = {
|
194
|
-
/**
|
195
|
-
* Checks whether or not this composite component is mounted.
|
196
|
-
* @param {ReactClass} publicInstance The instance we want to test.
|
197
|
-
* @return {boolean} True if mounted, false otherwise.
|
198
|
-
* @protected
|
199
|
-
* @final
|
200
|
-
*/
|
201
|
-
isMounted: function (publicInstance) {
|
202
|
-
return false;
|
203
|
-
},
|
204
|
-
|
205
|
-
/**
|
206
|
-
* Forces an update. This should only be invoked when it is known with
|
207
|
-
* certainty that we are **not** in a DOM transaction.
|
208
|
-
*
|
209
|
-
* You may want to call this when you know that some deeper aspect of the
|
210
|
-
* component's state has changed but `setState` was not called.
|
211
|
-
*
|
212
|
-
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
213
|
-
* `componentWillUpdate` and `componentDidUpdate`.
|
214
|
-
*
|
215
|
-
* @param {ReactClass} publicInstance The instance that should rerender.
|
216
|
-
* @param {?function} callback Called after component is updated.
|
217
|
-
* @param {?string} callerName name of the calling function in the public API.
|
218
|
-
* @internal
|
219
|
-
*/
|
220
|
-
enqueueForceUpdate: function (publicInstance, callback, callerName) {
|
221
|
-
warnNoop(publicInstance, 'forceUpdate');
|
222
|
-
},
|
223
|
-
|
224
|
-
/**
|
225
|
-
* Replaces all of the state. Always use this or `setState` to mutate state.
|
226
|
-
* You should treat `this.state` as immutable.
|
227
|
-
*
|
228
|
-
* There is no guarantee that `this.state` will be immediately updated, so
|
229
|
-
* accessing `this.state` after calling this method may return the old value.
|
230
|
-
*
|
231
|
-
* @param {ReactClass} publicInstance The instance that should rerender.
|
232
|
-
* @param {object} completeState Next state.
|
233
|
-
* @param {?function} callback Called after component is updated.
|
234
|
-
* @param {?string} callerName name of the calling function in the public API.
|
235
|
-
* @internal
|
236
|
-
*/
|
237
|
-
enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
|
238
|
-
warnNoop(publicInstance, 'replaceState');
|
239
|
-
},
|
240
|
-
|
241
|
-
/**
|
242
|
-
* Sets a subset of the state. This only exists because _pendingState is
|
243
|
-
* internal. This provides a merging strategy that is not available to deep
|
244
|
-
* properties which is confusing. TODO: Expose pendingState or don't use it
|
245
|
-
* during the merge.
|
246
|
-
*
|
247
|
-
* @param {ReactClass} publicInstance The instance that should rerender.
|
248
|
-
* @param {object} partialState Next partial state to be merged with state.
|
249
|
-
* @param {?function} callback Called after component is updated.
|
250
|
-
* @param {?string} Name of the calling function in the public API.
|
251
|
-
* @internal
|
252
|
-
*/
|
253
|
-
enqueueSetState: function (publicInstance, partialState, callback, callerName) {
|
254
|
-
warnNoop(publicInstance, 'setState');
|
255
|
-
}
|
256
|
-
};
|
257
|
-
|
258
|
-
var assign = Object.assign;
|
259
|
-
|
260
|
-
var emptyObject = {};
|
261
|
-
|
262
|
-
{
|
263
|
-
Object.freeze(emptyObject);
|
264
|
-
}
|
265
|
-
/**
|
266
|
-
* Base class helpers for the updating state of a component.
|
267
|
-
*/
|
268
|
-
|
269
|
-
|
270
|
-
function Component(props, context, updater) {
|
271
|
-
this.props = props;
|
272
|
-
this.context = context; // If a component has string refs, we will assign a different object later.
|
273
|
-
|
274
|
-
this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
|
275
|
-
// renderer.
|
276
|
-
|
277
|
-
this.updater = updater || ReactNoopUpdateQueue;
|
278
|
-
}
|
279
|
-
|
280
|
-
Component.prototype.isReactComponent = {};
|
281
|
-
/**
|
282
|
-
* Sets a subset of the state. Always use this to mutate
|
283
|
-
* state. You should treat `this.state` as immutable.
|
284
|
-
*
|
285
|
-
* There is no guarantee that `this.state` will be immediately updated, so
|
286
|
-
* accessing `this.state` after calling this method may return the old value.
|
287
|
-
*
|
288
|
-
* There is no guarantee that calls to `setState` will run synchronously,
|
289
|
-
* as they may eventually be batched together. You can provide an optional
|
290
|
-
* callback that will be executed when the call to setState is actually
|
291
|
-
* completed.
|
292
|
-
*
|
293
|
-
* When a function is provided to setState, it will be called at some point in
|
294
|
-
* the future (not synchronously). It will be called with the up to date
|
295
|
-
* component arguments (state, props, context). These values can be different
|
296
|
-
* from this.* because your function may be called after receiveProps but before
|
297
|
-
* shouldComponentUpdate, and this new state, props, and context will not yet be
|
298
|
-
* assigned to this.
|
299
|
-
*
|
300
|
-
* @param {object|function} partialState Next partial state or function to
|
301
|
-
* produce next partial state to be merged with current state.
|
302
|
-
* @param {?function} callback Called after state is updated.
|
303
|
-
* @final
|
304
|
-
* @protected
|
305
|
-
*/
|
306
|
-
|
307
|
-
Component.prototype.setState = function (partialState, callback) {
|
308
|
-
if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) {
|
309
|
-
throw new Error('takes an object of state variables to update or a ' + 'function which returns an object of state variables.');
|
310
|
-
}
|
311
|
-
|
312
|
-
this.updater.enqueueSetState(this, partialState, callback, 'setState');
|
313
|
-
};
|
314
|
-
/**
|
315
|
-
* Forces an update. This should only be invoked when it is known with
|
316
|
-
* certainty that we are **not** in a DOM transaction.
|
317
|
-
*
|
318
|
-
* You may want to call this when you know that some deeper aspect of the
|
319
|
-
* component's state has changed but `setState` was not called.
|
320
|
-
*
|
321
|
-
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
322
|
-
* `componentWillUpdate` and `componentDidUpdate`.
|
323
|
-
*
|
324
|
-
* @param {?function} callback Called after update is complete.
|
325
|
-
* @final
|
326
|
-
* @protected
|
327
|
-
*/
|
328
|
-
|
329
|
-
|
330
|
-
Component.prototype.forceUpdate = function (callback) {
|
331
|
-
this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
|
332
|
-
};
|
333
|
-
/**
|
334
|
-
* Deprecated APIs. These APIs used to exist on classic React classes but since
|
335
|
-
* we would like to deprecate them, we're not going to move them over to this
|
336
|
-
* modern base class. Instead, we define a getter that warns if it's accessed.
|
337
|
-
*/
|
338
|
-
|
339
|
-
|
340
|
-
{
|
341
|
-
var deprecatedAPIs = {
|
342
|
-
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
343
|
-
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
344
|
-
};
|
345
|
-
|
346
|
-
var defineDeprecationWarning = function (methodName, info) {
|
347
|
-
Object.defineProperty(Component.prototype, methodName, {
|
348
|
-
get: function () {
|
349
|
-
warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
350
|
-
|
351
|
-
return undefined;
|
352
|
-
}
|
353
|
-
});
|
354
|
-
};
|
355
|
-
|
356
|
-
for (var fnName in deprecatedAPIs) {
|
357
|
-
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
358
|
-
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
359
|
-
}
|
360
|
-
}
|
361
|
-
}
|
362
|
-
|
363
|
-
function ComponentDummy() {}
|
364
|
-
|
365
|
-
ComponentDummy.prototype = Component.prototype;
|
366
|
-
/**
|
367
|
-
* Convenience component with default shallow equality check for sCU.
|
368
|
-
*/
|
369
|
-
|
370
|
-
function PureComponent(props, context, updater) {
|
371
|
-
this.props = props;
|
372
|
-
this.context = context; // If a component has string refs, we will assign a different object later.
|
373
|
-
|
374
|
-
this.refs = emptyObject;
|
375
|
-
this.updater = updater || ReactNoopUpdateQueue;
|
376
|
-
}
|
377
|
-
|
378
|
-
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
379
|
-
pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
|
380
|
-
|
381
|
-
assign(pureComponentPrototype, Component.prototype);
|
382
|
-
pureComponentPrototype.isPureReactComponent = true;
|
383
|
-
|
384
|
-
// an immutable object with a single mutable value
|
385
|
-
function createRef() {
|
386
|
-
var refObject = {
|
387
|
-
current: null
|
388
|
-
};
|
389
|
-
|
390
|
-
{
|
391
|
-
Object.seal(refObject);
|
392
|
-
}
|
393
|
-
|
394
|
-
return refObject;
|
395
|
-
}
|
396
|
-
|
397
|
-
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
398
|
-
|
399
|
-
function isArray(a) {
|
400
|
-
return isArrayImpl(a);
|
401
|
-
}
|
402
|
-
|
403
|
-
/*
|
404
|
-
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
|
405
|
-
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
|
406
|
-
*
|
407
|
-
* The functions in this module will throw an easier-to-understand,
|
408
|
-
* easier-to-debug exception with a clear errors message message explaining the
|
409
|
-
* problem. (Instead of a confusing exception thrown inside the implementation
|
410
|
-
* of the `value` object).
|
411
|
-
*/
|
412
|
-
// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
|
413
|
-
function typeName(value) {
|
414
|
-
{
|
415
|
-
// toStringTag is needed for namespaced types like Temporal.Instant
|
416
|
-
var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
|
417
|
-
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object'; // $FlowFixMe[incompatible-return]
|
418
|
-
|
419
|
-
return type;
|
420
|
-
}
|
421
|
-
} // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
|
422
|
-
|
423
|
-
|
424
|
-
function willCoercionThrow(value) {
|
425
|
-
{
|
426
|
-
try {
|
427
|
-
testStringCoercion(value);
|
428
|
-
return false;
|
429
|
-
} catch (e) {
|
430
|
-
return true;
|
431
|
-
}
|
432
|
-
}
|
433
|
-
}
|
434
|
-
|
435
|
-
function testStringCoercion(value) {
|
436
|
-
// If you ended up here by following an exception call stack, here's what's
|
437
|
-
// happened: you supplied an object or symbol value to React (as a prop, key,
|
438
|
-
// DOM attribute, CSS property, string ref, etc.) and when React tried to
|
439
|
-
// coerce it to a string using `'' + value`, an exception was thrown.
|
440
|
-
//
|
441
|
-
// The most common types that will cause this exception are `Symbol` instances
|
442
|
-
// and Temporal objects like `Temporal.Instant`. But any object that has a
|
443
|
-
// `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
|
444
|
-
// exception. (Library authors do this to prevent users from using built-in
|
445
|
-
// numeric operators like `+` or comparison operators like `>=` because custom
|
446
|
-
// methods are needed to perform accurate arithmetic or comparison.)
|
447
|
-
//
|
448
|
-
// To fix the problem, coerce this object or symbol value to a string before
|
449
|
-
// passing it to React. The most reliable way is usually `String(value)`.
|
450
|
-
//
|
451
|
-
// To find which value is throwing, check the browser or debugger console.
|
452
|
-
// Before this exception was thrown, there should be `console.error` output
|
453
|
-
// that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
|
454
|
-
// problem and how that type was used: key, atrribute, input value prop, etc.
|
455
|
-
// In most cases, this console output also shows the component and its
|
456
|
-
// ancestor components where the exception happened.
|
457
|
-
//
|
458
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
459
|
-
return '' + value;
|
460
|
-
}
|
461
|
-
function checkKeyStringCoercion(value) {
|
462
|
-
{
|
463
|
-
if (willCoercionThrow(value)) {
|
464
|
-
error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before using it here.', typeName(value));
|
465
|
-
|
466
|
-
return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
|
467
|
-
}
|
468
|
-
}
|
469
|
-
}
|
470
|
-
|
471
|
-
function getWrappedName(outerType, innerType, wrapperName) {
|
472
|
-
var displayName = outerType.displayName;
|
473
|
-
|
474
|
-
if (displayName) {
|
475
|
-
return displayName;
|
476
|
-
}
|
477
|
-
|
478
|
-
var functionName = innerType.displayName || innerType.name || '';
|
479
|
-
return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
|
480
|
-
} // Keep in sync with react-reconciler/getComponentNameFromFiber
|
481
|
-
|
482
|
-
|
483
|
-
function getContextName(type) {
|
484
|
-
return type.displayName || 'Context';
|
485
|
-
}
|
486
|
-
|
487
|
-
var REACT_CLIENT_REFERENCE$2 = Symbol.for('react.client.reference'); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
|
488
|
-
|
489
|
-
function getComponentNameFromType(type) {
|
490
|
-
if (type == null) {
|
491
|
-
// Host root, text node or just invalid type.
|
492
|
-
return null;
|
493
|
-
}
|
494
|
-
|
495
|
-
if (typeof type === 'function') {
|
496
|
-
if (type.$$typeof === REACT_CLIENT_REFERENCE$2) {
|
497
|
-
// TODO: Create a convention for naming client references with debug info.
|
498
|
-
return null;
|
499
|
-
}
|
500
|
-
|
501
|
-
return type.displayName || type.name || null;
|
502
|
-
}
|
503
|
-
|
504
|
-
if (typeof type === 'string') {
|
505
|
-
return type;
|
506
|
-
}
|
507
|
-
|
508
|
-
switch (type) {
|
509
|
-
case REACT_FRAGMENT_TYPE:
|
510
|
-
return 'Fragment';
|
511
|
-
|
512
|
-
case REACT_PORTAL_TYPE:
|
513
|
-
return 'Portal';
|
514
|
-
|
515
|
-
case REACT_PROFILER_TYPE:
|
516
|
-
return 'Profiler';
|
517
|
-
|
518
|
-
case REACT_STRICT_MODE_TYPE:
|
519
|
-
return 'StrictMode';
|
520
|
-
|
521
|
-
case REACT_SUSPENSE_TYPE:
|
522
|
-
return 'Suspense';
|
523
|
-
|
524
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
525
|
-
return 'SuspenseList';
|
526
|
-
|
527
|
-
}
|
528
|
-
|
529
|
-
if (typeof type === 'object') {
|
530
|
-
{
|
531
|
-
if (typeof type.tag === 'number') {
|
532
|
-
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
|
533
|
-
}
|
534
|
-
}
|
535
|
-
|
536
|
-
switch (type.$$typeof) {
|
537
|
-
case REACT_PROVIDER_TYPE:
|
538
|
-
{
|
539
|
-
return null;
|
540
|
-
}
|
541
|
-
|
542
|
-
case REACT_CONTEXT_TYPE:
|
543
|
-
var context = type;
|
544
|
-
|
545
|
-
{
|
546
|
-
return getContextName(context) + '.Provider';
|
547
|
-
}
|
548
|
-
|
549
|
-
case REACT_CONSUMER_TYPE:
|
550
|
-
{
|
551
|
-
var consumer = type;
|
552
|
-
return getContextName(consumer._context) + '.Consumer';
|
553
|
-
}
|
554
|
-
|
555
|
-
case REACT_FORWARD_REF_TYPE:
|
556
|
-
return getWrappedName(type, type.render, 'ForwardRef');
|
557
|
-
|
558
|
-
case REACT_MEMO_TYPE:
|
559
|
-
var outerName = type.displayName || null;
|
560
|
-
|
561
|
-
if (outerName !== null) {
|
562
|
-
return outerName;
|
563
|
-
}
|
564
|
-
|
565
|
-
return getComponentNameFromType(type.type) || 'Memo';
|
566
|
-
|
567
|
-
case REACT_LAZY_TYPE:
|
568
|
-
{
|
569
|
-
var lazyComponent = type;
|
570
|
-
var payload = lazyComponent._payload;
|
571
|
-
var init = lazyComponent._init;
|
572
|
-
|
573
|
-
try {
|
574
|
-
return getComponentNameFromType(init(payload));
|
575
|
-
} catch (x) {
|
576
|
-
return null;
|
577
|
-
}
|
578
|
-
}
|
579
|
-
}
|
580
|
-
}
|
581
|
-
|
582
|
-
return null;
|
583
|
-
}
|
584
|
-
|
585
|
-
// $FlowFixMe[method-unbinding]
|
586
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
587
|
-
|
588
|
-
var REACT_CLIENT_REFERENCE$1 = Symbol.for('react.client.reference');
|
589
|
-
function isValidElementType(type) {
|
590
|
-
if (typeof type === 'string' || typeof type === 'function') {
|
591
|
-
return true;
|
592
|
-
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
593
|
-
|
594
|
-
|
595
|
-
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableTransitionTracing ) {
|
596
|
-
return true;
|
597
|
-
}
|
598
|
-
|
599
|
-
if (typeof type === 'object' && type !== null) {
|
600
|
-
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || !enableRenderableContext || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
601
|
-
// types supported by any Flight configuration anywhere since
|
602
|
-
// we don't know which Flight build this will end up being used
|
603
|
-
// with.
|
604
|
-
type.$$typeof === REACT_CLIENT_REFERENCE$1 || type.getModuleId !== undefined) {
|
605
|
-
return true;
|
606
|
-
}
|
607
|
-
}
|
608
|
-
|
609
|
-
return false;
|
610
|
-
}
|
611
|
-
|
612
|
-
// Helpers to patch console.logs to avoid logging during side-effect free
|
613
|
-
// replaying on render function. This currently only patches the object
|
614
|
-
// lazily which won't cover if the log function was extracted eagerly.
|
615
|
-
// We could also eagerly patch the method.
|
616
|
-
var disabledDepth = 0;
|
617
|
-
var prevLog;
|
618
|
-
var prevInfo;
|
619
|
-
var prevWarn;
|
620
|
-
var prevError;
|
621
|
-
var prevGroup;
|
622
|
-
var prevGroupCollapsed;
|
623
|
-
var prevGroupEnd;
|
624
|
-
|
625
|
-
function disabledLog() {}
|
626
|
-
|
627
|
-
disabledLog.__reactDisabledLog = true;
|
628
|
-
function disableLogs() {
|
629
|
-
{
|
630
|
-
if (disabledDepth === 0) {
|
631
|
-
/* eslint-disable react-internal/no-production-logging */
|
632
|
-
prevLog = console.log;
|
633
|
-
prevInfo = console.info;
|
634
|
-
prevWarn = console.warn;
|
635
|
-
prevError = console.error;
|
636
|
-
prevGroup = console.group;
|
637
|
-
prevGroupCollapsed = console.groupCollapsed;
|
638
|
-
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
|
639
|
-
|
640
|
-
var props = {
|
641
|
-
configurable: true,
|
642
|
-
enumerable: true,
|
643
|
-
value: disabledLog,
|
644
|
-
writable: true
|
645
|
-
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
|
646
|
-
|
647
|
-
Object.defineProperties(console, {
|
648
|
-
info: props,
|
649
|
-
log: props,
|
650
|
-
warn: props,
|
651
|
-
error: props,
|
652
|
-
group: props,
|
653
|
-
groupCollapsed: props,
|
654
|
-
groupEnd: props
|
655
|
-
});
|
656
|
-
/* eslint-enable react-internal/no-production-logging */
|
657
|
-
}
|
658
|
-
|
659
|
-
disabledDepth++;
|
660
|
-
}
|
661
|
-
}
|
662
|
-
function reenableLogs() {
|
663
|
-
{
|
664
|
-
disabledDepth--;
|
665
|
-
|
666
|
-
if (disabledDepth === 0) {
|
667
|
-
/* eslint-disable react-internal/no-production-logging */
|
668
|
-
var props = {
|
669
|
-
configurable: true,
|
670
|
-
enumerable: true,
|
671
|
-
writable: true
|
672
|
-
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
|
673
|
-
|
674
|
-
Object.defineProperties(console, {
|
675
|
-
log: assign({}, props, {
|
676
|
-
value: prevLog
|
677
|
-
}),
|
678
|
-
info: assign({}, props, {
|
679
|
-
value: prevInfo
|
680
|
-
}),
|
681
|
-
warn: assign({}, props, {
|
682
|
-
value: prevWarn
|
683
|
-
}),
|
684
|
-
error: assign({}, props, {
|
685
|
-
value: prevError
|
686
|
-
}),
|
687
|
-
group: assign({}, props, {
|
688
|
-
value: prevGroup
|
689
|
-
}),
|
690
|
-
groupCollapsed: assign({}, props, {
|
691
|
-
value: prevGroupCollapsed
|
692
|
-
}),
|
693
|
-
groupEnd: assign({}, props, {
|
694
|
-
value: prevGroupEnd
|
695
|
-
})
|
696
|
-
});
|
697
|
-
/* eslint-enable react-internal/no-production-logging */
|
698
|
-
}
|
699
|
-
|
700
|
-
if (disabledDepth < 0) {
|
701
|
-
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
|
702
|
-
}
|
703
|
-
}
|
704
|
-
}
|
705
|
-
|
706
|
-
var prefix;
|
707
|
-
function describeBuiltInComponentFrame(name) {
|
708
|
-
{
|
709
|
-
if (prefix === undefined) {
|
710
|
-
// Extract the VM specific prefix used by each line.
|
711
|
-
try {
|
712
|
-
throw Error();
|
713
|
-
} catch (x) {
|
714
|
-
var match = x.stack.trim().match(/\n( *(at )?)/);
|
715
|
-
prefix = match && match[1] || '';
|
716
|
-
}
|
717
|
-
} // We use the prefix to ensure our stacks line up with native stack frames.
|
718
|
-
|
719
|
-
|
720
|
-
return '\n' + prefix + name;
|
721
|
-
}
|
722
|
-
}
|
723
|
-
var reentry = false;
|
724
|
-
var componentFrameCache;
|
725
|
-
|
726
|
-
{
|
727
|
-
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
|
728
|
-
componentFrameCache = new PossiblyWeakMap();
|
729
|
-
}
|
730
|
-
/**
|
731
|
-
* Leverages native browser/VM stack frames to get proper details (e.g.
|
732
|
-
* filename, line + col number) for a single component in a component stack. We
|
733
|
-
* do this by:
|
734
|
-
* (1) throwing and catching an error in the function - this will be our
|
735
|
-
* control error.
|
736
|
-
* (2) calling the component which will eventually throw an error that we'll
|
737
|
-
* catch - this will be our sample error.
|
738
|
-
* (3) diffing the control and sample error stacks to find the stack frame
|
739
|
-
* which represents our component.
|
740
|
-
*/
|
741
|
-
|
742
|
-
|
743
|
-
function describeNativeComponentFrame(fn, construct) {
|
744
|
-
// If something asked for a stack inside a fake render, it should get ignored.
|
745
|
-
if (!fn || reentry) {
|
746
|
-
return '';
|
747
|
-
}
|
748
|
-
|
749
|
-
{
|
750
|
-
var frame = componentFrameCache.get(fn);
|
751
|
-
|
752
|
-
if (frame !== undefined) {
|
753
|
-
return frame;
|
754
|
-
}
|
755
|
-
}
|
756
|
-
|
757
|
-
reentry = true;
|
758
|
-
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined.
|
759
|
-
|
760
|
-
Error.prepareStackTrace = undefined;
|
761
|
-
var previousDispatcher = null;
|
762
|
-
|
763
|
-
{
|
764
|
-
previousDispatcher = ReactSharedInternals$1.H; // Set the dispatcher in DEV because this might be call in the render function
|
765
|
-
// for warnings.
|
766
|
-
|
767
|
-
ReactSharedInternals$1.H = null;
|
768
|
-
disableLogs();
|
769
|
-
}
|
770
|
-
/**
|
771
|
-
* Finding a common stack frame between sample and control errors can be
|
772
|
-
* tricky given the different types and levels of stack trace truncation from
|
773
|
-
* different JS VMs. So instead we'll attempt to control what that common
|
774
|
-
* frame should be through this object method:
|
775
|
-
* Having both the sample and control errors be in the function under the
|
776
|
-
* `DescribeNativeComponentFrameRoot` property, + setting the `name` and
|
777
|
-
* `displayName` properties of the function ensures that a stack
|
778
|
-
* frame exists that has the method name `DescribeNativeComponentFrameRoot` in
|
779
|
-
* it for both control and sample stacks.
|
780
|
-
*/
|
781
|
-
|
782
|
-
|
783
|
-
var RunInRootFrame = {
|
784
|
-
DetermineComponentFrameRoot: function () {
|
785
|
-
var control;
|
786
|
-
|
787
|
-
try {
|
788
|
-
// This should throw.
|
789
|
-
if (construct) {
|
790
|
-
// Something should be setting the props in the constructor.
|
791
|
-
var Fake = function () {
|
792
|
-
throw Error();
|
793
|
-
}; // $FlowFixMe[prop-missing]
|
794
|
-
|
795
|
-
|
796
|
-
Object.defineProperty(Fake.prototype, 'props', {
|
797
|
-
set: function () {
|
798
|
-
// We use a throwing setter instead of frozen or non-writable props
|
799
|
-
// because that won't throw in a non-strict mode function.
|
800
|
-
throw Error();
|
801
|
-
}
|
802
|
-
});
|
803
|
-
|
804
|
-
if (typeof Reflect === 'object' && Reflect.construct) {
|
805
|
-
// We construct a different control for this case to include any extra
|
806
|
-
// frames added by the construct call.
|
807
|
-
try {
|
808
|
-
Reflect.construct(Fake, []);
|
809
|
-
} catch (x) {
|
810
|
-
control = x;
|
811
|
-
}
|
812
|
-
|
813
|
-
Reflect.construct(fn, [], Fake);
|
814
|
-
} else {
|
815
|
-
try {
|
816
|
-
Fake.call();
|
817
|
-
} catch (x) {
|
818
|
-
control = x;
|
819
|
-
} // $FlowFixMe[prop-missing] found when upgrading Flow
|
820
|
-
|
821
|
-
|
822
|
-
fn.call(Fake.prototype);
|
823
|
-
}
|
824
|
-
} else {
|
825
|
-
try {
|
826
|
-
throw Error();
|
827
|
-
} catch (x) {
|
828
|
-
control = x;
|
829
|
-
} // TODO(luna): This will currently only throw if the function component
|
830
|
-
// tries to access React/ReactDOM/props. We should probably make this throw
|
831
|
-
// in simple components too
|
832
|
-
|
833
|
-
|
834
|
-
var maybePromise = fn(); // If the function component returns a promise, it's likely an async
|
835
|
-
// component, which we don't yet support. Attach a noop catch handler to
|
836
|
-
// silence the error.
|
837
|
-
// TODO: Implement component stacks for async client components?
|
838
|
-
|
839
|
-
if (maybePromise && typeof maybePromise.catch === 'function') {
|
840
|
-
maybePromise.catch(function () {});
|
841
|
-
}
|
842
|
-
}
|
843
|
-
} catch (sample) {
|
844
|
-
// This is inlined manually because closure doesn't do it for us.
|
845
|
-
if (sample && control && typeof sample.stack === 'string') {
|
846
|
-
return [sample.stack, control.stack];
|
847
|
-
}
|
848
|
-
}
|
849
|
-
|
850
|
-
return [null, null];
|
851
|
-
}
|
852
|
-
}; // $FlowFixMe[prop-missing]
|
853
|
-
|
854
|
-
RunInRootFrame.DetermineComponentFrameRoot.displayName = 'DetermineComponentFrameRoot';
|
855
|
-
var namePropDescriptor = Object.getOwnPropertyDescriptor(RunInRootFrame.DetermineComponentFrameRoot, 'name'); // Before ES6, the `name` property was not configurable.
|
856
|
-
|
857
|
-
if (namePropDescriptor && namePropDescriptor.configurable) {
|
858
|
-
// V8 utilizes a function's `name` property when generating a stack trace.
|
859
|
-
Object.defineProperty(RunInRootFrame.DetermineComponentFrameRoot, // Configurable properties can be updated even if its writable descriptor
|
860
|
-
// is set to `false`.
|
861
|
-
// $FlowFixMe[cannot-write]
|
862
|
-
'name', {
|
863
|
-
value: 'DetermineComponentFrameRoot'
|
864
|
-
});
|
865
|
-
}
|
866
|
-
|
867
|
-
try {
|
868
|
-
var _RunInRootFrame$Deter = RunInRootFrame.DetermineComponentFrameRoot(),
|
869
|
-
sampleStack = _RunInRootFrame$Deter[0],
|
870
|
-
controlStack = _RunInRootFrame$Deter[1];
|
871
|
-
|
872
|
-
if (sampleStack && controlStack) {
|
873
|
-
// This extracts the first frame from the sample that isn't also in the control.
|
874
|
-
// Skipping one frame that we assume is the frame that calls the two.
|
875
|
-
var sampleLines = sampleStack.split('\n');
|
876
|
-
var controlLines = controlStack.split('\n');
|
877
|
-
var s = 0;
|
878
|
-
var c = 0;
|
879
|
-
|
880
|
-
while (s < sampleLines.length && !sampleLines[s].includes('DetermineComponentFrameRoot')) {
|
881
|
-
s++;
|
882
|
-
}
|
883
|
-
|
884
|
-
while (c < controlLines.length && !controlLines[c].includes('DetermineComponentFrameRoot')) {
|
885
|
-
c++;
|
886
|
-
} // We couldn't find our intentionally injected common root frame, attempt
|
887
|
-
// to find another common root frame by search from the bottom of the
|
888
|
-
// control stack...
|
889
|
-
|
890
|
-
|
891
|
-
if (s === sampleLines.length || c === controlLines.length) {
|
892
|
-
s = sampleLines.length - 1;
|
893
|
-
c = controlLines.length - 1;
|
894
|
-
|
895
|
-
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
896
|
-
// We expect at least one stack frame to be shared.
|
897
|
-
// Typically this will be the root most one. However, stack frames may be
|
898
|
-
// cut off due to maximum stack limits. In this case, one maybe cut off
|
899
|
-
// earlier than the other. We assume that the sample is longer or the same
|
900
|
-
// and there for cut off earlier. So we should find the root most frame in
|
901
|
-
// the sample somewhere in the control.
|
902
|
-
c--;
|
903
|
-
}
|
904
|
-
}
|
905
|
-
|
906
|
-
for (; s >= 1 && c >= 0; s--, c--) {
|
907
|
-
// Next we find the first one that isn't the same which should be the
|
908
|
-
// frame that called our sample function and the control.
|
909
|
-
if (sampleLines[s] !== controlLines[c]) {
|
910
|
-
// In V8, the first line is describing the message but other VMs don't.
|
911
|
-
// If we're about to return the first line, and the control is also on the same
|
912
|
-
// line, that's a pretty good indicator that our sample threw at same line as
|
913
|
-
// the control. I.e. before we entered the sample frame. So we ignore this result.
|
914
|
-
// This can happen if you passed a class to function component, or non-function.
|
915
|
-
if (s !== 1 || c !== 1) {
|
916
|
-
do {
|
917
|
-
s--;
|
918
|
-
c--; // We may still have similar intermediate frames from the construct call.
|
919
|
-
// The next one that isn't the same should be our match though.
|
920
|
-
|
921
|
-
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
922
|
-
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
|
923
|
-
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
|
924
|
-
// but we have a user-provided "displayName"
|
925
|
-
// splice it in to make the stack more readable.
|
926
|
-
|
927
|
-
|
928
|
-
if (fn.displayName && _frame.includes('<anonymous>')) {
|
929
|
-
_frame = _frame.replace('<anonymous>', fn.displayName);
|
930
|
-
}
|
931
|
-
|
932
|
-
if (true) {
|
933
|
-
if (typeof fn === 'function') {
|
934
|
-
componentFrameCache.set(fn, _frame);
|
935
|
-
}
|
936
|
-
} // Return the line we found.
|
937
|
-
|
938
|
-
|
939
|
-
return _frame;
|
940
|
-
}
|
941
|
-
} while (s >= 1 && c >= 0);
|
942
|
-
}
|
943
|
-
|
944
|
-
break;
|
945
|
-
}
|
946
|
-
}
|
947
|
-
}
|
948
|
-
} finally {
|
949
|
-
reentry = false;
|
950
|
-
|
951
|
-
{
|
952
|
-
ReactSharedInternals$1.H = previousDispatcher;
|
953
|
-
reenableLogs();
|
954
|
-
}
|
955
|
-
|
956
|
-
Error.prepareStackTrace = previousPrepareStackTrace;
|
957
|
-
} // Fallback to just using the name if we couldn't make it throw.
|
958
|
-
|
959
|
-
|
960
|
-
var name = fn ? fn.displayName || fn.name : '';
|
961
|
-
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
|
962
|
-
|
963
|
-
{
|
964
|
-
if (typeof fn === 'function') {
|
965
|
-
componentFrameCache.set(fn, syntheticFrame);
|
966
|
-
}
|
967
|
-
}
|
968
|
-
|
969
|
-
return syntheticFrame;
|
970
|
-
}
|
971
|
-
function describeFunctionComponentFrame(fn) {
|
972
|
-
{
|
973
|
-
return describeNativeComponentFrame(fn, false);
|
974
|
-
}
|
975
|
-
}
|
976
|
-
|
977
|
-
function shouldConstruct(Component) {
|
978
|
-
var prototype = Component.prototype;
|
979
|
-
return !!(prototype && prototype.isReactComponent);
|
980
|
-
}
|
981
|
-
|
982
|
-
function describeUnknownElementTypeFrameInDEV(type) {
|
983
|
-
|
984
|
-
if (type == null) {
|
985
|
-
return '';
|
986
|
-
}
|
987
|
-
|
988
|
-
if (typeof type === 'function') {
|
989
|
-
{
|
990
|
-
return describeNativeComponentFrame(type, shouldConstruct(type));
|
991
|
-
}
|
992
|
-
}
|
993
|
-
|
994
|
-
if (typeof type === 'string') {
|
995
|
-
return describeBuiltInComponentFrame(type);
|
996
|
-
}
|
997
|
-
|
998
|
-
switch (type) {
|
999
|
-
case REACT_SUSPENSE_TYPE:
|
1000
|
-
return describeBuiltInComponentFrame('Suspense');
|
1001
|
-
|
1002
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
1003
|
-
return describeBuiltInComponentFrame('SuspenseList');
|
1004
|
-
}
|
1005
|
-
|
1006
|
-
if (typeof type === 'object') {
|
1007
|
-
switch (type.$$typeof) {
|
1008
|
-
case REACT_FORWARD_REF_TYPE:
|
1009
|
-
return describeFunctionComponentFrame(type.render);
|
1010
|
-
|
1011
|
-
case REACT_MEMO_TYPE:
|
1012
|
-
// Memo may contain any component type so we recursively resolve it.
|
1013
|
-
return describeUnknownElementTypeFrameInDEV(type.type);
|
1014
|
-
|
1015
|
-
case REACT_LAZY_TYPE:
|
1016
|
-
{
|
1017
|
-
var lazyComponent = type;
|
1018
|
-
var payload = lazyComponent._payload;
|
1019
|
-
var init = lazyComponent._init;
|
1020
|
-
|
1021
|
-
try {
|
1022
|
-
// Lazy may contain any component type so we recursively resolve it.
|
1023
|
-
return describeUnknownElementTypeFrameInDEV(init(payload));
|
1024
|
-
} catch (x) {}
|
1025
|
-
}
|
1026
|
-
}
|
1027
|
-
}
|
1028
|
-
|
1029
|
-
return '';
|
1030
|
-
}
|
1031
|
-
|
1032
|
-
var REACT_CLIENT_REFERENCE = Symbol.for('react.client.reference');
|
1033
|
-
var specialPropKeyWarningShown;
|
1034
|
-
var didWarnAboutElementRef;
|
1035
|
-
var didWarnAboutOldJSXRuntime;
|
1036
|
-
|
1037
|
-
{
|
1038
|
-
didWarnAboutElementRef = {};
|
1039
|
-
}
|
1040
|
-
|
1041
|
-
function hasValidRef(config) {
|
1042
|
-
{
|
1043
|
-
if (hasOwnProperty.call(config, 'ref')) {
|
1044
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
1045
|
-
|
1046
|
-
if (getter && getter.isReactWarning) {
|
1047
|
-
return false;
|
1048
|
-
}
|
1049
|
-
}
|
1050
|
-
}
|
1051
|
-
|
1052
|
-
return config.ref !== undefined;
|
1053
|
-
}
|
1054
|
-
|
1055
|
-
function hasValidKey(config) {
|
1056
|
-
{
|
1057
|
-
if (hasOwnProperty.call(config, 'key')) {
|
1058
|
-
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
1059
|
-
|
1060
|
-
if (getter && getter.isReactWarning) {
|
1061
|
-
return false;
|
1062
|
-
}
|
1063
|
-
}
|
1064
|
-
}
|
1065
|
-
|
1066
|
-
return config.key !== undefined;
|
1067
|
-
}
|
1068
|
-
|
1069
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
1070
|
-
{
|
1071
|
-
var warnAboutAccessingKey = function () {
|
1072
|
-
if (!specialPropKeyWarningShown) {
|
1073
|
-
specialPropKeyWarningShown = true;
|
1074
|
-
|
1075
|
-
error('%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://react.dev/link/special-props)', displayName);
|
1076
|
-
}
|
1077
|
-
};
|
1078
|
-
|
1079
|
-
warnAboutAccessingKey.isReactWarning = true;
|
1080
|
-
Object.defineProperty(props, 'key', {
|
1081
|
-
get: warnAboutAccessingKey,
|
1082
|
-
configurable: true
|
1083
|
-
});
|
1084
|
-
}
|
1085
|
-
}
|
1086
|
-
|
1087
|
-
function elementRefGetterWithDeprecationWarning() {
|
1088
|
-
{
|
1089
|
-
var componentName = getComponentNameFromType(this.type);
|
1090
|
-
|
1091
|
-
if (!didWarnAboutElementRef[componentName]) {
|
1092
|
-
didWarnAboutElementRef[componentName] = true;
|
1093
|
-
|
1094
|
-
error('Accessing element.ref was removed in React 19. ref is now a ' + 'regular prop. It will be removed from the JSX Element ' + 'type in a future release.');
|
1095
|
-
} // An undefined `element.ref` is coerced to `null` for
|
1096
|
-
// backwards compatibility.
|
1097
|
-
|
1098
|
-
|
1099
|
-
var refProp = this.props.ref;
|
1100
|
-
return refProp !== undefined ? refProp : null;
|
1101
|
-
}
|
1102
|
-
}
|
1103
|
-
/**
|
1104
|
-
* Factory method to create a new React element. This no longer adheres to
|
1105
|
-
* the class pattern, so do not use new to call it. Also, instanceof check
|
1106
|
-
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
1107
|
-
* if something is a React Element.
|
1108
|
-
*
|
1109
|
-
* @param {*} type
|
1110
|
-
* @param {*} props
|
1111
|
-
* @param {*} key
|
1112
|
-
* @param {string|object} ref
|
1113
|
-
* @param {*} owner
|
1114
|
-
* @param {*} self A *temporary* helper to detect places where `this` is
|
1115
|
-
* different from the `owner` when React.createElement is called, so that we
|
1116
|
-
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
1117
|
-
* functions, and as long as `this` and owner are the same, there will be no
|
1118
|
-
* change in behavior.
|
1119
|
-
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
1120
|
-
* indicating filename, line number, and/or other information.
|
1121
|
-
* @internal
|
1122
|
-
*/
|
1123
|
-
|
1124
|
-
|
1125
|
-
function ReactElement(type, key, _ref, self, source, owner, props) {
|
1126
|
-
var ref;
|
1127
|
-
|
1128
|
-
{
|
1129
|
-
// When enableRefAsProp is on, ignore whatever was passed as the ref
|
1130
|
-
// argument and treat `props.ref` as the source of truth. The only thing we
|
1131
|
-
// use this for is `element.ref`, which will log a deprecation warning on
|
1132
|
-
// access. In the next release, we can remove `element.ref` as well as the
|
1133
|
-
// `ref` argument.
|
1134
|
-
var refProp = props.ref; // An undefined `element.ref` is coerced to `null` for
|
1135
|
-
// backwards compatibility.
|
1136
|
-
|
1137
|
-
ref = refProp !== undefined ? refProp : null;
|
1138
|
-
}
|
1139
|
-
|
1140
|
-
var element;
|
1141
|
-
|
1142
|
-
{
|
1143
|
-
// In dev, make `ref` a non-enumerable property with a warning. It's non-
|
1144
|
-
// enumerable so that test matchers and serializers don't access it and
|
1145
|
-
// trigger the warning.
|
1146
|
-
//
|
1147
|
-
// `ref` will be removed from the element completely in a future release.
|
1148
|
-
element = {
|
1149
|
-
// This tag allows us to uniquely identify this as a React Element
|
1150
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
1151
|
-
// Built-in properties that belong on the element
|
1152
|
-
type: type,
|
1153
|
-
key: key,
|
1154
|
-
props: props,
|
1155
|
-
// Record the component responsible for creating this element.
|
1156
|
-
_owner: owner
|
1157
|
-
};
|
1158
|
-
|
1159
|
-
if (ref !== null) {
|
1160
|
-
Object.defineProperty(element, 'ref', {
|
1161
|
-
enumerable: false,
|
1162
|
-
get: elementRefGetterWithDeprecationWarning
|
1163
|
-
});
|
1164
|
-
} else {
|
1165
|
-
// Don't warn on access if a ref is not given. This reduces false
|
1166
|
-
// positives in cases where a test serializer uses
|
1167
|
-
// getOwnPropertyDescriptors to compare objects, like Jest does, which is
|
1168
|
-
// a problem because it bypasses non-enumerability.
|
1169
|
-
//
|
1170
|
-
// So unfortunately this will trigger a false positive warning in Jest
|
1171
|
-
// when the diff is printed:
|
1172
|
-
//
|
1173
|
-
// expect(<div ref={ref} />).toEqual(<span ref={ref} />);
|
1174
|
-
//
|
1175
|
-
// A bit sketchy, but this is what we've done for the `props.key` and
|
1176
|
-
// `props.ref` accessors for years, which implies it will be good enough
|
1177
|
-
// for `element.ref`, too. Let's see if anyone complains.
|
1178
|
-
Object.defineProperty(element, 'ref', {
|
1179
|
-
enumerable: false,
|
1180
|
-
value: null
|
1181
|
-
});
|
1182
|
-
}
|
1183
|
-
}
|
1184
|
-
|
1185
|
-
{
|
1186
|
-
// The validation flag is currently mutative. We put it on
|
1187
|
-
// an external backing store so that we can freeze the whole object.
|
1188
|
-
// This can be replaced with a WeakMap once they are implemented in
|
1189
|
-
// commonly used development environments.
|
1190
|
-
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
1191
|
-
// the validation flag non-enumerable (where possible, which should
|
1192
|
-
// include every environment we run tests in), so the test framework
|
1193
|
-
// ignores it.
|
1194
|
-
|
1195
|
-
Object.defineProperty(element._store, 'validated', {
|
1196
|
-
configurable: false,
|
1197
|
-
enumerable: false,
|
1198
|
-
writable: true,
|
1199
|
-
value: false
|
1200
|
-
}); // debugInfo contains Server Component debug information.
|
1201
|
-
|
1202
|
-
Object.defineProperty(element, '_debugInfo', {
|
1203
|
-
configurable: false,
|
1204
|
-
enumerable: false,
|
1205
|
-
writable: true,
|
1206
|
-
value: null
|
1207
|
-
});
|
1208
|
-
|
1209
|
-
if (Object.freeze) {
|
1210
|
-
Object.freeze(element.props);
|
1211
|
-
Object.freeze(element);
|
1212
|
-
}
|
1213
|
-
}
|
1214
|
-
|
1215
|
-
return element;
|
1216
|
-
}
|
1217
|
-
/**
|
1218
|
-
* Create and return a new ReactElement of the given type.
|
1219
|
-
* See https://reactjs.org/docs/react-api.html#createelement
|
1220
|
-
*/
|
1221
|
-
|
1222
|
-
function createElement(type, config, children) {
|
1223
|
-
{
|
1224
|
-
if (!isValidElementType(type)) {
|
1225
|
-
// This is an invalid element type.
|
1226
|
-
//
|
1227
|
-
// We warn in this case but don't throw. We expect the element creation to
|
1228
|
-
// succeed and there will likely be errors in render.
|
1229
|
-
var info = '';
|
1230
|
-
|
1231
|
-
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
1232
|
-
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.";
|
1233
|
-
}
|
1234
|
-
|
1235
|
-
var typeString;
|
1236
|
-
|
1237
|
-
if (type === null) {
|
1238
|
-
typeString = 'null';
|
1239
|
-
} else if (isArray(type)) {
|
1240
|
-
typeString = 'array';
|
1241
|
-
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
1242
|
-
typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
|
1243
|
-
info = ' Did you accidentally export a JSX literal instead of a component?';
|
1244
|
-
} else {
|
1245
|
-
typeString = typeof type;
|
1246
|
-
}
|
1247
|
-
|
1248
|
-
error('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);
|
1249
|
-
} else {
|
1250
|
-
// This is a valid element type.
|
1251
|
-
// Skip key warning if the type isn't valid since our key validation logic
|
1252
|
-
// doesn't expect a non-string/function type and can throw confusing
|
1253
|
-
// errors. We don't want exception behavior to differ between dev and
|
1254
|
-
// prod. (Rendering will throw with a helpful message and as soon as the
|
1255
|
-
// type is fixed, the key warnings will appear.)
|
1256
|
-
for (var i = 2; i < arguments.length; i++) {
|
1257
|
-
validateChildKeys(arguments[i], type);
|
1258
|
-
}
|
1259
|
-
} // Unlike the jsx() runtime, createElement() doesn't warn about key spread.
|
1260
|
-
|
1261
|
-
}
|
1262
|
-
|
1263
|
-
var propName; // Reserved names are extracted
|
1264
|
-
|
1265
|
-
var props = {};
|
1266
|
-
var key = null;
|
1267
|
-
var ref = null;
|
1268
|
-
|
1269
|
-
if (config != null) {
|
1270
|
-
{
|
1271
|
-
if (!didWarnAboutOldJSXRuntime && '__self' in config && // Do not assume this is the result of an oudated JSX transform if key
|
1272
|
-
// is present, because the modern JSX transform sometimes outputs
|
1273
|
-
// createElement to preserve precedence between a static key and a
|
1274
|
-
// spread key. To avoid false positive warnings, we never warn if
|
1275
|
-
// there's a key.
|
1276
|
-
!('key' in config)) {
|
1277
|
-
didWarnAboutOldJSXRuntime = true;
|
1278
|
-
|
1279
|
-
warn('Your app (or one of its dependencies) is using an outdated JSX ' + 'transform. Update to the modern JSX transform for ' + 'faster performance: ' + // TODO: Create a short link for this
|
1280
|
-
'https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html');
|
1281
|
-
}
|
1282
|
-
}
|
1283
|
-
|
1284
|
-
if (hasValidRef(config)) ;
|
1285
|
-
|
1286
|
-
if (hasValidKey(config)) {
|
1287
|
-
{
|
1288
|
-
checkKeyStringCoercion(config.key);
|
1289
|
-
}
|
1290
|
-
|
1291
|
-
key = '' + config.key;
|
1292
|
-
} // Remaining properties are added to a new props object
|
1293
|
-
|
1294
|
-
|
1295
|
-
for (propName in config) {
|
1296
|
-
if (hasOwnProperty.call(config, propName) && // Skip over reserved prop names
|
1297
|
-
propName !== 'key' && (enableRefAsProp ) && // Even though we don't use these anymore in the runtime, we don't want
|
1298
|
-
// them to appear as props, so in createElement we filter them out.
|
1299
|
-
// We don't have to do this in the jsx() runtime because the jsx()
|
1300
|
-
// transform never passed these as props; it used separate arguments.
|
1301
|
-
propName !== '__self' && propName !== '__source') {
|
1302
|
-
{
|
1303
|
-
props[propName] = config[propName];
|
1304
|
-
}
|
1305
|
-
}
|
1306
|
-
}
|
1307
|
-
} // Children can be more than one argument, and those are transferred onto
|
1308
|
-
// the newly allocated props object.
|
1309
|
-
|
1310
|
-
|
1311
|
-
var childrenLength = arguments.length - 2;
|
1312
|
-
|
1313
|
-
if (childrenLength === 1) {
|
1314
|
-
props.children = children;
|
1315
|
-
} else if (childrenLength > 1) {
|
1316
|
-
var childArray = Array(childrenLength);
|
1317
|
-
|
1318
|
-
for (var _i = 0; _i < childrenLength; _i++) {
|
1319
|
-
childArray[_i] = arguments[_i + 2];
|
1320
|
-
}
|
1321
|
-
|
1322
|
-
{
|
1323
|
-
if (Object.freeze) {
|
1324
|
-
Object.freeze(childArray);
|
1325
|
-
}
|
1326
|
-
}
|
1327
|
-
|
1328
|
-
props.children = childArray;
|
1329
|
-
} // Resolve default props
|
1330
|
-
|
1331
|
-
|
1332
|
-
if (type && type.defaultProps) {
|
1333
|
-
var defaultProps = type.defaultProps;
|
1334
|
-
|
1335
|
-
for (propName in defaultProps) {
|
1336
|
-
if (props[propName] === undefined) {
|
1337
|
-
props[propName] = defaultProps[propName];
|
1338
|
-
}
|
1339
|
-
}
|
1340
|
-
}
|
1341
|
-
|
1342
|
-
{
|
1343
|
-
if (key || !enableRefAsProp ) {
|
1344
|
-
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
1345
|
-
|
1346
|
-
if (key) {
|
1347
|
-
defineKeyPropWarningGetter(props, displayName);
|
1348
|
-
}
|
1349
|
-
}
|
1350
|
-
}
|
1351
|
-
|
1352
|
-
var element = ReactElement(type, key, ref, undefined, undefined, ReactSharedInternals$1.owner, props);
|
1353
|
-
|
1354
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
1355
|
-
validateFragmentProps(element);
|
1356
|
-
}
|
1357
|
-
|
1358
|
-
return element;
|
1359
|
-
}
|
1360
|
-
function cloneAndReplaceKey(oldElement, newKey) {
|
1361
|
-
return ReactElement(oldElement.type, newKey, // When enableRefAsProp is on, this argument is ignored. This check only
|
1362
|
-
// exists to avoid the `ref` access warning.
|
1363
|
-
null , undefined, undefined, oldElement._owner, oldElement.props);
|
1364
|
-
}
|
1365
|
-
/**
|
1366
|
-
* Clone and return a new ReactElement using element as the starting point.
|
1367
|
-
* See https://reactjs.org/docs/react-api.html#cloneelement
|
1368
|
-
*/
|
1369
|
-
|
1370
|
-
function cloneElement(element, config, children) {
|
1371
|
-
if (element === null || element === undefined) {
|
1372
|
-
throw new Error("The argument must be a React element, but you passed " + element + ".");
|
1373
|
-
}
|
1374
|
-
|
1375
|
-
var propName; // Original props are copied
|
1376
|
-
|
1377
|
-
var props = assign({}, element.props); // Reserved names are extracted
|
1378
|
-
|
1379
|
-
var key = element.key;
|
1380
|
-
var ref = null ; // Owner will be preserved, unless ref is overridden
|
1381
|
-
|
1382
|
-
var owner = element._owner;
|
1383
|
-
|
1384
|
-
if (config != null) {
|
1385
|
-
if (hasValidRef(config)) {
|
1386
|
-
owner = ReactSharedInternals$1.owner;
|
1387
|
-
}
|
1388
|
-
|
1389
|
-
if (hasValidKey(config)) {
|
1390
|
-
{
|
1391
|
-
checkKeyStringCoercion(config.key);
|
1392
|
-
}
|
1393
|
-
|
1394
|
-
key = '' + config.key;
|
1395
|
-
} // Remaining properties override existing props
|
1396
|
-
|
1397
|
-
for (propName in config) {
|
1398
|
-
if (hasOwnProperty.call(config, propName) && // Skip over reserved prop names
|
1399
|
-
propName !== 'key' && (enableRefAsProp ) && // ...and maybe these, too, though we currently rely on them for
|
1400
|
-
// warnings and debug information in dev. Need to decide if we're OK
|
1401
|
-
// with dropping them. In the jsx() runtime it's not an issue because
|
1402
|
-
// the data gets passed as separate arguments instead of props, but
|
1403
|
-
// it would be nice to stop relying on them entirely so we can drop
|
1404
|
-
// them from the internal Fiber field.
|
1405
|
-
propName !== '__self' && propName !== '__source' && // Undefined `ref` is ignored by cloneElement. We treat it the same as
|
1406
|
-
// if the property were missing. This is mostly for
|
1407
|
-
// backwards compatibility.
|
1408
|
-
!(propName === 'ref' && config.ref === undefined)) {
|
1409
|
-
{
|
1410
|
-
{
|
1411
|
-
props[propName] = config[propName];
|
1412
|
-
}
|
1413
|
-
}
|
1414
|
-
}
|
1415
|
-
}
|
1416
|
-
} // Children can be more than one argument, and those are transferred onto
|
1417
|
-
// the newly allocated props object.
|
1418
|
-
|
1419
|
-
|
1420
|
-
var childrenLength = arguments.length - 2;
|
1421
|
-
|
1422
|
-
if (childrenLength === 1) {
|
1423
|
-
props.children = children;
|
1424
|
-
} else if (childrenLength > 1) {
|
1425
|
-
var childArray = Array(childrenLength);
|
1426
|
-
|
1427
|
-
for (var i = 0; i < childrenLength; i++) {
|
1428
|
-
childArray[i] = arguments[i + 2];
|
1429
|
-
}
|
1430
|
-
|
1431
|
-
props.children = childArray;
|
1432
|
-
}
|
1433
|
-
|
1434
|
-
var clonedElement = ReactElement(element.type, key, ref, undefined, undefined, owner, props);
|
1435
|
-
|
1436
|
-
for (var _i2 = 2; _i2 < arguments.length; _i2++) {
|
1437
|
-
validateChildKeys(arguments[_i2], clonedElement.type);
|
1438
|
-
}
|
1439
|
-
|
1440
|
-
return clonedElement;
|
1441
|
-
}
|
1442
|
-
|
1443
|
-
function getDeclarationErrorAddendum() {
|
1444
|
-
{
|
1445
|
-
if (ReactSharedInternals$1.owner) {
|
1446
|
-
var name = getComponentNameFromType(ReactSharedInternals$1.owner.type);
|
1447
|
-
|
1448
|
-
if (name) {
|
1449
|
-
return '\n\nCheck the render method of `' + name + '`.';
|
1450
|
-
}
|
1451
|
-
}
|
1452
|
-
|
1453
|
-
return '';
|
1454
|
-
}
|
1455
|
-
}
|
1456
|
-
/**
|
1457
|
-
* Ensure that every element either is passed in a static location, in an
|
1458
|
-
* array with an explicit keys property defined, or in an object literal
|
1459
|
-
* with valid key property.
|
1460
|
-
*
|
1461
|
-
* @internal
|
1462
|
-
* @param {ReactNode} node Statically passed child of any type.
|
1463
|
-
* @param {*} parentType node's parent's type.
|
1464
|
-
*/
|
1465
|
-
|
1466
|
-
|
1467
|
-
function validateChildKeys(node, parentType) {
|
1468
|
-
{
|
1469
|
-
if (typeof node !== 'object' || !node) {
|
1470
|
-
return;
|
1471
|
-
}
|
1472
|
-
|
1473
|
-
if (node.$$typeof === REACT_CLIENT_REFERENCE) ; else if (isArray(node)) {
|
1474
|
-
for (var i = 0; i < node.length; i++) {
|
1475
|
-
var child = node[i];
|
1476
|
-
|
1477
|
-
if (isValidElement(child)) {
|
1478
|
-
validateExplicitKey(child, parentType);
|
1479
|
-
}
|
1480
|
-
}
|
1481
|
-
} else if (isValidElement(node)) {
|
1482
|
-
// This element was passed in a valid location.
|
1483
|
-
if (node._store) {
|
1484
|
-
node._store.validated = true;
|
1485
|
-
}
|
1486
|
-
} else {
|
1487
|
-
var iteratorFn = getIteratorFn(node);
|
1488
|
-
|
1489
|
-
if (typeof iteratorFn === 'function') {
|
1490
|
-
// Entry iterators used to provide implicit keys,
|
1491
|
-
// but now we print a separate warning for them later.
|
1492
|
-
if (iteratorFn !== node.entries) {
|
1493
|
-
var iterator = iteratorFn.call(node);
|
1494
|
-
var step;
|
1495
|
-
|
1496
|
-
while (!(step = iterator.next()).done) {
|
1497
|
-
if (isValidElement(step.value)) {
|
1498
|
-
validateExplicitKey(step.value, parentType);
|
1499
|
-
}
|
1500
|
-
}
|
1501
|
-
}
|
1502
|
-
}
|
1503
|
-
}
|
1504
|
-
}
|
1505
|
-
}
|
1506
|
-
/**
|
1507
|
-
* Verifies the object is a ReactElement.
|
1508
|
-
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
1509
|
-
* @param {?object} object
|
1510
|
-
* @return {boolean} True if `object` is a ReactElement.
|
1511
|
-
* @final
|
1512
|
-
*/
|
1513
|
-
|
1514
|
-
|
1515
|
-
function isValidElement(object) {
|
1516
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
1517
|
-
}
|
1518
|
-
var ownerHasKeyUseWarning = {};
|
1519
|
-
/**
|
1520
|
-
* Warn if the element doesn't have an explicit key assigned to it.
|
1521
|
-
* This element is in an array. The array could grow and shrink or be
|
1522
|
-
* reordered. All children that haven't already been validated are required to
|
1523
|
-
* have a "key" property assigned to it. Error statuses are cached so a warning
|
1524
|
-
* will only be shown once.
|
1525
|
-
*
|
1526
|
-
* @internal
|
1527
|
-
* @param {ReactElement} element Element that requires a key.
|
1528
|
-
* @param {*} parentType element's parent's type.
|
1529
|
-
*/
|
1530
|
-
|
1531
|
-
function validateExplicitKey(element, parentType) {
|
1532
|
-
{
|
1533
|
-
if (!element._store || element._store.validated || element.key != null) {
|
1534
|
-
return;
|
1535
|
-
}
|
1536
|
-
|
1537
|
-
element._store.validated = true;
|
1538
|
-
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
1539
|
-
|
1540
|
-
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
1541
|
-
return;
|
1542
|
-
}
|
1543
|
-
|
1544
|
-
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
1545
|
-
// property, it may be the creator of the child that's responsible for
|
1546
|
-
// assigning it a key.
|
1547
|
-
|
1548
|
-
var childOwner = '';
|
1549
|
-
|
1550
|
-
if (element && element._owner != null && element._owner !== ReactSharedInternals$1.owner) {
|
1551
|
-
var ownerName = null;
|
1552
|
-
|
1553
|
-
if (typeof element._owner.tag === 'number') {
|
1554
|
-
ownerName = getComponentNameFromType(element._owner.type);
|
1555
|
-
} else if (typeof element._owner.name === 'string') {
|
1556
|
-
ownerName = element._owner.name;
|
1557
|
-
} // Give the component that originally created this child.
|
1558
|
-
|
1559
|
-
|
1560
|
-
childOwner = " It was passed a child from " + ownerName + ".";
|
1561
|
-
}
|
1562
|
-
|
1563
|
-
setCurrentlyValidatingElement(element);
|
1564
|
-
|
1565
|
-
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://react.dev/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
1566
|
-
|
1567
|
-
setCurrentlyValidatingElement(null);
|
1568
|
-
}
|
1569
|
-
}
|
1570
|
-
|
1571
|
-
function setCurrentlyValidatingElement(element) {
|
1572
|
-
{
|
1573
|
-
if (element) {
|
1574
|
-
var stack = describeUnknownElementTypeFrameInDEV(element.type);
|
1575
|
-
ReactSharedInternals$1.setExtraStackFrame(stack);
|
1576
|
-
} else {
|
1577
|
-
ReactSharedInternals$1.setExtraStackFrame(null);
|
1578
|
-
}
|
1579
|
-
}
|
1580
|
-
}
|
1581
|
-
|
1582
|
-
function getCurrentComponentErrorInfo(parentType) {
|
1583
|
-
{
|
1584
|
-
var info = getDeclarationErrorAddendum();
|
1585
|
-
|
1586
|
-
if (!info) {
|
1587
|
-
var parentName = getComponentNameFromType(parentType);
|
1588
|
-
|
1589
|
-
if (parentName) {
|
1590
|
-
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
1591
|
-
}
|
1592
|
-
}
|
1593
|
-
|
1594
|
-
return info;
|
1595
|
-
}
|
1596
|
-
}
|
1597
|
-
/**
|
1598
|
-
* Given a fragment, validate that it can only be provided with fragment props
|
1599
|
-
* @param {ReactElement} fragment
|
1600
|
-
*/
|
1601
|
-
|
1602
|
-
|
1603
|
-
function validateFragmentProps(fragment) {
|
1604
|
-
// TODO: Move this to render phase instead of at element creation.
|
1605
|
-
{
|
1606
|
-
var keys = Object.keys(fragment.props);
|
1607
|
-
|
1608
|
-
for (var i = 0; i < keys.length; i++) {
|
1609
|
-
var key = keys[i];
|
1610
|
-
|
1611
|
-
if (key !== 'children' && key !== 'key') {
|
1612
|
-
setCurrentlyValidatingElement(fragment);
|
1613
|
-
|
1614
|
-
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
1615
|
-
|
1616
|
-
setCurrentlyValidatingElement(null);
|
1617
|
-
break;
|
1618
|
-
}
|
1619
|
-
}
|
1620
|
-
}
|
1621
|
-
}
|
1622
|
-
|
1623
|
-
var SEPARATOR = '.';
|
1624
|
-
var SUBSEPARATOR = ':';
|
1625
|
-
/**
|
1626
|
-
* Escape and wrap key so it is safe to use as a reactid
|
1627
|
-
*
|
1628
|
-
* @param {string} key to be escaped.
|
1629
|
-
* @return {string} the escaped key.
|
1630
|
-
*/
|
1631
|
-
|
1632
|
-
function escape(key) {
|
1633
|
-
var escapeRegex = /[=:]/g;
|
1634
|
-
var escaperLookup = {
|
1635
|
-
'=': '=0',
|
1636
|
-
':': '=2'
|
1637
|
-
};
|
1638
|
-
var escapedString = key.replace(escapeRegex, function (match) {
|
1639
|
-
return escaperLookup[match];
|
1640
|
-
});
|
1641
|
-
return '$' + escapedString;
|
1642
|
-
}
|
1643
|
-
/**
|
1644
|
-
* TODO: Test that a single child and an array with one item have the same key
|
1645
|
-
* pattern.
|
1646
|
-
*/
|
1647
|
-
|
1648
|
-
|
1649
|
-
var didWarnAboutMaps = false;
|
1650
|
-
var userProvidedKeyEscapeRegex = /\/+/g;
|
1651
|
-
|
1652
|
-
function escapeUserProvidedKey(text) {
|
1653
|
-
return text.replace(userProvidedKeyEscapeRegex, '$&/');
|
1654
|
-
}
|
1655
|
-
/**
|
1656
|
-
* Generate a key string that identifies a element within a set.
|
1657
|
-
*
|
1658
|
-
* @param {*} element A element that could contain a manual key.
|
1659
|
-
* @param {number} index Index that is used if a manual key is not provided.
|
1660
|
-
* @return {string}
|
1661
|
-
*/
|
1662
|
-
|
1663
|
-
|
1664
|
-
function getElementKey(element, index) {
|
1665
|
-
// Do some typechecking here since we call this blindly. We want to ensure
|
1666
|
-
// that we don't block potential future ES APIs.
|
1667
|
-
if (typeof element === 'object' && element !== null && element.key != null) {
|
1668
|
-
// Explicit key
|
1669
|
-
{
|
1670
|
-
checkKeyStringCoercion(element.key);
|
1671
|
-
}
|
1672
|
-
|
1673
|
-
return escape('' + element.key);
|
1674
|
-
} // Implicit key determined by the index in the set
|
1675
|
-
|
1676
|
-
|
1677
|
-
return index.toString(36);
|
1678
|
-
}
|
1679
|
-
|
1680
|
-
function noop$1() {}
|
1681
|
-
|
1682
|
-
function resolveThenable(thenable) {
|
1683
|
-
switch (thenable.status) {
|
1684
|
-
case 'fulfilled':
|
1685
|
-
{
|
1686
|
-
var fulfilledValue = thenable.value;
|
1687
|
-
return fulfilledValue;
|
1688
|
-
}
|
1689
|
-
|
1690
|
-
case 'rejected':
|
1691
|
-
{
|
1692
|
-
var rejectedError = thenable.reason;
|
1693
|
-
throw rejectedError;
|
1694
|
-
}
|
1695
|
-
|
1696
|
-
default:
|
1697
|
-
{
|
1698
|
-
if (typeof thenable.status === 'string') {
|
1699
|
-
// Only instrument the thenable if the status if not defined. If
|
1700
|
-
// it's defined, but an unknown value, assume it's been instrumented by
|
1701
|
-
// some custom userspace implementation. We treat it as "pending".
|
1702
|
-
// Attach a dummy listener, to ensure that any lazy initialization can
|
1703
|
-
// happen. Flight lazily parses JSON when the value is actually awaited.
|
1704
|
-
thenable.then(noop$1, noop$1);
|
1705
|
-
} else {
|
1706
|
-
// This is an uncached thenable that we haven't seen before.
|
1707
|
-
// TODO: Detect infinite ping loops caused by uncached promises.
|
1708
|
-
var pendingThenable = thenable;
|
1709
|
-
pendingThenable.status = 'pending';
|
1710
|
-
pendingThenable.then(function (fulfilledValue) {
|
1711
|
-
if (thenable.status === 'pending') {
|
1712
|
-
var fulfilledThenable = thenable;
|
1713
|
-
fulfilledThenable.status = 'fulfilled';
|
1714
|
-
fulfilledThenable.value = fulfilledValue;
|
1715
|
-
}
|
1716
|
-
}, function (error) {
|
1717
|
-
if (thenable.status === 'pending') {
|
1718
|
-
var rejectedThenable = thenable;
|
1719
|
-
rejectedThenable.status = 'rejected';
|
1720
|
-
rejectedThenable.reason = error;
|
1721
|
-
}
|
1722
|
-
});
|
1723
|
-
} // Check one more time in case the thenable resolved synchronously.
|
1724
|
-
|
1725
|
-
|
1726
|
-
switch (thenable.status) {
|
1727
|
-
case 'fulfilled':
|
1728
|
-
{
|
1729
|
-
var fulfilledThenable = thenable;
|
1730
|
-
return fulfilledThenable.value;
|
1731
|
-
}
|
1732
|
-
|
1733
|
-
case 'rejected':
|
1734
|
-
{
|
1735
|
-
var rejectedThenable = thenable;
|
1736
|
-
var _rejectedError = rejectedThenable.reason;
|
1737
|
-
throw _rejectedError;
|
1738
|
-
}
|
1739
|
-
}
|
1740
|
-
}
|
1741
|
-
}
|
1742
|
-
|
1743
|
-
throw thenable;
|
1744
|
-
}
|
1745
|
-
|
1746
|
-
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
1747
|
-
var type = typeof children;
|
1748
|
-
|
1749
|
-
if (type === 'undefined' || type === 'boolean') {
|
1750
|
-
// All of the above are perceived as null.
|
1751
|
-
children = null;
|
1752
|
-
}
|
1753
|
-
|
1754
|
-
var invokeCallback = false;
|
1755
|
-
|
1756
|
-
if (children === null) {
|
1757
|
-
invokeCallback = true;
|
1758
|
-
} else {
|
1759
|
-
switch (type) {
|
1760
|
-
case 'bigint':
|
1761
|
-
case 'string':
|
1762
|
-
case 'number':
|
1763
|
-
invokeCallback = true;
|
1764
|
-
break;
|
1765
|
-
|
1766
|
-
case 'object':
|
1767
|
-
switch (children.$$typeof) {
|
1768
|
-
case REACT_ELEMENT_TYPE:
|
1769
|
-
case REACT_PORTAL_TYPE:
|
1770
|
-
invokeCallback = true;
|
1771
|
-
break;
|
1772
|
-
|
1773
|
-
case REACT_LAZY_TYPE:
|
1774
|
-
var payload = children._payload;
|
1775
|
-
var init = children._init;
|
1776
|
-
return mapIntoArray(init(payload), array, escapedPrefix, nameSoFar, callback);
|
1777
|
-
}
|
1778
|
-
|
1779
|
-
}
|
1780
|
-
}
|
1781
|
-
|
1782
|
-
if (invokeCallback) {
|
1783
|
-
var _child = children;
|
1784
|
-
var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array
|
1785
|
-
// so that it's consistent if the number of children grows:
|
1786
|
-
|
1787
|
-
var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
|
1788
|
-
|
1789
|
-
if (isArray(mappedChild)) {
|
1790
|
-
var escapedChildKey = '';
|
1791
|
-
|
1792
|
-
if (childKey != null) {
|
1793
|
-
escapedChildKey = escapeUserProvidedKey(childKey) + '/';
|
1794
|
-
}
|
1795
|
-
|
1796
|
-
mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {
|
1797
|
-
return c;
|
1798
|
-
});
|
1799
|
-
} else if (mappedChild != null) {
|
1800
|
-
if (isValidElement(mappedChild)) {
|
1801
|
-
{
|
1802
|
-
// The `if` statement here prevents auto-disabling of the safe
|
1803
|
-
// coercion ESLint rule, so we must manually disable it below.
|
1804
|
-
// $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
|
1805
|
-
if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
|
1806
|
-
checkKeyStringCoercion(mappedChild.key);
|
1807
|
-
}
|
1808
|
-
}
|
1809
|
-
|
1810
|
-
mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
|
1811
|
-
// traverseAllChildren used to do for objects as children
|
1812
|
-
escapedPrefix + ( // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
|
1813
|
-
mappedChild.key && (!_child || _child.key !== mappedChild.key) ? escapeUserProvidedKey( // $FlowFixMe[unsafe-addition]
|
1814
|
-
'' + mappedChild.key // eslint-disable-line react-internal/safe-string-coercion
|
1815
|
-
) + '/' : '') + childKey);
|
1816
|
-
}
|
1817
|
-
|
1818
|
-
array.push(mappedChild);
|
1819
|
-
}
|
1820
|
-
|
1821
|
-
return 1;
|
1822
|
-
}
|
1823
|
-
|
1824
|
-
var child;
|
1825
|
-
var nextName;
|
1826
|
-
var subtreeCount = 0; // Count of children found in the current subtree.
|
1827
|
-
|
1828
|
-
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
1829
|
-
|
1830
|
-
if (isArray(children)) {
|
1831
|
-
for (var i = 0; i < children.length; i++) {
|
1832
|
-
child = children[i];
|
1833
|
-
nextName = nextNamePrefix + getElementKey(child, i);
|
1834
|
-
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
1835
|
-
}
|
1836
|
-
} else {
|
1837
|
-
var iteratorFn = getIteratorFn(children);
|
1838
|
-
|
1839
|
-
if (typeof iteratorFn === 'function') {
|
1840
|
-
var iterableChildren = children;
|
1841
|
-
|
1842
|
-
{
|
1843
|
-
// Warn about using Maps as children
|
1844
|
-
if (iteratorFn === iterableChildren.entries) {
|
1845
|
-
if (!didWarnAboutMaps) {
|
1846
|
-
warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
|
1847
|
-
}
|
1848
|
-
|
1849
|
-
didWarnAboutMaps = true;
|
1850
|
-
}
|
1851
|
-
}
|
1852
|
-
|
1853
|
-
var iterator = iteratorFn.call(iterableChildren);
|
1854
|
-
var step;
|
1855
|
-
var ii = 0; // $FlowFixMe[incompatible-use] `iteratorFn` might return null according to typing.
|
1856
|
-
|
1857
|
-
while (!(step = iterator.next()).done) {
|
1858
|
-
child = step.value;
|
1859
|
-
nextName = nextNamePrefix + getElementKey(child, ii++);
|
1860
|
-
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
1861
|
-
}
|
1862
|
-
} else if (type === 'object') {
|
1863
|
-
if (typeof children.then === 'function') {
|
1864
|
-
return mapIntoArray(resolveThenable(children), array, escapedPrefix, nameSoFar, callback);
|
1865
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
1866
|
-
|
1867
|
-
|
1868
|
-
var childrenString = String(children);
|
1869
|
-
throw new Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.');
|
1870
|
-
}
|
1871
|
-
}
|
1872
|
-
|
1873
|
-
return subtreeCount;
|
1874
|
-
}
|
1875
|
-
/**
|
1876
|
-
* Maps children that are typically specified as `props.children`.
|
1877
|
-
*
|
1878
|
-
* See https://reactjs.org/docs/react-api.html#reactchildrenmap
|
1879
|
-
*
|
1880
|
-
* The provided mapFunction(child, index) will be called for each
|
1881
|
-
* leaf child.
|
1882
|
-
*
|
1883
|
-
* @param {?*} children Children tree container.
|
1884
|
-
* @param {function(*, int)} func The map function.
|
1885
|
-
* @param {*} context Context for mapFunction.
|
1886
|
-
* @return {object} Object containing the ordered map of results.
|
1887
|
-
*/
|
1888
|
-
|
1889
|
-
|
1890
|
-
function mapChildren(children, func, context) {
|
1891
|
-
if (children == null) {
|
1892
|
-
// $FlowFixMe limitation refining abstract types in Flow
|
1893
|
-
return children;
|
1894
|
-
}
|
1895
|
-
|
1896
|
-
var result = [];
|
1897
|
-
var count = 0;
|
1898
|
-
mapIntoArray(children, result, '', '', function (child) {
|
1899
|
-
return func.call(context, child, count++);
|
1900
|
-
});
|
1901
|
-
return result;
|
1902
|
-
}
|
1903
|
-
/**
|
1904
|
-
* Count the number of children that are typically specified as
|
1905
|
-
* `props.children`.
|
1906
|
-
*
|
1907
|
-
* See https://reactjs.org/docs/react-api.html#reactchildrencount
|
1908
|
-
*
|
1909
|
-
* @param {?*} children Children tree container.
|
1910
|
-
* @return {number} The number of children.
|
1911
|
-
*/
|
1912
|
-
|
1913
|
-
|
1914
|
-
function countChildren(children) {
|
1915
|
-
var n = 0;
|
1916
|
-
mapChildren(children, function () {
|
1917
|
-
n++; // Don't return anything
|
1918
|
-
});
|
1919
|
-
return n;
|
1920
|
-
}
|
1921
|
-
/**
|
1922
|
-
* Iterates through children that are typically specified as `props.children`.
|
1923
|
-
*
|
1924
|
-
* See https://reactjs.org/docs/react-api.html#reactchildrenforeach
|
1925
|
-
*
|
1926
|
-
* The provided forEachFunc(child, index) will be called for each
|
1927
|
-
* leaf child.
|
1928
|
-
*
|
1929
|
-
* @param {?*} children Children tree container.
|
1930
|
-
* @param {function(*, int)} forEachFunc
|
1931
|
-
* @param {*} forEachContext Context for forEachContext.
|
1932
|
-
*/
|
1933
|
-
|
1934
|
-
|
1935
|
-
function forEachChildren(children, forEachFunc, forEachContext) {
|
1936
|
-
mapChildren(children, // $FlowFixMe[missing-this-annot]
|
1937
|
-
function () {
|
1938
|
-
forEachFunc.apply(this, arguments); // Don't return anything.
|
1939
|
-
}, forEachContext);
|
1940
|
-
}
|
1941
|
-
/**
|
1942
|
-
* Flatten a children object (typically specified as `props.children`) and
|
1943
|
-
* return an array with appropriately re-keyed children.
|
1944
|
-
*
|
1945
|
-
* See https://reactjs.org/docs/react-api.html#reactchildrentoarray
|
1946
|
-
*/
|
1947
|
-
|
1948
|
-
|
1949
|
-
function toArray(children) {
|
1950
|
-
return mapChildren(children, function (child) {
|
1951
|
-
return child;
|
1952
|
-
}) || [];
|
1953
|
-
}
|
1954
|
-
/**
|
1955
|
-
* Returns the first child in a collection of children and verifies that there
|
1956
|
-
* is only one child in the collection.
|
1957
|
-
*
|
1958
|
-
* See https://reactjs.org/docs/react-api.html#reactchildrenonly
|
1959
|
-
*
|
1960
|
-
* The current implementation of this function assumes that a single child gets
|
1961
|
-
* passed without a wrapper, but the purpose of this helper function is to
|
1962
|
-
* abstract away the particular structure of children.
|
1963
|
-
*
|
1964
|
-
* @param {?object} children Child collection structure.
|
1965
|
-
* @return {ReactElement} The first and only `ReactElement` contained in the
|
1966
|
-
* structure.
|
1967
|
-
*/
|
1968
|
-
|
1969
|
-
|
1970
|
-
function onlyChild(children) {
|
1971
|
-
if (!isValidElement(children)) {
|
1972
|
-
throw new Error('React.Children.only expected to receive a single React element child.');
|
1973
|
-
}
|
1974
|
-
|
1975
|
-
return children;
|
1976
|
-
}
|
1977
|
-
|
1978
|
-
function createContext(defaultValue) {
|
1979
|
-
// TODO: Second argument used to be an optional `calculateChangedBits`
|
1980
|
-
// function. Warn to reserve for future use?
|
1981
|
-
var context = {
|
1982
|
-
$$typeof: REACT_CONTEXT_TYPE,
|
1983
|
-
// As a workaround to support multiple concurrent renderers, we categorize
|
1984
|
-
// some renderers as primary and others as secondary. We only expect
|
1985
|
-
// there to be two concurrent renderers at most: React Native (primary) and
|
1986
|
-
// Fabric (secondary); React DOM (primary) and React ART (secondary).
|
1987
|
-
// Secondary renderers store their context values on separate fields.
|
1988
|
-
_currentValue: defaultValue,
|
1989
|
-
_currentValue2: defaultValue,
|
1990
|
-
// Used to track how many concurrent renderers this context currently
|
1991
|
-
// supports within in a single renderer. Such as parallel server rendering.
|
1992
|
-
_threadCount: 0,
|
1993
|
-
// These are circular
|
1994
|
-
Provider: null,
|
1995
|
-
Consumer: null
|
1996
|
-
};
|
1997
|
-
|
1998
|
-
{
|
1999
|
-
context.Provider = context;
|
2000
|
-
context.Consumer = {
|
2001
|
-
$$typeof: REACT_CONSUMER_TYPE,
|
2002
|
-
_context: context
|
2003
|
-
};
|
2004
|
-
}
|
2005
|
-
|
2006
|
-
{
|
2007
|
-
context._currentRenderer = null;
|
2008
|
-
context._currentRenderer2 = null;
|
2009
|
-
}
|
2010
|
-
|
2011
|
-
return context;
|
2012
|
-
}
|
2013
|
-
|
2014
|
-
var Uninitialized = -1;
|
2015
|
-
var Pending = 0;
|
2016
|
-
var Resolved = 1;
|
2017
|
-
var Rejected = 2;
|
2018
|
-
|
2019
|
-
function lazyInitializer(payload) {
|
2020
|
-
if (payload._status === Uninitialized) {
|
2021
|
-
var ctor = payload._result;
|
2022
|
-
var thenable = ctor(); // Transition to the next state.
|
2023
|
-
// This might throw either because it's missing or throws. If so, we treat it
|
2024
|
-
// as still uninitialized and try again next time. Which is the same as what
|
2025
|
-
// happens if the ctor or any wrappers processing the ctor throws. This might
|
2026
|
-
// end up fixing it if the resolution was a concurrency bug.
|
2027
|
-
|
2028
|
-
thenable.then(function (moduleObject) {
|
2029
|
-
if (payload._status === Pending || payload._status === Uninitialized) {
|
2030
|
-
// Transition to the next state.
|
2031
|
-
var resolved = payload;
|
2032
|
-
resolved._status = Resolved;
|
2033
|
-
resolved._result = moduleObject;
|
2034
|
-
}
|
2035
|
-
}, function (error) {
|
2036
|
-
if (payload._status === Pending || payload._status === Uninitialized) {
|
2037
|
-
// Transition to the next state.
|
2038
|
-
var rejected = payload;
|
2039
|
-
rejected._status = Rejected;
|
2040
|
-
rejected._result = error;
|
2041
|
-
}
|
2042
|
-
});
|
2043
|
-
|
2044
|
-
if (payload._status === Uninitialized) {
|
2045
|
-
// In case, we're still uninitialized, then we're waiting for the thenable
|
2046
|
-
// to resolve. Set it as pending in the meantime.
|
2047
|
-
var pending = payload;
|
2048
|
-
pending._status = Pending;
|
2049
|
-
pending._result = thenable;
|
2050
|
-
}
|
2051
|
-
}
|
2052
|
-
|
2053
|
-
if (payload._status === Resolved) {
|
2054
|
-
var moduleObject = payload._result;
|
2055
|
-
|
2056
|
-
{
|
2057
|
-
if (moduleObject === undefined) {
|
2058
|
-
error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
|
2059
|
-
'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))\n\n" + 'Did you accidentally put curly braces around the import?', moduleObject);
|
2060
|
-
}
|
2061
|
-
}
|
2062
|
-
|
2063
|
-
{
|
2064
|
-
if (!('default' in moduleObject)) {
|
2065
|
-
error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
|
2066
|
-
'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
|
2067
|
-
}
|
2068
|
-
}
|
2069
|
-
|
2070
|
-
return moduleObject.default;
|
2071
|
-
} else {
|
2072
|
-
throw payload._result;
|
2073
|
-
}
|
2074
|
-
}
|
2075
|
-
|
2076
|
-
function lazy(ctor) {
|
2077
|
-
var payload = {
|
2078
|
-
// We use these fields to store the result.
|
2079
|
-
_status: Uninitialized,
|
2080
|
-
_result: ctor
|
2081
|
-
};
|
2082
|
-
var lazyType = {
|
2083
|
-
$$typeof: REACT_LAZY_TYPE,
|
2084
|
-
_payload: payload,
|
2085
|
-
_init: lazyInitializer
|
2086
|
-
};
|
2087
|
-
|
2088
|
-
return lazyType;
|
2089
|
-
}
|
2090
|
-
|
2091
|
-
function forwardRef(render) {
|
2092
|
-
{
|
2093
|
-
if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
|
2094
|
-
error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
|
2095
|
-
} else if (typeof render !== 'function') {
|
2096
|
-
error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
|
2097
|
-
} else {
|
2098
|
-
if (render.length !== 0 && render.length !== 2) {
|
2099
|
-
error('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.');
|
2100
|
-
}
|
2101
|
-
}
|
2102
|
-
|
2103
|
-
if (render != null) {
|
2104
|
-
if (render.defaultProps != null) {
|
2105
|
-
error('forwardRef render functions do not support defaultProps. ' + 'Did you accidentally pass a React component?');
|
2106
|
-
}
|
2107
|
-
}
|
2108
|
-
}
|
2109
|
-
|
2110
|
-
var elementType = {
|
2111
|
-
$$typeof: REACT_FORWARD_REF_TYPE,
|
2112
|
-
render: render
|
2113
|
-
};
|
2114
|
-
|
2115
|
-
{
|
2116
|
-
var ownName;
|
2117
|
-
Object.defineProperty(elementType, 'displayName', {
|
2118
|
-
enumerable: false,
|
2119
|
-
configurable: true,
|
2120
|
-
get: function () {
|
2121
|
-
return ownName;
|
2122
|
-
},
|
2123
|
-
set: function (name) {
|
2124
|
-
ownName = name; // The inner component shouldn't inherit this display name in most cases,
|
2125
|
-
// because the component may be used elsewhere.
|
2126
|
-
// But it's nice for anonymous functions to inherit the name,
|
2127
|
-
// so that our component-stack generation logic will display their frames.
|
2128
|
-
// An anonymous function generally suggests a pattern like:
|
2129
|
-
// React.forwardRef((props, ref) => {...});
|
2130
|
-
// This kind of inner function is not used elsewhere so the side effect is okay.
|
2131
|
-
|
2132
|
-
if (!render.name && !render.displayName) {
|
2133
|
-
render.displayName = name;
|
2134
|
-
}
|
2135
|
-
}
|
2136
|
-
});
|
2137
|
-
}
|
2138
|
-
|
2139
|
-
return elementType;
|
2140
|
-
}
|
2141
|
-
|
2142
|
-
function memo(type, compare) {
|
2143
|
-
{
|
2144
|
-
if (!isValidElementType(type)) {
|
2145
|
-
error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
|
2146
|
-
}
|
2147
|
-
}
|
2148
|
-
|
2149
|
-
var elementType = {
|
2150
|
-
$$typeof: REACT_MEMO_TYPE,
|
2151
|
-
type: type,
|
2152
|
-
compare: compare === undefined ? null : compare
|
2153
|
-
};
|
2154
|
-
|
2155
|
-
{
|
2156
|
-
var ownName;
|
2157
|
-
Object.defineProperty(elementType, 'displayName', {
|
2158
|
-
enumerable: false,
|
2159
|
-
configurable: true,
|
2160
|
-
get: function () {
|
2161
|
-
return ownName;
|
2162
|
-
},
|
2163
|
-
set: function (name) {
|
2164
|
-
ownName = name; // The inner component shouldn't inherit this display name in most cases,
|
2165
|
-
// because the component may be used elsewhere.
|
2166
|
-
// But it's nice for anonymous functions to inherit the name,
|
2167
|
-
// so that our component-stack generation logic will display their frames.
|
2168
|
-
// An anonymous function generally suggests a pattern like:
|
2169
|
-
// React.memo((props) => {...});
|
2170
|
-
// This kind of inner function is not used elsewhere so the side effect is okay.
|
2171
|
-
|
2172
|
-
if (!type.name && !type.displayName) {
|
2173
|
-
type.displayName = name;
|
2174
|
-
}
|
2175
|
-
}
|
2176
|
-
});
|
2177
|
-
}
|
2178
|
-
|
2179
|
-
return elementType;
|
2180
|
-
}
|
2181
|
-
|
2182
|
-
function noopCache(fn) {
|
2183
|
-
// On the client (i.e. not a Server Components environment) `cache` has
|
2184
|
-
// no caching behavior. We just return the function as-is.
|
2185
|
-
//
|
2186
|
-
// We intend to implement client caching in a future major release. In the
|
2187
|
-
// meantime, it's only exposed as an API so that Shared Components can use
|
2188
|
-
// per-request caching on the server without breaking on the client. But it
|
2189
|
-
// does mean they need to be aware of the behavioral difference.
|
2190
|
-
//
|
2191
|
-
// The rest of the behavior is the same as the server implementation — it
|
2192
|
-
// returns a new reference, extra properties like `displayName` are not
|
2193
|
-
// preserved, the length of the new function is 0, etc. That way apps can't
|
2194
|
-
// accidentally depend on those details.
|
2195
|
-
return function () {
|
2196
|
-
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
|
2197
|
-
return fn.apply(null, arguments);
|
2198
|
-
};
|
2199
|
-
}
|
2200
|
-
var cache = noopCache ;
|
2201
|
-
|
2202
|
-
function resolveDispatcher() {
|
2203
|
-
var dispatcher = ReactSharedInternals$1.H;
|
2204
|
-
|
2205
|
-
{
|
2206
|
-
if (dispatcher === null) {
|
2207
|
-
error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.');
|
2208
|
-
}
|
2209
|
-
} // Will result in a null access error if accessed outside render phase. We
|
2210
|
-
// intentionally don't throw our own error because this is in a hot path.
|
2211
|
-
// Also helps ensure this is inlined.
|
2212
|
-
|
2213
|
-
|
2214
|
-
return dispatcher;
|
2215
|
-
}
|
2216
|
-
function useContext(Context) {
|
2217
|
-
var dispatcher = resolveDispatcher();
|
2218
|
-
|
2219
|
-
{
|
2220
|
-
if (Context.$$typeof === REACT_CONSUMER_TYPE) {
|
2221
|
-
error('Calling useContext(Context.Consumer) is not supported and will cause bugs. ' + 'Did you mean to call useContext(Context) instead?');
|
2222
|
-
}
|
2223
|
-
}
|
2224
|
-
|
2225
|
-
return dispatcher.useContext(Context);
|
2226
|
-
}
|
2227
|
-
function useState(initialState) {
|
2228
|
-
var dispatcher = resolveDispatcher();
|
2229
|
-
return dispatcher.useState(initialState);
|
2230
|
-
}
|
2231
|
-
function useReducer(reducer, initialArg, init) {
|
2232
|
-
var dispatcher = resolveDispatcher();
|
2233
|
-
return dispatcher.useReducer(reducer, initialArg, init);
|
2234
|
-
}
|
2235
|
-
function useRef(initialValue) {
|
2236
|
-
var dispatcher = resolveDispatcher();
|
2237
|
-
return dispatcher.useRef(initialValue);
|
2238
|
-
}
|
2239
|
-
function useEffect(create, deps) {
|
2240
|
-
var dispatcher = resolveDispatcher();
|
2241
|
-
return dispatcher.useEffect(create, deps);
|
2242
|
-
}
|
2243
|
-
function useInsertionEffect(create, deps) {
|
2244
|
-
var dispatcher = resolveDispatcher();
|
2245
|
-
return dispatcher.useInsertionEffect(create, deps);
|
2246
|
-
}
|
2247
|
-
function useLayoutEffect(create, deps) {
|
2248
|
-
var dispatcher = resolveDispatcher();
|
2249
|
-
return dispatcher.useLayoutEffect(create, deps);
|
2250
|
-
}
|
2251
|
-
function useCallback(callback, deps) {
|
2252
|
-
var dispatcher = resolveDispatcher();
|
2253
|
-
return dispatcher.useCallback(callback, deps);
|
2254
|
-
}
|
2255
|
-
function useMemo(create, deps) {
|
2256
|
-
var dispatcher = resolveDispatcher();
|
2257
|
-
return dispatcher.useMemo(create, deps);
|
2258
|
-
}
|
2259
|
-
function useImperativeHandle(ref, create, deps) {
|
2260
|
-
var dispatcher = resolveDispatcher();
|
2261
|
-
return dispatcher.useImperativeHandle(ref, create, deps);
|
2262
|
-
}
|
2263
|
-
function useDebugValue(value, formatterFn) {
|
2264
|
-
{
|
2265
|
-
var dispatcher = resolveDispatcher();
|
2266
|
-
return dispatcher.useDebugValue(value, formatterFn);
|
2267
|
-
}
|
2268
|
-
}
|
2269
|
-
function useTransition() {
|
2270
|
-
var dispatcher = resolveDispatcher();
|
2271
|
-
return dispatcher.useTransition();
|
2272
|
-
}
|
2273
|
-
function useDeferredValue(value, initialValue) {
|
2274
|
-
var dispatcher = resolveDispatcher();
|
2275
|
-
return dispatcher.useDeferredValue(value, initialValue);
|
2276
|
-
}
|
2277
|
-
function useId() {
|
2278
|
-
var dispatcher = resolveDispatcher();
|
2279
|
-
return dispatcher.useId();
|
2280
|
-
}
|
2281
|
-
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
2282
|
-
var dispatcher = resolveDispatcher();
|
2283
|
-
return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
2284
|
-
}
|
2285
|
-
function useCacheRefresh() {
|
2286
|
-
var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional
|
2287
|
-
|
2288
|
-
return dispatcher.useCacheRefresh();
|
2289
|
-
}
|
2290
|
-
function use(usable) {
|
2291
|
-
var dispatcher = resolveDispatcher();
|
2292
|
-
return dispatcher.use(usable);
|
2293
|
-
}
|
2294
|
-
function useOptimistic(passthrough, reducer) {
|
2295
|
-
var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional
|
2296
|
-
|
2297
|
-
return dispatcher.useOptimistic(passthrough, reducer);
|
2298
|
-
}
|
2299
|
-
function useActionState(action, initialState, permalink) {
|
2300
|
-
{
|
2301
|
-
var dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional
|
2302
|
-
|
2303
|
-
return dispatcher.useActionState(action, initialState, permalink);
|
2304
|
-
}
|
2305
|
-
}
|
2306
|
-
|
2307
|
-
var enableSchedulerDebugging = false;
|
2308
|
-
var enableProfiling = false;
|
2309
|
-
var frameYieldMs = 5;
|
2310
|
-
var userBlockingPriorityTimeout = 250;
|
2311
|
-
var normalPriorityTimeout = 5000;
|
2312
|
-
var lowPriorityTimeout = 10000;
|
2313
|
-
|
2314
|
-
function push(heap, node) {
|
2315
|
-
var index = heap.length;
|
2316
|
-
heap.push(node);
|
2317
|
-
siftUp(heap, node, index);
|
2318
|
-
}
|
2319
|
-
function peek(heap) {
|
2320
|
-
return heap.length === 0 ? null : heap[0];
|
2321
|
-
}
|
2322
|
-
function pop(heap) {
|
2323
|
-
if (heap.length === 0) {
|
2324
|
-
return null;
|
2325
|
-
}
|
2326
|
-
|
2327
|
-
var first = heap[0];
|
2328
|
-
var last = heap.pop();
|
2329
|
-
|
2330
|
-
if (last !== first) {
|
2331
|
-
heap[0] = last;
|
2332
|
-
siftDown(heap, last, 0);
|
2333
|
-
}
|
2334
|
-
|
2335
|
-
return first;
|
2336
|
-
}
|
2337
|
-
|
2338
|
-
function siftUp(heap, node, i) {
|
2339
|
-
var index = i;
|
2340
|
-
|
2341
|
-
while (index > 0) {
|
2342
|
-
var parentIndex = index - 1 >>> 1;
|
2343
|
-
var parent = heap[parentIndex];
|
2344
|
-
|
2345
|
-
if (compare(parent, node) > 0) {
|
2346
|
-
// The parent is larger. Swap positions.
|
2347
|
-
heap[parentIndex] = node;
|
2348
|
-
heap[index] = parent;
|
2349
|
-
index = parentIndex;
|
2350
|
-
} else {
|
2351
|
-
// The parent is smaller. Exit.
|
2352
|
-
return;
|
2353
|
-
}
|
2354
|
-
}
|
2355
|
-
}
|
2356
|
-
|
2357
|
-
function siftDown(heap, node, i) {
|
2358
|
-
var index = i;
|
2359
|
-
var length = heap.length;
|
2360
|
-
var halfLength = length >>> 1;
|
2361
|
-
|
2362
|
-
while (index < halfLength) {
|
2363
|
-
var leftIndex = (index + 1) * 2 - 1;
|
2364
|
-
var left = heap[leftIndex];
|
2365
|
-
var rightIndex = leftIndex + 1;
|
2366
|
-
var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
|
2367
|
-
|
2368
|
-
if (compare(left, node) < 0) {
|
2369
|
-
if (rightIndex < length && compare(right, left) < 0) {
|
2370
|
-
heap[index] = right;
|
2371
|
-
heap[rightIndex] = node;
|
2372
|
-
index = rightIndex;
|
2373
|
-
} else {
|
2374
|
-
heap[index] = left;
|
2375
|
-
heap[leftIndex] = node;
|
2376
|
-
index = leftIndex;
|
2377
|
-
}
|
2378
|
-
} else if (rightIndex < length && compare(right, node) < 0) {
|
2379
|
-
heap[index] = right;
|
2380
|
-
heap[rightIndex] = node;
|
2381
|
-
index = rightIndex;
|
2382
|
-
} else {
|
2383
|
-
// Neither child is smaller. Exit.
|
2384
|
-
return;
|
2385
|
-
}
|
2386
|
-
}
|
2387
|
-
}
|
2388
|
-
|
2389
|
-
function compare(a, b) {
|
2390
|
-
// Compare sort index first, then task id.
|
2391
|
-
var diff = a.sortIndex - b.sortIndex;
|
2392
|
-
return diff !== 0 ? diff : a.id - b.id;
|
2393
|
-
}
|
2394
|
-
|
2395
|
-
// TODO: Use symbols?
|
2396
|
-
var ImmediatePriority = 1;
|
2397
|
-
var UserBlockingPriority = 2;
|
2398
|
-
var NormalPriority = 3;
|
2399
|
-
var LowPriority = 4;
|
2400
|
-
var IdlePriority = 5;
|
2401
|
-
|
2402
|
-
function markTaskErrored(task, ms) {
|
2403
|
-
}
|
2404
|
-
|
2405
|
-
/* eslint-disable no-var */
|
2406
|
-
var getCurrentTime;
|
2407
|
-
var hasPerformanceNow = // $FlowFixMe[method-unbinding]
|
2408
|
-
typeof performance === 'object' && typeof performance.now === 'function';
|
2409
|
-
|
2410
|
-
if (hasPerformanceNow) {
|
2411
|
-
var localPerformance = performance;
|
2412
|
-
|
2413
|
-
getCurrentTime = function () {
|
2414
|
-
return localPerformance.now();
|
2415
|
-
};
|
2416
|
-
} else {
|
2417
|
-
var localDate = Date;
|
2418
|
-
var initialTime = localDate.now();
|
2419
|
-
|
2420
|
-
getCurrentTime = function () {
|
2421
|
-
return localDate.now() - initialTime;
|
2422
|
-
};
|
2423
|
-
} // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
|
2424
|
-
// Math.pow(2, 30) - 1
|
2425
|
-
// 0b111111111111111111111111111111
|
2426
|
-
|
2427
|
-
|
2428
|
-
var maxSigned31BitInt = 1073741823; // Tasks are stored on a min heap
|
2429
|
-
|
2430
|
-
var taskQueue = [];
|
2431
|
-
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
|
2432
|
-
|
2433
|
-
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
|
2434
|
-
var currentTask = null;
|
2435
|
-
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrance.
|
2436
|
-
|
2437
|
-
var isPerformingWork = false;
|
2438
|
-
var isHostCallbackScheduled = false;
|
2439
|
-
var isHostTimeoutScheduled = false; // Capture local references to native APIs, in case a polyfill overrides them.
|
2440
|
-
|
2441
|
-
var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : null;
|
2442
|
-
var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : null;
|
2443
|
-
var localSetImmediate = typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom
|
2444
|
-
|
2445
|
-
function advanceTimers(currentTime) {
|
2446
|
-
// Check for tasks that are no longer delayed and add them to the queue.
|
2447
|
-
var timer = peek(timerQueue);
|
2448
|
-
|
2449
|
-
while (timer !== null) {
|
2450
|
-
if (timer.callback === null) {
|
2451
|
-
// Timer was cancelled.
|
2452
|
-
pop(timerQueue);
|
2453
|
-
} else if (timer.startTime <= currentTime) {
|
2454
|
-
// Timer fired. Transfer to the task queue.
|
2455
|
-
pop(timerQueue);
|
2456
|
-
timer.sortIndex = timer.expirationTime;
|
2457
|
-
push(taskQueue, timer);
|
2458
|
-
} else {
|
2459
|
-
// Remaining timers are pending.
|
2460
|
-
return;
|
2461
|
-
}
|
2462
|
-
|
2463
|
-
timer = peek(timerQueue);
|
2464
|
-
}
|
2465
|
-
}
|
2466
|
-
|
2467
|
-
function handleTimeout(currentTime) {
|
2468
|
-
isHostTimeoutScheduled = false;
|
2469
|
-
advanceTimers(currentTime);
|
2470
|
-
|
2471
|
-
if (!isHostCallbackScheduled) {
|
2472
|
-
if (peek(taskQueue) !== null) {
|
2473
|
-
isHostCallbackScheduled = true;
|
2474
|
-
requestHostCallback();
|
2475
|
-
} else {
|
2476
|
-
var firstTimer = peek(timerQueue);
|
2477
|
-
|
2478
|
-
if (firstTimer !== null) {
|
2479
|
-
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
|
2480
|
-
}
|
2481
|
-
}
|
2482
|
-
}
|
2483
|
-
}
|
2484
|
-
|
2485
|
-
function flushWork(initialTime) {
|
2486
|
-
|
2487
|
-
|
2488
|
-
isHostCallbackScheduled = false;
|
2489
|
-
|
2490
|
-
if (isHostTimeoutScheduled) {
|
2491
|
-
// We scheduled a timeout but it's no longer needed. Cancel it.
|
2492
|
-
isHostTimeoutScheduled = false;
|
2493
|
-
cancelHostTimeout();
|
2494
|
-
}
|
2495
|
-
|
2496
|
-
isPerformingWork = true;
|
2497
|
-
var previousPriorityLevel = currentPriorityLevel;
|
2498
|
-
|
2499
|
-
try {
|
2500
|
-
var currentTime; if (enableProfiling) ; else {
|
2501
|
-
// No catch in prod code path.
|
2502
|
-
return workLoop(initialTime);
|
2503
|
-
}
|
2504
|
-
} finally {
|
2505
|
-
currentTask = null;
|
2506
|
-
currentPriorityLevel = previousPriorityLevel;
|
2507
|
-
isPerformingWork = false;
|
2508
|
-
}
|
2509
|
-
}
|
2510
|
-
|
2511
|
-
function workLoop(initialTime) {
|
2512
|
-
var currentTime = initialTime;
|
2513
|
-
advanceTimers(currentTime);
|
2514
|
-
currentTask = peek(taskQueue);
|
2515
|
-
|
2516
|
-
while (currentTask !== null && !(enableSchedulerDebugging )) {
|
2517
|
-
if (currentTask.expirationTime > currentTime && shouldYieldToHost()) {
|
2518
|
-
// This currentTask hasn't expired, and we've reached the deadline.
|
2519
|
-
break;
|
2520
|
-
} // $FlowFixMe[incompatible-use] found when upgrading Flow
|
2521
|
-
|
2522
|
-
|
2523
|
-
var callback = currentTask.callback;
|
2524
|
-
|
2525
|
-
if (typeof callback === 'function') {
|
2526
|
-
// $FlowFixMe[incompatible-use] found when upgrading Flow
|
2527
|
-
currentTask.callback = null; // $FlowFixMe[incompatible-use] found when upgrading Flow
|
2528
|
-
|
2529
|
-
currentPriorityLevel = currentTask.priorityLevel; // $FlowFixMe[incompatible-use] found when upgrading Flow
|
2530
|
-
|
2531
|
-
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
|
2532
|
-
|
2533
|
-
var continuationCallback = callback(didUserCallbackTimeout);
|
2534
|
-
currentTime = getCurrentTime();
|
2535
|
-
|
2536
|
-
if (typeof continuationCallback === 'function') {
|
2537
|
-
// If a continuation is returned, immediately yield to the main thread
|
2538
|
-
// regardless of how much time is left in the current time slice.
|
2539
|
-
// $FlowFixMe[incompatible-use] found when upgrading Flow
|
2540
|
-
currentTask.callback = continuationCallback;
|
2541
|
-
|
2542
|
-
advanceTimers(currentTime);
|
2543
|
-
return true;
|
2544
|
-
} else {
|
2545
|
-
|
2546
|
-
if (currentTask === peek(taskQueue)) {
|
2547
|
-
pop(taskQueue);
|
2548
|
-
}
|
2549
|
-
|
2550
|
-
advanceTimers(currentTime);
|
2551
|
-
}
|
2552
|
-
} else {
|
2553
|
-
pop(taskQueue);
|
2554
|
-
}
|
2555
|
-
|
2556
|
-
currentTask = peek(taskQueue);
|
2557
|
-
} // Return whether there's additional work
|
2558
|
-
|
2559
|
-
|
2560
|
-
if (currentTask !== null) {
|
2561
|
-
return true;
|
2562
|
-
} else {
|
2563
|
-
var firstTimer = peek(timerQueue);
|
2564
|
-
|
2565
|
-
if (firstTimer !== null) {
|
2566
|
-
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
|
2567
|
-
}
|
2568
|
-
|
2569
|
-
return false;
|
2570
|
-
}
|
2571
|
-
}
|
2572
|
-
|
2573
|
-
function unstable_runWithPriority(priorityLevel, eventHandler) {
|
2574
|
-
switch (priorityLevel) {
|
2575
|
-
case ImmediatePriority:
|
2576
|
-
case UserBlockingPriority:
|
2577
|
-
case NormalPriority:
|
2578
|
-
case LowPriority:
|
2579
|
-
case IdlePriority:
|
2580
|
-
break;
|
2581
|
-
|
2582
|
-
default:
|
2583
|
-
priorityLevel = NormalPriority;
|
2584
|
-
}
|
2585
|
-
|
2586
|
-
var previousPriorityLevel = currentPriorityLevel;
|
2587
|
-
currentPriorityLevel = priorityLevel;
|
2588
|
-
|
2589
|
-
try {
|
2590
|
-
return eventHandler();
|
2591
|
-
} finally {
|
2592
|
-
currentPriorityLevel = previousPriorityLevel;
|
2593
|
-
}
|
2594
|
-
}
|
2595
|
-
|
2596
|
-
function unstable_next(eventHandler) {
|
2597
|
-
var priorityLevel;
|
2598
|
-
|
2599
|
-
switch (currentPriorityLevel) {
|
2600
|
-
case ImmediatePriority:
|
2601
|
-
case UserBlockingPriority:
|
2602
|
-
case NormalPriority:
|
2603
|
-
// Shift down to normal priority
|
2604
|
-
priorityLevel = NormalPriority;
|
2605
|
-
break;
|
2606
|
-
|
2607
|
-
default:
|
2608
|
-
// Anything lower than normal priority should remain at the current level.
|
2609
|
-
priorityLevel = currentPriorityLevel;
|
2610
|
-
break;
|
2611
|
-
}
|
2612
|
-
|
2613
|
-
var previousPriorityLevel = currentPriorityLevel;
|
2614
|
-
currentPriorityLevel = priorityLevel;
|
2615
|
-
|
2616
|
-
try {
|
2617
|
-
return eventHandler();
|
2618
|
-
} finally {
|
2619
|
-
currentPriorityLevel = previousPriorityLevel;
|
2620
|
-
}
|
2621
|
-
}
|
2622
|
-
|
2623
|
-
function unstable_wrapCallback(callback) {
|
2624
|
-
var parentPriorityLevel = currentPriorityLevel; // $FlowFixMe[incompatible-return]
|
2625
|
-
// $FlowFixMe[missing-this-annot]
|
2626
|
-
|
2627
|
-
return function () {
|
2628
|
-
// This is a fork of runWithPriority, inlined for performance.
|
2629
|
-
var previousPriorityLevel = currentPriorityLevel;
|
2630
|
-
currentPriorityLevel = parentPriorityLevel;
|
2631
|
-
|
2632
|
-
try {
|
2633
|
-
return callback.apply(this, arguments);
|
2634
|
-
} finally {
|
2635
|
-
currentPriorityLevel = previousPriorityLevel;
|
2636
|
-
}
|
2637
|
-
};
|
2638
|
-
}
|
2639
|
-
|
2640
|
-
function unstable_scheduleCallback(priorityLevel, callback, options) {
|
2641
|
-
var currentTime = getCurrentTime();
|
2642
|
-
var startTime;
|
2643
|
-
|
2644
|
-
if (typeof options === 'object' && options !== null) {
|
2645
|
-
var delay = options.delay;
|
2646
|
-
|
2647
|
-
if (typeof delay === 'number' && delay > 0) {
|
2648
|
-
startTime = currentTime + delay;
|
2649
|
-
} else {
|
2650
|
-
startTime = currentTime;
|
2651
|
-
}
|
2652
|
-
} else {
|
2653
|
-
startTime = currentTime;
|
2654
|
-
}
|
2655
|
-
|
2656
|
-
var timeout;
|
2657
|
-
|
2658
|
-
switch (priorityLevel) {
|
2659
|
-
case ImmediatePriority:
|
2660
|
-
// Times out immediately
|
2661
|
-
timeout = -1;
|
2662
|
-
break;
|
2663
|
-
|
2664
|
-
case UserBlockingPriority:
|
2665
|
-
// Eventually times out
|
2666
|
-
timeout = userBlockingPriorityTimeout;
|
2667
|
-
break;
|
2668
|
-
|
2669
|
-
case IdlePriority:
|
2670
|
-
// Never times out
|
2671
|
-
timeout = maxSigned31BitInt;
|
2672
|
-
break;
|
2673
|
-
|
2674
|
-
case LowPriority:
|
2675
|
-
// Eventually times out
|
2676
|
-
timeout = lowPriorityTimeout;
|
2677
|
-
break;
|
2678
|
-
|
2679
|
-
case NormalPriority:
|
2680
|
-
default:
|
2681
|
-
// Eventually times out
|
2682
|
-
timeout = normalPriorityTimeout;
|
2683
|
-
break;
|
2684
|
-
}
|
2685
|
-
|
2686
|
-
var expirationTime = startTime + timeout;
|
2687
|
-
var newTask = {
|
2688
|
-
id: taskIdCounter++,
|
2689
|
-
callback: callback,
|
2690
|
-
priorityLevel: priorityLevel,
|
2691
|
-
startTime: startTime,
|
2692
|
-
expirationTime: expirationTime,
|
2693
|
-
sortIndex: -1
|
2694
|
-
};
|
2695
|
-
|
2696
|
-
if (startTime > currentTime) {
|
2697
|
-
// This is a delayed task.
|
2698
|
-
newTask.sortIndex = startTime;
|
2699
|
-
push(timerQueue, newTask);
|
2700
|
-
|
2701
|
-
if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
|
2702
|
-
// All tasks are delayed, and this is the task with the earliest delay.
|
2703
|
-
if (isHostTimeoutScheduled) {
|
2704
|
-
// Cancel an existing timeout.
|
2705
|
-
cancelHostTimeout();
|
2706
|
-
} else {
|
2707
|
-
isHostTimeoutScheduled = true;
|
2708
|
-
} // Schedule a timeout.
|
2709
|
-
|
2710
|
-
|
2711
|
-
requestHostTimeout(handleTimeout, startTime - currentTime);
|
2712
|
-
}
|
2713
|
-
} else {
|
2714
|
-
newTask.sortIndex = expirationTime;
|
2715
|
-
push(taskQueue, newTask);
|
2716
|
-
// wait until the next time we yield.
|
2717
|
-
|
2718
|
-
|
2719
|
-
if (!isHostCallbackScheduled && !isPerformingWork) {
|
2720
|
-
isHostCallbackScheduled = true;
|
2721
|
-
requestHostCallback();
|
2722
|
-
}
|
2723
|
-
}
|
2724
|
-
|
2725
|
-
return newTask;
|
2726
|
-
}
|
2727
|
-
|
2728
|
-
function unstable_pauseExecution() {
|
2729
|
-
}
|
2730
|
-
|
2731
|
-
function unstable_continueExecution() {
|
2732
|
-
|
2733
|
-
if (!isHostCallbackScheduled && !isPerformingWork) {
|
2734
|
-
isHostCallbackScheduled = true;
|
2735
|
-
requestHostCallback();
|
2736
|
-
}
|
2737
|
-
}
|
2738
|
-
|
2739
|
-
function unstable_getFirstCallbackNode() {
|
2740
|
-
return peek(taskQueue);
|
2741
|
-
}
|
2742
|
-
|
2743
|
-
function unstable_cancelCallback(task) {
|
2744
|
-
// remove from the queue because you can't remove arbitrary nodes from an
|
2745
|
-
// array based heap, only the first one.)
|
2746
|
-
|
2747
|
-
|
2748
|
-
task.callback = null;
|
2749
|
-
}
|
2750
|
-
|
2751
|
-
function unstable_getCurrentPriorityLevel() {
|
2752
|
-
return currentPriorityLevel;
|
2753
|
-
}
|
2754
|
-
|
2755
|
-
var isMessageLoopRunning = false;
|
2756
|
-
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
|
2757
|
-
// thread, like user events. By default, it yields multiple times per frame.
|
2758
|
-
// It does not attempt to align with frame boundaries, since most tasks don't
|
2759
|
-
// need to be frame aligned; for those that do, use requestAnimationFrame.
|
2760
|
-
|
2761
|
-
var frameInterval = frameYieldMs;
|
2762
|
-
var startTime = -1;
|
2763
|
-
|
2764
|
-
function shouldYieldToHost() {
|
2765
|
-
var timeElapsed = getCurrentTime() - startTime;
|
2766
|
-
|
2767
|
-
if (timeElapsed < frameInterval) {
|
2768
|
-
// The main thread has only been blocked for a really short amount of time;
|
2769
|
-
// smaller than a single frame. Don't yield yet.
|
2770
|
-
return false;
|
2771
|
-
} // Yield now.
|
2772
|
-
|
2773
|
-
|
2774
|
-
return true;
|
2775
|
-
}
|
2776
|
-
|
2777
|
-
function requestPaint() {}
|
2778
|
-
|
2779
|
-
function forceFrameRate(fps) {
|
2780
|
-
if (fps < 0 || fps > 125) {
|
2781
|
-
// Using console['error'] to evade Babel and ESLint
|
2782
|
-
console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported');
|
2783
|
-
return;
|
2784
|
-
}
|
2785
|
-
|
2786
|
-
if (fps > 0) {
|
2787
|
-
frameInterval = Math.floor(1000 / fps);
|
2788
|
-
} else {
|
2789
|
-
// reset the framerate
|
2790
|
-
frameInterval = frameYieldMs;
|
2791
|
-
}
|
2792
|
-
}
|
2793
|
-
|
2794
|
-
var performWorkUntilDeadline = function () {
|
2795
|
-
if (isMessageLoopRunning) {
|
2796
|
-
var currentTime = getCurrentTime(); // Keep track of the start time so we can measure how long the main thread
|
2797
|
-
// has been blocked.
|
2798
|
-
|
2799
|
-
startTime = currentTime; // If a scheduler task throws, exit the current browser task so the
|
2800
|
-
// error can be observed.
|
2801
|
-
//
|
2802
|
-
// Intentionally not using a try-catch, since that makes some debugging
|
2803
|
-
// techniques harder. Instead, if `flushWork` errors, then `hasMoreWork` will
|
2804
|
-
// remain true, and we'll continue the work loop.
|
2805
|
-
|
2806
|
-
var hasMoreWork = true;
|
2807
|
-
|
2808
|
-
try {
|
2809
|
-
hasMoreWork = flushWork(currentTime);
|
2810
|
-
} finally {
|
2811
|
-
if (hasMoreWork) {
|
2812
|
-
// If there's more work, schedule the next message event at the end
|
2813
|
-
// of the preceding one.
|
2814
|
-
schedulePerformWorkUntilDeadline();
|
2815
|
-
} else {
|
2816
|
-
isMessageLoopRunning = false;
|
2817
|
-
}
|
2818
|
-
}
|
2819
|
-
}
|
2820
|
-
};
|
2821
|
-
|
2822
|
-
var schedulePerformWorkUntilDeadline;
|
2823
|
-
|
2824
|
-
if (typeof localSetImmediate === 'function') {
|
2825
|
-
// Node.js and old IE.
|
2826
|
-
// There's a few reasons for why we prefer setImmediate.
|
2827
|
-
//
|
2828
|
-
// Unlike MessageChannel, it doesn't prevent a Node.js process from exiting.
|
2829
|
-
// (Even though this is a DOM fork of the Scheduler, you could get here
|
2830
|
-
// with a mix of Node.js 15+, which has a MessageChannel, and jsdom.)
|
2831
|
-
// https://github.com/facebook/react/issues/20756
|
2832
|
-
//
|
2833
|
-
// But also, it runs earlier which is the semantic we want.
|
2834
|
-
// If other browsers ever implement it, it's better to use it.
|
2835
|
-
// Although both of these would be inferior to native scheduling.
|
2836
|
-
schedulePerformWorkUntilDeadline = function () {
|
2837
|
-
localSetImmediate(performWorkUntilDeadline);
|
2838
|
-
};
|
2839
|
-
} else if (typeof MessageChannel !== 'undefined') {
|
2840
|
-
// DOM and Worker environments.
|
2841
|
-
// We prefer MessageChannel because of the 4ms setTimeout clamping.
|
2842
|
-
var channel = new MessageChannel();
|
2843
|
-
var port = channel.port2;
|
2844
|
-
channel.port1.onmessage = performWorkUntilDeadline;
|
2845
|
-
|
2846
|
-
schedulePerformWorkUntilDeadline = function () {
|
2847
|
-
port.postMessage(null);
|
2848
|
-
};
|
2849
|
-
} else {
|
2850
|
-
// We should only fallback here in non-browser environments.
|
2851
|
-
schedulePerformWorkUntilDeadline = function () {
|
2852
|
-
// $FlowFixMe[not-a-function] nullable value
|
2853
|
-
localSetTimeout(performWorkUntilDeadline, 0);
|
2854
|
-
};
|
2855
|
-
}
|
2856
|
-
|
2857
|
-
function requestHostCallback() {
|
2858
|
-
if (!isMessageLoopRunning) {
|
2859
|
-
isMessageLoopRunning = true;
|
2860
|
-
schedulePerformWorkUntilDeadline();
|
2861
|
-
}
|
2862
|
-
}
|
2863
|
-
|
2864
|
-
function requestHostTimeout(callback, ms) {
|
2865
|
-
// $FlowFixMe[not-a-function] nullable value
|
2866
|
-
taskTimeoutID = localSetTimeout(function () {
|
2867
|
-
callback(getCurrentTime());
|
2868
|
-
}, ms);
|
2869
|
-
}
|
2870
|
-
|
2871
|
-
function cancelHostTimeout() {
|
2872
|
-
// $FlowFixMe[not-a-function] nullable value
|
2873
|
-
localClearTimeout(taskTimeoutID);
|
2874
|
-
taskTimeoutID = -1;
|
2875
|
-
}
|
2876
|
-
var unstable_Profiling = null;
|
2877
|
-
|
2878
|
-
var Scheduler = /*#__PURE__*/Object.freeze({
|
2879
|
-
__proto__: null,
|
2880
|
-
unstable_IdlePriority: IdlePriority,
|
2881
|
-
unstable_ImmediatePriority: ImmediatePriority,
|
2882
|
-
unstable_LowPriority: LowPriority,
|
2883
|
-
unstable_NormalPriority: NormalPriority,
|
2884
|
-
unstable_Profiling: unstable_Profiling,
|
2885
|
-
unstable_UserBlockingPriority: UserBlockingPriority,
|
2886
|
-
unstable_cancelCallback: unstable_cancelCallback,
|
2887
|
-
unstable_continueExecution: unstable_continueExecution,
|
2888
|
-
unstable_forceFrameRate: forceFrameRate,
|
2889
|
-
unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel,
|
2890
|
-
unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
|
2891
|
-
unstable_next: unstable_next,
|
2892
|
-
get unstable_now () { return getCurrentTime; },
|
2893
|
-
unstable_pauseExecution: unstable_pauseExecution,
|
2894
|
-
unstable_requestPaint: requestPaint,
|
2895
|
-
unstable_runWithPriority: unstable_runWithPriority,
|
2896
|
-
unstable_scheduleCallback: unstable_scheduleCallback,
|
2897
|
-
unstable_shouldYield: shouldYieldToHost,
|
2898
|
-
unstable_wrapCallback: unstable_wrapCallback
|
2899
|
-
});
|
2900
|
-
|
2901
|
-
var ReactSharedInternals = {
|
2902
|
-
H: null,
|
2903
|
-
C: null,
|
2904
|
-
T: null,
|
2905
|
-
// Re-export the schedule API(s) for UMD bundles.
|
2906
|
-
// This avoids introducing a dependency on a new UMD global in a minor update,
|
2907
|
-
// Since that would be a breaking change (e.g. for all existing CodeSandboxes).
|
2908
|
-
// This re-export is only required for UMD bundles;
|
2909
|
-
// CJS bundles use the shared NPM package.
|
2910
|
-
Scheduler: Scheduler
|
2911
|
-
};
|
2912
|
-
|
2913
|
-
{
|
2914
|
-
ReactSharedInternals.owner = null;
|
2915
|
-
}
|
2916
|
-
|
2917
|
-
{
|
2918
|
-
ReactSharedInternals.actQueue = null;
|
2919
|
-
ReactSharedInternals.isBatchingLegacy = false;
|
2920
|
-
ReactSharedInternals.didScheduleLegacyUpdate = false;
|
2921
|
-
ReactSharedInternals.didUsePromise = false;
|
2922
|
-
ReactSharedInternals.thrownErrors = [];
|
2923
|
-
var currentExtraStackFrame = null;
|
2924
|
-
|
2925
|
-
ReactSharedInternals.setExtraStackFrame = function (stack) {
|
2926
|
-
currentExtraStackFrame = stack;
|
2927
|
-
}; // Stack implementation injected by the current renderer.
|
2928
|
-
|
2929
|
-
|
2930
|
-
ReactSharedInternals.getCurrentStack = null;
|
2931
|
-
|
2932
|
-
ReactSharedInternals.getStackAddendum = function () {
|
2933
|
-
var stack = ''; // Add an extra top frame while an element is being validated
|
2934
|
-
|
2935
|
-
if (currentExtraStackFrame) {
|
2936
|
-
stack += currentExtraStackFrame;
|
2937
|
-
} // Delegate to the injected renderer-specific implementation
|
2938
|
-
|
2939
|
-
|
2940
|
-
var impl = ReactSharedInternals.getCurrentStack;
|
2941
|
-
|
2942
|
-
if (impl) {
|
2943
|
-
stack += impl() || '';
|
2944
|
-
}
|
2945
|
-
|
2946
|
-
return stack;
|
2947
|
-
};
|
2948
|
-
}
|
2949
|
-
|
2950
|
-
var reportGlobalError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
|
2951
|
-
// emulating an uncaught JavaScript error.
|
2952
|
-
reportError : function (error) {
|
2953
|
-
if (typeof window === 'object' && typeof window.ErrorEvent === 'function') {
|
2954
|
-
// Browser Polyfill
|
2955
|
-
var message = typeof error === 'object' && error !== null && typeof error.message === 'string' ? // eslint-disable-next-line react-internal/safe-string-coercion
|
2956
|
-
String(error.message) : // eslint-disable-next-line react-internal/safe-string-coercion
|
2957
|
-
String(error);
|
2958
|
-
var event = new window.ErrorEvent('error', {
|
2959
|
-
bubbles: true,
|
2960
|
-
cancelable: true,
|
2961
|
-
message: message,
|
2962
|
-
error: error
|
2963
|
-
});
|
2964
|
-
var shouldLog = window.dispatchEvent(event);
|
2965
|
-
|
2966
|
-
if (!shouldLog) {
|
2967
|
-
return;
|
2968
|
-
}
|
2969
|
-
} else if (typeof process === 'object' && // $FlowFixMe[method-unbinding]
|
2970
|
-
typeof process.emit === 'function') {
|
2971
|
-
// Node Polyfill
|
2972
|
-
process.emit('uncaughtException', error);
|
2973
|
-
return;
|
2974
|
-
} // eslint-disable-next-line react-internal/no-production-logging
|
2975
|
-
|
2976
|
-
|
2977
|
-
console['error'](error);
|
2978
|
-
};
|
2979
|
-
|
2980
|
-
function startTransition(scope, options) {
|
2981
|
-
var prevTransition = ReactSharedInternals$1.T; // Each renderer registers a callback to receive the return value of
|
2982
|
-
// the scope function. This is used to implement async actions.
|
2983
|
-
|
2984
|
-
var callbacks = new Set();
|
2985
|
-
var transition = {
|
2986
|
-
_callbacks: callbacks
|
2987
|
-
};
|
2988
|
-
ReactSharedInternals$1.T = transition;
|
2989
|
-
var currentTransition = ReactSharedInternals$1.T;
|
2990
|
-
|
2991
|
-
{
|
2992
|
-
ReactSharedInternals$1.T._updatedFibers = new Set();
|
2993
|
-
}
|
2994
|
-
|
2995
|
-
{
|
2996
|
-
try {
|
2997
|
-
var returnValue = scope();
|
2998
|
-
|
2999
|
-
if (typeof returnValue === 'object' && returnValue !== null && typeof returnValue.then === 'function') {
|
3000
|
-
callbacks.forEach(function (callback) {
|
3001
|
-
return callback(currentTransition, returnValue);
|
3002
|
-
});
|
3003
|
-
returnValue.then(noop, reportGlobalError);
|
3004
|
-
}
|
3005
|
-
} catch (error) {
|
3006
|
-
reportGlobalError(error);
|
3007
|
-
} finally {
|
3008
|
-
warnAboutTransitionSubscriptions(prevTransition, currentTransition);
|
3009
|
-
ReactSharedInternals$1.T = prevTransition;
|
3010
|
-
}
|
3011
|
-
}
|
3012
|
-
}
|
3013
|
-
|
3014
|
-
function warnAboutTransitionSubscriptions(prevTransition, currentTransition) {
|
3015
|
-
{
|
3016
|
-
if (prevTransition === null && currentTransition._updatedFibers) {
|
3017
|
-
var updatedFibersCount = currentTransition._updatedFibers.size;
|
3018
|
-
|
3019
|
-
currentTransition._updatedFibers.clear();
|
3020
|
-
|
3021
|
-
if (updatedFibersCount > 10) {
|
3022
|
-
warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.');
|
3023
|
-
}
|
3024
|
-
}
|
3025
|
-
}
|
3026
|
-
}
|
3027
|
-
|
3028
|
-
function noop() {}
|
3029
|
-
|
3030
|
-
var didWarnAboutMessageChannel = false;
|
3031
|
-
var enqueueTaskImpl = null;
|
3032
|
-
function enqueueTask(task) {
|
3033
|
-
if (enqueueTaskImpl === null) {
|
3034
|
-
try {
|
3035
|
-
// read require off the module object to get around the bundlers.
|
3036
|
-
// we don't want them to detect a require and bundle a Node polyfill.
|
3037
|
-
var requireString = ('require' + Math.random()).slice(0, 7);
|
3038
|
-
var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
|
3039
|
-
// version of setImmediate, bypassing fake timers if any.
|
3040
|
-
|
3041
|
-
enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
|
3042
|
-
} catch (_err) {
|
3043
|
-
// we're in a browser
|
3044
|
-
// we can't use regular timers because they may still be faked
|
3045
|
-
// so we try MessageChannel+postMessage instead
|
3046
|
-
enqueueTaskImpl = function (callback) {
|
3047
|
-
{
|
3048
|
-
if (didWarnAboutMessageChannel === false) {
|
3049
|
-
didWarnAboutMessageChannel = true;
|
3050
|
-
|
3051
|
-
if (typeof MessageChannel === 'undefined') {
|
3052
|
-
error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
|
3053
|
-
}
|
3054
|
-
}
|
3055
|
-
}
|
3056
|
-
|
3057
|
-
var channel = new MessageChannel();
|
3058
|
-
channel.port1.onmessage = callback;
|
3059
|
-
channel.port2.postMessage(undefined);
|
3060
|
-
};
|
3061
|
-
}
|
3062
|
-
}
|
3063
|
-
|
3064
|
-
return enqueueTaskImpl(task);
|
3065
|
-
}
|
3066
|
-
|
3067
|
-
// number of `act` scopes on the stack.
|
3068
|
-
|
3069
|
-
var actScopeDepth = 0; // We only warn the first time you neglect to await an async `act` scope.
|
3070
|
-
|
3071
|
-
var didWarnNoAwaitAct = false;
|
3072
|
-
|
3073
|
-
function aggregateErrors(errors) {
|
3074
|
-
if (errors.length > 1 && typeof AggregateError === 'function') {
|
3075
|
-
// eslint-disable-next-line no-undef
|
3076
|
-
return new AggregateError(errors);
|
3077
|
-
}
|
3078
|
-
|
3079
|
-
return errors[0];
|
3080
|
-
}
|
3081
|
-
|
3082
|
-
function act(callback) {
|
3083
|
-
{
|
3084
|
-
// When ReactSharedInternals.actQueue is not null, it signals to React that
|
3085
|
-
// we're currently inside an `act` scope. React will push all its tasks to
|
3086
|
-
// this queue instead of scheduling them with platform APIs.
|
3087
|
-
//
|
3088
|
-
// We set this to an empty array when we first enter an `act` scope, and
|
3089
|
-
// only unset it once we've left the outermost `act` scope — remember that
|
3090
|
-
// `act` calls can be nested.
|
3091
|
-
//
|
3092
|
-
// If we're already inside an `act` scope, reuse the existing queue.
|
3093
|
-
var prevIsBatchingLegacy = false;
|
3094
|
-
var prevActQueue = ReactSharedInternals.actQueue;
|
3095
|
-
var prevActScopeDepth = actScopeDepth;
|
3096
|
-
actScopeDepth++;
|
3097
|
-
var queue = ReactSharedInternals.actQueue = prevActQueue !== null ? prevActQueue : []; // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only
|
3098
|
-
|
3099
|
-
var result; // This tracks whether the `act` call is awaited. In certain cases, not
|
3100
|
-
// awaiting it is a mistake, so we will detect that and warn.
|
3101
|
-
|
3102
|
-
var didAwaitActCall = false;
|
3103
|
-
|
3104
|
-
try {
|
3105
|
-
// Reset this to `false` right before entering the React work loop. The
|
3106
|
-
// only place we ever read this fields is just below, right after running
|
3107
|
-
// the callback. So we don't need to reset after the callback runs.
|
3108
|
-
if (!disableLegacyMode) ;
|
3109
|
-
|
3110
|
-
result = callback();
|
3111
|
-
var didScheduleLegacyUpdate = !disableLegacyMode ? ReactSharedInternals.didScheduleLegacyUpdate : false; // Replicate behavior of original `act` implementation in legacy mode,
|
3112
|
-
// which flushed updates immediately after the scope function exits, even
|
3113
|
-
// if it's an async function.
|
3114
|
-
|
3115
|
-
if (!prevIsBatchingLegacy && didScheduleLegacyUpdate) {
|
3116
|
-
flushActQueue(queue);
|
3117
|
-
} // `isBatchingLegacy` gets reset using the regular stack, not the async
|
3118
|
-
// one used to track `act` scopes. Why, you may be wondering? Because
|
3119
|
-
// that's how it worked before version 18. Yes, it's confusing! We should
|
3120
|
-
// delete legacy mode!!
|
3121
|
-
|
3122
|
-
|
3123
|
-
if (!disableLegacyMode) ;
|
3124
|
-
} catch (error) {
|
3125
|
-
// `isBatchingLegacy` gets reset using the regular stack, not the async
|
3126
|
-
// one used to track `act` scopes. Why, you may be wondering? Because
|
3127
|
-
// that's how it worked before version 18. Yes, it's confusing! We should
|
3128
|
-
// delete legacy mode!!
|
3129
|
-
ReactSharedInternals.thrownErrors.push(error);
|
3130
|
-
}
|
3131
|
-
|
3132
|
-
if (ReactSharedInternals.thrownErrors.length > 0) {
|
3133
|
-
|
3134
|
-
popActScope(prevActQueue, prevActScopeDepth);
|
3135
|
-
var thrownError = aggregateErrors(ReactSharedInternals.thrownErrors);
|
3136
|
-
ReactSharedInternals.thrownErrors.length = 0;
|
3137
|
-
throw thrownError;
|
3138
|
-
}
|
3139
|
-
|
3140
|
-
if (result !== null && typeof result === 'object' && // $FlowFixMe[method-unbinding]
|
3141
|
-
typeof result.then === 'function') {
|
3142
|
-
// A promise/thenable was returned from the callback. Wait for it to
|
3143
|
-
// resolve before flushing the queue.
|
3144
|
-
//
|
3145
|
-
// If `act` were implemented as an async function, this whole block could
|
3146
|
-
// be a single `await` call. That's really the only difference between
|
3147
|
-
// this branch and the next one.
|
3148
|
-
var thenable = result; // Warn if the an `act` call with an async scope is not awaited. In a
|
3149
|
-
// future release, consider making this an error.
|
3150
|
-
|
3151
|
-
queueSeveralMicrotasks(function () {
|
3152
|
-
if (!didAwaitActCall && !didWarnNoAwaitAct) {
|
3153
|
-
didWarnNoAwaitAct = true;
|
3154
|
-
|
3155
|
-
error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, ' + 'interleaving multiple act calls and mixing their ' + 'scopes. ' + 'You should - await act(async () => ...);');
|
3156
|
-
}
|
3157
|
-
});
|
3158
|
-
return {
|
3159
|
-
then: function (resolve, reject) {
|
3160
|
-
didAwaitActCall = true;
|
3161
|
-
thenable.then(function (returnValue) {
|
3162
|
-
popActScope(prevActQueue, prevActScopeDepth);
|
3163
|
-
|
3164
|
-
if (prevActScopeDepth === 0) {
|
3165
|
-
// We're exiting the outermost `act` scope. Flush the queue.
|
3166
|
-
try {
|
3167
|
-
flushActQueue(queue);
|
3168
|
-
enqueueTask(function () {
|
3169
|
-
return (// Recursively flush tasks scheduled by a microtask.
|
3170
|
-
recursivelyFlushAsyncActWork(returnValue, resolve, reject)
|
3171
|
-
);
|
3172
|
-
});
|
3173
|
-
} catch (error) {
|
3174
|
-
// `thenable` might not be a real promise, and `flushActQueue`
|
3175
|
-
// might throw, so we need to wrap `flushActQueue` in a
|
3176
|
-
// try/catch.
|
3177
|
-
ReactSharedInternals.thrownErrors.push(error);
|
3178
|
-
}
|
3179
|
-
|
3180
|
-
if (ReactSharedInternals.thrownErrors.length > 0) {
|
3181
|
-
var _thrownError = aggregateErrors(ReactSharedInternals.thrownErrors);
|
3182
|
-
|
3183
|
-
ReactSharedInternals.thrownErrors.length = 0;
|
3184
|
-
reject(_thrownError);
|
3185
|
-
}
|
3186
|
-
} else {
|
3187
|
-
resolve(returnValue);
|
3188
|
-
}
|
3189
|
-
}, function (error) {
|
3190
|
-
popActScope(prevActQueue, prevActScopeDepth);
|
3191
|
-
|
3192
|
-
if (ReactSharedInternals.thrownErrors.length > 0) {
|
3193
|
-
var _thrownError2 = aggregateErrors(ReactSharedInternals.thrownErrors);
|
3194
|
-
|
3195
|
-
ReactSharedInternals.thrownErrors.length = 0;
|
3196
|
-
reject(_thrownError2);
|
3197
|
-
} else {
|
3198
|
-
reject(error);
|
3199
|
-
}
|
3200
|
-
});
|
3201
|
-
}
|
3202
|
-
};
|
3203
|
-
} else {
|
3204
|
-
var returnValue = result; // The callback is not an async function. Exit the current
|
3205
|
-
// scope immediately.
|
3206
|
-
|
3207
|
-
popActScope(prevActQueue, prevActScopeDepth);
|
3208
|
-
|
3209
|
-
if (prevActScopeDepth === 0) {
|
3210
|
-
// We're exiting the outermost `act` scope. Flush the queue.
|
3211
|
-
flushActQueue(queue); // If the queue is not empty, it implies that we intentionally yielded
|
3212
|
-
// to the main thread, because something suspended. We will continue
|
3213
|
-
// in an asynchronous task.
|
3214
|
-
//
|
3215
|
-
// Warn if something suspends but the `act` call is not awaited.
|
3216
|
-
// In a future release, consider making this an error.
|
3217
|
-
|
3218
|
-
if (queue.length !== 0) {
|
3219
|
-
queueSeveralMicrotasks(function () {
|
3220
|
-
if (!didAwaitActCall && !didWarnNoAwaitAct) {
|
3221
|
-
didWarnNoAwaitAct = true;
|
3222
|
-
|
3223
|
-
error('A component suspended inside an `act` scope, but the ' + '`act` call was not awaited. When testing React ' + 'components that depend on asynchronous data, you must ' + 'await the result:\n\n' + 'await act(() => ...)');
|
3224
|
-
}
|
3225
|
-
});
|
3226
|
-
} // Like many things in this module, this is next part is confusing.
|
3227
|
-
//
|
3228
|
-
// We do not currently require every `act` call that is passed a
|
3229
|
-
// callback to be awaited, through arguably we should. Since this
|
3230
|
-
// callback was synchronous, we need to exit the current scope before
|
3231
|
-
// returning.
|
3232
|
-
//
|
3233
|
-
// However, if thenable we're about to return *is* awaited, we'll
|
3234
|
-
// immediately restore the current scope. So it shouldn't observable.
|
3235
|
-
//
|
3236
|
-
// This doesn't affect the case where the scope callback is async,
|
3237
|
-
// because we always require those calls to be awaited.
|
3238
|
-
//
|
3239
|
-
// TODO: In a future version, consider always requiring all `act` calls
|
3240
|
-
// to be awaited, regardless of whether the callback is sync or async.
|
3241
|
-
|
3242
|
-
|
3243
|
-
ReactSharedInternals.actQueue = null;
|
3244
|
-
}
|
3245
|
-
|
3246
|
-
if (ReactSharedInternals.thrownErrors.length > 0) {
|
3247
|
-
var _thrownError3 = aggregateErrors(ReactSharedInternals.thrownErrors);
|
3248
|
-
|
3249
|
-
ReactSharedInternals.thrownErrors.length = 0;
|
3250
|
-
throw _thrownError3;
|
3251
|
-
}
|
3252
|
-
|
3253
|
-
return {
|
3254
|
-
then: function (resolve, reject) {
|
3255
|
-
didAwaitActCall = true;
|
3256
|
-
|
3257
|
-
if (prevActScopeDepth === 0) {
|
3258
|
-
// If the `act` call is awaited, restore the queue we were
|
3259
|
-
// using before (see long comment above) so we can flush it.
|
3260
|
-
ReactSharedInternals.actQueue = queue;
|
3261
|
-
enqueueTask(function () {
|
3262
|
-
return (// Recursively flush tasks scheduled by a microtask.
|
3263
|
-
recursivelyFlushAsyncActWork(returnValue, resolve, reject)
|
3264
|
-
);
|
3265
|
-
});
|
3266
|
-
} else {
|
3267
|
-
resolve(returnValue);
|
3268
|
-
}
|
3269
|
-
}
|
3270
|
-
};
|
3271
|
-
}
|
3272
|
-
}
|
3273
|
-
}
|
3274
|
-
|
3275
|
-
function popActScope(prevActQueue, prevActScopeDepth) {
|
3276
|
-
{
|
3277
|
-
if (prevActScopeDepth !== actScopeDepth - 1) {
|
3278
|
-
error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
|
3279
|
-
}
|
3280
|
-
|
3281
|
-
actScopeDepth = prevActScopeDepth;
|
3282
|
-
}
|
3283
|
-
}
|
3284
|
-
|
3285
|
-
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
3286
|
-
{
|
3287
|
-
// Check if any tasks were scheduled asynchronously.
|
3288
|
-
var queue = ReactSharedInternals.actQueue;
|
3289
|
-
|
3290
|
-
if (queue !== null) {
|
3291
|
-
if (queue.length !== 0) {
|
3292
|
-
// Async tasks were scheduled, mostly likely in a microtask.
|
3293
|
-
// Keep flushing until there are no more.
|
3294
|
-
try {
|
3295
|
-
flushActQueue(queue); // The work we just performed may have schedule additional async
|
3296
|
-
// tasks. Wait a macrotask and check again.
|
3297
|
-
|
3298
|
-
enqueueTask(function () {
|
3299
|
-
return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
3300
|
-
});
|
3301
|
-
return;
|
3302
|
-
} catch (error) {
|
3303
|
-
// Leave remaining tasks on the queue if something throws.
|
3304
|
-
ReactSharedInternals.thrownErrors.push(error);
|
3305
|
-
}
|
3306
|
-
} else {
|
3307
|
-
// The queue is empty. We can finish.
|
3308
|
-
ReactSharedInternals.actQueue = null;
|
3309
|
-
}
|
3310
|
-
}
|
3311
|
-
|
3312
|
-
if (ReactSharedInternals.thrownErrors.length > 0) {
|
3313
|
-
var thrownError = aggregateErrors(ReactSharedInternals.thrownErrors);
|
3314
|
-
ReactSharedInternals.thrownErrors.length = 0;
|
3315
|
-
reject(thrownError);
|
3316
|
-
} else {
|
3317
|
-
resolve(returnValue);
|
3318
|
-
}
|
3319
|
-
}
|
3320
|
-
}
|
3321
|
-
|
3322
|
-
var isFlushing = false;
|
3323
|
-
|
3324
|
-
function flushActQueue(queue) {
|
3325
|
-
{
|
3326
|
-
if (!isFlushing) {
|
3327
|
-
// Prevent re-entrance.
|
3328
|
-
isFlushing = true;
|
3329
|
-
var i = 0;
|
3330
|
-
|
3331
|
-
try {
|
3332
|
-
for (; i < queue.length; i++) {
|
3333
|
-
var callback = queue[i];
|
3334
|
-
|
3335
|
-
do {
|
3336
|
-
ReactSharedInternals.didUsePromise = false;
|
3337
|
-
var continuation = callback(false);
|
3338
|
-
|
3339
|
-
if (continuation !== null) {
|
3340
|
-
if (ReactSharedInternals.didUsePromise) {
|
3341
|
-
// The component just suspended. Yield to the main thread in
|
3342
|
-
// case the promise is already resolved. If so, it will ping in
|
3343
|
-
// a microtask and we can resume without unwinding the stack.
|
3344
|
-
queue[i] = callback;
|
3345
|
-
queue.splice(0, i);
|
3346
|
-
return;
|
3347
|
-
}
|
3348
|
-
|
3349
|
-
callback = continuation;
|
3350
|
-
} else {
|
3351
|
-
break;
|
3352
|
-
}
|
3353
|
-
} while (true);
|
3354
|
-
} // We flushed the entire queue.
|
3355
|
-
|
3356
|
-
|
3357
|
-
queue.length = 0;
|
3358
|
-
} catch (error) {
|
3359
|
-
// If something throws, leave the remaining callbacks on the queue.
|
3360
|
-
queue.splice(0, i + 1);
|
3361
|
-
ReactSharedInternals.thrownErrors.push(error);
|
3362
|
-
} finally {
|
3363
|
-
isFlushing = false;
|
3364
|
-
}
|
3365
|
-
}
|
3366
|
-
}
|
3367
|
-
} // Some of our warnings attempt to detect if the `act` call is awaited by
|
3368
|
-
// checking in an asynchronous task. Wait a few microtasks before checking. The
|
3369
|
-
// only reason one isn't sufficient is we want to accommodate the case where an
|
3370
|
-
// `act` call is returned from an async function without first being awaited,
|
3371
|
-
// since that's a somewhat common pattern. If you do this too many times in a
|
3372
|
-
// nested sequence, you might get a warning, but you can always fix by awaiting
|
3373
|
-
// the call.
|
3374
|
-
//
|
3375
|
-
// A macrotask would also work (and is the fallback) but depending on the test
|
3376
|
-
// environment it may cause the warning to fire too late.
|
3377
|
-
|
3378
|
-
|
3379
|
-
var queueSeveralMicrotasks = typeof queueMicrotask === 'function' ? function (callback) {
|
3380
|
-
queueMicrotask(function () {
|
3381
|
-
return queueMicrotask(callback);
|
3382
|
-
});
|
3383
|
-
} : enqueueTask;
|
3384
|
-
|
3385
|
-
var Children = {
|
3386
|
-
map: mapChildren,
|
3387
|
-
forEach: forEachChildren,
|
3388
|
-
count: countChildren,
|
3389
|
-
toArray: toArray,
|
3390
|
-
only: onlyChild
|
3391
|
-
};
|
3392
|
-
|
3393
|
-
exports.Children = Children;
|
3394
|
-
exports.Component = Component;
|
3395
|
-
exports.Fragment = REACT_FRAGMENT_TYPE;
|
3396
|
-
exports.Profiler = REACT_PROFILER_TYPE;
|
3397
|
-
exports.PureComponent = PureComponent;
|
3398
|
-
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
3399
|
-
exports.Suspense = REACT_SUSPENSE_TYPE;
|
3400
|
-
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
3401
|
-
exports.act = act;
|
3402
|
-
exports.cache = cache;
|
3403
|
-
exports.cloneElement = cloneElement;
|
3404
|
-
exports.createContext = createContext;
|
3405
|
-
exports.createElement = createElement;
|
3406
|
-
exports.createRef = createRef;
|
3407
|
-
exports.forwardRef = forwardRef;
|
3408
|
-
exports.isValidElement = isValidElement;
|
3409
|
-
exports.lazy = lazy;
|
3410
|
-
exports.memo = memo;
|
3411
|
-
exports.startTransition = startTransition;
|
3412
|
-
exports.unstable_useCacheRefresh = useCacheRefresh;
|
3413
|
-
exports.use = use;
|
3414
|
-
exports.useActionState = useActionState;
|
3415
|
-
exports.useCallback = useCallback;
|
3416
|
-
exports.useContext = useContext;
|
3417
|
-
exports.useDebugValue = useDebugValue;
|
3418
|
-
exports.useDeferredValue = useDeferredValue;
|
3419
|
-
exports.useEffect = useEffect;
|
3420
|
-
exports.useId = useId;
|
3421
|
-
exports.useImperativeHandle = useImperativeHandle;
|
3422
|
-
exports.useInsertionEffect = useInsertionEffect;
|
3423
|
-
exports.useLayoutEffect = useLayoutEffect;
|
3424
|
-
exports.useMemo = useMemo;
|
3425
|
-
exports.useOptimistic = useOptimistic;
|
3426
|
-
exports.useReducer = useReducer;
|
3427
|
-
exports.useRef = useRef;
|
3428
|
-
exports.useState = useState;
|
3429
|
-
exports.useSyncExternalStore = useSyncExternalStore;
|
3430
|
-
exports.useTransition = useTransition;
|
3431
|
-
exports.version = ReactVersion;
|
3432
|
-
|
3433
|
-
}));
|