react 16.14.0 → 17.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build-info.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "branch": "pull/18344",
3
- "buildNumber": "106499",
4
- "checksum": "7fe5a2e",
5
- "commit": "da834083c",
2
+ "branch": "master",
3
+ "buildNumber": "216201",
4
+ "checksum": "6a2f7e9",
5
+ "commit": "4ead6b530",
6
6
  "environment": "ci",
7
- "reactVersion": "16.12.0-da834083c"
7
+ "reactVersion": "17.0.0-alpha.0-4ead6b530"
8
8
  }
@@ -1,4 +1,4 @@
1
- /** @license React v16.14.0
1
+ /** @license React v17.0.0-rc.3
2
2
  * react-jsx-dev-runtime.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -14,6 +14,7 @@ if (process.env.NODE_ENV !== "production") {
14
14
  'use strict';
15
15
 
16
16
  var React = require('react');
17
+ var _assign = require('object-assign');
17
18
 
18
19
  // ATTENTION
19
20
  // When adding new symbols to this file,
@@ -98,16 +99,7 @@ function printWarning(level, format, args) {
98
99
  // update consoleWithStackDev.www.js as well.
99
100
  {
100
101
  var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
101
- var stack = '';
102
-
103
- if (currentlyValidatingElement) {
104
- var name = getComponentName(currentlyValidatingElement.type);
105
- var owner = currentlyValidatingElement._owner;
106
- stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
107
- }
108
-
109
- stack += ReactDebugCurrentFrame.getStackAddendum();
110
-
102
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
111
103
 
112
104
  if (stack !== '') {
113
105
  format += '%s';
@@ -148,49 +140,16 @@ function isValidElementType(type) {
148
140
 
149
141
  return false;
150
142
  }
151
- var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
152
- function describeComponentFrame (name, source, ownerName) {
153
- var sourceInfo = '';
154
-
155
- if (source) {
156
- var path = source.fileName;
157
- var fileName = path.replace(BEFORE_SLASH_RE, '');
158
-
159
- {
160
- // In DEV, include code for a common special case:
161
- // prefer "folder/index.js" instead of just "index.js".
162
- if (/^index\./.test(fileName)) {
163
- var match = path.match(BEFORE_SLASH_RE);
164
-
165
- if (match) {
166
- var pathBeforeSlash = match[1];
167
-
168
- if (pathBeforeSlash) {
169
- var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
170
- fileName = folderName + '/' + fileName;
171
- }
172
- }
173
- }
174
- }
175
-
176
- sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
177
- } else if (ownerName) {
178
- sourceInfo = ' (created by ' + ownerName + ')';
179
- }
180
-
181
- return '\n in ' + (name || 'Unknown') + sourceInfo;
182
- }
183
-
184
- var Resolved = 1;
185
- function refineResolvedLazyComponent(lazyComponent) {
186
- return lazyComponent._status === Resolved ? lazyComponent._result : null;
187
- }
188
143
 
189
144
  function getWrappedName(outerType, innerType, wrapperName) {
190
145
  var functionName = innerType.displayName || innerType.name || '';
191
146
  return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
192
147
  }
193
148
 
149
+ function getContextName(type) {
150
+ return type.displayName || 'Context';
151
+ }
152
+
194
153
  function getComponentName(type) {
195
154
  if (type == null) {
196
155
  // Host root, text node or just invalid type.
@@ -219,7 +178,7 @@ function getComponentName(type) {
219
178
  return 'Portal';
220
179
 
221
180
  case REACT_PROFILER_TYPE:
222
- return "Profiler";
181
+ return 'Profiler';
223
182
 
224
183
  case REACT_STRICT_MODE_TYPE:
225
184
  return 'StrictMode';
@@ -234,10 +193,12 @@ function getComponentName(type) {
234
193
  if (typeof type === 'object') {
235
194
  switch (type.$$typeof) {
236
195
  case REACT_CONTEXT_TYPE:
237
- return 'Context.Consumer';
196
+ var context = type;
197
+ return getContextName(context) + '.Consumer';
238
198
 
239
199
  case REACT_PROVIDER_TYPE:
240
- return 'Context.Provider';
200
+ var provider = type;
201
+ return getContextName(provider._context) + '.Provider';
241
202
 
242
203
  case REACT_FORWARD_REF_TYPE:
243
204
  return getWrappedName(type, type.render, 'ForwardRef');
@@ -246,30 +207,375 @@ function getComponentName(type) {
246
207
  return getComponentName(type.type);
247
208
 
248
209
  case REACT_BLOCK_TYPE:
249
- return getComponentName(type.render);
210
+ return getComponentName(type._render);
250
211
 
251
212
  case REACT_LAZY_TYPE:
252
213
  {
253
- var thenable = type;
254
- var resolvedThenable = refineResolvedLazyComponent(thenable);
214
+ var lazyComponent = type;
215
+ var payload = lazyComponent._payload;
216
+ var init = lazyComponent._init;
217
+
218
+ try {
219
+ return getComponentName(init(payload));
220
+ } catch (x) {
221
+ return null;
222
+ }
223
+ }
224
+ }
225
+ }
226
+
227
+ return null;
228
+ }
229
+
230
+ // Helpers to patch console.logs to avoid logging during side-effect free
231
+ // replaying on render function. This currently only patches the object
232
+ // lazily which won't cover if the log function was extracted eagerly.
233
+ // We could also eagerly patch the method.
234
+ var disabledDepth = 0;
235
+ var prevLog;
236
+ var prevInfo;
237
+ var prevWarn;
238
+ var prevError;
239
+ var prevGroup;
240
+ var prevGroupCollapsed;
241
+ var prevGroupEnd;
242
+
243
+ function disabledLog() {}
244
+
245
+ disabledLog.__reactDisabledLog = true;
246
+ function disableLogs() {
247
+ {
248
+ if (disabledDepth === 0) {
249
+ /* eslint-disable react-internal/no-production-logging */
250
+ prevLog = console.log;
251
+ prevInfo = console.info;
252
+ prevWarn = console.warn;
253
+ prevError = console.error;
254
+ prevGroup = console.group;
255
+ prevGroupCollapsed = console.groupCollapsed;
256
+ prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
257
+
258
+ var props = {
259
+ configurable: true,
260
+ enumerable: true,
261
+ value: disabledLog,
262
+ writable: true
263
+ }; // $FlowFixMe Flow thinks console is immutable.
264
+
265
+ Object.defineProperties(console, {
266
+ info: props,
267
+ log: props,
268
+ warn: props,
269
+ error: props,
270
+ group: props,
271
+ groupCollapsed: props,
272
+ groupEnd: props
273
+ });
274
+ /* eslint-enable react-internal/no-production-logging */
275
+ }
276
+
277
+ disabledDepth++;
278
+ }
279
+ }
280
+ function reenableLogs() {
281
+ {
282
+ disabledDepth--;
283
+
284
+ if (disabledDepth === 0) {
285
+ /* eslint-disable react-internal/no-production-logging */
286
+ var props = {
287
+ configurable: true,
288
+ enumerable: true,
289
+ writable: true
290
+ }; // $FlowFixMe Flow thinks console is immutable.
291
+
292
+ Object.defineProperties(console, {
293
+ log: _assign({}, props, {
294
+ value: prevLog
295
+ }),
296
+ info: _assign({}, props, {
297
+ value: prevInfo
298
+ }),
299
+ warn: _assign({}, props, {
300
+ value: prevWarn
301
+ }),
302
+ error: _assign({}, props, {
303
+ value: prevError
304
+ }),
305
+ group: _assign({}, props, {
306
+ value: prevGroup
307
+ }),
308
+ groupCollapsed: _assign({}, props, {
309
+ value: prevGroupCollapsed
310
+ }),
311
+ groupEnd: _assign({}, props, {
312
+ value: prevGroupEnd
313
+ })
314
+ });
315
+ /* eslint-enable react-internal/no-production-logging */
316
+ }
317
+
318
+ if (disabledDepth < 0) {
319
+ error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
320
+ }
321
+ }
322
+ }
323
+
324
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
325
+ var prefix;
326
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
327
+ {
328
+ if (prefix === undefined) {
329
+ // Extract the VM specific prefix used by each line.
330
+ try {
331
+ throw Error();
332
+ } catch (x) {
333
+ var match = x.stack.trim().match(/\n( *(at )?)/);
334
+ prefix = match && match[1] || '';
335
+ }
336
+ } // We use the prefix to ensure our stacks line up with native stack frames.
337
+
338
+
339
+ return '\n' + prefix + name;
340
+ }
341
+ }
342
+ var reentry = false;
343
+ var componentFrameCache;
344
+
345
+ {
346
+ var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
347
+ componentFrameCache = new PossiblyWeakMap();
348
+ }
349
+
350
+ function describeNativeComponentFrame(fn, construct) {
351
+ // If something asked for a stack inside a fake render, it should get ignored.
352
+ if (!fn || reentry) {
353
+ return '';
354
+ }
355
+
356
+ {
357
+ var frame = componentFrameCache.get(fn);
358
+
359
+ if (frame !== undefined) {
360
+ return frame;
361
+ }
362
+ }
363
+
364
+ var control;
365
+ reentry = true;
366
+ var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
367
+
368
+ Error.prepareStackTrace = undefined;
369
+ var previousDispatcher;
370
+
371
+ {
372
+ previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
373
+ // for warnings.
374
+
375
+ ReactCurrentDispatcher.current = null;
376
+ disableLogs();
377
+ }
378
+
379
+ try {
380
+ // This should throw.
381
+ if (construct) {
382
+ // Something should be setting the props in the constructor.
383
+ var Fake = function () {
384
+ throw Error();
385
+ }; // $FlowFixMe
386
+
387
+
388
+ Object.defineProperty(Fake.prototype, 'props', {
389
+ set: function () {
390
+ // We use a throwing setter instead of frozen or non-writable props
391
+ // because that won't throw in a non-strict mode function.
392
+ throw Error();
393
+ }
394
+ });
395
+
396
+ if (typeof Reflect === 'object' && Reflect.construct) {
397
+ // We construct a different control for this case to include any extra
398
+ // frames added by the construct call.
399
+ try {
400
+ Reflect.construct(Fake, []);
401
+ } catch (x) {
402
+ control = x;
403
+ }
255
404
 
256
- if (resolvedThenable) {
257
- return getComponentName(resolvedThenable);
405
+ Reflect.construct(fn, [], Fake);
406
+ } else {
407
+ try {
408
+ Fake.call();
409
+ } catch (x) {
410
+ control = x;
411
+ }
412
+
413
+ fn.call(Fake.prototype);
414
+ }
415
+ } else {
416
+ try {
417
+ throw Error();
418
+ } catch (x) {
419
+ control = x;
420
+ }
421
+
422
+ fn();
423
+ }
424
+ } catch (sample) {
425
+ // This is inlined manually because closure doesn't do it for us.
426
+ if (sample && control && typeof sample.stack === 'string') {
427
+ // This extracts the first frame from the sample that isn't also in the control.
428
+ // Skipping one frame that we assume is the frame that calls the two.
429
+ var sampleLines = sample.stack.split('\n');
430
+ var controlLines = control.stack.split('\n');
431
+ var s = sampleLines.length - 1;
432
+ var c = controlLines.length - 1;
433
+
434
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
435
+ // We expect at least one stack frame to be shared.
436
+ // Typically this will be the root most one. However, stack frames may be
437
+ // cut off due to maximum stack limits. In this case, one maybe cut off
438
+ // earlier than the other. We assume that the sample is longer or the same
439
+ // and there for cut off earlier. So we should find the root most frame in
440
+ // the sample somewhere in the control.
441
+ c--;
442
+ }
443
+
444
+ for (; s >= 1 && c >= 0; s--, c--) {
445
+ // Next we find the first one that isn't the same which should be the
446
+ // frame that called our sample function and the control.
447
+ if (sampleLines[s] !== controlLines[c]) {
448
+ // In V8, the first line is describing the message but other VMs don't.
449
+ // If we're about to return the first line, and the control is also on the same
450
+ // line, that's a pretty good indicator that our sample threw at same line as
451
+ // the control. I.e. before we entered the sample frame. So we ignore this result.
452
+ // This can happen if you passed a class to function component, or non-function.
453
+ if (s !== 1 || c !== 1) {
454
+ do {
455
+ s--;
456
+ c--; // We may still have similar intermediate frames from the construct call.
457
+ // The next one that isn't the same should be our match though.
458
+
459
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
460
+ // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
461
+ var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
462
+
463
+ {
464
+ if (typeof fn === 'function') {
465
+ componentFrameCache.set(fn, _frame);
466
+ }
467
+ } // Return the line we found.
468
+
469
+
470
+ return _frame;
471
+ }
472
+ } while (s >= 1 && c >= 0);
258
473
  }
259
474
 
260
475
  break;
261
476
  }
477
+ }
478
+ }
479
+ } finally {
480
+ reentry = false;
481
+
482
+ {
483
+ ReactCurrentDispatcher.current = previousDispatcher;
484
+ reenableLogs();
485
+ }
486
+
487
+ Error.prepareStackTrace = previousPrepareStackTrace;
488
+ } // Fallback to just using the name if we couldn't make it throw.
489
+
490
+
491
+ var name = fn ? fn.displayName || fn.name : '';
492
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
493
+
494
+ {
495
+ if (typeof fn === 'function') {
496
+ componentFrameCache.set(fn, syntheticFrame);
262
497
  }
263
498
  }
264
499
 
265
- return null;
500
+ return syntheticFrame;
501
+ }
502
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
503
+ {
504
+ return describeNativeComponentFrame(fn, false);
505
+ }
506
+ }
507
+
508
+ function shouldConstruct(Component) {
509
+ var prototype = Component.prototype;
510
+ return !!(prototype && prototype.isReactComponent);
266
511
  }
512
+
513
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
514
+
515
+ if (type == null) {
516
+ return '';
517
+ }
518
+
519
+ if (typeof type === 'function') {
520
+ {
521
+ return describeNativeComponentFrame(type, shouldConstruct(type));
522
+ }
523
+ }
524
+
525
+ if (typeof type === 'string') {
526
+ return describeBuiltInComponentFrame(type);
527
+ }
528
+
529
+ switch (type) {
530
+ case REACT_SUSPENSE_TYPE:
531
+ return describeBuiltInComponentFrame('Suspense');
532
+
533
+ case REACT_SUSPENSE_LIST_TYPE:
534
+ return describeBuiltInComponentFrame('SuspenseList');
535
+ }
536
+
537
+ if (typeof type === 'object') {
538
+ switch (type.$$typeof) {
539
+ case REACT_FORWARD_REF_TYPE:
540
+ return describeFunctionComponentFrame(type.render);
541
+
542
+ case REACT_MEMO_TYPE:
543
+ // Memo may contain any component type so we recursively resolve it.
544
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
545
+
546
+ case REACT_BLOCK_TYPE:
547
+ return describeFunctionComponentFrame(type._render);
548
+
549
+ case REACT_LAZY_TYPE:
550
+ {
551
+ var lazyComponent = type;
552
+ var payload = lazyComponent._payload;
553
+ var init = lazyComponent._init;
554
+
555
+ try {
556
+ // Lazy may contain any component type so we recursively resolve it.
557
+ return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
558
+ } catch (x) {}
559
+ }
560
+ }
561
+ }
562
+
563
+ return '';
564
+ }
565
+
267
566
  var loggedTypeFailures = {};
268
567
  var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
269
- var currentlyValidatingElement = null;
270
568
 
271
569
  function setCurrentlyValidatingElement(element) {
272
- currentlyValidatingElement = element;
570
+ {
571
+ if (element) {
572
+ var owner = element._owner;
573
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
574
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
575
+ } else {
576
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
577
+ }
578
+ }
273
579
  }
274
580
 
275
581
  function checkPropTypes(typeSpecs, values, location, componentName, element) {
@@ -559,7 +865,15 @@ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
559
865
  var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
560
866
 
561
867
  function setCurrentlyValidatingElement$1(element) {
562
- currentlyValidatingElement = element;
868
+ {
869
+ if (element) {
870
+ var owner = element._owner;
871
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
872
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
873
+ } else {
874
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
875
+ }
876
+ }
563
877
  }
564
878
 
565
879
  var propTypesMisspellWarningShown;